Browse Source

ch376-native: minor code cleanup

pull/592/head
Dean Netherton 10 months ago
parent
commit
e24860f474
  1. 4
      Source/HBIOS/ch376-native/base-drv/ch376.c.s
  2. 84
      Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s
  3. 8
      Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s
  4. 187
      Source/HBIOS/ch376-native/base-drv/transfers.c.s
  5. 10
      Source/HBIOS/ch376-native/base-drv/usb-base-drv.c.s
  6. 32
      Source/HBIOS/ch376-native/base-drv/usb_state.c.s
  7. 12
      Source/HBIOS/ch376-native/keyboard/kyb_driver.c.s
  8. 4
      Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c
  9. 3
      Source/HBIOS/ch376-native/source-doc/base-drv/ch376.h
  10. 51
      Source/HBIOS/ch376-native/source-doc/base-drv/class_hub.h
  11. 5
      Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.c
  12. 2
      Source/HBIOS/ch376-native/source-doc/base-drv/enumerate_hub.c
  13. 1
      Source/HBIOS/ch376-native/source-doc/base-drv/enumerate_storage.h
  14. 1
      Source/HBIOS/ch376-native/source-doc/base-drv/print.h
  15. 19
      Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c
  16. 4
      Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.c
  17. 2
      Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.h
  18. 1
      Source/HBIOS/ch376-native/source-doc/base-drv/usb_state.c
  19. 6
      Source/HBIOS/ch376-native/source-doc/base-drv/z80.h

4
Source/HBIOS/ch376-native/base-drv/ch376.c.s

@ -251,7 +251,7 @@ l_ch_probe_00107:
inc sp inc sp
pop ix pop ix
ret ret
;source-doc/base-drv/ch376.c:112: uint8_t ch_cmd_set_usb_mode(const uint8_t mode) __z88dk_fastcall {
;source-doc/base-drv/ch376.c:112: usb_error ch_cmd_set_usb_mode(const uint8_t mode) __z88dk_fastcall {
; --------------------------------- ; ---------------------------------
; Function ch_cmd_set_usb_mode ; Function ch_cmd_set_usb_mode
; --------------------------------- ; ---------------------------------
@ -581,7 +581,7 @@ l_ch_data_in_transfer_00111:
;source-doc/base-drv/ch376.c:187: } ;source-doc/base-drv/ch376.c:187: }
pop ix pop ix
ret ret
;source-doc/base-drv/ch376.c:190: usb_error ch_data_in_transfer_n(uint8_t *const buffer, int8_t *const buffer_size, endpoint_param *const endpoint) {
;source-doc/base-drv/ch376.c:190: 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 ; Function ch_data_in_transfer_n
; --------------------------------- ; ---------------------------------

84
Source/HBIOS/ch376-native/base-drv/dev_transfers.c.s

@ -48,7 +48,7 @@ _USB_MODULE_LEDS .EQU 0xff8a
;-------------------------------------------------------- ;--------------------------------------------------------
; code ; code
;-------------------------------------------------------- ;--------------------------------------------------------
;source-doc/base-drv/dev_transfers.c:24: * See https://www.beyondlogic.org/usbnutshell/usb4.shtml for a description of the USB control transfer
;source-doc/base-drv/dev_transfers.c:23: * See https://www.beyondlogic.org/usbnutshell/usb4.shtml for a description of the USB control transfer
; --------------------------------- ; ---------------------------------
; Function usbdev_control_transfer ; Function usbdev_control_transfer
; --------------------------------- ; ---------------------------------
@ -56,7 +56,7 @@ _usbdev_control_transfer:
push ix push ix
ld ix,0 ld ix,0
add ix,sp add ix,sp
;source-doc/base-drv/dev_transfers.c:25: *
;source-doc/base-drv/dev_transfers.c:24: *
ld l,(ix+4) ld l,(ix+4)
ld h,(ix+5) ld h,(ix+5)
ld e,l ld e,l
@ -82,10 +82,10 @@ _usbdev_control_transfer:
pop af pop af
pop af pop af
pop af pop af
;source-doc/base-drv/dev_transfers.c:26: * @param device the usb device
;source-doc/base-drv/dev_transfers.c:25: * @param device the usb device
pop ix pop ix
ret ret
;source-doc/base-drv/dev_transfers.c:28: * @param buffer Pointer of data to send or receive into
;source-doc/base-drv/dev_transfers.c:27: * @param buffer Pointer of data to send or receive into
; --------------------------------- ; ---------------------------------
; Function usbdev_blk_out_trnsfer ; Function usbdev_blk_out_trnsfer
; --------------------------------- ; ---------------------------------
@ -95,13 +95,13 @@ _usbdev_blk_out_trnsfer:
add ix,sp add ix,sp
push af push af
push af push af
;source-doc/base-drv/dev_transfers.c:30: */
;source-doc/base-drv/dev_transfers.c:29: */
ld e,(ix+4) ld e,(ix+4)
ld d,(ix+5) ld d,(ix+5)
ld hl,0x0003 ld hl,0x0003
add hl, de add hl, de
ex (sp), hl ex (sp), hl
;source-doc/base-drv/dev_transfers.c:32: return usb_control_transfer(cmd_packet, buffer, device->address, device->max_packet_size);
;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-2),e
ld (ix-1),d ld (ix-1),d
pop bc pop bc
@ -134,12 +134,12 @@ _usbdev_blk_out_trnsfer:
pop de pop de
ld a, l ld a, l
ld (_result), a ld (_result), a
;source-doc/base-drv/dev_transfers.c:34:
;source-doc/base-drv/dev_transfers.c:33:
ld hl,_result ld hl,_result
ld a, (hl) ld a, (hl)
sub 0x02 sub 0x02
jr NZ,l_usbdev_blk_out_trnsfer_00102 jr NZ,l_usbdev_blk_out_trnsfer_00102
;source-doc/base-drv/dev_transfers.c:35: usb_error usbdev_blk_out_trnsfer(device_config *const dev, const uint8_t *const buffer, const uint16_t buffer_size) {
;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 ex de, hl
inc hl inc hl
ld d, (hl) ld d, (hl)
@ -164,23 +164,23 @@ _usbdev_blk_out_trnsfer:
call _usbtrn_clear_endpoint_halt call _usbtrn_clear_endpoint_halt
pop af pop af
inc sp inc sp
;source-doc/base-drv/dev_transfers.c:36:
;source-doc/base-drv/dev_transfers.c:35:
pop hl pop hl
push hl push hl
res 0, (hl) res 0, (hl)
;source-doc/base-drv/dev_transfers.c:37: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_OUT];
;source-doc/base-drv/dev_transfers.c:36: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_OUT];
ld l,0x02 ld l,0x02
jr l_usbdev_blk_out_trnsfer_00104 jr l_usbdev_blk_out_trnsfer_00104
l_usbdev_blk_out_trnsfer_00102: l_usbdev_blk_out_trnsfer_00102:
;source-doc/base-drv/dev_transfers.c:40:
;source-doc/base-drv/dev_transfers.c:43: endpoint->toggle = 0;
;source-doc/base-drv/dev_transfers.c:39:
;source-doc/base-drv/dev_transfers.c:42: endpoint->toggle = 0;
ld hl, (_result) ld hl, (_result)
l_usbdev_blk_out_trnsfer_00104: l_usbdev_blk_out_trnsfer_00104:
;source-doc/base-drv/dev_transfers.c:44: return USB_ERR_STALL;
;source-doc/base-drv/dev_transfers.c:43: return USB_ERR_STALL;
ld sp, ix ld sp, ix
pop ix pop ix
ret ret
;source-doc/base-drv/dev_transfers.c:46:
;source-doc/base-drv/dev_transfers.c:45:
; --------------------------------- ; ---------------------------------
; Function usbdev_bulk_in_transfer ; Function usbdev_bulk_in_transfer
; --------------------------------- ; ---------------------------------
@ -190,13 +190,13 @@ _usbdev_bulk_in_transfer:
add ix,sp add ix,sp
push af push af
push af push af
;source-doc/base-drv/dev_transfers.c:47: RETURN_CHECK(result);
;source-doc/base-drv/dev_transfers.c:46: RETURN_CHECK(result);
ld e,(ix+4) ld e,(ix+4)
ld d,(ix+5) ld d,(ix+5)
ld hl,0x0006 ld hl,0x0006
add hl, de add hl, de
ex (sp), hl ex (sp), hl
;source-doc/base-drv/dev_transfers.c:49: done:
;source-doc/base-drv/dev_transfers.c:48: done:
ld (ix-2),e ld (ix-2),e
ld (ix-1),d ld (ix-1),d
pop bc pop bc
@ -229,12 +229,12 @@ _usbdev_bulk_in_transfer:
pop de pop de
ld a, l ld a, l
ld (_result), a ld (_result), a
;source-doc/base-drv/dev_transfers.c:51: }
;source-doc/base-drv/dev_transfers.c:50: }
ld hl,_result ld hl,_result
ld a, (hl) ld a, (hl)
sub 0x02 sub 0x02
jr NZ,l_usbdev_bulk_in_transfer_00102 jr NZ,l_usbdev_bulk_in_transfer_00102
;source-doc/base-drv/dev_transfers.c:52:
;source-doc/base-drv/dev_transfers.c:51:
ex de, hl ex de, hl
inc hl inc hl
ld d, (hl) ld d, (hl)
@ -259,23 +259,23 @@ _usbdev_bulk_in_transfer:
call _usbtrn_clear_endpoint_halt call _usbtrn_clear_endpoint_halt
pop af pop af
inc sp inc sp
;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) {
;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 pop hl
push hl push hl
res 0, (hl) res 0, (hl)
;source-doc/base-drv/dev_transfers.c:54: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_IN];
;source-doc/base-drv/dev_transfers.c:53: endpoint_param *const endpoint = &dev->endpoints[ENDPOINT_BULK_IN];
ld l,0x02 ld l,0x02
jr l_usbdev_bulk_in_transfer_00104 jr l_usbdev_bulk_in_transfer_00104
l_usbdev_bulk_in_transfer_00102: l_usbdev_bulk_in_transfer_00102:
;source-doc/base-drv/dev_transfers.c:57:
;source-doc/base-drv/dev_transfers.c:59: usbtrn_clear_endpoint_halt(endpoint->number, dev->address, dev->max_packet_size);
;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) ld hl, (_result)
l_usbdev_bulk_in_transfer_00104: l_usbdev_bulk_in_transfer_00104:
;source-doc/base-drv/dev_transfers.c:60: endpoint->toggle = 0;
;source-doc/base-drv/dev_transfers.c:59: endpoint->toggle = 0;
ld sp, ix ld sp, ix
pop ix pop ix
ret ret
;source-doc/base-drv/dev_transfers.c:62: }
;source-doc/base-drv/dev_transfers.c:61: }
; --------------------------------- ; ---------------------------------
; Function usbdev_dat_in_trnsfer ; Function usbdev_dat_in_trnsfer
; --------------------------------- ; ---------------------------------
@ -285,7 +285,7 @@ _usbdev_dat_in_trnsfer:
add ix,sp add ix,sp
push af push af
push af push af
;source-doc/base-drv/dev_transfers.c:67: }
;source-doc/base-drv/dev_transfers.c:66: }
ld e,(ix+4) ld e,(ix+4)
ld d,(ix+5) ld d,(ix+5)
ld c, e ld c, e
@ -304,7 +304,7 @@ _usbdev_dat_in_trnsfer:
ld a,0x00 ld a,0x00
adc a, b adc a, b
ld (ix-3),a ld (ix-3),a
;source-doc/base-drv/dev_transfers.c:69: usb_error usbdev_dat_in_trnsfer(device_config *const device,
;source-doc/base-drv/dev_transfers.c:68: usb_error usbdev_dat_in_trnsfer(device_config *const device,
ld (ix-2),e ld (ix-2),e
ld (ix-1),d ld (ix-1),d
pop bc pop bc
@ -337,12 +337,12 @@ _usbdev_dat_in_trnsfer:
pop de pop de
ld a, l ld a, l
ld (_result), a ld (_result), a
;source-doc/base-drv/dev_transfers.c:71: const uint16_t buffer_size,
;source-doc/base-drv/dev_transfers.c:70: const uint16_t buffer_size,
ld hl,_result ld hl,_result
ld a, (hl) ld a, (hl)
sub 0x02 sub 0x02
jr NZ,l_usbdev_dat_in_trnsfer_00102 jr NZ,l_usbdev_dat_in_trnsfer_00102
;source-doc/base-drv/dev_transfers.c:72: const usb_endpoint_type endpoint_type) {
;source-doc/base-drv/dev_transfers.c:71: const usb_endpoint_type endpoint_type) {
ex de, hl ex de, hl
inc hl inc hl
ld d, (hl) ld d, (hl)
@ -367,23 +367,23 @@ _usbdev_dat_in_trnsfer:
call _usbtrn_clear_endpoint_halt call _usbtrn_clear_endpoint_halt
pop af pop af
inc sp inc sp
;source-doc/base-drv/dev_transfers.c:73:
;source-doc/base-drv/dev_transfers.c:72:
pop hl pop hl
push hl push hl
res 0, (hl) res 0, (hl)
;source-doc/base-drv/dev_transfers.c:74: endpoint_param *const endpoint = &device->endpoints[endpoint_type];
;source-doc/base-drv/dev_transfers.c:73: endpoint_param *const endpoint = &device->endpoints[endpoint_type];
ld l,0x02 ld l,0x02
jr l_usbdev_dat_in_trnsfer_00104 jr l_usbdev_dat_in_trnsfer_00104
l_usbdev_dat_in_trnsfer_00102: l_usbdev_dat_in_trnsfer_00102:
;source-doc/base-drv/dev_transfers.c:77:
;source-doc/base-drv/dev_transfers.c:79: usbtrn_clear_endpoint_halt(endpoint->number, device->address, device->max_packet_size);
;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) ld hl, (_result)
l_usbdev_dat_in_trnsfer_00104: l_usbdev_dat_in_trnsfer_00104:
;source-doc/base-drv/dev_transfers.c:80: endpoint->toggle = 0;
;source-doc/base-drv/dev_transfers.c:79: endpoint->toggle = 0;
ld sp, ix ld sp, ix
pop ix pop ix
ret ret
;source-doc/base-drv/dev_transfers.c:82: }
;source-doc/base-drv/dev_transfers.c:81: }
; --------------------------------- ; ---------------------------------
; Function usbdev_dat_in_trnsfer_0 ; Function usbdev_dat_in_trnsfer_0
; --------------------------------- ; ---------------------------------
@ -393,13 +393,13 @@ _usbdev_dat_in_trnsfer_0:
add ix,sp add ix,sp
push af push af
push af push af
;source-doc/base-drv/dev_transfers.c:83:
;source-doc/base-drv/dev_transfers.c:82:
ld e,(ix+4) ld e,(ix+4)
ld d,(ix+5) ld d,(ix+5)
ld hl,0x0003 ld hl,0x0003
add hl, de add hl, de
ex (sp), hl ex (sp), hl
;source-doc/base-drv/dev_transfers.c:85: done:
;source-doc/base-drv/dev_transfers.c:84: done:
ld (ix-2),e ld (ix-2),e
ld (ix-1),d ld (ix-1),d
pop bc pop bc
@ -432,12 +432,12 @@ _usbdev_dat_in_trnsfer_0:
pop de pop de
ld a, l ld a, l
ld (_result), a ld (_result), a
;source-doc/base-drv/dev_transfers.c:87: }
;source-doc/base-drv/dev_transfers.c:86: }
ld hl,_result ld hl,_result
ld a, (hl) ld a, (hl)
sub 0x02 sub 0x02
jr NZ,l_usbdev_dat_in_trnsfer_0_00102 jr NZ,l_usbdev_dat_in_trnsfer_0_00102
;source-doc/base-drv/dev_transfers.c:88:
;source-doc/base-drv/dev_transfers.c:87:
ex de, hl ex de, hl
inc hl inc hl
ld d, (hl) ld d, (hl)
@ -462,18 +462,18 @@ _usbdev_dat_in_trnsfer_0:
call _usbtrn_clear_endpoint_halt call _usbtrn_clear_endpoint_halt
pop af pop af
inc sp inc sp
;source-doc/base-drv/dev_transfers.c:89: usb_error usbdev_dat_in_trnsfer_0(device_config *const device, uint8_t *const buffer, const uint8_t buffer_size) {
;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 pop hl
push hl push hl
res 0, (hl) res 0, (hl)
;source-doc/base-drv/dev_transfers.c:90: endpoint_param *const endpoint = &device->endpoints[0];
;source-doc/base-drv/dev_transfers.c:89: endpoint_param *const endpoint = &device->endpoints[0];
ld l,0x02 ld l,0x02
jr l_usbdev_dat_in_trnsfer_0_00103 jr l_usbdev_dat_in_trnsfer_0_00103
l_usbdev_dat_in_trnsfer_0_00102: l_usbdev_dat_in_trnsfer_0_00102:
;source-doc/base-drv/dev_transfers.c:93:
;source-doc/base-drv/dev_transfers.c:92:
ld hl, (_result) ld hl, (_result)
l_usbdev_dat_in_trnsfer_0_00103: l_usbdev_dat_in_trnsfer_0_00103:
;source-doc/base-drv/dev_transfers.c:94: if (result == USB_ERR_STALL) {
;source-doc/base-drv/dev_transfers.c:93: if (result == USB_ERR_STALL) {
ld sp, ix ld sp, ix
pop ix pop ix
ret ret

8
Source/HBIOS/ch376-native/base-drv/enumerate_hub.c.s

@ -333,11 +333,9 @@ l_configure_usb_hub_00126:
pop bc pop bc
or a or a
jp NZ, l_configure_usb_hub_00129 jp NZ, l_configure_usb_hub_00129
;source-doc/base-drv/enumerate_hub.c:61: if (port_status.wPortStatus.port_connection) {
ld hl,8
add hl, sp
ld a, (hl)
and 0x01
;source-doc/base-drv/enumerate_hub.c:61: if (port_status.wPortStatus & PORT_STAT_CONNECTION) {
ld e,(ix-6)
bit 0, e
jr Z,l_configure_usb_hub_00124 jr Z,l_configure_usb_hub_00124
;source-doc/base-drv/enumerate_hub.c:62: CHECK(hub_clear_feature(hub_config, HUB_FEATURE_PORT_CONNECTION_CHA, i)); ;source-doc/base-drv/enumerate_hub.c:62: CHECK(hub_clear_feature(hub_config, HUB_FEATURE_PORT_CONNECTION_CHA, i));
push bc push bc

187
Source/HBIOS/ch376-native/base-drv/transfers.c.s

@ -48,7 +48,7 @@ _USB_MODULE_LEDS .EQU 0xff8a
;-------------------------------------------------------- ;--------------------------------------------------------
; code ; code
;-------------------------------------------------------- ;--------------------------------------------------------
;source-doc/base-drv/transfers.c:23:
;source-doc/base-drv/transfers.c:22:
; --------------------------------- ; ---------------------------------
; Function usb_ctrl_trnsfer_ext ; Function usb_ctrl_trnsfer_ext
; --------------------------------- ; ---------------------------------
@ -56,26 +56,26 @@ _usb_ctrl_trnsfer_ext:
push ix push ix
ld ix,0 ld ix,0
add ix,sp add ix,sp
;source-doc/base-drv/transfers.c:27: const uint8_t max_packet_size) {
;source-doc/base-drv/transfers.c:26: const uint8_t max_packet_size) {
ld a,(ix+5) ld a,(ix+5)
sub 0x80 sub 0x80
jr NC,l_usb_ctrl_trnsfer_ext_00102 jr NC,l_usb_ctrl_trnsfer_ext_00102
;source-doc/base-drv/transfers.c:28: if ((uint16_t)cmd_packet < LOWER_SAFE_RAM_ADDRESS)
;source-doc/base-drv/transfers.c:27: if ((uint16_t)cmd_packet < LOWER_SAFE_RAM_ADDRESS)
ld l,0x82 ld l,0x82
jr l_usb_ctrl_trnsfer_ext_00106 jr l_usb_ctrl_trnsfer_ext_00106
l_usb_ctrl_trnsfer_ext_00102: l_usb_ctrl_trnsfer_ext_00102:
;source-doc/base-drv/transfers.c:30:
;source-doc/base-drv/transfers.c:29:
ld a,(ix+7) ld a,(ix+7)
or (ix+6) or (ix+6)
jr Z,l_usb_ctrl_trnsfer_ext_00104 jr Z,l_usb_ctrl_trnsfer_ext_00104
ld a,(ix+7) ld a,(ix+7)
sub 0x80 sub 0x80
jr NC,l_usb_ctrl_trnsfer_ext_00104 jr NC,l_usb_ctrl_trnsfer_ext_00104
;source-doc/base-drv/transfers.c:31: if (buffer != 0 && (uint16_t)buffer < LOWER_SAFE_RAM_ADDRESS)
;source-doc/base-drv/transfers.c:30: if (buffer != 0 && (uint16_t)buffer < LOWER_SAFE_RAM_ADDRESS)
ld l,0x82 ld l,0x82
jr l_usb_ctrl_trnsfer_ext_00106 jr l_usb_ctrl_trnsfer_ext_00106
l_usb_ctrl_trnsfer_ext_00104: l_usb_ctrl_trnsfer_ext_00104:
;source-doc/base-drv/transfers.c:33:
;source-doc/base-drv/transfers.c:32:
ld h,(ix+9) ld h,(ix+9)
ld l,(ix+8) ld l,(ix+8)
push hl push hl
@ -90,10 +90,10 @@ l_usb_ctrl_trnsfer_ext_00104:
pop af pop af
pop af pop af
l_usb_ctrl_trnsfer_ext_00106: l_usb_ctrl_trnsfer_ext_00106:
;source-doc/base-drv/transfers.c:34: return usb_control_transfer(cmd_packet, buffer, device_address, max_packet_size);
;source-doc/base-drv/transfers.c:33: return usb_control_transfer(cmd_packet, buffer, device_address, max_packet_size);
pop ix pop ix
ret ret
;source-doc/base-drv/transfers.c:38: * @brief Perform a USB control transfer (in or out)
;source-doc/base-drv/transfers.c:37: * @brief Perform a USB control transfer (in or out)
; --------------------------------- ; ---------------------------------
; Function usb_control_transfer ; Function usb_control_transfer
; --------------------------------- ; ---------------------------------
@ -103,7 +103,7 @@ _usb_control_transfer:
add ix,sp add ix,sp
push af push af
push af push af
;source-doc/base-drv/transfers.c:43: * @param device_address usb device address
;source-doc/base-drv/transfers.c:42: * @param device_address usb device address
ld hl,0 ld hl,0
add hl, sp add hl, sp
set 0, (hl) set 0, (hl)
@ -125,30 +125,30 @@ _usb_control_transfer:
and 0xfc and 0xfc
or e or e
ld (hl), a ld (hl), a
;source-doc/base-drv/transfers.c:45: * @return usb_error USB_ERR_OK if all good, otherwise specific error code
;source-doc/base-drv/transfers.c:44: * @return usb_error USB_ERR_OK if all good, otherwise specific error code
ld c,(ix+4) ld c,(ix+4)
ld b,(ix+5) ld b,(ix+5)
ld a, (bc) ld a, (bc)
and 0x80 and 0x80
;source-doc/base-drv/transfers.c:47: usb_error usb_control_transfer(const setup_packet *const cmd_packet,
;source-doc/base-drv/transfers.c:46: usb_error usb_control_transfer(const setup_packet *const cmd_packet,
ld (ix-1),a ld (ix-1),a
or a or a
jr Z,l_usb_control_transfer_00102 jr Z,l_usb_control_transfer_00102
ld a,(ix+7) ld a,(ix+7)
or (ix+6) or (ix+6)
jr NZ,l_usb_control_transfer_00102 jr NZ,l_usb_control_transfer_00102
;source-doc/base-drv/transfers.c:48: void *const buffer,
;source-doc/base-drv/transfers.c:47: void *const buffer,
ld l,0x0f ld l,0x0f
jp l_usb_control_transfer_00114 jp l_usb_control_transfer_00114
l_usb_control_transfer_00102: l_usb_control_transfer_00102:
;source-doc/base-drv/transfers.c:50: const uint8_t max_packet_size) {
;source-doc/base-drv/transfers.c:49: const uint8_t max_packet_size) {
push bc push bc
call _critical_begin call _critical_begin
;source-doc/base-drv/transfers.c:52: endpoint_param endpoint = {1, 0, max_packet_size};
;source-doc/base-drv/transfers.c:51: endpoint_param endpoint = {1, 0, max_packet_size};
ld l,(ix+8) ld l,(ix+8)
call _ch_set_usb_address call _ch_set_usb_address
pop bc pop bc
;source-doc/base-drv/transfers.c:54: const uint8_t transferIn = (cmd_packet->bmRequestType & 0x80);
;source-doc/base-drv/transfers.c:53: const uint8_t transferIn = (cmd_packet->bmRequestType & 0x80);
ld e,(ix+4) ld e,(ix+4)
ld d,(ix+5) ld d,(ix+5)
push bc push bc
@ -159,21 +159,21 @@ l_usb_control_transfer_00102:
call _ch_write_data call _ch_write_data
pop af pop af
inc sp inc sp
;source-doc/base-drv/transfers.c:55:
;source-doc/base-drv/transfers.c:54:
call _ch_issue_token_setup call _ch_issue_token_setup
;source-doc/base-drv/transfers.c:56: if (transferIn && buffer == 0)
;source-doc/base-drv/transfers.c:55: if (transferIn && buffer == 0)
call _ch_short_wait_int_and_get_stat call _ch_short_wait_int_and_get_stat
pop bc pop bc
;source-doc/base-drv/transfers.c:57: return USB_ERR_OTHER;
;source-doc/base-drv/transfers.c:56: return USB_ERR_OTHER;
ld a, l ld a, l
or a or a
jr NZ,l_usb_control_transfer_00113 jr NZ,l_usb_control_transfer_00113
;source-doc/base-drv/transfers.c:59: critical_begin();
;source-doc/base-drv/transfers.c:58: critical_begin();
ld hl,6 ld hl,6
add hl, bc add hl, bc
ld c, (hl) ld c, (hl)
inc hl inc hl
;source-doc/base-drv/transfers.c:62:
;source-doc/base-drv/transfers.c:61:
ld a,(hl) ld a,(hl)
ld b,a ld b,a
or c or c
@ -204,58 +204,58 @@ l_usb_control_transfer_00118:
l_usb_control_transfer_00119: l_usb_control_transfer_00119:
jr l_usb_control_transfer_00117 jr l_usb_control_transfer_00117
l_usb_control_transfer_00116: l_usb_control_transfer_00116:
;source-doc/base-drv/transfers.c:63: ch_write_data((const uint8_t *)cmd_packet, sizeof(setup_packet));
;source-doc/base-drv/transfers.c:62: ch_write_data((const uint8_t *)cmd_packet, sizeof(setup_packet));
ld l,0x00 ld l,0x00
l_usb_control_transfer_00117: l_usb_control_transfer_00117:
;source-doc/base-drv/transfers.c:65: result = ch_short_wait_int_and_get_statu();
;source-doc/base-drv/transfers.c:64: result = ch_short_wait_int_and_get_statu();
ld a, l ld a, l
or a or a
jr NZ,l_usb_control_transfer_00113 jr NZ,l_usb_control_transfer_00113
;source-doc/base-drv/transfers.c:67:
;source-doc/base-drv/transfers.c:66:
ld a,(ix-1) ld a,(ix-1)
or a or a
jr Z,l_usb_control_transfer_00112 jr Z,l_usb_control_transfer_00112
;source-doc/base-drv/transfers.c:68: const uint16_t length = cmd_packet->wLength;
;source-doc/base-drv/transfers.c:67: const uint16_t length = cmd_packet->wLength;
ld l,0x2c ld l,0x2c
call _ch_command call _ch_command
;source-doc/base-drv/transfers.c:69:
;source-doc/base-drv/transfers.c:68:
ld a,0x00 ld a,0x00
ld bc,_CH376_DATA_PORT ld bc,_CH376_DATA_PORT
out (c), a out (c), a
;source-doc/base-drv/transfers.c:70: result = length != 0
;source-doc/base-drv/transfers.c:69: result = length != 0
call _ch_issue_token_out_ep0 call _ch_issue_token_out_ep0
;source-doc/base-drv/transfers.c:71: ? (transferIn ? ch_data_in_transfer(buffer, length, &endpoint) : ch_data_out_transfer(buffer, length, &endpoint))
;source-doc/base-drv/transfers.c:70: ? (transferIn ? ch_data_in_transfer(buffer, length, &endpoint) : ch_data_out_transfer(buffer, length, &endpoint))
call _ch_long_wait_int_and_get_statu call _ch_long_wait_int_and_get_statu
;source-doc/base-drv/transfers.c:73:
;source-doc/base-drv/transfers.c:72:
ld a,l ld a,l
or a or a
jr Z,l_usb_control_transfer_00108 jr Z,l_usb_control_transfer_00108
sub 0x02 sub 0x02
jr NZ,l_usb_control_transfer_00113 jr NZ,l_usb_control_transfer_00113
l_usb_control_transfer_00108: l_usb_control_transfer_00108:
;source-doc/base-drv/transfers.c:74: CHECK(result)
;source-doc/base-drv/transfers.c:73: CHECK(result)
ld l,0x00 ld l,0x00
;source-doc/base-drv/transfers.c:75:
;source-doc/base-drv/transfers.c:74:
jr l_usb_control_transfer_00113 jr l_usb_control_transfer_00113
;source-doc/base-drv/transfers.c:78: CH376_DATA_PORT = 0;
;source-doc/base-drv/transfers.c:77: CH376_DATA_PORT = 0;
l_usb_control_transfer_00112: l_usb_control_transfer_00112:
;source-doc/base-drv/transfers.c:81:
;source-doc/base-drv/transfers.c:80:
call _ch_issue_token_in_ep0 call _ch_issue_token_in_ep0
;source-doc/base-drv/transfers.c:82: if (result == USB_ERR_OK || result == USB_ERR_STALL) {
;source-doc/base-drv/transfers.c:81: if (result == USB_ERR_OK || result == USB_ERR_STALL) {
call _ch_long_wait_int_and_get_statu call _ch_long_wait_int_and_get_statu
;source-doc/base-drv/transfers.c:86:
;source-doc/base-drv/transfers.c:85:
l_usb_control_transfer_00113: l_usb_control_transfer_00113:
;source-doc/base-drv/transfers.c:87: RETURN_CHECK(result);
;source-doc/base-drv/transfers.c:86: RETURN_CHECK(result);
push hl push hl
call _critical_end call _critical_end
pop hl pop hl
;source-doc/base-drv/transfers.c:88: }
;source-doc/base-drv/transfers.c:87: }
l_usb_control_transfer_00114: l_usb_control_transfer_00114:
;source-doc/base-drv/transfers.c:89:
;source-doc/base-drv/transfers.c:88:
ld sp, ix ld sp, ix
pop ix pop ix
ret ret
;source-doc/base-drv/transfers.c:92:
;source-doc/base-drv/transfers.c:91:
; --------------------------------- ; ---------------------------------
; Function usb_dat_in_trnsfer_ext ; Function usb_dat_in_trnsfer_ext
; --------------------------------- ; ---------------------------------
@ -263,26 +263,26 @@ _usb_dat_in_trnsfer_ext:
push ix push ix
ld ix,0 ld ix,0
add ix,sp add ix,sp
;source-doc/base-drv/transfers.c:93: RETURN_CHECK(result);
;source-doc/base-drv/transfers.c:92: RETURN_CHECK(result);
ld a,(ix+5) ld a,(ix+5)
or (ix+4) or (ix+4)
jr Z,l_usb_dat_in_trnsfer_ext_00102 jr Z,l_usb_dat_in_trnsfer_ext_00102
ld a,(ix+5) ld a,(ix+5)
sub 0x80 sub 0x80
jr NC,l_usb_dat_in_trnsfer_ext_00102 jr NC,l_usb_dat_in_trnsfer_ext_00102
;source-doc/base-drv/transfers.c:94:
;source-doc/base-drv/transfers.c:93:
ld l,0x82 ld l,0x82
jr l_usb_dat_in_trnsfer_ext_00106 jr l_usb_dat_in_trnsfer_ext_00106
l_usb_dat_in_trnsfer_ext_00102: l_usb_dat_in_trnsfer_ext_00102:
;source-doc/base-drv/transfers.c:96: critical_end();
;source-doc/base-drv/transfers.c:95: critical_end();
ld a,(ix+10) ld a,(ix+10)
sub 0x80 sub 0x80
jr NC,l_usb_dat_in_trnsfer_ext_00105 jr NC,l_usb_dat_in_trnsfer_ext_00105
;source-doc/base-drv/transfers.c:97: return result;
;source-doc/base-drv/transfers.c:96: return result;
ld l,0x82 ld l,0x82
jr l_usb_dat_in_trnsfer_ext_00106 jr l_usb_dat_in_trnsfer_ext_00106
l_usb_dat_in_trnsfer_ext_00105: l_usb_dat_in_trnsfer_ext_00105:
;source-doc/base-drv/transfers.c:99:
;source-doc/base-drv/transfers.c:98:
ld l,(ix+9) ld l,(ix+9)
ld h,(ix+10) ld h,(ix+10)
push hl push hl
@ -301,67 +301,10 @@ l_usb_dat_in_trnsfer_ext_00105:
pop af pop af
inc sp inc sp
l_usb_dat_in_trnsfer_ext_00106: l_usb_dat_in_trnsfer_ext_00106:
;source-doc/base-drv/transfers.c:100: usb_error
;source-doc/base-drv/transfers.c:99: usb_error
pop ix pop ix
ret ret
;source-doc/base-drv/transfers.c:103: return USB_BAD_ADDRESS;
; ---------------------------------
; Function usb_dat_in_trns_n_ext
; ---------------------------------
_usb_dat_in_trns_n_ext:
push ix
ld ix,0
add ix,sp
;source-doc/base-drv/transfers.c:104:
ld a,(ix+5)
or (ix+4)
jr Z,l_usb_dat_in_trns_n_ext_00102
ld a,(ix+5)
and 0xc0
jr NZ,l_usb_dat_in_trns_n_ext_00102
;source-doc/base-drv/transfers.c:105: if ((uint16_t)endpoint < LOWER_SAFE_RAM_ADDRESS)
ld l,0x82
jr l_usb_dat_in_trns_n_ext_00108
l_usb_dat_in_trns_n_ext_00102:
;source-doc/base-drv/transfers.c:107:
ld a,(ix+10)
and 0xc0
jr NZ,l_usb_dat_in_trns_n_ext_00105
;source-doc/base-drv/transfers.c:108: return usb_data_in_transfer(buffer, buffer_size, device_address, endpoint);
ld l,0x82
jr l_usb_dat_in_trns_n_ext_00108
l_usb_dat_in_trns_n_ext_00105:
;source-doc/base-drv/transfers.c:110:
ld a,(ix+7)
and 0xc0
jr NZ,l_usb_dat_in_trns_n_ext_00107
;source-doc/base-drv/transfers.c:111: usb_error
ld l,0x82
jr l_usb_dat_in_trns_n_ext_00108
l_usb_dat_in_trns_n_ext_00107:
;source-doc/base-drv/transfers.c:113: if (buffer != 0 && ((uint16_t)buffer & 0xC000) == 0)
ld c,(ix+6)
ld b,(ix+7)
ld l,(ix+9)
ld h,(ix+10)
push hl
ld a,(ix+8)
push af
inc sp
push bc
ld l,(ix+4)
ld h,(ix+5)
push hl
call _usb_data_in_transfer_n
pop af
pop af
pop af
inc sp
l_usb_dat_in_trns_n_ext_00108:
;source-doc/base-drv/transfers.c:114: return USB_BAD_ADDRESS;
pop ix
ret
;source-doc/base-drv/transfers.c:119: if (((uint16_t)buffer_size & 0xC000) == 0)
;source-doc/base-drv/transfers.c:104: if ((uint16_t)endpoint < LOWER_SAFE_RAM_ADDRESS)
; --------------------------------- ; ---------------------------------
; Function usb_data_in_transfer ; Function usb_data_in_transfer
; --------------------------------- ; ---------------------------------
@ -369,12 +312,12 @@ _usb_data_in_transfer:
push ix push ix
ld ix,0 ld ix,0
add ix,sp add ix,sp
;source-doc/base-drv/transfers.c:120: return USB_BAD_ADDRESS;
;source-doc/base-drv/transfers.c:105: return USB_BAD_ADDRESS;
call _critical_begin call _critical_begin
;source-doc/base-drv/transfers.c:122: return usb_data_in_transfer_n(buffer, buffer_size, device_address, endpoint);
;source-doc/base-drv/transfers.c:107: return usb_data_in_transfer(buffer, buffer_size, device_address, endpoint);
ld l,(ix+8) ld l,(ix+8)
call _ch_set_usb_address call _ch_set_usb_address
;source-doc/base-drv/transfers.c:124:
;source-doc/base-drv/transfers.c:109:
ld l,(ix+9) ld l,(ix+9)
ld h,(ix+10) ld h,(ix+10)
push hl push hl
@ -390,14 +333,14 @@ _usb_data_in_transfer:
pop af pop af
ld a, l ld a, l
ld (_result), a ld (_result), a
;source-doc/base-drv/transfers.c:126: * @brief Perform a USB data in on the specififed endpoint
;source-doc/base-drv/transfers.c:111: * @brief Perform a USB data in on the specififed endpoint
call _critical_end call _critical_end
;source-doc/base-drv/transfers.c:128: * @param buffer the buffer to receive the data
;source-doc/base-drv/transfers.c:113: * @param buffer the buffer to receive the data
ld hl, (_result) ld hl, (_result)
;source-doc/base-drv/transfers.c:129: * @param buffer_size the maximum size of data to be received
;source-doc/base-drv/transfers.c:114: * @param buffer_size the maximum size of data to be received
pop ix pop ix
ret ret
;source-doc/base-drv/transfers.c:134: usb_error
;source-doc/base-drv/transfers.c:119: usb_error
; --------------------------------- ; ---------------------------------
; Function usb_data_in_transfer_n ; Function usb_data_in_transfer_n
; --------------------------------- ; ---------------------------------
@ -405,12 +348,12 @@ _usb_data_in_transfer_n:
push ix push ix
ld ix,0 ld ix,0
add ix,sp add ix,sp
;source-doc/base-drv/transfers.c:135: 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:120: usb_data_in_transfer(uint8_t *buffer, const uint16_t buffer_size, const uint8_t device_address, endpoint_param *const endpoint) {
call _critical_begin call _critical_begin
;source-doc/base-drv/transfers.c:137:
;source-doc/base-drv/transfers.c:122:
ld l,(ix+8) ld l,(ix+8)
call _ch_set_usb_address call _ch_set_usb_address
;source-doc/base-drv/transfers.c:139:
;source-doc/base-drv/transfers.c:124:
ld l,(ix+9) ld l,(ix+9)
ld h,(ix+10) ld h,(ix+10)
push hl push hl
@ -426,14 +369,14 @@ _usb_data_in_transfer_n:
pop af pop af
ld a, l ld a, l
ld (_result), a ld (_result), a
;source-doc/base-drv/transfers.c:141:
;source-doc/base-drv/transfers.c:126:
call _critical_end call _critical_end
;source-doc/base-drv/transfers.c:143:
;source-doc/base-drv/transfers.c:128:
ld hl, (_result) ld hl, (_result)
;source-doc/base-drv/transfers.c:144: return result;
;source-doc/base-drv/transfers.c:129: return result;
pop ix pop ix
ret ret
;source-doc/base-drv/transfers.c:149: *
;source-doc/base-drv/transfers.c:134: *
; --------------------------------- ; ---------------------------------
; Function usb_data_out_transfer ; Function usb_data_out_transfer
; --------------------------------- ; ---------------------------------
@ -441,12 +384,12 @@ _usb_data_out_transfer:
push ix push ix
ld ix,0 ld ix,0
add ix,sp add ix,sp
;source-doc/base-drv/transfers.c:150: * @param buffer the buffer to receive the data - must be 62 bytes
;source-doc/base-drv/transfers.c:135: * @param buffer the buffer to receive the data - must be 62 bytes
call _critical_begin call _critical_begin
;source-doc/base-drv/transfers.c:152: * @param device_address the usb address of the device
;source-doc/base-drv/transfers.c:137: * @param device_address the usb address of the device
ld l,(ix+8) ld l,(ix+8)
call _ch_set_usb_address call _ch_set_usb_address
;source-doc/base-drv/transfers.c:154: * @return usb_error USB_ERR_OK if all good, otherwise specific error code
;source-doc/base-drv/transfers.c:139: * @return usb_error USB_ERR_OK if all good, otherwise specific error code
ld l,(ix+9) ld l,(ix+9)
ld h,(ix+10) ld h,(ix+10)
push hl push hl
@ -462,10 +405,10 @@ _usb_data_out_transfer:
pop af pop af
ld a, l ld a, l
ld (_result), a ld (_result), a
;source-doc/base-drv/transfers.c:156: usb_error
;source-doc/base-drv/transfers.c:141: usb_error
call _critical_end call _critical_end
;source-doc/base-drv/transfers.c:158: critical_begin();
;source-doc/base-drv/transfers.c:143: critical_begin();
ld hl, (_result) ld hl, (_result)
;source-doc/base-drv/transfers.c:159:
;source-doc/base-drv/transfers.c:144:
pop ix pop ix
ret ret

10
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 call _ch_cmd_set_usb_mode
;source-doc/base-drv/usb-base-drv.c:15: delay_20ms(); ;source-doc/base-drv/usb-base-drv.c:15: delay_20ms();
call _delay_20ms call _delay_20ms
;source-doc/base-drv/ch376.h:111: #endif
;source-doc/base-drv/ch376.h:111:
ld l,0x0b ld l,0x0b
call _ch_command call _ch_command
;source-doc/base-drv/ch376.h:112:
;source-doc/base-drv/ch376.h:112: #endif
ld a,0x25 ld a,0x25
ld bc,_CH376_DATA_PORT ld bc,_CH376_DATA_PORT
out (c), a out (c), a
;source-doc/base-drv/ch376.h:113: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF)
;source-doc/base-drv/ch376.h:113:
ld a,0xdf ld a,0xdf
ld bc,_CH376_DATA_PORT ld bc,_CH376_DATA_PORT
out (c), a out (c), a
@ -201,7 +201,7 @@ l_usb_init_00112:
l_usb_init_00113: l_usb_init_00113:
;source-doc/base-drv/usb-base-drv.c:69: } ;source-doc/base-drv/usb-base-drv.c:69: }
ret ret
;source-doc/base-drv/usb-base-drv.c:71: uint8_t usb_scsi_seek(const uint16_t dev_index, const uint32_t lba) {
;source-doc/base-drv/usb-base-drv.c:71: usb_error usb_scsi_seek(const uint16_t dev_index, const uint32_t lba) {
; --------------------------------- ; ---------------------------------
; Function usb_scsi_seek ; Function usb_scsi_seek
; --------------------------------- ; ---------------------------------
@ -220,7 +220,7 @@ _usb_scsi_seek:
add hl, sp add hl, sp
ld bc,0x0004 ld bc,0x0004
ldir ldir
;source-doc/base-drv/usb-base-drv.c:75: return 0;
;source-doc/base-drv/usb-base-drv.c:75: return USB_ERR_OK;
ld l,0x00 ld l,0x00
;source-doc/base-drv/usb-base-drv.c:76: } ;source-doc/base-drv/usb-base-drv.c:76: }
pop ix pop ix

32
Source/HBIOS/ch376-native/base-drv/usb_state.c.s

@ -187,14 +187,14 @@ l_next_device_config_00102:
l_next_device_config_00105: l_next_device_config_00105:
;source-doc/base-drv/usb_state.c:72: } ;source-doc/base-drv/usb_state.c:72: }
ret ret
;source-doc/base-drv/usb_state.c:75: device_config *get_usb_device_config(const uint8_t device_index) __sdcccall(1) {
;source-doc/base-drv/usb_state.c:74: device_config *get_usb_device_config(const uint8_t device_index) __sdcccall(1) {
; --------------------------------- ; ---------------------------------
; Function get_usb_device_config ; Function get_usb_device_config
; --------------------------------- ; ---------------------------------
_get_usb_device_config: _get_usb_device_config:
ld c, a ld c, a
;source-doc/base-drv/usb_state.c:76: const _usb_state *const usb_state = get_usb_work_area();
;source-doc/base-drv/usb_state.c:80: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) {
;source-doc/base-drv/usb_state.c:75: const _usb_state *const usb_state = get_usb_work_area();
;source-doc/base-drv/usb_state.c:79: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) {
push bc push bc
ld hl,_x ld hl,_x
call _first_device_config call _first_device_config
@ -204,33 +204,33 @@ l_get_usb_device_config_00107:
ld a, d ld a, d
or e or e
jr Z,l_get_usb_device_config_00105 jr Z,l_get_usb_device_config_00105
;source-doc/base-drv/usb_state.c:81: if (p->type != USB_NOT_SUPPORTED) {
;source-doc/base-drv/usb_state.c:80: if (p->type != USB_NOT_SUPPORTED) {
ld l, e ld l, e
ld h, d ld h, d
ld a, (hl) ld a, (hl)
and 0x0f and 0x0f
jr Z,l_get_usb_device_config_00108 jr Z,l_get_usb_device_config_00108
;source-doc/base-drv/usb_state.c:82: if (counter == device_index)
;source-doc/base-drv/usb_state.c:81: if (counter == device_index)
ld a, c ld a, c
sub b sub b
;source-doc/base-drv/usb_state.c:83: return p;
;source-doc/base-drv/usb_state.c:82: return p;
jr Z,l_get_usb_device_config_00109 jr Z,l_get_usb_device_config_00109
;source-doc/base-drv/usb_state.c:84: counter++;
;source-doc/base-drv/usb_state.c:83: counter++;
inc b inc b
l_get_usb_device_config_00108: l_get_usb_device_config_00108:
;source-doc/base-drv/usb_state.c:80: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) {
;source-doc/base-drv/usb_state.c:79: for (device_config *p = first_device_config(usb_state); p; p = next_device_config(usb_state, p)) {
push bc push bc
ld hl,_x ld hl,_x
call _next_device_config call _next_device_config
pop bc pop bc
jr l_get_usb_device_config_00107 jr l_get_usb_device_config_00107
l_get_usb_device_config_00105: l_get_usb_device_config_00105:
;source-doc/base-drv/usb_state.c:88: return NULL; // is not a usb device
;source-doc/base-drv/usb_state.c:87: return NULL; // is not a usb device
ld de,0x0000 ld de,0x0000
l_get_usb_device_config_00109: l_get_usb_device_config_00109:
;source-doc/base-drv/usb_state.c:89: }
;source-doc/base-drv/usb_state.c:88: }
ret ret
;source-doc/base-drv/usb_state.c:91: usb_device_type get_usb_device_type(const uint8_t dev_index) {
;source-doc/base-drv/usb_state.c:90: usb_device_type get_usb_device_type(const uint8_t dev_index) {
; --------------------------------- ; ---------------------------------
; Function get_usb_device_type ; Function get_usb_device_type
; --------------------------------- ; ---------------------------------
@ -238,24 +238,24 @@ _get_usb_device_type:
push ix push ix
ld ix,0 ld ix,0
add ix,sp add ix,sp
;source-doc/base-drv/usb_state.c:92: const device_config *dev = get_usb_device_config(dev_index);
;source-doc/base-drv/usb_state.c:91: const device_config *dev = get_usb_device_config(dev_index);
ld a,(ix+4) ld a,(ix+4)
call _get_usb_device_config call _get_usb_device_config
ld l, e ld l, e
;source-doc/base-drv/usb_state.c:94: if (dev == NULL)
;source-doc/base-drv/usb_state.c:93: if (dev == NULL)
ld a,d ld a,d
ld h,a ld h,a
or e or e
jr NZ,l_get_usb_device_type_00102 jr NZ,l_get_usb_device_type_00102
;source-doc/base-drv/usb_state.c:95: return -1;
;source-doc/base-drv/usb_state.c:94: return -1;
ld l,0xff ld l,0xff
jr l_get_usb_device_type_00103 jr l_get_usb_device_type_00103
l_get_usb_device_type_00102: l_get_usb_device_type_00102:
;source-doc/base-drv/usb_state.c:97: return dev->type;
;source-doc/base-drv/usb_state.c:96: return dev->type;
ld a, (hl) ld a, (hl)
and 0x0f and 0x0f
ld l, a ld l, a
l_get_usb_device_type_00103: l_get_usb_device_type_00103:
;source-doc/base-drv/usb_state.c:98: }
;source-doc/base-drv/usb_state.c:97: }
pop ix pop ix
ret ret

12
Source/HBIOS/ch376-native/keyboard/kyb_driver.c.s

@ -358,14 +358,14 @@ _usb_kyb_tick:
or a or a
;source-doc/keyboard/kyb_driver.c:120: if (is_in_critical_section()) ;source-doc/keyboard/kyb_driver.c:120: if (is_in_critical_section())
jr NZ,l_usb_kyb_tick_00112 jr NZ,l_usb_kyb_tick_00112
;././source-doc/base-drv//ch376.h:111: #endif
;././source-doc/base-drv//ch376.h:111:
ld l,0x0b ld l,0x0b
call _ch_command call _ch_command
;././source-doc/base-drv//ch376.h:112:
;././source-doc/base-drv//ch376.h:112: #endif
ld a,0x25 ld a,0x25
ld bc,_CH376_DATA_PORT ld bc,_CH376_DATA_PORT
out (c), a out (c), a
;././source-doc/base-drv//ch376.h:113: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF)
;././source-doc/base-drv//ch376.h:113:
ld a,0x1f ld a,0x1f
ld bc,_CH376_DATA_PORT ld bc,_CH376_DATA_PORT
out (c), a out (c), a
@ -383,14 +383,14 @@ _usb_kyb_tick:
inc sp inc sp
ld a, l ld a, l
ld (_result), a ld (_result), a
;././source-doc/base-drv//ch376.h:111: #endif
;././source-doc/base-drv//ch376.h:111:
ld l,0x0b ld l,0x0b
call _ch_command call _ch_command
;././source-doc/base-drv//ch376.h:112:
;././source-doc/base-drv//ch376.h:112: #endif
ld a,0x25 ld a,0x25
ld bc,_CH376_DATA_PORT ld bc,_CH376_DATA_PORT
out (c), a out (c), a
;././source-doc/base-drv//ch376.h:113: #define calc_max_packet_sizex(packet_size) (packet_size & 0x3FF)
;././source-doc/base-drv//ch376.h:113:
ld a,0xdf ld a,0xdf
ld bc,_CH376_DATA_PORT ld bc,_CH376_DATA_PORT
out (c), a out (c), a

4
Source/HBIOS/ch376-native/source-doc/base-drv/ch376.c

@ -109,7 +109,7 @@ uint8_t ch_probe(void) {
return false; return false;
} }
uint8_t ch_cmd_set_usb_mode(const uint8_t mode) __z88dk_fastcall {
usb_error ch_cmd_set_usb_mode(const uint8_t mode) __z88dk_fastcall {
uint8_t result = 0; uint8_t result = 0;
CH376_COMMAND_PORT = CH_CMD_SET_USB_MODE; CH376_COMMAND_PORT = CH_CMD_SET_USB_MODE;
@ -187,7 +187,7 @@ done:
} }
// TODO: review: does buffer_size need to be signed? // TODO: review: does buffer_size need to be signed?
usb_error ch_data_in_transfer_n(uint8_t *const buffer, int8_t *const buffer_size, endpoint_param *const endpoint) {
usb_error ch_data_in_transfer_n(uint8_t *const buffer, uint8_t *const buffer_size, endpoint_param *const endpoint) {
uint8_t count; uint8_t count;
usb_error result; usb_error result;

3
Source/HBIOS/ch376-native/source-doc/base-drv/ch376.h

@ -4,6 +4,7 @@
#include "ch376inc.h" #include "ch376inc.h"
#include "delay.h" #include "delay.h"
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
typedef enum { typedef enum {
@ -157,7 +158,7 @@ extern usb_error ch_control_transfer_request_descriptor(const uint8_t descriptor
extern usb_error ch_control_transfer_set_address(const uint8_t device_address) __z88dk_fastcall; extern usb_error ch_control_transfer_set_address(const uint8_t device_address) __z88dk_fastcall;
extern usb_error ch_control_transfer_set_config(const uint8_t config_value) __z88dk_fastcall; extern usb_error ch_control_transfer_set_config(const uint8_t config_value) __z88dk_fastcall;
extern usb_error ch_data_in_transfer(uint8_t *buffer, int16_t data_length, endpoint_param *const endpoint); extern usb_error ch_data_in_transfer(uint8_t *buffer, int16_t data_length, endpoint_param *const endpoint);
extern usb_error ch_data_in_transfer_n(uint8_t *buffer, int8_t *const buffer_size, endpoint_param *const endpoint);
extern usb_error ch_data_in_transfer_n(uint8_t *buffer, uint8_t *const buffer_size, endpoint_param *const endpoint);
extern usb_error ch_data_out_transfer(const uint8_t *buffer, int16_t buffer_length, endpoint_param *const endpoint); extern usb_error ch_data_out_transfer(const uint8_t *buffer, int16_t buffer_length, endpoint_param *const endpoint);
inline void ch_configure_nak_retry(const ch_nak_retry_type retry, const uint8_t number_of_retries) { inline void ch_configure_nak_retry(const ch_nak_retry_type retry, const uint8_t number_of_retries) {

51
Source/HBIOS/ch376-native/source-doc/base-drv/class_hub.h

@ -36,40 +36,27 @@ typedef struct {
} hub_descriptor; } hub_descriptor;
typedef struct { typedef struct {
union {
struct {
uint8_t port_connection : 1;
uint8_t port_enable : 1;
uint8_t port_suspend : 1;
uint8_t port_over_current : 1;
uint8_t port_reset : 1;
uint8_t reserved : 3;
uint8_t port_power : 1;
uint8_t port_low_speed : 1;
uint8_t port_high_speed : 1;
uint8_t port_test : 1;
uint8_t port_indicator : 1;
};
uint16_t val;
} wPortStatus;
union {
struct {
uint8_t c_port_connection : 1;
uint8_t c_port_enable : 1;
uint8_t c_port_suspend : 1;
uint8_t c_port_over_current : 1;
uint8_t c_port_reset : 1;
};
uint16_t val;
} wPortChange;
uint16_t wPortStatus;
uint16_t wPortChange;
} hub_port_status; } hub_port_status;
#define PORT_STAT_CONNECTION 0x0001
#define PORT_STAT_ENABLE 0x0002
#define PORT_STAT_SUSPEND 0x0004
#define PORT_STAT_OVERCURRENT 0x0008
#define PORT_STAT_RESET 0x0010
#define PORT_STAT_POWER 0x0100
#define PORT_STAT_LOW_SPEED 0x0200
#define PORT_STAT_HIGH_SPEED 0x0400
#define PORT_STAT_TEST 0x0800
#define PORT_STAT_INDICATOR 0x1000
#define PORT_STAT_C_CONNECTION 0x0001
#define PORT_STAT_C_ENABLE 0x0002
#define PORT_STAT_C_SUSPEND 0x0004
#define PORT_STAT_C_OVERCURRENT 0x0008
#define PORT_STAT_C_RESET 0x0010
usb_error hub_get_descriptor(const device_config_hub *const hub_config, hub_descriptor *const hub_description) __sdcccall(1); usb_error hub_get_descriptor(const device_config_hub *const hub_config, hub_descriptor *const hub_description) __sdcccall(1);
#endif #endif

5
Source/HBIOS/ch376-native/source-doc/base-drv/dev_transfers.c

@ -12,13 +12,12 @@
#include "dev_transfers.h" #include "dev_transfers.h"
#include "ch376.h" #include "ch376.h"
#include "critical-section.h"
#include "delay.h" #include "delay.h"
#include "ez80-helpers.h"
#include "protocol.h" #include "protocol.h"
#include <stdlib.h> #include <stdlib.h>
#include <critical-section.h>
#include "ez80-helpers.h"
/** /**
* @brief Perform a USB control transfer (in or out) * @brief Perform a USB control transfer (in or out)
* See https://www.beyondlogic.org/usbnutshell/usb4.shtml for a description of the USB control transfer * See https://www.beyondlogic.org/usbnutshell/usb4.shtml for a description of the USB control transfer

2
Source/HBIOS/ch376-native/source-doc/base-drv/enumerate_hub.c

@ -58,7 +58,7 @@ usb_error configure_usb_hub(_working *const working) __z88dk_fastcall {
CHECK(hub_get_status_port(hub_config, i, &port_status)); CHECK(hub_get_status_port(hub_config, i, &port_status));
if (port_status.wPortStatus.port_connection) {
if (port_status.wPortStatus & PORT_STAT_CONNECTION) {
CHECK(hub_clear_feature(hub_config, HUB_FEATURE_PORT_CONNECTION_CHANGE, i)); CHECK(hub_clear_feature(hub_config, HUB_FEATURE_PORT_CONNECTION_CHANGE, i));
CHECK(hub_clear_feature(hub_config, FEAT_PORT_ENABLE_CHANGE, i)); CHECK(hub_clear_feature(hub_config, FEAT_PORT_ENABLE_CHANGE, i));

1
Source/HBIOS/ch376-native/source-doc/base-drv/enumerate_storage.h

@ -1,6 +1,7 @@
#ifndef __USB_ENUMERATE_STORAGE #ifndef __USB_ENUMERATE_STORAGE
#define __USB_ENUMERATE_STORAGE #define __USB_ENUMERATE_STORAGE
#include "dev_transfers.h"
#include "protocol.h" #include "protocol.h"
extern void parse_endpoints(device_config_storage *const storage_dev, const endpoint_descriptor const *pEndpoint); extern void parse_endpoints(device_config_storage *const storage_dev, const endpoint_descriptor const *pEndpoint);

1
Source/HBIOS/ch376-native/source-doc/base-drv/print.h

@ -1,6 +1,7 @@
#ifndef __XPRINT #ifndef __XPRINT
#define __XPRINT #define __XPRINT
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
extern void print_hex(const char c) __z88dk_fastcall; extern void print_hex(const char c) __z88dk_fastcall;

19
Source/HBIOS/ch376-native/source-doc/base-drv/transfers.c

@ -12,11 +12,10 @@
#include "transfers.h" #include "transfers.h"
#include "ch376.h" #include "ch376.h"
#include "critical-section.h"
#include "delay.h" #include "delay.h"
#include "ez80-helpers.h" #include "ez80-helpers.h"
#include "print.h" #include "print.h"
#include "z80.h"
#include <critical-section.h>
#include <stdlib.h> #include <stdlib.h>
#define LOWER_SAFE_RAM_ADDRESS 0x8000 #define LOWER_SAFE_RAM_ADDRESS 0x8000
@ -108,20 +107,6 @@ usb_dat_in_trnsfer_ext(uint8_t *buffer, const uint16_t buffer_size, const uint8_
return usb_data_in_transfer(buffer, buffer_size, device_address, endpoint); return usb_data_in_transfer(buffer, buffer_size, device_address, endpoint);
} }
usb_error
usb_dat_in_trns_n_ext(uint8_t *buffer, uint16_t *buffer_size, const uint8_t device_address, endpoint_param *const endpoint) {
if (buffer != 0 && ((uint16_t)buffer & 0xC000) == 0)
return USB_BAD_ADDRESS;
if (((uint16_t)endpoint & 0xC000) == 0)
return USB_BAD_ADDRESS;
if (((uint16_t)buffer_size & 0xC000) == 0)
return USB_BAD_ADDRESS;
return usb_data_in_transfer_n(buffer, buffer_size, device_address, endpoint);
}
/** /**
* @brief Perform a USB data in on the specififed endpoint * @brief Perform a USB data in on the specififed endpoint
* *
@ -145,7 +130,7 @@ usb_data_in_transfer(uint8_t *buffer, const uint16_t buffer_size, const uint8_t
} }
/** /**
* @brief Perform a USB data in on the specififed endpoint
* @brief Perform a USB data in on the specified endpoint
* *
* @param buffer the buffer to receive the data - must be 62 bytes * @param buffer the buffer to receive the data - must be 62 bytes
* @param buffer_size on exit the actual size of data received * @param buffer_size on exit the actual size of data received

4
Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.c

@ -68,9 +68,9 @@ uint16_t usb_init(uint8_t state) __z88dk_fastcall {
return (uint16_t)count_of_devices() << 8 | 4; return (uint16_t)count_of_devices() << 8 | 4;
} }
uint8_t usb_scsi_seek(const uint16_t dev_index, const uint32_t lba) {
usb_error usb_scsi_seek(const uint16_t dev_index, const uint32_t lba) {
device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index); device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index);
dev->current_lba = lba; dev->current_lba = lba;
return 0;
return USB_ERR_OK;
} }

2
Source/HBIOS/ch376-native/source-doc/base-drv/usb-base-drv.h

@ -1,8 +1,8 @@
#ifndef __USB_BASE_DRV #ifndef __USB_BASE_DRV
#define __USB_BASE_DRV #define __USB_BASE_DRV
#include "dev_transfers.h"
#include "usb_state.h" #include "usb_state.h"
#include <dev_transfers.h>
#include <stdint.h> #include <stdint.h>
extern uint16_t usb_init(uint8_t state) __z88dk_fastcall; extern uint16_t usb_init(uint8_t state) __z88dk_fastcall;

1
Source/HBIOS/ch376-native/source-doc/base-drv/usb_state.c

@ -71,7 +71,6 @@ device_config *next_device_config(const _usb_state *const usb_state, const devic
return result; return result;
} }
// always usb work area
device_config *get_usb_device_config(const uint8_t device_index) __sdcccall(1) { device_config *get_usb_device_config(const uint8_t device_index) __sdcccall(1) {
const _usb_state *const usb_state = get_usb_work_area(); const _usb_state *const usb_state = get_usb_work_area();

6
Source/HBIOS/ch376-native/source-doc/base-drv/z80.h

@ -1,6 +0,0 @@
#ifndef __Z80_HELPERS
#define __Z80_HELPERS
#include <stdint.h>
#endif
Loading…
Cancel
Save