From 024074b2cf1a9ab14ee1eeeedad780801518ea83 Mon Sep 17 00:00:00 2001 From: Dean Netherton Date: Mon, 5 May 2025 12:13:29 +1000 Subject: [PATCH] ch376-native: fixed issue where keyboard int handler could cause corruption of io --- Source/HBIOS/Config/RCEZ80_std.asm | 4 +- Source/HBIOS/ch376-native/base-drv/ch376.c.s | 284 ++++++++------- .../ch376-native/base-drv/dev_transfers.c.s | 331 ++++++++---------- .../HBIOS/ch376-native/base-drv/protocol.c.s | 128 +++---- .../HBIOS/ch376-native/base-drv/transfers.c.s | 56 ++- .../ch376-native/base-drv/usb-base-drv.c.s | 6 +- .../ch376-native/keyboard/kyb_driver.c.s | 51 +-- .../ch376-native/scsi-drv/class_scsi.c.s | 107 +++--- .../ch376-native/scsi-drv/scsi_driver.c.s | 295 ++++++++-------- .../ch376-native/source-doc/base-drv/ch376.c | 5 +- .../ch376-native/source-doc/base-drv/ch376.h | 2 - .../source-doc/base-drv/dev_transfers.c | 6 + .../source-doc/base-drv/protocol.c | 4 + .../source-doc/base-drv/transfers.c | 4 + .../source-doc/keyboard/kyb_driver.c | 2 + .../source-doc/scsi-drv/class_scsi.c | 2 + .../source-doc/scsi-drv/scsi_driver.c | 5 + .../ch376-native/source-doc/ufi-drv/usb_cbi.c | 2 +- Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s | 26 +- 19 files changed, 630 insertions(+), 690 deletions(-) diff --git a/Source/HBIOS/Config/RCEZ80_std.asm b/Source/HBIOS/Config/RCEZ80_std.asm index 8743b2b0..fe4c9450 100644 --- a/Source/HBIOS/Config/RCEZ80_std.asm +++ b/Source/HBIOS/Config/RCEZ80_std.asm @@ -89,7 +89,7 @@ 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) -CHNATIVEEZ80 .SET FALSE ; CH376: DELEGATE USB DRIVERS TO EZ80'S FIRMWARE +CHNATIVEEZ80 .SET TRUE ; CH376: DELEGATE USB DRIVERS TO EZ80'S FIRMWARE CHNATIVEFORCE .SET TRUE ; CH376: DISABLE AUTO-DETECTION OF MODULE - ASSUME ITS INSTALLED -EZ80TIMER .SET EZ80TMR_INT ; EZ80: TIMER TICK MODEL: EZ80TMR_[INT|FIRM] +EZ80TIMER .SET EZ80TMR_FIRM ; EZ80: TIMER TICK MODEL: EZ80TMR_[INT|FIRM] diff --git a/Source/HBIOS/ch376-native/base-drv/ch376.c.s b/Source/HBIOS/ch376-native/base-drv/ch376.c.s index 35d7c3cb..710a7959 100644 --- a/Source/HBIOS/ch376-native/base-drv/ch376.c.s +++ b/Source/HBIOS/ch376-native/base-drv/ch376.c.s @@ -33,8 +33,6 @@ _USB_MODULE_LEDS .EQU 0xff8a ; .area _INITIALIZED removed by z88dk -_result: - DEFS 1 #ENDIF @@ -50,12 +48,12 @@ _result: ;-------------------------------------------------------- ; code ;-------------------------------------------------------- -;source-doc/base-drv/ch376.c:8: void ch_command(const uint8_t command) __z88dk_fastcall { +;source-doc/base-drv/ch376.c:6: void ch_command(const uint8_t command) __z88dk_fastcall { ; --------------------------------- ; Function ch_command ; --------------------------------- _ch_command: -;source-doc/base-drv/ch376.c:10: while ((CH376_COMMAND_PORT & PARA_STATE_BUSY) && --counter != 0) +;source-doc/base-drv/ch376.c:8: while ((CH376_COMMAND_PORT & PARA_STATE_BUSY) && --counter != 0) ld b,0xff l_ch_command_00102: ld a, +((_CH376_COMMAND_PORT) / 256) @@ -64,150 +62,150 @@ l_ch_command_00102: jr Z,l_ch_command_00104 djnz l_ch_command_00102 l_ch_command_00104: -;source-doc/base-drv/ch376.c:21: CH376_COMMAND_PORT = command; +;source-doc/base-drv/ch376.c:19: CH376_COMMAND_PORT = command; ld a, l ld bc,_CH376_COMMAND_PORT out (c), a -;source-doc/base-drv/ch376.c:22: } +;source-doc/base-drv/ch376.c:20: } ret -;source-doc/base-drv/ch376.c:26: usb_error ch_long_wait_int_and_get_status(void) { return ch_wait_int_and_get_status(5000); } +;source-doc/base-drv/ch376.c:24: 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:28: usb_error ch_short_wait_int_and_get_statu(void) { return ch_wait_int_and_get_status(100); } +;source-doc/base-drv/ch376.c:26: 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:30: usb_error ch_very_short_wait_int_and_get_(void) { return ch_wait_int_and_get_status(10); } +;source-doc/base-drv/ch376.c:28: 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:32: usb_error ch_get_status(void) { +;source-doc/base-drv/ch376.c:30: usb_error ch_get_status(void) { ; --------------------------------- ; Function ch_get_status ; --------------------------------- _ch_get_status: -;source-doc/base-drv/ch376.c:33: ch_command(CH_CMD_GET_STATUS); +;source-doc/base-drv/ch376.c:31: ch_command(CH_CMD_GET_STATUS); ld l,0x22 call _ch_command -;source-doc/base-drv/ch376.c:34: uint8_t ch_status = CH376_DATA_PORT; +;source-doc/base-drv/ch376.c:32: 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:36: if (ch_status >= USB_FILERR_MIN && ch_status <= USB_FILERR_MAX) +;source-doc/base-drv/ch376.c:34: if (ch_status >= USB_FILERR_MIN && ch_status <= USB_FILERR_MAX) cp 0x41 jr C,l_ch_get_status_00102 cp 0xb5 jr NC,l_ch_get_status_00102 -;source-doc/base-drv/ch376.c:37: return ch_status; +;source-doc/base-drv/ch376.c:35: return ch_status; ld l, a jr l_ch_get_status_00126 l_ch_get_status_00102: -;source-doc/base-drv/ch376.c:39: if (ch_status == CH_CMD_RET_SUCCESS) +;source-doc/base-drv/ch376.c:37: if (ch_status == CH_CMD_RET_SUCCESS) cp 0x51 jr NZ,l_ch_get_status_00105 -;source-doc/base-drv/ch376.c:40: return USB_ERR_OK; +;source-doc/base-drv/ch376.c:38: return USB_ERR_OK; ld l,0x00 jr l_ch_get_status_00126 l_ch_get_status_00105: -;source-doc/base-drv/ch376.c:42: if (ch_status == CH_USB_INT_SUCCESS) +;source-doc/base-drv/ch376.c:40: if (ch_status == CH_USB_INT_SUCCESS) cp 0x14 jr NZ,l_ch_get_status_00107 -;source-doc/base-drv/ch376.c:43: return USB_ERR_OK; +;source-doc/base-drv/ch376.c:41: return USB_ERR_OK; ld l,0x00 jr l_ch_get_status_00126 l_ch_get_status_00107: -;source-doc/base-drv/ch376.c:45: if (ch_status == CH_USB_INT_CONNECT) +;source-doc/base-drv/ch376.c:43: if (ch_status == CH_USB_INT_CONNECT) cp 0x15 jr NZ,l_ch_get_status_00109 -;source-doc/base-drv/ch376.c:46: return USB_INT_CONNECT; +;source-doc/base-drv/ch376.c:44: return USB_INT_CONNECT; ld l,0x81 jr l_ch_get_status_00126 l_ch_get_status_00109: -;source-doc/base-drv/ch376.c:48: if (ch_status == CH_USB_INT_DISK_READ) +;source-doc/base-drv/ch376.c:46: if (ch_status == CH_USB_INT_DISK_READ) cp 0x1d jr NZ,l_ch_get_status_00111 -;source-doc/base-drv/ch376.c:49: return USB_ERR_DISK_READ; +;source-doc/base-drv/ch376.c:47: 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:51: if (ch_status == CH_USB_INT_DISK_WRITE) +;source-doc/base-drv/ch376.c:49: if (ch_status == CH_USB_INT_DISK_WRITE) cp 0x1e jr NZ,l_ch_get_status_00113 -;source-doc/base-drv/ch376.c:52: return USB_ERR_DISK_WRITE; +;source-doc/base-drv/ch376.c:50: 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:54: if (ch_status == CH_USB_INT_DISCONNECT) { +;source-doc/base-drv/ch376.c:52: if (ch_status == CH_USB_INT_DISCONNECT) { cp 0x16 jr NZ,l_ch_get_status_00115 -;source-doc/base-drv/ch376.c:55: ch_cmd_set_usb_mode(5); +;source-doc/base-drv/ch376.c:53: ch_cmd_set_usb_mode(5); ld l,0x05 call _ch_cmd_set_usb_mode -;source-doc/base-drv/ch376.c:56: return USB_ERR_NO_DEVICE; +;source-doc/base-drv/ch376.c:54: 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:59: if (ch_status == CH_USB_INT_BUF_OVER) +;source-doc/base-drv/ch376.c:57: if (ch_status == CH_USB_INT_BUF_OVER) cp 0x17 jr NZ,l_ch_get_status_00117 -;source-doc/base-drv/ch376.c:60: return USB_ERR_DATA_ERROR; +;source-doc/base-drv/ch376.c:58: 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:62: ch_status &= 0x2F; +;source-doc/base-drv/ch376.c:60: ch_status &= 0x2F; and 0x2f -;source-doc/base-drv/ch376.c:64: if (ch_status == 0x2A) +;source-doc/base-drv/ch376.c:62: if (ch_status == 0x2A) cp 0x2a jr NZ,l_ch_get_status_00119 -;source-doc/base-drv/ch376.c:65: return USB_ERR_NAK; +;source-doc/base-drv/ch376.c:63: return USB_ERR_NAK; ld l,0x01 jr l_ch_get_status_00126 l_ch_get_status_00119: -;source-doc/base-drv/ch376.c:67: if (ch_status == 0x2E) +;source-doc/base-drv/ch376.c:65: if (ch_status == 0x2E) cp 0x2e jr NZ,l_ch_get_status_00121 -;source-doc/base-drv/ch376.c:68: return USB_ERR_STALL; +;source-doc/base-drv/ch376.c:66: return USB_ERR_STALL; ld l,0x02 jr l_ch_get_status_00126 l_ch_get_status_00121: -;source-doc/base-drv/ch376.c:70: ch_status &= 0x23; +;source-doc/base-drv/ch376.c:68: ch_status &= 0x23; and 0x23 -;source-doc/base-drv/ch376.c:72: if (ch_status == 0x20) +;source-doc/base-drv/ch376.c:70: if (ch_status == 0x20) cp 0x20 jr NZ,l_ch_get_status_00123 -;source-doc/base-drv/ch376.c:73: return USB_ERR_TIMEOUT; +;source-doc/base-drv/ch376.c:71: return USB_ERR_TIMEOUT; ld l,0x03 jr l_ch_get_status_00126 l_ch_get_status_00123: -;source-doc/base-drv/ch376.c:75: if (ch_status == 0x23) +;source-doc/base-drv/ch376.c:73: if (ch_status == 0x23) sub 0x23 jr NZ,l_ch_get_status_00125 -;source-doc/base-drv/ch376.c:76: return USB_TOKEN_OUT_OF_SYNC; +;source-doc/base-drv/ch376.c:74: 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:78: return USB_ERR_UNEXPECTED_STATUS_FROM_; +;source-doc/base-drv/ch376.c:76: return USB_ERR_UNEXPECTED_STATUS_FROM_; ld l,0x08 l_ch_get_status_00126: -;source-doc/base-drv/ch376.c:79: } +;source-doc/base-drv/ch376.c:77: } ret -;source-doc/base-drv/ch376.c:81: void ch_cmd_reset_all(void) { ch_command(CH_CMD_RESET_ALL); } +;source-doc/base-drv/ch376.c:79: 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:100: uint8_t ch_probe(void) { +;source-doc/base-drv/ch376.c:98: uint8_t ch_probe(void) { ; --------------------------------- ; Function ch_probe ; --------------------------------- @@ -216,66 +214,66 @@ _ch_probe: ld ix,0 add ix,sp dec sp -;source-doc/base-drv/ch376.c:102: do { +;source-doc/base-drv/ch376.c:100: do { ld (ix-1),0x05 l_ch_probe_00103: -;source-doc/base-drv/ch376.c:85: ch_command(CH_CMD_CHECK_EXIST); +;source-doc/base-drv/ch376.c:83: ch_command(CH_CMD_CHECK_EXIST); ld l,0x06 call _ch_command -;source-doc/base-drv/ch376.c:86: CH376_DATA_PORT = (uint8_t)~0x55; +;source-doc/base-drv/ch376.c:84: CH376_DATA_PORT = (uint8_t)~0x55; ld a,0xaa ld bc,_CH376_DATA_PORT out (c), a -;source-doc/base-drv/ch376.c:87: delay(); +;source-doc/base-drv/ch376.c:85: delay(); call _delay -;source-doc/base-drv/ch376.c:88: complement = CH376_DATA_PORT; +;source-doc/base-drv/ch376.c:86: complement = CH376_DATA_PORT; ld a, +((_CH376_DATA_PORT) / 256) in a, (((_CH376_DATA_PORT) & 0xFF)) -;source-doc/base-drv/ch376.c:89: return complement == 0x55; +;source-doc/base-drv/ch376.c:87: return complement == 0x55; sub 0x55 jr NZ,l_ch_probe_00102 -;source-doc/base-drv/ch376.c:103: if (ch_cmd_check_exist()) -;source-doc/base-drv/ch376.c:104: return true; +;source-doc/base-drv/ch376.c:101: if (ch_cmd_check_exist()) +;source-doc/base-drv/ch376.c:102: return true; ld l,0x01 jr l_ch_probe_00107 l_ch_probe_00102: -;source-doc/base-drv/ch376.c:106: delay_medium(); +;source-doc/base-drv/ch376.c:104: delay_medium(); call _delay_medium -;source-doc/base-drv/ch376.c:107: } while (--i != 0); +;source-doc/base-drv/ch376.c:105: } while (--i != 0); dec (ix-1) jr NZ,l_ch_probe_00103 -;source-doc/base-drv/ch376.c:109: return false; +;source-doc/base-drv/ch376.c:107: return false; ld l,0x00 l_ch_probe_00107: -;source-doc/base-drv/ch376.c:110: } +;source-doc/base-drv/ch376.c:108: } inc sp pop ix ret -;source-doc/base-drv/ch376.c:112: usb_error ch_cmd_set_usb_mode(const uint8_t mode) __z88dk_fastcall { +;source-doc/base-drv/ch376.c:110: usb_error ch_cmd_set_usb_mode(const uint8_t mode) __z88dk_fastcall { ; --------------------------------- ; Function ch_cmd_set_usb_mode ; --------------------------------- _ch_cmd_set_usb_mode: ld c, l -;source-doc/base-drv/ch376.c:113: uint8_t result = 0; +;source-doc/base-drv/ch376.c:111: uint8_t result = 0; ld b,0x00 -;source-doc/base-drv/ch376.c:115: CH376_COMMAND_PORT = CH_CMD_SET_USB_MODE; +;source-doc/base-drv/ch376.c:113: 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:116: delay(); +;source-doc/base-drv/ch376.c:114: delay(); call _delay pop bc -;source-doc/base-drv/ch376.c:117: CH376_DATA_PORT = mode; +;source-doc/base-drv/ch376.c:115: CH376_DATA_PORT = mode; ld a, c push bc ld bc,_CH376_DATA_PORT out (c), a -;source-doc/base-drv/ch376.c:118: delay(); +;source-doc/base-drv/ch376.c:116: delay(); call _delay pop bc -;source-doc/base-drv/ch376.c:122: while (result != CH_CMD_RET_SUCCESS && result != CH_CMD_RET_ABORT && --count != 0) { +;source-doc/base-drv/ch376.c:120: 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, b @@ -294,17 +292,17 @@ l_ch_cmd_set_usb_mode_00147: jr Z,l_ch_cmd_set_usb_mode_00105 dec c jr Z,l_ch_cmd_set_usb_mode_00105 -;source-doc/base-drv/ch376.c:123: result = CH376_DATA_PORT; +;source-doc/base-drv/ch376.c:121: result = CH376_DATA_PORT; ld a, +((_CH376_DATA_PORT) / 256) in a, (((_CH376_DATA_PORT) & 0xFF)) ld b, a -;source-doc/base-drv/ch376.c:124: delay(); +;source-doc/base-drv/ch376.c:122: delay(); push bc call _delay pop bc jr l_ch_cmd_set_usb_mode_00103 l_ch_cmd_set_usb_mode_00105: -;source-doc/base-drv/ch376.c:127: return (result == CH_CMD_RET_SUCCESS) ? USB_ERR_OK : USB_ERR_FAIL; +;source-doc/base-drv/ch376.c:125: 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 @@ -313,24 +311,24 @@ l_ch_cmd_set_usb_mode_00105: l_ch_cmd_set_usb_mode_00108: ld l,0x0e l_ch_cmd_set_usb_mode_00109: -;source-doc/base-drv/ch376.c:128: } +;source-doc/base-drv/ch376.c:126: } ret -;source-doc/base-drv/ch376.c:130: uint8_t ch_cmd_get_ic_version(void) { +;source-doc/base-drv/ch376.c:128: 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:131: ch_command(CH_CMD_GET_IC_VER); +;source-doc/base-drv/ch376.c:129: ch_command(CH_CMD_GET_IC_VER); ld l,0x01 call _ch_command -;source-doc/base-drv/ch376.c:132: return CH376_DATA_PORT & 0x1f; +;source-doc/base-drv/ch376.c:130: 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:133: } +;source-doc/base-drv/ch376.c:131: } ret -;source-doc/base-drv/ch376.c:135: void ch_issue_token(const uint8_t toggle_bit, const uint8_t endpoint, const ch376_pid pid) { +;source-doc/base-drv/ch376.c:133: void ch_issue_token(const uint8_t toggle_bit, const uint8_t endpoint, const ch376_pid pid) { ; --------------------------------- ; Function ch_issue_token ; --------------------------------- @@ -338,14 +336,14 @@ _ch_issue_token: push ix ld ix,0 add ix,sp -;source-doc/base-drv/ch376.c:136: ch_command(CH_CMD_ISSUE_TKN_X); +;source-doc/base-drv/ch376.c:134: ch_command(CH_CMD_ISSUE_TKN_X); ld l,0x4e call _ch_command -;source-doc/base-drv/ch376.c:137: CH376_DATA_PORT = toggle_bit; +;source-doc/base-drv/ch376.c:135: CH376_DATA_PORT = toggle_bit; ld a,(ix+4) ld bc,_CH376_DATA_PORT out (c), a -;source-doc/base-drv/ch376.c:138: CH376_DATA_PORT = endpoint << 4 | pid; +;source-doc/base-drv/ch376.c:136: CH376_DATA_PORT = endpoint << 4 | pid; ld a,(ix+5) add a, a add a, a @@ -354,15 +352,15 @@ _ch_issue_token: or (ix+6) ld bc,_CH376_DATA_PORT out (c), a -;source-doc/base-drv/ch376.c:139: } +;source-doc/base-drv/ch376.c:137: } pop ix ret -;source-doc/base-drv/ch376.c:141: void ch_issue_token_in(const endpoint_param *const endpoint) __z88dk_fastcall { +;source-doc/base-drv/ch376.c:139: 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:142: ch_issue_token(endpoint->toggle ? 0x80 : 0x00, endpoint->number, CH_PID_IN); +;source-doc/base-drv/ch376.c:140: ch_issue_token(endpoint->toggle ? 0x80 : 0x00, endpoint->number, CH_PID_IN); ld e,l ld d,h ld a, (hl) @@ -386,14 +384,14 @@ l_ch_issue_token_in_00104: call _ch_issue_token pop af inc sp -;source-doc/base-drv/ch376.c:143: } +;source-doc/base-drv/ch376.c:141: } ret -;source-doc/base-drv/ch376.c:145: void ch_issue_token_out(const endpoint_param *const endpoint) __z88dk_fastcall { +;source-doc/base-drv/ch376.c:143: 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:146: ch_issue_token(endpoint->toggle ? 0x40 : 0x00, endpoint->number, CH_PID_OUT); +;source-doc/base-drv/ch376.c:144: ch_issue_token(endpoint->toggle ? 0x40 : 0x00, endpoint->number, CH_PID_OUT); ld e,l ld d,h ld a, (hl) @@ -417,9 +415,9 @@ l_ch_issue_token_out_00104: call _ch_issue_token pop af inc sp -;source-doc/base-drv/ch376.c:147: } +;source-doc/base-drv/ch376.c:145: } ret -;source-doc/base-drv/ch376.c:149: void ch_issue_token_out_ep0(void) { ch_issue_token(0x40, 0, CH_PID_OUT); } +;source-doc/base-drv/ch376.c:147: void ch_issue_token_out_ep0(void) { ch_issue_token(0x40, 0, CH_PID_OUT); } ; --------------------------------- ; Function ch_issue_token_out_ep0 ; --------------------------------- @@ -435,7 +433,7 @@ _ch_issue_token_out_ep0: pop af inc sp ret -;source-doc/base-drv/ch376.c:151: void ch_issue_token_in_ep0(void) { ch_issue_token(0x80, 0, CH_PID_IN); } +;source-doc/base-drv/ch376.c:149: void ch_issue_token_in_ep0(void) { ch_issue_token(0x80, 0, CH_PID_IN); } ; --------------------------------- ; Function ch_issue_token_in_ep0 ; --------------------------------- @@ -451,7 +449,7 @@ _ch_issue_token_in_ep0: pop af inc sp ret -;source-doc/base-drv/ch376.c:153: void ch_issue_token_setup(void) { ch_issue_token(0, 0, CH_PID_SETUP); } +;source-doc/base-drv/ch376.c:151: void ch_issue_token_setup(void) { ch_issue_token(0, 0, CH_PID_SETUP); } ; --------------------------------- ; Function ch_issue_token_setup ; --------------------------------- @@ -469,7 +467,7 @@ _ch_issue_token_setup: pop af inc sp ret -;source-doc/base-drv/ch376.c:155: usb_error ch_data_in_transfer(uint8_t *buffer, int16_t buffer_size, endpoint_param *const endpoint) { +;source-doc/base-drv/ch376.c:153: usb_error ch_data_in_transfer(uint8_t *buffer, int16_t buffer_size, endpoint_param *const endpoint) { ; --------------------------------- ; Function ch_data_in_transfer ; --------------------------------- @@ -477,37 +475,36 @@ _ch_data_in_transfer: push ix ld ix,0 add ix,sp -;source-doc/base-drv/ch376.c:158: if (buffer_size == 0) +;source-doc/base-drv/ch376.c:157: 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:159: return USB_ERR_OK; +;source-doc/base-drv/ch376.c:158: return USB_ERR_OK; ld l,0x00 jp l_ch_data_in_transfer_00111 l_ch_data_in_transfer_00102: -;source-doc/base-drv/ch376.c:161: USB_MODULE_LEDS = 0x01; +;source-doc/base-drv/ch376.c:160: USB_MODULE_LEDS = 0x01; ld a,0x01 ld bc,_USB_MODULE_LEDS out (c), a -;source-doc/base-drv/ch376.c:162: do { +;source-doc/base-drv/ch376.c:161: do { ld c,(ix+8) ld b,(ix+9) l_ch_data_in_transfer_00107: -;source-doc/base-drv/ch376.c:163: ch_issue_token_in(endpoint); +;source-doc/base-drv/ch376.c:162: ch_issue_token_in(endpoint); ld l,c ld h,b push hl call _ch_issue_token_in -;source-doc/base-drv/ch376.c:165: result = ch_long_wait_int_and_get_status(); +;source-doc/base-drv/ch376.c:164: result = ch_long_wait_int_and_get_status(); call _ch_long_wait_int_and_get_statu - pop bc ld a, l - ld (_result), a -;source-doc/base-drv/ch376.c:166: CHECK(result); - ld a,(_result) + pop bc + ld l, a +;source-doc/base-drv/ch376.c:165: CHECK(result); or a jr NZ,l_ch_data_in_transfer_00110 -;source-doc/base-drv/ch376.c:168: endpoint->toggle = !endpoint->toggle; +;source-doc/base-drv/ch376.c:167: endpoint->toggle = !endpoint->toggle; ld e, c ld d, b ld l, e @@ -521,32 +518,32 @@ l_ch_data_in_transfer_00107: and 0xfe or l ld (de), a -;source-doc/base-drv/ch376.c:170: count = ch_read_data(buffer); +;source-doc/base-drv/ch376.c:169: 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:172: if (count == 0) { +;source-doc/base-drv/ch376.c:171: if (count == 0) { ld a, e -;source-doc/base-drv/ch376.c:173: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/ch376.c:172: 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:174: return USB_ERR_DATA_ERROR; +;source-doc/base-drv/ch376.c:173: return USB_ERR_DATA_ERROR; ld l,0x04 jr l_ch_data_in_transfer_00111 l_ch_data_in_transfer_00106: -;source-doc/base-drv/ch376.c:177: buffer += count; +;source-doc/base-drv/ch376.c:176: buffer += count; ld a,(ix+4) add a, e ld (ix+4),a jr NC,l_ch_data_in_transfer_00148 inc (ix+5) l_ch_data_in_transfer_00148: -;source-doc/base-drv/ch376.c:178: buffer_size -= count; +;source-doc/base-drv/ch376.c:177: buffer_size -= count; ld d,0x00 ld a,(ix+6) sub e @@ -554,7 +551,7 @@ l_ch_data_in_transfer_00148: ld a,(ix+7) sbc a, d ld (ix+7),a -;source-doc/base-drv/ch376.c:179: } while (buffer_size > 0); +;source-doc/base-drv/ch376.c:178: } while (buffer_size > 0); xor a cp (ix+6) sbc a,(ix+7) @@ -562,26 +559,25 @@ l_ch_data_in_transfer_00148: xor 0x80 l_ch_data_in_transfer_00149: jp M, l_ch_data_in_transfer_00107 -;source-doc/base-drv/ch376.c:181: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/ch376.c:180: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS out (c), a -;source-doc/base-drv/ch376.c:182: return USB_ERR_OK; +;source-doc/base-drv/ch376.c:181: return USB_ERR_OK; ld l,0x00 jr l_ch_data_in_transfer_00111 -;source-doc/base-drv/ch376.c:184: done: +;source-doc/base-drv/ch376.c:183: done: l_ch_data_in_transfer_00110: -;source-doc/base-drv/ch376.c:185: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/ch376.c:184: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS out (c), a -;source-doc/base-drv/ch376.c:186: return result; - ld hl, (_result) +;source-doc/base-drv/ch376.c:185: return result; l_ch_data_in_transfer_00111: -;source-doc/base-drv/ch376.c:187: } +;source-doc/base-drv/ch376.c:186: } pop ix ret -;source-doc/base-drv/ch376.c:190: usb_error ch_data_in_transfer_n(uint8_t *const buffer, uint8_t *const buffer_size, endpoint_param *const endpoint) { +;source-doc/base-drv/ch376.c:189: usb_error ch_data_in_transfer_n(uint8_t *const buffer, uint8_t *const buffer_size, endpoint_param *const endpoint) { ; --------------------------------- ; Function ch_data_in_transfer_n ; --------------------------------- @@ -589,20 +585,20 @@ _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:193: 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:195: 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:197: 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; +;source-doc/base-drv/ch376.c:199: endpoint->toggle = !endpoint->toggle; ld l,(ix+8) ld h,(ix+9) ld a, (hl) @@ -614,33 +610,33 @@ _ch_data_in_transfer_n: and 0xfe or c ld (hl), a -;source-doc/base-drv/ch376.c:202: count = ch_read_data(buffer); +;source-doc/base-drv/ch376.c:201: 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:203: *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:205: 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:207: return USB_ERR_OK; ld l,0x00 jr l_ch_data_in_transfer_n_00104 -;source-doc/base-drv/ch376.c:209: done: +;source-doc/base-drv/ch376.c:208: done: l_ch_data_in_transfer_n_00103: -;source-doc/base-drv/ch376.c:210: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/ch376.c:209: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS out (c), a -;source-doc/base-drv/ch376.c:211: return result; +;source-doc/base-drv/ch376.c:210: return result; l_ch_data_in_transfer_n_00104: -;source-doc/base-drv/ch376.c:212: } +;source-doc/base-drv/ch376.c:211: } pop ix ret -;source-doc/base-drv/ch376.c:214: usb_error ch_data_out_transfer(const uint8_t *buffer, int16_t buffer_length, endpoint_param *const endpoint) { +;source-doc/base-drv/ch376.c:213: usb_error ch_data_out_transfer(const uint8_t *buffer, int16_t buffer_length, endpoint_param *const endpoint) { ; --------------------------------- ; Function ch_data_out_transfer ; --------------------------------- @@ -649,7 +645,7 @@ _ch_data_out_transfer: ld ix,0 add ix,sp dec sp -;source-doc/base-drv/ch376.c:217: const uint8_t max_packet_size = calc_max_packet_size(endpoint->max_packet_sizex); +;source-doc/base-drv/ch376.c:216: 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 @@ -657,13 +653,13 @@ _ch_data_out_transfer: inc de ld a, (de) ld (ix-1),a -;source-doc/base-drv/ch376.c:219: USB_MODULE_LEDS = 0x02; +;source-doc/base-drv/ch376.c:218: 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:221: while (buffer_length > 0) { +;source-doc/base-drv/ch376.c:220: while (buffer_length > 0) { l_ch_data_out_transfer_00103: xor a cp (ix+6) @@ -672,7 +668,7 @@ l_ch_data_out_transfer_00103: xor 0x80 l_ch_data_out_transfer_00139: jp P, l_ch_data_out_transfer_00105 -;source-doc/base-drv/ch376.c:222: const uint8_t size = max_packet_size < buffer_length ? max_packet_size : buffer_length; +;source-doc/base-drv/ch376.c:221: const uint8_t size = max_packet_size < buffer_length ? max_packet_size : buffer_length; ld d,(ix-1) ld e,0x00 ld a, d @@ -688,7 +684,7 @@ l_ch_data_out_transfer_00109: ld d,(ix+6) ld e,(ix+7) l_ch_data_out_transfer_00110: -;source-doc/base-drv/ch376.c:223: buffer = ch_write_data(buffer, size); +;source-doc/base-drv/ch376.c:222: buffer = ch_write_data(buffer, size); push bc push de push de @@ -703,7 +699,7 @@ l_ch_data_out_transfer_00110: pop bc ld (ix+4),l ld (ix+5),h -;source-doc/base-drv/ch376.c:224: buffer_length -= size; +;source-doc/base-drv/ch376.c:223: buffer_length -= size; ld e,0x00 ld a,(ix+6) sub d @@ -711,19 +707,19 @@ l_ch_data_out_transfer_00110: ld a,(ix+7) sbc a, e ld (ix+7),a -;source-doc/base-drv/ch376.c:225: ch_issue_token_out(endpoint); +;source-doc/base-drv/ch376.c:224: ch_issue_token_out(endpoint); ld l,c ld h,b push hl call _ch_issue_token_out -;source-doc/base-drv/ch376.c:227: CHECK(ch_long_wait_int_and_get_status()); +;source-doc/base-drv/ch376.c:226: CHECK(ch_long_wait_int_and_get_status()); call _ch_long_wait_int_and_get_statu ld a, l pop bc ld l, a or a jr NZ,l_ch_data_out_transfer_00106 -;source-doc/base-drv/ch376.c:229: endpoint->toggle = !endpoint->toggle; +;source-doc/base-drv/ch376.c:228: endpoint->toggle = !endpoint->toggle; ld e, c ld d, b ld l, e @@ -739,40 +735,38 @@ l_ch_data_out_transfer_00110: ld (de), a jr l_ch_data_out_transfer_00103 l_ch_data_out_transfer_00105: -;source-doc/base-drv/ch376.c:232: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/ch376.c:231: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS out (c), a -;source-doc/base-drv/ch376.c:233: return USB_ERR_OK; +;source-doc/base-drv/ch376.c:232: return USB_ERR_OK; ld l,0x00 jr l_ch_data_out_transfer_00107 -;source-doc/base-drv/ch376.c:235: done: +;source-doc/base-drv/ch376.c:234: done: l_ch_data_out_transfer_00106: -;source-doc/base-drv/ch376.c:236: USB_MODULE_LEDS = 0x00; +;source-doc/base-drv/ch376.c:235: USB_MODULE_LEDS = 0x00; ld a,0x00 ld bc,_USB_MODULE_LEDS out (c), a -;source-doc/base-drv/ch376.c:237: return result; +;source-doc/base-drv/ch376.c:236: return result; l_ch_data_out_transfer_00107: -;source-doc/base-drv/ch376.c:238: } +;source-doc/base-drv/ch376.c:237: } inc sp pop ix ret -;source-doc/base-drv/ch376.c:240: void ch_set_usb_address(const uint8_t device_address) __z88dk_fastcall { +;source-doc/base-drv/ch376.c:239: 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:241: ch_command(CH_CMD_SET_USB_ADDR); +;source-doc/base-drv/ch376.c:240: ch_command(CH_CMD_SET_USB_ADDR); push hl ld l,0x13 call _ch_command pop hl -;source-doc/base-drv/ch376.c:242: CH376_DATA_PORT = device_address; +;source-doc/base-drv/ch376.c:241: CH376_DATA_PORT = device_address; ld a, l ld bc,_CH376_DATA_PORT out (c), a -;source-doc/base-drv/ch376.c:243: } +;source-doc/base-drv/ch376.c:242: } ret -_result: - DEFB +0x00 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 baa56e99..7185ae4c 100644 --- a/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s +++ b/Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s @@ -94,30 +94,28 @@ _usbdev_blk_out_trnsfer: ld ix,0 add ix,sp push af - push af -;source-doc/base-drv/dev_transfers.c:29: */ - ld e,(ix+4) - ld d,(ix+5) - ld hl,0x0003 - add hl, de - ex (sp), hl -;source-doc/base-drv/dev_transfers.c:31: return usb_control_transfer(cmd_packet, buffer, device->address, device->max_packet_size); - ld (ix-2),e - ld (ix-1),d - pop bc +;source-doc/base-drv/dev_transfers.c:30: usb_error usbdev_control_transfer(device_config *const device, const setup_packet *const cmd_packet, uint8_t *const buffer) { + ld c,(ix+4) + ld b,(ix+5) + ld e, c + ld d, b + inc de + inc de + inc de +;source-doc/base-drv/dev_transfers.c:32: } pop hl + ld l,c + ld h,b ld a,(hl) push hl - push bc rlca rlca rlca rlca and 0x0f + push bc + push de push de - ld l,(ix-4) - ld h,(ix-3) - push hl push af inc sp ld l,(ix+8) @@ -132,55 +130,51 @@ _usbdev_blk_out_trnsfer: pop af inc sp pop de + pop bc +;source-doc/base-drv/dev_transfers.c:34: usb_error usbdev_blk_out_trnsfer(device_config *const dev, const uint8_t *const buffer, const uint16_t buffer_size) { ld a, l - ld (_result), a -;source-doc/base-drv/dev_transfers.c:33: - ld hl,_result - ld a, (hl) sub 0x02 jr NZ,l_usbdev_blk_out_trnsfer_00102 -;source-doc/base-drv/dev_transfers.c:34: usb_error usbdev_blk_out_trnsfer(device_config *const dev, const uint8_t *const buffer, const uint16_t buffer_size) { - ex de, hl - inc hl - ld d, (hl) - ld l,(ix-2) - ld h,(ix-1) - ld a, (hl) +;source-doc/base-drv/dev_transfers.c:35: usb_error result; + inc bc + ld a, (bc) + ld b, a + pop hl + ld a,(hl) + push hl rlca rlca rlca rlca and 0x0f - ld b, a - pop hl - ld a,(hl) - push hl + ld c, a + ld l, e + ld h, d + ld a, (hl) rrca and 0x07 - ld e,b push de - push af + push bc inc sp + ld h, c + ld l,a + push hl call _usbtrn_clear_endpoint_halt pop af inc sp -;source-doc/base-drv/dev_transfers.c:35: - pop hl - push hl + pop de +;source-doc/base-drv/dev_transfers.c:36: + ex de, hl res 0, (hl) -;source-doc/base-drv/dev_transfers.c:36: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_OUT]; +;source-doc/base-drv/dev_transfers.c:37: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_OUT]; ld l,0x02 - jr l_usbdev_blk_out_trnsfer_00104 +;source-doc/base-drv/dev_transfers.c:43: endpoint->toggle = 0; l_usbdev_blk_out_trnsfer_00102: -;source-doc/base-drv/dev_transfers.c:39: -;source-doc/base-drv/dev_transfers.c:42: endpoint->toggle = 0; - ld hl, (_result) -l_usbdev_blk_out_trnsfer_00104: -;source-doc/base-drv/dev_transfers.c:43: return USB_ERR_STALL; +;source-doc/base-drv/dev_transfers.c:44: return USB_ERR_STALL; ld sp, ix pop ix ret -;source-doc/base-drv/dev_transfers.c:45: +;source-doc/base-drv/dev_transfers.c:46: ; --------------------------------- ; Function usbdev_bulk_in_transfer ; --------------------------------- @@ -189,30 +183,26 @@ _usbdev_bulk_in_transfer: ld ix,0 add ix,sp push af - push af -;source-doc/base-drv/dev_transfers.c:46: RETURN_CHECK(result); - ld e,(ix+4) - ld d,(ix+5) +;source-doc/base-drv/dev_transfers.c:49: done: + ld c,(ix+4) + ld b,(ix+5) ld hl,0x0006 - add hl, de - ex (sp), hl -;source-doc/base-drv/dev_transfers.c:48: done: - ld (ix-2),e - ld (ix-1),d - pop bc - pop hl + add hl, bc +;source-doc/base-drv/dev_transfers.c:51: } + pop de + ld e,c + ld d,b + ex de,hl ld a,(hl) push hl - push bc rlca rlca rlca rlca and 0x0f + push bc + push de push de - ld l,(ix-4) - ld h,(ix-3) - push hl push af inc sp ld l,(ix+8) @@ -227,55 +217,51 @@ _usbdev_bulk_in_transfer: pop af inc sp pop de + pop bc +;source-doc/base-drv/dev_transfers.c:53: usb_error usbdev_bulk_in_transfer(device_config *const dev, uint8_t *const buffer, uint8_t *const buffer_size) { ld a, l - ld (_result), a -;source-doc/base-drv/dev_transfers.c:50: } - ld hl,_result - ld a, (hl) sub 0x02 jr NZ,l_usbdev_bulk_in_transfer_00102 -;source-doc/base-drv/dev_transfers.c:51: - ex de, hl - inc hl - ld d, (hl) - ld l,(ix-2) - ld h,(ix-1) - ld a, (hl) +;source-doc/base-drv/dev_transfers.c:54: usb_error result; + inc bc + ld a, (bc) + ld b, a + pop hl + ld a,(hl) + push hl rlca rlca rlca rlca and 0x0f - ld b, a - pop hl - ld a,(hl) - push hl + ld c, a + ld l, e + ld h, d + ld a, (hl) rrca and 0x07 - ld e,b push de - push af + push bc inc sp + ld h, c + ld l,a + push hl call _usbtrn_clear_endpoint_halt pop af inc sp -;source-doc/base-drv/dev_transfers.c:52: usb_error usbdev_bulk_in_transfer(device_config *const dev, uint8_t *const buffer, uint8_t *const buffer_size) { - pop hl - push hl + pop de +;source-doc/base-drv/dev_transfers.c:55: + ex de, hl res 0, (hl) -;source-doc/base-drv/dev_transfers.c:53: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_IN]; +;source-doc/base-drv/dev_transfers.c:56: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_IN]; ld l,0x02 - jr l_usbdev_bulk_in_transfer_00104 +;source-doc/base-drv/dev_transfers.c:61: usbtrn_clear_endpoint_halt(endpoint->number, dev->address, dev->max_packet_size); l_usbdev_bulk_in_transfer_00102: -;source-doc/base-drv/dev_transfers.c:56: -;source-doc/base-drv/dev_transfers.c:58: usbtrn_clear_endpoint_halt(endpoint->number, dev->address, dev->max_packet_size); - ld hl, (_result) -l_usbdev_bulk_in_transfer_00104: -;source-doc/base-drv/dev_transfers.c:59: endpoint->toggle = 0; +;source-doc/base-drv/dev_transfers.c:62: endpoint->toggle = 0; ld sp, ix pop ix ret -;source-doc/base-drv/dev_transfers.c:61: } +;source-doc/base-drv/dev_transfers.c:64: } ; --------------------------------- ; Function usbdev_dat_in_trnsfer ; --------------------------------- @@ -284,43 +270,39 @@ _usbdev_dat_in_trnsfer: ld ix,0 add ix,sp push af - push af -;source-doc/base-drv/dev_transfers.c:66: } - ld e,(ix+4) - ld d,(ix+5) - ld c, e - ld b, d - inc bc - inc bc - inc bc +;source-doc/base-drv/dev_transfers.c:70: + ld c,(ix+4) + ld b,(ix+5) + ld e, c + ld d, b + inc de + inc de + inc de push de ld a,(ix+10) ld e, a add a, a add a, e pop de - add a, c - ld (ix-4),a + add a, e + ld e, a ld a,0x00 - adc a, b - ld (ix-3),a -;source-doc/base-drv/dev_transfers.c:68: usb_error usbdev_dat_in_trnsfer(device_config *const device, - ld (ix-2),e - ld (ix-1),d - pop bc + adc a, d + ld d, a +;source-doc/base-drv/dev_transfers.c:72: uint8_t *const buffer, pop hl + ld l,c + ld h,b ld a,(hl) push hl - push bc rlca rlca rlca rlca and 0x0f + push bc + push de push de - ld l,(ix-4) - ld h,(ix-3) - push hl push af inc sp ld l,(ix+8) @@ -335,55 +317,51 @@ _usbdev_dat_in_trnsfer: pop af inc sp pop de + pop bc +;source-doc/base-drv/dev_transfers.c:74: const usb_endpoint_type endpoint_type) { ld a, l - ld (_result), a -;source-doc/base-drv/dev_transfers.c:70: const uint16_t buffer_size, - ld hl,_result - ld a, (hl) sub 0x02 jr NZ,l_usbdev_dat_in_trnsfer_00102 -;source-doc/base-drv/dev_transfers.c:71: const usb_endpoint_type endpoint_type) { - ex de, hl - inc hl - ld d, (hl) - ld l,(ix-2) - ld h,(ix-1) - ld a, (hl) +;source-doc/base-drv/dev_transfers.c:75: usb_error result; + inc bc + ld a, (bc) + ld b, a + pop hl + ld a,(hl) + push hl rlca rlca rlca rlca and 0x0f - ld b, a - pop hl - ld a,(hl) - push hl + ld c, a + ld l, e + ld h, d + ld a, (hl) rrca and 0x07 - ld e,b push de - push af + push bc inc sp + ld h, c + ld l,a + push hl call _usbtrn_clear_endpoint_halt pop af inc sp -;source-doc/base-drv/dev_transfers.c:72: - pop hl - push hl + pop de +;source-doc/base-drv/dev_transfers.c:76: + ex de, hl res 0, (hl) -;source-doc/base-drv/dev_transfers.c:73: endpoint_param *const endpoint = &device->endpoints[endpoint_type]; +;source-doc/base-drv/dev_transfers.c:77: endpoint_param *const endpoint = &device->endpoints[endpoint_type]; ld l,0x02 - jr l_usbdev_dat_in_trnsfer_00104 +;source-doc/base-drv/dev_transfers.c:82: usbtrn_clear_endpoint_halt(endpoint->number, device->address, device->max_packet_size); l_usbdev_dat_in_trnsfer_00102: -;source-doc/base-drv/dev_transfers.c:76: -;source-doc/base-drv/dev_transfers.c:78: usbtrn_clear_endpoint_halt(endpoint->number, device->address, device->max_packet_size); - ld hl, (_result) -l_usbdev_dat_in_trnsfer_00104: -;source-doc/base-drv/dev_transfers.c:79: endpoint->toggle = 0; +;source-doc/base-drv/dev_transfers.c:83: endpoint->toggle = 0; ld sp, ix pop ix ret -;source-doc/base-drv/dev_transfers.c:81: } +;source-doc/base-drv/dev_transfers.c:85: } ; --------------------------------- ; Function usbdev_dat_in_trnsfer_0 ; --------------------------------- @@ -392,35 +370,33 @@ _usbdev_dat_in_trnsfer_0: ld ix,0 add ix,sp push af - push af -;source-doc/base-drv/dev_transfers.c:82: - ld e,(ix+4) - ld d,(ix+5) - ld hl,0x0003 - add hl, de - ex (sp), hl -;source-doc/base-drv/dev_transfers.c:84: done: - ld (ix-2),e - ld (ix-1),d - pop bc +;source-doc/base-drv/dev_transfers.c:88: done: + ld c,(ix+4) + ld b,(ix+5) + ld e, c + ld d, b + inc de + inc de + inc de +;source-doc/base-drv/dev_transfers.c:90: } pop hl + ld l,c + ld h,b ld a,(hl) push hl - push bc rlca rlca rlca rlca and 0x0f - ld c,(ix+8) - ld b,0x00 + ld l,(ix+8) + ld h,0x00 + push bc + push de push de - ld l,(ix-4) - ld h,(ix-3) - push hl push af inc sp - push bc + push hl ld l,(ix+6) ld h,(ix+7) push hl @@ -430,50 +406,47 @@ _usbdev_dat_in_trnsfer_0: pop af inc sp pop de + pop bc +;source-doc/base-drv/dev_transfers.c:92: usb_error usbdev_dat_in_trnsfer_0(device_config *const device, uint8_t *const buffer, const uint8_t buffer_size) { ld a, l - ld (_result), a -;source-doc/base-drv/dev_transfers.c:86: } - ld hl,_result - ld a, (hl) sub 0x02 jr NZ,l_usbdev_dat_in_trnsfer_0_00102 -;source-doc/base-drv/dev_transfers.c:87: - ex de, hl - inc hl - ld d, (hl) - ld l,(ix-2) - ld h,(ix-1) - ld a, (hl) +;source-doc/base-drv/dev_transfers.c:93: usb_error result; + inc bc + ld a, (bc) + ld b, a + pop hl + ld a,(hl) + push hl rlca rlca rlca rlca and 0x0f - ld b, a - pop hl - ld a,(hl) - push hl + ld c, a + ld l, e + ld h, d + ld a, (hl) rrca and 0x07 - ld e,b push de - push af + push bc inc sp + ld h, c + ld l,a + push hl call _usbtrn_clear_endpoint_halt pop af inc sp -;source-doc/base-drv/dev_transfers.c:88: usb_error usbdev_dat_in_trnsfer_0(device_config *const device, uint8_t *const buffer, const uint8_t buffer_size) { - pop hl - push hl + pop de +;source-doc/base-drv/dev_transfers.c:94: + ex de, hl res 0, (hl) -;source-doc/base-drv/dev_transfers.c:89: endpoint_param *const endpoint = &device->endpoints[0]; +;source-doc/base-drv/dev_transfers.c:95: endpoint_param *const endpoint = &device->endpoints[0]; ld l,0x02 - jr l_usbdev_dat_in_trnsfer_0_00103 +;source-doc/base-drv/dev_transfers.c:98: l_usbdev_dat_in_trnsfer_0_00102: -;source-doc/base-drv/dev_transfers.c:92: - ld hl, (_result) -l_usbdev_dat_in_trnsfer_0_00103: -;source-doc/base-drv/dev_transfers.c:93: if (result == USB_ERR_STALL) { +;source-doc/base-drv/dev_transfers.c:99: if (result == USB_ERR_STALL) { ld sp, ix pop ix ret diff --git a/Source/HBIOS/ch376-native/base-drv/protocol.c.s b/Source/HBIOS/ch376-native/base-drv/protocol.c.s index c22b7e5e..165c2f6e 100644 --- a/Source/HBIOS/ch376-native/base-drv/protocol.c.s +++ b/Source/HBIOS/ch376-native/base-drv/protocol.c.s @@ -59,18 +59,18 @@ _usbtrn_get_descriptor: ld hl, -8 add hl, sp ld sp, hl -;source-doc/base-drv/protocol.c:27: * @return usb_error USB_ERR_OK if all good, otherwise specific error code +;source-doc/base-drv/protocol.c:28: */ ld hl,0 add hl, sp ex de, hl ld bc,0x0008 ld hl,_cmd_get_device_descriptor ldir -;source-doc/base-drv/protocol.c:28: */ +;source-doc/base-drv/protocol.c:29: usb_error usbtrn_get_descriptor(device_descriptor *const buffer) { ld (ix-2),0x08 xor a ld (ix-1),a -;source-doc/base-drv/protocol.c:30: setup_packet cmd; +;source-doc/base-drv/protocol.c:31: setup_packet cmd; ld c,(ix+4) ld b,(ix+5) push bc @@ -91,15 +91,14 @@ _usbtrn_get_descriptor: pop af pop af pop af + ld a, l pop de pop bc - ld a, l - ld (_result), a -;source-doc/base-drv/protocol.c:32: cmd.wLength = 8; - ld a,(_result) + ld l, a +;source-doc/base-drv/protocol.c:33: cmd.wLength = 8; or a jr NZ,l_usbtrn_get_descriptor_00103 -;source-doc/base-drv/protocol.c:34: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, 8); +;source-doc/base-drv/protocol.c:35: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, 8); push de push bc ld hl,4 @@ -110,11 +109,11 @@ _usbtrn_get_descriptor: ldir pop bc pop de -;source-doc/base-drv/protocol.c:35: +;source-doc/base-drv/protocol.c:36: ld (ix-2),0x12 xor a ld (ix-1),a -;source-doc/base-drv/protocol.c:36: CHECK(result); +;source-doc/base-drv/protocol.c:37: CHECK(result); ld hl,7 add hl, bc ld a, (hl) @@ -131,14 +130,10 @@ _usbtrn_get_descriptor: pop af pop af pop af - ld a, l - ld (_result), a -;source-doc/base-drv/protocol.c:38: cmd = cmd_get_device_descriptor; -;source-doc/base-drv/protocol.c:40: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, buffer->bMaxPacketSize0); +;source-doc/base-drv/protocol.c:41: result = usb_control_transfer(&cmd, (uint8_t *)buffer, 0, buffer->bMaxPacketSize0); l_usbtrn_get_descriptor_00103: -;source-doc/base-drv/protocol.c:41: - ld hl, (_result) -;source-doc/base-drv/protocol.c:42: RETURN_CHECK(result); +;source-doc/base-drv/protocol.c:42: +;source-doc/base-drv/protocol.c:43: RETURN_CHECK(result); ld sp, ix pop ix ret @@ -150,7 +145,7 @@ _cmd_get_device_descriptor: DEFB +0x00 DEFB +0x00 DEFW +0x0008 -;source-doc/base-drv/protocol.c:46: } +;source-doc/base-drv/protocol.c:47: } ; --------------------------------- ; Function usbtrn_get_descriptor2 ; --------------------------------- @@ -161,18 +156,18 @@ _usbtrn_get_descriptor2: ld hl, -8 add hl, sp ld sp, hl -;source-doc/base-drv/protocol.c:48: /** +;source-doc/base-drv/protocol.c:51: * ld hl,0 add hl, sp ex de, hl ld bc,0x0008 ld hl,_cmd_get_device_descriptor ldir -;source-doc/base-drv/protocol.c:49: * @brief Issue GET_DESCRIPTOR request to retrieve the device descriptor for usb device at the specified address +;source-doc/base-drv/protocol.c:52: * @param buffer the buffer to store the device descriptor in ld (ix-2),0x08 xor a ld (ix-1),a -;source-doc/base-drv/protocol.c:51: * @param buffer the buffer to store the device descriptor in +;source-doc/base-drv/protocol.c:54: */ ld c,(ix+4) ld b,(ix+5) push bc @@ -190,15 +185,14 @@ _usbtrn_get_descriptor2: pop af pop af pop af + ld a, l pop de pop bc - ld a, l - ld (_result), a -;source-doc/base-drv/protocol.c:53: */ - ld a,(_result) + ld l, a +;source-doc/base-drv/protocol.c:56: usb_error result; or a jr NZ,l_usbtrn_get_descriptor2_00103 -;source-doc/base-drv/protocol.c:55: setup_packet cmd; +;source-doc/base-drv/protocol.c:58: setup_packet cmd; push de push bc ld hl,4 @@ -209,11 +203,11 @@ _usbtrn_get_descriptor2: ldir pop bc pop de -;source-doc/base-drv/protocol.c:56: cmd = cmd_get_device_descriptor; +;source-doc/base-drv/protocol.c:59: cmd = cmd_get_device_descriptor; ld (ix-2),0x12 xor a ld (ix-1),a -;source-doc/base-drv/protocol.c:57: cmd.wLength = 8; +;source-doc/base-drv/protocol.c:60: cmd.wLength = 8; ld hl,7 add hl, bc ld h,(hl) @@ -227,17 +221,14 @@ _usbtrn_get_descriptor2: pop af pop af pop af - ld a, l - ld (_result), a -;source-doc/base-drv/protocol.c:58: +;source-doc/base-drv/protocol.c:61: l_usbtrn_get_descriptor2_00103: -;source-doc/base-drv/protocol.c:59: result = usb_control_transfer(&cmd, (uint8_t *)buffer, device_address, 8); - ld hl, (_result) -;source-doc/base-drv/protocol.c:60: +;source-doc/base-drv/protocol.c:62: result = usb_control_transfer(&cmd, (uint8_t *)buffer, device_address, 8); +;source-doc/base-drv/protocol.c:63: ld sp, ix pop ix ret -;source-doc/base-drv/protocol.c:66: done: +;source-doc/base-drv/protocol.c:69: done: ; --------------------------------- ; Function usbtrn_set_address ; --------------------------------- @@ -250,7 +241,7 @@ _usbtrn_set_address: push af push af ld c, l -;source-doc/base-drv/protocol.c:68: } +;source-doc/base-drv/protocol.c:71: } push bc ld hl,2 add hl, sp @@ -259,9 +250,9 @@ _usbtrn_set_address: ld hl,_cmd_set_device_address ldir pop bc -;source-doc/base-drv/protocol.c:69: +;source-doc/base-drv/protocol.c:72: ld (ix-6),c -;source-doc/base-drv/protocol.c:71: +;source-doc/base-drv/protocol.c:74: xor a push af inc sp @@ -274,7 +265,7 @@ _usbtrn_set_address: add hl, sp push hl call _usb_control_transfer -;source-doc/base-drv/protocol.c:72: /** +;source-doc/base-drv/protocol.c:75: /** ld sp,ix pop ix ret @@ -286,7 +277,7 @@ _cmd_set_device_address: DEFB +0x00 DEFB +0x00 DEFW +0x0000 -;source-doc/base-drv/protocol.c:78: usb_error usbtrn_set_address(const uint8_t device_address) __z88dk_fastcall { +;source-doc/base-drv/protocol.c:81: usb_error usbtrn_set_address(const uint8_t device_address) __z88dk_fastcall { ; --------------------------------- ; Function usbtrn_set_configuration ; --------------------------------- @@ -297,7 +288,7 @@ _usbtrn_set_configuration: ld hl, -8 add hl, sp ld sp, hl -;source-doc/base-drv/protocol.c:80: cmd = cmd_set_device_address; +;source-doc/base-drv/protocol.c:83: cmd = cmd_set_device_address; ld hl,0 add hl, sp ld e,l @@ -307,10 +298,10 @@ _usbtrn_set_configuration: ld hl,_cmd_set_configuration ldir pop bc -;source-doc/base-drv/protocol.c:81: cmd.bValue[0] = device_address; +;source-doc/base-drv/protocol.c:84: cmd.bValue[0] = device_address; ld a,(ix+6) ld (ix-6),a -;source-doc/base-drv/protocol.c:83: return usb_control_transfer(&cmd, 0, 0, 0); +;source-doc/base-drv/protocol.c:86: return usb_control_transfer(&cmd, 0, 0, 0); ld h,(ix+5) ld l,(ix+4) push hl @@ -318,7 +309,7 @@ _usbtrn_set_configuration: push hl push bc call _usb_control_transfer -;source-doc/base-drv/protocol.c:84: } +;source-doc/base-drv/protocol.c:87: } ld sp,ix pop ix ret @@ -330,7 +321,7 @@ _cmd_set_configuration: DEFB +0x00 DEFB +0x00 DEFW +0x0000 -;source-doc/base-drv/protocol.c:90: * +;source-doc/base-drv/protocol.c:93: * ; --------------------------------- ; Function usbtrn_get_config_descriptor ; --------------------------------- @@ -341,7 +332,7 @@ _usbtrn_get_config_descriptor: ld hl, -8 add hl, sp ld sp, hl -;source-doc/base-drv/protocol.c:96: cmd = cmd_set_configuration; +;source-doc/base-drv/protocol.c:99: cmd = cmd_set_configuration; ld hl,0 add hl, sp ld e,l @@ -351,10 +342,10 @@ _usbtrn_get_config_descriptor: ld hl,_cmd_get_config_descriptor ldir pop bc -;source-doc/base-drv/protocol.c:97: cmd.bValue[0] = configuration; +;source-doc/base-drv/protocol.c:100: cmd.bValue[0] = configuration; ld a,(ix+6) ld (ix-6),a -;source-doc/base-drv/protocol.c:98: +;source-doc/base-drv/protocol.c:101: ld hl,0x0006 add hl, bc ld e,(ix+7) @@ -362,7 +353,7 @@ _usbtrn_get_config_descriptor: ld (hl), e inc hl ld (hl), a -;source-doc/base-drv/protocol.c:100: } +;source-doc/base-drv/protocol.c:103: } ld e,(ix+4) ld d,(ix+5) ld h,(ix+9) @@ -371,7 +362,7 @@ _usbtrn_get_config_descriptor: push de push bc call _usb_control_transfer -;source-doc/base-drv/protocol.c:101: +;source-doc/base-drv/protocol.c:104: ld sp,ix pop ix ret @@ -383,7 +374,7 @@ _cmd_get_config_descriptor: DEFB +0x00 DEFB +0x00 DEFW +0x0000 -;source-doc/base-drv/protocol.c:103: +;source-doc/base-drv/protocol.c:106: ; --------------------------------- ; Function usbtrn_gfull_cfg_desc ; --------------------------------- @@ -391,7 +382,7 @@ _usbtrn_gfull_cfg_desc: push ix ld ix,0 add ix,sp -;source-doc/base-drv/protocol.c:110: * @param device_address the usb address of the device +;source-doc/base-drv/protocol.c:114: * @param max_packet_size the max packet size for control transfers (endpoint 0) ld c,(ix+8) ld b,(ix+9) push bc @@ -411,24 +402,22 @@ _usbtrn_gfull_cfg_desc: pop af pop bc ld a, l - ld (_result), a - ld a,(_result) or a jr NZ,l_usbtrn_gfull_cfg_desc_00107 -;source-doc/base-drv/protocol.c:112: * @return usb_error USB_ERR_OK if all good, otherwise specific error code +;source-doc/base-drv/protocol.c:116: */ ld l,(ix+8) ld h,(ix+9) inc hl inc hl ld d, (hl) -;source-doc/base-drv/protocol.c:113: */ +;source-doc/base-drv/protocol.c:117: usb_error usbtrn_get_config_descriptor(config_descriptor *const buffer, ld a,(ix+7) sub d jr NC,l_usbtrn_gfull_cfg_desc_00104 -;source-doc/base-drv/protocol.c:114: usb_error usbtrn_get_config_descriptor(config_descriptor *const buffer, +;source-doc/base-drv/protocol.c:118: const uint8_t config_index, ld d,(ix+7) l_usbtrn_gfull_cfg_desc_00104: -;source-doc/base-drv/protocol.c:116: const uint8_t buffer_size, +;source-doc/base-drv/protocol.c:120: const uint8_t device_address, ld h,(ix+6) ld l,(ix+5) push hl @@ -440,22 +429,17 @@ l_usbtrn_gfull_cfg_desc_00104: pop af pop af ld a, l - ld (_result), a - ld a,(_result) -;source-doc/base-drv/protocol.c:118: const uint8_t max_packet_size) { +;source-doc/base-drv/protocol.c:122: setup_packet cmd; or a jr NZ,l_usbtrn_gfull_cfg_desc_00107 ld l,a - jr l_usbtrn_gfull_cfg_desc_00108 -;source-doc/base-drv/protocol.c:119: setup_packet cmd; +;source-doc/base-drv/protocol.c:123: cmd = cmd_get_config_descriptor; +;source-doc/base-drv/protocol.c:124: cmd.bValue[0] = config_index; l_usbtrn_gfull_cfg_desc_00107: -;source-doc/base-drv/protocol.c:120: cmd = cmd_get_config_descriptor; - ld hl, (_result) -l_usbtrn_gfull_cfg_desc_00108: -;source-doc/base-drv/protocol.c:121: cmd.bValue[0] = config_index; +;source-doc/base-drv/protocol.c:125: cmd.wLength = (uint16_t)buffer_size; pop ix ret -;source-doc/base-drv/protocol.c:125: } +;source-doc/base-drv/protocol.c:129: ; --------------------------------- ; Function usbtrn_clear_endpoint_halt ; --------------------------------- @@ -466,7 +450,7 @@ _usbtrn_clear_endpoint_halt: ld hl, -8 add hl, sp ld sp, hl -;source-doc/base-drv/protocol.c:127: usb_error usbtrn_gfull_cfg_desc(const uint8_t config_index, +;source-doc/base-drv/protocol.c:131: const uint8_t device_address, ld hl,0 add hl, sp ld e,l @@ -476,10 +460,10 @@ _usbtrn_clear_endpoint_halt: ld hl,_usb_cmd_clear_endpoint_halt ldir pop bc -;source-doc/base-drv/protocol.c:128: const uint8_t device_address, +;source-doc/base-drv/protocol.c:132: const uint8_t max_packet_size, ld a,(ix+4) ld (ix-4),a -;source-doc/base-drv/protocol.c:130: const uint8_t max_buffer_size, +;source-doc/base-drv/protocol.c:134: uint8_t *const buffer) { ld h,(ix+6) ld l,(ix+5) push hl @@ -487,7 +471,7 @@ _usbtrn_clear_endpoint_halt: push hl push bc call _usb_control_transfer -;source-doc/base-drv/protocol.c:131: uint8_t *const buffer) { +;source-doc/base-drv/protocol.c:135: usb_error result; 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 5a11aaa5..0289e39b 100644 --- a/Source/HBIOS/ch376-native/base-drv/transfers.c.s +++ b/Source/HBIOS/ch376-native/base-drv/transfers.c.s @@ -218,12 +218,12 @@ _usb_data_in_transfer: push ix ld ix,0 add ix,sp -;source-doc/base-drv/transfers.c:80: critical_end(); +;source-doc/base-drv/transfers.c:81: return result; call _critical_begin -;source-doc/base-drv/transfers.c:82: } +;source-doc/base-drv/transfers.c:83: ld l,(ix+8) call _ch_set_usb_address -;source-doc/base-drv/transfers.c:84: /** +;source-doc/base-drv/transfers.c:85: * @brief Perform a USB data in on the specified endpoint ld l,(ix+9) ld h,(ix+10) push hl @@ -236,17 +236,15 @@ _usb_data_in_transfer: call _ch_data_in_transfer pop af pop af - pop af - ld a, l - ld (_result), a -;source-doc/base-drv/transfers.c:86: * +;source-doc/base-drv/transfers.c:87: * @param buffer the buffer to receive the data + ex (sp),hl call _critical_end -;source-doc/base-drv/transfers.c:88: * @param buffer_size the maximum size of data to be received - ld hl, (_result) + pop hl ;source-doc/base-drv/transfers.c:89: * @param device_address the usb address of the device +;source-doc/base-drv/transfers.c:90: * @param endpoint the usb endpoint to receive from (toggle of endpoint is updated) pop ix ret -;source-doc/base-drv/transfers.c:94: 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:95: usb_error result; ; --------------------------------- ; Function usb_data_in_transfer_n ; --------------------------------- @@ -254,12 +252,12 @@ _usb_data_in_transfer_n: push ix ld ix,0 add ix,sp -;source-doc/base-drv/transfers.c:95: critical_begin(); +;source-doc/base-drv/transfers.c:98: ch_set_usb_address(device_address); call _critical_begin -;source-doc/base-drv/transfers.c:97: ch_set_usb_address(device_address); +;source-doc/base-drv/transfers.c:100: result = ch_data_in_transfer(buffer, buffer_size, endpoint); ld l,(ix+8) call _ch_set_usb_address -;source-doc/base-drv/transfers.c:99: result = ch_data_in_transfer(buffer, buffer_size, endpoint); +;source-doc/base-drv/transfers.c:102: critical_end(); ld l,(ix+9) ld h,(ix+10) push hl @@ -272,17 +270,15 @@ _usb_data_in_transfer_n: call _ch_data_in_transfer_n pop af pop af - pop af - ld a, l - ld (_result), a -;source-doc/base-drv/transfers.c:101: critical_end(); +;source-doc/base-drv/transfers.c:104: return result; + ex (sp),hl call _critical_end -;source-doc/base-drv/transfers.c:103: return result; - ld hl, (_result) -;source-doc/base-drv/transfers.c:104: } + pop hl +;source-doc/base-drv/transfers.c:106: +;source-doc/base-drv/transfers.c:107: /** pop ix ret -;source-doc/base-drv/transfers.c:109: * @param buffer the buffer to receive the data - must be 62 bytes +;source-doc/base-drv/transfers.c:112: * @param device_address the usb address of the device ; --------------------------------- ; Function usb_data_out_transfer ; --------------------------------- @@ -290,12 +286,12 @@ _usb_data_out_transfer: push ix ld ix,0 add ix,sp -;source-doc/base-drv/transfers.c:110: * @param buffer_size on exit the actual size of data received +;source-doc/base-drv/transfers.c:114: * @return usb_error USB_ERR_OK if all good, otherwise specific error code call _critical_begin -;source-doc/base-drv/transfers.c:112: * @param endpoint the usb endpoint to receive from (toggle of endpoint is updated) +;source-doc/base-drv/transfers.c:116: usb_error ld l,(ix+8) call _ch_set_usb_address -;source-doc/base-drv/transfers.c:114: */ +;source-doc/base-drv/transfers.c:118: usb_error result; ld l,(ix+9) ld h,(ix+10) push hl @@ -308,13 +304,11 @@ _usb_data_out_transfer: call _ch_data_out_transfer pop af pop af - pop af - ld a, l - ld (_result), a -;source-doc/base-drv/transfers.c:116: 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:120: critical_begin(); + ex (sp),hl call _critical_end -;source-doc/base-drv/transfers.c:118: - ld hl, (_result) -;source-doc/base-drv/transfers.c:119: ch_set_usb_address(device_address); + pop hl +;source-doc/base-drv/transfers.c:122: ch_set_usb_address(device_address); +;source-doc/base-drv/transfers.c:123: 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 d343f3af..81697938 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 @@ -68,14 +68,14 @@ _usb_host_bus_reset: call _ch_cmd_set_usb_mode ;source-doc/base-drv/usb-base-drv.c:15: delay_20ms(); call _delay_20ms -;source-doc/base-drv/ch376.h:111: +;source-doc/base-drv/ch376.h:108: #define TRACE_USB_ERROR(result) ld l,0x0b call _ch_command -;source-doc/base-drv/ch376.h:112: #endif +;source-doc/base-drv/ch376.h:109: ld a,0x25 ld bc,_CH376_DATA_PORT out (c), a -;source-doc/base-drv/ch376.h:113: +;source-doc/base-drv/ch376.h:110: #endif ld a,0xdf ld bc,_CH376_DATA_PORT out (c), a diff --git a/Source/HBIOS/ch376-native/keyboard/kyb_driver.c.s b/Source/HBIOS/ch376-native/keyboard/kyb_driver.c.s index 964dbaeb..26988280 100644 --- a/Source/HBIOS/ch376-native/keyboard/kyb_driver.c.s +++ b/Source/HBIOS/ch376-native/keyboard/kyb_driver.c.s @@ -273,24 +273,24 @@ l_usb_kyb_flush_00101: ; Function usb_kyb_tick ; --------------------------------- _usb_kyb_tick: -;source-doc/keyboard/kyb_driver.c:107: +;source-doc/keyboard/kyb_driver.c:109: usb_error result; ld hl,_in_critical_usb_section ld a, (hl) or a -;source-doc/keyboard/kyb_driver.c:108: void usb_kyb_tick(void) { +;source-doc/keyboard/kyb_driver.c:110: jr NZ,l_usb_kyb_tick_00112 -;././source-doc/base-drv//ch376.h:111: +;././source-doc/base-drv//ch376.h:108: #define TRACE_USB_ERROR(result) ld l,0x0b call _ch_command -;././source-doc/base-drv//ch376.h:112: #endif +;././source-doc/base-drv//ch376.h:109: ld a,0x25 ld bc,_CH376_DATA_PORT out (c), a -;././source-doc/base-drv//ch376.h:113: +;././source-doc/base-drv//ch376.h:110: #endif ld a,0x1f ld bc,_CH376_DATA_PORT out (c), a -;source-doc/keyboard/kyb_driver.c:111: +;source-doc/keyboard/kyb_driver.c:113: ld bc,_report+0 ld hl, (_keyboard_config) ld a,0x08 @@ -302,74 +302,75 @@ _usb_kyb_tick: pop af pop af inc sp - ld a, l - ld (_result), a +;././source-doc/base-drv//ch376.h:108: #define TRACE_USB_ERROR(result) + push hl ld l,0x0b call _ch_command -;././source-doc/base-drv//ch376.h:112: #endif + pop hl +;././source-doc/base-drv//ch376.h:109: ld a,0x25 ld bc,_CH376_DATA_PORT out (c), a -;././source-doc/base-drv//ch376.h:113: +;././source-doc/base-drv//ch376.h:110: #endif ld a,0xdf ld bc,_CH376_DATA_PORT out (c), a - ld hl,_result - ld a, (hl) +;source-doc/keyboard/kyb_driver.c:115: result = usbdev_dat_in_trnsfer_0((device_config *)keyboard_config, (uint8_t *)&report, 8); + ld a, l or a jr NZ,l_usb_kyb_tick_00112 -;source-doc/keyboard/kyb_driver.c:114: ch_configure_nak_retry_3s(); +;source-doc/keyboard/kyb_driver.c:116: ch_configure_nak_retry_3s(); call _report_diff or a jr Z,l_usb_kyb_tick_00112 -;source-doc/keyboard/kyb_driver.c:116: if (report_diff()) { +;source-doc/keyboard/kyb_driver.c:118: if (report_diff()) { ld b,0x06 l_usb_kyb_tick_00103: -;source-doc/keyboard/kyb_driver.c:117: uint8_t i = 6; +;source-doc/keyboard/kyb_driver.c:119: uint8_t i = 6; ld a, b dec a push bc call _keyboard_buf_put pop bc -;source-doc/keyboard/kyb_driver.c:118: do { +;source-doc/keyboard/kyb_driver.c:120: do { djnz l_usb_kyb_tick_00103 -;source-doc/keyboard/kyb_driver.c:119: keyboard_buf_put(i - 1); +;source-doc/keyboard/kyb_driver.c:121: keyboard_buf_put(i - 1); ld de,_previous ld bc,0x0008 ld hl,_report ldir l_usb_kyb_tick_00112: -;source-doc/keyboard/kyb_driver.c:122: } - ret ;source-doc/keyboard/kyb_driver.c:124: } + ret +;source-doc/keyboard/kyb_driver.c:126: } ; --------------------------------- ; Function usb_kyb_init ; --------------------------------- _usb_kyb_init: -;source-doc/keyboard/kyb_driver.c:125: +;source-doc/keyboard/kyb_driver.c:127: call _get_usb_device_config ex de, hl ld (_keyboard_config), hl -;source-doc/keyboard/kyb_driver.c:127: keyboard_config = (device_config_keyboard *)get_usb_device_config(dev_index); +;source-doc/keyboard/kyb_driver.c:129: keyboard_config = (device_config_keyboard *)get_usb_device_config(dev_index); ld hl,_keyboard_config + 1 ld a, (hl) dec hl or (hl) -;source-doc/keyboard/kyb_driver.c:128: +;source-doc/keyboard/kyb_driver.c:130: ret Z -;source-doc/keyboard/kyb_driver.c:130: return; +;source-doc/keyboard/kyb_driver.c:132: return; ld a,0x01 push af inc sp ld hl, (_keyboard_config) call _hid_set_protocol -;source-doc/keyboard/kyb_driver.c:131: +;source-doc/keyboard/kyb_driver.c:133: ld a,0x80 push af inc sp ld hl, (_keyboard_config) call _hid_set_idle -;source-doc/keyboard/kyb_driver.c:132: hid_set_protocol(keyboard_config, 1); +;source-doc/keyboard/kyb_driver.c:134: hid_set_protocol(keyboard_config, 1); ret _caps_lock_engaged: DEFB +0x01 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 3c142a8a..31d4623d 100644 --- a/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s +++ b/Source/HBIOS/ch376-native/scsi-drv/class_scsi.c.s @@ -67,7 +67,7 @@ _do_scsi_cmd: ld hl, -8 add hl, sp ld sp, hl -;source-doc/scsi-drv/class_scsi.c:18: cbw->dCBWTag[0] = next_tag++; +;source-doc/scsi-drv/class_scsi.c:20: cbw->dCBWTag[0] = next_tag++; ld c,(ix+6) ld b,(ix+7) ld hl,0x0004 @@ -85,19 +85,19 @@ _do_scsi_cmd: ld (hl), e inc hl ld (hl), d -;source-doc/scsi-drv/class_scsi.c:20: if (!send) +;source-doc/scsi-drv/class_scsi.c:22: if (!send) bit 0,(ix+10) jr NZ,l_do_scsi_cmd_00102 -;source-doc/scsi-drv/class_scsi.c:21: cbw->bmCBWFlags = 0x80; +;source-doc/scsi-drv/class_scsi.c:23: cbw->bmCBWFlags = 0x80; ld hl,0x000c add hl, bc ld (hl),0x80 l_do_scsi_cmd_00102: -;source-doc/scsi-drv/class_scsi.c:23: critical_begin(); +;source-doc/scsi-drv/class_scsi.c:25: critical_begin(); push bc call _critical_begin pop bc -;source-doc/scsi-drv/class_scsi.c:26: &dev->endpoints[ENDPOINT_BULK_OUT])); +;source-doc/scsi-drv/class_scsi.c:28: &dev->endpoints[ENDPOINT_BULK_OUT])); ld a,(ix+4) ld (ix-6),a ld e, a @@ -138,11 +138,9 @@ l_do_scsi_cmd_00102: pop de pop bc ld a, l - ld (_result), a - ld a,(_result) or a jp NZ, l_do_scsi_cmd_00120 -;source-doc/scsi-drv/class_scsi.c:28: if (cbw->dCBWDataTransferLength != 0) { +;source-doc/scsi-drv/class_scsi.c:30: if (cbw->dCBWDataTransferLength != 0) { ld hl,8 add hl, bc ld c, (hl) @@ -157,15 +155,15 @@ l_do_scsi_cmd_00102: or b or c jr Z,l_do_scsi_cmd_00113 -;source-doc/scsi-drv/class_scsi.c:31: &dev->endpoints[ENDPOINT_BULK_IN])); - ld a,(ix+8) - ld (ix-2),a - ld a,(ix+9) - ld (ix-1),a -;source-doc/scsi-drv/class_scsi.c:29: if (!send) { +;source-doc/scsi-drv/class_scsi.c:33: &dev->endpoints[ENDPOINT_BULK_IN])); + ld (ix-2),c + ld (ix-1),b + ld c,(ix+8) + ld b,(ix+9) +;source-doc/scsi-drv/class_scsi.c:31: if (!send) { bit 0,(ix+10) jr NZ,l_do_scsi_cmd_00110 -;source-doc/scsi-drv/class_scsi.c:31: &dev->endpoints[ENDPOINT_BULK_IN])); +;source-doc/scsi-drv/class_scsi.c:33: &dev->endpoints[ENDPOINT_BULK_IN])); ld a,(ix-6) add a,0x06 ld e, a @@ -183,23 +181,21 @@ l_do_scsi_cmd_00102: push de push af inc sp - push bc ld l,(ix-2) ld h,(ix-1) push hl + push bc call _usb_data_in_transfer pop af pop af pop af inc sp ld a, l - ld (_result), a - ld a,(_result) or a jr Z,l_do_scsi_cmd_00113 - jp l_do_scsi_cmd_00120 + jr l_do_scsi_cmd_00120 l_do_scsi_cmd_00110: -;source-doc/scsi-drv/class_scsi.c:35: &dev->endpoints[ENDPOINT_BULK_OUT])); +;source-doc/scsi-drv/class_scsi.c:37: &dev->endpoints[ENDPOINT_BULK_OUT])); ld l,(ix-4) ld h,(ix-3) ld a, (hl) @@ -211,28 +207,26 @@ l_do_scsi_cmd_00110: push de push af inc sp - push bc ld l,(ix-2) ld h,(ix-1) push hl + push bc call _usb_data_out_transfer pop af pop af pop af inc sp ld a, l - ld (_result), a - ld a,(_result) or a jr NZ,l_do_scsi_cmd_00120 l_do_scsi_cmd_00113: -;source-doc/scsi-drv/class_scsi.c:40: usb_data_in_transfer((uint8_t *)&csw, sizeof(_scsi_command_status_wrapper), dev->address, &dev->endpoints[ENDPOINT_BULK_IN])); +;source-doc/scsi-drv/class_scsi.c:42: usb_data_in_transfer((uint8_t *)&csw, sizeof(_scsi_command_status_wrapper), dev->address, &dev->endpoints[ENDPOINT_BULK_IN])); ld a,(ix-6) add a,0x06 - ld e, a + ld c, a ld a,(ix-5) adc a,0x00 - ld d, a + ld b, a ld l,(ix-4) ld h,(ix-3) ld a, (hl) @@ -241,9 +235,9 @@ l_do_scsi_cmd_00113: rlca rlca and 0x0f - ld b, a - push de + ld d, a push bc + push de inc sp ld hl,0x000d push hl @@ -255,11 +249,9 @@ l_do_scsi_cmd_00113: pop af inc sp ld a, l - ld (_result), a - ld a,(_result) or a jr NZ,l_do_scsi_cmd_00120 -;source-doc/scsi-drv/class_scsi.c:42: if (csw.bCSWStatus != 0 && csw.dCSWTag[0] != cbw->dCBWTag[0]) +;source-doc/scsi-drv/class_scsi.c:44: if (csw.bCSWStatus != 0 && csw.dCSWTag[0] != cbw->dCBWTag[0]) ld a, (_csw + 12) or a jr Z,l_do_scsi_cmd_00117 @@ -273,25 +265,24 @@ l_do_scsi_cmd_00113: xor a sbc hl,bc jr Z,l_do_scsi_cmd_00117 -;source-doc/scsi-drv/class_scsi.c:43: result = USB_ERR_FAIL; - ld hl,_result - ld (hl),0x0e +;source-doc/scsi-drv/class_scsi.c:45: result = USB_ERR_FAIL; + ld l,0x0e jr l_do_scsi_cmd_00120 l_do_scsi_cmd_00117: -;source-doc/scsi-drv/class_scsi.c:45: result = USB_ERR_OK; - xor a - ld (_result),a -;source-doc/scsi-drv/class_scsi.c:47: done: +;source-doc/scsi-drv/class_scsi.c:47: result = USB_ERR_OK; + ld l,0x00 +;source-doc/scsi-drv/class_scsi.c:49: done: l_do_scsi_cmd_00120: -;source-doc/scsi-drv/class_scsi.c:48: critical_end(); +;source-doc/scsi-drv/class_scsi.c:50: critical_end(); + push hl call _critical_end -;source-doc/scsi-drv/class_scsi.c:49: return result; - ld hl, (_result) -;source-doc/scsi-drv/class_scsi.c:50: } + pop hl +;source-doc/scsi-drv/class_scsi.c:51: return result; +;source-doc/scsi-drv/class_scsi.c:52: } ld sp, ix pop ix ret -;source-doc/scsi-drv/class_scsi.c:52: usb_error scsi_test(device_config_storage *const dev) { +;source-doc/scsi-drv/class_scsi.c:54: usb_error scsi_test(device_config_storage *const dev) { ; --------------------------------- ; Function scsi_test ; --------------------------------- @@ -302,7 +293,7 @@ _scsi_test: ld hl, -27 add hl, sp ld sp, hl -;source-doc/scsi-drv/class_scsi.c:54: cbw_scsi.cbw = scsi_command_block_wrapper; +;source-doc/scsi-drv/class_scsi.c:56: cbw_scsi.cbw = scsi_command_block_wrapper; ld hl,0 add hl, sp ld e,l @@ -311,7 +302,7 @@ _scsi_test: ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir -;source-doc/scsi-drv/class_scsi.c:55: memset(&cbw_scsi.test, 0, sizeof(_scsi_packet_test)); +;source-doc/scsi-drv/class_scsi.c:57: memset(&cbw_scsi.test, 0, sizeof(_scsi_packet_test)); ld hl,17 add hl, sp ld b,0x06 @@ -323,11 +314,11 @@ l_scsi_test_00103: inc hl djnz l_scsi_test_00103 pop bc -;source-doc/scsi-drv/class_scsi.c:57: cbw_scsi.cbw.bCBWLUN = 0; +;source-doc/scsi-drv/class_scsi.c:59: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 -;source-doc/scsi-drv/class_scsi.c:58: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_test); +;source-doc/scsi-drv/class_scsi.c:60: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_test); ld (ix-13),0x0c -;source-doc/scsi-drv/class_scsi.c:59: cbw_scsi.cbw.dCBWDataTransferLength = 0; +;source-doc/scsi-drv/class_scsi.c:61: cbw_scsi.cbw.dCBWDataTransferLength = 0; ld hl,0x0008 add hl, bc xor a @@ -338,7 +329,7 @@ l_scsi_test_00103: ld (hl), a inc hl ld (hl), a -;source-doc/scsi-drv/class_scsi.c:61: return do_scsi_cmd(dev, &cbw_scsi.cbw, 0, false); +;source-doc/scsi-drv/class_scsi.c:63: return do_scsi_cmd(dev, &cbw_scsi.cbw, 0, false); xor a push af inc sp @@ -349,11 +340,11 @@ l_scsi_test_00103: ld h,(ix+5) push hl call _do_scsi_cmd -;source-doc/scsi-drv/class_scsi.c:62: } +;source-doc/scsi-drv/class_scsi.c:64: } ld sp,ix pop ix ret -;source-doc/scsi-drv/class_scsi.c:66: usb_error scsi_request_sense(device_config_storage *const dev, scsi_sense_result *const sens_result) { +;source-doc/scsi-drv/class_scsi.c:68: usb_error scsi_request_sense(device_config_storage *const dev, scsi_sense_result *const sens_result) { ; --------------------------------- ; Function scsi_request_sense ; --------------------------------- @@ -364,7 +355,7 @@ _scsi_request_sense: ld hl, -27 add hl, sp ld sp, hl -;source-doc/scsi-drv/class_scsi.c:68: cbw_scsi.cbw = scsi_command_block_wrapper; +;source-doc/scsi-drv/class_scsi.c:70: cbw_scsi.cbw = scsi_command_block_wrapper; ld hl,0 add hl, sp ld e,l @@ -373,7 +364,7 @@ _scsi_request_sense: ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir -;source-doc/scsi-drv/class_scsi.c:69: cbw_scsi.request_sense = scsi_packet_request_sense; +;source-doc/scsi-drv/class_scsi.c:71: cbw_scsi.request_sense = scsi_packet_request_sense; ld hl,17 add hl, sp ex de, hl @@ -381,11 +372,11 @@ _scsi_request_sense: ld hl,_scsi_packet_request_sense ldir pop bc -;source-doc/scsi-drv/class_scsi.c:71: cbw_scsi.cbw.bCBWLUN = 0; +;source-doc/scsi-drv/class_scsi.c:73: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 -;source-doc/scsi-drv/class_scsi.c:72: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_request_sense); +;source-doc/scsi-drv/class_scsi.c:74: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_request_sense); ld (ix-13),0x0c -;source-doc/scsi-drv/class_scsi.c:73: cbw_scsi.cbw.dCBWDataTransferLength = sizeof(scsi_sense_result); +;source-doc/scsi-drv/class_scsi.c:75: cbw_scsi.cbw.dCBWDataTransferLength = sizeof(scsi_sense_result); ld hl,0x0008 add hl, bc ld (hl),0x12 @@ -396,7 +387,7 @@ _scsi_request_sense: ld (hl), a inc hl ld (hl), a -;source-doc/scsi-drv/class_scsi.c:75: return do_scsi_cmd(dev, &cbw_scsi.cbw, sens_result, false); +;source-doc/scsi-drv/class_scsi.c:77: return do_scsi_cmd(dev, &cbw_scsi.cbw, sens_result, false); ld e,(ix+6) ld d,(ix+7) xor a @@ -408,7 +399,7 @@ _scsi_request_sense: ld h,(ix+5) push hl call _do_scsi_cmd -;source-doc/scsi-drv/class_scsi.c:76: } +;source-doc/scsi-drv/class_scsi.c:78: } ld sp,ix pop ix ret diff --git a/Source/HBIOS/ch376-native/scsi-drv/scsi_driver.c.s b/Source/HBIOS/ch376-native/scsi-drv/scsi_driver.c.s index cf87d6aa..47527495 100644 --- a/Source/HBIOS/ch376-native/scsi-drv/scsi_driver.c.s +++ b/Source/HBIOS/ch376-native/scsi-drv/scsi_driver.c.s @@ -63,14 +63,14 @@ _usb_scsi_init: ld hl, -18 add hl, sp ld sp, hl -;source-doc/scsi-drv/scsi_driver.c:9: device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); +;source-doc/scsi-drv/scsi_driver.c:11: device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); ld a,(ix+4) call _get_usb_device_config -;source-doc/scsi-drv/scsi_driver.c:14: critical_begin(); +;source-doc/scsi-drv/scsi_driver.c:16: critical_begin(); push de call _critical_begin pop de -;source-doc/scsi-drv/scsi_driver.c:15: while ((result = scsi_test(dev)) && --counter > 0) +;source-doc/scsi-drv/scsi_driver.c:17: while ((result = scsi_test(dev)) && --counter > 0) ld c,0x03 l_usb_scsi_init_00102: push bc @@ -81,16 +81,16 @@ l_usb_scsi_init_00102: ld a, l pop de pop bc - ld (_result),a + ld l, a or a jr Z,l_usb_scsi_init_00104 dec c jr Z,l_usb_scsi_init_00104 -;source-doc/scsi-drv/scsi_driver.c:16: scsi_request_sense(dev, &response); - ld hl,0 - add hl, sp +;source-doc/scsi-drv/scsi_driver.c:18: scsi_request_sense(dev, &response); push bc push de + ld hl,4 + add hl, sp push hl push de call _scsi_request_sense @@ -100,15 +100,16 @@ l_usb_scsi_init_00102: pop bc jr l_usb_scsi_init_00102 l_usb_scsi_init_00104: -;source-doc/scsi-drv/scsi_driver.c:17: critical_end(); +;source-doc/scsi-drv/scsi_driver.c:19: critical_end(); + push hl call _critical_end -;source-doc/scsi-drv/scsi_driver.c:19: return result; - ld hl, (_result) -;source-doc/scsi-drv/scsi_driver.c:20: } + pop hl +;source-doc/scsi-drv/scsi_driver.c:21: return result; +;source-doc/scsi-drv/scsi_driver.c:22: } ld sp, ix pop ix ret -;source-doc/scsi-drv/scsi_driver.c:24: usb_error usb_scsi_read_capacity(const uint16_t dev_index, scsi_read_capacity_result *cap_result) { +;source-doc/scsi-drv/scsi_driver.c:26: usb_error usb_scsi_read_capacity(const uint16_t dev_index, scsi_read_capacity_result *cap_result) { ; --------------------------------- ; Function usb_scsi_read_capacity ; --------------------------------- @@ -119,10 +120,10 @@ _usb_scsi_read_capacity: ld hl, -27 add hl, sp ld sp, hl -;source-doc/scsi-drv/scsi_driver.c:25: device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); +;source-doc/scsi-drv/scsi_driver.c:27: device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); ld a,(ix+4) call _get_usb_device_config -;source-doc/scsi-drv/scsi_driver.c:28: cbw_scsi.cbw = scsi_command_block_wrapper; +;source-doc/scsi-drv/scsi_driver.c:30: cbw_scsi.cbw = scsi_command_block_wrapper; push de ld hl,2 add hl, sp @@ -131,7 +132,7 @@ _usb_scsi_read_capacity: ld hl,_scsi_command_block_wrapper ldir pop de -;source-doc/scsi-drv/scsi_driver.c:29: cbw_scsi.read_capacity = scsi_packet_read_capacity; +;source-doc/scsi-drv/scsi_driver.c:31: cbw_scsi.read_capacity = scsi_packet_read_capacity; push de ld hl,17 add hl, sp @@ -140,17 +141,17 @@ _usb_scsi_read_capacity: ld hl,_scsi_packet_read_capacity ldir pop de -;source-doc/scsi-drv/scsi_driver.c:31: cbw_scsi.cbw.bCBWLUN = 0; +;source-doc/scsi-drv/scsi_driver.c:33: cbw_scsi.cbw.bCBWLUN = 0; ld (ix-14),0x00 -;source-doc/scsi-drv/scsi_driver.c:32: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_read_capacity); +;source-doc/scsi-drv/scsi_driver.c:34: cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_read_capacity); ld (ix-13),0x0c -;source-doc/scsi-drv/scsi_driver.c:33: cbw_scsi.cbw.dCBWDataTransferLength = sizeof(scsi_read_capacity_result); +;source-doc/scsi-drv/scsi_driver.c:35: cbw_scsi.cbw.dCBWDataTransferLength = sizeof(scsi_read_capacity_result); ld (ix-19),0x08 xor a ld (ix-18),a ld (ix-17),a ld (ix-16),a -;source-doc/scsi-drv/scsi_driver.c:35: return do_scsi_cmd(dev, &cbw_scsi.cbw, cap_result, false); +;source-doc/scsi-drv/scsi_driver.c:37: return do_scsi_cmd(dev, &cbw_scsi.cbw, cap_result, false); ld c,(ix+6) ld b,(ix+7) xor a @@ -166,11 +167,11 @@ _usb_scsi_read_capacity: pop af pop af inc sp -;source-doc/scsi-drv/scsi_driver.c:36: } +;source-doc/scsi-drv/scsi_driver.c:38: } ld sp, ix pop ix ret -;source-doc/scsi-drv/scsi_driver.c:56: usb_error usb_scsi_read(const uint16_t dev_index, uint8_t *const buffer) { +;source-doc/scsi-drv/scsi_driver.c:58: usb_error usb_scsi_read(const uint16_t dev_index, uint8_t *const buffer) { ; --------------------------------- ; Function usb_scsi_read ; --------------------------------- @@ -179,12 +180,12 @@ _usb_scsi_read: ld ix,0 add ix,sp push af -;source-doc/scsi-drv/scsi_driver.c:57: device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); +;source-doc/scsi-drv/scsi_driver.c:61: device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); ld a,(ix+4) call _get_usb_device_config pop bc push de -;source-doc/scsi-drv/scsi_driver.c:59: memset(&cbw, 0, sizeof(cbw_scsi_read_write)); +;source-doc/scsi-drv/scsi_driver.c:63: memset(&cbw, 0, sizeof(cbw_scsi_read_write)); ld de,_cbw ld l, e ld h, d @@ -197,116 +198,111 @@ l_usb_scsi_read_00113: ld (hl),0x00 inc hl djnz l_usb_scsi_read_00112 -;source-doc/scsi-drv/scsi_driver.c:60: cbw.cbw = scsi_command_block_wrapper; +;source-doc/scsi-drv/scsi_driver.c:64: cbw.cbw = scsi_command_block_wrapper; ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir -;source-doc/scsi-drv/scsi_driver.c:62: cbw.cbw.bCBWLUN = 0; +;source-doc/scsi-drv/scsi_driver.c:66: cbw.cbw.bCBWLUN = 0; ld hl,_cbw + 13 ld (hl),0x00 -;source-doc/scsi-drv/scsi_driver.c:63: cbw.cbw.bCBWCBLength = sizeof(_scsi_packet_read_write); +;source-doc/scsi-drv/scsi_driver.c:67: cbw.cbw.bCBWCBLength = sizeof(_scsi_packet_read_write); ld hl,_cbw + 14 ld (hl),0x0c -;source-doc/scsi-drv/scsi_driver.c:64: cbw.cbw.dCBWDataTransferLength = 512; +;source-doc/scsi-drv/scsi_driver.c:68: cbw.cbw.dCBWDataTransferLength = 512; ld hl,0x0200 ld (_cbw + 8),hl ld h, l ld (_cbw + 8 + 2),hl -;source-doc/scsi-drv/scsi_driver.c:66: cbw.scsi_cmd.operation_code = 0x28; // read operation +;source-doc/scsi-drv/scsi_driver.c:70: cbw.scsi_cmd.operation_code = 0x28; // read operation ld hl,_cbw + 15 ld (hl),0x28 -;source-doc/scsi-drv/scsi_driver.c:67: cbw.scsi_cmd.transfer_len[1] = 1; +;source-doc/scsi-drv/scsi_driver.c:71: cbw.scsi_cmd.transfer_len[1] = 1; ld hl,_cbw + 23 ld (hl),0x01 -;source-doc/scsi-drv/scsi_driver.c:68: cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; - ld l,(ix-2) - ld h,(ix-1) - ld bc,0x000c - add hl,bc - ld c,l - ld b,h +;source-doc/scsi-drv/scsi_driver.c:72: cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; + pop hl + push hl + ld de,0x000c + add hl, de + push hl inc hl inc hl inc hl ld a, (hl) ld ((_cbw + 17)),a -;source-doc/scsi-drv/scsi_driver.c:69: cbw.scsi_cmd.lba[1] = dev->current_lba >> 16; -;source-doc/scsi-drv/scsi_driver.c:70: cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; - ld l,c - ld h,b + pop hl +;source-doc/scsi-drv/scsi_driver.c:73: cbw.scsi_cmd.lba[1] = dev->current_lba >> 16; + push hl inc hl inc hl - ld a,(hl) + ld a, (hl) ld ((_cbw + 18)),a - dec hl - ld e, (hl) - ld hl, +(_cbw + 19) - ld (hl), e -;source-doc/scsi-drv/scsi_driver.c:71: cbw.scsi_cmd.lba[3] = dev->current_lba; - ld a, (bc) + pop hl +;source-doc/scsi-drv/scsi_driver.c:74: cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; + push hl inc hl - ld (hl), a -;source-doc/scsi-drv/scsi_driver.c:73: result = do_scsi_cmd(dev, &cbw.cbw, buffer, false); - ld e,(ix+6) - ld d,(ix+7) - push bc + ld a, (hl) + ld ((_cbw + 19)),a + pop hl +;source-doc/scsi-drv/scsi_driver.c:75: cbw.scsi_cmd.lba[3] = dev->current_lba; + ld bc,_cbw + 20 + ld a, (hl) + ld (bc), a +;source-doc/scsi-drv/scsi_driver.c:77: result = do_scsi_cmd(dev, &cbw.cbw, buffer, false); + ld c,(ix+6) + ld b,(ix+7) + push hl xor a push af inc sp + push bc + ld de,_cbw + push de + ld e,(ix-2) + ld d,(ix-1) push de - ld hl,_cbw - push hl - ld l,(ix-2) - ld h,(ix-1) - push hl call _do_scsi_cmd pop af pop af pop af inc sp - pop bc ld a, l - ld (_result), a -;source-doc/scsi-drv/scsi_driver.c:75: if (result == USB_ERR_OK) - ld a,(_result) + pop hl + ld (ix-1),a +;source-doc/scsi-drv/scsi_driver.c:79: if (result == USB_ERR_OK) or a jr NZ,l_usb_scsi_read_00102 -;source-doc/scsi-drv/scsi_driver.c:76: dev->current_lba++; - ld l, c - ld h, b - ld e, (hl) +;source-doc/scsi-drv/scsi_driver.c:80: dev->current_lba++; + ld c,(hl) + push hl inc hl - ld d, (hl) + ld b, (hl) inc hl - ld a,(hl) + ld e, (hl) inc hl - ld h,(hl) - ld l,a - inc e + ld d, (hl) + pop hl + inc c jr NZ,l_usb_scsi_read_00114 - inc d + inc b jr NZ,l_usb_scsi_read_00114 - inc hl + inc de l_usb_scsi_read_00114: - ld a, e - ld (bc), a - inc bc - ld a, d - ld (bc), a - inc bc - ld a, l - ld (bc), a - inc bc - ld a, h - ld (bc), a + ld (hl), c + inc hl + ld (hl), b + inc hl + ld (hl), e + inc hl + ld (hl), d l_usb_scsi_read_00102: -;source-doc/scsi-drv/scsi_driver.c:77: return result; - ld hl, (_result) -;source-doc/scsi-drv/scsi_driver.c:78: } +;source-doc/scsi-drv/scsi_driver.c:81: return result; + ld l,(ix-1) +;source-doc/scsi-drv/scsi_driver.c:82: } ld sp, ix pop ix ret -;source-doc/scsi-drv/scsi_driver.c:80: usb_error usb_scsi_write(const uint16_t dev_index, uint8_t *const buffer) { +;source-doc/scsi-drv/scsi_driver.c:84: usb_error usb_scsi_write(const uint16_t dev_index, uint8_t *const buffer) { ; --------------------------------- ; Function usb_scsi_write ; --------------------------------- @@ -315,12 +311,12 @@ _usb_scsi_write: ld ix,0 add ix,sp push af -;source-doc/scsi-drv/scsi_driver.c:81: device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); +;source-doc/scsi-drv/scsi_driver.c:86: device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); ld a,(ix+4) call _get_usb_device_config pop bc push de -;source-doc/scsi-drv/scsi_driver.c:83: memset(&cbw, 0, sizeof(cbw_scsi_read_write)); +;source-doc/scsi-drv/scsi_driver.c:88: memset(&cbw, 0, sizeof(cbw_scsi_read_write)); ld de,_cbw ld l, e ld h, d @@ -333,112 +329,107 @@ l_usb_scsi_write_00113: ld (hl),0x00 inc hl djnz l_usb_scsi_write_00112 -;source-doc/scsi-drv/scsi_driver.c:84: cbw.cbw = scsi_command_block_wrapper; +;source-doc/scsi-drv/scsi_driver.c:89: cbw.cbw = scsi_command_block_wrapper; ld bc,0x000f ld hl,_scsi_command_block_wrapper ldir -;source-doc/scsi-drv/scsi_driver.c:86: cbw.cbw.bCBWLUN = 0; +;source-doc/scsi-drv/scsi_driver.c:91: cbw.cbw.bCBWLUN = 0; ld hl,_cbw + 13 ld (hl),0x00 -;source-doc/scsi-drv/scsi_driver.c:87: cbw.cbw.bCBWCBLength = sizeof(_scsi_packet_read_write); +;source-doc/scsi-drv/scsi_driver.c:92: cbw.cbw.bCBWCBLength = sizeof(_scsi_packet_read_write); ld hl,_cbw + 14 ld (hl),0x0c -;source-doc/scsi-drv/scsi_driver.c:88: cbw.cbw.dCBWDataTransferLength = 512; +;source-doc/scsi-drv/scsi_driver.c:93: cbw.cbw.dCBWDataTransferLength = 512; ld hl,0x0200 ld (_cbw + 8),hl ld h, l ld (_cbw + 8 + 2),hl -;source-doc/scsi-drv/scsi_driver.c:90: cbw.scsi_cmd.operation_code = 0x2A; // write operation +;source-doc/scsi-drv/scsi_driver.c:95: cbw.scsi_cmd.operation_code = 0x2A; // write operation ld hl,_cbw + 15 ld (hl),0x2a -;source-doc/scsi-drv/scsi_driver.c:91: cbw.scsi_cmd.transfer_len[1] = 1; +;source-doc/scsi-drv/scsi_driver.c:96: cbw.scsi_cmd.transfer_len[1] = 1; ld hl,_cbw + 23 ld (hl),0x01 -;source-doc/scsi-drv/scsi_driver.c:92: cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; - ld l,(ix-2) - ld h,(ix-1) - ld bc,0x000c - add hl,bc - ld c,l - ld b,h +;source-doc/scsi-drv/scsi_driver.c:97: cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; + pop hl + push hl + ld de,0x000c + add hl, de + push hl inc hl inc hl inc hl ld a, (hl) ld ((_cbw + 17)),a -;source-doc/scsi-drv/scsi_driver.c:93: cbw.scsi_cmd.lba[1] = dev->current_lba >> 16; -;source-doc/scsi-drv/scsi_driver.c:94: cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; - ld l,c - ld h,b + pop hl +;source-doc/scsi-drv/scsi_driver.c:98: cbw.scsi_cmd.lba[1] = dev->current_lba >> 16; + push hl inc hl inc hl - ld a,(hl) + ld a, (hl) ld ((_cbw + 18)),a - dec hl - ld e, (hl) - ld hl, +(_cbw + 19) - ld (hl), e -;source-doc/scsi-drv/scsi_driver.c:95: cbw.scsi_cmd.lba[3] = dev->current_lba; - ld a, (bc) + pop hl +;source-doc/scsi-drv/scsi_driver.c:99: cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; + push hl inc hl - ld (hl), a -;source-doc/scsi-drv/scsi_driver.c:97: result = do_scsi_cmd(dev, &cbw.cbw, buffer, true); - ld e,(ix+6) - ld d,(ix+7) - push bc + ld a, (hl) + ld ((_cbw + 19)),a + pop hl +;source-doc/scsi-drv/scsi_driver.c:100: cbw.scsi_cmd.lba[3] = dev->current_lba; + ld bc,_cbw + 20 + ld a, (hl) + ld (bc), a +;source-doc/scsi-drv/scsi_driver.c:102: result = do_scsi_cmd(dev, &cbw.cbw, buffer, true); + ld c,(ix+6) + ld b,(ix+7) + push hl ld a,0x01 push af inc sp + push bc + ld de,_cbw + push de + ld e,(ix-2) + ld d,(ix-1) push de - ld hl,_cbw - push hl - ld l,(ix-2) - ld h,(ix-1) - push hl call _do_scsi_cmd pop af pop af pop af inc sp - pop bc ld a, l - ld (_result), a -;source-doc/scsi-drv/scsi_driver.c:99: if (result == USB_ERR_OK) - ld a,(_result) + pop hl + ld (ix-1),a +;source-doc/scsi-drv/scsi_driver.c:104: if (result == USB_ERR_OK) or a jr NZ,l_usb_scsi_write_00102 -;source-doc/scsi-drv/scsi_driver.c:100: dev->current_lba++; - ld l, c - ld h, b - ld e, (hl) +;source-doc/scsi-drv/scsi_driver.c:105: dev->current_lba++; + ld c,(hl) + push hl inc hl - ld d, (hl) + ld b, (hl) inc hl - ld a,(hl) + ld e, (hl) inc hl - ld h,(hl) - ld l,a - inc e + ld d, (hl) + pop hl + inc c jr NZ,l_usb_scsi_write_00114 - inc d + inc b jr NZ,l_usb_scsi_write_00114 - inc hl + inc de l_usb_scsi_write_00114: - ld a, e - ld (bc), a - inc bc - ld a, d - ld (bc), a - inc bc - ld a, l - ld (bc), a - inc bc - ld a, h - ld (bc), a + ld (hl), c + inc hl + ld (hl), b + inc hl + ld (hl), e + inc hl + ld (hl), d l_usb_scsi_write_00102: -;source-doc/scsi-drv/scsi_driver.c:101: return result; - ld hl, (_result) -;source-doc/scsi-drv/scsi_driver.c:102: } +;source-doc/scsi-drv/scsi_driver.c:106: return result; + ld l,(ix-1) +;source-doc/scsi-drv/scsi_driver.c:107: } ld sp, ix pop ix ret 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 bf825ee3..6892df6d 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c @@ -3,8 +3,6 @@ #include "ez80-helpers.h" #include "print.h" -usb_error result = 0; - void ch_command(const uint8_t command) __z88dk_fastcall { uint8_t counter = 255; while ((CH376_COMMAND_PORT & PARA_STATE_BUSY) && --counter != 0) @@ -153,7 +151,8 @@ void ch_issue_token_in_ep0(void) { ch_issue_token(0x80, 0, CH_PID_IN); } void ch_issue_token_setup(void) { ch_issue_token(0, 0, CH_PID_SETUP); } usb_error ch_data_in_transfer(uint8_t *buffer, int16_t buffer_size, endpoint_param *const endpoint) { - uint8_t count; + uint8_t count; + usb_error result; if (buffer_size == 0) return USB_ERR_OK; diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.h b/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.h index f9240966..9507c765 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.h +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/ch376.h @@ -90,8 +90,6 @@ extern int printf(const char *msg, ...); #else -extern usb_error result; - #define trace_printf(...) #define CHECK(fn) \ diff --git a/Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.c b/Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.c index 99e08a5a..e3be00e4 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.c @@ -32,6 +32,7 @@ usb_error usbdev_control_transfer(device_config *const device, const setup_packe } usb_error usbdev_blk_out_trnsfer(device_config *const dev, const uint8_t *const buffer, const uint16_t buffer_size) { + usb_error result; endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_OUT]; @@ -50,6 +51,8 @@ done: } usb_error usbdev_bulk_in_transfer(device_config *const dev, uint8_t *const buffer, uint8_t *const buffer_size) { + usb_error result; + endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_IN]; result = usb_data_in_transfer_n(buffer, buffer_size, dev->address, endpoint); @@ -69,6 +72,7 @@ usb_error usbdev_dat_in_trnsfer(device_config *const device, uint8_t *const buffer, const uint16_t buffer_size, const usb_endpoint_type endpoint_type) { + usb_error result; endpoint_param *const endpoint = &device->endpoints[endpoint_type]; @@ -86,6 +90,8 @@ done: } usb_error usbdev_dat_in_trnsfer_0(device_config *const device, uint8_t *const buffer, const uint8_t buffer_size) { + usb_error result; + endpoint_param *const endpoint = &device->endpoints[0]; result = usb_data_in_transfer(buffer, buffer_size, device->address, endpoint); 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 73f96a85..c9bf9476 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/protocol.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/protocol.c @@ -27,6 +27,7 @@ const setup_packet cmd_get_device_descriptor = {0x80, 6, {0, 1}, {0, 0}, 8}; * @return usb_error USB_ERR_OK if all good, otherwise specific error code */ usb_error usbtrn_get_descriptor(device_descriptor *const buffer) { + usb_error result; setup_packet cmd; cmd = cmd_get_device_descriptor; cmd.wLength = 8; @@ -52,6 +53,8 @@ done: * @return usb_error USB_ERR_OK if all good, otherwise specific error code */ usb_error usbtrn_get_descriptor2(device_descriptor *const buffer, const uint8_t device_address) { + usb_error result; + setup_packet cmd; cmd = cmd_get_device_descriptor; cmd.wLength = 8; @@ -129,6 +132,7 @@ usb_error usbtrn_gfull_cfg_desc(const uint8_t config_index, const uint8_t max_packet_size, const uint8_t max_buffer_size, uint8_t *const buffer) { + usb_error result; CHECK(usbtrn_get_config_descriptor((config_descriptor *)buffer, config_index, sizeof(config_descriptor), device_address, max_packet_size)); 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 9705b89e..a5e1e9c1 100644 --- a/Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c +++ b/Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c @@ -92,6 +92,7 @@ done: */ usb_error usb_data_in_transfer(uint8_t *buffer, const uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { + usb_error result; critical_begin(); ch_set_usb_address(device_address); @@ -114,6 +115,8 @@ usb_data_in_transfer(uint8_t *buffer, const uint16_t buffer_size, const uint8_t */ usb_error usb_data_in_transfer_n(uint8_t *buffer, uint8_t *const buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { + usb_error result; + critical_begin(); ch_set_usb_address(device_address); @@ -136,6 +139,7 @@ usb_data_in_transfer_n(uint8_t *buffer, uint8_t *const buffer_size, const uint8_ */ usb_error usb_data_out_transfer(const uint8_t *buffer, uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) { + usb_error result; critical_begin(); ch_set_usb_address(device_address); diff --git a/Source/HBIOS/ch376-native/source-doc/keyboard/kyb_driver.c b/Source/HBIOS/ch376-native/source-doc/keyboard/kyb_driver.c index 217d151d..17d5a015 100644 --- a/Source/HBIOS/ch376-native/source-doc/keyboard/kyb_driver.c +++ b/Source/HBIOS/ch376-native/source-doc/keyboard/kyb_driver.c @@ -106,6 +106,8 @@ uint8_t usb_kyb_flush() __sdcccall(1) { } void usb_kyb_tick(void) { + usb_error result; + if (is_in_critical_section()) return; diff --git a/Source/HBIOS/ch376-native/source-doc/scsi-drv/class_scsi.c b/Source/HBIOS/ch376-native/source-doc/scsi-drv/class_scsi.c index de2a26ae..5a5a0e51 100644 --- a/Source/HBIOS/ch376-native/source-doc/scsi-drv/class_scsi.c +++ b/Source/HBIOS/ch376-native/source-doc/scsi-drv/class_scsi.c @@ -15,6 +15,8 @@ usb_error do_scsi_cmd(device_config_storage *const dev, void *const send_receive_buffer, const bool send) { + usb_error result; + cbw->dCBWTag[0] = next_tag++; if (!send) diff --git a/Source/HBIOS/ch376-native/source-doc/scsi-drv/scsi_driver.c b/Source/HBIOS/ch376-native/source-doc/scsi-drv/scsi_driver.c index fd24aa02..4151f853 100644 --- a/Source/HBIOS/ch376-native/source-doc/scsi-drv/scsi_driver.c +++ b/Source/HBIOS/ch376-native/source-doc/scsi-drv/scsi_driver.c @@ -6,6 +6,8 @@ #include usb_error usb_scsi_init(const uint16_t dev_index) { + usb_error result; + device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); scsi_sense_result response; @@ -54,6 +56,8 @@ usb_error usb_scsi_read_capacity(const uint16_t dev_index, scsi_read_capacity_re static cbw_scsi_read_write cbw = {{{0}}}; usb_error usb_scsi_read(const uint16_t dev_index, uint8_t *const buffer) { + usb_error result; + device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); memset(&cbw, 0, sizeof(cbw_scsi_read_write)); @@ -78,6 +82,7 @@ usb_error usb_scsi_read(const uint16_t dev_index, uint8_t *const buffer) { } usb_error usb_scsi_write(const uint16_t dev_index, uint8_t *const buffer) { + usb_error result; device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); memset(&cbw, 0, sizeof(cbw_scsi_read_write)); diff --git a/Source/HBIOS/ch376-native/source-doc/ufi-drv/usb_cbi.c b/Source/HBIOS/ch376-native/source-doc/ufi-drv/usb_cbi.c index e4b76046..8c2763e5 100644 --- a/Source/HBIOS/ch376-native/source-doc/ufi-drv/usb_cbi.c +++ b/Source/HBIOS/ch376-native/source-doc/ufi-drv/usb_cbi.c @@ -13,7 +13,7 @@ usb_error usb_execute_cbi(device_config *const storage_device, const uint16_t buffer_size, uint8_t *const buffer, uint8_t *const sense_codes) { - + usb_error result; const uint8_t interface_number = storage_device->interface_number; setup_packet adsc; 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 0db067ee..c00100d5 100644 --- a/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s +++ b/Source/HBIOS/ch376-native/ufi-drv/usb_cbi.c.s @@ -98,10 +98,8 @@ _usb_execute_cbi: pop af pop af pop af - ld a, l - ld (_result), a ;source-doc/ufi-drv/usb_cbi.c:27: if (result == USB_ERR_STALL) { - ld a,(_result) + ld a, l sub 0x02 jr NZ,l_usb_execute_cbi_00104 ;source-doc/ufi-drv/usb_cbi.c:28: if (sense_codes != NULL) @@ -126,15 +124,14 @@ _usb_execute_cbi: ld sp, hl l_usb_execute_cbi_00102: ;source-doc/ufi-drv/usb_cbi.c:31: result = USB_ERR_STALL; - ld hl,_result - ld (hl),0x02 + ld l,0x02 ;source-doc/ufi-drv/usb_cbi.c:32: goto done; - jp l_usb_execute_cbi_00116 + jr l_usb_execute_cbi_00116 l_usb_execute_cbi_00104: ;source-doc/ufi-drv/usb_cbi.c:35: if (result != USB_ERR_OK) { - ld a,(_result) + ld a, l or a - jp NZ, l_usb_execute_cbi_00116 + jr NZ,l_usb_execute_cbi_00116 ;source-doc/ufi-drv/usb_cbi.c:40: if (send) { bit 0,(ix+8) jr Z,l_usb_execute_cbi_00112 @@ -152,10 +149,8 @@ l_usb_execute_cbi_00104: pop af pop af pop af - ld a, l - ld (_result), a ;source-doc/ufi-drv/usb_cbi.c:43: if (result != USB_ERR_OK) { - ld a,(_result) + ld a, l or a jr Z,l_usb_execute_cbi_00113 ;source-doc/ufi-drv/usb_cbi.c:45: goto done; @@ -179,10 +174,8 @@ l_usb_execute_cbi_00112: pop af pop af inc sp - ld a, l - ld (_result), a ;source-doc/ufi-drv/usb_cbi.c:50: if (result != USB_ERR_OK) { - ld a,(_result) + ld a, l or a jr NZ,l_usb_execute_cbi_00116 ;source-doc/ufi-drv/usb_cbi.c:52: goto done; @@ -208,14 +201,13 @@ l_usb_execute_cbi_00113: pop af pop af inc sp - ld a, l - ld (_result), a ;source-doc/ufi-drv/usb_cbi.c:65: done: l_usb_execute_cbi_00116: ;source-doc/ufi-drv/usb_cbi.c:66: critical_end(); + push hl call _critical_end + pop hl ;source-doc/ufi-drv/usb_cbi.c:68: return result; - ld hl, (_result) ;source-doc/ufi-drv/usb_cbi.c:69: } ld sp, ix pop ix