From 7c3eeaff27b3f7ad48f1a87828dbeec4e2789111 Mon Sep 17 00:00:00 2001 From: Dean Netherton Date: Wed, 18 Sep 2024 18:41:22 +1000 Subject: [PATCH] ch376-native: fixes --- .gitignore | 6 + Source/HBIOS/Config/RCEZ80_std.asm | 11 +- Source/HBIOS/cfg_RCEZ80.asm | 4 +- Source/HBIOS/ch376-native/Dockerfile | 6 + Source/HBIOS/ch376-native/Makefile | 15 +- Source/HBIOS/ch376-native/base-drv.asm | 1 - Source/HBIOS/ch376-native/base-drv/ch376.c.s | 446 +++++++++-------- .../HBIOS/ch376-native/base-drv/class_hub.c.s | 24 +- .../ch376-native/base-drv/dev_transfers.c.s | 209 ++++---- .../HBIOS/ch376-native/base-drv/enumerate.c.s | 455 ++++++++++-------- .../ch376-native/base-drv/enumerate_hub.c.s | 234 +++++---- .../base-drv/enumerate_storage.c.s | 52 +- Source/HBIOS/ch376-native/base-drv/print.c.s | 31 +- .../HBIOS/ch376-native/base-drv/protocol.c.s | 235 +++++---- .../HBIOS/ch376-native/base-drv/transfers.c.s | 226 ++++----- .../ch376-native/base-drv/usb-base-drv.c.s | 15 +- .../HBIOS/ch376-native/base-drv/usb-init.c.s | 16 +- .../HBIOS/ch376-native/base-drv/usb_state.c.s | 21 +- .../HBIOS/ch376-native/base-drv/work-area.c.s | 2 +- Source/HBIOS/ch376-native/build-docker.sh | 0 .../ch376-native/scsi-drv/class_scsi.c.s | 355 +++++++------- Source/HBIOS/ch376-native/scsi-drv/init.c.s | 162 ------- .../HBIOS/ch376-native/scsi-drv/scsi-init.c.s | 18 +- .../ch376-native/source-doc/base-drv/ch376.c | 14 +- .../source-doc/base-drv/ez80-helpers.h | 1 + .../source-doc/base-drv/protocol.c | 2 + .../source-doc/base-drv/transfers.c | 6 +- .../source-doc/convert-for-uz80as.sh | 2 +- .../HBIOS/ch376-native/source-doc/depends.d | 117 +---- .../HBIOS/ch376-native/ufi-drv/class_ufi.c.s | 234 ++++----- .../HBIOS/ch376-native/ufi-drv/ufi-init.c.s | 67 ++- Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s | 18 +- Source/HBIOS/util.asm | 11 + 33 files changed, 1482 insertions(+), 1534 deletions(-) create mode 100644 Source/HBIOS/ch376-native/Dockerfile create mode 100644 Source/HBIOS/ch376-native/build-docker.sh delete mode 100644 Source/HBIOS/ch376-native/scsi-drv/init.c.s create mode 100644 Source/HBIOS/ch376-native/source-doc/base-drv/ez80-helpers.h diff --git a/.gitignore b/.gitignore index af06bcf5..d2ab7849 100644 --- a/.gitignore +++ b/.gitignore @@ -195,3 +195,9 @@ Tools/unix/OpenSpin/build/ Tools/unix/zxcc/config.h Tools/unix/zxcc/zxcc Binary/Apps/bbcbasic.txt + +Source/Images/hd1k_msxroms1.img +Source/Images/hd1k_msxroms1.img +Source/Images/hd1k_msxroms2.img +Source/Images/hd512_msxroms1.img +Source/Images/hd512_msxroms2.img diff --git a/Source/HBIOS/Config/RCEZ80_std.asm b/Source/HBIOS/Config/RCEZ80_std.asm index 8383e087..e9f7d2db 100644 --- a/Source/HBIOS/Config/RCEZ80_std.asm +++ b/Source/HBIOS/Config/RCEZ80_std.asm @@ -50,7 +50,7 @@ CPUOSC .SET 20000000 ; CPU OSC FREQ IN MHZ ; FPLED_ENABLE .SET TRUE ; FP: ENABLES FRONT PANEL LEDS -FPSW_ENABLE .SET TRUE ; FP: ENABLES FRONT PANEL SWITCHES +FPSW_ENABLE .SET FALSE ; FP: ENABLES FRONT PANEL SWITCHES CRTACT .SET FALSE ; ACTIVATE CRT (VDU,CVDU,PROPIO,ETC) AT STARTUP VDAEMU_SERKBD .SET $FF ; VDA EMULATION: SERIAL KBD UNIT #, OR $FF FOR HW KBD ;; @@ -61,12 +61,12 @@ TMSTIMENABLE .SET FALSE ; TMS: ENABLE TIMER INTERRUPTS (REQUIRES IM1) VRCENABLE .SET FALSE ; VRC: ENABLE VGARC VIDEO/KBD DRIVER (VRC.ASM) EFENABLE .SET FALSE ; EF: ENABLE EF9345 VIDEO DRIVER (EF.ASM) ; -FDENABLE .SET TRUE ; FD: ENABLE FLOPPY DISK DRIVER (FD.ASM) +FDENABLE .SET FALSE ; FD: ENABLE FLOPPY DISK DRIVER (FD.ASM) FDMODE .SET FDMODE_RCWDC ; FD: DRIVER MODE: FDMODE_[DIO|ZETA|ZETA2|DIDE|N8|DIO3|RCSMC|RCWDC|DYNO|EPFDC|MBC] ; -IDEENABLE .SET TRUE ; IDE: ENABLE IDE DISK DRIVER (IDE.ASM) +IDEENABLE .SET FALSE ; IDE: ENABLE IDE DISK DRIVER (IDE.ASM) ; -PPIDEENABLE .SET TRUE ; PPIDE: ENABLE PARALLEL PORT IDE DISK DRIVER (PPIDE.ASM) +PPIDEENABLE .SET FALSE ; PPIDE: ENABLE PARALLEL PORT IDE DISK DRIVER (PPIDE.ASM) ; SDENABLE .SET FALSE ; SD: ENABLE SD CARD DISK DRIVER (SD.ASM) SDMODE .SET SDMODE_PIO ; SD: DRIVER MODE: SDMODE_[JUHA|N8|CSIO|PPI|UART|DSD|MK4|SC|MT|USR|PIO|Z80R|EPITX|FZ80|GM|EZ512|K80W] @@ -83,6 +83,9 @@ AY38910ENABLE .SET FALSE ; AY: ENABLE AY-3-8910 / YM2149 SOUND DRIVER AYMODE .SET AYMODE_RCZ80 ; AY: DRIVER MODE: AYMODE_[SCG|N8|RCZ80|RCZ180|MSX|LINC|MBC|DUO|NABU] AY_FORCE .SET FALSE ; AY: BYPASS AUTO-DETECT, FORCED PRESENT +CHENABLE .SET FALSE ; CH: ENABLE CH375/376 USB SUPPORT +CH0USBENABLE .SET FALSE ; CH375: ENABLE CH375 USB DRIVER +CH1USBENABLE .SET FALSE ; CH376: ENABLE CH376 USB DRIVER CHNATIVEENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE USB DRIVER CHSCSIENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE MASS STORAGE DEVICES (REQUIRES CHNATIVEENABLE) CHUFIENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE UFI FLOPPY DISK DEVICES (REQUIRES CHNATIVEENABLE) diff --git a/Source/HBIOS/cfg_RCEZ80.asm b/Source/HBIOS/cfg_RCEZ80.asm index 5a33c933..508548ae 100644 --- a/Source/HBIOS/cfg_RCEZ80.asm +++ b/Source/HBIOS/cfg_RCEZ80.asm @@ -125,7 +125,7 @@ PKDENABLE .SET FALSE ; ENABLES DSKY NG PKD DRIVER (8259) PKDPPIBASE .SET $60 ; BASE I/O ADDRESS OF PKD PPI PKDOSC .SET 3000000 ; OSCILLATOR FREQ FOR PKD (IN HZ) H8PENABLE .SET FALSE ; ENABLES HEATH H8 FRONT PANEL -LCDENABLE .SET TRUE ; ENABLE LCD DISPLAY +LCDENABLE .SET FALSE ; ENABLE LCD DISPLAY LCDBASE .SET $DA ; BASE I/O ADDRESS OF LCD CONTROLLER GM7303ENABLE .SET FALSE ; ENABLES THE GM7303 BOARD WITH 16X2 LCD ; @@ -426,7 +426,7 @@ EZ80_IO_MIN_NS .SET 250 ; CALCULATE AT BOOT TIME THE REQUIRED W/S OR B/C, IF EZ EZ80_IO_MIN_WS .SET 7 ; MINIMUM WAIT STATES TO APPLY, IF EZ80_WSMD_TYP = EZ80WSMD_CALC ; ; APPLY CYCLES, W/S OR CALCULATE CYCLES BASED ON DESIRED PERIOD -EZ80_WSMD_TYP .SET EZ80WSMD_CALC ; BUS WAIT STATE CONFIG: EZ80WSMD_[CALC|CYCLES|WAIT] +EZ80_WSMD_TYP .SET EZ80WSMD_CYCLES ; BUS WAIT STATE CONFIG: EZ80WSMD_[CALC|CYCLES|WAIT] ; ; BUS TIMING FOR ON CHIP ROM ; diff --git a/Source/HBIOS/ch376-native/Dockerfile b/Source/HBIOS/ch376-native/Dockerfile new file mode 100644 index 00000000..47156098 --- /dev/null +++ b/Source/HBIOS/ch376-native/Dockerfile @@ -0,0 +1,6 @@ +# Build with: docker build --progress plain -t romwbw-z88dk . +# run with : docker run -v ${PWD}:/src/ --privileged=true -u $(id -u ${USER}):$(id -g ${USER}) -it romwbw-z88dk:latest + +FROM z88dk/z88dk + +RUN apk add build-base diff --git a/Source/HBIOS/ch376-native/Makefile b/Source/HBIOS/ch376-native/Makefile index 6a08c627..78963327 100644 --- a/Source/HBIOS/ch376-native/Makefile +++ b/Source/HBIOS/ch376-native/Makefile @@ -1,9 +1,11 @@ -SHELL := /bin/bash -.SHELLFLAGS := -eu -o pipefail -c +SHELL := /bin/sh +SHELLFLAGS := -c -e -x .ONESHELL: MAKEFLAGS += --warn-undefined-variables MAKEFLAGS += --no-builtin-rules +ZCC_EXTRA := --vc -Cs --Werror + ZCCRELFLAGS= ifdef RELEASE ZCCRELFLAGS=-SO3 --max-allocs-per-node600000 --allow-unsafe-read --opt-code-speed @@ -12,7 +14,7 @@ endif SRC := ./source-doc/ LIBS := -I./$(SRC)base-drv/ -ZCC := zcc +msx --vc -subtype=rom -startup=1 -crt0 $(SRC)crt.asm -compiler=sdcc -Cs--std=c23 -Cs--Werror $(ZCCRELFLAGS) $(LIBS) +ZCC := zcc +z80 -vn -startup=0 -clib=sdcc_iy -crt0 $(SRC)crt.asm -compiler=sdcc -Cs--std=c23 -Cs--Werror $(ZCCRELFLAGS) $(LIBS) ASSDIR := ./ @@ -79,7 +81,7 @@ format: @clang-format --version find \( -name "*.c" -o -name "*.h" \) -exec echo "formating {}" \; -exec clang-format -i {} \; -ZSDCPP_FLAGS=-iquote"." -isystem"${ZCCCFG}/../../include/_DEVELOPMENT/sdcc" $(LIBS) +ZSDCPP_FLAGS= -I"${ZCCCFG}../../include/_DEVELOPMENT/sdcc" $(LIBS) include ${SRC}depends.d @@ -92,7 +94,10 @@ deps: filename=$$(basename $$file_no_ext) from="$$filename.o" to="${ASSDIR}$$file_no_ext.c.s" - sdcpp ${ZSDCPP_FLAGS} -MM -MF /tmp/deps.deps ./${SRC}$$file_no_ext.c + echo -n "$${file}: " > /tmp/deps.deps + echo -n "$${file_no_ext}.c " >> /tmp/deps.deps + z88dk-ucpp ${ZSDCPP_FLAGS} -M ./${SRC}$$file_no_ext.c >> /tmp/deps.deps + touch /tmp/deps.deps sed "s+$$from+$$to+g" /tmp/deps.deps >> ${SRC}/depends.d done diff --git a/Source/HBIOS/ch376-native/base-drv.asm b/Source/HBIOS/ch376-native/base-drv.asm index 8990bf92..12e1c250 100644 --- a/Source/HBIOS/ch376-native/base-drv.asm +++ b/Source/HBIOS/ch376-native/base-drv.asm @@ -21,7 +21,6 @@ _ch_wait_int_and_get_status: ld bc, DELAY_FACTOR keep_waiting: - CALL _delay ld a, $FF in a, (_CH376_COMMAND_PORT & 0xFF) rlca diff --git a/Source/HBIOS/ch376-native/base-drv/ch376.c.s b/Source/HBIOS/ch376-native/base-drv/ch376.c.s index ea6a174c..4ef2b7d7 100644 --- a/Source/HBIOS/ch376-native/base-drv/ch376.c.s +++ b/Source/HBIOS/ch376-native/base-drv/ch376.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -50,344 +50,363 @@ _result: ;-------------------------------------------------------- ; code ;-------------------------------------------------------- -;source-doc/base-drv/./ch376.c:7: void ch_command(const uint8_t command) __z88dk_fastcall { +;source-doc/base-drv/./ch376.c:8: void ch_command(const uint8_t command) __z88dk_fastcall { ; --------------------------------- ; Function ch_command ; --------------------------------- _ch_command: -;source-doc/base-drv/./ch376.c:9: while ((CH376_COMMAND_PORT & PARA_STATE_BUSY) && --counter != 0) +;source-doc/base-drv/./ch376.c:10: while ((CH376_COMMAND_PORT & PARA_STATE_BUSY) && --counter != 0) ld h,0xff l_ch_command_00102: ld a, +((_CH376_COMMAND_PORT) / 256) in a, (((_CH376_COMMAND_PORT) & 0xFF)) bit 4, a jr Z,l_ch_command_00104 - dec h + dec h jr Z,l_ch_command_00104 -;source-doc/base-drv/./ch376.c:10: delay(); +;source-doc/base-drv/./ch376.c:11: delay(); push hl call _delay pop hl jr l_ch_command_00102 l_ch_command_00104: -;source-doc/base-drv/./ch376.c:20: delay(); +;source-doc/base-drv/./ch376.c:21: delay(); push hl call _delay pop hl -;source-doc/base-drv/./ch376.c:21: CH376_COMMAND_PORT = command; +;source-doc/base-drv/./ch376.c:22: CH376_COMMAND_PORT = command; ld a, l ld bc,_CH376_COMMAND_PORT out (c),a -;source-doc/base-drv/./ch376.c:22: delay(); -;source-doc/base-drv/./ch376.c:23: } +;source-doc/base-drv/./ch376.c:23: delay(); + call _delay +;source-doc/base-drv/./ch376.c:24: delay(); + call _delay +;source-doc/base-drv/./ch376.c:25: delay(); + call _delay +;source-doc/base-drv/./ch376.c:26: delay(); +;source-doc/base-drv/./ch376.c:27: } jp _delay -;source-doc/base-drv/./ch376.c:27: usb_error ch_long_wait_int_and_get_status(void) { return ch_wait_int_and_get_status(5000); } +;source-doc/base-drv/./ch376.c:31: usb_error ch_long_wait_int_and_get_status(void) { return ch_wait_int_and_get_status(5000); } ; --------------------------------- ; Function ch_long_wait_int_and_get_status ; --------------------------------- _ch_long_wait_int_and_get_statu: ld hl,0x1388 jp _ch_wait_int_and_get_status -;source-doc/base-drv/./ch376.c:29: usb_error ch_short_wait_int_and_get_statu(void) { return ch_wait_int_and_get_status(100); } +;source-doc/base-drv/./ch376.c:33: usb_error ch_short_wait_int_and_get_statu(void) { return ch_wait_int_and_get_status(100); } ; --------------------------------- ; Function ch_short_wait_int_and_get_statu ; --------------------------------- _ch_short_wait_int_and_get_stat: ld hl,0x0064 jp _ch_wait_int_and_get_status -;source-doc/base-drv/./ch376.c:31: usb_error ch_very_short_wait_int_and_get_(void) { return ch_wait_int_and_get_status(10); } +;source-doc/base-drv/./ch376.c:35: usb_error ch_very_short_wait_int_and_get_(void) { return ch_wait_int_and_get_status(10); } ; --------------------------------- ; Function ch_very_short_wait_int_and_get_ ; --------------------------------- _ch_very_short_wait_int_and_get: ld hl,0x000a jp _ch_wait_int_and_get_status -;source-doc/base-drv/./ch376.c:33: usb_error ch_get_status(void) { +;source-doc/base-drv/./ch376.c:37: usb_error ch_get_status(void) { ; --------------------------------- ; Function ch_get_status ; --------------------------------- _ch_get_status: -;source-doc/base-drv/./ch376.c:34: ch_command(CH_CMD_GET_STATUS); +;source-doc/base-drv/./ch376.c:38: ch_command(CH_CMD_GET_STATUS); ld l,0x22 call _ch_command -;source-doc/base-drv/./ch376.c:35: uint8_t ch_status = CH376_DATA_PORT; +;source-doc/base-drv/./ch376.c:39: delay(); + call _delay +;source-doc/base-drv/./ch376.c:40: delay(); + call _delay +;source-doc/base-drv/./ch376.c:41: delay(); + call _delay +;source-doc/base-drv/./ch376.c:42: delay(); + call _delay +;source-doc/base-drv/./ch376.c:43: uint8_t ch_status = CH376_DATA_PORT; ld a, +((_CH376_DATA_PORT) / 256) in a, (((_CH376_DATA_PORT) & 0xFF)) -;source-doc/base-drv/./ch376.c:37: if (ch_status >= USB_FILERR_MIN && ch_status <= USB_FILERR_MAX) +;source-doc/base-drv/./ch376.c:45: if (ch_status >= USB_FILERR_MIN && ch_status <= USB_FILERR_MAX) ld l,a sub 0x41 jr C,l_ch_get_status_00102 ld a,0xb4 sub l -;source-doc/base-drv/./ch376.c:38: return ch_status; +;source-doc/base-drv/./ch376.c:46: return ch_status; jr NC,l_ch_get_status_00126 l_ch_get_status_00102: -;source-doc/base-drv/./ch376.c:40: if (ch_status == CH_CMD_RET_SUCCESS) +;source-doc/base-drv/./ch376.c:48: if (ch_status == CH_CMD_RET_SUCCESS) ld a, l -;source-doc/base-drv/./ch376.c:41: return USB_ERR_OK; +;source-doc/base-drv/./ch376.c:49: return USB_ERR_OK; sub 0x51 jr NZ,l_ch_get_status_00105 ld l,a jr l_ch_get_status_00126 l_ch_get_status_00105: -;source-doc/base-drv/./ch376.c:43: if (ch_status == CH_USB_INT_SUCCESS) +;source-doc/base-drv/./ch376.c:51: if (ch_status == CH_USB_INT_SUCCESS) ld a, l -;source-doc/base-drv/./ch376.c:44: return USB_ERR_OK; +;source-doc/base-drv/./ch376.c:52: return USB_ERR_OK; sub 0x14 jr NZ,l_ch_get_status_00107 ld l,a jr l_ch_get_status_00126 l_ch_get_status_00107: -;source-doc/base-drv/./ch376.c:46: if (ch_status == CH_USB_INT_CONNECT) +;source-doc/base-drv/./ch376.c:54: if (ch_status == CH_USB_INT_CONNECT) ld a, l sub 0x15 jr NZ,l_ch_get_status_00109 -;source-doc/base-drv/./ch376.c:47: return USB_INT_CONNECT; +;source-doc/base-drv/./ch376.c:55: return USB_INT_CONNECT; ld l,0x81 jr l_ch_get_status_00126 l_ch_get_status_00109: -;source-doc/base-drv/./ch376.c:49: if (ch_status == CH_USB_INT_DISK_READ) +;source-doc/base-drv/./ch376.c:57: if (ch_status == CH_USB_INT_DISK_READ) ld a, l sub 0x1d jr NZ,l_ch_get_status_00111 -;source-doc/base-drv/./ch376.c:50: return USB_ERR_DISK_READ; +;source-doc/base-drv/./ch376.c:58: return USB_ERR_DISK_READ; ld l,0x1d jr l_ch_get_status_00126 l_ch_get_status_00111: -;source-doc/base-drv/./ch376.c:52: if (ch_status == CH_USB_INT_DISK_WRITE) +;source-doc/base-drv/./ch376.c:60: if (ch_status == CH_USB_INT_DISK_WRITE) ld a, l sub 0x1e jr NZ,l_ch_get_status_00113 -;source-doc/base-drv/./ch376.c:53: return USB_ERR_DISK_WRITE; +;source-doc/base-drv/./ch376.c:61: return USB_ERR_DISK_WRITE; ld l,0x1e jr l_ch_get_status_00126 l_ch_get_status_00113: -;source-doc/base-drv/./ch376.c:55: if (ch_status == CH_USB_INT_DISCONNECT) { +;source-doc/base-drv/./ch376.c:63: if (ch_status == CH_USB_INT_DISCONNECT) { ld a, l sub 0x16 jr NZ,l_ch_get_status_00115 -;source-doc/base-drv/./ch376.c:56: ch_cmd_set_usb_mode(5); +;source-doc/base-drv/./ch376.c:64: ch_cmd_set_usb_mode(5); ld l,0x05 call _ch_cmd_set_usb_mode -;source-doc/base-drv/./ch376.c:57: return USB_ERR_NO_DEVICE; +;source-doc/base-drv/./ch376.c:65: return USB_ERR_NO_DEVICE; ld l,0x05 jr l_ch_get_status_00126 l_ch_get_status_00115: -;source-doc/base-drv/./ch376.c:60: if (ch_status == CH_USB_INT_BUF_OVER) +;source-doc/base-drv/./ch376.c:68: if (ch_status == CH_USB_INT_BUF_OVER) ld a, l sub 0x17 jr NZ,l_ch_get_status_00117 -;source-doc/base-drv/./ch376.c:61: return USB_ERR_DATA_ERROR; +;source-doc/base-drv/./ch376.c:69: return USB_ERR_DATA_ERROR; ld l,0x04 jr l_ch_get_status_00126 l_ch_get_status_00117: -;source-doc/base-drv/./ch376.c:63: ch_status &= 0x2F; +;source-doc/base-drv/./ch376.c:71: ch_status &= 0x2F; ld a, l and 0x2f -;source-doc/base-drv/./ch376.c:65: if (ch_status == 0x2A) +;source-doc/base-drv/./ch376.c:73: if (ch_status == 0x2A) cp 0x2a jr NZ,l_ch_get_status_00119 -;source-doc/base-drv/./ch376.c:66: return USB_ERR_NAK; +;source-doc/base-drv/./ch376.c:74: return USB_ERR_NAK; ld l,0x01 jr l_ch_get_status_00126 l_ch_get_status_00119: -;source-doc/base-drv/./ch376.c:68: if (ch_status == 0x2E) +;source-doc/base-drv/./ch376.c:76: if (ch_status == 0x2E) cp 0x2e jr NZ,l_ch_get_status_00121 -;source-doc/base-drv/./ch376.c:69: return USB_ERR_STALL; +;source-doc/base-drv/./ch376.c:77: return USB_ERR_STALL; ld l,0x02 jr l_ch_get_status_00126 l_ch_get_status_00121: -;source-doc/base-drv/./ch376.c:71: ch_status &= 0x23; +;source-doc/base-drv/./ch376.c:79: ch_status &= 0x23; and 0x23 -;source-doc/base-drv/./ch376.c:73: if (ch_status == 0x20) +;source-doc/base-drv/./ch376.c:81: if (ch_status == 0x20) cp 0x20 jr NZ,l_ch_get_status_00123 -;source-doc/base-drv/./ch376.c:74: return USB_ERR_TIMEOUT; +;source-doc/base-drv/./ch376.c:82: return USB_ERR_TIMEOUT; ld l,0x03 jr l_ch_get_status_00126 l_ch_get_status_00123: -;source-doc/base-drv/./ch376.c:76: if (ch_status == 0x23) +;source-doc/base-drv/./ch376.c:84: if (ch_status == 0x23) sub 0x23 jr NZ,l_ch_get_status_00125 -;source-doc/base-drv/./ch376.c:77: return USB_TOKEN_OUT_OF_SYNC; +;source-doc/base-drv/./ch376.c:85: return USB_TOKEN_OUT_OF_SYNC; ld l,0x07 jr l_ch_get_status_00126 l_ch_get_status_00125: -;source-doc/base-drv/./ch376.c:79: return USB_ERR_UNEXPECTED_STATUS_FROM_; +;source-doc/base-drv/./ch376.c:87: return USB_ERR_UNEXPECTED_STATUS_FROM_; ld l,0x08 l_ch_get_status_00126: -;source-doc/base-drv/./ch376.c:80: } +;source-doc/base-drv/./ch376.c:88: } ret -;source-doc/base-drv/./ch376.c:82: void ch_cmd_reset_all(void) { ch_command(CH_CMD_RESET_ALL); } +;source-doc/base-drv/./ch376.c:90: void ch_cmd_reset_all(void) { ch_command(CH_CMD_RESET_ALL); } ; --------------------------------- ; Function ch_cmd_reset_all ; --------------------------------- _ch_cmd_reset_all: ld l,0x05 jp _ch_command -;source-doc/base-drv/./ch376.c:101: uint8_t ch_probe(void) { +;source-doc/base-drv/./ch376.c:109: uint8_t ch_probe(void) { ; --------------------------------- ; Function ch_probe ; --------------------------------- _ch_probe: -;source-doc/base-drv/./ch376.c:103: do { +;source-doc/base-drv/./ch376.c:111: do { ld c,0x05 l_ch_probe_00103: -;source-doc/base-drv/./ch376.c:86: ch_command(CH_CMD_CHECK_EXIST); +;source-doc/base-drv/./ch376.c:94: ch_command(CH_CMD_CHECK_EXIST); push bc ld l,0x06 call _ch_command pop bc -;source-doc/base-drv/./ch376.c:87: CH376_DATA_PORT = (uint8_t)~0x55; +;source-doc/base-drv/./ch376.c:95: CH376_DATA_PORT = (uint8_t)~0x55; ld a,0xaa push bc ld bc,_CH376_DATA_PORT out (c),a call _delay pop bc -;source-doc/base-drv/./ch376.c:89: complement = CH376_DATA_PORT; +;source-doc/base-drv/./ch376.c:97: complement = CH376_DATA_PORT; ld a, +((_CH376_DATA_PORT) / 256) in a, (((_CH376_DATA_PORT) & 0xFF)) -;source-doc/base-drv/./ch376.c:90: return complement == 0x55; +;source-doc/base-drv/./ch376.c:98: return complement == 0x55; sub 0x55 jr NZ,l_ch_probe_00102 -;source-doc/base-drv/./ch376.c:104: if (ch_cmd_check_exist()) -;source-doc/base-drv/./ch376.c:105: return true; +;source-doc/base-drv/./ch376.c:112: if (ch_cmd_check_exist()) +;source-doc/base-drv/./ch376.c:113: return true; ld l,0x01 jr l_ch_probe_00107 l_ch_probe_00102: -;source-doc/base-drv/./ch376.c:107: delay_medium(); +;source-doc/base-drv/./ch376.c:115: delay_medium(); push bc call _delay_medium pop bc -;source-doc/base-drv/./ch376.c:108: } while (--i != 0); +;source-doc/base-drv/./ch376.c:116: } while (--i != 0); dec c - ld a, c -;source-doc/base-drv/./ch376.c:110: return false; - or a jr NZ,l_ch_probe_00103 - ld l,a +;source-doc/base-drv/./ch376.c:118: return false; + ld l,0x00 l_ch_probe_00107: -;source-doc/base-drv/./ch376.c:111: } +;source-doc/base-drv/./ch376.c:119: } ret -;source-doc/base-drv/./ch376.c:113: uint8_t ch_cmd_set_usb_mode(const uint8_t mode) __z88dk_fastcall { +;source-doc/base-drv/./ch376.c:121: uint8_t ch_cmd_set_usb_mode(const uint8_t mode) __z88dk_fastcall { ; --------------------------------- ; Function ch_cmd_set_usb_mode ; --------------------------------- _ch_cmd_set_usb_mode: -;source-doc/base-drv/./ch376.c:114: uint8_t result = 0; - ld h,0x00 -;source-doc/base-drv/./ch376.c:116: CH376_COMMAND_PORT = CH_CMD_SET_USB_MODE; + ld c, l +;source-doc/base-drv/./ch376.c:122: uint8_t result = 0; + ld b,0x00 +;source-doc/base-drv/./ch376.c:124: CH376_COMMAND_PORT = CH_CMD_SET_USB_MODE; ld a,0x15 + push bc ld bc,_CH376_COMMAND_PORT out (c),a -;source-doc/base-drv/./ch376.c:117: delay(); - push hl call _delay - pop hl -;source-doc/base-drv/./ch376.c:118: CH376_DATA_PORT = mode; - ld a, l + pop bc +;source-doc/base-drv/./ch376.c:126: CH376_DATA_PORT = mode; + ld a, c + push bc ld bc,_CH376_DATA_PORT out (c),a -;source-doc/base-drv/./ch376.c:119: delay(); - push hl call _delay - pop hl -;source-doc/base-drv/./ch376.c:123: while (result != CH_CMD_RET_SUCCESS && result != CH_CMD_RET_ABORT && --count != 0) { - ld l,0x7f + pop bc +;source-doc/base-drv/./ch376.c:131: while (result != CH_CMD_RET_SUCCESS && result != CH_CMD_RET_ABORT && --count != 0) { + ld c,0x7f l_ch_cmd_set_usb_mode_00103: - ld a, h + ld a, b sub 0x51 - jr NZ,l_ch_cmd_set_usb_mode_00136 + jr NZ,l_ch_cmd_set_usb_mode_00146 ld a,0x01 - jr l_ch_cmd_set_usb_mode_00137 -l_ch_cmd_set_usb_mode_00136: + jr l_ch_cmd_set_usb_mode_00147 +l_ch_cmd_set_usb_mode_00146: xor a -l_ch_cmd_set_usb_mode_00137: - ld c,a - bit 0,a +l_ch_cmd_set_usb_mode_00147: + ld e, a + bit 0, e jr NZ,l_ch_cmd_set_usb_mode_00105 - ld a, h + ld a, b sub 0x5f jr Z,l_ch_cmd_set_usb_mode_00105 - dec l + dec c jr Z,l_ch_cmd_set_usb_mode_00105 -;source-doc/base-drv/./ch376.c:124: result = CH376_DATA_PORT; +;source-doc/base-drv/./ch376.c:132: result = CH376_DATA_PORT; ld a, +((_CH376_DATA_PORT) / 256) in a, (((_CH376_DATA_PORT) & 0xFF)) - ld h, a -;source-doc/base-drv/./ch376.c:125: delay(); - push hl + ld b, a +;source-doc/base-drv/./ch376.c:133: delay(); + push bc call _delay - pop hl + pop bc jr l_ch_cmd_set_usb_mode_00103 l_ch_cmd_set_usb_mode_00105: -;source-doc/base-drv/./ch376.c:128: return (result == CH_CMD_RET_SUCCESS) ? USB_ERR_OK : USB_ERR_FAIL; - ld a, c +;source-doc/base-drv/./ch376.c:136: return (result == CH_CMD_RET_SUCCESS) ? USB_ERR_OK : USB_ERR_FAIL; + ld a, e or a jr Z,l_ch_cmd_set_usb_mode_00108 - ld hl,0x0000 + ld l,0x00 jr l_ch_cmd_set_usb_mode_00109 l_ch_cmd_set_usb_mode_00108: - ld hl,0x000e + ld l,0x0e l_ch_cmd_set_usb_mode_00109: -;source-doc/base-drv/./ch376.c:129: } +;source-doc/base-drv/./ch376.c:137: } ret -;source-doc/base-drv/./ch376.c:131: uint8_t ch_cmd_get_ic_version(void) { +;source-doc/base-drv/./ch376.c:139: uint8_t ch_cmd_get_ic_version(void) { ; --------------------------------- ; Function ch_cmd_get_ic_version ; --------------------------------- _ch_cmd_get_ic_version: -;source-doc/base-drv/./ch376.c:132: ch_command(CH_CMD_GET_IC_VER); +;source-doc/base-drv/./ch376.c:140: ch_command(CH_CMD_GET_IC_VER); ld l,0x01 call _ch_command -;source-doc/base-drv/./ch376.c:133: return CH376_DATA_PORT & 0x1f; +;source-doc/base-drv/./ch376.c:141: return CH376_DATA_PORT & 0x1f; ld a, +((_CH376_DATA_PORT) / 256) in a, (((_CH376_DATA_PORT) & 0xFF)) and 0x1f ld l, a -;source-doc/base-drv/./ch376.c:134: } +;source-doc/base-drv/./ch376.c:142: } ret -;source-doc/base-drv/./ch376.c:136: void ch_issue_token(const uint8_t toggle_bit, const uint8_t endpoint, const ch376_pid pid) { +;source-doc/base-drv/./ch376.c:144: void ch_issue_token(const uint8_t toggle_bit, const uint8_t endpoint, const ch376_pid pid) { ; --------------------------------- ; Function ch_issue_token ; --------------------------------- _ch_issue_token: -;source-doc/base-drv/./ch376.c:137: ch_command(CH_CMD_ISSUE_TKN_X); + push ix + ld ix,0 + add ix,sp +;source-doc/base-drv/./ch376.c:145: ch_command(CH_CMD_ISSUE_TKN_X); ld l,0x4e call _ch_command -;source-doc/base-drv/./ch376.c:138: CH376_DATA_PORT = toggle_bit; - ld hl,2+0 - add hl, sp - ld a, (hl) +;source-doc/base-drv/./ch376.c:146: delay(); + call _delay +;source-doc/base-drv/./ch376.c:147: delay(); + call _delay +;source-doc/base-drv/./ch376.c:148: CH376_DATA_PORT = toggle_bit; + ld a,(ix+4) ld bc,_CH376_DATA_PORT out (c),a -;source-doc/base-drv/./ch376.c:139: delay(); +;source-doc/base-drv/./ch376.c:149: delay(); call _delay -;source-doc/base-drv/./ch376.c:140: CH376_DATA_PORT = endpoint << 4 | pid; - ld iy,3 - add iy, sp - ld a,(iy+0) +;source-doc/base-drv/./ch376.c:150: delay(); + call _delay +;source-doc/base-drv/./ch376.c:151: CH376_DATA_PORT = endpoint << 4 | pid; + ld a,(ix+5) add a, a add a, a add a, a add a, a - inc iy - or (iy+0) + or (ix+6) ld bc,_CH376_DATA_PORT out (c),a -;source-doc/base-drv/./ch376.c:141: delay(); -;source-doc/base-drv/./ch376.c:142: } +;source-doc/base-drv/./ch376.c:152: delay(); + call _delay +;source-doc/base-drv/./ch376.c:153: delay(); +;source-doc/base-drv/./ch376.c:154: } + pop ix jp _delay -;source-doc/base-drv/./ch376.c:144: void ch_issue_token_in(const endpoint_param *const endpoint) __z88dk_fastcall { +;source-doc/base-drv/./ch376.c:156: void ch_issue_token_in(const endpoint_param *const endpoint) __z88dk_fastcall { ; --------------------------------- ; Function ch_issue_token_in ; --------------------------------- _ch_issue_token_in: -;source-doc/base-drv/./ch376.c:145: ch_issue_token(endpoint->toggle ? 0x80 : 0x00, endpoint->number, CH_PID_IN); - ld e,l - ld d,h + ex de, hl +;source-doc/base-drv/./ch376.c:157: ch_issue_token(endpoint->toggle ? 0x80 : 0x00, endpoint->number, CH_PID_IN); + ld l, e + ld h, d ld a, (hl) rrca and 0x07 @@ -402,23 +421,26 @@ l_ch_issue_token_in_00103: xor a l_ch_issue_token_in_00104: ld h,0x09 - ld l,b push hl + inc sp + push bc + inc sp push af inc sp call _ch_issue_token pop af inc sp -;source-doc/base-drv/./ch376.c:146: } +;source-doc/base-drv/./ch376.c:158: } ret -;source-doc/base-drv/./ch376.c:148: void ch_issue_token_out(const endpoint_param *const endpoint) __z88dk_fastcall { +;source-doc/base-drv/./ch376.c:160: void ch_issue_token_out(const endpoint_param *const endpoint) __z88dk_fastcall { ; --------------------------------- ; Function ch_issue_token_out ; --------------------------------- _ch_issue_token_out: -;source-doc/base-drv/./ch376.c:149: ch_issue_token(endpoint->toggle ? 0x40 : 0x00, endpoint->number, CH_PID_OUT); - ld e,l - ld d,h + ex de, hl +;source-doc/base-drv/./ch376.c:161: ch_issue_token(endpoint->toggle ? 0x40 : 0x00, endpoint->number, CH_PID_OUT); + ld l, e + ld h, d ld a, (hl) rrca and 0x07 @@ -433,16 +455,18 @@ l_ch_issue_token_out_00103: xor a l_ch_issue_token_out_00104: ld h,0x01 - ld l,b push hl + inc sp + push bc + inc sp push af inc sp call _ch_issue_token pop af inc sp -;source-doc/base-drv/./ch376.c:150: } +;source-doc/base-drv/./ch376.c:162: } ret -;source-doc/base-drv/./ch376.c:152: void ch_issue_token_out_ep0(void) { ch_issue_token(0x40, 0, CH_PID_OUT); } +;source-doc/base-drv/./ch376.c:164: void ch_issue_token_out_ep0(void) { ch_issue_token(0x40, 0, CH_PID_OUT); } ; --------------------------------- ; Function ch_issue_token_out_ep0 ; --------------------------------- @@ -458,7 +482,7 @@ _ch_issue_token_out_ep0: pop af inc sp ret -;source-doc/base-drv/./ch376.c:154: void ch_issue_token_in_ep0(void) { ch_issue_token(0x80, 0, CH_PID_IN); } +;source-doc/base-drv/./ch376.c:166: void ch_issue_token_in_ep0(void) { ch_issue_token(0x80, 0, CH_PID_IN); } ; --------------------------------- ; Function ch_issue_token_in_ep0 ; --------------------------------- @@ -474,7 +498,7 @@ _ch_issue_token_in_ep0: pop af inc sp ret -;source-doc/base-drv/./ch376.c:156: void ch_issue_token_setup(void) { ch_issue_token(0, 0, CH_PID_SETUP); } +;source-doc/base-drv/./ch376.c:168: void ch_issue_token_setup(void) { ch_issue_token(0, 0, CH_PID_SETUP); } ; --------------------------------- ; Function ch_issue_token_setup ; --------------------------------- @@ -492,7 +516,7 @@ _ch_issue_token_setup: pop af inc sp ret -;source-doc/base-drv/./ch376.c:158: usb_error ch_data_in_transfer(uint8_t *buffer, int16_t buffer_size, endpoint_param *const endpoint) { +;source-doc/base-drv/./ch376.c:170: usb_error ch_data_in_transfer(uint8_t *buffer, int16_t buffer_size, endpoint_param *const endpoint) { ; --------------------------------- ; Function ch_data_in_transfer ; --------------------------------- @@ -501,42 +525,43 @@ _ch_data_in_transfer: ld ix,0 add ix,sp push af -;source-doc/base-drv/./ch376.c:162: if (buffer_size == 0) +;source-doc/base-drv/./ch376.c:174: if (buffer_size == 0) ld a,(ix+7) or (ix+6) jr NZ,l_ch_data_in_transfer_00102 -;source-doc/base-drv/./ch376.c:163: return USB_ERR_OK; +;source-doc/base-drv/./ch376.c:175: return USB_ERR_OK; ld l,0x00 jp l_ch_data_in_transfer_00110 l_ch_data_in_transfer_00102: -;source-doc/base-drv/./ch376.c:165: USB_MODULE_LEDS = 0x01; +;source-doc/base-drv/./ch376.c:177: USB_MODULE_LEDS = 0x01; ld a,0x01 ld bc,_USB_MODULE_LEDS out (c),a -;source-doc/base-drv/./ch376.c:166: do { +;source-doc/base-drv/./ch376.c:178: do { ld c,(ix+8) ld b,(ix+9) - pop de + inc sp + inc sp push bc l_ch_data_in_transfer_00107: -;source-doc/base-drv/./ch376.c:167: ch_issue_token_in(endpoint); - ld l,c - ld h,b - push hl +;source-doc/base-drv/./ch376.c:179: ch_issue_token_in(endpoint); + push bc + ld l, c + ld h, b call _ch_issue_token_in call _ch_long_wait_int_and_get_statu ld a, l pop bc ld l, a -;source-doc/base-drv/./ch376.c:170: CHECK(result); +;source-doc/base-drv/./ch376.c:182: CHECK(result); or a jr NZ,l_ch_data_in_transfer_00110 -;source-doc/base-drv/./ch376.c:172: endpoint->toggle = !endpoint->toggle; +;source-doc/base-drv/./ch376.c:184: endpoint->toggle = !endpoint->toggle; ld e, c ld d, b pop hl - ld a,(hl) push hl + ld a, (hl) and 0x01 xor 0x01 and 0x01 @@ -545,31 +570,32 @@ l_ch_data_in_transfer_00107: and 0xfe or l ld (de), a -;source-doc/base-drv/./ch376.c:174: count = ch_read_data(buffer); +;source-doc/base-drv/./ch376.c:186: count = ch_read_data(buffer); push bc ld l,(ix+4) ld h,(ix+5) call _ch_read_data + ld e, a pop bc -;source-doc/base-drv/./ch376.c:176: if (count == 0) { - ld e,a -;source-doc/base-drv/./ch376.c:177: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/./ch376.c:188: if (count == 0) { + ld a, e +;source-doc/base-drv/./ch376.c:189: USB_MODULE_LEDS = 0x00; or a jr NZ,l_ch_data_in_transfer_00106 ld bc,_USB_MODULE_LEDS out (c),a -;source-doc/base-drv/./ch376.c:178: return USB_ERR_DATA_ERROR; +;source-doc/base-drv/./ch376.c:190: return USB_ERR_DATA_ERROR; ld l,0x04 jr l_ch_data_in_transfer_00110 l_ch_data_in_transfer_00106: -;source-doc/base-drv/./ch376.c:181: buffer += count; - ld a, e - add a,(ix+4) +;source-doc/base-drv/./ch376.c:193: buffer += count; + ld a,(ix+4) + add a, e ld (ix+4),a - ld a,0x00 - adc a,(ix+5) - ld (ix+5),a -;source-doc/base-drv/./ch376.c:182: buffer_size -= count; + jr NC,l_ch_data_in_transfer_00147 + inc (ix+5) +l_ch_data_in_transfer_00147: +;source-doc/base-drv/./ch376.c:194: buffer_size -= count; ld d,0x00 ld a,(ix+6) sub e @@ -577,26 +603,26 @@ l_ch_data_in_transfer_00106: ld a,(ix+7) sbc a, d ld (ix+7),a -;source-doc/base-drv/./ch376.c:183: } while (buffer_size > 0); +;source-doc/base-drv/./ch376.c:195: } while (buffer_size > 0); xor a cp (ix+6) sbc a,(ix+7) - jp PO, l_ch_data_in_transfer_00137 + jp PO, l_ch_data_in_transfer_00148 xor 0x80 -l_ch_data_in_transfer_00137: +l_ch_data_in_transfer_00148: jp M, l_ch_data_in_transfer_00107 -;source-doc/base-drv/./ch376.c:185: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/./ch376.c:197: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS out (c),a -;source-doc/base-drv/./ch376.c:187: return USB_ERR_OK; +;source-doc/base-drv/./ch376.c:199: return USB_ERR_OK; ld l,0x00 l_ch_data_in_transfer_00110: -;source-doc/base-drv/./ch376.c:188: } +;source-doc/base-drv/./ch376.c:200: } ld sp, ix pop ix ret -;source-doc/base-drv/./ch376.c:190: usb_error ch_data_in_transfer_n(uint8_t *const buffer, int8_t *const buffer_size, endpoint_param *const endpoint) { +;source-doc/base-drv/./ch376.c:202: usb_error ch_data_in_transfer_n(uint8_t *const buffer, int8_t *const buffer_size, endpoint_param *const endpoint) { ; --------------------------------- ; Function ch_data_in_transfer_n ; --------------------------------- @@ -604,50 +630,53 @@ _ch_data_in_transfer_n: push ix ld ix,0 add ix,sp -;source-doc/base-drv/./ch376.c:194: USB_MODULE_LEDS = 0x01; +;source-doc/base-drv/./ch376.c:206: USB_MODULE_LEDS = 0x01; ld a,0x01 ld bc,_USB_MODULE_LEDS out (c),a -;source-doc/base-drv/./ch376.c:196: ch_issue_token_in(endpoint); +;source-doc/base-drv/./ch376.c:208: ch_issue_token_in(endpoint); ld l,(ix+8) ld h,(ix+9) call _ch_issue_token_in -;source-doc/base-drv/./ch376.c:198: CHECK(ch_long_wait_int_and_get_status()); +;source-doc/base-drv/./ch376.c:210: CHECK(ch_long_wait_int_and_get_status()); call _ch_long_wait_int_and_get_statu ld a,l or a jr NZ,l_ch_data_in_transfer_n_00103 -;source-doc/base-drv/./ch376.c:200: endpoint->toggle = !endpoint->toggle; - ld l,(ix+8) - ld h,(ix+9) - ld a,(hl) +;source-doc/base-drv/./ch376.c:212: endpoint->toggle = !endpoint->toggle; + ld e,(ix+8) + ld d,(ix+9) + ld c, e + ld b, d + ex de, hl + ld a, (hl) and 0x01 xor 0x01 and 0x01 - ld e,a - ld a,(hl) + ld e, a + ld a, (bc) and 0xfe or e - ld (hl),a -;source-doc/base-drv/./ch376.c:202: count = ch_read_data(buffer); + ld (bc), a +;source-doc/base-drv/./ch376.c:214: count = ch_read_data(buffer); ld l,(ix+4) ld h,(ix+5) call _ch_read_data -;source-doc/base-drv/./ch376.c:204: *buffer_size = count; +;source-doc/base-drv/./ch376.c:216: *buffer_size = count; ld c,(ix+6) ld b,(ix+7) ld (bc), a -;source-doc/base-drv/./ch376.c:206: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/./ch376.c:218: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS out (c),a -;source-doc/base-drv/./ch376.c:208: return USB_ERR_OK; +;source-doc/base-drv/./ch376.c:220: return USB_ERR_OK; ld l,0x00 l_ch_data_in_transfer_n_00103: -;source-doc/base-drv/./ch376.c:209: } +;source-doc/base-drv/./ch376.c:221: } pop ix ret -;source-doc/base-drv/./ch376.c:211: usb_error ch_data_out_transfer(const uint8_t *buffer, int16_t buffer_length, endpoint_param *const endpoint) { +;source-doc/base-drv/./ch376.c:223: usb_error ch_data_out_transfer(const uint8_t *buffer, int16_t buffer_length, endpoint_param *const endpoint) { ; --------------------------------- ; Function ch_data_out_transfer ; --------------------------------- @@ -657,7 +686,7 @@ _ch_data_out_transfer: add ix,sp push af dec sp -;source-doc/base-drv/./ch376.c:214: const uint8_t max_packet_size = calc_max_packet_size(endpoint->max_packet_sizex); +;source-doc/base-drv/./ch376.c:226: const uint8_t max_packet_size = calc_max_packet_size(endpoint->max_packet_sizex); ld c,(ix+8) ld b,(ix+9) ld e, c @@ -665,43 +694,44 @@ _ch_data_out_transfer: inc de ld a, (de) ld (ix-3),a -;source-doc/base-drv/./ch376.c:216: USB_MODULE_LEDS = 0x02; +;source-doc/base-drv/./ch376.c:228: USB_MODULE_LEDS = 0x02; ld a,0x02 push bc ld bc,_USB_MODULE_LEDS out (c),a pop bc -;source-doc/base-drv/./ch376.c:218: while (buffer_length > 0) { +;source-doc/base-drv/./ch376.c:230: while (buffer_length > 0) { ld (ix-2),c ld (ix-1),b l_ch_data_out_transfer_00103: xor a cp (ix+6) sbc a,(ix+7) - jp PO, l_ch_data_out_transfer_00130 + jp PO, l_ch_data_out_transfer_00138 xor 0x80 -l_ch_data_out_transfer_00130: +l_ch_data_out_transfer_00138: jp P, l_ch_data_out_transfer_00105 -;source-doc/base-drv/./ch376.c:219: const uint8_t size = max_packet_size < buffer_length ? max_packet_size : buffer_length; - ld d,(ix-3) - ld e,0x00 - ld a, d - sub (ix+6) +;source-doc/base-drv/./ch376.c:231: const uint8_t size = max_packet_size < buffer_length ? max_packet_size : buffer_length; + ld e,(ix-3) + ld d,0x00 ld a, e + sub (ix+6) + ld a, d sbc a,(ix+7) - jp PO, l_ch_data_out_transfer_00131 + jp PO, l_ch_data_out_transfer_00139 xor 0x80 -l_ch_data_out_transfer_00131: +l_ch_data_out_transfer_00139: jp P, l_ch_data_out_transfer_00108 jr l_ch_data_out_transfer_00109 l_ch_data_out_transfer_00108: - ld d,(ix+6) - ld e,(ix+7) + ld e,(ix+6) + ld d,(ix+7) l_ch_data_out_transfer_00109: -;source-doc/base-drv/./ch376.c:220: buffer = ch_write_data(buffer, size); +;source-doc/base-drv/./ch376.c:232: buffer = ch_write_data(buffer, size); push bc push de - push de + ld a, e + push af inc sp ld l,(ix+4) ld h,(ix+5) @@ -713,18 +743,18 @@ l_ch_data_out_transfer_00109: pop bc ld (ix+4),l ld (ix+5),h -;source-doc/base-drv/./ch376.c:221: buffer_length -= size; - ld e,0x00 +;source-doc/base-drv/./ch376.c:233: buffer_length -= size; + ld d,0x00 ld a,(ix+6) - sub d + sub e ld (ix+6),a ld a,(ix+7) - sbc a, e + sbc a, d ld (ix+7),a -;source-doc/base-drv/./ch376.c:222: ch_issue_token_out(endpoint); - ld l,c - ld h,b - push hl +;source-doc/base-drv/./ch376.c:234: ch_issue_token_out(endpoint); + push bc + ld l, c + ld h, b call _ch_issue_token_out call _ch_long_wait_int_and_get_statu ld a, l @@ -732,7 +762,7 @@ l_ch_data_out_transfer_00109: ld l, a or a jr NZ,l_ch_data_out_transfer_00106 -;source-doc/base-drv/./ch376.c:226: endpoint->toggle = !endpoint->toggle; +;source-doc/base-drv/./ch376.c:238: endpoint->toggle = !endpoint->toggle; ld e, c ld d, b ld l,(ix-2) @@ -748,33 +778,33 @@ l_ch_data_out_transfer_00109: ld (de), a jr l_ch_data_out_transfer_00103 l_ch_data_out_transfer_00105: -;source-doc/base-drv/./ch376.c:229: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/./ch376.c:241: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS out (c),a -;source-doc/base-drv/./ch376.c:231: return USB_ERR_OK; +;source-doc/base-drv/./ch376.c:243: return USB_ERR_OK; ld l,0x00 l_ch_data_out_transfer_00106: -;source-doc/base-drv/./ch376.c:232: } +;source-doc/base-drv/./ch376.c:244: } ld sp, ix pop ix ret -;source-doc/base-drv/./ch376.c:234: void ch_set_usb_address(const uint8_t device_address) __z88dk_fastcall { +;source-doc/base-drv/./ch376.c:246: void ch_set_usb_address(const uint8_t device_address) __z88dk_fastcall { ; --------------------------------- ; Function ch_set_usb_address ; --------------------------------- _ch_set_usb_address: -;source-doc/base-drv/./ch376.c:235: ch_command(CH_CMD_SET_USB_ADDR); +;source-doc/base-drv/./ch376.c:247: ch_command(CH_CMD_SET_USB_ADDR); push hl ld l,0x13 call _ch_command pop hl -;source-doc/base-drv/./ch376.c:236: CH376_DATA_PORT = device_address; +;source-doc/base-drv/./ch376.c:248: CH376_DATA_PORT = device_address; ld a, l ld bc,_CH376_DATA_PORT out (c),a -;source-doc/base-drv/./ch376.c:237: delay(); -;source-doc/base-drv/./ch376.c:238: } +;source-doc/base-drv/./ch376.c:249: delay(); +;source-doc/base-drv/./ch376.c:250: } jp _delay _result: DEFB +0x00 diff --git a/Source/HBIOS/ch376-native/base-drv/class_hub.c.s b/Source/HBIOS/ch376-native/base-drv/class_hub.c.s index 37be1196..2ba02fa6 100644 --- a/Source/HBIOS/ch376-native/base-drv/class_hub.c.s +++ b/Source/HBIOS/ch376-native/base-drv/class_hub.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -53,17 +53,12 @@ _USB_MODULE_LEDS .EQU 0xff8a ; Function hub_get_descriptor ; --------------------------------- _hub_get_descriptor: - push ix - ld ix,0 - add ix,sp - dec sp ;source-doc/base-drv/./class_hub.c:8: return usb_control_transfer(&cmd_get_hub_descriptor, hub_description, hub_config->address, hub_config->max_packet_size); - ld c,l + ld a,l ld b,h inc hl - ld a, (hl) - ld (ix-1),a - ld l, c + ld c, (hl) + ld l, a ld h, b ld a, (hl) rlca @@ -72,12 +67,13 @@ _hub_get_descriptor: rlca and 0x0f ld b, a - ld a,(ix-1) - ld c,b - ld b,a + ld hl,_cmd_get_hub_descriptor + ld a, c + push af + inc sp push bc + inc sp push de - ld hl,_cmd_get_hub_descriptor push hl call _usb_control_transfer pop af @@ -85,8 +81,6 @@ _hub_get_descriptor: pop af ld a, l ;source-doc/base-drv/./class_hub.c:9: } - inc sp - pop ix ret _cmd_get_hub_descriptor: DEFB +0xa0 diff --git a/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s b/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s index 200bb6b2..962ed8e1 100644 --- a/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s +++ b/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -53,12 +53,12 @@ _USB_MODULE_LEDS .EQU 0xff8a ; Function usbdev_control_transfer ; --------------------------------- _usbdev_control_transfer: + push ix + ld ix,0 + add ix,sp ;source-doc/base-drv/./dev_transfers.c:29: return usb_control_transfer(cmd_packet, buffer, device->address, device->max_packet_size); - ld hl,2 - add hl, sp - ld e, (hl) - inc hl - ld d, (hl) + ld e,(ix+4) + ld d,(ix+5) ld l, e ld h, d inc hl @@ -70,23 +70,22 @@ _usbdev_control_transfer: rlca rlca and 0x0f - ld iy,6 - add iy, sp - ld e,(iy+0) - ld d,(iy+1) - ld c,a + ld e,(ix+8) + ld d,(ix+9) push bc + inc sp + push af + inc sp push de - dec iy - dec iy - ld l,(iy+0) - ld h,(iy+1) + ld l,(ix+6) + ld h,(ix+7) push hl call _usb_control_transfer pop af pop af pop af ;source-doc/base-drv/./dev_transfers.c:30: } + pop ix ret ;source-doc/base-drv/./dev_transfers.c:32: usb_error usbdev_blk_out_trnsfer(device_config *const dev, const uint8_t *const buffer, const uint16_t buffer_size) { ; --------------------------------- @@ -96,15 +95,13 @@ _usbdev_blk_out_trnsfer: push ix ld ix,0 add ix,sp - dec sp + push af ;source-doc/base-drv/./dev_transfers.c:36: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_OUT]; ld c,(ix+4) ld b,(ix+5) - ld e, c - ld d, b - inc de - inc de - inc de + ld hl,0x0003 + add hl, bc + ex (sp), hl ;source-doc/base-drv/./dev_transfers.c:38: result = usb_data_out_transfer(buffer, buffer_size, dev->address, endpoint); ld l, c ld h, b @@ -115,8 +112,11 @@ _usbdev_blk_out_trnsfer: rlca and 0x0f push bc + pop de + pop hl + push hl push de - push de + push hl push af inc sp ld l,(ix+8) @@ -130,18 +130,17 @@ _usbdev_blk_out_trnsfer: pop af pop af inc sp - pop de + ld d, l pop bc ;source-doc/base-drv/./dev_transfers.c:40: if (result == USB_ERR_STALL) { - ld a, l + ld a, d sub 0x02 jr NZ,l_usbdev_blk_out_trnsfer_00102 ;source-doc/base-drv/./dev_transfers.c:41: usbtrn_clear_endpoint_halt(endpoint->number, dev->address, dev->max_packet_size); ld l, c ld h, b inc hl - ld a, (hl) - ld (ix-1),a + ld d, (hl) ld l, c ld h, b ld a, (hl) @@ -151,30 +150,33 @@ _usbdev_blk_out_trnsfer: rlca and 0x0f ld b, a - ld l, e - ld h, d + pop hl + push hl ld a, (hl) rrca and 0x07 push de - ld h,(ix-1) - ld l,b - push hl + inc sp + push bc + inc sp push af inc sp call _usbtrn_clear_endpoint_halt pop af inc sp - pop de ;source-doc/base-drv/./dev_transfers.c:42: endpoint->toggle = 0; - ex de, hl + pop hl + push hl res 0, (hl) ;source-doc/base-drv/./dev_transfers.c:43: return USB_ERR_STALL; ld l,0x02 -;source-doc/base-drv/./dev_transfers.c:46: RETURN_CHECK(result); + jr l_usbdev_blk_out_trnsfer_00103 l_usbdev_blk_out_trnsfer_00102: +;source-doc/base-drv/./dev_transfers.c:46: RETURN_CHECK(result); + ld l, d +l_usbdev_blk_out_trnsfer_00103: ;source-doc/base-drv/./dev_transfers.c:47: } - inc sp + ld sp, ix pop ix ret ;source-doc/base-drv/./dev_transfers.c:49: usb_error usbdev_bulk_in_transfer(device_config *const dev, uint8_t *const buffer, uint8_t *const buffer_size) { @@ -185,16 +187,16 @@ _usbdev_bulk_in_transfer: push ix ld ix,0 add ix,sp - dec sp + push af ;source-doc/base-drv/./dev_transfers.c:53: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_IN]; ld c,(ix+4) ld b,(ix+5) ld hl,0x0006 add hl, bc + ex (sp), hl ;source-doc/base-drv/./dev_transfers.c:55: result = usb_data_in_transfer_n(buffer, buffer_size, dev->address, endpoint); - ld e,c - ld d,b - ex de,hl + ld l, c + ld h, b ld a, (hl) rlca rlca @@ -202,8 +204,11 @@ _usbdev_bulk_in_transfer: rlca and 0x0f push bc + pop de + pop hl + push hl push de - push de + push hl push af inc sp ld l,(ix+8) @@ -217,18 +222,17 @@ _usbdev_bulk_in_transfer: pop af pop af inc sp - pop de + ld d, l pop bc ;source-doc/base-drv/./dev_transfers.c:57: if (result == USB_ERR_STALL) { - ld a, l + ld a, d sub 0x02 jr NZ,l_usbdev_bulk_in_transfer_00102 ;source-doc/base-drv/./dev_transfers.c:58: usbtrn_clear_endpoint_halt(endpoint->number, dev->address, dev->max_packet_size); ld l, c ld h, b inc hl - ld a, (hl) - ld (ix-1),a + ld d, (hl) ld l, c ld h, b ld a, (hl) @@ -238,30 +242,33 @@ _usbdev_bulk_in_transfer: rlca and 0x0f ld b, a - ld l, e - ld h, d + pop hl + push hl ld a, (hl) rrca and 0x07 push de - ld h,(ix-1) - ld l,b - push hl + inc sp + push bc + inc sp push af inc sp call _usbtrn_clear_endpoint_halt pop af inc sp - pop de ;source-doc/base-drv/./dev_transfers.c:59: endpoint->toggle = 0; - ex de, hl + pop hl + push hl res 0, (hl) ;source-doc/base-drv/./dev_transfers.c:60: return USB_ERR_STALL; ld l,0x02 -;source-doc/base-drv/./dev_transfers.c:63: RETURN_CHECK(result); + jr l_usbdev_bulk_in_transfer_00103 l_usbdev_bulk_in_transfer_00102: +;source-doc/base-drv/./dev_transfers.c:63: RETURN_CHECK(result); + ld l, d +l_usbdev_bulk_in_transfer_00103: ;source-doc/base-drv/./dev_transfers.c:64: } - inc sp + ld sp, ix pop ix ret ;source-doc/base-drv/./dev_transfers.c:66: usb_error usbdev_dat_in_trnsfer(device_config *const device, @@ -272,7 +279,7 @@ _usbdev_dat_in_trnsfer: push ix ld ix,0 add ix,sp - dec sp + push af ;source-doc/base-drv/./dev_transfers.c:73: endpoint_param *const endpoint = &device->endpoints[endpoint_type]; ld c,(ix+4) ld b,(ix+5) @@ -282,17 +289,19 @@ _usbdev_dat_in_trnsfer: inc de inc de push de - ld l,(ix+10) - ld e, l - add hl, hl - add hl, de + ld a,(ix+10) + ld e, a + add a, a + add a, e pop de - ld h,0x00 - add hl, de + add a, e + ld (ix-2),a + ld a,0x00 + adc a, d + ld (ix-1),a ;source-doc/base-drv/./dev_transfers.c:75: result = usb_data_in_transfer(buffer, buffer_size, device->address, endpoint); - ld e,c - ld d,b - ex de,hl + ld l, c + ld h, b ld a, (hl) rlca rlca @@ -300,8 +309,11 @@ _usbdev_dat_in_trnsfer: rlca and 0x0f push bc + pop de + pop hl + push hl push de - push de + push hl push af inc sp ld l,(ix+8) @@ -315,18 +327,17 @@ _usbdev_dat_in_trnsfer: pop af pop af inc sp - pop de + ld d, l pop bc ;source-doc/base-drv/./dev_transfers.c:77: if (result == USB_ERR_STALL) { - ld a, l + ld a, d sub 0x02 jr NZ,l_usbdev_dat_in_trnsfer_00102 ;source-doc/base-drv/./dev_transfers.c:78: usbtrn_clear_endpoint_halt(endpoint->number, device->address, device->max_packet_size); ld l, c ld h, b inc hl - ld a, (hl) - ld (ix-1),a + ld d, (hl) ld l, c ld h, b ld a, (hl) @@ -336,30 +347,33 @@ _usbdev_dat_in_trnsfer: rlca and 0x0f ld b, a - ld l, e - ld h, d + pop hl + push hl ld a, (hl) rrca and 0x07 push de - ld h,(ix-1) - ld l,b - push hl + inc sp + push bc + inc sp push af inc sp call _usbtrn_clear_endpoint_halt pop af inc sp - pop de ;source-doc/base-drv/./dev_transfers.c:79: endpoint->toggle = 0; - ex de, hl + pop hl + push hl res 0, (hl) ;source-doc/base-drv/./dev_transfers.c:80: return USB_ERR_STALL; ld l,0x02 -;source-doc/base-drv/./dev_transfers.c:83: RETURN_CHECK(result); + jr l_usbdev_dat_in_trnsfer_00103 l_usbdev_dat_in_trnsfer_00102: +;source-doc/base-drv/./dev_transfers.c:83: RETURN_CHECK(result); + ld l, d +l_usbdev_dat_in_trnsfer_00103: ;source-doc/base-drv/./dev_transfers.c:84: } - inc sp + ld sp, ix pop ix ret ;source-doc/base-drv/./dev_transfers.c:86: usb_error usbdev_dat_in_trnsfer_0(device_config *const device, uint8_t *const buffer, const uint8_t buffer_size) __sdcccall(1) { @@ -370,14 +384,16 @@ _usbdev_dat_in_trnsfer_0: push ix ld ix,0 add ix,sp + push af + push af + ld c, l + ld b, h + ld (ix-2),e + ld (ix-1),d ;source-doc/base-drv/./dev_transfers.c:90: endpoint_param *const endpoint = &device->endpoints[0]; - push hl - ld c,l - ld b,h - pop iy - inc iy - inc iy - inc iy + ld hl,0x0003 + add hl, bc + ex (sp), hl ;source-doc/base-drv/./dev_transfers.c:92: result = usb_data_in_transfer(buffer, buffer_size, device->address, endpoint); ld l, c ld h, b @@ -387,22 +403,24 @@ _usbdev_dat_in_trnsfer_0: rlca rlca and 0x0f - ld l,(ix+4) - ld h,0x00 + ld e,(ix+4) + ld d,0x00 push bc - push iy - push iy + ld l,(ix-4) + ld h,(ix-3) + push hl push af inc sp - push hl push de + ld l,(ix-2) + ld h,(ix-1) + push hl call _usb_data_in_transfer pop af pop af pop af inc sp ld d, l - pop iy pop bc ;source-doc/base-drv/./dev_transfers.c:94: if (result == USB_ERR_STALL) { ld a, d @@ -422,23 +440,23 @@ _usbdev_dat_in_trnsfer_0: rlca and 0x0f ld b, a - push iy pop hl + push hl ld a, (hl) rrca and 0x07 - push iy - ld e,b push de + inc sp + push bc + inc sp push af inc sp call _usbtrn_clear_endpoint_halt pop af inc sp - pop iy ;source-doc/base-drv/./dev_transfers.c:96: endpoint->toggle = 0; - push iy pop hl + push hl res 0, (hl) ;source-doc/base-drv/./dev_transfers.c:97: return USB_ERR_STALL; ld a,0x02 @@ -448,6 +466,7 @@ l_usbdev_dat_in_trnsfer_0_00102: ld a, d l_usbdev_dat_in_trnsfer_0_00103: ;source-doc/base-drv/./dev_transfers.c:101: } + ld sp, ix pop ix pop hl inc sp diff --git a/Source/HBIOS/ch376-native/base-drv/enumerate.c.s b/Source/HBIOS/ch376-native/base-drv/enumerate.c.s index 34a3b265..91a0e9bc 100644 --- a/Source/HBIOS/ch376-native/base-drv/enumerate.c.s +++ b/Source/HBIOS/ch376-native/base-drv/enumerate.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -53,34 +53,41 @@ _USB_MODULE_LEDS .EQU 0xff8a ; Function parse_endpoint_keyboard ; --------------------------------- _parse_endpoint_keyboard: + push ix + ld ix,0 + add ix,sp + push af ;source-doc/base-drv/./enumerate.c:15: endpoint_param *const ep = &keyboard_config->endpoints[0]; inc hl inc hl inc hl - push hl - pop iy + ld c,l + ld b,h ;source-doc/base-drv/./enumerate.c:16: ep->number = pEndpoint->bEndpointAddress; - push iy - pop bc + inc sp + inc sp + push bc ld l, e ld h, d inc hl inc hl ld a, (hl) + pop hl + push hl rlca and 0x0e - ld l, a - ld a, (bc) + push bc + ld c, a + ld a, (hl) and 0xf1 - or l - ld (bc), a + or c + ld (hl), a + pop bc ;source-doc/base-drv/./enumerate.c:17: ep->toggle = 0; - push iy - pop hl + ld l, c + ld h, b res 0, (hl) ;source-doc/base-drv/./enumerate.c:18: ep->max_packet_sizex = calc_max_packet_sizex(pEndpoint->wMaxPacketSize); - push iy - pop bc inc bc ld hl,4 add hl, de @@ -100,6 +107,8 @@ _parse_endpoint_keyboard: or l ld (bc), a ;source-doc/base-drv/./enumerate.c:19: } + ld sp, ix + pop ix ret ;source-doc/base-drv/./enumerate.c:21: usb_device_type identify_class_driver(_working *const working) { ; --------------------------------- @@ -109,6 +118,8 @@ _identify_class_driver: push ix ld ix,0 add ix,sp + push af + dec sp ;source-doc/base-drv/./enumerate.c:22: const interface_descriptor *const p = (const interface_descriptor *)working->ptr; ld c,(ix+4) ld b,(ix+5) @@ -118,39 +129,48 @@ _identify_class_driver: inc hl ld b, (hl) ;source-doc/base-drv/./enumerate.c:23: if (p->bInterfaceClass == 2) - push bc - pop iy - ld e,(iy+5) + ld e, c + ld d, b + ld hl,5 + add hl, de + ld e, (hl) ld a, e sub 0x02 jr NZ,l_identify_class_driver_00102 ;source-doc/base-drv/./enumerate.c:24: return USB_IS_CDC; ld l,0x03 - jr l_identify_class_driver_00118 + jp l_identify_class_driver_00118 l_identify_class_driver_00102: ;source-doc/base-drv/./enumerate.c:26: if (p->bInterfaceClass == 8 && (p->bInterfaceSubClass == 6 || p->bInterfaceSubClass == 5) && p->bInterfaceProtocol == 80) ld a, e sub 0x08 - jr NZ,l_identify_class_driver_00177 + jr NZ,l_identify_class_driver_00199 ld a,0x01 - jr l_identify_class_driver_00178 -l_identify_class_driver_00177: + jr l_identify_class_driver_00200 +l_identify_class_driver_00199: xor a -l_identify_class_driver_00178: - ld d,a +l_identify_class_driver_00200: + ld (ix-3),a + ld hl,0x0006 + add hl, bc + ld (ix-2),l + ld (ix-1),h + ld hl,0x0007 + add hl, bc + ld c, l + ld b, h + ld a,(ix-3) or a jr Z,l_identify_class_driver_00104 - ld hl,0x0006 - add hl,bc + ld l,(ix-2) + ld h,(ix-1) ld a, (hl) cp 0x06 jr Z,l_identify_class_driver_00107 sub 0x05 jr NZ,l_identify_class_driver_00104 l_identify_class_driver_00107: - ld hl,0x0007 - add hl,bc - ld a, (hl) + ld a, (bc) sub 0x50 jr NZ,l_identify_class_driver_00104 ;source-doc/base-drv/./enumerate.c:27: return USB_IS_MASS_STORAGE; @@ -158,17 +178,15 @@ l_identify_class_driver_00107: jr l_identify_class_driver_00118 l_identify_class_driver_00104: ;source-doc/base-drv/./enumerate.c:29: if (p->bInterfaceClass == 8 && p->bInterfaceSubClass == 4 && p->bInterfaceProtocol == 0) - ld a, d + ld a,(ix-3) or a jr Z,l_identify_class_driver_00109 - ld hl,0x0006 - add hl,bc + ld l,(ix-2) + ld h,(ix-1) ld a, (hl) sub 0x04 jr NZ,l_identify_class_driver_00109 - ld hl,0x0007 - add hl,bc - ld a, (hl) + ld a, (bc) or a jr NZ,l_identify_class_driver_00109 ;source-doc/base-drv/./enumerate.c:30: return USB_IS_FLOPPY; @@ -179,14 +197,12 @@ l_identify_class_driver_00109: ld a, e sub 0x09 jr NZ,l_identify_class_driver_00113 - ld hl,0x0006 - add hl,bc + ld l,(ix-2) + ld h,(ix-1) ld a, (hl) or a jr NZ,l_identify_class_driver_00113 - ld hl,7 - add hl, bc - ld a, (hl) + ld a, (bc) or a jr NZ,l_identify_class_driver_00113 ;source-doc/base-drv/./enumerate.c:33: return USB_IS_HUB; @@ -205,6 +221,7 @@ l_identify_class_driver_00117: ld l,0x06 l_identify_class_driver_00118: ;source-doc/base-drv/./enumerate.c:39: } + ld sp, ix pop ix ret ;source-doc/base-drv/./enumerate.c:41: usb_error op_interface_next(_working *const working) __z88dk_fastcall { @@ -278,19 +295,25 @@ l_op_endpoint_next_00103: ; Function op_parse_endpoint ; --------------------------------- _op_parse_endpoint: + push ix + ld ix,0 + add ix,sp + push af ;source-doc/base-drv/./enumerate.c:58: const endpoint_descriptor *endpoint = (endpoint_descriptor *)working->ptr; ld c,l ld b,h - ld hl,27 - add hl,bc - ld e, (hl) - inc hl - ld d, (hl) - push de - pop iy + ld de,0x001c + add hl, de + ld a, (hl) + dec hl + ld l, (hl) + ld (ix-2),l + ld (ix-1),a ;source-doc/base-drv/./enumerate.c:59: device_config *const device = working->p_current_device; + ld e, c + ld d, b ld hl,29 - add hl,bc + add hl, de ld e, (hl) inc hl ld d, (hl) @@ -311,7 +334,9 @@ _op_parse_endpoint: l_op_parse_endpoint_00102: ;source-doc/base-drv/./enumerate.c:64: parse_endpoints(device, endpoint); push bc - push iy + ld l,(ix-2) + ld h,(ix-1) + push hl push de call _parse_endpoints pop af @@ -324,8 +349,8 @@ l_op_parse_endpoint_00103: ;source-doc/base-drv/./enumerate.c:69: parse_endpoint_keyboard((device_config_keyboard *)device, endpoint); ex de, hl push bc - push iy - pop de + ld e,(ix-2) + ld d,(ix-1) call _parse_endpoint_keyboard pop bc ;source-doc/base-drv/./enumerate.c:72: } @@ -333,8 +358,11 @@ l_op_parse_endpoint_00104: ;source-doc/base-drv/./enumerate.c:74: return op_endpoint_next(working); ld l, c ld h, b + call _op_endpoint_next ;source-doc/base-drv/./enumerate.c:75: } - jp _op_endpoint_next + ld sp, ix + pop ix + ret ;source-doc/base-drv/./enumerate.c:78: configure_device(const _working *const working, const interface_descriptor *const interface, device_config *const dev_cfg) { ; --------------------------------- ; Function configure_device @@ -344,84 +372,83 @@ _configure_device: ld ix,0 add ix,sp push af + push af ;source-doc/base-drv/./enumerate.c:79: dev_cfg->interface_number = interface->bInterfaceNumber; - ld e,(ix+8) - ld d,(ix+9) - ld c, e - ld b, d + ld a,(ix+8) + ld (ix-4),a + ld a,(ix+9) + ld (ix-3),a + pop bc + push bc inc bc inc bc - ld l,(ix+6) - ld h,(ix+7) - inc hl - inc hl - ld a, (hl) + ld e,(ix+6) + ld d,(ix+7) + inc de + inc de + ld a, (de) ld (bc), a ;source-doc/base-drv/./enumerate.c:80: dev_cfg->max_packet_size = working->desc.bMaxPacketSize0; - ld hl,0x0001 - add hl, de - ex (sp), hl - push iy - ex (sp), hl - ld l,(ix+4) - ex (sp), hl - ex (sp), hl - ld h,(ix+5) - ex (sp), hl - pop iy - push iy - pop bc + ld a,(ix-4) + add a,0x01 + ld (ix-2),a + ld a,(ix-3) + adc a,0x00 + ld (ix-1),a + ld c,(ix+4) + ld b,(ix+5) + ld e, c + ld d, b ld hl,10 - add hl, bc + add hl, de ld a, (hl) + pop de pop hl push hl + push de ld (hl), a ;source-doc/base-drv/./enumerate.c:81: dev_cfg->address = working->current_device_address; - ld c, e - ld b, d - push iy - pop hl - ld a,+((0x0018) & 0xFF) - add a,l - ld l,a - ld a,+((0x0018) / 256) - adc a,h - ld h,a + pop de + push de + ld l, c + ld h, b + push bc + ld bc,0x0018 + add hl, bc + pop bc ld a, (hl) add a, a add a, a add a, a add a, a ld l, a - ld a, (bc) + ld a, (de) and 0x0f or l - ld (bc), a + ld (de), a ;source-doc/base-drv/./enumerate.c:82: dev_cfg->type = working->usb_device; - ld c, e - ld b, d - push iy - pop hl + pop de + push de + ld l, c + ld h, b inc hl inc hl ld a, (hl) and 0x0f ld l, a - ld a, (bc) + ld a, (de) and 0xf0 or l - ld (bc), a + ld (de), a ;source-doc/base-drv/./enumerate.c:84: return usbtrn_set_configuration(dev_cfg->address, dev_cfg->max_packet_size, working->config.desc.bConfigurationvalue); - push iy - pop bc ld hl,36 add hl, bc ld c, (hl) + ld l,(ix-2) + ld h,(ix-1) + ld b, (hl) pop hl - ld b,(hl) push hl - ex de, hl ld a, (hl) rlca rlca @@ -429,8 +456,10 @@ _configure_device: rlca and 0x0f ld h, c - ld l,b push hl + inc sp + push bc + inc sp push af inc sp call _usbtrn_set_configuration @@ -446,17 +475,21 @@ _op_capture_hub_driver_interfac: push ix ld ix,0 add ix,sp - ld iy, -7 - add iy, sp - ld sp, iy + push af + push af + push af + dec sp + ex de, hl ;source-doc/base-drv/./enumerate.c:88: const interface_descriptor *const interface = (interface_descriptor *)working->ptr; - push hl - ex de,hl - pop iy - ld c,(iy+28) - ld a,(iy+27) - ld (ix-4),a - ld (ix-3),c + ld l, e + ld h, d + ld bc,0x001c + add hl, bc + ld a, (hl) + dec hl + ld l, (hl) + ld (ix-4),l + ld (ix-3),a ;source-doc/base-drv/./enumerate.c:92: working->hub_config = &hub_config; ld hl,0x0019 add hl, de @@ -465,8 +498,8 @@ _op_capture_hub_driver_interfac: ld hl,0 add hl, sp ld c, l + ld b, h ld l,(ix-2) - ld b,h ld h,(ix-1) ld (hl), c inc hl @@ -490,9 +523,10 @@ _op_capture_hub_driver_interfac: pop af pop af pop af - ld a, l pop de - or a + ld a, l + inc l + dec l jr NZ,l_op_capture_hub_driver_interfa ;source-doc/base-drv/./enumerate.c:96: RETURN_CHECK(configure_usb_hub(working)); ex de, hl @@ -511,12 +545,16 @@ _op_cap_drv_intf: push ix ld ix,0 add ix,sp - ld iy, -16 - add iy, sp - ld sp, iy + ld c, l + ld b, h + ld hl, -16 + add hl, sp + ld sp, hl + ld (ix-2),c + ld (ix-1),b ;source-doc/base-drv/./enumerate.c:102: const interface_descriptor *const interface = (interface_descriptor *)working->ptr; - ld (ix-2),l - ld (ix-1),h + ld l,(ix-2) + ld h,(ix-1) ld de,0x001b add hl, de ld e, (hl) @@ -541,27 +579,33 @@ _op_cap_drv_intf: ld a,(ix-1) adc a,0x00 ld d, a - push bc - pop iy - ld a,(iy+4) + ld l, c + ld h, b + inc hl + inc hl + inc hl + inc hl + ld a, (hl) ld (de), a ;source-doc/base-drv/./enumerate.c:106: working->p_current_device = NULL; - ld l,(ix-2) - ld h,(ix-1) - ld de,0x001d - add hl,de - ld (ix-4),l - ld (ix-3),h + ld a,(ix-2) + add a,0x1d + ld (ix-4),a + ld a,(ix-1) + adc a,0x00 + ld (ix-3),a + ld l,(ix-4) + ld h,(ix-3) xor a ld (hl), a inc hl ld (hl), a ;source-doc/base-drv/./enumerate.c:108: switch (working->usb_device) { - ld e,(ix-2) - ld d,(ix-1) - inc de - inc de - ld a, (de) + ld l,(ix-2) + ld h,(ix-1) + inc hl + inc hl + ld a, (hl) cp 0x06 jr Z,l_op_cap_drv_intf_00104 sub 0x0f @@ -580,12 +624,11 @@ l_op_cap_drv_intf_00104: push bc ld hl,2 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x0c - push hl - call _memset_callee + ld b,0x0c +l_op_cap_drv_intf_00169: + ld (hl),0x00 + inc hl + djnz l_op_cap_drv_intf_00169 pop bc ;source-doc/base-drv/./enumerate.c:117: working->p_current_device = &unkown_dev_cfg; ld hl,0 @@ -617,11 +660,11 @@ l_op_cap_drv_intf_00107: ;source-doc/base-drv/./enumerate.c:123: device_config *dev_cfg = find_first_free(); push bc call _find_first_free -;source-doc/base-drv/./enumerate.c:124: if (dev_cfg == NULL) + ex de, hl pop bc - ld a,h - or l - ex de,hl +;source-doc/base-drv/./enumerate.c:124: if (dev_cfg == NULL) + ld a, d + or e jr NZ,l_op_cap_drv_intf_00109 ;source-doc/base-drv/./enumerate.c:125: return USB_ERR_OUT_OF_MEMORY; ld l,0x83 @@ -669,17 +712,21 @@ l_op_cap_drv_intf_00115: ; Function op_id_class_drv ; --------------------------------- _op_id_class_drv: + ex de, hl ;source-doc/base-drv/./enumerate.c:139: const interface_descriptor *const ptr = (const interface_descriptor *)working->ptr; - push hl - ex de,hl - pop iy - ld l,(iy+27) - ld h,(iy+28) + ld l, e + ld h, d + ld bc,0x001c + add hl, bc + ld a, (hl) + dec hl + ld l, (hl) ;source-doc/base-drv/./enumerate.c:141: working->usb_device = ptr->bLength > 5 ? identify_class_driver(working) : 0; ld c, e ld b, d inc bc inc bc + ld h, a ld l, (hl) ld a,0x05 sub l @@ -692,11 +739,9 @@ _op_id_class_drv: ld a, l pop de pop bc - ld l,0x00 jr l_op_id_class_drv_00106 l_op_id_class_drv_00105: xor a - ld l, a l_op_id_class_drv_00106: ld (bc), a ;source-doc/base-drv/./enumerate.c:143: CHECK(op_cap_drv_intf(working)); @@ -713,22 +758,22 @@ l_op_id_class_drv_00106: ; Function op_get_cfg_desc ; --------------------------------- _op_get_cfg_desc: + push ix + ld ix,0 + add ix,sp + push af ex de, hl ;source-doc/base-drv/./enumerate.c:151: memset(working->config.buffer, 0, MAX_CONFIG_SIZE); - ld iy,0x001f - add iy, de - push iy - pop bc - push de - push iy - push bc - ld hl,0x0000 - push hl - ld l,0x8c + ld hl,0x001f + add hl, de + ex (sp), hl + pop hl push hl - call _memset_callee - pop iy - pop de + ld b,0x8c +l_op_get_cfg_desc_00121: + ld (hl),0x00 + inc hl + djnz l_op_get_cfg_desc_00121 ;source-doc/base-drv/./enumerate.c:153: const uint8_t max_packet_size = working->desc.bMaxPacketSize0; ld c, e ld b, d @@ -752,21 +797,23 @@ _op_get_cfg_desc: pop bc ld c, (hl) push de - push iy - push iy + ld l,(ix-2) + ld h,(ix-1) + push hl ld h,0x8c - ld l,a push hl + inc sp + push af + inc sp push bc call _usbtrn_gfull_cfg_desc pop af pop af pop af ld a, l - pop iy pop de or a - ret NZ + jr NZ,l_op_get_cfg_desc_00105 ;source-doc/base-drv/./enumerate.c:158: working->ptr = (working->config.buffer + sizeof(config_descriptor)); ld hl,0x001b add hl, de @@ -789,8 +836,8 @@ _op_get_cfg_desc: add hl, de ld c, l ld b, h - push iy pop hl + push hl inc hl inc hl inc hl @@ -801,9 +848,12 @@ _op_get_cfg_desc: ex de, hl call _op_id_class_drv or a - ret NZ + jr NZ,l_op_get_cfg_desc_00105 ;source-doc/base-drv/./enumerate.c:163: return result; +l_op_get_cfg_desc_00105: ;source-doc/base-drv/./enumerate.c:164: } + ld sp, ix + pop ix ret ;source-doc/base-drv/./enumerate.c:166: usb_error read_all_configs(enumeration_state *const state) { ; --------------------------------- @@ -819,17 +869,17 @@ _read_all_configs: ;source-doc/base-drv/./enumerate.c:171: memset(&working, 0, sizeof(_working)); ld hl,0 add hl, sp - push hl - push hl - ld hl,0x0000 - push hl - ld l,0xab - push hl - call _memset_callee + ex de, hl + ld l, e + ld h, d + ld b,0xab +l_read_all_configs_00148: + ld (hl),0x00 + inc hl + djnz l_read_all_configs_00148 ;source-doc/base-drv/./enumerate.c:172: working.state = state; - pop hl - ld e,l - ld d,h + ld l, e + ld h, d ld a,(ix+4) ld (hl), a inc hl @@ -842,23 +892,31 @@ _read_all_configs: push hl call _usbtrn_get_descriptor pop af + ld c, l pop de - ld a, l + ld a, c or a - jr NZ,l_read_all_configs_00111 + jr Z,l_read_all_configs_00102 + ld l, c + jr l_read_all_configs_00111 +l_read_all_configs_00102: ;source-doc/base-drv/./enumerate.c:176: state->next_device_address++; - ld l,(ix+4) - ld h,(ix+5) - ld c, (hl) - inc c - ld (hl), c + ld a,(ix+4) + ld c,(ix+5) + ld l, a + ld h, c + ld b, (hl) + inc b + ld l, a + ld h, c + ld (hl), b ;source-doc/base-drv/./enumerate.c:177: working.current_device_address = state->next_device_address; ld hl,0x0018 add hl, de - ld (hl), c + ld (hl), b ;source-doc/base-drv/./enumerate.c:178: CHECK(usbtrn_set_address(working.current_device_address)); push de - ld l, c + ld l, b call _usbtrn_set_address pop de ld a, l @@ -867,7 +925,7 @@ _read_all_configs: jr NZ,l_read_all_configs_00111 ld c,a l_read_all_configs_00109: - ld hl,20+0 + ld hl,20 add hl, sp ld b, (hl) ld a, c @@ -907,30 +965,29 @@ l_read_all_configs_00111: ; --------------------------------- _enumerate_all_devices: push ix - ld ix,0 - add ix,sp dec sp ;source-doc/base-drv/./enumerate.c:190: _usb_state *const work_area = get_usb_work_area(); ;source-doc/base-drv/./enumerate.c:192: memset(&state, 0, sizeof(enumeration_state)); ld hl,0 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x01 - push hl - call _memset_callee + ex de, hl + ld l, e + ld h, d + ld (hl),0x00 ;source-doc/base-drv/./enumerate.c:193: state.next_device_address = 0; - ld (ix-1),0x00 + xor a + ld (de), a ;source-doc/base-drv/./enumerate.c:195: usb_error result = read_all_configs(&state); - ld hl,0 - add hl, sp - push hl + ld c, e + ld b, d + push de + push bc call _read_all_configs pop af + ld c, l + pop de ;source-doc/base-drv/./enumerate.c:197: work_area->count_of_detected_usb_devices = state.next_device_address; - ld a,(ix-1) - ld c,l + ld a, (de) ld ((_x + 1)),a ;source-doc/base-drv/./enumerate.c:199: CHECK(result); ld a, c diff --git a/Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s b/Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s index 7974a653..69ffc3bd 100644 --- a/Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s +++ b/Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -62,10 +62,15 @@ _hub_set_feature: ;source-doc/base-drv/./enumerate_hub.c:15: set_feature = cmd_set_feature; ld hl,0 add hl, sp - ex de, hl - ld bc,0x0008 + ld c, l + ld b, h + ld e, c + ld d, b + push bc ld hl,_cmd_set_feature + ld bc,0x0008 ldir + pop bc ;source-doc/base-drv/./enumerate_hub.c:17: set_feature.bValue[0] = feature; ld a,(ix+6) ld (ix-6),a @@ -73,26 +78,28 @@ _hub_set_feature: ld a,(ix+7) ld (ix-4),a ;source-doc/base-drv/./enumerate_hub.c:19: return usb_control_transfer(&set_feature, 0, hub_config->address, hub_config->max_packet_size); - ld l,(ix+4) - ld h,(ix+5) - ld e,l - ld d,h + ld a,(ix+4) + ld d,(ix+5) + ld l, a + ld h, d inc hl - ld b, (hl) - ex de, hl + ld e, (hl) + ld l, a + ld h, d ld a, (hl) rlca rlca rlca rlca and 0x0f - ld c,a - push bc - ld hl,0x0000 + ld h, e push hl - ld hl,4 - add hl, sp + inc sp + push af + inc sp + ld hl,0x0000 push hl + push bc call _usb_control_transfer ;source-doc/base-drv/./enumerate_hub.c:20: } ld sp,ix @@ -136,10 +143,15 @@ _hub_clear_feature: ;source-doc/base-drv/./enumerate_hub.c:24: clear_feature = cmd_clear_feature; ld hl,0 add hl, sp - ex de, hl - ld bc,0x0008 + ld c, l + ld b, h + ld e, c + ld d, b + push bc ld hl,_cmd_clear_feature + ld bc,0x0008 ldir + pop bc ;source-doc/base-drv/./enumerate_hub.c:26: clear_feature.bValue[0] = feature; ld a,(ix+6) ld (ix-6),a @@ -147,26 +159,28 @@ _hub_clear_feature: ld a,(ix+7) ld (ix-4),a ;source-doc/base-drv/./enumerate_hub.c:28: return usb_control_transfer(&clear_feature, 0, hub_config->address, hub_config->max_packet_size); - ld l,(ix+4) - ld h,(ix+5) - ld e,l - ld d,h + ld a,(ix+4) + ld d,(ix+5) + ld l, a + ld h, d inc hl - ld b, (hl) - ex de, hl + ld e, (hl) + ld l, a + ld h, d ld a, (hl) rlca rlca rlca rlca and 0x0f - ld c,a - push bc - ld hl,0x0000 + ld h, e push hl - ld hl,4 - add hl, sp + inc sp + push af + inc sp + ld hl,0x0000 push hl + push bc call _usb_control_transfer ;source-doc/base-drv/./enumerate_hub.c:29: } ld sp,ix @@ -187,17 +201,17 @@ _hub_get_status_port: ld hl,0 add hl, sp ex de, hl - ld bc,0x0008 ld hl,_cmd_get_status_port + ld bc,0x0008 ldir ;source-doc/base-drv/./enumerate_hub.c:35: get_status_port.bIndex[0] = index; ld a,(ix+6) ld (ix-4),a ;source-doc/base-drv/./enumerate_hub.c:36: return usb_control_transfer(&get_status_port, port_status, hub_config->address, hub_config->max_packet_size); - ld l,(ix+4) - ld h,(ix+5) - ld e,l - ld d,h + ld e,(ix+4) + ld d,(ix+5) + ld l, e + ld h, d inc hl ld b, (hl) ex de, hl @@ -209,11 +223,13 @@ _hub_get_status_port: and 0x0f ld e,(ix+7) ld d,(ix+8) - ld c,a + ld hl,0 + add hl, sp push bc + inc sp + push af + inc sp push de - ld hl,4 - add hl, sp push hl call _usb_control_transfer ;source-doc/base-drv/./enumerate_hub.c:37: } @@ -228,111 +244,104 @@ _configure_usb_hub: push ix ld ix,0 add ix,sp - ld iy, -14 - add iy, sp - ld sp, iy + ld c, l + ld b, h + ld hl, -15 + add hl, sp + ld sp, hl + ld (ix-3),c + ld (ix-2),b ;source-doc/base-drv/./enumerate_hub.c:45: const device_config_hub *const hub_config = working->hub_config; - push hl - ld c,l - ld b,h - pop iy - ld a,(iy+25) - ld (ix-2),a - ld a,(iy+26) - ld (ix-1),a + ld c,(ix-3) + ld b,(ix-2) + ld hl,25 + add hl, bc + ld c, (hl) + inc hl + ld b, (hl) ;source-doc/base-drv/./enumerate_hub.c:47: CHECK(hub_get_descriptor(hub_config, &hub_description)); push bc ld hl,2 add hl, sp ex de, hl - ld l,(ix-2) - ld h,(ix-1) + ld l, c + ld h, b call _hub_get_descriptor + ld e, a pop bc - ld e,a + ld a, e or a jr Z,l_configure_usb_hub_00102 ld l, e jp l_configure_usb_hub_00129 l_configure_usb_hub_00102: ;source-doc/base-drv/./enumerate_hub.c:49: uint8_t i = hub_description.bNbrPorts; - ld d,(ix-12) + ld a,(ix-13) + ld (ix-1),a ;source-doc/base-drv/./enumerate_hub.c:50: do { l_configure_usb_hub_00126: ;source-doc/base-drv/./enumerate_hub.c:51: CHECK(hub_clear_feature(hub_config, FEAT_PORT_POWER, i)); push bc - push de + ld d,(ix-1) ld e,0x08 push de - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_clear_feature pop af pop af - pop de pop bc ld a, l or a jp NZ,l_configure_usb_hub_00129 ;source-doc/base-drv/./enumerate_hub.c:53: CHECK(hub_set_feature(hub_config, FEAT_PORT_POWER, i)); push bc - push de + ld d,(ix-1) ld e,0x08 push de - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_set_feature pop af pop af - pop de pop bc ld a, l or a jp NZ,l_configure_usb_hub_00129 ;source-doc/base-drv/./enumerate_hub.c:55: hub_clear_feature(hub_config, FEAT_PORT_RESET, i); push bc - push de + ld d,(ix-1) ld e,0x04 push de - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_clear_feature pop af pop af - pop de - push de + pop bc +;source-doc/base-drv/./enumerate_hub.c:57: CHECK(hub_set_feature(hub_config, FEAT_PORT_RESET, i)); + push bc + ld d,(ix-1) ld e,0x04 push de - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_set_feature pop af pop af - pop de pop bc ld a, l or a jp NZ,l_configure_usb_hub_00129 ;source-doc/base-drv/./enumerate_hub.c:59: CHECK(hub_get_status_port(hub_config, i, &port_status)); push bc - push de - ld hl,12 + ld hl,10 add hl, sp push hl - push de + ld a,(ix-1) + push af inc sp - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_get_status_port pop af pop af inc sp - pop de pop bc ld a, l or a @@ -342,97 +351,81 @@ l_configure_usb_hub_00126: add hl, sp ld a, (hl) and 0x01 - jp Z, l_configure_usb_hub_00124 + jr Z,l_configure_usb_hub_00124 ;source-doc/base-drv/./enumerate_hub.c:62: CHECK(hub_clear_feature(hub_config, HUB_FEATURE_PORT_CONNECTION_CHA, i)); push bc - push de + ld d,(ix-1) ld e,0x10 push de - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_clear_feature pop af pop af - pop de pop bc ld a, l or a - jp NZ,l_configure_usb_hub_00129 + jr NZ,l_configure_usb_hub_00129 ;source-doc/base-drv/./enumerate_hub.c:64: CHECK(hub_clear_feature(hub_config, FEAT_PORT_ENABLE_CHANGE, i)); push bc - push de + ld d,(ix-1) ld e,0x11 push de - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_clear_feature pop af pop af - pop de pop bc ld a, l or a jr NZ,l_configure_usb_hub_00129 ;source-doc/base-drv/./enumerate_hub.c:66: CHECK(hub_clear_feature(hub_config, FEAT_PORT_RESET_CHANGE, i)); push bc - push de + ld d,(ix-1) ld e,0x14 push de - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_clear_feature pop af pop af - pop de pop bc ld a, l or a jr NZ,l_configure_usb_hub_00129 ;source-doc/base-drv/./enumerate_hub.c:67: delay_short(); push bc - push de call _delay_short - pop de - push de - ld hl,12 + pop bc +;source-doc/base-drv/./enumerate_hub.c:69: CHECK(hub_get_status_port(hub_config, i, &port_status)); + push bc + ld hl,10 add hl, sp push hl - push de + ld a,(ix-1) + push af inc sp - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_get_status_port pop af pop af inc sp - pop de pop bc ld a, l or a jr NZ,l_configure_usb_hub_00129 ;source-doc/base-drv/./enumerate_hub.c:70: delay_short(); push bc - push de call _delay_short - pop de + pop bc ;source-doc/base-drv/./enumerate_hub.c:72: CHECK(read_all_configs(working->state)); - pop hl - ld e,(hl) - ld c,l - ld b,h + ld l,(ix-3) + ld h,(ix-2) + ld e, (hl) inc hl - ld h, (hl) + ld d, (hl) push bc push de - ld l, e - push hl call _read_all_configs pop af - pop de pop bc ld a, l or a @@ -441,28 +434,23 @@ l_configure_usb_hub_00126: l_configure_usb_hub_00124: ;source-doc/base-drv/./enumerate_hub.c:75: CHECK(hub_clear_feature(hub_config, FEAT_PORT_POWER, i)); push bc - push de + ld d,(ix-1) ld e,0x08 push de - ld l,(ix-2) - ld h,(ix-1) - push hl + push bc call _hub_clear_feature pop af pop af - pop de pop bc ld a, l or a jr NZ,l_configure_usb_hub_00129 l_configure_usb_hub_00127: ;source-doc/base-drv/./enumerate_hub.c:77: } while (--i != 0); - dec d - ld a, d + dec (ix-1) + jp NZ, l_configure_usb_hub_00126 ;source-doc/base-drv/./enumerate_hub.c:79: return USB_ERR_OK; - or a - jp NZ,l_configure_usb_hub_00126 - ld l,a + ld l,0x00 l_configure_usb_hub_00129: ;source-doc/base-drv/./enumerate_hub.c:80: } ld sp, ix diff --git a/Source/HBIOS/ch376-native/base-drv/enumerate_storage.c.s b/Source/HBIOS/ch376-native/base-drv/enumerate_storage.c.s index 0c6b3b90..0211f31d 100644 --- a/Source/HBIOS/ch376-native/base-drv/enumerate_storage.c.s +++ b/Source/HBIOS/ch376-native/base-drv/enumerate_storage.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -60,17 +60,22 @@ _parse_endpoints: ;source-doc/base-drv/./enumerate_storage.c:7: if (!(pEndpoint->bmAttributes & 0x02)) ld c,(ix+6) ld b,(ix+7) - push bc - pop iy - ld a,(iy+3) + ld l, c + ld h, b + inc hl + inc hl + inc hl + ld a, (hl) ld (ix-2),a - bit 1,a + bit 1,(ix-2) ;source-doc/base-drv/./enumerate_storage.c:8: return; jr Z,l_parse_endpoints_00108 ;source-doc/base-drv/./enumerate_storage.c:10: const uint8_t x = calc_max_packet_sizex(pEndpoint->wMaxPacketSize); - push bc - pop iy - ld a,(iy+4) + ld e, c + ld d, b + ld hl,4 + add hl, de + ld a, (hl) ld (ix-1),a ;source-doc/base-drv/./enumerate_storage.c:11: endpoint_param *const eps = storage_dev->endpoints; ld e,(ix+4) @@ -82,24 +87,27 @@ _parse_endpoints: inc bc inc bc ld a, (bc) - ld c,a + ld l,a and 0x80 - ld b,0x00 + ld c, a + xor a ;source-doc/base-drv/./enumerate_storage.c:14: if (pEndpoint->bmAttributes & 0x01) { // 3 -> Interrupt bit 0,(ix-2) jr Z,l_parse_endpoints_00106 ;source-doc/base-drv/./enumerate_storage.c:15: if (!(pEndpoint->bEndpointAddress & 0x80)) - or b + or c ;source-doc/base-drv/./enumerate_storage.c:16: return; jr Z,l_parse_endpoints_00108 ;source-doc/base-drv/./enumerate_storage.c:18: ep = &eps[ENDPOINT_INTERRUPT_IN]; - ld hl,0x0006 - add hl, de - ex de, hl + ld a, e + add a,0x06 + ld e, a + jr NC,l_parse_endpoints_00107 + inc d jr l_parse_endpoints_00107 l_parse_endpoints_00106: ;source-doc/base-drv/./enumerate_storage.c:21: ep = (pEndpoint->bEndpointAddress & 0x80) ? &eps[ENDPOINT_BULK_IN] : &eps[ENDPOINT_BULK_OUT]; - or b + or c jr Z,l_parse_endpoints_00110 inc de inc de @@ -107,17 +115,17 @@ l_parse_endpoints_00106: l_parse_endpoints_00110: l_parse_endpoints_00107: ;source-doc/base-drv/./enumerate_storage.c:24: ep->number = pEndpoint->bEndpointAddress & 0x07; - ld l, e - ld h, d - ld a, c + ld c, e + ld b, d + ld a, l and 0x07 rlca and 0x0e - ld c, a - ld a, (hl) + ld l, a + ld a, (bc) and 0xf1 - or c - ld (hl), a + or l + ld (bc), a ;source-doc/base-drv/./enumerate_storage.c:25: ep->toggle = 0; ld l, e ld h, d diff --git a/Source/HBIOS/ch376-native/base-drv/print.c.s b/Source/HBIOS/ch376-native/base-drv/print.c.s index 2bfe74db..12d60c89 100644 --- a/Source/HBIOS/ch376-native/base-drv/print.c.s +++ b/Source/HBIOS/ch376-native/base-drv/print.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -50,33 +50,32 @@ ; Function print_device_mounted ; --------------------------------- _print_device_mounted: + push ix + ld ix,0 + add ix,sp ;source-doc/base-drv/./print.c:4: print_string("\r\n $"); ld hl,print_str_0 call _print_string ;source-doc/base-drv/./print.c:5: print_uint16(count); - ld iy,4 - add iy, sp - ld l,(iy+0) - ld h,0x00 + ld e,(ix+6) + ld d,0x00 + ex de, hl call _print_uint16 ;source-doc/base-drv/./print.c:6: print_string(description); - ld hl,2 - add hl, sp - ld a, (hl) - inc hl - ld h, (hl) - ld l, a + ld l,(ix+4) + ld h,(ix+5) call _print_string ;source-doc/base-drv/./print.c:7: if (count > 1) ld a,0x01 - ld iy,4 - add iy, sp - sub (iy+0) - ret NC + sub (ix+6) + jr NC,l_print_device_mounted_00103 ;source-doc/base-drv/./print.c:8: print_string("S$"); ld hl,print_str_1 + call _print_string +l_print_device_mounted_00103: ;source-doc/base-drv/./print.c:9: } - jp _print_string + pop ix + ret print_str_0: DEFB 0x0d DEFB 0x0a diff --git a/Source/HBIOS/ch376-native/base-drv/protocol.c.s b/Source/HBIOS/ch376-native/base-drv/protocol.c.s index 6d9e0b73..a7e42b9c 100644 --- a/Source/HBIOS/ch376-native/base-drv/protocol.c.s +++ b/Source/HBIOS/ch376-native/base-drv/protocol.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -48,7 +48,7 @@ _USB_MODULE_LEDS .EQU 0xff8a ;-------------------------------------------------------- ; code ;-------------------------------------------------------- -;source-doc/base-drv/./protocol.c:28: usb_error usbtrn_get_descriptor(device_descriptor *const buffer) { +;source-doc/base-drv/./protocol.c:29: usb_error usbtrn_get_descriptor(device_descriptor *const buffer) { ; --------------------------------- ; Function usbtrn_get_descriptor ; --------------------------------- @@ -59,18 +59,26 @@ _usbtrn_get_descriptor: ld hl, -8 add hl, sp ld sp, hl -;source-doc/base-drv/./protocol.c:31: cmd = cmd_get_device_descriptor; +;source-doc/base-drv/./protocol.c:32: cmd = cmd_get_device_descriptor; ld hl,0 add hl, sp ex de, hl - ld bc,0x0008 ld hl,_cmd_get_device_descriptor + ld bc,0x0008 ldir -;source-doc/base-drv/./protocol.c:32: cmd.wLength = 8; +;source-doc/base-drv/./protocol.c:33: cmd.wLength = 8; ld (ix-2),0x08 xor a ld (ix-1),a -;source-doc/base-drv/./protocol.c:34: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, 8); +;source-doc/base-drv/./protocol.c:35: debugger(); + PUSH AF + PUSH BC + XOR A + LD B, 7 + DEFB 0x49, 0xD7 + POP BC + POP AF +;source-doc/base-drv/./protocol.c:36: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, 8); ld c,(ix+4) ld b,(ix+5) ld e, c @@ -91,24 +99,24 @@ _usbtrn_get_descriptor: pop af pop af pop bc -;source-doc/base-drv/./protocol.c:36: CHECK(result); +;source-doc/base-drv/./protocol.c:38: CHECK(result); ld a, l or a jr NZ,l_usbtrn_get_descriptor_00103 -;source-doc/base-drv/./protocol.c:38: cmd = cmd_get_device_descriptor; +;source-doc/base-drv/./protocol.c:40: cmd = cmd_get_device_descriptor; ld hl,0 add hl, sp ex de, hl push bc - ld bc,0x0008 ld hl,_cmd_get_device_descriptor + ld bc,0x0008 ldir pop bc -;source-doc/base-drv/./protocol.c:39: cmd.wLength = 18; +;source-doc/base-drv/./protocol.c:41: cmd.wLength = 18; ld (ix-2),0x12 xor a ld (ix-1),a -;source-doc/base-drv/./protocol.c:40: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, buffer->bMaxPacketSize0); +;source-doc/base-drv/./protocol.c:42: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, buffer->bMaxPacketSize0); ld e,(ix+4) ld d,(ix+5) ld hl,7 @@ -127,9 +135,9 @@ _usbtrn_get_descriptor: pop af pop af pop af -;source-doc/base-drv/./protocol.c:42: RETURN_CHECK(result); +;source-doc/base-drv/./protocol.c:44: RETURN_CHECK(result); l_usbtrn_get_descriptor_00103: -;source-doc/base-drv/./protocol.c:43: } +;source-doc/base-drv/./protocol.c:45: } ld sp, ix pop ix ret @@ -141,7 +149,7 @@ _cmd_get_device_descriptor: DEFB +0x00 DEFB +0x00 DEFW +0x0008 -;source-doc/base-drv/./protocol.c:51: usb_error usbtrn_get_descriptor2(device_descriptor *const buffer, const uint8_t device_address) { +;source-doc/base-drv/./protocol.c:53: usb_error usbtrn_get_descriptor2(device_descriptor *const buffer, const uint8_t device_address) { ; --------------------------------- ; Function usbtrn_get_descriptor2 ; --------------------------------- @@ -149,85 +157,94 @@ _usbtrn_get_descriptor2: push ix ld ix,0 add ix,sp - ld hl, -10 + ld hl, -13 add hl, sp ld sp, hl -;source-doc/base-drv/./protocol.c:54: cmd = cmd_get_device_descriptor; - ld hl,0 +;source-doc/base-drv/./protocol.c:56: cmd = cmd_get_device_descriptor; + ld hl,2 add hl, sp - ld e,l - ld d,h - push hl - ld bc,0x0008 + ex de, hl ld hl,_cmd_get_device_descriptor + ld bc,0x0008 ldir - pop bc -;source-doc/base-drv/./protocol.c:55: cmd.wLength = 8; - ld (ix-4),0x08 +;source-doc/base-drv/./protocol.c:57: cmd.wLength = 8; + ld (ix-5),0x08 xor a - ld (ix-3),a -;source-doc/base-drv/./protocol.c:57: result = usb_control_transfer(&cmd, (uint8_t *)buffer, device_address, 8); + ld (ix-4),a +;source-doc/base-drv/./protocol.c:59: result = usb_control_transfer(&cmd, (uint8_t *)buffer, device_address, 8); ld a,(ix+4) ld (ix-2),a - ld l, a ld a,(ix+5) ld (ix-1),a - ld h,a - ld e, c - ld d, b - push bc - ld b,0x08 - ld c,(ix+6) + ld c,(ix-2) + ld b,(ix-1) + ld a,0x08 + push af + inc sp + ld a,(ix+6) + push af + inc sp push bc + ld hl,6 + add hl, sp push hl - push de call _usb_control_transfer pop af pop af pop af - ld a, l - pop bc - ld l, a -;source-doc/base-drv/./protocol.c:59: CHECK(result); + ld (ix-12),l + ld (ix-3),l +;source-doc/base-drv/./protocol.c:61: CHECK(result); + ld a,(ix-12) or a - jr NZ,l_usbtrn_get_descriptor2_00103 -;source-doc/base-drv/./protocol.c:61: cmd = cmd_get_device_descriptor; - ld e, c - ld d, b - push bc - ld bc,0x0008 + jr Z,l_usbtrn_get_descriptor2_00102 + ld l,(ix-3) + jr l_usbtrn_get_descriptor2_00103 +l_usbtrn_get_descriptor2_00102: +;source-doc/base-drv/./protocol.c:63: cmd = cmd_get_device_descriptor; + ex de, hl + ld hl,2 + add hl, sp + ex de, hl ld hl,_cmd_get_device_descriptor + ld bc,0x0008 ldir - pop bc -;source-doc/base-drv/./protocol.c:62: cmd.wLength = 18; - ld (ix-4),0x12 +;source-doc/base-drv/./protocol.c:64: cmd.wLength = 18; + ld (ix-5),0x12 xor a - ld (ix-3),a -;source-doc/base-drv/./protocol.c:63: RETURN_CHECK(usb_control_transfer(&cmd, (uint8_t *)buffer, device_address, buffer->bMaxPacketSize0)); - ld e,(ix+4) - ld d,(ix+5) - ld hl,7 + ld (ix-4),a +;source-doc/base-drv/./protocol.c:65: RETURN_CHECK(usb_control_transfer(&cmd, (uint8_t *)buffer, device_address, buffer->bMaxPacketSize0)); + ld a,(ix+4) + ld (ix-13),a + ld a,(ix+5) + ld (ix-12),a + pop hl + push hl + ld de,0x0007 add hl, de ld a, (hl) - ld e,(ix-2) - ld d,(ix-1) + ld (ix-3),a push af inc sp ld a,(ix+6) push af inc sp - push de - push bc + ld l,(ix-2) + ld h,(ix-1) + push hl + ld hl,6 + add hl, sp + push hl call _usb_control_transfer pop af pop af pop af l_usbtrn_get_descriptor2_00103: -;source-doc/base-drv/./protocol.c:64: } +;source-doc/base-drv/./protocol.c:66: } ld sp, ix pop ix ret -;source-doc/base-drv/./protocol.c:74: usb_error usbtrn_set_address(const uint8_t device_address) __z88dk_fastcall { +;source-doc/base-drv/./protocol.c:76: usb_error usbtrn_set_address(const uint8_t device_address) __z88dk_fastcall { ; --------------------------------- ; Function usbtrn_set_address ; --------------------------------- @@ -235,22 +252,23 @@ _usbtrn_set_address: push ix ld ix,0 add ix,sp - ld iy, -8 - add iy, sp - ld sp, iy + push af + push af + push af + push af ld c, l -;source-doc/base-drv/./protocol.c:76: cmd = cmd_set_device_address; +;source-doc/base-drv/./protocol.c:78: cmd = cmd_set_device_address; ld hl,0 add hl, sp ex de, hl push bc - ld bc,0x0008 ld hl,_cmd_set_device_address + ld bc,0x0008 ldir pop bc -;source-doc/base-drv/./protocol.c:77: cmd.bValue[0] = device_address; +;source-doc/base-drv/./protocol.c:79: cmd.bValue[0] = device_address; ld (ix-6),c -;source-doc/base-drv/./protocol.c:79: return usb_control_transfer(&cmd, 0, 0, 0); +;source-doc/base-drv/./protocol.c:81: return usb_control_transfer(&cmd, 0, 0, 0); xor a push af inc sp @@ -263,7 +281,7 @@ _usbtrn_set_address: add hl, sp push hl call _usb_control_transfer -;source-doc/base-drv/./protocol.c:80: } +;source-doc/base-drv/./protocol.c:82: } ld sp,ix pop ix ret @@ -275,7 +293,7 @@ _cmd_set_device_address: DEFB +0x00 DEFB +0x00 DEFW +0x0000 -;source-doc/base-drv/./protocol.c:90: usb_error usbtrn_set_configuration(const uint8_t device_address, const uint8_t max_packet_size, const uint8_t configuration) { +;source-doc/base-drv/./protocol.c:92: usb_error usbtrn_set_configuration(const uint8_t device_address, const uint8_t max_packet_size, const uint8_t configuration) { ; --------------------------------- ; Function usbtrn_set_configuration ; --------------------------------- @@ -286,20 +304,22 @@ _usbtrn_set_configuration: ld hl, -8 add hl, sp ld sp, hl -;source-doc/base-drv/./protocol.c:92: cmd = cmd_set_configuration; +;source-doc/base-drv/./protocol.c:94: cmd = cmd_set_configuration; ld hl,0 add hl, sp - ld e,l - ld d,h - push hl - ld bc,0x0008 + ld c, l + ld b, h + ld e, c + ld d, b + push bc ld hl,_cmd_set_configuration + ld bc,0x0008 ldir pop bc -;source-doc/base-drv/./protocol.c:93: cmd.bValue[0] = configuration; +;source-doc/base-drv/./protocol.c:95: cmd.bValue[0] = configuration; ld a,(ix+6) ld (ix-6),a -;source-doc/base-drv/./protocol.c:95: return usb_control_transfer(&cmd, 0, device_address, max_packet_size); +;source-doc/base-drv/./protocol.c:97: return usb_control_transfer(&cmd, 0, device_address, max_packet_size); ld h,(ix+5) ld l,(ix+4) push hl @@ -307,7 +327,7 @@ _usbtrn_set_configuration: push hl push bc call _usb_control_transfer -;source-doc/base-drv/./protocol.c:96: } +;source-doc/base-drv/./protocol.c:98: } ld sp,ix pop ix ret @@ -319,7 +339,7 @@ _cmd_set_configuration: DEFB +0x00 DEFB +0x00 DEFW +0x0000 -;source-doc/base-drv/./protocol.c:110: usb_error usbtrn_get_config_descriptor(config_descriptor *const buffer, +;source-doc/base-drv/./protocol.c:112: usb_error usbtrn_get_config_descriptor(config_descriptor *const buffer, ; --------------------------------- ; Function usbtrn_get_config_descriptor ; --------------------------------- @@ -330,24 +350,26 @@ _usbtrn_get_config_descriptor: ld hl, -8 add hl, sp ld sp, hl -;source-doc/base-drv/./protocol.c:116: cmd = cmd_get_config_descriptor; +;source-doc/base-drv/./protocol.c:118: cmd = cmd_get_config_descriptor; ld hl,0 add hl, sp - ld e,l - ld d,h - push hl - ld bc,0x0008 + ld c, l + ld b, h + ld e, c + ld d, b + push bc ld hl,_cmd_get_config_descriptor + ld bc,0x0008 ldir pop bc -;source-doc/base-drv/./protocol.c:117: cmd.bValue[0] = config_index; +;source-doc/base-drv/./protocol.c:119: cmd.bValue[0] = config_index; ld a,(ix+6) ld (ix-6),a -;source-doc/base-drv/./protocol.c:118: cmd.wLength = (uint16_t)buffer_size; +;source-doc/base-drv/./protocol.c:120: cmd.wLength = (uint16_t)buffer_size; ld e,(ix+7) ld (ix-2),e ld (ix-1),0x00 -;source-doc/base-drv/./protocol.c:120: RETURN_CHECK(usb_control_transfer(&cmd, (uint8_t *)buffer, device_address, max_packet_size)); +;source-doc/base-drv/./protocol.c:122: RETURN_CHECK(usb_control_transfer(&cmd, (uint8_t *)buffer, device_address, max_packet_size)); ld e,(ix+4) ld d,(ix+5) ld h,(ix+9) @@ -356,7 +378,7 @@ _usbtrn_get_config_descriptor: push de push bc call _usb_control_transfer -;source-doc/base-drv/./protocol.c:121: } +;source-doc/base-drv/./protocol.c:123: } ld sp,ix pop ix ret @@ -368,7 +390,7 @@ _cmd_get_config_descriptor: DEFB +0x00 DEFB +0x00 DEFW +0x0000 -;source-doc/base-drv/./protocol.c:123: usb_error usbtrn_gfull_cfg_desc(const uint8_t config_index, +;source-doc/base-drv/./protocol.c:125: usb_error usbtrn_gfull_cfg_desc(const uint8_t config_index, ; --------------------------------- ; Function usbtrn_gfull_cfg_desc ; --------------------------------- @@ -376,7 +398,7 @@ _usbtrn_gfull_cfg_desc: push ix ld ix,0 add ix,sp -;source-doc/base-drv/./protocol.c:131: max_packet_size)); +;source-doc/base-drv/./protocol.c:133: max_packet_size)); ld c,(ix+8) ld b,(ix+9) push bc @@ -398,40 +420,43 @@ _usbtrn_gfull_cfg_desc: ld a, l or a jr NZ,l_usbtrn_gfull_cfg_desc_00107 -;source-doc/base-drv/./protocol.c:133: uint8_t max_length = ((config_descriptor *)buffer)->wTotalLength; +;source-doc/base-drv/./protocol.c:135: uint8_t max_length = ((config_descriptor *)buffer)->wTotalLength; ld l, c ld h, b inc hl inc hl ld d, (hl) -;source-doc/base-drv/./protocol.c:134: if (max_length > max_buffer_size) +;source-doc/base-drv/./protocol.c:136: if (max_length > max_buffer_size) ld a,(ix+7) sub d jr NC,l_usbtrn_gfull_cfg_desc_00104 -;source-doc/base-drv/./protocol.c:135: max_length = max_buffer_size; +;source-doc/base-drv/./protocol.c:137: max_length = max_buffer_size; ld d,(ix+7) l_usbtrn_gfull_cfg_desc_00104: -;source-doc/base-drv/./protocol.c:137: CHECK(usbtrn_get_config_descriptor((config_descriptor *)buffer, config_index, max_length, device_address, max_packet_size)); +;source-doc/base-drv/./protocol.c:139: CHECK(usbtrn_get_config_descriptor((config_descriptor *)buffer, config_index, max_length, device_address, max_packet_size)); ld h,(ix+6) ld l,(ix+5) push hl - ld e,(ix+4) push de + inc sp + ld a,(ix+4) + push af + inc sp push bc call _usbtrn_get_config_descriptor pop af pop af pop af ld a, l -;source-doc/base-drv/./protocol.c:139: return USB_ERR_OK; +;source-doc/base-drv/./protocol.c:141: return USB_ERR_OK; or a jr NZ,l_usbtrn_gfull_cfg_desc_00107 ld l,a l_usbtrn_gfull_cfg_desc_00107: -;source-doc/base-drv/./protocol.c:140: } +;source-doc/base-drv/./protocol.c:142: } pop ix ret -;source-doc/base-drv/./protocol.c:144: usb_error usbtrn_clear_endpoint_halt(const uint8_t endpoint_number, const uint8_t device_address, const uint8_t max_packet_size) { +;source-doc/base-drv/./protocol.c:146: usb_error usbtrn_clear_endpoint_halt(const uint8_t endpoint_number, const uint8_t device_address, const uint8_t max_packet_size) { ; --------------------------------- ; Function usbtrn_clear_endpoint_halt ; --------------------------------- @@ -442,20 +467,22 @@ _usbtrn_clear_endpoint_halt: ld hl, -8 add hl, sp ld sp, hl -;source-doc/base-drv/./protocol.c:146: cmd = usb_cmd_clear_endpoint_halt; +;source-doc/base-drv/./protocol.c:148: cmd = usb_cmd_clear_endpoint_halt; ld hl,0 add hl, sp - ld e,l - ld d,h - push hl - ld bc,0x0008 + ld c, l + ld b, h + ld e, c + ld d, b + push bc ld hl,_usb_cmd_clear_endpoint_halt + ld bc,0x0008 ldir pop bc -;source-doc/base-drv/./protocol.c:147: cmd.bIndex[0] = endpoint_number; +;source-doc/base-drv/./protocol.c:149: cmd.bIndex[0] = endpoint_number; ld a,(ix+4) ld (ix-4),a -;source-doc/base-drv/./protocol.c:149: usb_error result = usb_control_transfer(&cmd, (uint8_t *)0, device_address, max_packet_size); +;source-doc/base-drv/./protocol.c:151: usb_error result = usb_control_transfer(&cmd, (uint8_t *)0, device_address, max_packet_size); ld h,(ix+6) ld l,(ix+5) push hl @@ -463,8 +490,8 @@ _usbtrn_clear_endpoint_halt: push hl push bc call _usb_control_transfer -;source-doc/base-drv/./protocol.c:151: RETURN_CHECK(result); -;source-doc/base-drv/./protocol.c:152: } +;source-doc/base-drv/./protocol.c:153: RETURN_CHECK(result); +;source-doc/base-drv/./protocol.c:154: } ld sp,ix pop ix ret diff --git a/Source/HBIOS/ch376-native/base-drv/transfers.c.s b/Source/HBIOS/ch376-native/base-drv/transfers.c.s index fc056368..a080f748 100644 --- a/Source/HBIOS/ch376-native/base-drv/transfers.c.s +++ b/Source/HBIOS/ch376-native/base-drv/transfers.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -48,7 +48,7 @@ _USB_MODULE_LEDS .EQU 0xff8a ;-------------------------------------------------------- ; code ;-------------------------------------------------------- -;source-doc/base-drv/./transfers.c:21: usb_error usb_ctrl_trnsfer_ext(const setup_packet *const cmd_packet, +;source-doc/base-drv/./transfers.c:24: usb_error usb_ctrl_trnsfer_ext(const setup_packet *const cmd_packet, ; --------------------------------- ; Function usb_ctrl_trnsfer_ext ; --------------------------------- @@ -56,26 +56,26 @@ _usb_ctrl_trnsfer_ext: push ix ld ix,0 add ix,sp -;source-doc/base-drv/./transfers.c:25: if ((uint16_t)cmd_packet < LOWER_SAFE_RAM_ADDRESS) +;source-doc/base-drv/./transfers.c:28: if ((uint16_t)cmd_packet < LOWER_SAFE_RAM_ADDRESS) ld a,(ix+5) sub 0x80 jr NC,l_usb_ctrl_trnsfer_ext_00102 -;source-doc/base-drv/./transfers.c:26: return USB_BAD_ADDRESS; +;source-doc/base-drv/./transfers.c:29: return USB_BAD_ADDRESS; ld l,0x82 jr l_usb_ctrl_trnsfer_ext_00106 l_usb_ctrl_trnsfer_ext_00102: -;source-doc/base-drv/./transfers.c:28: if (buffer != 0 && (uint16_t)buffer < LOWER_SAFE_RAM_ADDRESS) +;source-doc/base-drv/./transfers.c:31: if (buffer != 0 && (uint16_t)buffer < LOWER_SAFE_RAM_ADDRESS) ld a,(ix+7) or (ix+6) jr Z,l_usb_ctrl_trnsfer_ext_00104 ld a,(ix+7) sub 0x80 jr NC,l_usb_ctrl_trnsfer_ext_00104 -;source-doc/base-drv/./transfers.c:29: return USB_BAD_ADDRESS; +;source-doc/base-drv/./transfers.c:32: return USB_BAD_ADDRESS; ld l,0x82 jr l_usb_ctrl_trnsfer_ext_00106 l_usb_ctrl_trnsfer_ext_00104: -;source-doc/base-drv/./transfers.c:31: return usb_control_transfer(cmd_packet, buffer, device_address, max_packet_size); +;source-doc/base-drv/./transfers.c:34: return usb_control_transfer(cmd_packet, buffer, device_address, max_packet_size); ld h,(ix+9) ld l,(ix+8) push hl @@ -90,10 +90,10 @@ l_usb_ctrl_trnsfer_ext_00104: pop af pop af l_usb_ctrl_trnsfer_ext_00106: -;source-doc/base-drv/./transfers.c:32: } +;source-doc/base-drv/./transfers.c:35: } pop ix ret -;source-doc/base-drv/./transfers.c:44: usb_error usb_control_transfer(const setup_packet *const cmd_packet, +;source-doc/base-drv/./transfers.c:47: usb_error usb_control_transfer(const setup_packet *const cmd_packet, ; --------------------------------- ; Function usb_control_transfer ; --------------------------------- @@ -103,7 +103,7 @@ _usb_control_transfer: add ix,sp push af push af -;source-doc/base-drv/./transfers.c:49: endpoint_param endpoint = {1, 0, max_packet_size}; +;source-doc/base-drv/./transfers.c:52: endpoint_param endpoint = {1, 0, max_packet_size}; ld hl,0 add hl, sp set 0, (hl) @@ -125,28 +125,28 @@ _usb_control_transfer: and 0xfc or e ld (hl), a -;source-doc/base-drv/./transfers.c:51: const uint8_t transferIn = (cmd_packet->bmRequestType & 0x80); +;source-doc/base-drv/./transfers.c:54: const uint8_t transferIn = (cmd_packet->bmRequestType & 0x80); ld c,(ix+4) ld b,(ix+5) ld a, (bc) and 0x80 -;source-doc/base-drv/./transfers.c:53: if (transferIn && buffer == 0) +;source-doc/base-drv/./transfers.c:56: if (transferIn && buffer == 0) ld (ix-1),a or a jr Z,l_usb_control_transfer_00102 ld a,(ix+7) or (ix+6) jr NZ,l_usb_control_transfer_00102 -;source-doc/base-drv/./transfers.c:54: return USB_ERR_OTHER; +;source-doc/base-drv/./transfers.c:57: return USB_ERR_OTHER; ld l,0x0f jp l_usb_control_transfer_00113 l_usb_control_transfer_00102: -;source-doc/base-drv/./transfers.c:56: ch_set_usb_address(device_address); +;source-doc/base-drv/./transfers.c:59: ch_set_usb_address(device_address); push bc ld l,(ix+8) call _ch_set_usb_address pop bc -;source-doc/base-drv/./transfers.c:58: ch_write_data((const uint8_t *)cmd_packet, sizeof(setup_packet)); +;source-doc/base-drv/./transfers.c:61: ch_write_data((const uint8_t *)cmd_packet, sizeof(setup_packet)); ld e,(ix+4) ld d,(ix+5) push bc @@ -160,17 +160,18 @@ l_usb_control_transfer_00102: call _ch_issue_token_setup call _ch_short_wait_int_and_get_stat pop bc +;source-doc/base-drv/./transfers.c:64: CHECK(result); ld a, l or a jr NZ,l_usb_control_transfer_00113 -;source-doc/base-drv/./transfers.c:62: const uint16_t length = cmd_packet->wLength; +;source-doc/base-drv/./transfers.c:66: const uint16_t length = cmd_packet->wLength; ld hl,6 add hl, bc ld c, (hl) inc hl -;source-doc/base-drv/./transfers.c:65: ? (transferIn ? ch_data_in_transfer(buffer, length, &endpoint) : ch_data_out_transfer(buffer, length, &endpoint)) - ld a,(hl) - ld b,a + ld b, (hl) +;source-doc/base-drv/./transfers.c:69: ? (transferIn ? ch_data_in_transfer(buffer, length, &endpoint) : ch_data_out_transfer(buffer, length, &endpoint)) + ld a, b or c jr Z,l_usb_control_transfer_00115 ld e,(ix+6) @@ -201,56 +202,56 @@ l_usb_control_transfer_00117: l_usb_control_transfer_00118: jr l_usb_control_transfer_00116 l_usb_control_transfer_00115: -;source-doc/base-drv/./transfers.c:66: : USB_ERR_OK; - ld hl,0x0000 +;source-doc/base-drv/./transfers.c:70: : USB_ERR_OK; + ld l,0x00 l_usb_control_transfer_00116: -;source-doc/base-drv/./transfers.c:68: CHECK(result) +;source-doc/base-drv/./transfers.c:72: CHECK(result) ld a, l or a jr NZ,l_usb_control_transfer_00113 -;source-doc/base-drv/./transfers.c:70: if (transferIn) { +;source-doc/base-drv/./transfers.c:74: if (transferIn) { ld a,(ix-1) or a jr Z,l_usb_control_transfer_00112 -;source-doc/base-drv/./transfers.c:71: ch_command(CH_CMD_WR_HOST_DATA); +;source-doc/base-drv/./transfers.c:75: ch_command(CH_CMD_WR_HOST_DATA); ld l,0x2c call _ch_command -;source-doc/base-drv/./transfers.c:72: CH376_DATA_PORT = 0; +;source-doc/base-drv/./transfers.c:76: CH376_DATA_PORT = 0; ld a,0x00 ld bc,_CH376_DATA_PORT out (c),a -;source-doc/base-drv/./transfers.c:73: delay(); +;source-doc/base-drv/./transfers.c:77: delay(); call _delay -;source-doc/base-drv/./transfers.c:74: ch_issue_token_out_ep0(); +;source-doc/base-drv/./transfers.c:78: ch_issue_token_out_ep0(); call _ch_issue_token_out_ep0 -;source-doc/base-drv/./transfers.c:75: result = ch_long_wait_int_and_get_status(); /* sometimes we get STALL here - seems to be ok to ignore */ +;source-doc/base-drv/./transfers.c:79: result = ch_long_wait_int_and_get_status(); /* sometimes we get STALL here - seems to be ok to ignore */ call _ch_long_wait_int_and_get_statu +;source-doc/base-drv/./transfers.c:81: if (result == USB_ERR_OK || result == USB_ERR_STALL) ld a, l -;source-doc/base-drv/./transfers.c:77: if (result == USB_ERR_OK || result == USB_ERR_STALL) or a jr Z,l_usb_control_transfer_00108 - cp 0x02 + ld a, l + sub 0x02 jr NZ,l_usb_control_transfer_00109 l_usb_control_transfer_00108: -;source-doc/base-drv/./transfers.c:78: return USB_ERR_OK; +;source-doc/base-drv/./transfers.c:82: return USB_ERR_OK; ld l,0x00 jr l_usb_control_transfer_00113 l_usb_control_transfer_00109: -;source-doc/base-drv/./transfers.c:80: RETURN_CHECK(result); - ld l, a +;source-doc/base-drv/./transfers.c:84: RETURN_CHECK(result); jr l_usb_control_transfer_00113 l_usb_control_transfer_00112: -;source-doc/base-drv/./transfers.c:83: ch_issue_token_in_ep0(); +;source-doc/base-drv/./transfers.c:87: ch_issue_token_in_ep0(); call _ch_issue_token_in_ep0 -;source-doc/base-drv/./transfers.c:84: result = ch_long_wait_int_and_get_status(); +;source-doc/base-drv/./transfers.c:88: result = ch_long_wait_int_and_get_status(); call _ch_long_wait_int_and_get_statu -;source-doc/base-drv/./transfers.c:86: RETURN_CHECK(result); +;source-doc/base-drv/./transfers.c:90: RETURN_CHECK(result); l_usb_control_transfer_00113: -;source-doc/base-drv/./transfers.c:87: } +;source-doc/base-drv/./transfers.c:91: } ld sp, ix pop ix ret -;source-doc/base-drv/./transfers.c:90: usb_dat_in_trnsfer_ext(uint8_t *buffer, const uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { +;source-doc/base-drv/./transfers.c:94: usb_dat_in_trnsfer_ext(uint8_t *buffer, const uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { ; --------------------------------- ; Function usb_dat_in_trnsfer_ext ; --------------------------------- @@ -258,26 +259,26 @@ _usb_dat_in_trnsfer_ext: push ix ld ix,0 add ix,sp -;source-doc/base-drv/./transfers.c:91: if (buffer != 0 && (uint16_t)buffer < LOWER_SAFE_RAM_ADDRESS) +;source-doc/base-drv/./transfers.c:95: if (buffer != 0 && (uint16_t)buffer < LOWER_SAFE_RAM_ADDRESS) ld a,(ix+5) or (ix+4) jr Z,l_usb_dat_in_trnsfer_ext_00102 ld a,(ix+5) sub 0x80 jr NC,l_usb_dat_in_trnsfer_ext_00102 -;source-doc/base-drv/./transfers.c:92: return USB_BAD_ADDRESS; +;source-doc/base-drv/./transfers.c:96: return USB_BAD_ADDRESS; ld l,0x82 jr l_usb_dat_in_trnsfer_ext_00106 l_usb_dat_in_trnsfer_ext_00102: -;source-doc/base-drv/./transfers.c:94: if ((uint16_t)endpoint < LOWER_SAFE_RAM_ADDRESS) +;source-doc/base-drv/./transfers.c:98: if ((uint16_t)endpoint < LOWER_SAFE_RAM_ADDRESS) ld a,(ix+10) sub 0x80 jr NC,l_usb_dat_in_trnsfer_ext_00105 -;source-doc/base-drv/./transfers.c:95: return USB_BAD_ADDRESS; +;source-doc/base-drv/./transfers.c:99: return USB_BAD_ADDRESS; ld l,0x82 jr l_usb_dat_in_trnsfer_ext_00106 l_usb_dat_in_trnsfer_ext_00105: -;source-doc/base-drv/./transfers.c:97: return usb_data_in_transfer(buffer, buffer_size, device_address, endpoint); +;source-doc/base-drv/./transfers.c:101: return usb_data_in_transfer(buffer, buffer_size, device_address, endpoint); ld l,(ix+9) ld h,(ix+10) push hl @@ -296,10 +297,10 @@ l_usb_dat_in_trnsfer_ext_00105: pop af inc sp l_usb_dat_in_trnsfer_ext_00106: -;source-doc/base-drv/./transfers.c:98: } +;source-doc/base-drv/./transfers.c:102: } pop ix ret -;source-doc/base-drv/./transfers.c:101: usb_dat_in_trns_n_ext(uint8_t *buffer, uint16_t *buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { +;source-doc/base-drv/./transfers.c:105: usb_dat_in_trns_n_ext(uint8_t *buffer, uint16_t *buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { ; --------------------------------- ; Function usb_dat_in_trns_n_ext ; --------------------------------- @@ -307,34 +308,34 @@ _usb_dat_in_trns_n_ext: push ix ld ix,0 add ix,sp -;source-doc/base-drv/./transfers.c:102: if (buffer != 0 && ((uint16_t)buffer & 0xC000) == 0) +;source-doc/base-drv/./transfers.c:106: if (buffer != 0 && ((uint16_t)buffer & 0xC000) == 0) ld a,(ix+5) or (ix+4) jr Z,l_usb_dat_in_trns_n_ext_00102 ld a,(ix+5) and 0xc0 jr NZ,l_usb_dat_in_trns_n_ext_00102 -;source-doc/base-drv/./transfers.c:103: return USB_BAD_ADDRESS; +;source-doc/base-drv/./transfers.c:107: return USB_BAD_ADDRESS; ld l,0x82 jr l_usb_dat_in_trns_n_ext_00108 l_usb_dat_in_trns_n_ext_00102: -;source-doc/base-drv/./transfers.c:105: if (((uint16_t)endpoint & 0xC000) == 0) +;source-doc/base-drv/./transfers.c:109: if (((uint16_t)endpoint & 0xC000) == 0) ld a,(ix+10) and 0xc0 jr NZ,l_usb_dat_in_trns_n_ext_00105 -;source-doc/base-drv/./transfers.c:106: return USB_BAD_ADDRESS; +;source-doc/base-drv/./transfers.c:110: return USB_BAD_ADDRESS; ld l,0x82 jr l_usb_dat_in_trns_n_ext_00108 l_usb_dat_in_trns_n_ext_00105: -;source-doc/base-drv/./transfers.c:108: if (((uint16_t)buffer_size & 0xC000) == 0) +;source-doc/base-drv/./transfers.c:112: if (((uint16_t)buffer_size & 0xC000) == 0) ld a,(ix+7) and 0xc0 jr NZ,l_usb_dat_in_trns_n_ext_00107 -;source-doc/base-drv/./transfers.c:109: return USB_BAD_ADDRESS; +;source-doc/base-drv/./transfers.c:113: return USB_BAD_ADDRESS; ld l,0x82 jr l_usb_dat_in_trns_n_ext_00108 l_usb_dat_in_trns_n_ext_00107: -;source-doc/base-drv/./transfers.c:111: return usb_data_in_transfer_n(buffer, buffer_size, device_address, endpoint); +;source-doc/base-drv/./transfers.c:115: return usb_data_in_transfer_n(buffer, buffer_size, device_address, endpoint); ld c,(ix+6) ld b,(ix+7) ld l,(ix+9) @@ -353,76 +354,66 @@ l_usb_dat_in_trns_n_ext_00107: pop af inc sp l_usb_dat_in_trns_n_ext_00108: -;source-doc/base-drv/./transfers.c:112: } +;source-doc/base-drv/./transfers.c:116: } pop ix ret -;source-doc/base-drv/./transfers.c:124: usb_data_in_transfer(uint8_t *buffer, const uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { +;source-doc/base-drv/./transfers.c:128: usb_data_in_transfer(uint8_t *buffer, const uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { ; --------------------------------- ; Function usb_data_in_transfer ; --------------------------------- _usb_data_in_transfer: -;source-doc/base-drv/./transfers.c:125: ch_set_usb_address(device_address); - ld iy,6 - add iy, sp - ld l,(iy+0) + push ix + ld ix,0 + add ix,sp +;source-doc/base-drv/./transfers.c:129: ch_set_usb_address(device_address); + ld l,(ix+8) call _ch_set_usb_address -;source-doc/base-drv/./transfers.c:127: return ch_data_in_transfer(buffer, buffer_size, endpoint); - ld iy,7 - add iy, sp - ld l,(iy+0) - ld h,(iy+1) +;source-doc/base-drv/./transfers.c:131: return ch_data_in_transfer(buffer, buffer_size, endpoint); + ld l,(ix+9) + ld h,(ix+10) push hl - dec iy - dec iy - dec iy - ld l,(iy+0) - ld h,(iy+1) + ld l,(ix+6) + ld h,(ix+7) push hl - dec iy - dec iy - ld l,(iy+0) - ld h,(iy+1) + ld l,(ix+4) + ld h,(ix+5) push hl call _ch_data_in_transfer pop af pop af pop af -;source-doc/base-drv/./transfers.c:128: } +;source-doc/base-drv/./transfers.c:132: } + pop ix ret -;source-doc/base-drv/./transfers.c:140: usb_data_in_transfer_n(uint8_t *buffer, uint8_t *const buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { +;source-doc/base-drv/./transfers.c:144: usb_data_in_transfer_n(uint8_t *buffer, uint8_t *const buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { ; --------------------------------- ; Function usb_data_in_transfer_n ; --------------------------------- _usb_data_in_transfer_n: -;source-doc/base-drv/./transfers.c:141: ch_set_usb_address(device_address); - ld iy,6 - add iy, sp - ld l,(iy+0) + push ix + ld ix,0 + add ix,sp +;source-doc/base-drv/./transfers.c:145: ch_set_usb_address(device_address); + ld l,(ix+8) call _ch_set_usb_address -;source-doc/base-drv/./transfers.c:143: return ch_data_in_transfer_n(buffer, buffer_size, endpoint); - ld iy,7 - add iy, sp - ld l,(iy+0) - ld h,(iy+1) +;source-doc/base-drv/./transfers.c:147: return ch_data_in_transfer_n(buffer, buffer_size, endpoint); + ld l,(ix+9) + ld h,(ix+10) push hl - dec iy - dec iy - dec iy - ld l,(iy+0) - ld h,(iy+1) + ld l,(ix+6) + ld h,(ix+7) push hl - dec iy - dec iy - ld l,(iy+0) - ld h,(iy+1) + ld l,(ix+4) + ld h,(ix+5) push hl call _ch_data_in_transfer_n pop af pop af pop af -;source-doc/base-drv/./transfers.c:144: } +;source-doc/base-drv/./transfers.c:148: } + pop ix ret -;source-doc/base-drv/./transfers.c:147: usb_dat_out_trns_ext(const uint8_t *buffer, uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { +;source-doc/base-drv/./transfers.c:151: usb_dat_out_trns_ext(const uint8_t *buffer, uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { ; --------------------------------- ; Function usb_dat_out_trns_ext ; --------------------------------- @@ -430,26 +421,26 @@ _usb_dat_out_trns_ext: push ix ld ix,0 add ix,sp -;source-doc/base-drv/./transfers.c:149: if (buffer != 0 && (uint16_t)buffer < LOWER_SAFE_RAM_ADDRESS) +;source-doc/base-drv/./transfers.c:153: if (buffer != 0 && (uint16_t)buffer < LOWER_SAFE_RAM_ADDRESS) ld a,(ix+5) or (ix+4) jr Z,l_usb_dat_out_trns_ext_00102 ld a,(ix+5) sub 0x80 jr NC,l_usb_dat_out_trns_ext_00102 -;source-doc/base-drv/./transfers.c:150: return USB_BAD_ADDRESS; +;source-doc/base-drv/./transfers.c:154: return USB_BAD_ADDRESS; ld l,0x82 jr l_usb_dat_out_trns_ext_00106 l_usb_dat_out_trns_ext_00102: -;source-doc/base-drv/./transfers.c:152: if ((uint16_t)endpoint < LOWER_SAFE_RAM_ADDRESS) +;source-doc/base-drv/./transfers.c:156: if ((uint16_t)endpoint < LOWER_SAFE_RAM_ADDRESS) ld a,(ix+10) sub 0x80 jr NC,l_usb_dat_out_trns_ext_00105 -;source-doc/base-drv/./transfers.c:153: return USB_BAD_ADDRESS; +;source-doc/base-drv/./transfers.c:157: return USB_BAD_ADDRESS; ld l,0x82 jr l_usb_dat_out_trns_ext_00106 l_usb_dat_out_trns_ext_00105: -;source-doc/base-drv/./transfers.c:155: return usb_data_out_transfer(buffer, buffer_size, device_address, endpoint); +;source-doc/base-drv/./transfers.c:159: return usb_data_out_transfer(buffer, buffer_size, device_address, endpoint); ld l,(ix+9) ld h,(ix+10) push hl @@ -468,39 +459,34 @@ l_usb_dat_out_trns_ext_00105: pop af inc sp l_usb_dat_out_trns_ext_00106: -;source-doc/base-drv/./transfers.c:156: } +;source-doc/base-drv/./transfers.c:160: } pop ix ret -;source-doc/base-drv/./transfers.c:168: usb_data_out_transfer(const uint8_t *buffer, uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { +;source-doc/base-drv/./transfers.c:172: usb_data_out_transfer(const uint8_t *buffer, uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { ; --------------------------------- ; Function usb_data_out_transfer ; --------------------------------- _usb_data_out_transfer: -;source-doc/base-drv/./transfers.c:169: ch_set_usb_address(device_address); - ld iy,6 - add iy, sp - ld l,(iy+0) + push ix + ld ix,0 + add ix,sp +;source-doc/base-drv/./transfers.c:173: ch_set_usb_address(device_address); + ld l,(ix+8) call _ch_set_usb_address -;source-doc/base-drv/./transfers.c:171: return ch_data_out_transfer(buffer, buffer_size, endpoint); - ld iy,7 - add iy, sp - ld l,(iy+0) - ld h,(iy+1) +;source-doc/base-drv/./transfers.c:175: return ch_data_out_transfer(buffer, buffer_size, endpoint); + ld l,(ix+9) + ld h,(ix+10) push hl - dec iy - dec iy - dec iy - ld l,(iy+0) - ld h,(iy+1) + ld l,(ix+6) + ld h,(ix+7) push hl - dec iy - dec iy - ld l,(iy+0) - ld h,(iy+1) + ld l,(ix+4) + ld h,(ix+5) push hl call _ch_data_out_transfer pop af pop af pop af -;source-doc/base-drv/./transfers.c:172: } +;source-doc/base-drv/./transfers.c:176: } + pop ix ret diff --git a/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s b/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s index 46c575d9..242ccf70 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -58,16 +58,20 @@ _chnative_seek: push ix ld ix,0 add ix,sp + push af ld c, l ld b, h ;source-doc/base-drv/./usb-base-drv.c:7: storage_device->current_lba = lba; - ld h,(ix+5) ld a,(ix+4) + ld (ix-2),a + ld a,(ix+5) + ld (ix-1),a + ld a,(ix-2) add a,0x0c ld l, a - jr NC,l_chnative_seek_00103 - inc h -l_chnative_seek_00103: + ld a,(ix-1) + adc a,0x00 + ld h, a ld (hl), e inc hl ld (hl), d @@ -78,6 +82,7 @@ l_chnative_seek_00103: ;source-doc/base-drv/./usb-base-drv.c:8: return 0; xor a ;source-doc/base-drv/./usb-base-drv.c:9: } + ld sp, ix pop ix pop hl pop bc diff --git a/Source/HBIOS/ch376-native/base-drv/usb-init.c.s b/Source/HBIOS/ch376-native/base-drv/usb-init.c.s index a376087d..db185d27 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb-init.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb-init.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -78,8 +78,7 @@ _usb_host_bus_reset: ;source-doc/base-drv/./ch376.h:162: delay(); call _delay ;source-doc/base-drv/./ch376.h:163: CH376_DATA_PORT = retry << 6 | (number_of_retries & 0x1F); - ld a,0xc0 - or 0x1f + ld a,0xdf ld bc,_CH376_DATA_PORT out (c),a ;source-doc/base-drv/./ch376.h:164: delay(); @@ -95,12 +94,11 @@ _usb_host_bus_reset: _chnative_init: ;source-doc/base-drv/./usb-init.c:26: memset(get_usb_work_area(), 0, sizeof(_usb_state)); ld hl,_x - push hl - ld hl,0x0000 - push hl - ld l,0x69 - push hl - call _memset_callee + ld b,0x69 +l_chnative_init_00139: + ld (hl),0x00 + inc hl + djnz l_chnative_init_00139 ;source-doc/base-drv/./usb-init.c:28: ch_cmd_reset_all(); call _ch_cmd_reset_all ;source-doc/base-drv/./usb-init.c:30: delay_medium(); diff --git a/Source/HBIOS/ch376-native/base-drv/usb_state.c.s b/Source/HBIOS/ch376-native/base-drv/usb_state.c.s index 363e00b9..d1352853 100644 --- a/Source/HBIOS/ch376-native/base-drv/usb_state.c.s +++ b/Source/HBIOS/ch376-native/base-drv/usb_state.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -196,17 +196,15 @@ _get_usb_device_config: push ix ld ix,0 add ix,sp - dec sp + push af ld (ix-1),a ;source-doc/base-drv/./usb_state.c:69: const _usb_state *const usb_state = get_usb_work_area(); ;source-doc/base-drv/./usb_state.c:71: uint8_t counter = 1; - ld c,0x01 + ld (ix-2),0x01 ;source-doc/base-drv/./usb_state.c:73: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) { - push bc ld hl,_x call _first_device_config - pop bc - ld b,0x01 + ld c,0x01 l_get_usb_device_config_00112: ld a, d or e @@ -220,12 +218,12 @@ l_get_usb_device_config_00112: jr NZ,l_get_usb_device_config_00113 ;source-doc/base-drv/./usb_state.c:75: if (counter == device_index) ld a,(ix-1) - sub b + sub c ;source-doc/base-drv/./usb_state.c:76: return p; jr Z,l_get_usb_device_config_00117 ;source-doc/base-drv/./usb_state.c:77: counter++; - inc b - ld c, b + inc c + ld (ix-2),c l_get_usb_device_config_00113: ;source-doc/base-drv/./usb_state.c:73: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) { push bc @@ -235,10 +233,9 @@ l_get_usb_device_config_00113: jr l_get_usb_device_config_00112 l_get_usb_device_config_00105: ;source-doc/base-drv/./usb_state.c:81: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) { - push bc ld hl,_x call _first_device_config - pop bc + ld c,(ix-2) l_get_usb_device_config_00115: ld a, d or e @@ -269,6 +266,6 @@ l_get_usb_device_config_00110: ld de,0x0000 l_get_usb_device_config_00117: ;source-doc/base-drv/./usb_state.c:90: } - inc sp + ld sp, ix pop ix ret diff --git a/Source/HBIOS/ch376-native/base-drv/work-area.c.s b/Source/HBIOS/ch376-native/base-drv/work-area.c.s index 7e5fcc29..e084ee41 100644 --- a/Source/HBIOS/ch376-native/base-drv/work-area.c.s +++ b/Source/HBIOS/ch376-native/base-drv/work-area.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- diff --git a/Source/HBIOS/ch376-native/build-docker.sh b/Source/HBIOS/ch376-native/build-docker.sh new file mode 100644 index 00000000..e69de29b diff --git a/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s b/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s index 119505b8..58af4d5a 100644 --- a/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s +++ b/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -70,7 +70,7 @@ _do_scsi_cmd: push ix ld ix,0 add ix,sp - ld hl, -6 + ld hl, -10 add hl, sp ld sp, hl ;source-doc/scsi-drv/./class_scsi.c:16: cbw->dCBWTag[0] = next_tag++; @@ -79,7 +79,10 @@ _do_scsi_cmd: ld hl,0x0004 add hl, bc ex (sp), hl - ld de, (_next_tag) + ld hl,_next_tag + ld e, (hl) + inc hl + ld d, (hl) ld hl, (_next_tag) inc hl ld (_next_tag), hl @@ -97,45 +100,50 @@ _do_scsi_cmd: ld (hl),0x80 l_do_scsi_cmd_00102: ;source-doc/scsi-drv/./class_scsi.c:22: &dev->endpoints[ENDPOINT_BULK_OUT])); - ld e,(ix+4) - ld d,(ix+5) - ld hl,0x0003 - add hl, de - ld (ix-4),l - ld (ix-3),h - ld l, e - ld h, d + ld a,(ix+4) + ld (ix-8),a + ld a,(ix+5) + ld (ix-7),a + ld a,(ix-8) + add a,0x03 + ld (ix-6),a + ld a,(ix-7) + adc a,0x00 + ld (ix-5),a + pop de + pop hl + push hl + push de ld a, (hl) rlca rlca rlca rlca and 0x0f - ld l,(ix+6) - ld h,(ix+7) + ld e,(ix+6) + ld d,(ix+7) push bc - push de + ld l,(ix-6) + ld h,(ix-5) push hl - ld l,(ix-4) - ld h,(ix-3) - ex (sp), hl push af inc sp - ld iy,0x001f - push iy + ld hl,0x001f push hl + push de call _usb_data_out_transfer pop af pop af pop af inc sp - ld a, l - pop de pop bc - ld (_result+0),a + ld a, l + ld (_result), a + ld hl,_result + ld a, (hl) or a jr Z,l_do_scsi_cmd_00104 - ld l, a + ld l, (hl) jp l_do_scsi_cmd_00119 l_do_scsi_cmd_00104: ;source-doc/scsi-drv/./class_scsi.c:24: if (cbw->dCBWDataTransferLength != 0) { @@ -145,11 +153,19 @@ l_do_scsi_cmd_00104: inc hl ld b, (hl) inc hl + ld e, (hl) inc hl - ld a, (hl) - dec hl - ld l, (hl) - or l + ld d, (hl) +;source-doc/scsi-drv/./class_scsi.c:27: &dev->endpoints[ENDPOINT_BULK_IN])); + ld a,(ix-8) + add a,0x06 + ld (ix-4),a + ld a,(ix-7) + adc a,0x00 + ld (ix-3),a +;source-doc/scsi-drv/./class_scsi.c:24: if (cbw->dCBWDataTransferLength != 0) { + ld a, d + or e or b or c jr Z,l_do_scsi_cmd_00113 @@ -162,18 +178,19 @@ l_do_scsi_cmd_00104: bit 0,(ix+10) jr NZ,l_do_scsi_cmd_00110 ;source-doc/scsi-drv/./class_scsi.c:27: &dev->endpoints[ENDPOINT_BULK_IN])); - ld iy,0x0006 - add iy, de - ld l, e - ld h, d + pop de + pop hl + push hl + push de ld a, (hl) rlca rlca rlca rlca and 0x0f - push de - push iy + ld l,(ix-4) + ld h,(ix-3) + push hl push af inc sp ld l,(ix-2) @@ -186,25 +203,27 @@ l_do_scsi_cmd_00104: pop af inc sp ld a, l - pop de - ld (_result+0),a + ld (_result), a + ld hl,_result + ld a, (hl) or a jr Z,l_do_scsi_cmd_00113 - ld l, a - jr l_do_scsi_cmd_00119 + ld l, (hl) + jp l_do_scsi_cmd_00119 l_do_scsi_cmd_00110: ;source-doc/scsi-drv/./class_scsi.c:31: &dev->endpoints[ENDPOINT_BULK_OUT])); - ld l, e - ld h, d + pop de + pop hl + push hl + push de ld a, (hl) rlca rlca rlca rlca and 0x0f - push de - ld l,(ix-4) - ld h,(ix-3) + ld l,(ix-6) + ld h,(ix-5) push hl push af inc sp @@ -218,28 +237,30 @@ l_do_scsi_cmd_00110: pop af inc sp ld a, l - pop de - ld (_result+0),a + ld (_result), a + ld hl,_result + ld a, (hl) or a jr Z,l_do_scsi_cmd_00113 - ld l, a + ld l, (hl) jr l_do_scsi_cmd_00119 l_do_scsi_cmd_00113: ;source-doc/scsi-drv/./class_scsi.c:36: usb_data_in_transfer((uint8_t *)&csw, sizeof(_scsi_command_status_wrapper), dev->address, &dev->endpoints[ENDPOINT_BULK_IN])); - ld hl,0x0006 - add hl, de - ex de,hl - ld c,e - ld b,d + pop de + pop hl + push hl + push de ld a, (hl) rlca rlca rlca rlca and 0x0f - ld d, a + ld b, a + ld l,(ix-4) + ld h,(ix-3) + push hl push bc - push de inc sp ld hl,0x000d push hl @@ -251,10 +272,12 @@ l_do_scsi_cmd_00113: pop af inc sp ld a, l - ld (_result+0),a + ld (_result), a + ld hl,_result + ld a, (hl) or a jr Z,l_do_scsi_cmd_00115 - ld l, a + ld l, (hl) jr l_do_scsi_cmd_00119 l_do_scsi_cmd_00115: ;source-doc/scsi-drv/./class_scsi.c:38: if (csw.bCSWStatus != 0 && csw.dCSWTag[0] != cbw->dCBWTag[0]) @@ -263,13 +286,13 @@ l_do_scsi_cmd_00115: jr Z,l_do_scsi_cmd_00117 ld bc, (_csw + 4) pop hl - ld e,(hl) push hl + ld a, (hl) inc hl ld h, (hl) - ld l, e - xor a - sbc hl,bc + ld l, a + cp a + sbc hl, bc jr Z,l_do_scsi_cmd_00117 ;source-doc/scsi-drv/./class_scsi.c:39: return USB_ERR_FAIL; ld l,0x0e @@ -297,15 +320,15 @@ _get_scsi_read_capacity: ld hl,0 add hl, sp ex de, hl - ld bc,0x000f ld hl,_scsi_command_block_wrapper + ld bc,0x000f ldir ;source-doc/scsi-drv/./class_scsi.c:49: cbw_scsi.read_capacity = scsi_read_capacity; ld hl,15 add hl, sp ex de, hl - ld bc,0x000c ld hl,_scsi_read_capacity + ld bc,0x000c ldir ;source-doc/scsi-drv/./class_scsi.c:51: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 @@ -350,15 +373,15 @@ _scsi_inquiry: ld hl,0 add hl, sp ex de, hl - ld bc,0x000f ld hl,_scsi_command_block_wrapper + ld bc,0x000f ldir ;source-doc/scsi-drv/./class_scsi.c:63: cbw_scsi.inquiry = scsi_packet_inquiry; ld hl,15 add hl, sp ex de, hl - ld bc,0x000c ld hl,_scsi_packet_inquiry + ld bc,0x000c ldir ;source-doc/scsi-drv/./class_scsi.c:65: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 @@ -403,18 +426,17 @@ _scsi_test: ld hl,0 add hl, sp ex de, hl - ld bc,0x000f ld hl,_scsi_command_block_wrapper + ld bc,0x000f ldir ;source-doc/scsi-drv/./class_scsi.c:75: memset(&cbw_scsi.test, 0, sizeof(_scsi_packet_test)); ld hl,15 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x0c - push hl - call _memset_callee + ld b,0x0c +l_scsi_test_00103: + ld (hl),0x00 + inc hl + djnz l_scsi_test_00103 ;source-doc/scsi-drv/./class_scsi.c:77: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 ;source-doc/scsi-drv/./class_scsi.c:78: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_test); @@ -422,14 +444,15 @@ _scsi_test: ;source-doc/scsi-drv/./class_scsi.c:79: cbw_scsi.cbw.dCBWDataTransferLength = 0; ld hl,8 add hl, sp + ex de, hl xor a - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a + ld (de), a + inc de + ld (de), a + inc de + ld (de), a + inc de + ld (de), a ;source-doc/scsi-drv/./class_scsi.c:81: return do_scsi_cmd(dev, &cbw_scsi.cbw, 0, false); xor a push af @@ -462,15 +485,15 @@ _scsi_request_sense: ld hl,0 add hl, sp ex de, hl - ld bc,0x000f ld hl,_scsi_command_block_wrapper + ld bc,0x000f ldir ;source-doc/scsi-drv/./class_scsi.c:89: cbw_scsi.request_sense = scsi_packet_request_sense; ld hl,15 add hl, sp ex de, hl - ld bc,0x000c ld hl,_scsi_packet_request_sense + ld bc,0x000c ldir ;source-doc/scsi-drv/./class_scsi.c:91: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 @@ -505,6 +528,9 @@ _scsi_request_sense: ; Function scsi_sense_init ; --------------------------------- _scsi_sense_init: + push ix + ld ix,0 + add ix,sp ld hl, -18 add hl, sp ld sp, hl @@ -512,32 +538,26 @@ _scsi_sense_init: ld c,0x03 l_scsi_sense_init_00102: push bc - ld hl,22 - add hl, sp - ld c, (hl) - inc hl - ld b, (hl) - push bc + ld l,(ix+4) + ld h,(ix+5) + push hl call _scsi_test pop af ld a, l pop bc - ld (_result+0), a + ld (_result),a or a jr Z,l_scsi_sense_init_00104 - dec c + dec c jr Z,l_scsi_sense_init_00104 ;source-doc/scsi-drv/./class_scsi.c:103: scsi_request_sense(dev, &response); push bc ld hl,2 add hl, sp push hl - ld hl,24 - add hl, sp - ld c, (hl) - inc hl - ld b, (hl) - push bc + ld l,(ix+4) + ld h,(ix+5) + push hl call _scsi_request_sense pop af pop af @@ -545,12 +565,11 @@ l_scsi_sense_init_00102: jr l_scsi_sense_init_00102 l_scsi_sense_init_00104: ;source-doc/scsi-drv/./class_scsi.c:105: return result; - ld a, (_result+0) - ld l, a + ld hl,_result + ld l, (hl) ;source-doc/scsi-drv/./class_scsi.c:106: } - ld iy,18 - add iy, sp - ld sp, iy + ld sp, ix + pop ix ret ;source-doc/scsi-drv/./class_scsi.c:110: usb_error scsi_read(device_config_storage *const dev, uint8_t *const buffer) { ; --------------------------------- @@ -563,38 +582,40 @@ _scsi_read: push af ;source-doc/scsi-drv/./class_scsi.c:111: memset(&cbw, 0, sizeof(cbw_scsi_read_write)); ld hl,_cbw - push hl - ld hl,0x0000 - push hl - ld l,0x1b - push hl - call _memset_callee + ld b,0x1b +l_scsi_read_00112: + ld (hl),0x00 + inc hl + djnz l_scsi_read_00112 ;source-doc/scsi-drv/./class_scsi.c:112: cbw.cbw = scsi_command_block_wrapper; ld de,_cbw - ld bc,0x000f ld hl,_scsi_command_block_wrapper + ld bc,0x000f ldir ;source-doc/scsi-drv/./class_scsi.c:114: cbw.cbw.bCBWLUN = 0; + ld hl,_cbw + 13 + ld (hl),0x00 ;source-doc/scsi-drv/./class_scsi.c:115: cbw.cbw.bCBWCBLength = sizeof(_scsi_packet_read_write); - ld hl,0x0c00 - ld ((_cbw + 13)),hl + ld hl,_cbw + 14 + ld (hl),0x0c ;source-doc/scsi-drv/./class_scsi.c:116: cbw.cbw.dCBWDataTransferLength = 512; ld hl,0x0200 - ld (_cbw + 8),hl + ld ((_cbw + 8)), hl ld h, l - ld (_cbw + 8 + 2),hl + ld ((_cbw + 8)+2), hl ;source-doc/scsi-drv/./class_scsi.c:118: cbw.scsi_cmd.operation_code = 0x28; // read operation - ld hl, +(_cbw + 15) + ld hl,_cbw + 15 ld (hl),0x28 ;source-doc/scsi-drv/./class_scsi.c:119: cbw.scsi_cmd.transfer_len[1] = 1; - ld hl, +(_cbw + 23) + ld hl,_cbw + 23 ld (hl),0x01 ;source-doc/scsi-drv/./class_scsi.c:120: cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; ld c,(ix+4) ld b,(ix+5) ld hl,0x000c add hl, bc - pop af + ex (sp), hl + pop hl push hl inc hl inc hl @@ -606,20 +627,22 @@ _scsi_read: push hl inc hl inc hl + inc hl + dec hl ld a, (hl) ld ((_cbw + 18)),a ;source-doc/scsi-drv/./class_scsi.c:122: cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; pop hl push hl inc hl - ld a,(hl) - ld ((_cbw + 19)),a + ld d, (hl) + ld hl, +(_cbw + 19) + ld (hl), d ;source-doc/scsi-drv/./class_scsi.c:123: cbw.scsi_cmd.lba[3] = dev->current_lba; - ld de,_cbw + 20 pop hl - ld a,(hl) push hl - ld (de), a + ld a, (hl) + ld ((_cbw + 20)),a ;source-doc/scsi-drv/./class_scsi.c:125: result = do_scsi_cmd(dev, &cbw.cbw, buffer, false); ld e,(ix+6) ld d,(ix+7) @@ -636,14 +659,15 @@ _scsi_read: pop af inc sp ld a, l + ld (_result), a ;source-doc/scsi-drv/./class_scsi.c:127: if (result == USB_ERR_OK) - ld (_result+0),a + ld a,(_result) or a jr NZ,l_scsi_read_00102 ;source-doc/scsi-drv/./class_scsi.c:128: dev->current_lba++; pop hl - ld c,(hl) push hl + ld c, (hl) inc hl ld b, (hl) inc hl @@ -651,11 +675,11 @@ _scsi_read: inc hl ld d, (hl) inc c - jr NZ,l_scsi_read_00110 + jr NZ,l_scsi_read_00114 inc b - jr NZ,l_scsi_read_00110 + jr NZ,l_scsi_read_00114 inc de -l_scsi_read_00110: +l_scsi_read_00114: pop hl push hl ld (hl), c @@ -667,8 +691,8 @@ l_scsi_read_00110: ld (hl), d l_scsi_read_00102: ;source-doc/scsi-drv/./class_scsi.c:129: return result; - ld a, (_result+0) - ld l, a + ld hl,_result + ld l, (hl) ;source-doc/scsi-drv/./class_scsi.c:130: } ld sp, ix pop ix @@ -684,38 +708,40 @@ _scsi_write: push af ;source-doc/scsi-drv/./class_scsi.c:133: memset(&cbw, 0, sizeof(cbw_scsi_read_write)); ld hl,_cbw - push hl - ld hl,0x0000 - push hl - ld l,0x1b - push hl - call _memset_callee + ld b,0x1b +l_scsi_write_00112: + ld (hl),0x00 + inc hl + djnz l_scsi_write_00112 ;source-doc/scsi-drv/./class_scsi.c:134: cbw.cbw = scsi_command_block_wrapper; ld de,_cbw - ld bc,0x000f ld hl,_scsi_command_block_wrapper + ld bc,0x000f ldir ;source-doc/scsi-drv/./class_scsi.c:136: cbw.cbw.bCBWLUN = 0; + ld hl,_cbw + 13 + ld (hl),0x00 ;source-doc/scsi-drv/./class_scsi.c:137: cbw.cbw.bCBWCBLength = sizeof(_scsi_packet_read_write); - ld hl,0x0c00 - ld ((_cbw + 13)),hl + ld hl,_cbw + 14 + ld (hl),0x0c ;source-doc/scsi-drv/./class_scsi.c:138: cbw.cbw.dCBWDataTransferLength = 512; ld hl,0x0200 - ld (_cbw + 8),hl + ld ((_cbw + 8)), hl ld h, l - ld (_cbw + 8 + 2),hl + ld ((_cbw + 8)+2), hl ;source-doc/scsi-drv/./class_scsi.c:140: cbw.scsi_cmd.operation_code = 0x2A; // write operation - ld hl, +(_cbw + 15) + ld hl,_cbw + 15 ld (hl),0x2a ;source-doc/scsi-drv/./class_scsi.c:141: cbw.scsi_cmd.transfer_len[1] = 1; - ld hl, +(_cbw + 23) + ld hl,_cbw + 23 ld (hl),0x01 ;source-doc/scsi-drv/./class_scsi.c:142: cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; ld c,(ix+4) ld b,(ix+5) ld hl,0x000c add hl, bc - pop af + ex (sp), hl + pop hl push hl inc hl inc hl @@ -727,20 +753,22 @@ _scsi_write: push hl inc hl inc hl + inc hl + dec hl ld a, (hl) ld ((_cbw + 18)),a ;source-doc/scsi-drv/./class_scsi.c:144: cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; pop hl push hl inc hl - ld a,(hl) - ld ((_cbw + 19)),a + ld d, (hl) + ld hl, +(_cbw + 19) + ld (hl), d ;source-doc/scsi-drv/./class_scsi.c:145: cbw.scsi_cmd.lba[3] = dev->current_lba; - ld de,_cbw + 20 pop hl - ld a,(hl) push hl - ld (de), a + ld a, (hl) + ld ((_cbw + 20)),a ;source-doc/scsi-drv/./class_scsi.c:147: result = do_scsi_cmd(dev, &cbw.cbw, buffer, true); ld e,(ix+6) ld d,(ix+7) @@ -757,14 +785,15 @@ _scsi_write: pop af inc sp ld a, l + ld (_result), a ;source-doc/scsi-drv/./class_scsi.c:149: if (result == USB_ERR_OK) - ld (_result+0),a + ld a,(_result) or a jr NZ,l_scsi_write_00102 ;source-doc/scsi-drv/./class_scsi.c:150: dev->current_lba++; pop hl - ld c,(hl) push hl + ld c, (hl) inc hl ld b, (hl) inc hl @@ -772,11 +801,11 @@ _scsi_write: inc hl ld d, (hl) inc c - jr NZ,l_scsi_write_00110 + jr NZ,l_scsi_write_00114 inc b - jr NZ,l_scsi_write_00110 + jr NZ,l_scsi_write_00114 inc de -l_scsi_write_00110: +l_scsi_write_00114: pop hl push hl ld (hl), c @@ -788,8 +817,8 @@ l_scsi_write_00110: ld (hl), d l_scsi_write_00102: ;source-doc/scsi-drv/./class_scsi.c:151: return result; - ld a, (_result+0) - ld l, a + ld hl,_result + ld l, (hl) ;source-doc/scsi-drv/./class_scsi.c:152: } ld sp, ix pop ix @@ -809,18 +838,17 @@ _scsi_eject: ld hl,0 add hl, sp ex de, hl - ld bc,0x000f ld hl,_scsi_command_block_wrapper + ld bc,0x000f ldir ;source-doc/scsi-drv/./class_scsi.c:158: memset(&cbw_scsi.eject, 0, sizeof(_scsi_packet_eject)); ld hl,15 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x06 - push hl - call _memset_callee + ld b,0x06 +l_scsi_eject_00103: + ld (hl),0x00 + inc hl + djnz l_scsi_eject_00103 ;source-doc/scsi-drv/./class_scsi.c:160: cbw_scsi.eject.operation_code = 0x1B; ld (ix-6),0x1b ;source-doc/scsi-drv/./class_scsi.c:161: cbw_scsi.eject.loej = 1; @@ -834,14 +862,15 @@ _scsi_eject: ;source-doc/scsi-drv/./class_scsi.c:165: cbw_scsi.cbw.dCBWDataTransferLength = 0; ld hl,8 add hl, sp + ex de, hl xor a - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a + ld (de), a + inc de + ld (de), a + inc de + ld (de), a + inc de + ld (de), a ;source-doc/scsi-drv/./class_scsi.c:167: return do_scsi_cmd(dev, &cbw_scsi.cbw, 0, false); xor a push af diff --git a/Source/HBIOS/ch376-native/scsi-drv/init.c.s b/Source/HBIOS/ch376-native/scsi-drv/init.c.s deleted file mode 100644 index 5a8f145d..00000000 --- a/Source/HBIOS/ch376-native/scsi-drv/init.c.s +++ /dev/null @@ -1,162 +0,0 @@ -; -; Generated from source-doc/scsi-drv/./init.c.asm -- not to be modify directly -; -; -;-------------------------------------------------------- -; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) -;-------------------------------------------------------- -; Processed by Z88DK -;-------------------------------------------------------- - - -;-------------------------------------------------------- -; Public variables in this module -;-------------------------------------------------------- -;-------------------------------------------------------- -; Externals used -;-------------------------------------------------------- -;-------------------------------------------------------- -; special function registers -;-------------------------------------------------------- -_CH376_DATA_PORT .EQU 0xff88 -_CH376_COMMAND_PORT .EQU 0xff89 -_USB_MODULE_LEDS .EQU 0xff8a -;-------------------------------------------------------- -; ram data -;-------------------------------------------------------- -;-------------------------------------------------------- -; ram data -;-------------------------------------------------------- - -#IF 0 - -; .area _INITIALIZED removed by z88dk - - -#ENDIF - -;-------------------------------------------------------- -; absolute external ram data -;-------------------------------------------------------- -;-------------------------------------------------------- -; global & static initialisations -;-------------------------------------------------------- -;-------------------------------------------------------- -; Home -;-------------------------------------------------------- -;-------------------------------------------------------- -; code -;-------------------------------------------------------- -;source-doc/scsi-drv/./init.c:13: uint8_t chscsi_seek(const uint32_t lba, device_config_storage *const storage_device) __sdcccall(1) { -; --------------------------------- -; Function chscsi_seek -; --------------------------------- -_chscsi_seek: - push ix - ld ix,0 - add ix,sp - ld c, l - ld b, h -;source-doc/scsi-drv/./init.c:14: storage_device->current_lba = lba; - ld a,(ix+4) - ld h,(ix+5) - add a,0x0c - ld l, a - jr NC,l_chscsi_seek_00103 - inc h -l_chscsi_seek_00103: - ld (hl), e - inc hl - ld (hl), d - inc hl - ld (hl), c - inc hl - ld (hl), b -;source-doc/scsi-drv/./init.c:15: return 0; - xor a -;source-doc/scsi-drv/./init.c:16: } - pop ix - pop hl - pop bc - jp (hl) -;source-doc/scsi-drv/./init.c:18: void chscsi_init(void) { -; --------------------------------- -; Function chscsi_init -; --------------------------------- -_chscsi_init: - push ix - ld ix,0 - add ix,sp - dec sp -;source-doc/scsi-drv/./init.c:21: do { - ld c,0x00 - ld (ix-1),0x01 -l_chscsi_init_00105: -;source-doc/scsi-drv/./init.c:22: device_config_storage *const storage_device = (device_config_storage *)get_usb_device_config(index); - push bc - ld a,(ix-1) - call _get_usb_device_config - pop bc -;source-doc/scsi-drv/./init.c:24: if (storage_device == NULL) - ld a, d - or e - jr Z,l_chscsi_init_00107 -;source-doc/scsi-drv/./init.c:27: const usb_device_type t = storage_device->type; - ld l, e - ld h, d - ld a, (hl) - and 0x0f -;source-doc/scsi-drv/./init.c:29: if (t == USB_IS_MASS_STORAGE) { - sub 0x02 - jr NZ,l_chscsi_init_00106 -;source-doc/scsi-drv/./init.c:30: storage_device->drive_index = storage_count++; - ld hl,0x0010 - add hl, de - ld (hl), c - inc c -;source-doc/scsi-drv/./init.c:31: scsi_sense_init(storage_device); - push bc - push de - push de - call _scsi_sense_init - pop af - pop de - ld hl,_ch_scsi_fntbl - call _dio_add_entry - pop bc -l_chscsi_init_00106: -;source-doc/scsi-drv/./init.c:35: } while (++index != MAX_NUMBER_OF_STORAGE_DEVICES + 1); - inc (ix-1) - ld a,(ix-1) - sub 0x05 - jr NZ,l_chscsi_init_00105 -l_chscsi_init_00107: -;source-doc/scsi-drv/./init.c:37: if (storage_count == 0) - ld a, c - or a -;source-doc/scsi-drv/./init.c:38: return; - jr Z,l_chscsi_init_00110 -;source-doc/scsi-drv/./init.c:40: print_string(" $"); - push bc - ld hl,init_str_0 - call _print_string - pop bc -;source-doc/scsi-drv/./init.c:41: print_uint16(storage_count); - ld h,0x00 - ld l, c - call _print_uint16 -;source-doc/scsi-drv/./init.c:42: print_string(" STORAGE DEVICES$"); - ld hl,init_str_1 - call _print_string -l_chscsi_init_00110: -;source-doc/scsi-drv/./init.c:43: } - inc sp - pop ix - ret -init_str_0: - DEFM " $" - DEFB 0x00 -init_str_1: - DEFM " STORAGE DEVICES$" - DEFB 0x00 diff --git a/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s b/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s index 673285b5..691f8f85 100644 --- a/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s +++ b/Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -78,11 +78,11 @@ l_chscsi_init_00105: ;source-doc/scsi-drv/./scsi-init.c:24: storage_device->drive_index = storage_count++; ld hl,0x0010 add hl, de - ld a,(_storage_count+0) + ld c, l + ld b, h + ld hl,_storage_count + ld a, (hl) ld (ix-2),a - ld c,l - ld b,h - ld hl,_storage_count+0 inc (hl) ld a,(ix-2) ld (bc), a @@ -103,11 +103,13 @@ l_chscsi_init_00106: jr NZ,l_chscsi_init_00105 l_chscsi_init_00107: ;source-doc/scsi-drv/./scsi-init.c:31: if (storage_count == 0) -;source-doc/scsi-drv/./scsi-init.c:32: return; -;source-doc/scsi-drv/./scsi-init.c:34: print_device_mounted(" STORAGE DEVICE$", storage_count); - ld a,(_storage_count+0) + ld hl,_storage_count + ld a, (hl) or a +;source-doc/scsi-drv/./scsi-init.c:32: return; jr Z,l_chscsi_init_00110 +;source-doc/scsi-drv/./scsi-init.c:34: print_device_mounted(" STORAGE DEVICE$", storage_count); + ld a,(_storage_count) push af inc sp ld hl,scsi_init_str_0 diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c b/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c index 7f4dca77..3e358feb 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c @@ -1,6 +1,7 @@ #include "ch376.h" #include "print.h" +#include "ez80-helpers.h" usb_error result = 0; @@ -20,6 +21,9 @@ void ch_command(const uint8_t command) __z88dk_fastcall { delay(); CH376_COMMAND_PORT = command; delay(); + delay(); + delay(); + delay(); } extern usb_error ch_wait_int_and_get_status(const int16_t timeout) __z88dk_fastcall; @@ -32,8 +36,12 @@ usb_error ch_very_short_wait_int_and_get_status(void) { return ch_wait_int_and_g usb_error ch_get_status(void) { ch_command(CH_CMD_GET_STATUS); + delay(); + delay(); + delay(); + delay(); uint8_t ch_status = CH376_DATA_PORT; - + if (ch_status >= USB_FILERR_MIN && ch_status <= USB_FILERR_MAX) return ch_status; @@ -135,10 +143,14 @@ uint8_t ch_cmd_get_ic_version(void) { void ch_issue_token(const uint8_t toggle_bit, const uint8_t endpoint, const ch376_pid pid) { ch_command(CH_CMD_ISSUE_TKN_X); + delay(); + delay(); CH376_DATA_PORT = toggle_bit; delay(); + delay(); CH376_DATA_PORT = endpoint << 4 | pid; delay(); + delay(); } void ch_issue_token_in(const endpoint_param *const endpoint) __z88dk_fastcall { diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/ez80-helpers.h b/Source/HBIOS/ch376-native/source-doc/base-drv/ez80-helpers.h new file mode 100644 index 00000000..02240c95 --- /dev/null +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/ez80-helpers.h @@ -0,0 +1 @@ +#define debugger() __asm__("PUSH AF \n PUSH BC \n XOR A \n LD B, 7 \n .DB 0x49, 0xD7 \n POP BC \n POP AF") diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/protocol.c b/Source/HBIOS/ch376-native/source-doc/base-drv/protocol.c index 0b09bcdf..10dbbdd4 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/protocol.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/protocol.c @@ -16,6 +16,7 @@ #include #include "print.h" +#include "ez80-helpers.h" const setup_packet cmd_get_device_descriptor = {0x80, 6, {0, 1}, {0, 0}, 8}; @@ -31,6 +32,7 @@ usb_error usbtrn_get_descriptor(device_descriptor *const buffer) { cmd = cmd_get_device_descriptor; cmd.wLength = 8; + debugger(); result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, 8); CHECK(result); diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c b/Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c index 883ec873..4c7bcbe9 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c @@ -16,6 +16,9 @@ #include "z80.h" #include +#include "print.h" +#include "ez80-helpers.h" + #define LOWER_SAFE_RAM_ADDRESS 0x8000 usb_error usb_ctrl_trnsfer_ext(const setup_packet *const cmd_packet, @@ -57,7 +60,8 @@ usb_error usb_control_transfer(const setup_packet *const cmd_packet, ch_write_data((const uint8_t *)cmd_packet, sizeof(setup_packet)); ch_issue_token_setup(); - CHECK(ch_short_wait_int_and_get_status()) + result = ch_short_wait_int_and_get_status(); + CHECK(result); const uint16_t length = cmd_packet->wLength; diff --git a/Source/HBIOS/ch376-native/source-doc/convert-for-uz80as.sh b/Source/HBIOS/ch376-native/source-doc/convert-for-uz80as.sh index ad00b407..8c1a1286 100755 --- a/Source/HBIOS/ch376-native/source-doc/convert-for-uz80as.sh +++ b/Source/HBIOS/ch376-native/source-doc/convert-for-uz80as.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Check if exactly two arguments are provided if [ "$#" -ne 2 ]; then diff --git a/Source/HBIOS/ch376-native/source-doc/depends.d b/Source/HBIOS/ch376-native/source-doc/depends.d index 5d2e46b4..6f457cee 100644 --- a/Source/HBIOS/ch376-native/source-doc/depends.d +++ b/Source/HBIOS/ch376-native/source-doc/depends.d @@ -1,103 +1,22 @@ -./base-drv/dev_transfers.c.s: source-doc/base-drv/dev_transfers.c \ - source-doc/base-drv/dev_transfers.h source-doc/base-drv/ch376.h \ - source-doc/base-drv/ch376inc.h source-doc/base-drv/delay.h \ - source-doc/base-drv/transfers.h source-doc/base-drv/protocol.h -./base-drv/enumerate.c.s: source-doc/base-drv/enumerate.c \ - source-doc/base-drv/enumerate.h source-doc/base-drv/ch376.h \ - source-doc/base-drv/ch376inc.h source-doc/base-drv/delay.h \ - source-doc/base-drv/protocol.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/transfers.h source-doc/base-drv/usb_state.h \ - source-doc/base-drv/enumerate_hub.h \ - source-doc/base-drv/enumerate_storage.h source-doc/base-drv/work-area.h \ - source-doc/base-drv/print.h -./base-drv/usb_state.c.s: source-doc/base-drv/usb_state.c \ - source-doc/base-drv/usb_state.h source-doc/base-drv/ch376.h \ - source-doc/base-drv/ch376inc.h source-doc/base-drv/delay.h \ - source-doc/base-drv/protocol.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/transfers.h source-doc/base-drv/work-area.h -./base-drv/class_hub.c.s: source-doc/base-drv/class_hub.c \ - source-doc/base-drv/class_hub.h source-doc/base-drv/ch376.h \ - source-doc/base-drv/ch376inc.h source-doc/base-drv/delay.h \ - source-doc/base-drv/protocol.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/transfers.h source-doc/base-drv/usb_state.h -./base-drv/enumerate_storage.c.s: source-doc/base-drv/enumerate_storage.c \ - source-doc/base-drv/enumerate_storage.h source-doc/base-drv/protocol.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/ch376inc.h \ - source-doc/base-drv/delay.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/transfers.h -./base-drv/enumerate_hub.c.s: source-doc/base-drv/enumerate_hub.c \ - source-doc/base-drv/enumerate_hub.h source-doc/base-drv/enumerate.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/ch376inc.h \ - source-doc/base-drv/delay.h source-doc/base-drv/protocol.h \ - source-doc/base-drv/dev_transfers.h source-doc/base-drv/transfers.h \ - source-doc/base-drv/usb_state.h source-doc/base-drv/class_hub.h \ - source-doc/base-drv/work-area.h -./base-drv/usb-base-drv.c.s: source-doc/base-drv/usb-base-drv.c \ - source-doc/base-drv/usb-base-drv.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/ch376inc.h \ - source-doc/base-drv/delay.h source-doc/base-drv/transfers.h -./base-drv/transfers.c.s: source-doc/base-drv/transfers.c \ - source-doc/base-drv/transfers.h source-doc/base-drv/ch376.h \ - source-doc/base-drv/ch376inc.h source-doc/base-drv/delay.h \ - source-doc/base-drv/z80.h -./base-drv/print.c.s: source-doc/base-drv/print.c source-doc/base-drv/print.h -./base-drv/ch376.c.s: source-doc/base-drv/ch376.c source-doc/base-drv/ch376.h \ - source-doc/base-drv/ch376inc.h source-doc/base-drv/delay.h \ - source-doc/base-drv/print.h -./base-drv/protocol.c.s: source-doc/base-drv/protocol.c source-doc/base-drv/protocol.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/ch376inc.h \ - source-doc/base-drv/delay.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/transfers.h source-doc/base-drv/print.h -./base-drv/work-area.c.s: source-doc/base-drv/work-area.c \ - source-doc/base-drv/usb_state.h source-doc/base-drv/ch376.h \ - source-doc/base-drv/ch376inc.h source-doc/base-drv/delay.h \ - source-doc/base-drv/protocol.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/transfers.h -./base-drv/usb-init.c.s: source-doc/base-drv/usb-init.c source-doc/base-drv/ch376.h \ - source-doc/base-drv/ch376inc.h source-doc/base-drv/delay.h \ - source-doc/base-drv/enumerate.h source-doc/base-drv/protocol.h \ - source-doc/base-drv/dev_transfers.h source-doc/base-drv/transfers.h \ - source-doc/base-drv/usb_state.h source-doc/base-drv/print.h \ - source-doc/base-drv/work-area.h source-doc/base-drv/z80.h -./ufi-drv/ufi-init.c.s: source-doc/ufi-drv/ufi-init.c source-doc/ufi-drv/class_ufi.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/ch376inc.h \ - source-doc/base-drv/delay.h source-doc/base-drv/protocol.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/transfers.h source-doc/ufi-drv/usb_cbi.h \ - source-doc/base-drv/dev_transfers.h source-doc/base-drv/usb_state.h \ - source-doc/base-drv/protocol.h source-doc/base-drv/hbios.h \ - source-doc/base-drv/print.h source-doc/base-drv/usb-base-drv.h \ - source-doc/base-drv/work-area.h source-doc/base-drv/usb_state.h -./ufi-drv/usb_cbi.c.s: source-doc/ufi-drv/usb_cbi.c source-doc/ufi-drv/usb_cbi.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/ch376inc.h \ - source-doc/base-drv/delay.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/transfers.h \ - source-doc/base-drv/protocol.h source-doc/base-drv/dev_transfers.h -./ufi-drv/class_ufi.c.s: source-doc/ufi-drv/class_ufi.c \ - source-doc/ufi-drv/class_ufi.h source-doc/base-drv/ch376.h \ - source-doc/base-drv/ch376inc.h source-doc/base-drv/delay.h \ - source-doc/base-drv/protocol.h source-doc/base-drv/ch376.h \ - source-doc/base-drv/dev_transfers.h source-doc/base-drv/transfers.h \ - source-doc/ufi-drv/usb_cbi.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/usb_state.h source-doc/base-drv/protocol.h \ - source-doc/base-drv/delay.h source-doc/base-drv/z80.h -./scsi-drv/scsi-init.c.s: source-doc/scsi-drv/scsi-init.c \ - source-doc/scsi-drv/class_scsi.h source-doc/base-drv/protocol.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/ch376inc.h \ - source-doc/base-drv/delay.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/transfers.h source-doc/base-drv/ch376.h \ - source-doc/base-drv/enumerate.h source-doc/base-drv/protocol.h \ - source-doc/base-drv/usb_state.h source-doc/base-drv/hbios.h \ - source-doc/base-drv/print.h source-doc/base-drv/usb-base-drv.h \ - source-doc/base-drv/dev_transfers.h source-doc/base-drv/work-area.h \ - source-doc/base-drv/z80.h -./scsi-drv/class_scsi.c.s: source-doc/scsi-drv/class_scsi.c \ - source-doc/scsi-drv/class_scsi.h source-doc/base-drv/protocol.h \ - source-doc/base-drv/ch376.h source-doc/base-drv/ch376inc.h \ - source-doc/base-drv/delay.h source-doc/base-drv/dev_transfers.h \ - source-doc/base-drv/transfers.h source-doc/base-drv/usb_state.h \ - source-doc/base-drv/protocol.h source-doc/base-drv/z80.h +./base-drv/dev_transfers.c: base-drv/dev_transfers.c ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/protocol.h +./base-drv/enumerate.c: base-drv/enumerate.c ././source-doc/base-drv/enumerate.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/usb_state.h ././source-doc/base-drv/enumerate_hub.h ././source-doc/base-drv/enumerate_storage.h ././source-doc/base-drv/work-area.h ././source-doc/base-drv/print.h +./base-drv/usb_state.c: base-drv/usb_state.c ././source-doc/base-drv/usb_state.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/work-area.h +./base-drv/class_hub.c: base-drv/class_hub.c ././source-doc/base-drv/class_hub.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/usb_state.h +./base-drv/enumerate_storage.c: base-drv/enumerate_storage.c ././source-doc/base-drv/enumerate_storage.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h +./base-drv/enumerate_hub.c: base-drv/enumerate_hub.c ././source-doc/base-drv/enumerate_hub.h ././source-doc/base-drv/enumerate.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/usb_state.h ././source-doc/base-drv/class_hub.h ././source-doc/base-drv/work-area.h +./base-drv/usb-base-drv.c: base-drv/usb-base-drv.c ././source-doc/base-drv/usb-base-drv.h ././source-doc/base-drv//ch376inc.h ././source-doc/base-drv//delay.h +./base-drv/transfers.c: base-drv/transfers.c ././source-doc/base-drv/transfers.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/z80.h ././source-doc/base-drv/print.h +./base-drv/print.c: base-drv/print.c ././source-doc/base-drv/print.h +./base-drv/ch376.c: base-drv/ch376.c ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/print.h +./base-drv/protocol.c: base-drv/protocol.c ././source-doc/base-drv/protocol.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/print.h +./base-drv/work-area.c: base-drv/work-area.c ././source-doc/base-drv/usb_state.h ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h +./base-drv/usb-init.c: base-drv/usb-init.c ././source-doc/base-drv/ch376.h ././source-doc/base-drv/ch376inc.h ././source-doc/base-drv/delay.h ././source-doc/base-drv/enumerate.h ././source-doc/base-drv/protocol.h ././source-doc/base-drv/dev_transfers.h ././source-doc/base-drv/transfers.h ././source-doc/base-drv/usb_state.h ././source-doc/base-drv/print.h ././source-doc/base-drv/work-area.h ././source-doc/base-drv/z80.h +./ufi-drv/ufi-init.c: ufi-drv/ufi-init.c ././source-doc/ufi-drv/class_ufi.h ././source-doc/base-drv//transfers.h ././source-doc/ufi-drv/usb_cbi.h +./ufi-drv/usb_cbi.c: ufi-drv/usb_cbi.c ././source-doc/ufi-drv/usb_cbi.h +./ufi-drv/class_ufi.c: ufi-drv/class_ufi.c ././source-doc/ufi-drv/class_ufi.h ././source-doc/base-drv//transfers.h ././source-doc/ufi-drv/usb_cbi.h +./scsi-drv/scsi-init.c: scsi-drv/scsi-init.c ././source-doc/scsi-drv/class_scsi.h ././source-doc/base-drv//ch376inc.h ././source-doc/base-drv//delay.h ././source-doc/base-drv//transfers.h +./scsi-drv/class_scsi.c: scsi-drv/class_scsi.c ././source-doc/scsi-drv/class_scsi.h ././source-doc/base-drv//ch376inc.h ././source-doc/base-drv//delay.h ././source-doc/base-drv//transfers.h ## ./base-drv.s: base-drv/./dev_transfers.c.s base-drv/./enumerate.c.s base-drv/./usb_state.c.s base-drv/./class_hub.c.s base-drv/./enumerate_storage.c.s base-drv/./enumerate_hub.c.s base-drv/./usb-base-drv.c.s base-drv/./transfers.c.s base-drv/./print.c.s base-drv/./ch376.c.s base-drv/./protocol.c.s base-drv/./work-area.c.s base-drv/./usb-init.c.s ## diff --git a/Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s b/Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s index 24ac5b51..f911d4c2 100644 --- a/Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s +++ b/Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -63,15 +63,15 @@ _wait_for_device_ready: ld c,(ix+6) l_wait_for_device_ready_00105: ;source-doc/ufi-drv/./class_ufi.c:19: memset(&sense, 0, sizeof(sense)); - push bc - ld hl,2 + ld hl,0 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x12 - push hl - call _memset_callee + ld b,0x12 +l_wait_for_device_ready_00132: + ld (hl),0x00 + inc hl + djnz l_wait_for_device_ready_00132 +;source-doc/ufi-drv/./class_ufi.c:20: result = ufi_test_unit_ready(storage_device, &sense); + push bc ld hl,2 add hl, sp push hl @@ -85,10 +85,10 @@ l_wait_for_device_ready_00105: pop bc ld b, a ;source-doc/ufi-drv/./class_ufi.c:22: if ((result == USB_ERR_OK && sense.sense_key == 0) || timeout_counter-- == 0) + ld hl,0+1+1 + add hl,sp or a jr NZ,l_wait_for_device_ready_00104 - ld hl,2 - add hl, sp ld a, (hl) and 0x0f jr Z,l_wait_for_device_ready_00107 @@ -105,8 +105,6 @@ l_wait_for_device_ready_00104: jr l_wait_for_device_ready_00105 l_wait_for_device_ready_00107: ;source-doc/ufi-drv/./class_ufi.c:29: return result | sense.sense_key; - ld hl,2 - add hl, sp ld a, (hl) and 0x0f or b @@ -194,12 +192,14 @@ _ufi_test_unit_ready: ;source-doc/ufi-drv/./class_ufi.c:35: memset(&ufi_cmd_request_test_unit_ready, 0, sizeof(ufi_test_unit_ready_command)); ld hl,0 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x0c - push hl - call _memset_callee + ex de, hl + ld l, e + ld h, d + ld b,0x0c +l_ufi_test_unit_ready_00103: + ld (hl),0x00 + inc hl + djnz l_ufi_test_unit_ready_00103 ;source-doc/ufi-drv/./class_ufi.c:37: usb_execute_cbi(storage_device, (uint8_t *)&ufi_cmd_request_test_unit_ready, false, 0, NULL, NULL); ld hl,0x0000 push hl @@ -208,9 +208,7 @@ _ufi_test_unit_ready: xor a push af inc sp - ld hl,7 - add hl, sp - push hl + push de ld l,(ix+4) ld h,(ix+5) push hl @@ -221,11 +219,13 @@ _ufi_test_unit_ready: ;source-doc/ufi-drv/./class_ufi.c:40: ufi_cmd_request_sense = _ufi_cmd_request_sense; ld hl,12 add hl, sp - ld e,l - ld d,h - push hl - ld bc,0x000c + ld c, l + ld b, h + ld e, c + ld d, b + push bc ld hl,__ufi_cmd_request_sense + ld bc,0x000c ldir pop bc ;source-doc/ufi-drv/./class_ufi.c:43: (uint8_t *)response, NULL); @@ -245,11 +245,9 @@ _ufi_test_unit_ready: ld h,(ix+5) push hl call _usb_execute_cbi - ld iy,11 - add iy, sp ;source-doc/ufi-drv/./class_ufi.c:45: RETURN_CHECK(result); ;source-doc/ufi-drv/./class_ufi.c:46: } - ld sp, ix + ld sp,ix pop ix ret ;source-doc/ufi-drv/./class_ufi.c:48: usb_error ufi_request_sense(device_config *const storage_device, ufi_request_sense_response const *response) { @@ -266,11 +264,13 @@ _ufi_request_sense: ;source-doc/ufi-drv/./class_ufi.c:50: ufi_cmd_request_sense = _ufi_cmd_request_sense; ld hl,0 add hl, sp - ld e,l - ld d,h - push hl - ld bc,0x000c + ld c, l + ld b, h + ld e, c + ld d, b + push bc ld hl,__ufi_cmd_request_sense + ld bc,0x000c ldir pop bc ;source-doc/ufi-drv/./class_ufi.c:52: usb_error result = usb_execute_cbi(storage_device, (uint8_t *)&ufi_cmd_request_sense, false, sizeof(ufi_request_sense_response), @@ -289,11 +289,9 @@ _ufi_request_sense: ld h,(ix+5) push hl call _usb_execute_cbi - ld iy,11 - add iy, sp ;source-doc/ufi-drv/./class_ufi.c:55: RETURN_CHECK(result); ;source-doc/ufi-drv/./class_ufi.c:56: } - ld sp, ix + ld sp,ix pop ix ret ;source-doc/ufi-drv/./class_ufi.c:58: usb_error ufi_read_frmt_caps(device_config *const storage_device, ufi_format_capacities_response const *response) { @@ -311,8 +309,8 @@ _ufi_read_frmt_caps: ld hl,0 add hl, sp ex de, hl - ld bc,0x000c ld hl,__ufi_cmd_read_format_capacitie + ld bc,0x000c ldir ;source-doc/ufi-drv/./class_ufi.c:63: result = usb_execute_cbi(storage_device, (uint8_t *)&ufi_cmd_read_format_capacities, false, 12, (uint8_t *)response, NULL); ld c,(ix+6) @@ -333,20 +331,22 @@ _ufi_read_frmt_caps: ld h,(ix+5) push hl call _usb_execute_cbi - ld iy,11 - add iy, sp - ld sp, iy + pop af + pop af + pop af + pop af + pop af + inc sp pop bc ;source-doc/ufi-drv/./class_ufi.c:66: CHECK(result); ld a, l or a jr NZ,l_ufi_read_frmt_caps_00103 ;source-doc/ufi-drv/./class_ufi.c:68: const uint8_t available_length = response->capacity_list_length; - ld l,(ix+6) - ld h,(ix+7) - inc hl - inc hl - inc hl + ld e,(ix+6) + ld d,(ix+7) + ld hl,3 + add hl, de ld e, (hl) ;source-doc/ufi-drv/./class_ufi.c:70: const uint8_t max_length = ld a,0x24 @@ -355,24 +355,23 @@ _ufi_read_frmt_caps: ld e,0x24 l_ufi_read_frmt_caps_00105: ;source-doc/ufi-drv/./class_ufi.c:74: memcpy(&cmd, &ufi_cmd_read_format_capacities, sizeof(cmd)); - push bc push de + push bc + ex de, hl ld hl,16 add hl, sp - push hl - ld hl,6 + ex de, hl + ld hl,4 add hl, sp - push hl - ld hl,0x000c - push hl - call _memcpy_callee - pop de + ld bc,0x000c + ldir pop bc + pop de ;source-doc/ufi-drv/./class_ufi.c:75: cmd.allocation_length[1] = max_length; ld (ix-4),e ;source-doc/ufi-drv/./class_ufi.c:77: result = usb_execute_cbi(storage_device, (uint8_t *)&cmd, false, max_length, (uint8_t *)response, NULL); + ld d,0x00 ld hl,0x0000 - ld d,l push hl push bc push de @@ -386,8 +385,12 @@ l_ufi_read_frmt_caps_00105: ld h,(ix+5) push hl call _usb_execute_cbi - ld iy,11 - add iy, sp + pop af + pop af + pop af + pop af + pop af + inc sp ;source-doc/ufi-drv/./class_ufi.c:80: RETURN_CHECK(result); l_ufi_read_frmt_caps_00103: ;source-doc/ufi-drv/./class_ufi.c:81: } @@ -408,11 +411,13 @@ _ufi_inquiry: ;source-doc/ufi-drv/./class_ufi.c:85: ufi_cmd_inquiry = _ufi_cmd_inquiry; ld hl,0 add hl, sp - ld e,l - ld d,h - push hl - ld bc,0x000c + ld c, l + ld b, h + ld e, c + ld d, b + push bc ld hl,__ufi_cmd_inquiry + ld bc,0x000c ldir pop bc ;source-doc/ufi-drv/./class_ufi.c:87: usb_error result = @@ -431,11 +436,9 @@ _ufi_inquiry: ld h,(ix+5) push hl call _usb_execute_cbi - ld iy,11 - add iy, sp ;source-doc/ufi-drv/./class_ufi.c:90: RETURN_CHECK(result); ;source-doc/ufi-drv/./class_ufi.c:91: } - ld sp, ix + ld sp,ix pop ix ret ;source-doc/ufi-drv/./class_ufi.c:93: usb_error ufi_read_write_sector(device_config *const storage_device, @@ -452,21 +455,20 @@ _ufi_read_write_sector: ;source-doc/ufi-drv/./class_ufi.c:100: memset(&cmd, 0, sizeof(cmd)); ld hl,0 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x0c - push hl - call _memset_callee + ld b,0x0c +l_ufi_read_write_sector_00112: + ld (hl),0x00 + inc hl + djnz l_ufi_read_write_sector_00112 ;source-doc/ufi-drv/./class_ufi.c:101: cmd.operation_code = send ? 0x2A : 0x28; bit 0,(ix+6) jr Z,l_ufi_read_write_sector_00103 - ld bc,0x002a + ld a,0x2a jr l_ufi_read_write_sector_00104 l_ufi_read_write_sector_00103: - ld bc,0x0028 + ld a,0x28 l_ufi_read_write_sector_00104: - ld (ix-12),c + ld (ix-12),a ;source-doc/ufi-drv/./class_ufi.c:102: cmd.lba[2] = sector_number >> 8; ld a,(ix+8) ld (ix-8),a @@ -474,9 +476,10 @@ l_ufi_read_write_sector_00104: ld a,(ix+7) ld (ix-7),a ;source-doc/ufi-drv/./class_ufi.c:104: cmd.transfer_length[1] = sector_count; -;source-doc/ufi-drv/./class_ufi.c:106: usb_error result = usb_execute_cbi(storage_device, (uint8_t *)&cmd, send, 512 * sector_count, (uint8_t *)buffer, sense_codes); ld a,(ix+9) ld (ix-4),a +;source-doc/ufi-drv/./class_ufi.c:106: usb_error result = usb_execute_cbi(storage_device, (uint8_t *)&cmd, send, 512 * sector_count, (uint8_t *)buffer, sense_codes); + ld a,(ix+9) add a, a ld c,0x00 ld l,(ix+12) @@ -497,11 +500,9 @@ l_ufi_read_write_sector_00104: ld h,(ix+5) push hl call _usb_execute_cbi - ld iy,11 - add iy, sp ;source-doc/ufi-drv/./class_ufi.c:108: RETURN_CHECK(result); ;source-doc/ufi-drv/./class_ufi.c:109: } - ld sp, ix + ld sp,ix pop ix ret ;source-doc/ufi-drv/./class_ufi.c:118: usb_error ufi_format(device_config *const storage_device, @@ -519,18 +520,21 @@ _ufi_format: ld hl,2 add hl, sp push hl - ld hl,0x0000 - push hl - ld l,0x0c - push hl - call _memset_callee + ld b,0x0c +l_ufi_format_00103: + ld (hl),0x00 + inc hl + djnz l_ufi_format_00103 + pop bc ;source-doc/ufi-drv/./class_ufi.c:128: cmd = _ufi_cmd_format; ld hl,14 add hl, sp ex de, hl - ld bc,0x000c + push bc ld hl,__ufi_cmd_format + ld bc,0x000c ldir + pop bc ;source-doc/ufi-drv/./class_ufi.c:131: cmd.track_number = track_number; ld a,(ix+7) ld (ix-10),a @@ -539,26 +543,26 @@ _ufi_format: ;source-doc/ufi-drv/./class_ufi.c:133: cmd.parameter_list_length[1] = sizeof(parameter_list); ld (ix-4),0x0c ;source-doc/ufi-drv/./class_ufi.c:135: parameter_list.defect_list_header.side = side; - ld hl,2+1 - add hl, sp - ex de, hl + ld e, c + ld d, b + inc de ld a,(ix+6) and 0x01 - ld c, a + ld l, a ld a, (de) and 0xfe - or c + or l ld (de), a ;source-doc/ufi-drv/./class_ufi.c:136: parameter_list.defect_list_header.immediate = 0; ld l, e ld h, d res 1, (hl) ;source-doc/ufi-drv/./class_ufi.c:137: parameter_list.defect_list_header.reserved2 = 0; - ld c, e - ld b, d - ld a, (bc) + ld l, e + ld h, d + ld a, (hl) and 0xf3 - ld (bc), a + ld (hl), a ;source-doc/ufi-drv/./class_ufi.c:138: parameter_list.defect_list_header.single_track = 1; ld l, e ld h, d @@ -572,30 +576,30 @@ _ufi_format: ld h, d res 6, (hl) ;source-doc/ufi-drv/./class_ufi.c:141: parameter_list.defect_list_header.fov = 1; - ld a, (de) - or 0x80 - ld (de), a + ex de, hl + set 7, (hl) ;source-doc/ufi-drv/./class_ufi.c:142: parameter_list.defect_list_header.defect_list_length_msb = 0; ld (ix-22),0x00 ;source-doc/ufi-drv/./class_ufi.c:143: parameter_list.defect_list_header.defect_list_length_lsb = 8; ld (ix-21),0x08 ;source-doc/ufi-drv/./class_ufi.c:144: memcpy(¶meter_list.format_descriptor, (void *)format, sizeof(ufi_format_capacity_descriptor)); - ld c,(ix+8) - ld b,(ix+9) - ld hl,6 - add hl, sp - push hl + ld e,(ix+8) + ld d,(ix+9) push bc - ld hl,0x0008 - push hl - call _memcpy_callee + ld l, e + ld h, d + ex de, hl + ld hl,8 + add hl, sp + ex de, hl + ld bc,0x0008 + ldir + pop bc ;source-doc/ufi-drv/./class_ufi.c:146: usb_error result = usb_execute_cbi(storage_device, (uint8_t *)&cmd, true, sizeof(parameter_list), (uint8_t *)¶meter_list, ld hl,0 add hl, sp push hl - ld hl,4 - add hl, sp - push hl + push bc ld hl,0x000c push hl ld a,0x01 @@ -608,11 +612,9 @@ _ufi_format: ld h,(ix+5) push hl call _usb_execute_cbi - ld iy,11 - add iy, sp ;source-doc/ufi-drv/./class_ufi.c:151: RETURN_CHECK(result); ;source-doc/ufi-drv/./class_ufi.c:152: } - ld sp, ix + ld sp,ix pop ix ret ;source-doc/ufi-drv/./class_ufi.c:154: usb_error ufi_send_diagnostics(device_config *const storage_device) { @@ -629,11 +631,13 @@ _ufi_send_diagnostics: ;source-doc/ufi-drv/./class_ufi.c:158: ufi_cmd_send_diagnostic = _ufi_cmd_send_diagnostic; ld hl,0 add hl, sp - ld e,l - ld d,h - push hl - ld bc,0x000c + ld c, l + ld b, h + ld e, c + ld d, b + push bc ld hl,__ufi_cmd_send_diagnostic + ld bc,0x000c ldir pop bc ;source-doc/ufi-drv/./class_ufi.c:160: result = usb_execute_cbi(storage_device, (uint8_t *)&ufi_cmd_send_diagnostic, true, 0, NULL, NULL); @@ -649,11 +653,9 @@ _ufi_send_diagnostics: ld h,(ix+5) push hl call _usb_execute_cbi - ld iy,11 - add iy, sp ;source-doc/ufi-drv/./class_ufi.c:162: RETURN_CHECK(result); ;source-doc/ufi-drv/./class_ufi.c:163: } - ld sp, ix + ld sp,ix pop ix ret ;source-doc/ufi-drv/./class_ufi.c:165: uint32_t convert_from_msb_first(const uint8_t *const buffer) { @@ -688,10 +690,10 @@ _convert_from_msb_first: inc de ;source-doc/ufi-drv/./class_ufi.c:172: *p_output++ = *p_input--; ld a, (bc) - dec bc ld (de), a inc de ;source-doc/ufi-drv/./class_ufi.c:173: *p_output = *p_input--; + dec bc ld a, (bc) ld (de), a ;source-doc/ufi-drv/./class_ufi.c:175: return result; diff --git a/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s b/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s index 6b99f86e..11daa508 100644 --- a/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s +++ b/Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -78,11 +78,11 @@ l_chufi_init_00105: ;source-doc/ufi-drv/./ufi-init.c:23: storage_device->drive_index = storage_count++; ld hl,0x0010 add hl, de - ld a,(_storage_count+0) + ld c, l + ld b, h + ld hl,_storage_count + ld a, (hl) ld (ix-2),a - ld c,l - ld b,h - ld hl,_storage_count+0 inc (hl) ld a,(ix-2) ld (bc), a @@ -97,11 +97,13 @@ l_chufi_init_00106: jr NZ,l_chufi_init_00105 l_chufi_init_00107: ;source-doc/ufi-drv/./ufi-init.c:30: if (storage_count == 0) -;source-doc/ufi-drv/./ufi-init.c:31: return; -;source-doc/ufi-drv/./ufi-init.c:33: print_device_mounted(" FLOPPY DRIVE$", storage_count); - ld a,(_storage_count+0) + ld hl,_storage_count + ld a, (hl) or a +;source-doc/ufi-drv/./ufi-init.c:31: return; jr Z,l_chufi_init_00110 +;source-doc/ufi-drv/./ufi-init.c:33: print_device_mounted(" FLOPPY DRIVE$", storage_count); + ld a,(_storage_count) push af inc sp ld hl,ufi_init_str_0 @@ -131,12 +133,11 @@ _chufi_get_cap: ;source-doc/ufi-drv/./ufi-init.c:38: memset(&response, 0, sizeof(ufi_format_capacities_response)); ld hl,0 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x24 - push hl - call _memset_callee + ld b,0x24 +l_chufi_get_cap_00112: + ld (hl),0x00 + inc hl + djnz l_chufi_get_cap_00112 ;source-doc/ufi-drv/./ufi-init.c:40: wait_for_device_ready(dev, 25); ld a,0x19 push af @@ -219,25 +220,22 @@ _chufi_read: call _wait_for_device_ready pop af inc sp - ld a, l + ld e, l pop bc + ld a, e or a jr Z,l_chufi_read_00102 ;source-doc/ufi-drv/./ufi-init.c:68: return -1; // Not READY! ld l,0xff - jp l_chufi_read_00109 + jr l_chufi_read_00109 l_chufi_read_00102: ;source-doc/ufi-drv/./ufi-init.c:73: memset(&sense_codes, 0, sizeof(sense_codes)); - push bc - ld hl,2 + ld hl,0 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x02 - push hl - call _memset_callee - pop bc + xor a + ld (hl), a + inc hl + ld (hl), a ;source-doc/ufi-drv/./ufi-init.c:75: if (ufi_read_write_sector((device_config *)dev, false, dev->current_lba, 1, buffer, (uint8_t *)&sense_codes) != USB_ERR_OK) ld e,(ix+4) ld d,(ix+5) @@ -262,9 +260,11 @@ l_chufi_read_00102: inc sp push bc call _ufi_read_write_sector - ld iy,10 - add iy, sp - ld sp, iy + pop af + pop af + pop af + pop af + pop af ld a, l pop bc or a @@ -277,12 +277,11 @@ l_chufi_read_00104: push bc ld hl,4 add hl, sp - push hl - ld hl,0x0000 - push hl - ld l,0x12 - push hl - call _memset_callee + ld b,0x12 +l_chufi_read_00139: + ld (hl),0x00 + inc hl + djnz l_chufi_read_00139 pop bc ;source-doc/ufi-drv/./ufi-init.c:81: if ((result = ufi_request_sense((device_config *)dev, &response)) != USB_ERR_OK) ld hl,2 diff --git a/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s b/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s index 852dd31b..134682ce 100644 --- a/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s +++ b/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s @@ -4,7 +4,7 @@ ; ;-------------------------------------------------------- ; File Created by SDCC : free open source ISO C Compiler -; Version 4.3.0 #14210 (Linux) +; Version 4.4.0 #14648 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- @@ -62,10 +62,10 @@ _usb_execute_cbi: add hl, sp ld sp, hl ;source-doc/ufi-drv/./usb_cbi.c:18: const uint8_t interface_number = storage_device->interface_number; - ld l,(ix+4) - ld h,(ix+5) - ld c,l - ld b,h + ld c,(ix+4) + ld b,(ix+5) + ld l, c + ld h, b inc hl inc hl ld e, (hl) @@ -76,8 +76,8 @@ _usb_execute_cbi: ld hl,4 add hl, sp ex de, hl - ld bc,0x0008 ld hl,_cbi2_adsc + ld bc,0x0008 ldir pop bc pop de @@ -116,8 +116,10 @@ _usb_execute_cbi: ld h,(ix+5) push hl call _usbdev_dat_in_trnsfer - ld hl,7 - add hl, sp + pop af + pop af + pop af + inc sp l_usb_execute_cbi_00102: ;source-doc/ufi-drv/./usb_cbi.c:30: return USB_ERR_STALL; ld l,0x02 diff --git a/Source/HBIOS/util.asm b/Source/HBIOS/util.asm index 6d1ee813..d9983fd8 100644 --- a/Source/HBIOS/util.asm +++ b/Source/HBIOS/util.asm @@ -578,6 +578,17 @@ DELAY1: ; | ; --- LOOP = ((CPUSCL * 16) - 5) TS ------------+ | DEC A ; 4TS | | #IF (BIOS == BIOS_WBW) ; | | + #IF (CPUFAM == CPU_EZ80) ; | | + OR A ; +?TS FOR EZ80 | | + OR A ; +?TS FOR EZ80 | | + OR A ; +?TS FOR EZ80 | | + OR A ; +?TS FOR EZ80 | | + OR A ; +?TS FOR EZ80 | | + OR A ; +?TS FOR EZ80 | | + OR A ; +?TS FOR EZ80 | | + OR A ; +?TS FOR EZ80 | | + OR A ; +?TS FOR EZ80 | | + #ENDIF ; | | #IF (CPUFAM == CPU_Z180) ; | | OR A ; +4TS FOR Z180 | | #ENDIF ; | |