From 319f4c431c4e0da909b8ff87442dcf0d3accde50 Mon Sep 17 00:00:00 2001 From: Phillip Stevens Date: Tue, 17 Oct 2017 10:40:18 +1100 Subject: [PATCH 1/4] yaz180 - initiate subtype=yabios (#458) * yaz180 - polish config_*.m4 files * rc2014 - update config_*.m4 #414 * yaz180 - i2c WIP1 & defc Basic interrupts * mod needs brackets * yaz180 - add missing config_basic.m4 * yaz180 - IDE 9% faster * rc2014 - IDE 9% faster * yaz180 - i2c WIP2 * yaz180 - initiate subtype=yabios --- lib/config/yaz180.cfg | 4 +- .../target/yaz180/config/config_pca9665.m4 | 59 ++---- .../yaz180/config/config_pca9665.m4.bak | 72 ++------ .../target/yaz180/config/config_target.m4 | 13 -- .../target/yaz180/config/config_target.m4.bak | 13 -- .../target/yaz180/config_yaz180.h | 50 +----- .../target/yaz180/config_yaz180_private.inc | 6 +- .../target/yaz180/config_yaz180_public.inc | 13 +- .../_DEVELOPMENT/target/yaz180/crt_config.bak | 22 +-- .../_DEVELOPMENT/target/yaz180/crt_config.inc | 10 +- .../target/yaz180/crt_preamble.asm | 17 +- .../yaz180/device/am9511a/__am9511a_data.asm | 3 +- .../yaz180/device/asci/__asci0_bss_Rx.asm | 25 +-- .../yaz180/device/asci/__asci0_bss_Tx.asm | 25 +-- .../target/yaz180/driver/i2c/__i2c1_data.asm | 14 +- .../target/yaz180/driver/i2c/__i2c2_data.asm | 13 +- .../target/yaz180/driver/ide/__ide_data.asm | 3 +- .../target/yaz180/startup/yaz180_crt_0.asm.m4 | 6 +- .../_DEVELOPMENT/target/yaz180/yaz180_crt.asm | 169 +++++++++--------- .../target/yaz180/yaz180_crt.asm.m4 | 4 +- 20 files changed, 198 insertions(+), 343 deletions(-) diff --git a/lib/config/yaz180.cfg b/lib/config/yaz180.cfg index a24efcc0c4..aaa17ed8da 100644 --- a/lib/config/yaz180.cfg +++ b/lib/config/yaz180.cfg @@ -7,7 +7,7 @@ CRT0 DESTDIR/lib/yaz180_crt0 # Any default options you want - these are options to zcc which are fed # through to compiler, assembler etc as necessary -OPTIONS -mz180 -v -O2 -SO2 -iquote. -D__Z88DK -D__YAZ180 -D__Z180 -clib=sdcc_iy -subtype=basic +OPTIONS -mz180 -v -O2 -SO2 -iquote. -D__Z88DK -D__YAZ180 -D__Z180 -clib=sdcc_iy -subtype=basic_dcio # Add special post-processing for yaz180 COPTRULESCPU DESTDIR/lib/yaz180_rules.1 @@ -19,7 +19,7 @@ CLIB sdcc_iy -compiler=sdcc --reserve-regs-iy -D__SDCC -D__SDCC_IY -Ca-D__SD CLIB clang_ix -compiler=clang -D__SDCC -D__SDCC_IX -Ca-D__SDCC -Ca-D__SDCC_IX -Cl-D__SDCC -Cl-D__SDCC_IX -nostdlib -isystemDESTDIR/include/_DEVELOPMENT/sdcc -Ca-IDESTDIR/libsrc/_DEVELOPMENT/target/yaz180 -lyaz180 -LDESTDIR/libsrc/_DEVELOPMENT/lib/sdcc_ix -Cl-IDESTDIR/libsrc/_DEVELOPMENT/target/yaz180 -crt0=DESTDIR/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm.m4 CLIB clang_iy -compiler=clang --reserve-regs-iy -D__SDCC -D__SDCC_IY -Ca-D__SDCC -Ca-D__SDCC_IY -Cl-D__SDCC -Cl-D__SDCC_IY -nostdlib -isystemDESTDIR/include/_DEVELOPMENT/sdcc -Ca-IDESTDIR/libsrc/_DEVELOPMENT/target/yaz180 -lyaz180 -LDESTDIR/libsrc/_DEVELOPMENT/lib/sdcc_iy -Cl-IDESTDIR/libsrc/_DEVELOPMENT/target/yaz180 -crt0=DESTDIR/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm.m4 -SUBTYPE asci0 -startup=0 -Cz"+rom --ihex" +SUBTYPE yabios -startup=0 -Cz"+rom --ihex" SUBTYPE basic -startup=16 -Cz"+rom --ihex" SUBTYPE basic_dcio -startup=17 -Cz"+rom --ihex" SUBTYPE none -startup=256 -Cz"+rom --ihex" diff --git a/libsrc/_DEVELOPMENT/target/yaz180/config/config_pca9665.m4 b/libsrc/_DEVELOPMENT/target/yaz180/config/config_pca9665.m4 index ce92e262ae..7621bcd788 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/config/config_pca9665.m4 +++ b/libsrc/_DEVELOPMENT/target/yaz180/config/config_pca9665.m4 @@ -4,6 +4,12 @@ divert(-1) # PCA9665 CONFIGURATION # +# PCA9665 I2C I/O Buffer Definitions + +define(`__IO_I2C_RX_SIZE', 68) # Size of the Rx Buffer, 68 Bytes +define(`__IO_I2C_TX_SIZE', 68) # Size of the Tx Buffer, 68 Bytes + # PCA9665 has 68 Byte Tx/Rx hardware buffer + # PCA9665 I2C I/O Register MSB addressing define(`__IO_I2C1_PORT_MSB', 0x`'eval((__IO_PCA9665_1_PORT_BASE/0x0100)&0xE0,16)) # distinguish the device address, with MSB @@ -106,6 +112,9 @@ dnl# ifdef(`CFG_ASM_PUB', ` +PUBLIC `__IO_I2C_RX_SIZE' +PUBLIC `__IO_I2C_TX_SIZE' + PUBLIC `__IO_I2C1_PORT_MSB' PUBLIC `__IO_I2C2_PORT_MSB' @@ -182,6 +191,9 @@ dnl# ifdef(`CFG_ASM_DEF', ` +defc `__IO_I2C_RX_SIZE' = __IO_I2C_RX_SIZE +defc `__IO_I2C_TX_SIZE' = __IO_I2C_TX_SIZE + defc `__IO_I2C1_PORT_MSB' = __IO_I2C1_PORT_MSB defc `__IO_I2C2_PORT_MSB' = __IO_I2C2_PORT_MSB @@ -258,51 +270,8 @@ dnl# ifdef(`CFG_C_DEF', ` - -`#undef' `__YAZ180' -`#define' `__YAZ180' __YAZ180 - -`#define' `__ASCI0_RX_SIZE' __ASCI0_RX_SIZE -`#define' `__ASCI0_TX_SIZE' __ASCI0_TX_SIZE - -`#define' `__ASCI1_RX_SIZE' __ASCI1_RX_SIZE -`#define' `__ASCI1_TX_SIZE' __ASCI1_TX_SIZE - -`#define' `__APU_CMD_SIZE' __APU_CMD_SIZE -`#define' `__APU_PTR_SIZE' __APU_PTR_SIZE - -`#define' `__I2C_RX_SIZE' __I2C_RX_SIZE -`#define' `__I2C_TX_SIZE' __I2C_TX_SIZE - -`#define' `__IO_BREAK' __IO_BREAK - -`#define' `__IO_PIO_PORT_BASE' __IO_PIO_PORT_BASE - -`#define' `__IO_PIO_PORT_A' __IO_PIO_PORT_A -`#define' `__IO_PIO_PORT_B' __IO_PIO_PORT_B -`#define' `__IO_PIO_PORT_C' __IO_PIO_PORT_C -`#define' `__IO_PIO_CONTROL' __IO_PIO_CONTROL - -`#define' `__IO_PIO_CNTL_00' __IO_PIO_CNTL_00 -`#define' `__IO_PIO_CNTL_01' __IO_PIO_CNTL_01 -`#define' `__IO_PIO_CNTL_02' __IO_PIO_CNTL_02 -`#define' `__IO_PIO_CNTL_03' __IO_PIO_CNTL_03 - -`#define' `__IO_PIO_CNTL_04' __IO_PIO_CNTL_04 -`#define' `__IO_PIO_CNTL_05' __IO_PIO_CNTL_05 -`#define' `__IO_PIO_CNTL_06' __IO_PIO_CNTL_06 -`#define' `__IO_PIO_CNTL_07' __IO_PIO_CNTL_07 - -`#define' `__IO_PIO_CNTL_08' __IO_PIO_CNTL_08 -`#define' `__IO_PIO_CNTL_09' __IO_PIO_CNTL_09 -`#define' `__IO_PIO_CNTL_10' __IO_PIO_CNTL_10 -`#define' `__IO_PIO_CNTL_11' __IO_PIO_CNTL_11 - -`#define' `__IO_PIO_CNTL_12' __IO_PIO_CNTL_12 -`#define' `__IO_PIO_CNTL_13' __IO_PIO_CNTL_13 -`#define' `__IO_PIO_CNTL_14' __IO_PIO_CNTL_14 -`#define' `__IO_PIO_CNTL_15' __IO_PIO_CNTL_15 - +`#define' `__IO_I2C_RX_SIZE' __IO_I2C_RX_SIZE +`#define' `__IO_I2C_TX_SIZE' __IO_I2C_TX_SIZE `#define' `__IO_PCA9665_1_PORT_BASE' __IO_PCA9665_1_PORT_BASE `#define' `__IO_PCA9665_2_PORT_BASE' __IO_PCA9665_2_PORT_BASE diff --git a/libsrc/_DEVELOPMENT/target/yaz180/config/config_pca9665.m4.bak b/libsrc/_DEVELOPMENT/target/yaz180/config/config_pca9665.m4.bak index 09316189d6..0bb8452456 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/config/config_pca9665.m4.bak +++ b/libsrc/_DEVELOPMENT/target/yaz180/config/config_pca9665.m4.bak @@ -4,6 +4,12 @@ divert(-1) # PCA9665 CONFIGURATION # +# PCA9665 I2C I/O Buffer Definitions + +define(`__IO_I2C_RX_SIZE', 68) # Size of the Rx Buffer, 68 Bytes +define(`__IO_I2C_TX_SIZE', 68) # Size of the Tx Buffer, 68 Bytes + # PCA9665 has 68 Byte Tx/Rx hardware buffer + # PCA9665 I2C I/O Register MSB addressing define(`__IO_I2C1_PORT_MSB', 0x`'eval((__IO_PCA9665_1_PORT_BASE/0x0100)&0xE0,16)) # distinguish the device address, with MSB @@ -73,8 +79,7 @@ define(`__IO_I2C_CON_MODE', 0x01) # Mode, 1 = buffered, 0 = byte # Bits in I2C_CON Echo, for CPU control -define(`__IO_I2C_CON_ECHO_BUS_STOP', 0x10) # We are finished the sentence -define(`__IO_I2C_CON_ECHO_SI', 0x08) # Serial Interrupt Received +define(`__IO_I2C_CON_ECHO_BUS_STOPPED', 0x10) # We are finished the sentence define(`__IO_I2C_CON_ECHO_BUS_RESTART', 0x04) # Bus Restart Requested define(`__IO_I2C_CON_ECHO_BUS_ILLEGAL', 0x02) # Unexpected Bus Response @@ -107,6 +112,10 @@ dnl# ifdef(`CFG_ASM_PUB', ` + +PUBLIC `__IO_I2C_RX_SIZE' +PUBLIC `__IO_I2C_TX_SIZE' + PUBLIC `__IO_I2C1_PORT_MSB' PUBLIC `__IO_I2C2_PORT_MSB' @@ -162,8 +171,7 @@ PUBLIC `__IO_I2C_CON_STO' PUBLIC `__IO_I2C_CON_SI' PUBLIC `__IO_I2C_CON_MODE' -PUBLIC `__IO_I2C_CON_ECHO_BUS_STOP' -PUBLIC `__IO_I2C_CON_ECHO_SI' +PUBLIC `__IO_I2C_CON_ECHO_BUS_STOPPED' PUBLIC `__IO_I2C_CON_ECHO_BUS_RESTART' PUBLIC `__IO_I2C_CON_ECHO_BUS_ILLEGAL' @@ -184,6 +192,9 @@ dnl# ifdef(`CFG_ASM_DEF', ` +defc `__IO_I2C_RX_SIZE' = __IO_I2C_RX_SIZE +defc `__IO_I2C_TX_SIZE' = __IO_I2C_TX_SIZE + defc `__IO_I2C1_PORT_MSB' = __IO_I2C1_PORT_MSB defc `__IO_I2C2_PORT_MSB' = __IO_I2C2_PORT_MSB @@ -239,8 +250,7 @@ defc `__IO_I2C_CON_STO' = __IO_I2C_CON_STO defc `__IO_I2C_CON_SI' = __IO_I2C_CON_SI defc `__IO_I2C_CON_MODE' = __IO_I2C_CON_MODE -defc `__IO_I2C_CON_ECHO_BUS_STOP' = __IO_I2C_CON_ECHO_BUS_STOP -defc `__IO_I2C_CON_ECHO_SI' = __IO_I2C_CON_ECHO_SI +defc `__IO_I2C_CON_ECHO_BUS_STOPPED' = __IO_I2C_CON_ECHO_BUS_STOPPED defc `__IO_I2C_CON_ECHO_BUS_RESTART' = __IO_I2C_CON_ECHO_BUS_RESTART defc `__IO_I2C_CON_ECHO_BUS_ILLEGAL' = __IO_I2C_CON_ECHO_BUS_ILLEGAL @@ -261,51 +271,8 @@ dnl# ifdef(`CFG_C_DEF', ` - -`#undef' `__YAZ180' -`#define' `__YAZ180' __YAZ180 - -`#define' `__ASCI0_RX_SIZE' __ASCI0_RX_SIZE -`#define' `__ASCI0_TX_SIZE' __ASCI0_TX_SIZE - -`#define' `__ASCI1_RX_SIZE' __ASCI1_RX_SIZE -`#define' `__ASCI1_TX_SIZE' __ASCI1_TX_SIZE - -`#define' `__APU_CMD_SIZE' __APU_CMD_SIZE -`#define' `__APU_PTR_SIZE' __APU_PTR_SIZE - -`#define' `__I2C_RX_SIZE' __I2C_RX_SIZE -`#define' `__I2C_TX_SIZE' __I2C_TX_SIZE - -`#define' `__IO_BREAK' __IO_BREAK - -`#define' `__IO_PIO_PORT_BASE' __IO_PIO_PORT_BASE - -`#define' `__IO_PIO_PORT_A' __IO_PIO_PORT_A -`#define' `__IO_PIO_PORT_B' __IO_PIO_PORT_B -`#define' `__IO_PIO_PORT_C' __IO_PIO_PORT_C -`#define' `__IO_PIO_CONTROL' __IO_PIO_CONTROL - -`#define' `__IO_PIO_CNTL_00' __IO_PIO_CNTL_00 -`#define' `__IO_PIO_CNTL_01' __IO_PIO_CNTL_01 -`#define' `__IO_PIO_CNTL_02' __IO_PIO_CNTL_02 -`#define' `__IO_PIO_CNTL_03' __IO_PIO_CNTL_03 - -`#define' `__IO_PIO_CNTL_04' __IO_PIO_CNTL_04 -`#define' `__IO_PIO_CNTL_05' __IO_PIO_CNTL_05 -`#define' `__IO_PIO_CNTL_06' __IO_PIO_CNTL_06 -`#define' `__IO_PIO_CNTL_07' __IO_PIO_CNTL_07 - -`#define' `__IO_PIO_CNTL_08' __IO_PIO_CNTL_08 -`#define' `__IO_PIO_CNTL_09' __IO_PIO_CNTL_09 -`#define' `__IO_PIO_CNTL_10' __IO_PIO_CNTL_10 -`#define' `__IO_PIO_CNTL_11' __IO_PIO_CNTL_11 - -`#define' `__IO_PIO_CNTL_12' __IO_PIO_CNTL_12 -`#define' `__IO_PIO_CNTL_13' __IO_PIO_CNTL_13 -`#define' `__IO_PIO_CNTL_14' __IO_PIO_CNTL_14 -`#define' `__IO_PIO_CNTL_15' __IO_PIO_CNTL_15 - +`#define' `__IO_I2C_RX_SIZE' __IO_I2C_RX_SIZE +`#define' `__IO_I2C_TX_SIZE' __IO_I2C_TX_SIZE `#define' `__IO_PCA9665_1_PORT_BASE' __IO_PCA9665_1_PORT_BASE `#define' `__IO_PCA9665_2_PORT_BASE' __IO_PCA9665_2_PORT_BASE @@ -365,8 +332,7 @@ ifdef(`CFG_C_DEF', `#define' `__IO_I2C_CON_SI' __IO_I2C_CON_SI `#define' `__IO_I2C_CON_MODE' __IO_I2C_CON_MODE -`#define' `__IO_I2C_CON_ECHO_BUS_STOP' __IO_I2C_CON_ECHO_BUS_STOP -`#define' `__IO_I2C_CON_ECHO_SI' __IO_I2C_CON_ECHO_SI +`#define' `__IO_I2C_CON_ECHO_BUS_STOPPED' __IO_I2C_CON_ECHO_BUS_STOPPED `#define' `__IO_I2C_CON_ECHO_BUS_RESTART' __IO_I2C_CON_ECHO_BUS_RESTART `#define' `__IO_I2C_CON_ECHO_BUS_ILLEGAL' __IO_I2C_CON_ECHO_BUS_ILLEGAL diff --git a/libsrc/_DEVELOPMENT/target/yaz180/config/config_target.m4 b/libsrc/_DEVELOPMENT/target/yaz180/config/config_target.m4 index 35e441d537..b6fed04985 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/config/config_target.m4 +++ b/libsrc/_DEVELOPMENT/target/yaz180/config/config_target.m4 @@ -43,10 +43,6 @@ define(`__IO_PIO_PORT_BASE', 0x4000) # Base Address for 82C55 # PCA9665 I2C Definitions -define(`__I2C_RX_SIZE', 0x100) # Size of the Rx Buffer, 256 Bytes -define(`__I2C_TX_SIZE', 0x100) # Size of the Tx Buffer, 256 Bytes - # PCA9665 has 68 Byte Tx/Rx hardware buffer - define(`__IO_PCA9665_1_PORT_BASE', 0xA000) # Base Address for PCA9665 1 I/O define(`__IO_PCA9665_2_PORT_BASE', 0x8000) # Base Address for PCA9665 2 I/O @@ -85,9 +81,6 @@ PUBLIC `__IO_BREAK' PUBLIC `__IO_PIO_PORT_BASE' -PUBLIC `__I2C_RX_SIZE' -PUBLIC `__I2C_TX_SIZE' - PUBLIC `__IO_PCA9665_1_PORT_BASE' PUBLIC `__IO_PCA9665_2_PORT_BASE' @@ -119,9 +112,6 @@ defc `__IO_BREAK' = __IO_BREAK defc `__IO_PIO_PORT_BASE' = __IO_PIO_PORT_BASE -defc `__I2C_RX_SIZE' = __I2C_RX_SIZE -defc `__I2C_TX_SIZE' = __I2C_TX_SIZE - defc `__IO_PCA9665_1_PORT_BASE' = __IO_PCA9665_1_PORT_BASE defc `__IO_PCA9665_2_PORT_BASE' = __IO_PCA9665_2_PORT_BASE @@ -154,9 +144,6 @@ ifdef(`CFG_C_DEF', `#define' `__IO_PIO_PORT_BASE' __IO_PIO_PORT_BASE -`#define' `__I2C_RX_SIZE' __I2C_RX_SIZE -`#define' `__I2C_TX_SIZE' __I2C_TX_SIZE - `#define' `__IO_PCA9665_1_PORT_BASE' __IO_PCA9665_1_PORT_BASE `#define' `__IO_PCA9665_2_PORT_BASE' __IO_PCA9665_2_PORT_BASE diff --git a/libsrc/_DEVELOPMENT/target/yaz180/config/config_target.m4.bak b/libsrc/_DEVELOPMENT/target/yaz180/config/config_target.m4.bak index 35e441d537..b6fed04985 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/config/config_target.m4.bak +++ b/libsrc/_DEVELOPMENT/target/yaz180/config/config_target.m4.bak @@ -43,10 +43,6 @@ define(`__IO_PIO_PORT_BASE', 0x4000) # Base Address for 82C55 # PCA9665 I2C Definitions -define(`__I2C_RX_SIZE', 0x100) # Size of the Rx Buffer, 256 Bytes -define(`__I2C_TX_SIZE', 0x100) # Size of the Tx Buffer, 256 Bytes - # PCA9665 has 68 Byte Tx/Rx hardware buffer - define(`__IO_PCA9665_1_PORT_BASE', 0xA000) # Base Address for PCA9665 1 I/O define(`__IO_PCA9665_2_PORT_BASE', 0x8000) # Base Address for PCA9665 2 I/O @@ -85,9 +81,6 @@ PUBLIC `__IO_BREAK' PUBLIC `__IO_PIO_PORT_BASE' -PUBLIC `__I2C_RX_SIZE' -PUBLIC `__I2C_TX_SIZE' - PUBLIC `__IO_PCA9665_1_PORT_BASE' PUBLIC `__IO_PCA9665_2_PORT_BASE' @@ -119,9 +112,6 @@ defc `__IO_BREAK' = __IO_BREAK defc `__IO_PIO_PORT_BASE' = __IO_PIO_PORT_BASE -defc `__I2C_RX_SIZE' = __I2C_RX_SIZE -defc `__I2C_TX_SIZE' = __I2C_TX_SIZE - defc `__IO_PCA9665_1_PORT_BASE' = __IO_PCA9665_1_PORT_BASE defc `__IO_PCA9665_2_PORT_BASE' = __IO_PCA9665_2_PORT_BASE @@ -154,9 +144,6 @@ ifdef(`CFG_C_DEF', `#define' `__IO_PIO_PORT_BASE' __IO_PIO_PORT_BASE -`#define' `__I2C_RX_SIZE' __I2C_RX_SIZE -`#define' `__I2C_TX_SIZE' __I2C_TX_SIZE - `#define' `__IO_PCA9665_1_PORT_BASE' __IO_PCA9665_1_PORT_BASE `#define' `__IO_PCA9665_2_PORT_BASE' __IO_PCA9665_2_PORT_BASE diff --git a/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180.h b/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180.h index 305f8f1752..9d991b9c2b 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180.h +++ b/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180.h @@ -53,9 +53,6 @@ #define __IO_PIO_PORT_BASE 0x4000 -#define __I2C_RX_SIZE 0x100 -#define __I2C_TX_SIZE 0x100 - #define __IO_PCA9665_1_PORT_BASE 0xA000 #define __IO_PCA9665_2_PORT_BASE 0x8000 @@ -822,51 +819,8 @@ - -#undef __YAZ180 -#define __YAZ180 1 - -#define __ASCI0_RX_SIZE 0x100 -#define __ASCI0_TX_SIZE 0x100 - -#define __ASCI1_RX_SIZE 0x100 -#define __ASCI1_TX_SIZE 0x100 - -#define __APU_CMD_SIZE 0x100 -#define __APU_PTR_SIZE 0x100 - -#define __I2C_RX_SIZE 0x100 -#define __I2C_TX_SIZE 0x100 - -#define __IO_BREAK 0x2000 - -#define __IO_PIO_PORT_BASE 0x4000 - -#define __IO_PIO_PORT_A 0x4000 -#define __IO_PIO_PORT_B 0x4001 -#define __IO_PIO_PORT_C 0x4002 -#define __IO_PIO_CONTROL 0x4003 - -#define __IO_PIO_CNTL_00 0x80 -#define __IO_PIO_CNTL_01 0x81 -#define __IO_PIO_CNTL_02 0x82 -#define __IO_PIO_CNTL_03 0x83 - -#define __IO_PIO_CNTL_04 0x88 -#define __IO_PIO_CNTL_05 0x89 -#define __IO_PIO_CNTL_06 0x8A -#define __IO_PIO_CNTL_07 0x8B - -#define __IO_PIO_CNTL_08 0x90 -#define __IO_PIO_CNTL_09 0x91 -#define __IO_PIO_CNTL_10 0x92 -#define __IO_PIO_CNTL_11 0x83 - -#define __IO_PIO_CNTL_12 0x98 -#define __IO_PIO_CNTL_13 0x99 -#define __IO_PIO_CNTL_14 0x9A -#define __IO_PIO_CNTL_15 0x9B - +#define __IO_I2C_RX_SIZE 68 +#define __IO_I2C_TX_SIZE 68 #define __IO_PCA9665_1_PORT_BASE 0xA000 #define __IO_PCA9665_2_PORT_BASE 0x8000 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_private.inc b/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_private.inc index 0d391012d3..1789b54b22 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_private.inc +++ b/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_private.inc @@ -48,9 +48,6 @@ defc __IO_BREAK = 0x2000 defc __IO_PIO_PORT_BASE = 0x4000 -defc __I2C_RX_SIZE = 0x100 -defc __I2C_TX_SIZE = 0x100 - defc __IO_PCA9665_1_PORT_BASE = 0xA000 defc __IO_PCA9665_2_PORT_BASE = 0x8000 @@ -816,6 +813,9 @@ defc __IO_APU_OP_PUPI = 0x1A +defc __IO_I2C_RX_SIZE = 68 +defc __IO_I2C_TX_SIZE = 68 + defc __IO_I2C1_PORT_MSB = 0xa0 defc __IO_I2C2_PORT_MSB = 0x80 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_public.inc b/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_public.inc index bfd88122bb..879f98d0be 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_public.inc +++ b/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_public.inc @@ -47,9 +47,6 @@ PUBLIC __IO_BREAK PUBLIC __IO_PIO_PORT_BASE -PUBLIC __I2C_RX_SIZE -PUBLIC __I2C_TX_SIZE - PUBLIC __IO_PCA9665_1_PORT_BASE PUBLIC __IO_PCA9665_2_PORT_BASE @@ -77,9 +74,6 @@ defc __IO_BREAK = 0x2000 defc __IO_PIO_PORT_BASE = 0x4000 -defc __I2C_RX_SIZE = 0x100 -defc __I2C_TX_SIZE = 0x100 - defc __IO_PCA9665_1_PORT_BASE = 0xA000 defc __IO_PCA9665_2_PORT_BASE = 0x8000 @@ -1501,6 +1495,10 @@ defc __IO_APU_OP_PUPI = 0x1A + +PUBLIC __IO_I2C_RX_SIZE +PUBLIC __IO_I2C_TX_SIZE + PUBLIC __IO_I2C1_PORT_MSB PUBLIC __IO_I2C2_PORT_MSB @@ -1573,6 +1571,9 @@ PUBLIC __IO_I2C_IMODE_CR +defc __IO_I2C_RX_SIZE = 68 +defc __IO_I2C_TX_SIZE = 68 + defc __IO_I2C1_PORT_MSB = 0xa0 defc __IO_I2C2_PORT_MSB = 0x80 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_config.bak b/libsrc/_DEVELOPMENT/target/yaz180/crt_config.bak index 73f8e4d1ab..ba93028473 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/crt_config.bak +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_config.bak @@ -16,23 +16,23 @@ ENDIF IF __CRTCFG = 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; asci driver model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; yabios model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; defc TAR__crt_org_code = 0 - defc TAR__crt_org_data = 0x2100 + defc TAR__crt_org_data = 0xE000 defc TAR__crt_org_bss = -1 defc TAR__crt_model = 2 - defc TAR__register_sp = 0 + defc TAR__register_sp = 0xFF00 defc TAR__crt_stack_size = 512 defc TAR__crt_initialize_bss = 1 defc TAR__crt_include_preamble = 1 - defc TAR__crt_org_vector_table = 0x2000 + defc TAR__crt_org_vector_table = 0xFF00 defc TAR__crt_io_vector_base = -1 defc TAR__crt_interrupt_mode = 1 @@ -68,13 +68,13 @@ IF __CRTCFG = 1 ;; basic driver model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - defc TAR__crt_org_code = 0x8200 + defc TAR__crt_org_code = 0x2900 defc TAR__crt_org_data = 0 defc TAR__crt_org_bss = -1 defc TAR__crt_model = 0 - defc TAR__register_sp = 0x4000 + defc TAR__register_sp = 0 defc TAR__crt_stack_size = 512 defc TAR__crt_initialize_bss = 1 @@ -84,7 +84,7 @@ IF __CRTCFG = 1 defc TAR__crt_org_vector_table = 0 defc TAR__crt_io_vector_base = -1 defc TAR__crt_interrupt_mode = -1 - + defc TAR__crt_enable_commandline = 0 defc TAR__crt_enable_restart = 0 defc TAR__crt_enable_close = 1 @@ -101,7 +101,7 @@ IF __CRTCFG = 1 defc TAR__clib_exit_stack_size = 0 defc TAR__clib_quickexit_stack_size = 0 - defc TAR__clib_malloc_heap_size = -0xFFFF + defc TAR__clib_malloc_heap_size = -1 defc TAR__clib_stdio_heap_size = 128 defc TAR__clib_balloc_table_size = 0 @@ -117,13 +117,13 @@ IF __CRTCFG = 2 ;; no drivers model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - defc TAR__crt_org_code = 0x8200 + defc TAR__crt_org_code = 0x0100 defc TAR__crt_org_data = 0 defc TAR__crt_org_bss = -1 defc TAR__crt_model = 0 - defc TAR__register_sp = 0x4000 + defc TAR__register_sp = 0 defc TAR__crt_stack_size = 512 defc TAR__crt_initialize_bss = 1 @@ -150,7 +150,7 @@ IF __CRTCFG = 2 defc TAR__clib_exit_stack_size = 0 defc TAR__clib_quickexit_stack_size = 0 - defc TAR__clib_malloc_heap_size = -0xFFFF + defc TAR__clib_malloc_heap_size = -1 defc TAR__clib_stdio_heap_size = 128 defc TAR__clib_balloc_table_size = 0 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_config.inc b/libsrc/_DEVELOPMENT/target/yaz180/crt_config.inc index 4f485c4946..ba93028473 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/crt_config.inc +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_config.inc @@ -16,23 +16,23 @@ ENDIF IF __CRTCFG = 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; asci driver model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; yabios model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; defc TAR__crt_org_code = 0 - defc TAR__crt_org_data = 0x2100 + defc TAR__crt_org_data = 0xE000 defc TAR__crt_org_bss = -1 defc TAR__crt_model = 2 - defc TAR__register_sp = 0 + defc TAR__register_sp = 0xFF00 defc TAR__crt_stack_size = 512 defc TAR__crt_initialize_bss = 1 defc TAR__crt_include_preamble = 1 - defc TAR__crt_org_vector_table = 0x2000 + defc TAR__crt_org_vector_table = 0xFF00 defc TAR__crt_io_vector_base = -1 defc TAR__crt_interrupt_mode = 1 @@ -117,7 +117,7 @@ IF __CRTCFG = 2 ;; no drivers model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - defc TAR__crt_org_code = 0x2900 + defc TAR__crt_org_code = 0x0100 defc TAR__crt_org_data = 0 defc TAR__crt_org_bss = -1 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_preamble.asm b/libsrc/_DEVELOPMENT/target/yaz180/crt_preamble.asm index 43b4b419e1..45602248a6 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/crt_preamble.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_preamble.asm @@ -29,16 +29,17 @@ EXTERN OMCR_M1E, CMR_X2, DCNTL_IWI0 OUT0 (DCNTL),A ; 0 Memory Wait & 2 I/O Wait ; Set Logical RAM Addresses - ; $8000-$FFFF RAM CA1 -> 80H - ; $4000-$7FFF RAM BANK -> 04H - ; $2000-$3FFF RAM CA0 - ; $0000-$1FFF Flash CA0 - - LD A,84H ; Set New Common / Bank Areas for RAM + ; $E000-$FFFF RAM CA1 -> $E. + ; $D000-$DFFF RAM BANK + ; $0000-$CFFF Flash BANK -> $.0 + + LD A,$E0 ; Set New Common 1 / Bank Areas for RAM OUT0 (CBAR),A - LD A,78H ; Set Common 1 Area Physical $80000 -> 78H + + LD A,$00 ; Set Common 1 Base Physical $0D000 -> $00 OUT0 (CBR),A - LD A,3CH ; Set Bank Area Physical $40000 -> 3CH + + LD A,$00 ; Set Bank Base Physical $00000 -> $00 OUT0 (BBR),A ENDIF diff --git a/libsrc/_DEVELOPMENT/target/yaz180/device/am9511a/__am9511a_data.asm b/libsrc/_DEVELOPMENT/target/yaz180/device/am9511a/__am9511a_data.asm index f37dd09d4c..40846d355c 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/device/am9511a/__am9511a_data.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/device/am9511a/__am9511a_data.asm @@ -17,7 +17,7 @@ SECTION data_driver PUBLIC APUCMDInPtr, APUCMDOutPtr, APUPTRInPtr, APUPTROutPtr - PUBLIC APUCMDBufUsed, APUPTRBufUsed, APUStatus, APUError + PUBLIC APUCMDBufUsed, APUPTRBufUsed, APUStatus, APUError, APULock APUCMDInPtr: DEFW APUCMDBuf APUCMDOutPtr: DEFW APUCMDBuf @@ -27,3 +27,4 @@ APUPTRBufUsed: DEFB 0 APUStatus: DEFB 0 APUError: DEFB 0 + APULock: DEFB 0 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Rx.asm b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Rx.asm index eae106be38..26eb18080a 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Rx.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Rx.asm @@ -1,22 +1,25 @@ -SECTION bss_driver - -EXTERN __ASCI0_RX_SIZE - -PUBLIC asci0RxCount, asci0RxIn, asci0RxOut - -asci0RxCount: defb 0 ; Space for Rx Buffer Management -asci0RxIn: defw asci0RxBuffer ; non-zero item in bss since it's initialized anyway -asci0RxOut: defw asci0RxBuffer ; non-zero item in bss since it's initialized anyway - SECTION data_align_256 PUBLIC asci0RxBuffer -asci0RxBuffer: defs __ASCI0_RX_SIZE ; Space for the Rx Buffer +EXTERN __ASCI0_RX_SIZE + +;asci0RxBuffer: defs __ASCI0_RX_SIZE ; Space for the Rx Buffer +asci0RxBuffer: defm __ASCI0_RX_SIZE ; Space for the Rx Buffer ; pad to next 256 byte boundary IF (ASMPC & 0xff) defs 256 - (ASMPC & 0xff) ENDIF + +SECTION data_driver + +PUBLIC asci0RxCount, asci0RxIn, asci0RxOut, asci0RxLock + +asci0RxCount: defb 0 ; Space for Rx Buffer Management +asci0RxIn: defw asci0RxBuffer ; non-zero item in bss since it's initialized anyway +asci0RxOut: defw asci0RxBuffer ; non-zero item in bss since it's initialized anyway +asci0RxLock: defb 0 ; lock flag for Rx exclusion + diff --git a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Tx.asm b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Tx.asm index a7297df910..8a47a25abb 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Tx.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Tx.asm @@ -1,22 +1,25 @@ -SECTION bss_driver - -EXTERN __ASCI0_TX_SIZE - -PUBLIC asci0TxCount, asci0TxIn, asci0TxOut, asci0TxLock - -asci0TxCount: defb 0 ; Space for Tx Buffer Management -asci0TxIn: defw asci0TxBuffer ; non-zero item in bss since it's initialized anyway -asci0TxOut: defw asci0TxBuffer ; non-zero item in bss since it's initialized anyway -asci0TxLock: defb 0 ; lock flag for Tx exclusion SECTION data_align_256 PUBLIC asci0TxBuffer -asci0TxBuffer: defs __ASCI0_TX_SIZE ; Space for the Tx Buffer +EXTERN __ASCI0_TX_SIZE + +; asci0TxBuffer: defs __ASCI0_TX_SIZE ; Space for the Tx Buffer +asci0TxBuffer: defm __ASCI0_TX_SIZE ; Space for the Tx Buffer ; pad to next 256 byte boundary IF (ASMPC & 0xff) defs 256 - (ASMPC & 0xff) ENDIF + +SECTION data_driver + +PUBLIC asci0TxCount, asci0TxIn, asci0TxOut, asci0TxLock + +asci0TxCount: defb 0 ; Space for Tx Buffer Management +asci0TxIn: defw asci0TxBuffer ; non-zero item in bss since it's initialized anyway +asci0TxOut: defw asci0TxBuffer ; non-zero item in bss since it's initialized anyway +asci0TxLock: defb 0 ; lock flag for Tx exclusion + diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/i2c/__i2c1_data.asm b/libsrc/_DEVELOPMENT/target/yaz180/driver/i2c/__i2c1_data.asm index b1f82b5cab..e93ae67919 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/driver/i2c/__i2c1_data.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/i2c/__i2c1_data.asm @@ -13,20 +13,12 @@ INCLUDE "config_private.inc" - SECTION data_align_256 + SECTION data_driver PUBLIC __i2c1RxBuffer, __i2c1TxBuffer - __i2c1RxBuffer: DEFS __I2C_RX_SIZE - __i2c1TxBuffer: DEFS __I2C_TX_SIZE - - ; pad to next 256 byte boundary - - IF (ASMPC & 0xff) - defs 256 - (ASMPC & 0xff) - ENDIF - - SECTION data_driver + __i2c1RxBuffer: DEFS __IO_I2C_RX_SIZE + __i2c1TxBuffer: DEFS __IO_I2C_TX_SIZE PUBLIC __i2c1RxInPtr, __i2c1RxOutPtr, __i2c1RxBufUsed PUBLIC __i2c1TxInPtr, __i2c1TxOutPtr, __i2c1TxBufUsed diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/i2c/__i2c2_data.asm b/libsrc/_DEVELOPMENT/target/yaz180/driver/i2c/__i2c2_data.asm index a0db7f06bb..fc43694201 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/driver/i2c/__i2c2_data.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/i2c/__i2c2_data.asm @@ -13,20 +13,13 @@ INCLUDE "config_private.inc" - SECTION data_align_256 + SECTION data_driver PUBLIC __i2c2RxBuffer, __i2c2TxBuffer - __i2c2RxBuffer: DEFS __I2C_RX_SIZE - __i2c2TxBuffer: DEFS __I2C_TX_SIZE - - ; pad to next 256 byte boundary + __i2c2RxBuffer: DEFS __IO_I2C_RX_SIZE + __i2c2TxBuffer: DEFS __IO_I2C_TX_SIZE - IF (ASMPC & 0xff) - defs 256 - (ASMPC & 0xff) - ENDIF - - SECTION data_driver PUBLIC __i2c2RxInPtr, __i2c2RxOutPtr, __i2c2RxBufUsed PUBLIC __i2c2TxInPtr, __i2c2TxOutPtr, __i2c2TxBufUsed diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/ide/__ide_data.asm b/libsrc/_DEVELOPMENT/target/yaz180/driver/ide/__ide_data.asm index 561819f622..6741855733 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/driver/ide/__ide_data.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/ide/__ide_data.asm @@ -1,7 +1,7 @@ SECTION data_driver -PUBLIC ideBuffer, ideStatus +PUBLIC ideBuffer, ideStatus, ideLock ; Space for the IDE Buffer ; used to respond to Drive ID requests, as sufficient buffer is not provided. @@ -14,4 +14,5 @@ ideBuffer: defs 512 ; bit 2 : Flag 0 = slave not previously accessed ideStatus: defb 0 +ideLock: defb 0 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/startup/yaz180_crt_0.asm.m4 b/libsrc/_DEVELOPMENT/target/yaz180/startup/yaz180_crt_0.asm.m4 index b3e620d754..6200fbc9c7 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/startup/yaz180_crt_0.asm.m4 +++ b/libsrc/_DEVELOPMENT/target/yaz180/startup/yaz180_crt_0.asm.m4 @@ -1,13 +1,13 @@ include(`z88dk.m4') dnl############################################################ -dnl## YAZ180_CRT_0.ASM.M4 - STANDALONE TARGET ## +dnl## YAZ180_CRT_0.ASM.M4 - YABIOS TARGET ## dnl############################################################ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; yaz180 standalone target ;; +;; yaz180 YABIOS target ;; ;; generated from target/yaz180/startup/yaz180_crt_0.asm.m4 ;; ;; ;; -;; flat 64k address space ;; +;; banked 64k address spaces ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm b/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm index c2ab4642ab..8008ac69f8 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm @@ -6,12 +6,44 @@ IF !DEFINED_startup defc DEFINED_startup = 1 - defc startup = 17 + defc startup = 0 IFNDEF startup ENDIF ENDIF +IF !DEFINED_CLIB_OPT_PRINTF + defc DEFINED_CLIB_OPT_PRINTF = 1 + defc CLIB_OPT_PRINTF = 0x200 + IFNDEF CLIB_OPT_PRINTF + ENDIF +ENDIF + + +IF !DEFINED_CLIB_OPT_PRINTF_2 + defc DEFINED_CLIB_OPT_PRINTF_2 = 1 + defc CLIB_OPT_PRINTF_2 = 0 + IFNDEF CLIB_OPT_PRINTF_2 + ENDIF +ENDIF + + +IF !DEFINED_CLIB_OPT_SCANF + defc DEFINED_CLIB_OPT_SCANF = 1 + defc CLIB_OPT_SCANF = 0x200000 + IFNDEF CLIB_OPT_SCANF + ENDIF +ENDIF + + +IF !DEFINED_CLIB_OPT_SCANF_2 + defc DEFINED_CLIB_OPT_SCANF_2 = 1 + defc CLIB_OPT_SCANF_2 = 0 + IFNDEF CLIB_OPT_SCANF_2 + ENDIF +ENDIF + + @@ -20,7 +52,7 @@ IFNDEF startup ; startup undefined so select a default - defc startup = 17 + defc startup = 0 ENDIF @@ -32,23 +64,15 @@ ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; asci driver ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; yabios drivers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; basic driver ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - - - - ; basic drivers using installed on stdin, stdout, stderr + ; yabios asci0 drivers installed on stdin, stdout, stderr IFNDEF __CRTCFG - defc __CRTCFG = 1 + defc __CRTCFG = 0 ENDIF @@ -61,10 +85,10 @@ ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; yaz180 standalone target ;; -;; generated from target/yaz180/startup/yaz180_crt_17.asm.m4 ;; +;; yaz180 YABIOS target ;; +;; generated from target/yaz180/startup/yaz180_crt_0.asm.m4 ;; ;; ;; -;; flat 64k address space ;; +;; banked 64k address spaces ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -757,14 +781,12 @@ ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FILE : _stdin ; - ; driver: rc_01_input_basic_dcio + ; driver: rc_00_input_asci0 ; fd : 0 ; mode : read only - ; type : 001 = input terminal - ; tie : __i_fcntl_fdstruct_1 + ; type : 003 = character input ; - ; ioctl_flags : CRT_ITERM_TERMINAL_FLAGS - ; buffer size : 64 bytes + ; ioctl_flags : 0x0100 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -819,14 +841,14 @@ ENDIF SECTION data_fcntl_stdio_heap_body EXTERN console_01_input_terminal_fdriver - EXTERN rc_01_input_basic_dcio + EXTERN rc_00_input_asci0 __i_fcntl_heap_0: ; heap header defw __i_fcntl_heap_1 - defw 98 + defw 23 defw 0 __i_fcntl_fdstruct_0: @@ -841,19 +863,19 @@ ENDIF ; jump to driver defb 195 - defw rc_01_input_basic_dcio + defw rc_00_input_asci0 ; flags ; reference_count ; mode_byte - defb 0x01 ; stdio handles ungetc + type = input terminal + defb 0x03 ; stdio handles ungetc + type = character input defb 2 defb 0x01 ; read only ; ioctl_flags - defw CRT_ITERM_TERMINAL_FLAGS + defw 0x0100 ; mtx_plain @@ -863,26 +885,6 @@ ENDIF defb 0xfe ; atomic spinlock defw 0 ; list of blocked threads - ; tied output terminal - ; pending_char - ; read_index - - defw __i_fcntl_fdstruct_1 - defb 0 - defw 0 - - ; b_array_t edit_buffer - - defw __edit_buffer_0 - defw 0 - defw 64 - - - ; reserve space for edit buffer - - __edit_buffer_0: defs 64 - - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -893,12 +895,12 @@ ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FILE : _stdout ; - ; driver: rc_01_output_basic_dcio + ; driver: rc_00_output_asci0 ; fd : 1 ; mode : write only - ; type : 002 = output terminal + ; type : 004 = character output ; - ; ioctl_flags : CRT_OTERM_TERMINAL_FLAGS + ; ioctl_flags : 0x0100 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -953,7 +955,7 @@ ENDIF SECTION data_fcntl_stdio_heap_body EXTERN console_01_output_terminal_fdriver - EXTERN rc_01_output_basic_dcio + EXTERN rc_00_output_asci0 __i_fcntl_heap_1: @@ -975,19 +977,19 @@ ENDIF ; jump to driver defb 195 - defw rc_01_output_basic_dcio + defw rc_00_output_asci0 ; flags ; reference_count ; mode_byte - defb 0x02 ; type = output terminal + defb 0x04 ; type = character output defb 2 defb 0x02 ; write only ; ioctl_flags - defw CRT_OTERM_TERMINAL_FLAGS + defw 0x0100 ; mtx_plain @@ -1001,7 +1003,8 @@ ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; DUPED FILE DESCRIPTOR ; @@ -1076,6 +1079,7 @@ ENDIF + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; create open and closed FILE lists ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1259,11 +1263,11 @@ ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; __clib_stdio_heap_size = desired stdio heap size in bytes - ; 121 = byte size of static FDSTRUCTs + ; 46 = byte size of static FDSTRUCTs ; 2 = number of heap allocations ; __i_fcntl_heap_n = address of allocation #n on heap (0..__I_FCNTL_NUM_HEAP-1) - IF 121 > 0 + IF 46 > 0 ; static FDSTRUCTs have been allocated in the heap @@ -1284,7 +1288,7 @@ ENDIF defb 0xfe ; spinlock (unlocked) defw 0 ; list of threads blocked on mutex - IF __clib_stdio_heap_size > (121 + 14) + IF __clib_stdio_heap_size > (46 + 14) ; expand stdio heap to desired size @@ -1295,7 +1299,7 @@ ENDIF defw __i_fcntl_heap_3 defw 0 defw __i_fcntl_heap_1 - defs __clib_stdio_heap_size - 121 - 14 + defs __clib_stdio_heap_size - 46 - 14 ; terminate stdio heap @@ -1421,6 +1425,15 @@ __Restart_2: SECTION code_crt_init ; user and library initialization + ; we do 256 ticks per second + ld hl, __CPU_CLOCK/__CPU_TIMER_SCALE/256-1 + out0 (RLDR0L), l + out0 (RLDR0H), h + + ; enable down counting and interrupts for PRT0 + ld a, TCR_TIE0|TCR_TDE0 + out0 (TCR), a + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MAIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1461,40 +1474,16 @@ SECTION code_crt_return ; terminate - IF (__crt_on_exit = 0x10002) - - ; returning to basic - - pop hl - - IF CRT_ABPASS > 0 - - ld a,h - ld b,l - call CRT_ABPASS - - ENDIF - - ld sp,(__sp_or_ret) - - im 1 - ei - ret - - ELSE - - include "../crt_exit_eidi.inc" - include "../crt_restore_sp.inc" - include "../crt_program_exit.inc" + include "../crt_exit_eidi.inc" + include "../crt_restore_sp.inc" + include "../crt_program_exit.inc" - ENDIF - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; RUNTIME VARS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; include "../crt_jump_vectors_z180.inc" -include "crt_interrupt_vectors_basic.inc" +include "crt_interrupt_vectors_z180.inc" IF (__crt_on_exit & 0x10000) && ((__crt_on_exit & 0x6) || ((__crt_on_exit & 0x8) && (__register_sp = -1))) @@ -1513,6 +1502,14 @@ include "../clib_stubs.inc" +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; basic driver ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + + + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; none ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm.m4 b/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm.m4 index 75fc45e71f..8246e58075 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm.m4 +++ b/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm.m4 @@ -39,12 +39,12 @@ ifelse(__STARTUP, -1, ') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; asci driver ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; yabios drivers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ifelse(__STARTUP, 0, ` - ; asci0 drivers installed on stdin, stdout, stderr + ; yabios asci0 drivers installed on stdin, stdout, stderr IFNDEF __CRTCFG From bc6e01c673938be13383f6f15e192e836f256374 Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Tue, 17 Oct 2017 22:50:13 +0100 Subject: [PATCH 2/4] ext/Oryx-Embedded-Common 47a5ac1...953536d (3): Add pathFindFileExtension --- ext/Oryx-Embedded-Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/Oryx-Embedded-Common b/ext/Oryx-Embedded-Common index 47a5ac1b15..953536d6f7 160000 --- a/ext/Oryx-Embedded-Common +++ b/ext/Oryx-Embedded-Common @@ -1 +1 @@ -Subproject commit 47a5ac1b152ee2e43beba93dd68d2ace83c831d6 +Subproject commit 953536d6f779660a2f4a890b4d69c76f74cf03bb From 78d894b6b194e2cb83216d6dbaed166eb5ce1788 Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Tue, 17 Oct 2017 23:44:42 +0100 Subject: [PATCH 3/4] Move external code to ext/ Move getopt to ext/getopt. Extract path.c and path.h from Oryx-Embedded-Common into ext/utils. Remove submodule Oryx-Embedded-Common. --- .gitmodules | 3 - ext/Oryx-Embedded-Common | 1 - {src => ext}/getopt/LICENSE | 0 {src => ext}/getopt/Makefile | 0 {src => ext}/getopt/README | 0 {src => ext}/getopt/getopt.c | 0 {src => ext}/getopt/getopt.h | 0 {src => ext}/getopt/test.c | 0 ext/utils/LICENSE | 339 +++++++++++++++++++ ext/utils/path.c | 489 ++++++++++++++++++++++++++++ ext/utils/path.h | 59 ++++ src/lstmanip/Makefile | 4 +- src/lstmanip/getopt/LICENSE | 33 -- src/lstmanip/getopt/Makefile | 28 -- src/lstmanip/getopt/README | 43 --- src/lstmanip/getopt/getopt.c | 246 -------------- src/lstmanip/getopt/getopt.h | 62 ---- src/lstmanip/getopt/test.c | 175 ---------- src/z80nm/Makefile | 4 +- win32/UNIXem/UNIXem.vcxproj | 4 +- win32/getopt/getopt.vcxproj | 4 +- win32/getopt/getopt.vcxproj.filters | 4 +- win32/lstmanip/lstmanip.vcxproj | 4 +- win32/z80asm/z80asm.vcxproj | 6 +- win32/z80nm/z80nm.vcxproj | 4 +- 25 files changed, 903 insertions(+), 609 deletions(-) delete mode 160000 ext/Oryx-Embedded-Common rename {src => ext}/getopt/LICENSE (100%) rename {src => ext}/getopt/Makefile (100%) rename {src => ext}/getopt/README (100%) rename {src => ext}/getopt/getopt.c (100%) rename {src => ext}/getopt/getopt.h (100%) rename {src => ext}/getopt/test.c (100%) create mode 100644 ext/utils/LICENSE create mode 100644 ext/utils/path.c create mode 100644 ext/utils/path.h delete mode 100644 src/lstmanip/getopt/LICENSE delete mode 100644 src/lstmanip/getopt/Makefile delete mode 100644 src/lstmanip/getopt/README delete mode 100644 src/lstmanip/getopt/getopt.c delete mode 100644 src/lstmanip/getopt/getopt.h delete mode 100644 src/lstmanip/getopt/test.c diff --git a/.gitmodules b/.gitmodules index 9f0acbfd6c..de51f67b4f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "ext/uthash"] path = ext/uthash url = https://github.com/z88dk/uthash.git -[submodule "ext/Oryx-Embedded-Common"] - path = ext/Oryx-Embedded-Common - url = https://github.com/z88dk/Common.git diff --git a/ext/Oryx-Embedded-Common b/ext/Oryx-Embedded-Common deleted file mode 160000 index 953536d6f7..0000000000 --- a/ext/Oryx-Embedded-Common +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 953536d6f779660a2f4a890b4d69c76f74cf03bb diff --git a/src/getopt/LICENSE b/ext/getopt/LICENSE similarity index 100% rename from src/getopt/LICENSE rename to ext/getopt/LICENSE diff --git a/src/getopt/Makefile b/ext/getopt/Makefile similarity index 100% rename from src/getopt/Makefile rename to ext/getopt/Makefile diff --git a/src/getopt/README b/ext/getopt/README similarity index 100% rename from src/getopt/README rename to ext/getopt/README diff --git a/src/getopt/getopt.c b/ext/getopt/getopt.c similarity index 100% rename from src/getopt/getopt.c rename to ext/getopt/getopt.c diff --git a/src/getopt/getopt.h b/ext/getopt/getopt.h similarity index 100% rename from src/getopt/getopt.h rename to ext/getopt/getopt.h diff --git a/src/getopt/test.c b/ext/getopt/test.c similarity index 100% rename from src/getopt/test.c rename to ext/getopt/test.c diff --git a/ext/utils/LICENSE b/ext/utils/LICENSE new file mode 100644 index 0000000000..23cb790338 --- /dev/null +++ b/ext/utils/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/ext/utils/path.c b/ext/utils/path.c new file mode 100644 index 0000000000..e79aa6796b --- /dev/null +++ b/ext/utils/path.c @@ -0,0 +1,489 @@ +/** + * @file path.c + * @brief Path manipulation helper functions + * + * @section License + * + * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * @author Oryx Embedded SARL (www.oryx-embedded.com) + * @version 1.7.8 + **/ + +//Dependencies +#include +#include +#include "path.h" + + +/** + * @brief Skip leading letter and colon to treat Windows paths + * @param[in] path NULL-terminated string that contains the path + * @return address path after the colon, or path if no drive spec given + **/ + +static const char_t *pathSkipDrive(const char_t *path, size_t *pMaxLen) +{ + if(strlen(path) >= 2 && isalpha(path[0]) && path[1] == ':') + { + path += 2; // skip volume + if (pMaxLen) + *pMaxLen -= 2; + } + + return path; +} + +/** + * @brief Test if the path is absolute + * @param[in] path NULL-terminated string that contains the path + * @return TRUE is the path is absolute, else FALSE + **/ + +bool_t pathIsAbsolute(const char_t *path) +{ + path = pathSkipDrive(path, NULL); + + //Determine if the path is absolute or relative + if(path[0] == '/' || path[0] == '\\') + return TRUE; + else + return FALSE; +} + + +/** + * @brief Test if the path is relative + * @param[in] path NULL-terminated string that contains the path + * @return TRUE is the path is relative, else FALSE + **/ + +bool_t pathIsRelative(const char_t *path) +{ + //Determine if the path is absolute or relative + return !pathIsAbsolute(path); +} + + +/** + * @brief Search a path for a file name + * @param[in] path NULL-terminated string that contains the path to search + * @return Pointer to the file name + **/ + +const char_t *pathFindFileName(const char_t *path) +{ + size_t n; + + path = pathSkipDrive(path, NULL); + + //Retrieve the length of the path + n = strlen(path); + + //Skip trailing slash or backslash characters + while(n > 0) + { + //Forward slash or backslash character found? + if(path[n - 1] != '/' && path[n - 1] != '\\') + break; + + //Previous character + n--; + } + + //Search the string for the last separator + while(n > 0) + { + //Forward slash or backslash character found? + if(path[n - 1] == '/' || path[n - 1] == '\\') + break; + + //Previous character + n--; + } + + //Return a pointer to the file name + return path + n; +} + + +/** + * @brief Search a path for a file extension + * @param[in] path NULL-terminated string that contains the path to search + * @return Pointer to the '.' of the file extention, or to the '\0' if none + **/ +const char_t *pathFindFileExtension(const char_t *path) +{ + size_t n; + + path = pathFindFileName(path); + + //Retrieve the length of the path + n = strlen(path); + + //Search the string for the last '.', except first '.' in a dot-file + while(n > 0) + { + //dot found and not at start of file name? + if(n > 1 && path[n - 1] == '.') + return path + n - 1; //return ".ext" + + //Previous character + n--; + } + + //Return a pointer to end of file name + return path + strlen(path); //no extension, dot-files have no extension +} + + +/** + * @brief Simplify a path + * @param[in] path NULL-terminated string containing the path to be canonicalized + **/ + +void pathCanonicalize(char_t *path) +{ + size_t i; + size_t j; + size_t k; + + path = (char_t *)pathSkipDrive(path, NULL); + + //Move to the beginning of the string + i = 0; + k = 0; + + //Replace backslashes with forward slashes + while(path[i] != '\0') + { + //Forward slash or backslash separator found? + if(path[i] == '/' || path[i] == '\\') + { + path[k++] = '/'; + while(path[i] == '/' || path[i] == '\\') i++; + } + else + { + path[k++] = path[i++]; + } + } + + //Properly terminate the string with a NULL character + path[k] = '\0'; + + //Move back to the beginning of the string + i = 0; + j = 0; + k = 0; + + //Parse the entire string + do + { + //Forward slash separator found? + if(path[i] == '/' || path[i] == '\0') + { + //"." element found? + if((i - j) == 1 && !strncmp(path + j, ".", 1)) + { + //Check whether the pathname is empty? + if(k == 0) + { + if(path[i] == '\0') + { + path[k++] = '.'; + } + else if(path[i] == '/' && path[i + 1] == '\0') + { + path[k++] = '.'; + path[k++] = '/'; + } + } + else if(k > 1) + { + //Remove the final slash if necessary + if(path[i] == '\0') + k--; + } + } + //".." element found? + else if((i - j) == 2 && !strncmp(path + j, "..", 2)) + { + //Check whether the pathname is empty? + if(k == 0) + { + path[k++] = '.'; + path[k++] = '.'; + + //Append a slash if necessary + if(path[i] == '/') + path[k++] = '/'; + } + else if(k > 1) + { + //Search the path for the previous slash + for(j = 1; j < k; j++) + { + if(path[k - j - 1] == '/') + break; + } + + //Slash separator found? + if(j < k) + { + if(!strncmp(path + k - j, "..", 2)) + { + path[k++] = '.'; + path[k++] = '.'; + } + else + { + k = k - j - 1; + } + + //Append a slash if necessary + if(k == 0 && path[0] == '/') + path[k++] = '/'; + else if(path[i] == '/') + path[k++] = '/'; + } + //No slash separator found? + else + { + if(k == 3 && !strncmp(path, "..", 2)) + { + path[k++] = '.'; + path[k++] = '.'; + + //Append a slash if necessary + if(path[i] == '/') + path[k++] = '/'; + } + else if(path[i] == '\0') + { + k = 0; + path[k++] = '.'; + } + else if(path[i] == '/' && path[i + 1] == '\0') + { + k = 0; + path[k++] = '.'; + path[k++] = '/'; + } + else + { + k = 0; + } + } + } + } + else + { + //Copy directory name + memmove(path + k, path + j, i - j); + //Advance write pointer + k += i - j; + + //Append a slash if necessary + if(path[i] == '/') + path[k++] = '/'; + } + + //Move to the next token + while(path[i] == '/') i++; + j = i; + } + } while(path[i++] != '\0'); + + //Properly terminate the string with a NULL character + path[k] = '\0'; +} + + +/** + * @brief Add a slash to the end of a string + * @param[in,out] path NULL-terminated string that represents the path + * @param[in] maxLen Maximum pathname length + **/ + +void pathAddSlash(char_t *path, size_t maxLen) +{ + size_t n; + + path = (char_t *)pathSkipDrive(path, &maxLen); + + //Retrieve the length of the string + n = strlen(path); + + //Add a slash character only if necessary + if(!n) + { + //Check the length of the resulting string + if(maxLen >= 1) + strcpy(path, "/"); + } + else if(path[n - 1] != '/' && path[n - 1] != '\\') + { + //Check the length of the resulting string + if(maxLen >= (n + 1)) + strcat(path, "/"); + } +} + + +/** + * @brief Remove the trailing slash from a given path + * @param[in,out] path NULL-terminated string that contains the path + **/ + +void pathRemoveSlash(char_t *path) +{ + char_t *end; + + path = (char_t *)pathSkipDrive(path, NULL); + + //Skip the leading slash character + if(pathIsAbsolute(path)) + path++; + + //Search for the first slash character to be removed + for(end = NULL; *path != '\0'; path++) + { + if(*path != '/' && *path != '\\') + end = NULL; + else if(!end) + end = path; + } + + //Remove the trailing slash characters + if(end) + *end = '\0'; +} + + +/** + * @brief Concatenate two paths + * @param[in,out] path NULL-terminated string containing the first path + * @param[in] more NULL-terminated string containing the second path + * @param[in] maxLen Maximum pathname length + **/ + +void pathCombine(char_t *path, const char_t *more, size_t maxLen) +{ + size_t n1; + size_t n2; + + path = (char_t *)pathSkipDrive(path, &maxLen); + + //Append a slash character to the first path + if(*path != '\0') + pathAddSlash(path, maxLen); + + //Skip any slash character at the beginning of the second path + while(*more == '/' || *more == '\\') more++; + + //Retrieve the length of the first path + n1 = strlen(path); + //Retrieve the length of second path + n2 = strlen(more); + + //Check the length of the resulting string + if(n1 < maxLen) + { + //Limit the number of characters to be copied + n2 = MIN(n2, maxLen - n1); + //Concatenate the resulting string + strncpy(path + n1, more, n2); + //Properly terminate the string with a NULL character + path[n1 + n2] = '\0'; + } +} + + +/** + * @brief Check whether a file name matches the specified pattern + * @param[in] path NULL-terminated string that contains the path to be matched + * @param[in] pattern NULL-terminated string that contains the pattern for + * which to search. The pattern may contain wildcard characters + * @return TRUE if the path matches the specified pattern, else FALSE + **/ + +bool_t pathMatch(const char_t *path, const char_t *pattern) +{ + size_t i = 0; + size_t j = 0; + + //Parse the pattern string + while(pattern[j] != '\0') + { + //Any wildcard character found? + if(pattern[j] == '?') + { + //The question mark matches a single character + if(path[i] == '\0') + { + return FALSE; + } + else + { + //Advance position in pathname + i++; + //Advance position in pattern string + j++; + } + } + else if(pattern[j] == '*') + { + //The asterisk sign matches zero or more characters + if(path[i] == '\0') + { + //Advance position in pattern string + j++; + } + else if(pathMatch(path + i, pattern + j + 1)) + { + return TRUE; + } + else + { + //Advance position in pathname + i++; + } + } + else + { + //Case insensitive comparison + if(tolower((uint8_t) path[i]) != tolower((uint8_t) pattern[j])) + { + return FALSE; + } + else + { + //Advance position in pathname + i++; + //Advance position in pattern string + j++; + } + } + } + + //Check whether the file name matches the specified pattern + if(path[i] == '\0' && pattern[j] == '\0') + return TRUE; + else + return FALSE; +} diff --git a/ext/utils/path.h b/ext/utils/path.h new file mode 100644 index 0000000000..29df6a1f57 --- /dev/null +++ b/ext/utils/path.h @@ -0,0 +1,59 @@ +/** + * @file path.h + * @brief Path manipulation helper functions + * + * @section License + * + * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * @author Oryx Embedded SARL (www.oryx-embedded.com) + * @version 1.7.8 + **/ + +#ifndef _PATH_H +#define _PATH_H + +//Dependencies +//#include "os_port.h" + +//C++ guard +#ifdef __cplusplus + extern "C" { +#endif + +//Path manipulation helper functions +bool_t pathIsAbsolute(const char_t *path); +bool_t pathIsRelative(const char_t *path); + +const char_t *pathFindFileName(const char_t *path); +const char_t *pathFindFileExtension(const char_t *path); + +void pathCanonicalize(char_t *path); + +void pathAddSlash(char_t *path, size_t maxLen); +void pathRemoveSlash(char_t *path); + +void pathCombine(char_t *path, const char_t *more, size_t maxLen); + +bool_t pathMatch(const char_t *path, const char_t *pattern); + +//C++ guard +#ifdef __cplusplus + } +#endif + +#endif diff --git a/src/lstmanip/Makefile b/src/lstmanip/Makefile index caa3c500e5..2f89bf8b60 100644 --- a/src/lstmanip/Makefile +++ b/src/lstmanip/Makefile @@ -4,8 +4,8 @@ OBJS = lstmanip.o INSTALL ?= install ifeq ($(EXEPREFIX),.exe) -OBJS += ../getopt/getopt.o -CFLAGS += -I../getopt +OBJS += ../../ext/getopt/getopt.o +CFLAGS += -I../../ext/getopt endif all: z88dk-lstmanip$(EXESUFFIX) diff --git a/src/lstmanip/getopt/LICENSE b/src/lstmanip/getopt/LICENSE deleted file mode 100644 index 99efb421aa..0000000000 --- a/src/lstmanip/getopt/LICENSE +++ /dev/null @@ -1,33 +0,0 @@ -Free Getopt -Copyright (c)2002-2003 Mark K. Kim -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - * Neither the original author of this software nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - diff --git a/src/lstmanip/getopt/Makefile b/src/lstmanip/getopt/Makefile deleted file mode 100644 index 8453e2b747..0000000000 --- a/src/lstmanip/getopt/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -############################################################################## - -CC=gcc -OBJECTS=getopt.o -BINARIES=test - - -############################################################################## -# PHONIES - -all: test - -clean: - rm -f $(BINARIES) *.o - - -############################################################################## -# FILES - -test: test.o $(OBJECTS) - $(CC) $(LDFLAGS) test.o $(OBJECTS) -o $@ $(LDLIBS) - -test.o: test.c - $(CC) $(CFLAGS) $< -o $@ -c - -getopt.o: getopt.c - $(CC) $(CFLAGS) $< -o $@ -c - diff --git a/src/lstmanip/getopt/README b/src/lstmanip/getopt/README deleted file mode 100644 index 36881a63fb..0000000000 --- a/src/lstmanip/getopt/README +++ /dev/null @@ -1,43 +0,0 @@ -Free Getopt - -****************************************************************************** -Please read the file LICENSE for the terms of use and distribution of this -software. -****************************************************************************** - -"getopt" is a library that allows a parsing of arguments passed -to a program. This is a useful library used in many software. -There are many versions of the getopt library available, two -popular versions being the BSD getopt and the GNU getopt. - -BSD getopt is somewhat old, dated, and isn't very user-friendly. -The GNU getopt is great, except the user license doesn't let you -statically link the library to a proprietary software. This -is usually not a problem on modern operating systems that allow -dynamic links to libraries, but sometimes you just gotta link -the library statically for one reason or another. That's where -Free Getopt steps in. - -Functionally, this getopt library is equivalent to GNU's getopt -library (the short option version, not the long one) in almost -every aspect. The only exception is how the "optind" variable -increments. Apparently due to different algorithms used by my -program and the GNU getopt, the "optind" changes quite differently -between our two software. I personally find my algorithm to be -quite elegant; I couldn't tell you about the GNU version since -I never looked at its source. - -GNU's getopt_long support is in progress. - -This library was deliberately left in non-library (not in -*.lib, *.so, or *.a) form because it's most likely to be -statically-linked in various platforms, and linking it -directly from source is probably the most straight-forward -way to use the software in any platform. - -I hope you find this software useful. - -Mark K. Kim - -$Header: /home/dom/z88dk-git/cvs/z88dk/src/z80nm/getopt/README,v 1.1 2016-07-09 13:55:41 pauloscustodio Exp $ - diff --git a/src/lstmanip/getopt/getopt.c b/src/lstmanip/getopt/getopt.c deleted file mode 100644 index 516f901c8d..0000000000 --- a/src/lstmanip/getopt/getopt.c +++ /dev/null @@ -1,246 +0,0 @@ -/***************************************************************************** -* getopt.c - competent and free getopt library. -* -* Copyright (c)2002-2003 Mark K. Kim -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* * Neither the original author of this software nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -*/ -#include -#include -#include -#include "getopt.h" - - -char* optarg = NULL; -int optind = 0; -int opterr = 1; -int optopt = '?'; - - -static char** prev_argv = NULL; /* Keep a copy of argv and argc to */ -static int prev_argc = 0; /* tell if getopt params change */ -static int argv_index = 0; /* Option we're checking */ -static int argv_index2 = 0; /* Option argument we're checking */ -static int opt_offset = 0; /* Index into compounded "-option" */ -static int dashdash = 0; /* True if "--" option reached */ -static int nonopt = 0; /* How many nonopts we've found */ - -static void increment_index() -{ - /* Move onto the next option */ - if(argv_index < argv_index2) - { - while(prev_argv[++argv_index] && prev_argv[argv_index][0] != '-' - && argv_index < argv_index2+1); - } - else argv_index++; - opt_offset = 1; -} - - -/* -* Permutes argv[] so that the argument currently being processed is moved -* to the end. -*/ -static int permute_argv_once() -{ - /* Movability check */ - if(argv_index + nonopt >= prev_argc) return 1; - /* Move the current option to the end, bring the others to front */ - else - { - char* tmp = prev_argv[argv_index]; - - /* Move the data */ - memmove(&prev_argv[argv_index], &prev_argv[argv_index+1], - sizeof(char**) * (prev_argc - argv_index - 1)); - prev_argv[prev_argc - 1] = tmp; - - nonopt++; - return 0; - } -} - - -int getopt(int argc, char** argv, char* optstr) -{ - int c = 0; - - /* If we have new argv, reinitialize */ - if(prev_argv != argv || prev_argc != argc) - { - /* Initialize variables */ - prev_argv = argv; - prev_argc = argc; - argv_index = 1; - argv_index2 = 1; - opt_offset = 1; - dashdash = 0; - nonopt = 0; - } - - /* Jump point in case we want to ignore the current argv_index */ - getopt_top: - - /* Misc. initializations */ - optarg = NULL; - - /* Dash-dash check */ - if(argv[argv_index] && !strcmp(argv[argv_index], "--")) - { - dashdash = 1; - increment_index(); - } - - /* If we're at the end of argv, that's it. */ - if(argv[argv_index] == NULL) - { - c = -1; - } - /* Are we looking at a string? Single dash is also a string */ - else if(dashdash || argv[argv_index][0] != '-' || !strcmp(argv[argv_index], "-")) - { - /* If we want a string... */ - if(optstr[0] == '-') - { - c = 1; - optarg = argv[argv_index]; - increment_index(); - } - /* If we really don't want it (we're in POSIX mode), we're done */ - else if(optstr[0] == '+' || getenv("POSIXLY_CORRECT")) - { - c = -1; - - /* Everything else is a non-opt argument */ - nonopt = argc - argv_index; - } - /* If we mildly don't want it, then move it back */ - else - { - if(!permute_argv_once()) goto getopt_top; - else c = -1; - } - } - /* Otherwise we're looking at an option */ - else - { - char* opt_ptr = NULL; - - /* Grab the option */ - c = argv[argv_index][opt_offset++]; - - /* Is the option in the optstr? */ - if(optstr[0] == '-') opt_ptr = strchr(optstr+1, c); - else opt_ptr = strchr(optstr, c); - /* Invalid argument */ - if(!opt_ptr) - { - if(opterr) - { - fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); - } - - optopt = c; - c = '?'; - - /* Move onto the next option */ - increment_index(); - } - /* Option takes argument */ - else if(opt_ptr[1] == ':') - { - /* ie, -oARGUMENT, -xxxoARGUMENT, etc. */ - if(argv[argv_index][opt_offset] != '\0') - { - optarg = &argv[argv_index][opt_offset]; - increment_index(); - } - /* ie, -o ARGUMENT (only if it's a required argument) */ - else if(opt_ptr[2] != ':') - { - /* One of those "you're not expected to understand this" moment */ - if(argv_index2 < argv_index) argv_index2 = argv_index; - while(argv[++argv_index2] && argv[argv_index2][0] == '-'); - optarg = argv[argv_index2]; - - /* Don't cross into the non-option argument list */ - if(argv_index2 + nonopt >= prev_argc) optarg = NULL; - - /* Move onto the next option */ - increment_index(); - } - else - { - /* Move onto the next option */ - increment_index(); - } - - /* In case we got no argument for an option with required argument */ - if(optarg == NULL && opt_ptr[2] != ':') - { - optopt = c; - c = '?'; - - if(opterr) - { - fprintf(stderr,"%s: option requires an argument -- %c\n", - argv[0], optopt); - } - } - } - /* Option does not take argument */ - else - { - /* Next argv_index */ - if(argv[argv_index][opt_offset] == '\0') - { - increment_index(); - } - } - } - - /* Calculate optind */ - if(c == -1) - { - optind = argc - nonopt; - } - else - { - optind = argv_index; - } - - return c; -} - - -/* vim:ts=3 -*/ diff --git a/src/lstmanip/getopt/getopt.h b/src/lstmanip/getopt/getopt.h deleted file mode 100644 index 75ac1236ac..0000000000 --- a/src/lstmanip/getopt/getopt.h +++ /dev/null @@ -1,62 +0,0 @@ -/***************************************************************************** -* getopt.h - competent and free getopt library. -* -* Copyright (c)2002-2003 Mark K. Kim -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* * Neither the original author of this software nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -*/ -#ifndef GETOPT_H_ -#define GETOPT_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - - -extern char* optarg; -extern int optind; -extern int opterr; -extern int optopt; - -int getopt(int argc, char** argv, char* optstr); - - -#ifdef __cplusplus -} -#endif - - -#endif /* GETOPT_H_ */ - - -/* vim:ts=3 -*/ diff --git a/src/lstmanip/getopt/test.c b/src/lstmanip/getopt/test.c deleted file mode 100644 index ceac90454e..0000000000 --- a/src/lstmanip/getopt/test.c +++ /dev/null @@ -1,175 +0,0 @@ -/***************************************************************************** -* getopt test program. -* -* Copyright (c)2002-2003 Mark K. Kim -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* * Neither the original author of this software nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -*/ -#include -#include -#include "getopt.h" - - -/***************************************************************************** -* DEFINES -*/ - -/** -* flags for different command-line options -* -* these options don't do anything - there's just here -* as examples -*/ -#define FLAG_INTERACT 0x0001 /* interactive mode */ -#define FLAG_FORCE 0x0002 /* force mode */ -#define FLAG_RECURSIVE 0x0004 /* recursive mode */ - - -/***************************************************************************** -* GLOBALS -*/ - -int flags = 0; /* store flags here */ - -int verbose = 5; /* verbosity level */ -const char* in_fname = NULL; /* input filename */ -const char* out_fname = NULL; /* output filename */ - - -/***************************************************************************** -* arg_to_int - Convert argument string to integer. -* -* min - Minimum allowed value, inclusive. -* max - Maximum allowed value, inclusive. -* defalt - The default value, in case of an error. -* opt - Option string of this argument. (ex., "-h"); -*/ - -int arg_to_int(const char* arg, int min, int max, int defalt, const char* opt) -{ - int i = defalt; - int rv; - - /* no argument means we use the default value */ - if(!arg) goto done; - - /* make sure we got an integer argument */ - rv = sscanf(arg, "%d", &i); - if(rv != 1) { - fprintf(stderr, "%s: integer argument required.\n", opt); - i = defalt; - goto done; - } - - /* make sure the integer argument is within the desired range */ - if(i < min || max < i) { - fprintf(stderr, "%s: argument out of integer range.\n", opt); - i = defalt; - goto done; - } - -done: - return i; -} - - -/***************************************************************************** -* help -*/ - -void help() -{ - printf( -"getopt test program\n" -"Usage: test [OPTION] [INPUT]\n" -" INPUT set input filename (doesn't do anything)\n" -" -h help menu (this screen)\n" -" -i interactive mode (doesn't do anything)\n" -" -f force mode (doesn't do anything)\n" -" -r recursive mode (doesn't do anything)\n" -" -v[level] set verbosity level (5 is default; doesn't do anything)\n" -" -o filename set output filename (doesn't do anything)\n" - ); -} - - -/***************************************************************************** -* MAIN -*/ - -int main(int argc, char* argv[]) -{ - /* check arguments */ - while(1) { - int c = getopt(argc, argv, "-ifrhv::o:"); - if(c == -1) break; - - switch(c) { - case 'i': flags |= FLAG_INTERACT; break; - case 'f': flags |= FLAG_FORCE; break; - case 'r': flags |= FLAG_RECURSIVE; break; - - case 'h': help(); exit(0); - - case 'v': verbose = arg_to_int(optarg, 0, 10, 5, "v"); break; - case 'o': out_fname = optarg; break; - case 1: in_fname = optarg; break; - - #ifdef DEBUG - default: - printf("Option '%c' (%d) with '%s'\n", c, c, optarg); - #endif - } - } - - #ifdef DEBUG - printf("optind at %d; argv[optind] = '%s'\n", optind, argv[optind]); - #endif - - /* print out what we got */ - if(flags & FLAG_INTERACT) printf("in interactive mode\n"); - else printf("not in interactive mode\n"); - if(flags & FLAG_FORCE) printf("in force mode\n"); - else printf("not in force mode\n"); - if(flags & FLAG_RECURSIVE) printf("in recursive mode\n"); - else printf("not in recursive mode\n"); - printf("verbosity level: %d\n", verbose); - if(in_fname) printf("input filename: %s\n", in_fname); - else printf("no input filename\n"); - if(out_fname) printf("output filename: %s\n", out_fname); - else printf("no output filename\n"); - - return 0; -} - - -/* vim:ts=3 -*/ diff --git a/src/z80nm/Makefile b/src/z80nm/Makefile index 03857a4193..bc35463fb7 100644 --- a/src/z80nm/Makefile +++ b/src/z80nm/Makefile @@ -4,8 +4,8 @@ OBJS = ar.o INSTALL ?= install ifeq ($(EXEPREFIX),.exe) -OBJS += ../getopt/getopt.o -CFLAGS += -I../getopt +OBJS += ../../ext/getopt/getopt.o +CFLAGS += -I../../ext/getopt endif all: z80nm$(EXESUFFIX) diff --git a/win32/UNIXem/UNIXem.vcxproj b/win32/UNIXem/UNIXem.vcxproj index 557016d97f..917de4a4ca 100644 --- a/win32/UNIXem/UNIXem.vcxproj +++ b/win32/UNIXem/UNIXem.vcxproj @@ -124,7 +124,7 @@ Level3 Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(ProjectDir)\..\..\ext\UNIXem\include + ..\..\ext\UNIXem\include Windows @@ -151,7 +151,7 @@ true true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(ProjectDir)\..\..\ext\UNIXem\include + ..\..\ext\UNIXem\include Windows diff --git a/win32/getopt/getopt.vcxproj b/win32/getopt/getopt.vcxproj index 86165d2dc0..882357ab5c 100644 --- a/win32/getopt/getopt.vcxproj +++ b/win32/getopt/getopt.vcxproj @@ -19,10 +19,10 @@ - + - + {0E6DEEBD-2979-4AB0-AB8A-5A51F6579AAF} diff --git a/win32/getopt/getopt.vcxproj.filters b/win32/getopt/getopt.vcxproj.filters index cc5ec550ab..d3ce0a3809 100644 --- a/win32/getopt/getopt.vcxproj.filters +++ b/win32/getopt/getopt.vcxproj.filters @@ -15,12 +15,12 @@ - + Header Files - + Source Files diff --git a/win32/lstmanip/lstmanip.vcxproj b/win32/lstmanip/lstmanip.vcxproj index e2976b923f..04dd32fa53 100644 --- a/win32/lstmanip/lstmanip.vcxproj +++ b/win32/lstmanip/lstmanip.vcxproj @@ -79,7 +79,7 @@ Level3 Disabled true - ..\..\src\getopt + ..\..\ext\getopt _MBCS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) @@ -97,7 +97,7 @@ true true true - ..\..\src\getopt + ..\..\ext\getopt _MBCS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) diff --git a/win32/z80asm/z80asm.vcxproj b/win32/z80asm/z80asm.vcxproj index 61d8dd4047..e421897876 100644 --- a/win32/z80asm/z80asm.vcxproj +++ b/win32/z80asm/z80asm.vcxproj @@ -89,8 +89,7 @@ Level3 Disabled _CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(ProjectDir)\..\..\src\z80asm\lib;$(ProjectDir)\..\..\ext\UNIXem\include;$(ProjectDir)\..\..\ext\uthash\src - + ..\..\src\z80asm\lib;..\..\ext\UNIXem\include;..\..\ext\uthash\src;..\..\ext\utils Console @@ -130,8 +129,7 @@ true true _CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - $(ProjectDir)\..\..\src\z80asm\lib;$(ProjectDir)\..\..\ext\UNIXem\include;$(ProjectDir)\..\..\ext\uthash\src - + ..\..\src\z80asm\lib;..\..\ext\UNIXem\include;..\..\ext\uthash\src;..\..\ext\utils Console diff --git a/win32/z80nm/z80nm.vcxproj b/win32/z80nm/z80nm.vcxproj index 91996700f6..5c65ffe809 100644 --- a/win32/z80nm/z80nm.vcxproj +++ b/win32/z80nm/z80nm.vcxproj @@ -92,7 +92,7 @@ Level3 Disabled _CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - ..\..\src\getopt + ..\..\ext\getopt Console @@ -122,7 +122,7 @@ true true _CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - ..\..\src\getopt + ..\..\ext\getopt Console From c7e51b49ca29688bb6579eecdd43c3a81e344dc3 Mon Sep 17 00:00:00 2001 From: Phillip Stevens Date: Wed, 18 Oct 2017 15:59:16 +1100 Subject: [PATCH 4/4] yaz180 - yabios wip2 (#462) * yaz180 - polish config_*.m4 files * rc2014 - update config_*.m4 #414 * yaz180 - i2c WIP1 & defc Basic interrupts * mod needs brackets * yaz180 - add missing config_basic.m4 * yaz180 - IDE 9% faster * rc2014 - IDE 9% faster * yaz180 - i2c WIP2 * yaz180 - initiate subtype=yabios * yaz180 - yabios wip2 --- .../target/yaz180/config_yaz180_public.inc | 1 - .../_DEVELOPMENT/target/yaz180/crt_config.bak | 19 +- .../_DEVELOPMENT/target/yaz180/crt_config.inc | 19 +- .../target/yaz180/crt_memory_map.bak | 2 +- .../target/yaz180/crt_memory_map.inc | 2 +- .../target/yaz180/crt_preamble.asm | 19 +- .../yaz180/crt_yabios_memory_model_z180.bak | 162 +++++++++ .../yaz180/crt_yabios_memory_model_z180.inc | 162 +++++++++ .../yaz180/crt_yabios_page_zero_z180.inc | 307 ++++++++++++++++++ .../target/yaz180/default/_am9511a_isr.asm | 4 +- .../target/yaz180/default/_am9511a_rst.asm | 4 + ..._z180_int_asci0_isr.asm => _asci0_isr.asm} | 2 - .../yaz180/default/_error_handler_rst.asm | 4 + .../target/yaz180/default/_far_call_rst.asm | 4 + .../target/yaz180/default/_system_rst.asm | 4 + .../yaz180/default/_system_tick_isr.asm | 2 - .../target/yaz180/default/_z180_trap.asm | 5 + .../target/yaz180/default/default.lst | 9 +- .../yaz180/device/am9511a/__am9511a_data.asm | 4 +- ...__asci0_bss_Rx.asm => __asci0_data_Rx.asm} | 11 +- ...__asci0_bss_Tx.asm => __asci0_data_Tx.asm} | 11 +- .../target/yaz180/device/asci/asci.lst | 4 +- .../target/yaz180/driver/driver_sccz80.lst | 1 + .../target/yaz180/driver/driver_sdcc_ix.lst | 1 + .../target/yaz180/driver/driver_sdcc_iy.lst | 1 + .../yaz180/driver/yabios/asm_am9511a_rst.asm | 13 + .../driver/yabios/asm_error_handler_rst.asm | 13 + .../yaz180/driver/yabios/asm_far_call_rst.asm | 13 + .../yaz180/driver/yabios/asm_system_rst.asm | 14 + .../yaz180/driver/yabios/asm_z180_trap.asm | 14 + .../target/yaz180/driver/yabios/yabios.lst | 5 + .../target/yaz180/startup/yaz180_crt_0.asm.m4 | 12 +- .../_DEVELOPMENT/target/yaz180/yaz180_crt.asm | 42 ++- .../target/yaz180/yaz180_rules.inc | 28 ++ 34 files changed, 849 insertions(+), 69 deletions(-) create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_memory_model_z180.bak create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_memory_model_z180.inc create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_page_zero_z180.inc create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/default/_am9511a_rst.asm rename libsrc/_DEVELOPMENT/target/yaz180/default/{_z180_int_asci0_isr.asm => _asci0_isr.asm} (61%) create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/default/_error_handler_rst.asm create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/default/_far_call_rst.asm create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/default/_system_rst.asm create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/default/_z180_trap.asm rename libsrc/_DEVELOPMENT/target/yaz180/device/asci/{__asci0_bss_Rx.asm => __asci0_data_Rx.asm} (71%) rename libsrc/_DEVELOPMENT/target/yaz180/device/asci/{__asci0_bss_Tx.asm => __asci0_data_Tx.asm} (71%) create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_am9511a_rst.asm create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_error_handler_rst.asm create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_far_call_rst.asm create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_system_rst.asm create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_z180_trap.asm create mode 100644 libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/yabios.lst diff --git a/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_public.inc b/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_public.inc index 879f98d0be..b86d9d1a82 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_public.inc +++ b/libsrc/_DEVELOPMENT/target/yaz180/config_yaz180_public.inc @@ -1495,7 +1495,6 @@ defc __IO_APU_OP_PUPI = 0x1A - PUBLIC __IO_I2C_RX_SIZE PUBLIC __IO_I2C_TX_SIZE diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_config.bak b/libsrc/_DEVELOPMENT/target/yaz180/crt_config.bak index ba93028473..d1ce26dd44 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/crt_config.bak +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_config.bak @@ -20,20 +20,23 @@ IF __CRTCFG = 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; defc TAR__crt_org_code = 0 - defc TAR__crt_org_data = 0xE000 + defc TAR__crt_org_data = 0xC000 defc TAR__crt_org_bss = -1 + defc TAR__crt_org_data_common1 = 0xF100 + defc TAR__crt_phase_code_common1 = 0xF700 + defc TAR__crt_model = 2 - defc TAR__register_sp = 0xFF00 + defc TAR__register_sp = 0xFFFE defc TAR__crt_stack_size = 512 defc TAR__crt_initialize_bss = 1 defc TAR__crt_include_preamble = 1 - defc TAR__crt_org_vector_table = 0xFF00 - defc TAR__crt_io_vector_base = -1 + defc TAR__crt_org_vector_table = 0xF000 + defc TAR__crt_io_vector_base = 0x60 defc TAR__crt_interrupt_mode = 1 defc TAR__crt_enable_commandline = 0 @@ -41,18 +44,18 @@ IF __CRTCFG = 0 defc TAR__crt_enable_close = 1 defc TAR__crt_enable_eidi = 0x13 - defc TAR__crt_on_exit = 0x10001 + defc TAR__crt_on_exit = 0x00001 - defc TAR__crt_enable_rst = 0 + defc TAR__crt_enable_rst = 0x009E defc TAR__crt_enable_nmi = 0 - defc TAR__crt_enable_trap = 0 + defc TAR__crt_enable_trap = 1 ; clib defaults defc TAR__clib_exit_stack_size = 0 defc TAR__clib_quickexit_stack_size = 0 - defc TAR__clib_malloc_heap_size = -1 + defc TAR__clib_malloc_heap_size = 0 defc TAR__clib_stdio_heap_size = 128 defc TAR__clib_balloc_table_size = 0 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_config.inc b/libsrc/_DEVELOPMENT/target/yaz180/crt_config.inc index ba93028473..d1ce26dd44 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/crt_config.inc +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_config.inc @@ -20,20 +20,23 @@ IF __CRTCFG = 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; defc TAR__crt_org_code = 0 - defc TAR__crt_org_data = 0xE000 + defc TAR__crt_org_data = 0xC000 defc TAR__crt_org_bss = -1 + defc TAR__crt_org_data_common1 = 0xF100 + defc TAR__crt_phase_code_common1 = 0xF700 + defc TAR__crt_model = 2 - defc TAR__register_sp = 0xFF00 + defc TAR__register_sp = 0xFFFE defc TAR__crt_stack_size = 512 defc TAR__crt_initialize_bss = 1 defc TAR__crt_include_preamble = 1 - defc TAR__crt_org_vector_table = 0xFF00 - defc TAR__crt_io_vector_base = -1 + defc TAR__crt_org_vector_table = 0xF000 + defc TAR__crt_io_vector_base = 0x60 defc TAR__crt_interrupt_mode = 1 defc TAR__crt_enable_commandline = 0 @@ -41,18 +44,18 @@ IF __CRTCFG = 0 defc TAR__crt_enable_close = 1 defc TAR__crt_enable_eidi = 0x13 - defc TAR__crt_on_exit = 0x10001 + defc TAR__crt_on_exit = 0x00001 - defc TAR__crt_enable_rst = 0 + defc TAR__crt_enable_rst = 0x009E defc TAR__crt_enable_nmi = 0 - defc TAR__crt_enable_trap = 0 + defc TAR__crt_enable_trap = 1 ; clib defaults defc TAR__clib_exit_stack_size = 0 defc TAR__clib_quickexit_stack_size = 0 - defc TAR__clib_malloc_heap_size = -1 + defc TAR__clib_malloc_heap_size = 0 defc TAR__clib_stdio_heap_size = 128 defc TAR__clib_balloc_table_size = 0 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_memory_map.bak b/libsrc/_DEVELOPMENT/target/yaz180/crt_memory_map.bak index a4a148219d..90a9594857 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/crt_memory_map.bak +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_memory_map.bak @@ -22,7 +22,7 @@ IF __MMAP = 0 ;; standard CODE/DATA/BSS memory map ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - INCLUDE "../crt_memory_model_z180.inc" + INCLUDE "crt_yabios_memory_model_z180.inc" ifelse(M4__CRT_APPEND_MMAP,1,`include(`./mmap.inc')') diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_memory_map.inc b/libsrc/_DEVELOPMENT/target/yaz180/crt_memory_map.inc index a4a148219d..90a9594857 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/crt_memory_map.inc +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_memory_map.inc @@ -22,7 +22,7 @@ IF __MMAP = 0 ;; standard CODE/DATA/BSS memory map ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - INCLUDE "../crt_memory_model_z180.inc" + INCLUDE "crt_yabios_memory_model_z180.inc" ifelse(M4__CRT_APPEND_MMAP,1,`include(`./mmap.inc')') diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_preamble.asm b/libsrc/_DEVELOPMENT/target/yaz180/crt_preamble.asm index 45602248a6..e3ee277bff 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/crt_preamble.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_preamble.asm @@ -10,8 +10,6 @@ EXTERN OMCR_M1E, CMR_X2, DCNTL_IWI0 ; Clear Refresh Control Reg (RCR) OUT0 (RCR),A ; DRAM Refresh Enable (0 Disabled) - OUT0 (TCR),A ; Disable PRT downcounting - ; Clear INT/TRAP Control Register (ITC) OUT0 (ITC),A ; Disable all external interrupts. @@ -29,17 +27,26 @@ EXTERN OMCR_M1E, CMR_X2, DCNTL_IWI0 OUT0 (DCNTL),A ; 0 Memory Wait & 2 I/O Wait ; Set Logical RAM Addresses - ; $E000-$FFFF RAM CA1 -> $E. - ; $D000-$DFFF RAM BANK + ; $F000-$FFFF RAM CA1 -> $F. + ; $D000-$EFFF RAM BANK ; $0000-$CFFF Flash BANK -> $.0 - LD A,$E0 ; Set New Common 1 / Bank Areas for RAM + LD A,$F0 ; Set New Common 1 / Bank Areas for RAM OUT0 (CBAR),A - LD A,$00 ; Set Common 1 Base Physical $0D000 -> $00 + LD A,$00 ; Set Common 1 Base Physical $0F000 -> $00 OUT0 (CBR),A LD A,$00 ; Set Bank Base Physical $00000 -> $00 OUT0 (BBR),A + ; we do 256 ticks per second + ld hl, __CPU_CLOCK/__CPU_TIMER_SCALE/256-1 + out0 (RLDR0L), l + out0 (RLDR0H), h + + ; enable down counting and interrupts for PRT0 + ld a, TCR_TIE0|TCR_TDE0 + out0 (TCR), a + ENDIF diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_memory_model_z180.bak b/libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_memory_model_z180.bak new file mode 100644 index 0000000000..8850fd9790 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_memory_model_z180.bak @@ -0,0 +1,162 @@ + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; memory model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +SECTION CODE + +org __crt_org_code + +section code_crt_start + +section code_crt_init +section code_crt_main +section code_crt_exit +section code_crt_return +section code_crt_common + +IF (__crt_org_vector_table) && (__crt_org_vector_table != -0x80) && (__crt_org_vector_table != -0x100) + +section interrupt_vectors + +ENDIF + +section code_driver +section code_font +section code_clib + include "../../clib_code.inc" +section code_lib +section code_compiler +section code_user + +section code_common1 + +section rodata_driver +section rodata_font +section rodata_clib + include "../../clib_rodata.inc" + ;;section rodata_error_strings + ;;section rodata_error_string_end + ;;defb 0 +section rodata_lib +section rodata_compiler +section rodata_user + +SECTION CODE_END + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +SECTION DATA + +IF __crt_org_data + + org __crt_org_data + +ELSE + + IF __crt_model + + "DATA section address must be specified for rom models" + + ENDIF + +ENDIF + +section data_align_256 +section data_align_128 +section data_align_64 +section data_align_32 +section data_align_16 +section data_align_8 +section data_align_4 +section data_align_2 + +section smc_jump_vectors +section smc_driver +section smc_font +section smc_clib + include "../../clib_smc.inc" +section smc_lib +section smc_compiler +section smc_user + +section data_driver +section data_font +section data_clib + include "../../clib_data.inc" + ;;section data_fcntl_stdio_heap_head + ;;section data_fcntl_stdio_heap_body + ;;section data_fcntl_stdio_heap_tail + ;;section data_fcntl_fdtable_body +section data_lib +section data_compiler +section data_user + +IF __crt_org_data_common1 + + org __crt_org_data_common1 + +ENDIF + +section data_common1_align_256 +section data_common1_align_128 +section data_common1_align_64 +section data_common1_align_32 +section data_common1_align_16 +section data_common1_align_8 +section data_common1_align_4 +section data_common1_align_2 +section data_common1_driver + +SECTION DATA_END + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +SECTION BSS + +IF __crt_org_bss + + org __crt_org_bss + +ELSE + + IF __crt_model + + org -1 + + ENDIF + +ENDIF + +section bss_align_256 +section bss_align_128 +section bss_align_64 +section bss_align_32 +section bss_align_16 +section bss_align_8 +section bss_align_4 +section bss_align_2 + +section bss_driver +section bss_font +section bss_clib + include "../../clib_bss.inc" +section bss_lib +section bss_compiler +section bss_user + +section BSS_UNINITIALIZED +SECTION BSS_END + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +IF (__crt_org_vector_table = 0) + +section interrupt_vectors +org 0 + +ENDIF + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_memory_model_z180.inc b/libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_memory_model_z180.inc new file mode 100644 index 0000000000..8850fd9790 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_memory_model_z180.inc @@ -0,0 +1,162 @@ + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; memory model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +SECTION CODE + +org __crt_org_code + +section code_crt_start + +section code_crt_init +section code_crt_main +section code_crt_exit +section code_crt_return +section code_crt_common + +IF (__crt_org_vector_table) && (__crt_org_vector_table != -0x80) && (__crt_org_vector_table != -0x100) + +section interrupt_vectors + +ENDIF + +section code_driver +section code_font +section code_clib + include "../../clib_code.inc" +section code_lib +section code_compiler +section code_user + +section code_common1 + +section rodata_driver +section rodata_font +section rodata_clib + include "../../clib_rodata.inc" + ;;section rodata_error_strings + ;;section rodata_error_string_end + ;;defb 0 +section rodata_lib +section rodata_compiler +section rodata_user + +SECTION CODE_END + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +SECTION DATA + +IF __crt_org_data + + org __crt_org_data + +ELSE + + IF __crt_model + + "DATA section address must be specified for rom models" + + ENDIF + +ENDIF + +section data_align_256 +section data_align_128 +section data_align_64 +section data_align_32 +section data_align_16 +section data_align_8 +section data_align_4 +section data_align_2 + +section smc_jump_vectors +section smc_driver +section smc_font +section smc_clib + include "../../clib_smc.inc" +section smc_lib +section smc_compiler +section smc_user + +section data_driver +section data_font +section data_clib + include "../../clib_data.inc" + ;;section data_fcntl_stdio_heap_head + ;;section data_fcntl_stdio_heap_body + ;;section data_fcntl_stdio_heap_tail + ;;section data_fcntl_fdtable_body +section data_lib +section data_compiler +section data_user + +IF __crt_org_data_common1 + + org __crt_org_data_common1 + +ENDIF + +section data_common1_align_256 +section data_common1_align_128 +section data_common1_align_64 +section data_common1_align_32 +section data_common1_align_16 +section data_common1_align_8 +section data_common1_align_4 +section data_common1_align_2 +section data_common1_driver + +SECTION DATA_END + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +SECTION BSS + +IF __crt_org_bss + + org __crt_org_bss + +ELSE + + IF __crt_model + + org -1 + + ENDIF + +ENDIF + +section bss_align_256 +section bss_align_128 +section bss_align_64 +section bss_align_32 +section bss_align_16 +section bss_align_8 +section bss_align_4 +section bss_align_2 + +section bss_driver +section bss_font +section bss_clib + include "../../clib_bss.inc" +section bss_lib +section bss_compiler +section bss_user + +section BSS_UNINITIALIZED +SECTION BSS_END + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +IF (__crt_org_vector_table = 0) + +section interrupt_vectors +org 0 + +ENDIF + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_page_zero_z180.inc b/libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_page_zero_z180.inc new file mode 100644 index 0000000000..ad5f732275 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/crt_yabios_page_zero_z180.inc @@ -0,0 +1,307 @@ +; address = 0x0000 +; must decide if this is a power on reset or a trap + + push af + ld a,__IO_BASE_ADDRESS + + jp __Test_Trap + + PUBLIC l_retn + +l_retn: + retn + +; address = 0x0008 + + defs 0x0008 - ASMPC + +IF ((__crt_enable_rst & $0202) = $02) + + EXTERN _z180_rst_08h + jp _z180_rst_08h + +ELSE + + IF ((__crt_enable_rst & $0202) = $0202) + + jp __z180_rst_08h + + ELSE + + jp l_ret + + ENDIF + +ENDIF + +IF ((__crt_enable_rst & $0202) != $0202) + + PUBLIC _z180_rst_08h_vector + defc _z180_rst_08h_vector = $09 + +ENDIF + + defm "Z88DK" + +; address = 0x0010 + + defs 0x0010 - ASMPC + +IF ((__crt_enable_rst & $0404) = $04) + + EXTERN _z180_rst_10h + jp _z180_rst_10h + +ELSE + + IF ((__crt_enable_rst & $0404) = $0404) + + jp __z180_rst_10h + + ELSE + + jp l_ret + + ENDIF + +ENDIF + +IF ((__crt_enable_rst & $0404) != $0404) + + PUBLIC _z180_rst_10h_vector + defc _z180_rst_10h_vector = $11 + +ENDIF + + defm "1.99C" + +; address = 0x0018 + + defs 0x0018 - ASMPC + +IF ((__crt_enable_rst & $0808) = $08) + + EXTERN _z180_rst_18h + jp _z180_rst_18h + +ELSE + + IF ((__crt_enable_rst & $0808) = $0808) + + jp __z180_rst_18h + + ELSE + + jp l_ret + + ENDIF + +ENDIF + +IF ((__crt_enable_rst & $0808) != $0808) + + PUBLIC _z180_rst_18h_vector + defc _z180_rst_18h_vector = $19 + +ENDIF + + PUBLIC l_ret + +l_ret: + ret + +; address = 0x0020 + + defs 0x0020 - ASMPC + +IF ((__crt_enable_rst & $1010) = $10) + + EXTERN _z180_rst_20h + jp _z180_rst_20h + +ELSE + + IF ((__crt_enable_rst & $1010) = $1010) + + jp __z180_rst_20h + + ELSE + + jp l_ret + + ENDIF + +ENDIF + +IF ((__crt_enable_rst & $1010) != $1010) + + PUBLIC _z180_rst_20h_vector + defc _z180_rst_20h_vector = $21 + +ENDIF + +; address = 0x0028 + + defs 0x0028 - ASMPC + +IF ((__crt_enable_rst & $2020) = $20) + + EXTERN _z180_rst_28h + jp _z180_rst_28h + +ELSE + + IF ((__crt_enable_rst & $2020) = $2020) + + jp __z180_rst_28h + + ELSE + + jp l_ret + + ENDIF + +ENDIF + +IF ((__crt_enable_rst & $2020) != $2020) + + PUBLIC _z180_rst_28h_vector + defc _z180_rst_28h_vector = $29 + +ENDIF + +; address = 0x0030 + + defs 0x0030 - ASMPC + +IF ((__crt_enable_rst & $4040) = $40) + + EXTERN _z180_rst_30h + jp _z180_rst_30h + +ELSE + + IF ((__crt_enable_rst & $4040) = $4040) + + jp __z180_rst_30h + + ELSE + + jp l_ret + + ENDIF + +ENDIF + +IF ((__crt_enable_rst & $4040) != $4040) + + PUBLIC _z180_rst_30h_vector + defc _z180_rst_30h_vector = $31 + +ENDIF + +; address = 0x0038 +; im 1 isr + + defs 0x0038 - ASMPC + +IF ((__crt_enable_rst & $8080) = $80) + + EXTERN _z180_rst_38h + jp _z180_rst_38h + +ELSE + + IF ((__crt_enable_rst & $8080) = $8080) + + jp __z180_rst_38h + + ELSE + + ei + reti + + ENDIF + +ENDIF + +IF ((__crt_enable_rst & $8080) != $8080) + + PUBLIC _z180_rst_38h_vector + defc _z180_rst_38h_vector = $39 + +ENDIF + +; address = 0x0066 + +; defs 0x0066 - ASMPC + +; NMI is tied high, because there is no capability in CP/M Page 0 to handle it. +; It is found in the middle of the default CP/M File Control Block. +; jp l_retn + + +; address = 0x100 + + defs 0x0100 - ASMPC + +section code_crt_start + +__Test_Trap: + + out0 (0x3f),a + + in0 a,(ITC) + + xor $80 + jp m, __reset + + out0 (ITC),a + +IF (__crt_enable_trap = 1) + + EXTERN _z180_trap + jp _z180_trap + +ELSE + + IF (__crt_enable_trap > 1) + + jp __z180_trap + + ELSE + + EXTERN __Unhandled_Trap + jp __Unhandled_Trap + + ENDIF + +ENDIF + +IF (__crt_enable_trap <= 1) + + PUBLIC _z180_trap_vector + defc _z180_trap_vector = ASMPC - 2 + +ENDIF + +__reset: + + include "../crt_start_di.inc" + +IF (REGISTER_SP = -1) + + pop af + +ENDIF + +IF (__crt_org_vector_table = 0) + + ld a,__IO_VECTOR_BASE + out0 (IL),a + +ENDIF + +;; fall through to __Start + +defc __page_zero_present = 1 diff --git a/libsrc/_DEVELOPMENT/target/yaz180/default/_am9511a_isr.asm b/libsrc/_DEVELOPMENT/target/yaz180/default/_am9511a_isr.asm index 6a255f0b90..cdb89572ad 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/default/_am9511a_isr.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/default/_am9511a_isr.asm @@ -1,6 +1,6 @@ ; compiles at address 0x0 get am9511a apu driver by default -PUBLIC _z180_nmi +PUBLIC _z180_rst_38h EXTERN asm_am9511a_isr -defc _z180_nmi = asm_am9511a_isr +defc _z180_rst_38h = asm_am9511a_isr diff --git a/libsrc/_DEVELOPMENT/target/yaz180/default/_am9511a_rst.asm b/libsrc/_DEVELOPMENT/target/yaz180/default/_am9511a_rst.asm new file mode 100644 index 0000000000..51354d1e8c --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/default/_am9511a_rst.asm @@ -0,0 +1,4 @@ +PUBLIC _z180_rst_18h +EXTERN asm_am9511a_rst + +defc _z180_rst_18h = asm_am9511a_rst diff --git a/libsrc/_DEVELOPMENT/target/yaz180/default/_z180_int_asci0_isr.asm b/libsrc/_DEVELOPMENT/target/yaz180/default/_asci0_isr.asm similarity index 61% rename from libsrc/_DEVELOPMENT/target/yaz180/default/_z180_int_asci0_isr.asm rename to libsrc/_DEVELOPMENT/target/yaz180/default/_asci0_isr.asm index ba26332f15..6c33312929 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/default/_z180_int_asci0_isr.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/default/_asci0_isr.asm @@ -1,5 +1,3 @@ -; compiles at address 0x0 get asci0 driver by default - PUBLIC _z180_int_asci0 EXTERN _asci0_interrupt diff --git a/libsrc/_DEVELOPMENT/target/yaz180/default/_error_handler_rst.asm b/libsrc/_DEVELOPMENT/target/yaz180/default/_error_handler_rst.asm new file mode 100644 index 0000000000..8a1fd33f36 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/default/_error_handler_rst.asm @@ -0,0 +1,4 @@ +PUBLIC _z180_rst_08h +EXTERN asm_error_handler_rst + +defc _z180_rst_08h = asm_error_handler_rst diff --git a/libsrc/_DEVELOPMENT/target/yaz180/default/_far_call_rst.asm b/libsrc/_DEVELOPMENT/target/yaz180/default/_far_call_rst.asm new file mode 100644 index 0000000000..d609471bfb --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/default/_far_call_rst.asm @@ -0,0 +1,4 @@ +PUBLIC _z180_rst_10h +EXTERN asm_far_call_rst + +defc _z180_rst_10h = asm_far_call_rst diff --git a/libsrc/_DEVELOPMENT/target/yaz180/default/_system_rst.asm b/libsrc/_DEVELOPMENT/target/yaz180/default/_system_rst.asm new file mode 100644 index 0000000000..7e96fac5fb --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/default/_system_rst.asm @@ -0,0 +1,4 @@ +PUBLIC _z180_rst_20h +EXTERN asm_system_rst + +defc _z180_rst_20h = asm_system_rst diff --git a/libsrc/_DEVELOPMENT/target/yaz180/default/_system_tick_isr.asm b/libsrc/_DEVELOPMENT/target/yaz180/default/_system_tick_isr.asm index 75ecdd8367..7dbe1f899a 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/default/_system_tick_isr.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/default/_system_tick_isr.asm @@ -1,5 +1,3 @@ -; compiles at address 0x0 get system tick driver by default - PUBLIC _z180_int_prt0 EXTERN asm_system_tick diff --git a/libsrc/_DEVELOPMENT/target/yaz180/default/_z180_trap.asm b/libsrc/_DEVELOPMENT/target/yaz180/default/_z180_trap.asm new file mode 100644 index 0000000000..ab610eaee7 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/default/_z180_trap.asm @@ -0,0 +1,5 @@ +PUBLIC _z180_trap +EXTERN asm_z180_trap + +defc _z180_trap = asm_z180_trap + diff --git a/libsrc/_DEVELOPMENT/target/yaz180/default/default.lst b/libsrc/_DEVELOPMENT/target/yaz180/default/default.lst index e7d4a4a6a4..1f2ae62525 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/default/default.lst +++ b/libsrc/_DEVELOPMENT/target/yaz180/default/default.lst @@ -1,3 +1,10 @@ -target/yaz180/default/_z180_int_asci0_isr target/yaz180/default/_am9511a_isr +target/yaz180/default/_asci0_isr target/yaz180/default/_system_tick_isr + +target/yaz180/default/_z180_trap +target/yaz180/default/_error_handler_rst +target/yaz180/default/_far_call_rst +target/yaz180/default/_system_rst +target/yaz180/default/_am9511a_rst + diff --git a/libsrc/_DEVELOPMENT/target/yaz180/device/am9511a/__am9511a_data.asm b/libsrc/_DEVELOPMENT/target/yaz180/device/am9511a/__am9511a_data.asm index 40846d355c..2893f31cf5 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/device/am9511a/__am9511a_data.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/device/am9511a/__am9511a_data.asm @@ -1,7 +1,7 @@ INCLUDE "config_private.inc" - SECTION data_align_256 + SECTION data_common1_align_256 PUBLIC APUCMDBuf, APUPTRBuf @@ -14,7 +14,7 @@ defs 256 - (ASMPC & 0xff) ENDIF - SECTION data_driver + SECTION data_common1_driver PUBLIC APUCMDInPtr, APUCMDOutPtr, APUPTRInPtr, APUPTROutPtr PUBLIC APUCMDBufUsed, APUPTRBufUsed, APUStatus, APUError, APULock diff --git a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Rx.asm b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_data_Rx.asm similarity index 71% rename from libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Rx.asm rename to libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_data_Rx.asm index 26eb18080a..54ece7d9d5 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Rx.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_data_Rx.asm @@ -1,12 +1,11 @@ -SECTION data_align_256 +INCLUDE "config_private.inc" + +SECTION data_common1_align_256 PUBLIC asci0RxBuffer -EXTERN __ASCI0_RX_SIZE - -;asci0RxBuffer: defs __ASCI0_RX_SIZE ; Space for the Rx Buffer -asci0RxBuffer: defm __ASCI0_RX_SIZE ; Space for the Rx Buffer +asci0RxBuffer: defs __ASCI0_RX_SIZE ; Space for the Rx Buffer ; pad to next 256 byte boundary @@ -14,7 +13,7 @@ IF (ASMPC & 0xff) defs 256 - (ASMPC & 0xff) ENDIF -SECTION data_driver +SECTION data_common1_driver PUBLIC asci0RxCount, asci0RxIn, asci0RxOut, asci0RxLock diff --git a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Tx.asm b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_data_Tx.asm similarity index 71% rename from libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Tx.asm rename to libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_data_Tx.asm index 8a47a25abb..2957d7ac79 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_bss_Tx.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/__asci0_data_Tx.asm @@ -1,12 +1,11 @@ -SECTION data_align_256 +INCLUDE "config_private.inc" -PUBLIC asci0TxBuffer +SECTION data_common1_align_256 -EXTERN __ASCI0_TX_SIZE +PUBLIC asci0TxBuffer -; asci0TxBuffer: defs __ASCI0_TX_SIZE ; Space for the Tx Buffer -asci0TxBuffer: defm __ASCI0_TX_SIZE ; Space for the Tx Buffer +asci0TxBuffer: defs __ASCI0_TX_SIZE ; Space for the Tx Buffer ; pad to next 256 byte boundary @@ -14,7 +13,7 @@ IF (ASMPC & 0xff) defs 256 - (ASMPC & 0xff) ENDIF -SECTION data_driver +SECTION data_common1_driver PUBLIC asci0TxCount, asci0TxIn, asci0TxOut, asci0TxLock diff --git a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/asci.lst b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/asci.lst index 026c325838..947d47fddf 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/device/asci/asci.lst +++ b/libsrc/_DEVELOPMENT/target/yaz180/device/asci/asci.lst @@ -1,5 +1,5 @@ -target/yaz180/device/asci/__asci0_bss_Rx -target/yaz180/device/asci/__asci0_bss_Tx +target/yaz180/device/asci/__asci0_data_Rx +target/yaz180/device/asci/__asci0_data_Tx target/yaz180/device/asci/__asci0_need target/yaz180/device/asci/asci0_flush_Rx target/yaz180/device/asci/asci0_flush_Tx diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sccz80.lst b/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sccz80.lst index 81bc33480e..e34f6f658a 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sccz80.lst +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sccz80.lst @@ -4,6 +4,7 @@ @target/yaz180/driver/character/rc_00_output_basic.lst @target/yaz180/driver/terminal/rc_01_input_basic_dcio.lst @target/yaz180/driver/terminal/rc_01_output_basic_dcio.lst +@target/yaz180/driver/yabios/yabios.lst @target/yaz180/driver/i2c/i2c.lst @target/yaz180/driver/ide/ide.lst @target/yaz180/driver/diskio/diskio_sccz80.lst diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sdcc_ix.lst b/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sdcc_ix.lst index 8c7bbcab60..20aafd2fb5 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sdcc_ix.lst +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sdcc_ix.lst @@ -4,6 +4,7 @@ @target/yaz180/driver/character/rc_00_output_basic.lst @target/yaz180/driver/terminal/rc_01_input_basic_dcio.lst @target/yaz180/driver/terminal/rc_01_output_basic_dcio.lst +@target/yaz180/driver/yabios/yabios.lst @target/yaz180/driver/i2c/i2c.lst @target/yaz180/driver/ide/ide.lst @target/yaz180/driver/diskio/diskio_sdcc.lst diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sdcc_iy.lst b/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sdcc_iy.lst index 8c7bbcab60..20aafd2fb5 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sdcc_iy.lst +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/driver_sdcc_iy.lst @@ -4,6 +4,7 @@ @target/yaz180/driver/character/rc_00_output_basic.lst @target/yaz180/driver/terminal/rc_01_input_basic_dcio.lst @target/yaz180/driver/terminal/rc_01_output_basic_dcio.lst +@target/yaz180/driver/yabios/yabios.lst @target/yaz180/driver/i2c/i2c.lst @target/yaz180/driver/ide/ide.lst @target/yaz180/driver/diskio/diskio_sdcc.lst diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_am9511a_rst.asm b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_am9511a_rst.asm new file mode 100644 index 0000000000..f97fb77bd8 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_am9511a_rst.asm @@ -0,0 +1,13 @@ +SECTION code_common1 + +PUBLIC asm_am9511a_rst + +EXTERN __crt_phase_code_common1 + +;PHASE __crt_phase_code_common1 +PHASE 0xF700 + +asm_am9511a_rst: + ret + +DEPHASE diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_error_handler_rst.asm b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_error_handler_rst.asm new file mode 100644 index 0000000000..7db7e11b95 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_error_handler_rst.asm @@ -0,0 +1,13 @@ +SECTION code_common1 + +PUBLIC asm_error_handler_rst + +EXTERN __crt_phase_code_common1 + +;PHASE __crt_phase_code_common1 +PHASE 0xF700 + +asm_error_handler_rst: + ret + +DEPHASE diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_far_call_rst.asm b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_far_call_rst.asm new file mode 100644 index 0000000000..1a1bf2e63d --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_far_call_rst.asm @@ -0,0 +1,13 @@ +SECTION code_common1 + +PUBLIC asm_far_call_rst + +EXTERN __crt_phase_code_common1 + +;PHASE __crt_phase_code_common1 +PHASE 0xF700 + +asm_far_call_rst: + ret + +DEPHASE diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_system_rst.asm b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_system_rst.asm new file mode 100644 index 0000000000..5a25df85d9 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_system_rst.asm @@ -0,0 +1,14 @@ +SECTION code_common1 + +PUBLIC asm_system_rst + +EXTERN __crt_phase_code_common1 + +;PHASE __crt_phase_code_common1 +PHASE 0xF700 + +asm_system_rst: + ret + +DEPHASE + diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_z180_trap.asm b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_z180_trap.asm new file mode 100644 index 0000000000..957038a1f6 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/asm_z180_trap.asm @@ -0,0 +1,14 @@ +SECTION code_common1 + +PUBLIC asm_z180_trap + +EXTERN __crt_phase_code_common1 + +;PHASE __crt_phase_code_common1 +PHASE 0xF700 + +asm_z180_trap: + ret + +DEPHASE + diff --git a/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/yabios.lst b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/yabios.lst new file mode 100644 index 0000000000..a7c96304b7 --- /dev/null +++ b/libsrc/_DEVELOPMENT/target/yaz180/driver/yabios/yabios.lst @@ -0,0 +1,5 @@ +target/yaz180/driver/yabios/asm_z180_trap +target/yaz180/driver/yabios/asm_am9511a_rst +target/yaz180/driver/yabios/asm_error_handler_rst +target/yaz180/driver/yabios/asm_far_call_rst +target/yaz180/driver/yabios/asm_system_rst diff --git a/libsrc/_DEVELOPMENT/target/yaz180/startup/yaz180_crt_0.asm.m4 b/libsrc/_DEVELOPMENT/target/yaz180/startup/yaz180_crt_0.asm.m4 index 6200fbc9c7..3302595346 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/startup/yaz180_crt_0.asm.m4 +++ b/libsrc/_DEVELOPMENT/target/yaz180/startup/yaz180_crt_0.asm.m4 @@ -110,7 +110,8 @@ ENDIF IF (ASMPC = 0) && (__crt_org_code = 0) - include "../crt_page_zero_z180.inc" + ; special YABIOS Page 0 + include "crt_yabios_page_zero_z180.inc" ENDIF @@ -158,15 +159,6 @@ __Restart_2: SECTION code_crt_init ; user and library initialization - ; we do 256 ticks per second - ld hl, __CPU_CLOCK/__CPU_TIMER_SCALE/256-1 - out0 (RLDR0L), l - out0 (RLDR0H), h - - ; enable down counting and interrupts for PRT0 - ld a, TCR_TIE0|TCR_TDE0 - out0 (TCR), a - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MAIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm b/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm index 8008ac69f8..1085339333 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm +++ b/libsrc/_DEVELOPMENT/target/yaz180/yaz180_crt.asm @@ -689,6 +689,34 @@ ENDIF ;; crt rules for yaz180 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + IFDEF CRT_PHASE_CODE_COMMMON1 + + defc __crt_phase_code_common1 = CRT_PHASE_CODE_COMMON1 + + ELSE + + IFDEF TAR__crt_phase_code_common1 + + defc __crt_phase_code_common1 = TAR__crt_phase_code_common1 + + ENDIF + + ENDIF + + IFDEF CRT_ORG_DATA_COMMMON1 + + defc __crt_org_data_common1 = CRT_ORG_DATA_COMMON1 + + ELSE + + IFDEF TAR__crt_org_data_common1 + + defc __crt_org_data_common1 = TAR__crt_org_data_common1 + + ENDIF + + ENDIF + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Input Terminal Settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -744,7 +772,7 @@ IF __MMAP = 0 ;; standard CODE/DATA/BSS memory map ;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - INCLUDE "../crt_memory_model_z180.inc" + INCLUDE "crt_yabios_memory_model_z180.inc" @@ -1377,7 +1405,8 @@ ENDIF IF (ASMPC = 0) && (__crt_org_code = 0) - include "../crt_page_zero_z180.inc" + ; special YABIOS Page 0 + include "crt_yabios_page_zero_z180.inc" ENDIF @@ -1425,15 +1454,6 @@ __Restart_2: SECTION code_crt_init ; user and library initialization - ; we do 256 ticks per second - ld hl, __CPU_CLOCK/__CPU_TIMER_SCALE/256-1 - out0 (RLDR0L), l - out0 (RLDR0H), h - - ; enable down counting and interrupts for PRT0 - ld a, TCR_TIE0|TCR_TDE0 - out0 (TCR), a - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MAIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/libsrc/_DEVELOPMENT/target/yaz180/yaz180_rules.inc b/libsrc/_DEVELOPMENT/target/yaz180/yaz180_rules.inc index b794ebd7e6..b54d2de8a2 100644 --- a/libsrc/_DEVELOPMENT/target/yaz180/yaz180_rules.inc +++ b/libsrc/_DEVELOPMENT/target/yaz180/yaz180_rules.inc @@ -2,6 +2,34 @@ ;; crt rules for yaz180 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + IFDEF CRT_PHASE_CODE_COMMMON1 + + defc __crt_phase_code_common1 = CRT_PHASE_CODE_COMMON1 + + ELSE + + IFDEF TAR__crt_phase_code_common1 + + defc __crt_phase_code_common1 = TAR__crt_phase_code_common1 + + ENDIF + + ENDIF + + IFDEF CRT_ORG_DATA_COMMMON1 + + defc __crt_org_data_common1 = CRT_ORG_DATA_COMMON1 + + ELSE + + IFDEF TAR__crt_org_data_common1 + + defc __crt_org_data_common1 = TAR__crt_org_data_common1 + + ENDIF + + ENDIF + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Input Terminal Settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;