mirror of https://github.com/wwarthen/RomWBW.git
39 changed files with 2318 additions and 2577 deletions
@ -1,465 +0,0 @@ |
|||
; |
|||
; Generated from source-doc/base-drv/usb-init.c.asm -- not to be modify directly |
|||
; |
|||
; |
|||
;-------------------------------------------------------- |
|||
; File Created by SDCC : free open source ISO C Compiler |
|||
; Version 4.5.0 #15248 (Linux) |
|||
;-------------------------------------------------------- |
|||
; Processed by Z88DK |
|||
;-------------------------------------------------------- |
|||
|
|||
|
|||
;-------------------------------------------------------- |
|||
; Public variables in this module |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Externals used |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; special function registers |
|||
;-------------------------------------------------------- |
|||
_CH376_DATA_PORT .EQU 0xff88 |
|||
_CH376_COMMAND_PORT .EQU 0xff89 |
|||
_USB_MODULE_LEDS .EQU 0xff8a |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
|
|||
#IF 0 |
|||
|
|||
; .area _INITIALIZED removed by z88dk |
|||
|
|||
|
|||
#ENDIF |
|||
|
|||
;-------------------------------------------------------- |
|||
; absolute external ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; global & static initialisations |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Home |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; code |
|||
;-------------------------------------------------------- |
|||
;source-doc/base-drv/usb-init.c:8: static usb_error usb_host_bus_reset(void) { |
|||
; --------------------------------- |
|||
; Function usb_host_bus_reset |
|||
; --------------------------------- |
|||
_usb_host_bus_reset: |
|||
;source-doc/base-drv/usb-init.c:9: ch_cmd_set_usb_mode(CH_MODE_HOST); |
|||
ld l,0x06 |
|||
call _ch_cmd_set_usb_mode |
|||
;source-doc/base-drv/usb-init.c:10: delay_20ms(); |
|||
call _delay_20ms |
|||
;source-doc/base-drv/usb-init.c:12: ch_cmd_set_usb_mode(CH_MODE_HOST_RESET); |
|||
ld l,0x07 |
|||
call _ch_cmd_set_usb_mode |
|||
;source-doc/base-drv/usb-init.c:13: delay_20ms(); |
|||
call _delay_20ms |
|||
;source-doc/base-drv/usb-init.c:15: ch_cmd_set_usb_mode(CH_MODE_HOST); |
|||
ld l,0x06 |
|||
call _ch_cmd_set_usb_mode |
|||
;source-doc/base-drv/usb-init.c:16: delay_20ms(); |
|||
call _delay_20ms |
|||
;source-doc/base-drv/ch376.h:110: #endif |
|||
ld l,0x0b |
|||
call _ch_command |
|||
;source-doc/base-drv/ch376.h:111: |
|||
ld a,0x25 |
|||
ld bc,_CH376_DATA_PORT |
|||
out (c), a |
|||
;source-doc/base-drv/ch376.h:112: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF) |
|||
ld a,0xdf |
|||
ld bc,_CH376_DATA_PORT |
|||
out (c), a |
|||
;source-doc/base-drv/usb-init.c:20: return USB_ERR_OK; |
|||
ld l,0x00 |
|||
;source-doc/base-drv/usb-init.c:21: } |
|||
ret |
|||
;source-doc/base-drv/usb-init.c:25: uint16_t ch376_init(uint8_t state) { |
|||
; --------------------------------- |
|||
; Function ch376_init |
|||
; --------------------------------- |
|||
_ch376_init: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
;source-doc/base-drv/usb-init.c:28: USB_MODULE_LEDS = 0x03; |
|||
ld a,0x03 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb-init.c:30: if (state == 0) { |
|||
ld a,(ix+4) |
|||
or a |
|||
jr NZ,l_ch376_init_00104 |
|||
;source-doc/base-drv/usb-init.c:31: ch_cmd_reset_all(); |
|||
call _ch_cmd_reset_all |
|||
;source-doc/base-drv/usb-init.c:32: delay_medium(); |
|||
call _delay_medium |
|||
;source-doc/base-drv/usb-init.c:34: if (!ch_probe()) { |
|||
call _ch_probe |
|||
ld a, l |
|||
;source-doc/base-drv/usb-init.c:35: USB_MODULE_LEDS = 0x00; |
|||
or a |
|||
jr NZ,l_ch376_init_00102 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb-init.c:36: return 0xFF00; |
|||
ld hl,0xff00 |
|||
jp l_ch376_init_00113 |
|||
l_ch376_init_00102: |
|||
;source-doc/base-drv/usb-init.c:38: USB_MODULE_LEDS = 0x00; |
|||
ld a,0x00 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb-init.c:39: return 1; |
|||
ld hl,0x0001 |
|||
jr l_ch376_init_00113 |
|||
l_ch376_init_00104: |
|||
;source-doc/base-drv/usb-init.c:42: if (state == 1) { |
|||
ld a,(ix+4) |
|||
dec a |
|||
jr NZ,l_ch376_init_00106 |
|||
;source-doc/base-drv/usb-init.c:43: r = ch_cmd_get_ic_version(); |
|||
call _ch_cmd_get_ic_version |
|||
;source-doc/base-drv/usb-init.c:45: USB_MODULE_LEDS = 0x00; |
|||
ld a,0x00 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb-init.c:46: return (uint16_t)r << 8 | 2; |
|||
xor a |
|||
ld h, l |
|||
ld l,0x02 |
|||
jr l_ch376_init_00113 |
|||
l_ch376_init_00106: |
|||
;source-doc/base-drv/usb-init.c:49: if (state == 2) { |
|||
ld a,(ix+4) |
|||
sub 0x02 |
|||
jr NZ,l_ch376_init_00159 |
|||
ld a,0x01 |
|||
jr l_ch376_init_00160 |
|||
l_ch376_init_00159: |
|||
xor a |
|||
l_ch376_init_00160: |
|||
ld c,a |
|||
or a |
|||
jr Z,l_ch376_init_00110 |
|||
;source-doc/base-drv/usb-init.c:50: usb_host_bus_reset(); |
|||
call _usb_host_bus_reset |
|||
;source-doc/base-drv/usb-init.c:52: r = ch_very_short_wait_int_and_get_(); |
|||
call _ch_very_short_wait_int_and_get |
|||
ld a, l |
|||
;source-doc/base-drv/usb-init.c:54: if (r != USB_INT_CONNECT) { |
|||
sub 0x81 |
|||
jr Z,l_ch376_init_00108 |
|||
;source-doc/base-drv/usb-init.c:55: USB_MODULE_LEDS = 0x00; |
|||
ld a,0x00 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb-init.c:56: return 2; |
|||
ld hl,0x0002 |
|||
jr l_ch376_init_00113 |
|||
l_ch376_init_00108: |
|||
;source-doc/base-drv/usb-init.c:59: return 3; |
|||
ld hl,0x0003 |
|||
jr l_ch376_init_00113 |
|||
l_ch376_init_00110: |
|||
;source-doc/base-drv/usb-init.c:62: memset(get_usb_work_area(), 0, sizeof(_usb_state)); |
|||
ld b,0x35 |
|||
ld hl,_x |
|||
jr l_ch376_init_00163 |
|||
l_ch376_init_00162: |
|||
ld (hl),0x00 |
|||
inc hl |
|||
l_ch376_init_00163: |
|||
ld (hl),0x00 |
|||
inc hl |
|||
djnz l_ch376_init_00162 |
|||
;source-doc/base-drv/usb-init.c:63: if (state != 2) { |
|||
bit 0, c |
|||
jr NZ,l_ch376_init_00112 |
|||
;source-doc/base-drv/usb-init.c:64: usb_host_bus_reset(); |
|||
call _usb_host_bus_reset |
|||
;source-doc/base-drv/usb-init.c:65: delay_medium(); |
|||
call _delay_medium |
|||
l_ch376_init_00112: |
|||
;source-doc/base-drv/usb-init.c:67: enumerate_all_devices(); |
|||
call _enumerate_all_devices |
|||
;source-doc/base-drv/usb-init.c:68: USB_MODULE_LEDS = 0x00; |
|||
ld a,0x00 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb-init.c:69: return (uint16_t)count_of_devices() << 8 | state + 1; |
|||
call _count_of_devices |
|||
ld c,(ix+4) |
|||
ld b,0x00 |
|||
inc bc |
|||
or b |
|||
ld h, a |
|||
ld l, c |
|||
l_ch376_init_00113: |
|||
;source-doc/base-drv/usb-init.c:70: } |
|||
pop ix |
|||
ret |
|||
;source-doc/base-drv/usb-init.c:72: static uint16_t wait_for_state(const uint8_t loop_counter, uint8_t state, const uint8_t desired_state) __sdcccall(1) { |
|||
; --------------------------------- |
|||
; Function wait_for_state |
|||
; --------------------------------- |
|||
_wait_for_state: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
dec sp |
|||
ld (ix-1),a |
|||
ld b, l |
|||
;source-doc/base-drv/usb-init.c:73: uint16_t r = state; |
|||
ld e, b |
|||
;source-doc/base-drv/usb-init.c:75: for (uint8_t i = 0; i < loop_counter; i++) { |
|||
ld d,0x00 |
|||
ld c,d |
|||
l_wait_for_state_00108: |
|||
ld a, c |
|||
sub (ix-1) |
|||
jr NC,l_wait_for_state_00106 |
|||
;source-doc/base-drv/usb-init.c:76: if (state == desired_state) |
|||
ld a,(ix+4) |
|||
sub b |
|||
jr Z,l_wait_for_state_00106 |
|||
;source-doc/base-drv/usb-init.c:79: if (i & 1) |
|||
bit 0, c |
|||
jr Z,l_wait_for_state_00104 |
|||
;source-doc/base-drv/usb-init.c:80: print_string("\b $"); |
|||
push bc |
|||
ld hl,usb_init_str_0 |
|||
call _print_string |
|||
pop bc |
|||
jr l_wait_for_state_00105 |
|||
l_wait_for_state_00104: |
|||
;source-doc/base-drv/usb-init.c:82: print_string("\b*$"); |
|||
push bc |
|||
ld hl,usb_init_str_1 |
|||
call _print_string |
|||
pop bc |
|||
l_wait_for_state_00105: |
|||
;source-doc/base-drv/usb-init.c:84: r = ch376_init(state); |
|||
push bc |
|||
push bc |
|||
inc sp |
|||
call _ch376_init |
|||
inc sp |
|||
ex de, hl |
|||
pop bc |
|||
;source-doc/base-drv/usb-init.c:85: state = r & 255; |
|||
ld b, e |
|||
;source-doc/base-drv/usb-init.c:75: for (uint8_t i = 0; i < loop_counter; i++) { |
|||
inc c |
|||
jr l_wait_for_state_00108 |
|||
l_wait_for_state_00106: |
|||
;source-doc/base-drv/usb-init.c:88: return r; |
|||
;source-doc/base-drv/usb-init.c:89: } |
|||
inc sp |
|||
pop ix |
|||
pop hl |
|||
inc sp |
|||
jp (hl) |
|||
usb_init_str_0: |
|||
DEFB 0x08 |
|||
DEFM " $" |
|||
DEFB 0x00 |
|||
usb_init_str_1: |
|||
DEFB 0x08 |
|||
DEFM "*$" |
|||
DEFB 0x00 |
|||
;source-doc/base-drv/usb-init.c:91: void _chnative_init(bool forced) { |
|||
; --------------------------------- |
|||
; Function _chnative_init |
|||
; --------------------------------- |
|||
__chnative_init: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
dec sp |
|||
;source-doc/base-drv/usb-init.c:94: const uint8_t loop_counter = forced ? 40 : 5; |
|||
bit 0,(ix+4) |
|||
jr Z,l__chnative_init_00113 |
|||
ld a,0x28 |
|||
jr l__chnative_init_00114 |
|||
l__chnative_init_00113: |
|||
ld a,0x05 |
|||
l__chnative_init_00114: |
|||
ld (ix-1),a |
|||
;source-doc/base-drv/usb-init.c:96: print_string("\r\nCH376: *$"); |
|||
ld hl,usb_init_str_2 |
|||
call _print_string |
|||
;source-doc/base-drv/usb-init.c:98: r = wait_for_state(loop_counter, state, 1); |
|||
ld a,0x01 |
|||
push af |
|||
inc sp |
|||
ld l,0x00 |
|||
ld a,(ix-1) |
|||
call _wait_for_state |
|||
ld b, e |
|||
;source-doc/base-drv/usb-init.c:99: state = r & 255; |
|||
;source-doc/base-drv/usb-init.c:101: print_string("\bPRESENT (VER $"); |
|||
push bc |
|||
ld hl,usb_init_str_3 |
|||
call _print_string |
|||
;source-doc/base-drv/usb-init.c:103: r = ch376_init(state); |
|||
inc sp |
|||
call _ch376_init |
|||
inc sp |
|||
ex de, hl |
|||
;source-doc/base-drv/usb-init.c:104: state = r & 255; |
|||
ld c, e |
|||
;source-doc/base-drv/usb-init.c:105: if (state != 2) { |
|||
ld a, c |
|||
sub 0x02 |
|||
jr Z,l__chnative_init_00102 |
|||
;source-doc/base-drv/usb-init.c:106: print_string("\rCH376: $"); |
|||
ld hl,usb_init_str_4 |
|||
call _print_string |
|||
;source-doc/base-drv/usb-init.c:107: print_string("VERSION FAILURE\r\n$"); |
|||
ld hl,usb_init_str_5 |
|||
call _print_string |
|||
;source-doc/base-drv/usb-init.c:108: return; |
|||
jr l__chnative_init_00111 |
|||
l__chnative_init_00102: |
|||
;source-doc/base-drv/usb-init.c:111: print_hex(r >> 8); |
|||
push bc |
|||
ld l, d |
|||
call _print_hex |
|||
;source-doc/base-drv/usb-init.c:112: print_string("); $"); |
|||
ld hl,usb_init_str_6 |
|||
call _print_string |
|||
;source-doc/base-drv/usb-init.c:114: print_string("USB: *$"); |
|||
ld hl,usb_init_str_7 |
|||
call _print_string |
|||
pop bc |
|||
;source-doc/base-drv/usb-init.c:116: r = wait_for_state(loop_counter, state, 3); |
|||
ld a,0x03 |
|||
push af |
|||
inc sp |
|||
ld l, c |
|||
ld a,(ix-1) |
|||
call _wait_for_state |
|||
ld b, e |
|||
;source-doc/base-drv/usb-init.c:117: state = r & 255; |
|||
;source-doc/base-drv/usb-init.c:119: if (state == 2) { |
|||
ld a, b |
|||
sub 0x02 |
|||
jr NZ,l__chnative_init_00104 |
|||
;source-doc/base-drv/usb-init.c:120: print_string("\bDISCONNECTED$"); |
|||
ld hl,usb_init_str_8 |
|||
call _print_string |
|||
;source-doc/base-drv/usb-init.c:121: return; |
|||
jr l__chnative_init_00111 |
|||
l__chnative_init_00104: |
|||
;source-doc/base-drv/usb-init.c:124: print_string("\bCONNECTED$"); |
|||
push bc |
|||
ld hl,usb_init_str_9 |
|||
call _print_string |
|||
;source-doc/base-drv/usb-init.c:127: r = ch376_init(state); |
|||
inc sp |
|||
call _ch376_init |
|||
inc sp |
|||
ex de, hl |
|||
;source-doc/base-drv/usb-init.c:128: state = r & 255; |
|||
ld b, e |
|||
;source-doc/base-drv/usb-init.c:130: for (uint8_t i = 0; i < loop_counter; i++) { |
|||
ld c,0x00 |
|||
l__chnative_init_00109: |
|||
ld a, c |
|||
sub (ix-1) |
|||
jr NC,l__chnative_init_00111 |
|||
;source-doc/base-drv/usb-init.c:131: if (r >> 8 != 0) |
|||
ld a,0x00 |
|||
or d |
|||
jr NZ,l__chnative_init_00111 |
|||
;source-doc/base-drv/usb-init.c:134: print_string(".$"); |
|||
push bc |
|||
ld hl,usb_init_str_10 |
|||
call _print_string |
|||
pop bc |
|||
;source-doc/base-drv/usb-init.c:135: r = ch376_init(state); |
|||
push bc |
|||
push bc |
|||
inc sp |
|||
call _ch376_init |
|||
inc sp |
|||
ex de, hl |
|||
pop bc |
|||
;source-doc/base-drv/usb-init.c:136: state = r & 255; |
|||
ld b, e |
|||
;source-doc/base-drv/usb-init.c:130: for (uint8_t i = 0; i < loop_counter; i++) { |
|||
inc c |
|||
jr l__chnative_init_00109 |
|||
l__chnative_init_00111: |
|||
;source-doc/base-drv/usb-init.c:138: } |
|||
inc sp |
|||
pop ix |
|||
ret |
|||
usb_init_str_2: |
|||
DEFB 0x0d |
|||
DEFB 0x0a |
|||
DEFM "CH376: *$" |
|||
DEFB 0x00 |
|||
usb_init_str_3: |
|||
DEFB 0x08 |
|||
DEFM "PRESENT (VER $" |
|||
DEFB 0x00 |
|||
usb_init_str_4: |
|||
DEFB 0x0d |
|||
DEFM "CH376: $" |
|||
DEFB 0x00 |
|||
usb_init_str_5: |
|||
DEFM "VERSION FAILURE" |
|||
DEFB 0x0d |
|||
DEFB 0x0a |
|||
DEFM "$" |
|||
DEFB 0x00 |
|||
usb_init_str_6: |
|||
DEFM "); $" |
|||
DEFB 0x00 |
|||
usb_init_str_7: |
|||
DEFM "USB: *$" |
|||
DEFB 0x00 |
|||
usb_init_str_8: |
|||
DEFB 0x08 |
|||
DEFM "DISCONNECTED$" |
|||
DEFB 0x00 |
|||
usb_init_str_9: |
|||
DEFB 0x08 |
|||
DEFM "CONNECTED$" |
|||
DEFB 0x00 |
|||
usb_init_str_10: |
|||
DEFM ".$" |
|||
DEFB 0x00 |
|||
;source-doc/base-drv/usb-init.c:140: void chnative_init_force(void) { _chnative_init(true); } |
|||
; --------------------------------- |
|||
; Function chnative_init_force |
|||
; --------------------------------- |
|||
_chnative_init_force: |
|||
ld a,0x01 |
|||
push af |
|||
inc sp |
|||
call __chnative_init |
|||
inc sp |
|||
ret |
|||
;source-doc/base-drv/usb-init.c:142: void chnative_init(void) { _chnative_init(false); } |
|||
; --------------------------------- |
|||
; Function chnative_init |
|||
; --------------------------------- |
|||
_chnative_init: |
|||
xor a |
|||
push af |
|||
inc sp |
|||
call __chnative_init |
|||
inc sp |
|||
ret |
|||
@ -1,203 +0,0 @@ |
|||
; |
|||
; Generated from source-doc/base-drv/usb_init.c.asm -- not to be modify directly |
|||
; |
|||
; |
|||
;-------------------------------------------------------- |
|||
; File Created by SDCC : free open source ISO C Compiler |
|||
; Version 4.5.0 #15248 (Linux) |
|||
;-------------------------------------------------------- |
|||
; Processed by Z88DK |
|||
;-------------------------------------------------------- |
|||
|
|||
|
|||
;-------------------------------------------------------- |
|||
; Public variables in this module |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Externals used |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; special function registers |
|||
;-------------------------------------------------------- |
|||
_CH376_DATA_PORT .EQU 0xff88 |
|||
_CH376_COMMAND_PORT .EQU 0xff89 |
|||
_USB_MODULE_LEDS .EQU 0xff8a |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
|
|||
#IF 0 |
|||
|
|||
; .area _INITIALIZED removed by z88dk |
|||
|
|||
|
|||
#ENDIF |
|||
|
|||
;-------------------------------------------------------- |
|||
; absolute external ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; global & static initialisations |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Home |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; code |
|||
;-------------------------------------------------------- |
|||
;source-doc/base-drv/usb_init.c:7: static usb_error usb_host_bus_reset(void) { |
|||
; --------------------------------- |
|||
; Function usb_host_bus_reset |
|||
; --------------------------------- |
|||
_usb_host_bus_reset: |
|||
;source-doc/base-drv/usb_init.c:8: ch_cmd_set_usb_mode(CH_MODE_HOST); |
|||
ld l,0x06 |
|||
call _ch_cmd_set_usb_mode |
|||
;source-doc/base-drv/usb_init.c:9: delay_20ms(); |
|||
call _delay_20ms |
|||
;source-doc/base-drv/usb_init.c:11: ch_cmd_set_usb_mode(CH_MODE_HOST_RESET); |
|||
ld l,0x07 |
|||
call _ch_cmd_set_usb_mode |
|||
;source-doc/base-drv/usb_init.c:12: delay_20ms(); |
|||
call _delay_20ms |
|||
;source-doc/base-drv/usb_init.c:14: ch_cmd_set_usb_mode(CH_MODE_HOST); |
|||
ld l,0x06 |
|||
call _ch_cmd_set_usb_mode |
|||
;source-doc/base-drv/usb_init.c:15: delay_20ms(); |
|||
call _delay_20ms |
|||
;source-doc/base-drv/ch376.h:110: #endif |
|||
ld l,0x0b |
|||
call _ch_command |
|||
;source-doc/base-drv/ch376.h:111: |
|||
ld a,0x25 |
|||
ld bc,_CH376_DATA_PORT |
|||
out (c), a |
|||
;source-doc/base-drv/ch376.h:112: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF) |
|||
ld a,0xdf |
|||
ld bc,_CH376_DATA_PORT |
|||
out (c), a |
|||
;source-doc/base-drv/usb_init.c:19: return USB_ERR_OK; |
|||
ld l,0x00 |
|||
;source-doc/base-drv/usb_init.c:20: } |
|||
ret |
|||
;source-doc/base-drv/usb_init.c:24: uint16_t usb_init(uint8_t state) __z88dk_fastcall { |
|||
; --------------------------------- |
|||
; Function usb_init |
|||
; --------------------------------- |
|||
_usb_init: |
|||
;source-doc/base-drv/usb_init.c:27: USB_MODULE_LEDS = 0x03; |
|||
ld a,0x03 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb_init.c:29: if (state == 0) { |
|||
ld a, l |
|||
or a |
|||
jr NZ,l_usb_init_00104 |
|||
;source-doc/base-drv/usb_init.c:30: ch_cmd_reset_all(); |
|||
call _ch_cmd_reset_all |
|||
;source-doc/base-drv/usb_init.c:31: delay_medium(); |
|||
call _delay_medium |
|||
;source-doc/base-drv/usb_init.c:33: if (!ch_probe()) { |
|||
call _ch_probe |
|||
ld a, l |
|||
;source-doc/base-drv/usb_init.c:34: USB_MODULE_LEDS = 0x00; |
|||
or a |
|||
jr NZ,l_usb_init_00102 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb_init.c:35: return 0xFF00; |
|||
ld hl,0xff00 |
|||
jp l_usb_init_00113 |
|||
l_usb_init_00102: |
|||
;source-doc/base-drv/usb_init.c:37: USB_MODULE_LEDS = 0x00; |
|||
ld a,0x00 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb_init.c:38: return 1; |
|||
ld hl,0x0001 |
|||
jr l_usb_init_00113 |
|||
l_usb_init_00104: |
|||
;source-doc/base-drv/usb_init.c:41: if (state == 1) { |
|||
ld a, l |
|||
dec a |
|||
jr NZ,l_usb_init_00106 |
|||
;source-doc/base-drv/usb_init.c:42: r = ch_cmd_get_ic_version(); |
|||
call _ch_cmd_get_ic_version |
|||
;source-doc/base-drv/usb_init.c:44: USB_MODULE_LEDS = 0x00; |
|||
ld a,0x00 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb_init.c:45: return (uint16_t)r << 8 | 2; |
|||
xor a |
|||
ld h, l |
|||
ld l,0x02 |
|||
jr l_usb_init_00113 |
|||
l_usb_init_00106: |
|||
;source-doc/base-drv/usb_init.c:48: if (state == 2) { |
|||
ld a, l |
|||
sub 0x02 |
|||
jr NZ,l_usb_init_00159 |
|||
ld a,0x01 |
|||
jr l_usb_init_00160 |
|||
l_usb_init_00159: |
|||
xor a |
|||
l_usb_init_00160: |
|||
ld c,a |
|||
or a |
|||
jr Z,l_usb_init_00110 |
|||
;source-doc/base-drv/usb_init.c:49: usb_host_bus_reset(); |
|||
call _usb_host_bus_reset |
|||
;source-doc/base-drv/usb_init.c:51: r = ch_very_short_wait_int_and_get_(); |
|||
call _ch_very_short_wait_int_and_get |
|||
ld a, l |
|||
;source-doc/base-drv/usb_init.c:53: if (r != USB_INT_CONNECT) { |
|||
sub 0x81 |
|||
jr Z,l_usb_init_00108 |
|||
;source-doc/base-drv/usb_init.c:54: USB_MODULE_LEDS = 0x00; |
|||
ld a,0x00 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb_init.c:55: return 2; |
|||
ld hl,0x0002 |
|||
jr l_usb_init_00113 |
|||
l_usb_init_00108: |
|||
;source-doc/base-drv/usb_init.c:58: return 3; |
|||
ld hl,0x0003 |
|||
jr l_usb_init_00113 |
|||
l_usb_init_00110: |
|||
;source-doc/base-drv/usb_init.c:61: memset(get_usb_work_area(), 0, sizeof(_usb_state)); |
|||
ld b,0x32 |
|||
ld hl,_x |
|||
jr l_usb_init_00163 |
|||
l_usb_init_00162: |
|||
ld (hl),0x00 |
|||
inc hl |
|||
l_usb_init_00163: |
|||
ld (hl),0x00 |
|||
inc hl |
|||
djnz l_usb_init_00162 |
|||
;source-doc/base-drv/usb_init.c:62: if (state != 2) { |
|||
bit 0, c |
|||
jr NZ,l_usb_init_00112 |
|||
;source-doc/base-drv/usb_init.c:63: usb_host_bus_reset(); |
|||
call _usb_host_bus_reset |
|||
;source-doc/base-drv/usb_init.c:64: delay_medium(); |
|||
call _delay_medium |
|||
l_usb_init_00112: |
|||
;source-doc/base-drv/usb_init.c:66: enumerate_all_devices(); |
|||
call _enumerate_all_devices |
|||
;source-doc/base-drv/usb_init.c:67: USB_MODULE_LEDS = 0x00; |
|||
ld a,0x00 |
|||
ld bc,_USB_MODULE_LEDS |
|||
out (c), a |
|||
;source-doc/base-drv/usb_init.c:68: return (uint16_t)count_of_devices() << 8 | 4; |
|||
call _count_of_devices |
|||
ld h, a |
|||
xor a |
|||
ld l,0x04 |
|||
l_usb_init_00113: |
|||
;source-doc/base-drv/usb_init.c:69: } |
|||
ret |
|||
@ -0,0 +1,583 @@ |
|||
; |
|||
; Generated from source-doc/keyboard/kyb_driver.c.asm -- not to be modify directly |
|||
; |
|||
; |
|||
;-------------------------------------------------------- |
|||
; File Created by SDCC : free open source ISO C Compiler |
|||
; Version 4.5.0 #15248 (Linux) |
|||
;-------------------------------------------------------- |
|||
; Processed by Z88DK |
|||
;-------------------------------------------------------- |
|||
|
|||
|
|||
;-------------------------------------------------------- |
|||
; Public variables in this module |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Externals used |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; special function registers |
|||
;-------------------------------------------------------- |
|||
_CH376_DATA_PORT .EQU 0xff88 |
|||
_CH376_COMMAND_PORT .EQU 0xff89 |
|||
_USB_MODULE_LEDS .EQU 0xff8a |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
|
|||
#IF 0 |
|||
|
|||
; .area _INITIALIZED removed by z88dk |
|||
|
|||
_keyboard_config: |
|||
DEFS 2 |
|||
_buffer: |
|||
DEFS 16 |
|||
_write_index: |
|||
DEFS 1 |
|||
_read_index: |
|||
DEFS 1 |
|||
_alt_write_index: |
|||
DEFS 1 |
|||
_alt_read_index: |
|||
DEFS 1 |
|||
_reports: |
|||
DEFS 64 |
|||
_queued_report: |
|||
DEFS 2 |
|||
_report: |
|||
DEFS 8 |
|||
_previous: |
|||
DEFS 8 |
|||
|
|||
#ENDIF |
|||
|
|||
;-------------------------------------------------------- |
|||
; absolute external ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; global & static initialisations |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Home |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; code |
|||
;-------------------------------------------------------- |
|||
;source-doc/keyboard/kyb_driver.c:26: |
|||
; --------------------------------- |
|||
; Function report_diff |
|||
; --------------------------------- |
|||
_report_diff: |
|||
;source-doc/keyboard/kyb_driver.c:27: static uint8_t report_diff() __sdcccall(1) { |
|||
ld de,_report+0 |
|||
;source-doc/keyboard/kyb_driver.c:28: uint8_t *a = (uint8_t *)&report; |
|||
;source-doc/keyboard/kyb_driver.c:31: uint8_t i = sizeof(report); |
|||
ld b,0x08 |
|||
ld hl,_previous |
|||
l_report_diff_00103: |
|||
;source-doc/keyboard/kyb_driver.c:32: do { |
|||
ld a, (de) |
|||
inc de |
|||
ld c, (hl) |
|||
inc hl |
|||
sub c |
|||
jr Z,l_report_diff_00104 |
|||
;source-doc/keyboard/kyb_driver.c:33: if (*a++ != *b++) |
|||
ld a,0x01 |
|||
jr l_report_diff_00106 |
|||
l_report_diff_00104: |
|||
;source-doc/keyboard/kyb_driver.c:34: return true; |
|||
djnz l_report_diff_00103 |
|||
;source-doc/keyboard/kyb_driver.c:36: |
|||
xor a |
|||
l_report_diff_00106: |
|||
;source-doc/keyboard/kyb_driver.c:37: return false; |
|||
ret |
|||
;source-doc/keyboard/kyb_driver.c:39: |
|||
; --------------------------------- |
|||
; Function report_put |
|||
; --------------------------------- |
|||
_report_put: |
|||
;source-doc/keyboard/kyb_driver.c:40: static void report_put() { |
|||
ld a, (_alt_write_index) |
|||
inc a |
|||
and 0x07 |
|||
ld c, a |
|||
;source-doc/keyboard/kyb_driver.c:42: |
|||
ld a,(_alt_read_index) |
|||
sub c |
|||
ret Z |
|||
;source-doc/keyboard/kyb_driver.c:43: if (next_write_index != alt_read_index) { // Check if buffer is not full |
|||
ld de,_reports+0 |
|||
ld hl, (_alt_write_index) |
|||
ld h,0x00 |
|||
add hl, hl |
|||
add hl, hl |
|||
add hl, hl |
|||
add hl, de |
|||
ex de, hl |
|||
push bc |
|||
ld bc,0x0008 |
|||
ld hl,_report |
|||
ldir |
|||
pop bc |
|||
;source-doc/keyboard/kyb_driver.c:44: reports[alt_write_index] = report; |
|||
ld hl,_alt_write_index |
|||
ld (hl), c |
|||
;source-doc/keyboard/kyb_driver.c:46: } |
|||
ret |
|||
;source-doc/keyboard/kyb_driver.c:48: |
|||
; --------------------------------- |
|||
; Function keyboard_buf_put |
|||
; --------------------------------- |
|||
_keyboard_buf_put: |
|||
ld c, a |
|||
;source-doc/keyboard/kyb_driver.c:49: static void keyboard_buf_put(const uint8_t indx) __sdcccall(1) { |
|||
ld b,0x00 |
|||
ld hl,+(_report + 2) |
|||
add hl, bc |
|||
;source-doc/keyboard/kyb_driver.c:50: const uint8_t key_code = report.keyCode[indx]; |
|||
ld a,(hl) |
|||
ld c,a |
|||
cp 0x80 |
|||
jr NC,l_keyboard_buf_put_00111 |
|||
or a |
|||
;source-doc/keyboard/kyb_driver.c:51: if (key_code >= 0x80 || key_code == 0) |
|||
jr Z,l_keyboard_buf_put_00111 |
|||
;source-doc/keyboard/kyb_driver.c:55: uint8_t i = 6; |
|||
;source-doc/keyboard/kyb_driver.c:56: uint8_t *a = previous.keyCode; |
|||
ld b,0x06 |
|||
ld hl,+(_previous + 2) |
|||
l_keyboard_buf_put_00106: |
|||
;source-doc/keyboard/kyb_driver.c:57: do { |
|||
ld a, (hl) |
|||
inc hl |
|||
sub c |
|||
;source-doc/keyboard/kyb_driver.c:58: if (*a++ == key_code) |
|||
ret Z |
|||
;source-doc/keyboard/kyb_driver.c:59: return; |
|||
djnz l_keyboard_buf_put_00106 |
|||
;source-doc/keyboard/kyb_driver.c:61: |
|||
ld a, (_write_index) |
|||
inc a |
|||
and 0x07 |
|||
ld b, a |
|||
;source-doc/keyboard/kyb_driver.c:62: uint8_t next_write_index = (write_index + 1) & KEYBOARD_BUFFER_SIZE_MASK; |
|||
ld a,(_read_index) |
|||
sub b |
|||
ret Z |
|||
;source-doc/keyboard/kyb_driver.c:63: if (next_write_index != read_index) { // Check if buffer is not full |
|||
ld de,_buffer+0 |
|||
ld hl, (_write_index) |
|||
ld h,0x00 |
|||
add hl, hl |
|||
add hl, de |
|||
ex de, hl |
|||
ld hl,(_report) |
|||
xor a |
|||
xor a |
|||
ld a, c |
|||
ld (de), a |
|||
inc de |
|||
ld a, l |
|||
ld (de), a |
|||
;source-doc/keyboard/kyb_driver.c:64: buffer[write_index] = (uint16_t)report.bModifierKeys << 8 | (uint16_t)key_code; |
|||
ld hl,_write_index |
|||
ld (hl), b |
|||
l_keyboard_buf_put_00111: |
|||
;source-doc/keyboard/kyb_driver.c:66: } |
|||
ret |
|||
;source-doc/keyboard/kyb_driver.c:68: |
|||
; --------------------------------- |
|||
; Function usb_kyb_buf_size |
|||
; --------------------------------- |
|||
_usb_kyb_buf_size: |
|||
;source-doc/keyboard/kyb_driver.c:72: |
|||
ld a,(_alt_write_index) |
|||
ld hl,_alt_read_index |
|||
sub (hl) |
|||
jr C,l_usb_kyb_buf_size_00102 |
|||
;source-doc/keyboard/kyb_driver.c:73: if (alt_write_index >= alt_read_index) |
|||
ld a,(_alt_write_index) |
|||
ld hl,_alt_read_index |
|||
sub (hl) |
|||
ld d, a |
|||
jr l_usb_kyb_buf_size_00103 |
|||
l_usb_kyb_buf_size_00102: |
|||
;source-doc/keyboard/kyb_driver.c:75: else |
|||
ld hl, (_alt_read_index) |
|||
ld a,0x08 |
|||
sub l |
|||
ld hl, (_alt_write_index) |
|||
add a, l |
|||
ld d, a |
|||
l_usb_kyb_buf_size_00103: |
|||
;source-doc/keyboard/kyb_driver.c:77: |
|||
ld a, d |
|||
or a |
|||
jr Z,l_usb_kyb_buf_size_00105 |
|||
;source-doc/keyboard/kyb_driver.c:78: if (alt_size != 0) |
|||
ld a, (_alt_read_index) |
|||
inc a |
|||
and 0x07 |
|||
ld (_alt_read_index),a |
|||
l_usb_kyb_buf_size_00105: |
|||
;source-doc/keyboard/kyb_driver.c:80: |
|||
ld a,(_write_index) |
|||
ld hl,_read_index |
|||
sub (hl) |
|||
jr C,l_usb_kyb_buf_size_00107 |
|||
;source-doc/keyboard/kyb_driver.c:81: if (write_index >= read_index) |
|||
ld a,(_write_index) |
|||
ld hl,_read_index |
|||
sub (hl) |
|||
ld e, a |
|||
jr l_usb_kyb_buf_size_00108 |
|||
l_usb_kyb_buf_size_00107: |
|||
;source-doc/keyboard/kyb_driver.c:83: else |
|||
ld hl, (_read_index) |
|||
ld a,0x08 |
|||
sub l |
|||
ld hl, (_write_index) |
|||
add a, l |
|||
ld e, a |
|||
l_usb_kyb_buf_size_00108: |
|||
;source-doc/keyboard/kyb_driver.c:85: |
|||
xor a |
|||
xor a |
|||
ex de, hl |
|||
;source-doc/keyboard/kyb_driver.c:86: return (uint16_t)alt_size << 8 | (uint16_t)size; |
|||
ret |
|||
;source-doc/keyboard/kyb_driver.c:88: |
|||
; --------------------------------- |
|||
; Function usb_kyb_buf_get_next |
|||
; --------------------------------- |
|||
_usb_kyb_buf_get_next: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
push af |
|||
push af |
|||
;source-doc/keyboard/kyb_driver.c:89: uint32_t usb_kyb_buf_get_next() { |
|||
ld a,(_write_index) |
|||
ld hl,_read_index |
|||
sub (hl) |
|||
jr NZ,l_usb_kyb_buf_get_next_00102 |
|||
;source-doc/keyboard/kyb_driver.c:90: if (write_index == read_index) // Check if buffer is empty |
|||
ld hl,0xff00 |
|||
ld e, l |
|||
ld d, l |
|||
jr l_usb_kyb_buf_get_next_00103 |
|||
l_usb_kyb_buf_get_next_00102: |
|||
;source-doc/keyboard/kyb_driver.c:92: |
|||
ld bc,_buffer+0 |
|||
ld hl, (_read_index) |
|||
ld h,0x00 |
|||
add hl, hl |
|||
add hl, bc |
|||
ld c, (hl) |
|||
inc hl |
|||
ld b, (hl) |
|||
;source-doc/keyboard/kyb_driver.c:93: const uint8_t modifier_key = buffer[read_index] >> 8; |
|||
;source-doc/keyboard/kyb_driver.c:94: const uint8_t key_code = buffer[read_index] & 255; |
|||
ld a, (_read_index) |
|||
inc a |
|||
and 0x07 |
|||
ld (_read_index),a |
|||
;source-doc/keyboard/kyb_driver.c:101: |
|||
push bc |
|||
ld l, c |
|||
ld a, b |
|||
call _scancode_to_char |
|||
ld e, a |
|||
pop bc |
|||
;source-doc/keyboard/kyb_driver.c:103: /* D = modifier, e-> char, H = 0, L=>code */ |
|||
xor a |
|||
ld (ix-1),b |
|||
xor a |
|||
ld (ix-4),a |
|||
ld (ix-3),a |
|||
ld (ix-2),a |
|||
xor a |
|||
ld d,(ix-1) |
|||
ld (ix-4),c |
|||
xor a |
|||
ld (ix-3),a |
|||
ld (ix-2),a |
|||
ld (ix-1),a |
|||
pop hl |
|||
push hl |
|||
l_usb_kyb_buf_get_next_00103: |
|||
;source-doc/keyboard/kyb_driver.c:104: return (uint32_t)modifier_key << 24 | (uint32_t)c << 16 | key_code; |
|||
ld sp, ix |
|||
pop ix |
|||
ret |
|||
;source-doc/keyboard/kyb_driver.c:106: |
|||
; --------------------------------- |
|||
; Function usb_kyb_flush |
|||
; --------------------------------- |
|||
_usb_kyb_flush: |
|||
;source-doc/keyboard/kyb_driver.c:107: void usb_kyb_flush() { |
|||
xor a |
|||
ld (_alt_read_index),a |
|||
ld (_alt_write_index),a |
|||
xor a |
|||
ld (_read_index),a |
|||
ld (_write_index),a |
|||
;source-doc/keyboard/kyb_driver.c:110: uint8_t i = sizeof(previous); |
|||
ld de,_previous+0 |
|||
;source-doc/keyboard/kyb_driver.c:111: uint8_t *a = (uint8_t *)previous; |
|||
;source-doc/keyboard/kyb_driver.c:112: uint8_t *b = (uint8_t *)report; |
|||
ld b,0x08 |
|||
ld hl,_report |
|||
l_usb_kyb_flush_00101: |
|||
;source-doc/keyboard/kyb_driver.c:113: do { |
|||
xor a |
|||
ld (de), a |
|||
inc de |
|||
;source-doc/keyboard/kyb_driver.c:114: *a++ = 0; |
|||
ld (hl),0x00 |
|||
inc hl |
|||
;source-doc/keyboard/kyb_driver.c:115: *b++ = 0; |
|||
djnz l_usb_kyb_flush_00101 |
|||
;source-doc/keyboard/kyb_driver.c:116: } while (--i != 0); |
|||
ret |
|||
;source-doc/keyboard/kyb_driver.c:118: |
|||
; --------------------------------- |
|||
; Function usb_kyb_tick |
|||
; --------------------------------- |
|||
_usb_kyb_tick: |
|||
;source-doc/keyboard/kyb_driver.c:119: void usb_kyb_tick(void) { |
|||
ld hl,_in_critical_usb_section |
|||
ld a, (hl) |
|||
or a |
|||
;source-doc/keyboard/kyb_driver.c:120: if (is_in_critical_section()) |
|||
jr NZ,l_usb_kyb_tick_00112 |
|||
;././source-doc/base-drv//ch376.h:111: #endif |
|||
ld l,0x0b |
|||
call _ch_command |
|||
;././source-doc/base-drv//ch376.h:112: |
|||
ld a,0x25 |
|||
ld bc,_CH376_DATA_PORT |
|||
out (c), a |
|||
;././source-doc/base-drv//ch376.h:113: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF) |
|||
ld a,0x1f |
|||
ld bc,_CH376_DATA_PORT |
|||
out (c), a |
|||
;source-doc/keyboard/kyb_driver.c:123: ch_configure_nak_retry_disable(); |
|||
ld bc,_report+0 |
|||
ld hl, (_keyboard_config) |
|||
ld a,0x08 |
|||
push af |
|||
inc sp |
|||
push bc |
|||
push hl |
|||
call _usbdev_dat_in_trnsfer_0 |
|||
pop af |
|||
pop af |
|||
inc sp |
|||
ld a, l |
|||
ld (_result), a |
|||
;././source-doc/base-drv//ch376.h:111: #endif |
|||
ld l,0x0b |
|||
call _ch_command |
|||
;././source-doc/base-drv//ch376.h:112: |
|||
ld a,0x25 |
|||
ld bc,_CH376_DATA_PORT |
|||
out (c), a |
|||
;././source-doc/base-drv//ch376.h:113: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF) |
|||
ld a,0xdf |
|||
ld bc,_CH376_DATA_PORT |
|||
out (c), a |
|||
;source-doc/keyboard/kyb_driver.c:125: ch_configure_nak_retry_3s(); |
|||
ld hl,_result |
|||
ld a, (hl) |
|||
or a |
|||
jr NZ,l_usb_kyb_tick_00112 |
|||
;source-doc/keyboard/kyb_driver.c:126: if (result == 0) { |
|||
call _report_diff |
|||
or a |
|||
jr Z,l_usb_kyb_tick_00112 |
|||
;source-doc/keyboard/kyb_driver.c:127: if (report_diff()) { |
|||
call _report_put |
|||
;source-doc/keyboard/kyb_driver.c:129: uint8_t i = 6; |
|||
ld b,0x06 |
|||
l_usb_kyb_tick_00103: |
|||
;source-doc/keyboard/kyb_driver.c:130: do { |
|||
ld a, b |
|||
dec a |
|||
push bc |
|||
call _keyboard_buf_put |
|||
pop bc |
|||
;source-doc/keyboard/kyb_driver.c:131: keyboard_buf_put(i - 1); |
|||
djnz l_usb_kyb_tick_00103 |
|||
;source-doc/keyboard/kyb_driver.c:132: } while (--i != 0); |
|||
ld de,_previous |
|||
ld bc,0x0008 |
|||
ld hl,_report |
|||
ldir |
|||
l_usb_kyb_tick_00112: |
|||
;source-doc/keyboard/kyb_driver.c:135: } |
|||
ret |
|||
;source-doc/keyboard/kyb_driver.c:137: |
|||
; --------------------------------- |
|||
; Function usb_kyb_init |
|||
; --------------------------------- |
|||
_usb_kyb_init: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
;source-doc/keyboard/kyb_driver.c:139: uint8_t result; |
|||
ld a,(ix+4) |
|||
call _get_usb_device_config |
|||
ex de, hl |
|||
ld (_keyboard_config), hl |
|||
;source-doc/keyboard/kyb_driver.c:141: |
|||
ld hl,_keyboard_config + 1 |
|||
ld a, (hl) |
|||
dec hl |
|||
or (hl) |
|||
jr NZ,l_usb_kyb_init_00102 |
|||
;source-doc/keyboard/kyb_driver.c:142: if (keyboard_config == NULL) |
|||
ld l,0x0f |
|||
jr l_usb_kyb_init_00106 |
|||
l_usb_kyb_init_00102: |
|||
;source-doc/keyboard/kyb_driver.c:144: |
|||
ld a,0x01 |
|||
push af |
|||
inc sp |
|||
ld hl, (_keyboard_config) |
|||
call _hid_set_protocol |
|||
ld l, a |
|||
or a |
|||
jr NZ,l_usb_kyb_init_00105 |
|||
;source-doc/keyboard/kyb_driver.c:145: CHECK(hid_set_protocol(keyboard_config, 1)); |
|||
ld a,0x80 |
|||
push af |
|||
inc sp |
|||
ld hl, (_keyboard_config) |
|||
call _hid_set_idle |
|||
ld l, a |
|||
;source-doc/keyboard/kyb_driver.c:147: |
|||
;source-doc/keyboard/kyb_driver.c:148: done: |
|||
l_usb_kyb_init_00105: |
|||
l_usb_kyb_init_00106: |
|||
;source-doc/keyboard/kyb_driver.c:149: return result; |
|||
pop ix |
|||
ret |
|||
_keyboard_config: |
|||
DEFW +0x0000 |
|||
_buffer: |
|||
DEFW +0x0000 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
_write_index: |
|||
DEFB +0x00 |
|||
_read_index: |
|||
DEFB +0x00 |
|||
_alt_write_index: |
|||
DEFB +0x00 |
|||
_alt_read_index: |
|||
DEFB +0x00 |
|||
_reports: |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
_queued_report: |
|||
DEFW +0x0000 |
|||
_report: |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
_previous: |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
@ -1,3 +1,4 @@ |
|||
; Generated File -- not to be modify directly |
|||
#include "ch376-native/scsi-drv/class_scsi.c.s" |
|||
#include "ch376-native/scsi-drv/scsi-init.c.s" |
|||
#include "ch376-native/scsi-drv/scsi_driver.c.s" |
|||
|
|||
@ -0,0 +1,482 @@ |
|||
; |
|||
; Generated from source-doc/scsi-drv/scsi_driver.c.asm -- not to be modify directly |
|||
; |
|||
; |
|||
;-------------------------------------------------------- |
|||
; File Created by SDCC : free open source ISO C Compiler |
|||
; Version 4.5.0 #15248 (Linux) |
|||
;-------------------------------------------------------- |
|||
; Processed by Z88DK |
|||
;-------------------------------------------------------- |
|||
|
|||
|
|||
;-------------------------------------------------------- |
|||
; Public variables in this module |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Externals used |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; special function registers |
|||
;-------------------------------------------------------- |
|||
_CH376_DATA_PORT .EQU 0xff88 |
|||
_CH376_COMMAND_PORT .EQU 0xff89 |
|||
_USB_MODULE_LEDS .EQU 0xff8a |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
|
|||
#IF 0 |
|||
|
|||
; .area _INITIALIZED removed by z88dk |
|||
|
|||
_scsi_packet_read_capacity: |
|||
DEFS 12 |
|||
_cbw: |
|||
DEFS 27 |
|||
|
|||
#ENDIF |
|||
|
|||
;-------------------------------------------------------- |
|||
; absolute external ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; global & static initialisations |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Home |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; code |
|||
;-------------------------------------------------------- |
|||
;source-doc/scsi-drv/scsi_driver.c:8: usb_error usb_scsi_init(const uint16_t dev_index) { |
|||
; --------------------------------- |
|||
; Function usb_scsi_init |
|||
; --------------------------------- |
|||
_usb_scsi_init: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
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); |
|||
ld a,(ix+4) |
|||
call _get_usb_device_config |
|||
;source-doc/scsi-drv/scsi_driver.c:14: critical_begin(); |
|||
push de |
|||
call _critical_begin |
|||
pop de |
|||
;source-doc/scsi-drv/scsi_driver.c:15: while ((result = scsi_test(dev)) && --counter > 0) |
|||
ld c,0x03 |
|||
l_usb_scsi_init_00102: |
|||
push bc |
|||
push de |
|||
push de |
|||
call _scsi_test |
|||
pop af |
|||
ld a, l |
|||
pop de |
|||
pop bc |
|||
ld (_result),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 |
|||
push bc |
|||
push de |
|||
push hl |
|||
push de |
|||
call _scsi_request_sense |
|||
pop af |
|||
pop af |
|||
pop de |
|||
pop bc |
|||
jr l_usb_scsi_init_00102 |
|||
l_usb_scsi_init_00104: |
|||
;source-doc/scsi-drv/scsi_driver.c:17: critical_end(); |
|||
call _critical_end |
|||
;source-doc/scsi-drv/scsi_driver.c:19: return result; |
|||
ld hl, (_result) |
|||
;source-doc/scsi-drv/scsi_driver.c:20: } |
|||
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) { |
|||
; --------------------------------- |
|||
; Function usb_scsi_read_capacity |
|||
; --------------------------------- |
|||
_usb_scsi_read_capacity: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
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); |
|||
ld a,(ix+4) |
|||
call _get_usb_device_config |
|||
;source-doc/scsi-drv/scsi_driver.c:28: cbw_scsi.cbw = scsi_command_block_wrapper; |
|||
push de |
|||
ld hl,2 |
|||
add hl, sp |
|||
ex de, hl |
|||
ld bc,0x000f |
|||
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; |
|||
push de |
|||
ld hl,17 |
|||
add hl, sp |
|||
ex de, hl |
|||
ld bc,0x000c |
|||
ld hl,_scsi_packet_read_capacity |
|||
ldir |
|||
pop de |
|||
;source-doc/scsi-drv/scsi_driver.c:31: 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); |
|||
ld (ix-13),0x0c |
|||
;source-doc/scsi-drv/scsi_driver.c:33: 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); |
|||
ld c,(ix+6) |
|||
ld b,(ix+7) |
|||
xor a |
|||
push af |
|||
inc sp |
|||
push bc |
|||
ld hl,3 |
|||
add hl, sp |
|||
push hl |
|||
push de |
|||
call _do_scsi_cmd |
|||
pop af |
|||
pop af |
|||
pop af |
|||
inc sp |
|||
;source-doc/scsi-drv/scsi_driver.c:36: } |
|||
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) { |
|||
; --------------------------------- |
|||
; Function usb_scsi_read |
|||
; --------------------------------- |
|||
_usb_scsi_read: |
|||
push ix |
|||
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); |
|||
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)); |
|||
ld de,_cbw |
|||
ld l, e |
|||
ld h, d |
|||
ld b,0x0e |
|||
jr l_usb_scsi_read_00113 |
|||
l_usb_scsi_read_00112: |
|||
ld (hl),0x00 |
|||
inc hl |
|||
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; |
|||
ld bc,0x000f |
|||
ld hl,_scsi_command_block_wrapper |
|||
ldir |
|||
;source-doc/scsi-drv/scsi_driver.c:62: 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); |
|||
ld hl,_cbw + 14 |
|||
ld (hl),0x0c |
|||
;source-doc/scsi-drv/scsi_driver.c:64: 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 |
|||
ld hl,_cbw + 15 |
|||
ld (hl),0x28 |
|||
;source-doc/scsi-drv/scsi_driver.c:67: 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 |
|||
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 |
|||
inc hl |
|||
inc 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) |
|||
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 |
|||
xor a |
|||
push af |
|||
inc sp |
|||
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) |
|||
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) |
|||
inc hl |
|||
ld d, (hl) |
|||
inc hl |
|||
ld a,(hl) |
|||
inc hl |
|||
ld h,(hl) |
|||
ld l,a |
|||
inc e |
|||
jr NZ,l_usb_scsi_read_00114 |
|||
inc d |
|||
jr NZ,l_usb_scsi_read_00114 |
|||
inc hl |
|||
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 |
|||
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: } |
|||
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) { |
|||
; --------------------------------- |
|||
; Function usb_scsi_write |
|||
; --------------------------------- |
|||
_usb_scsi_write: |
|||
push ix |
|||
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); |
|||
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)); |
|||
ld de,_cbw |
|||
ld l, e |
|||
ld h, d |
|||
ld b,0x0e |
|||
jr l_usb_scsi_write_00113 |
|||
l_usb_scsi_write_00112: |
|||
ld (hl),0x00 |
|||
inc hl |
|||
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; |
|||
ld bc,0x000f |
|||
ld hl,_scsi_command_block_wrapper |
|||
ldir |
|||
;source-doc/scsi-drv/scsi_driver.c:86: 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); |
|||
ld hl,_cbw + 14 |
|||
ld (hl),0x0c |
|||
;source-doc/scsi-drv/scsi_driver.c:88: 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 |
|||
ld hl,_cbw + 15 |
|||
ld (hl),0x2a |
|||
;source-doc/scsi-drv/scsi_driver.c:91: 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 |
|||
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 |
|||
inc hl |
|||
inc 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) |
|||
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,0x01 |
|||
push af |
|||
inc sp |
|||
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) |
|||
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) |
|||
inc hl |
|||
ld d, (hl) |
|||
inc hl |
|||
ld a,(hl) |
|||
inc hl |
|||
ld h,(hl) |
|||
ld l,a |
|||
inc e |
|||
jr NZ,l_usb_scsi_write_00114 |
|||
inc d |
|||
jr NZ,l_usb_scsi_write_00114 |
|||
inc hl |
|||
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 |
|||
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: } |
|||
ld sp, ix |
|||
pop ix |
|||
ret |
|||
_scsi_packet_read_capacity: |
|||
DEFB +0x25 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
_cbw: |
|||
DEFB +0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB +0x00,0x00, +0x00, +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB +0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB +0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
DEFB +0x00 |
|||
DEFB 0x00 |
|||
DEFB 0x00 |
|||
@ -1,69 +0,0 @@ |
|||
#include "usb_init.h" |
|||
#include "ch376.h" |
|||
#include "enumerate.h" |
|||
#include "work-area.h" |
|||
#include <string.h> |
|||
|
|||
static usb_error usb_host_bus_reset(void) { |
|||
ch_cmd_set_usb_mode(CH_MODE_HOST); |
|||
delay_20ms(); |
|||
|
|||
ch_cmd_set_usb_mode(CH_MODE_HOST_RESET); |
|||
delay_20ms(); |
|||
|
|||
ch_cmd_set_usb_mode(CH_MODE_HOST); |
|||
delay_20ms(); |
|||
|
|||
ch_configure_nak_retry_3s(); |
|||
|
|||
return USB_ERR_OK; |
|||
} |
|||
|
|||
#define ERASE_LINE "\x1B\x6C\r$" |
|||
|
|||
uint16_t usb_init(uint8_t state) __z88dk_fastcall { |
|||
uint8_t r; |
|||
|
|||
USB_MODULE_LEDS = 0x03; |
|||
|
|||
if (state == 0) { |
|||
ch_cmd_reset_all(); |
|||
delay_medium(); |
|||
|
|||
if (!ch_probe()) { |
|||
USB_MODULE_LEDS = 0x00; |
|||
return 0xFF00; |
|||
} |
|||
USB_MODULE_LEDS = 0x00; |
|||
return 1; |
|||
} |
|||
|
|||
if (state == 1) { |
|||
r = ch_cmd_get_ic_version(); |
|||
|
|||
USB_MODULE_LEDS = 0x00; |
|||
return (uint16_t)r << 8 | 2; |
|||
} |
|||
|
|||
if (state == 2) { |
|||
usb_host_bus_reset(); |
|||
|
|||
r = ch_very_short_wait_int_and_get_status(); |
|||
|
|||
if (r != USB_INT_CONNECT) { |
|||
USB_MODULE_LEDS = 0x00; |
|||
return 2; |
|||
} |
|||
|
|||
return 3; |
|||
} |
|||
|
|||
memset(get_usb_work_area(), 0, sizeof(_usb_state)); |
|||
if (state != 2) { |
|||
usb_host_bus_reset(); |
|||
delay_medium(); |
|||
} |
|||
enumerate_all_devices(); |
|||
USB_MODULE_LEDS = 0x00; |
|||
return (uint16_t)count_of_devices() << 8 | 4; |
|||
} |
|||
@ -1,8 +0,0 @@ |
|||
#ifndef __USB_INIT |
|||
#define __USB_INIT |
|||
|
|||
#include <stdint.h> |
|||
|
|||
extern uint16_t usb_init(uint8_t state) __z88dk_fastcall; |
|||
|
|||
#endif |
|||
@ -0,0 +1,150 @@ |
|||
#include "kyb_driver.h" |
|||
#include "class_hid.h" |
|||
#include "class_hid_keyboard.h" |
|||
#include <critical-section.h> |
|||
#include <dev_transfers.h> |
|||
#include <stdint.h> |
|||
#include <usb_state.h> |
|||
|
|||
#define KEYBOARD_BUFFER_SIZE 8 |
|||
#define KEYBOARD_BUFFER_SIZE_MASK 7 |
|||
typedef uint16_t modifier_and_code_t; |
|||
|
|||
static device_config_keyboard *keyboard_config = 0; |
|||
|
|||
static modifier_and_code_t buffer[KEYBOARD_BUFFER_SIZE] = {0}; |
|||
static uint8_t write_index = 0; |
|||
static uint8_t read_index = 0; |
|||
|
|||
static uint8_t alt_write_index = 0; |
|||
static uint8_t alt_read_index = 0; |
|||
static keyboard_report_t reports[KEYBOARD_BUFFER_SIZE] = {{0}}; |
|||
|
|||
static keyboard_report_t *queued_report = NULL; |
|||
static keyboard_report_t report = {0}; |
|||
static keyboard_report_t previous = {0}; |
|||
|
|||
static uint8_t report_diff() __sdcccall(1) { |
|||
uint8_t *a = (uint8_t *)&report; |
|||
uint8_t *b = (uint8_t *)&previous; |
|||
|
|||
uint8_t i = sizeof(report); |
|||
do { |
|||
if (*a++ != *b++) |
|||
return true; |
|||
} while (--i != 0); |
|||
|
|||
return false; |
|||
} |
|||
|
|||
static void report_put() { |
|||
uint8_t next_write_index = (alt_write_index + 1) & KEYBOARD_BUFFER_SIZE_MASK; |
|||
|
|||
if (next_write_index != alt_read_index) { // Check if buffer is not full
|
|||
reports[alt_write_index] = report; |
|||
alt_write_index = next_write_index; |
|||
} |
|||
} |
|||
|
|||
static void keyboard_buf_put(const uint8_t indx) __sdcccall(1) { |
|||
const uint8_t key_code = report.keyCode[indx]; |
|||
if (key_code >= 0x80 || key_code == 0) |
|||
return; // ignore ???
|
|||
|
|||
// if already reported, just skip it
|
|||
uint8_t i = 6; |
|||
uint8_t *a = previous.keyCode; |
|||
do { |
|||
if (*a++ == key_code) |
|||
return; |
|||
} while (--i != 0); |
|||
|
|||
uint8_t next_write_index = (write_index + 1) & KEYBOARD_BUFFER_SIZE_MASK; |
|||
if (next_write_index != read_index) { // Check if buffer is not full
|
|||
buffer[write_index] = (uint16_t)report.bModifierKeys << 8 | (uint16_t)key_code; |
|||
write_index = next_write_index; |
|||
} |
|||
} |
|||
|
|||
uint16_t usb_kyb_buf_size() { |
|||
uint8_t size; |
|||
uint8_t alt_size; |
|||
|
|||
if (alt_write_index >= alt_read_index) |
|||
alt_size = alt_write_index - alt_read_index; |
|||
else |
|||
alt_size = KEYBOARD_BUFFER_SIZE - alt_read_index + alt_write_index; |
|||
|
|||
if (alt_size != 0) |
|||
alt_read_index = (alt_read_index + 1) & KEYBOARD_BUFFER_SIZE_MASK; |
|||
|
|||
if (write_index >= read_index) |
|||
size = write_index - read_index; |
|||
else |
|||
size = KEYBOARD_BUFFER_SIZE - read_index + write_index; |
|||
|
|||
return (uint16_t)alt_size << 8 | (uint16_t)size; |
|||
} |
|||
|
|||
uint32_t usb_kyb_buf_get_next() { |
|||
if (write_index == read_index) // Check if buffer is empty
|
|||
return 0x0000FF00; // H = -1, D, E, L = 0
|
|||
|
|||
const uint8_t modifier_key = buffer[read_index] >> 8; |
|||
const uint8_t key_code = buffer[read_index] & 255; |
|||
read_index = (read_index + 1) & KEYBOARD_BUFFER_SIZE_MASK; |
|||
|
|||
// D: Modifier keys - aka Keystate
|
|||
// E: ASCII Code
|
|||
// H: 0
|
|||
// L: KeyCode aka scan code
|
|||
|
|||
const unsigned char c = scancode_to_char(modifier_key, key_code); |
|||
/* D = modifier, e-> char, H = 0, L=>code */ |
|||
return (uint32_t)modifier_key << 24 | (uint32_t)c << 16 | key_code; |
|||
} |
|||
|
|||
void usb_kyb_flush() { |
|||
write_index = read_index = alt_write_index = alt_read_index = 0; |
|||
|
|||
uint8_t i = sizeof(previous); |
|||
uint8_t *a = (uint8_t *)previous; |
|||
uint8_t *b = (uint8_t *)report; |
|||
do { |
|||
*a++ = 0; |
|||
*b++ = 0; |
|||
} while (--i != 0); |
|||
} |
|||
|
|||
void usb_kyb_tick(void) { |
|||
if (is_in_critical_section()) |
|||
return; |
|||
|
|||
ch_configure_nak_retry_disable(); |
|||
result = usbdev_dat_in_trnsfer_0((device_config *)keyboard_config, (uint8_t *)&report, 8); |
|||
ch_configure_nak_retry_3s(); |
|||
if (result == 0) { |
|||
if (report_diff()) { |
|||
report_put(); |
|||
uint8_t i = 6; |
|||
do { |
|||
keyboard_buf_put(i - 1); |
|||
} while (--i != 0); |
|||
previous = report; |
|||
} |
|||
} |
|||
} |
|||
|
|||
usb_error usb_kyb_init(const uint8_t dev_index) { |
|||
uint8_t result; |
|||
keyboard_config = (device_config_keyboard *)get_usb_device_config(dev_index); |
|||
|
|||
if (keyboard_config == NULL) |
|||
return USB_ERR_OTHER; |
|||
|
|||
CHECK(hid_set_protocol(keyboard_config, 1)); |
|||
return hid_set_idle(keyboard_config, 0x80); |
|||
|
|||
done: |
|||
return result; |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
#ifndef __KYB_DRIVER__ |
|||
#define __KYB_DRIVER__ |
|||
|
|||
#include <ch376.h> |
|||
#include <stdint.h> |
|||
|
|||
extern usb_error usb_kyb_init(const uint8_t dev_index); |
|||
extern void usb_kyb_flush(); |
|||
extern uint32_t usb_kyb_buf_get_next(); |
|||
extern uint16_t usb_kyb_buf_size(); |
|||
|
|||
#endif |
|||
@ -0,0 +1,118 @@ |
|||
#include "scsi_driver.h" |
|||
#include "class_scsi.h" |
|||
#include <ch376.h> |
|||
#include <critical-section.h> |
|||
#include <string.h> |
|||
#include <usb_state.h> |
|||
|
|||
usb_error usb_scsi_init(const uint16_t dev_index) { |
|||
device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); |
|||
|
|||
scsi_sense_result response; |
|||
uint8_t counter = 3; |
|||
|
|||
critical_begin(); |
|||
while ((result = scsi_test(dev)) && --counter > 0) |
|||
scsi_request_sense(dev, &response); |
|||
critical_end(); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
_scsi_read_capacity scsi_packet_read_capacity = {0x25, 0, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0}}; |
|||
|
|||
usb_error usb_scsi_read_capacity(const uint16_t dev_index, scsi_read_capacity_result *cap_result) { |
|||
device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); |
|||
|
|||
cbw_scsi_read_capacity cbw_scsi; |
|||
cbw_scsi.cbw = scsi_command_block_wrapper; |
|||
cbw_scsi.read_capacity = scsi_packet_read_capacity; |
|||
|
|||
cbw_scsi.cbw.bCBWLUN = 0; |
|||
cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_read_capacity); |
|||
cbw_scsi.cbw.dCBWDataTransferLength = sizeof(scsi_read_capacity_result); |
|||
|
|||
return do_scsi_cmd(dev, &cbw_scsi.cbw, cap_result, false); |
|||
} |
|||
|
|||
// _scsi_packet_inquiry scsi_packet_inquiry = {0x12, 0, 0, 0, 0x24, 0, {0, 0, 0, 0, 0, 0}};
|
|||
|
|||
// usb_error usb_scsi_inquiry(const uint16_t dev_index, scsi_inquiry_result *inq_result) {
|
|||
// device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index);
|
|||
|
|||
// cbw_scsi_inquiry cbw_scsi;
|
|||
// cbw_scsi.cbw = scsi_command_block_wrapper;
|
|||
// cbw_scsi.inquiry = scsi_packet_inquiry;
|
|||
|
|||
// cbw_scsi.cbw.bCBWLUN = 0;
|
|||
// cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_inquiry);
|
|||
// cbw_scsi.cbw.dCBWDataTransferLength = 0x24;
|
|||
|
|||
// return do_scsi_cmd(dev, &cbw_scsi.cbw, inq_result, false);
|
|||
// }
|
|||
|
|||
static cbw_scsi_read_write cbw = {{{0}}}; |
|||
|
|||
usb_error usb_scsi_read(const uint16_t dev_index, uint8_t *const buffer) { |
|||
device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); |
|||
|
|||
memset(&cbw, 0, sizeof(cbw_scsi_read_write)); |
|||
cbw.cbw = scsi_command_block_wrapper; |
|||
|
|||
cbw.cbw.bCBWLUN = 0; |
|||
cbw.cbw.bCBWCBLength = sizeof(_scsi_packet_read_write); |
|||
cbw.cbw.dCBWDataTransferLength = 512; |
|||
|
|||
cbw.scsi_cmd.operation_code = 0x28; // read operation
|
|||
cbw.scsi_cmd.transfer_len[1] = 1; |
|||
cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; |
|||
cbw.scsi_cmd.lba[1] = dev->current_lba >> 16; |
|||
cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; |
|||
cbw.scsi_cmd.lba[3] = dev->current_lba; |
|||
|
|||
result = do_scsi_cmd(dev, &cbw.cbw, buffer, false); |
|||
|
|||
if (result == USB_ERR_OK) |
|||
dev->current_lba++; |
|||
return result; |
|||
} |
|||
|
|||
usb_error usb_scsi_write(const uint16_t dev_index, uint8_t *const buffer) { |
|||
device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); |
|||
|
|||
memset(&cbw, 0, sizeof(cbw_scsi_read_write)); |
|||
cbw.cbw = scsi_command_block_wrapper; |
|||
|
|||
cbw.cbw.bCBWLUN = 0; |
|||
cbw.cbw.bCBWCBLength = sizeof(_scsi_packet_read_write); |
|||
cbw.cbw.dCBWDataTransferLength = 512; |
|||
|
|||
cbw.scsi_cmd.operation_code = 0x2A; // write operation
|
|||
cbw.scsi_cmd.transfer_len[1] = 1; |
|||
cbw.scsi_cmd.lba[0] = dev->current_lba >> 24; |
|||
cbw.scsi_cmd.lba[1] = dev->current_lba >> 16; |
|||
cbw.scsi_cmd.lba[2] = dev->current_lba >> 8; |
|||
cbw.scsi_cmd.lba[3] = dev->current_lba; |
|||
|
|||
result = do_scsi_cmd(dev, &cbw.cbw, buffer, true); |
|||
|
|||
if (result == USB_ERR_OK) |
|||
dev->current_lba++; |
|||
return result; |
|||
} |
|||
|
|||
// usb_error scsi_eject(device_config_storage *const dev) {
|
|||
// cbw_scsi_eject cbw_scsi;
|
|||
// cbw_scsi.cbw = scsi_command_block_wrapper;
|
|||
|
|||
// memset(&cbw_scsi.eject, 0, sizeof(_scsi_packet_eject));
|
|||
|
|||
// cbw_scsi.eject.operation_code = 0x1B;
|
|||
// cbw_scsi.eject.loej = 1;
|
|||
|
|||
// cbw_scsi.cbw.bCBWLUN = 0;
|
|||
// cbw_scsi.cbw.bCBWCBLength = sizeof(_scsi_packet_eject);
|
|||
// cbw_scsi.cbw.dCBWDataTransferLength = 0;
|
|||
|
|||
// return do_scsi_cmd(dev, &cbw_scsi.cbw, 0, false);
|
|||
// }
|
|||
@ -0,0 +1,14 @@ |
|||
#ifndef __SCSI_DRIVER__ |
|||
#define __SCSI_DRIVER__ |
|||
|
|||
#include "class_scsi.h" |
|||
#include <ch376.h> |
|||
#include <stdint.h> |
|||
|
|||
extern usb_error usb_scsi_init(const uint16_t dev_index); |
|||
extern usb_error usb_scsi_read_capacity(const uint16_t dev_index, scsi_read_capacity_result *result); |
|||
extern usb_error usb_scsi_read(const uint16_t dev_index, uint8_t *const buffer); |
|||
extern usb_error usb_scsi_write(const uint16_t dev_index, uint8_t *const buffer); |
|||
extern usb_error usb_scsi_seek(const uint16_t dev_index, const uint32_t lba); |
|||
|
|||
#endif |
|||
@ -0,0 +1,85 @@ |
|||
#include "ufi_driver.h" |
|||
#include "class_ufi.h" |
|||
#include <dev_transfers.h> |
|||
#include <string.h> |
|||
|
|||
uint32_t usb_ufi_get_cap(const uint16_t dev_index) { |
|||
device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); |
|||
|
|||
ufi_format_capacities_response response; |
|||
memset(&response, 0, sizeof(ufi_format_capacities_response)); |
|||
|
|||
wait_for_device_ready(dev, 25); |
|||
|
|||
// not sure if we need to do this to 'clear' some state
|
|||
ufi_inquiry_response inquiry; |
|||
ufi_inquiry(dev, &inquiry); |
|||
|
|||
wait_for_device_ready(dev, 15); |
|||
|
|||
const usb_error result = ufi_read_frmt_caps(dev, &response); |
|||
if (result != USB_ERR_OK) |
|||
return 0; |
|||
|
|||
return convert_from_msb_first(response.descriptors[0].number_of_blocks); |
|||
} |
|||
|
|||
uint8_t usb_ufi_read(const uint16_t dev_index, uint8_t *const buffer) { |
|||
device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); |
|||
|
|||
if (wait_for_device_ready((device_config *)dev, 20) != 0) |
|||
return -1; // Not READY!
|
|||
|
|||
usb_error result; |
|||
ufi_interrupt_status sense_codes; |
|||
|
|||
memset(&sense_codes, 0, sizeof(sense_codes)); |
|||
|
|||
if (ufi_read_write_sector((device_config *)dev, false, dev->current_lba, 1, buffer, (uint8_t *)&sense_codes) != USB_ERR_OK) |
|||
return -1; // general error
|
|||
|
|||
ufi_request_sense_response response; |
|||
memset(&response, 0, sizeof(response)); |
|||
|
|||
if ((result = ufi_request_sense((device_config *)dev, &response)) != USB_ERR_OK) |
|||
return -1; // error
|
|||
|
|||
const uint8_t asc = response.asc; |
|||
const uint8_t ascq = response.ascq; |
|||
const uint8_t sense_key = response.sense_key; |
|||
|
|||
if (sense_key != 0) |
|||
return -1; |
|||
|
|||
return USB_ERR_OK; |
|||
} |
|||
|
|||
usb_error usb_ufi_write(const uint16_t dev_index, uint8_t *const buffer) { |
|||
device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); |
|||
|
|||
if (wait_for_device_ready((device_config *)dev, 20) != 0) |
|||
return -1; // Not READY!
|
|||
|
|||
ufi_interrupt_status sense_codes; |
|||
|
|||
memset(&sense_codes, 0, sizeof(sense_codes)); |
|||
if ((ufi_read_write_sector((device_config *)dev, true, dev->current_lba, 1, buffer, (uint8_t *)&sense_codes)) != USB_ERR_OK) { |
|||
return -1; |
|||
} |
|||
|
|||
ufi_request_sense_response response; |
|||
memset(&response, 0, sizeof(response)); |
|||
|
|||
if ((ufi_request_sense((device_config *)dev, &response)) != USB_ERR_OK) { |
|||
return -1; |
|||
} |
|||
|
|||
const uint8_t asc = response.asc; |
|||
const uint8_t ascq = response.ascq; |
|||
const uint8_t sense_key = response.sense_key; |
|||
|
|||
if (sense_key != 0) |
|||
return -1; |
|||
|
|||
return USB_ERR_OK; |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
#ifndef __UFI_DRIVER__ |
|||
#define __UFI_DRIVER__ |
|||
|
|||
#include <ch376.h> |
|||
#include <stdint.h> |
|||
|
|||
extern uint32_t usb_ufi_get_cap(const uint16_t dev_index); |
|||
extern uint8_t usb_ufi_read(const uint16_t dev_index, uint8_t *const buffer); |
|||
extern usb_error usb_ufi_write(const uint16_t dev_index, uint8_t *const buffer); |
|||
|
|||
#endif |
|||
@ -1,4 +1,5 @@ |
|||
; Generated File -- not to be modify directly |
|||
#include "ch376-native/ufi-drv/class_ufi.c.s" |
|||
#include "ch376-native/ufi-drv/ufi-init.c.s" |
|||
#include "ch376-native/ufi-drv/ufi_driver.c.s" |
|||
#include "ch376-native/ufi-drv/usb_cbi.c.s" |
|||
|
|||
@ -0,0 +1,380 @@ |
|||
; |
|||
; Generated from source-doc/ufi-drv/ufi_driver.c.asm -- not to be modify directly |
|||
; |
|||
; |
|||
;-------------------------------------------------------- |
|||
; File Created by SDCC : free open source ISO C Compiler |
|||
; Version 4.5.0 #15248 (Linux) |
|||
;-------------------------------------------------------- |
|||
; Processed by Z88DK |
|||
;-------------------------------------------------------- |
|||
|
|||
|
|||
;-------------------------------------------------------- |
|||
; Public variables in this module |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Externals used |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; special function registers |
|||
;-------------------------------------------------------- |
|||
_CH376_DATA_PORT .EQU 0xff88 |
|||
_CH376_COMMAND_PORT .EQU 0xff89 |
|||
_USB_MODULE_LEDS .EQU 0xff8a |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; ram data |
|||
;-------------------------------------------------------- |
|||
|
|||
#IF 0 |
|||
|
|||
; .area _INITIALIZED removed by z88dk |
|||
|
|||
|
|||
#ENDIF |
|||
|
|||
;-------------------------------------------------------- |
|||
; absolute external ram data |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; global & static initialisations |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; Home |
|||
;-------------------------------------------------------- |
|||
;-------------------------------------------------------- |
|||
; code |
|||
;-------------------------------------------------------- |
|||
;source-doc/ufi-drv/ufi_driver.c:6: uint32_t usb_ufi_get_cap(const uint16_t dev_index) { |
|||
; --------------------------------- |
|||
; Function usb_ufi_get_cap |
|||
; --------------------------------- |
|||
_usb_ufi_get_cap: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
ld hl, -72 |
|||
add hl, sp |
|||
ld sp, hl |
|||
;source-doc/ufi-drv/ufi_driver.c:7: 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/ufi-drv/ufi_driver.c:10: memset(&response, 0, sizeof(ufi_format_capacities_response)); |
|||
ld hl,0 |
|||
add hl, sp |
|||
ld b,0x12 |
|||
l_usb_ufi_get_cap_00112: |
|||
xor a |
|||
ld (hl), a |
|||
inc hl |
|||
ld (hl), a |
|||
inc hl |
|||
djnz l_usb_ufi_get_cap_00112 |
|||
;source-doc/ufi-drv/ufi_driver.c:12: wait_for_device_ready(dev, 25); |
|||
push de |
|||
ld a,0x19 |
|||
push af |
|||
inc sp |
|||
push de |
|||
call _wait_for_device_ready |
|||
pop af |
|||
inc sp |
|||
pop de |
|||
;source-doc/ufi-drv/ufi_driver.c:16: ufi_inquiry(dev, &inquiry); |
|||
push de |
|||
ld hl,38 |
|||
add hl, sp |
|||
push hl |
|||
push de |
|||
call _ufi_inquiry |
|||
pop af |
|||
pop af |
|||
pop de |
|||
;source-doc/ufi-drv/ufi_driver.c:18: wait_for_device_ready(dev, 15); |
|||
push de |
|||
ld a,0x0f |
|||
push af |
|||
inc sp |
|||
push de |
|||
call _wait_for_device_ready |
|||
pop af |
|||
inc sp |
|||
pop de |
|||
;source-doc/ufi-drv/ufi_driver.c:20: const usb_error result = ufi_read_frmt_caps(dev, &response); |
|||
ld hl,0 |
|||
add hl, sp |
|||
push hl |
|||
push de |
|||
call _ufi_read_frmt_caps |
|||
pop af |
|||
pop af |
|||
ld a, l |
|||
;source-doc/ufi-drv/ufi_driver.c:21: if (result != USB_ERR_OK) |
|||
or a |
|||
jr Z,l_usb_ufi_get_cap_00102 |
|||
;source-doc/ufi-drv/ufi_driver.c:22: return 0; |
|||
ld hl,0x0000 |
|||
ld e, l |
|||
ld d, l |
|||
jr l_usb_ufi_get_cap_00103 |
|||
l_usb_ufi_get_cap_00102: |
|||
;source-doc/ufi-drv/ufi_driver.c:24: return convert_from_msb_first(response.descriptors[0].number_of_blocks); |
|||
ld hl,4 |
|||
add hl, sp |
|||
push hl |
|||
call _convert_from_msb_first |
|||
pop af |
|||
l_usb_ufi_get_cap_00103: |
|||
;source-doc/ufi-drv/ufi_driver.c:25: } |
|||
ld sp, ix |
|||
pop ix |
|||
ret |
|||
;source-doc/ufi-drv/ufi_driver.c:27: uint8_t usb_ufi_read(const uint16_t dev_index, uint8_t *const buffer) { |
|||
; --------------------------------- |
|||
; Function usb_ufi_read |
|||
; --------------------------------- |
|||
_usb_ufi_read: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
ld hl, -20 |
|||
add hl, sp |
|||
ld sp, hl |
|||
;source-doc/ufi-drv/ufi_driver.c:28: 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/ufi-drv/ufi_driver.c:30: if (wait_for_device_ready((device_config *)dev, 20) != 0) |
|||
push de |
|||
ld c,e |
|||
ld b,d |
|||
push de |
|||
ld a,0x14 |
|||
push af |
|||
inc sp |
|||
push bc |
|||
call _wait_for_device_ready |
|||
pop af |
|||
inc sp |
|||
ld a, l |
|||
pop de |
|||
pop bc |
|||
or a |
|||
jr Z,l_usb_ufi_read_00102 |
|||
;source-doc/ufi-drv/ufi_driver.c:31: return -1; // Not READY! |
|||
ld l,0xff |
|||
jr l_usb_ufi_read_00109 |
|||
l_usb_ufi_read_00102: |
|||
;source-doc/ufi-drv/ufi_driver.c:36: memset(&sense_codes, 0, sizeof(sense_codes)); |
|||
ld hl,0 |
|||
add hl, sp |
|||
xor a |
|||
ld (hl), a |
|||
inc hl |
|||
ld (hl), a |
|||
;source-doc/ufi-drv/ufi_driver.c:38: if (ufi_read_write_sector((device_config *)dev, false, dev->current_lba, 1, buffer, (uint8_t *)&sense_codes) != USB_ERR_OK) |
|||
ld hl,12 |
|||
add hl, de |
|||
ld e, (hl) |
|||
inc hl |
|||
ld d, (hl) |
|||
push bc |
|||
ld hl,2 |
|||
add hl, sp |
|||
push hl |
|||
ld l,(ix+6) |
|||
ld h,(ix+7) |
|||
push hl |
|||
ld a,0x01 |
|||
push af |
|||
inc sp |
|||
push de |
|||
xor a |
|||
push af |
|||
inc sp |
|||
push bc |
|||
call _ufi_read_write_sector |
|||
pop af |
|||
pop af |
|||
pop af |
|||
pop af |
|||
pop af |
|||
ld a, l |
|||
pop bc |
|||
or a |
|||
jr Z,l_usb_ufi_read_00104 |
|||
;source-doc/ufi-drv/ufi_driver.c:39: return -1; // general error |
|||
ld l,0xff |
|||
jr l_usb_ufi_read_00109 |
|||
l_usb_ufi_read_00104: |
|||
;source-doc/ufi-drv/ufi_driver.c:42: memset(&response, 0, sizeof(response)); |
|||
push bc |
|||
ld hl,4 |
|||
add hl, sp |
|||
ld b,0x09 |
|||
l_usb_ufi_read_00139: |
|||
xor a |
|||
ld (hl), a |
|||
inc hl |
|||
ld (hl), a |
|||
inc hl |
|||
djnz l_usb_ufi_read_00139 |
|||
pop bc |
|||
;source-doc/ufi-drv/ufi_driver.c:44: if ((result = ufi_request_sense((device_config *)dev, &response)) != USB_ERR_OK) |
|||
ld hl,2 |
|||
add hl, sp |
|||
push hl |
|||
push bc |
|||
call _ufi_request_sense |
|||
pop af |
|||
pop af |
|||
ld a, l |
|||
or a |
|||
jr Z,l_usb_ufi_read_00106 |
|||
;source-doc/ufi-drv/ufi_driver.c:45: return -1; // error |
|||
ld l,0xff |
|||
jr l_usb_ufi_read_00109 |
|||
l_usb_ufi_read_00106: |
|||
;source-doc/ufi-drv/ufi_driver.c:49: const uint8_t sense_key = response.sense_key; |
|||
ld hl,4 |
|||
add hl, sp |
|||
ld a, (hl) |
|||
;source-doc/ufi-drv/ufi_driver.c:51: if (sense_key != 0) |
|||
and 0x0f |
|||
jr Z,l_usb_ufi_read_00108 |
|||
;source-doc/ufi-drv/ufi_driver.c:52: return -1; |
|||
ld l,0xff |
|||
jr l_usb_ufi_read_00109 |
|||
l_usb_ufi_read_00108: |
|||
;source-doc/ufi-drv/ufi_driver.c:54: return USB_ERR_OK; |
|||
ld l,0x00 |
|||
l_usb_ufi_read_00109: |
|||
;source-doc/ufi-drv/ufi_driver.c:55: } |
|||
ld sp, ix |
|||
pop ix |
|||
ret |
|||
;source-doc/ufi-drv/ufi_driver.c:57: usb_error usb_ufi_write(const uint16_t dev_index, uint8_t *const buffer) { |
|||
; --------------------------------- |
|||
; Function usb_ufi_write |
|||
; --------------------------------- |
|||
_usb_ufi_write: |
|||
push ix |
|||
ld ix,0 |
|||
add ix,sp |
|||
ld hl, -20 |
|||
add hl, sp |
|||
ld sp, hl |
|||
;source-doc/ufi-drv/ufi_driver.c:58: 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/ufi-drv/ufi_driver.c:60: if (wait_for_device_ready((device_config *)dev, 20) != 0) |
|||
push de |
|||
ld c,e |
|||
ld b,d |
|||
push de |
|||
ld a,0x14 |
|||
push af |
|||
inc sp |
|||
push bc |
|||
call _wait_for_device_ready |
|||
pop af |
|||
inc sp |
|||
ld a, l |
|||
pop de |
|||
pop bc |
|||
or a |
|||
jr Z,l_usb_ufi_write_00102 |
|||
;source-doc/ufi-drv/ufi_driver.c:61: return -1; // Not READY! |
|||
ld l,0xff |
|||
jr l_usb_ufi_write_00109 |
|||
l_usb_ufi_write_00102: |
|||
;source-doc/ufi-drv/ufi_driver.c:65: memset(&sense_codes, 0, sizeof(sense_codes)); |
|||
ld hl,0 |
|||
add hl, sp |
|||
xor a |
|||
ld (hl), a |
|||
inc hl |
|||
ld (hl), a |
|||
;source-doc/ufi-drv/ufi_driver.c:66: if ((ufi_read_write_sector((device_config *)dev, true, dev->current_lba, 1, buffer, (uint8_t *)&sense_codes)) != USB_ERR_OK) { |
|||
ld hl,12 |
|||
add hl, de |
|||
ld e, (hl) |
|||
inc hl |
|||
ld d, (hl) |
|||
push bc |
|||
ld hl,2 |
|||
add hl, sp |
|||
push hl |
|||
ld l,(ix+6) |
|||
ld h,(ix+7) |
|||
push hl |
|||
ld a,0x01 |
|||
push af |
|||
inc sp |
|||
push de |
|||
ld a,0x01 |
|||
push af |
|||
inc sp |
|||
push bc |
|||
call _ufi_read_write_sector |
|||
pop af |
|||
pop af |
|||
pop af |
|||
pop af |
|||
pop af |
|||
ld a, l |
|||
pop bc |
|||
or a |
|||
jr Z,l_usb_ufi_write_00104 |
|||
;source-doc/ufi-drv/ufi_driver.c:67: return -1; |
|||
ld l,0xff |
|||
jr l_usb_ufi_write_00109 |
|||
l_usb_ufi_write_00104: |
|||
;source-doc/ufi-drv/ufi_driver.c:71: memset(&response, 0, sizeof(response)); |
|||
push bc |
|||
ld hl,4 |
|||
add hl, sp |
|||
ld b,0x09 |
|||
l_usb_ufi_write_00139: |
|||
xor a |
|||
ld (hl), a |
|||
inc hl |
|||
ld (hl), a |
|||
inc hl |
|||
djnz l_usb_ufi_write_00139 |
|||
pop bc |
|||
;source-doc/ufi-drv/ufi_driver.c:73: if ((ufi_request_sense((device_config *)dev, &response)) != USB_ERR_OK) { |
|||
ld hl,2 |
|||
add hl, sp |
|||
push hl |
|||
push bc |
|||
call _ufi_request_sense |
|||
pop af |
|||
pop af |
|||
ld a, l |
|||
or a |
|||
jr Z,l_usb_ufi_write_00106 |
|||
;source-doc/ufi-drv/ufi_driver.c:74: return -1; |
|||
ld l,0xff |
|||
jr l_usb_ufi_write_00109 |
|||
l_usb_ufi_write_00106: |
|||
;source-doc/ufi-drv/ufi_driver.c:79: const uint8_t sense_key = response.sense_key; |
|||
ld hl,4 |
|||
add hl, sp |
|||
ld a, (hl) |
|||
;source-doc/ufi-drv/ufi_driver.c:81: if (sense_key != 0) |
|||
and 0x0f |
|||
jr Z,l_usb_ufi_write_00108 |
|||
;source-doc/ufi-drv/ufi_driver.c:82: return -1; |
|||
ld l,0xff |
|||
jr l_usb_ufi_write_00109 |
|||
l_usb_ufi_write_00108: |
|||
;source-doc/ufi-drv/ufi_driver.c:84: return USB_ERR_OK; |
|||
ld l,0x00 |
|||
l_usb_ufi_write_00109: |
|||
;source-doc/ufi-drv/ufi_driver.c:85: } |
|||
ld sp, ix |
|||
pop ix |
|||
ret |
|||
Loading…
Reference in new issue