Browse Source

ch376-native: ufi driver refactor - removed use of bit fields to ensure compatibility with other c compilers

pull/592/head
Dean Netherton 9 months ago
parent
commit
f0133d1b1b
  1. 4
      Source/HBIOS/Config/RCEZ80_std.asm
  2. 2
      Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s
  3. 23
      Source/HBIOS/ch376-native/source-doc/ufi-drv/class_ufi.c
  4. 71
      Source/HBIOS/ch376-native/source-doc/ufi-drv/class_ufi.h
  5. 6
      Source/HBIOS/ch376-native/source-doc/ufi-drv/ufi_driver.c
  6. 2
      Source/HBIOS/ch376-native/source-doc/ufi-drv/ufi_driver.h
  7. 114
      Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s
  8. 2
      Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s
  9. 18
      Source/HBIOS/ch376-native/ufi-drv/ufi_driver.c.s

4
Source/HBIOS/Config/RCEZ80_std.asm

@ -89,7 +89,7 @@ CH1USBENABLE .SET FALSE ; CH376: ENABLE CH376 USB DRIVER
CHNATIVEENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE USB DRIVER CHNATIVEENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE USB DRIVER
CHNATIVEFORCE .SET TRUE ; CH376: DISABLE AUTO-DETECTION OF MODULE - ASSUME ITS INSTALLED CHNATIVEFORCE .SET TRUE ; CH376: DISABLE AUTO-DETECTION OF MODULE - ASSUME ITS INSTALLED
CHSCSIENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE MASS STORAGE DEVICES (REQUIRES CHNATIVEENABLE) CHSCSIENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE MASS STORAGE DEVICES (REQUIRES CHNATIVEENABLE)
CHUFIENABLE .SET FALSE ; CH376: ENABLE CH376 NATIVE UFI FLOPPY DISK DEVICES (REQUIRES CHNATIVEENABLE)
CHNATIVEEZ80 .SET TRUE
CHUFIENABLE .SET TRUE ; CH376: ENABLE CH376 NATIVE UFI FLOPPY DISK DEVICES (REQUIRES CHNATIVEENABLE)
CHNATIVEEZ80 .SET FALSE
EZ80TIMER .SET EZ80TMR_INT ; EZ80: TIMER TICK MODEL: EZ80TMR_[INT|FIRM] EZ80TIMER .SET EZ80TMR_INT ; EZ80: TIMER TICK MODEL: EZ80TMR_[INT|FIRM]

2
Source/HBIOS/ch376-native/scsi-drv/scsi-init.c.s

@ -76,7 +76,7 @@ l_chscsi_init_00103:
jr NZ,l_chscsi_init_00104 jr NZ,l_chscsi_init_00104
;source-doc/scsi-drv/scsi-init.c:15: const uint8_t dev_index = find_storage_dev(); // index == -1 (no more left) should never happen ;source-doc/scsi-drv/scsi-init.c:15: const uint8_t dev_index = find_storage_dev(); // index == -1 (no more left) should never happen
call _find_storage_dev call _find_storage_dev
;source-doc/scsi-drv/scsi-init.c:17: hbios_usb_storage_devices[dev_index].drive_index = dev_index+1;
;source-doc/scsi-drv/scsi-init.c:17: hbios_usb_storage_devices[dev_index].drive_index = dev_index + 1;
ld a, l ld a, l
ld c,0x00 ld c,0x00
add a, a add a, a

23
Source/HBIOS/ch376-native/source-doc/ufi-drv/class_ufi.c

@ -5,11 +5,11 @@
#include <string.h> #include <string.h>
#include <z80.h> #include <z80.h>
const ufi_request_sense_command _ufi_cmd_request_sense = {0x03, 0, 0, 0, 0, 18, {0, 0, 0, 0, 0, 0, 0}};
const ufi_read_format_capacities_command _ufi_cmd_read_format_capacities = {0x23, 0, 0, {0, 0, 0, 0, 0}, {0, 12}, {0, 0, 0}};
const ufi_inquiry_command _ufi_cmd_inquiry = {0x12, 0, 0, 0, 0, 0, 0x24, {0, 0, 0, 0, 0, 0, 0}};
const ufi_format_command _ufi_cmd_format = {0x04, 7, 0, 1, 0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0, 0}};
const ufi_send_diagnostic_command _ufi_cmd_send_diagnostic = {0x1D, 0, 0, 1, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
const ufi_request_sense_command _ufi_cmd_request_sense = {0x03, 0, 0, 0, 18, {0, 0, 0, 0, 0, 0, 0}};
const ufi_read_format_capacities_command _ufi_cmd_read_format_capacities = {0x23, 0, {0, 0, 0, 0, 0}, {0, 12}, {0, 0, 0}};
const ufi_inquiry_command _ufi_cmd_inquiry = {0x12, 0, 0, 0, 0x24, {0, 0, 0, 0, 0, 0, 0}};
const ufi_format_command _ufi_cmd_format = {0x04, 7 | 1 << 4, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0, 0}};
const ufi_send_diagnostic_command _ufi_cmd_send_diagnostic = {0x1D, 1 << 2, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
uint8_t wait_for_device_ready(device_config *const storage_device, uint8_t timeout_counter) { uint8_t wait_for_device_ready(device_config *const storage_device, uint8_t timeout_counter) {
usb_error result; usb_error result;
@ -19,14 +19,14 @@ uint8_t wait_for_device_ready(device_config *const storage_device, uint8_t timeo
memset(&sense, 0, sizeof(sense)); memset(&sense, 0, sizeof(sense));
result = ufi_test_unit_ready(storage_device, &sense); result = ufi_test_unit_ready(storage_device, &sense);
if ((result == USB_ERR_OK && sense.sense_key == 0) || timeout_counter-- == 0)
if ((result == USB_ERR_OK && (sense.sense_key & 15) == 0) || timeout_counter-- == 0)
break; break;
delay_medium(); delay_medium();
} while (true); } while (true);
return result | sense.sense_key;
return result | (sense.sense_key & 15);
} }
usb_error ufi_test_unit_ready(device_config *const storage_device, ufi_request_sense_response const *response) { usb_error ufi_test_unit_ready(device_config *const storage_device, ufi_request_sense_response const *response) {
@ -141,13 +141,8 @@ usb_error ufi_format(device_config *const storage_device,
cmd.interleave[1] = 0; cmd.interleave[1] = 0;
cmd.parameter_list_length[1] = sizeof(parameter_list); cmd.parameter_list_length[1] = sizeof(parameter_list);
parameter_list.defect_list_header.side = side;
parameter_list.defect_list_header.immediate = 0;
parameter_list.defect_list_header.reserved2 = 0;
parameter_list.defect_list_header.single_track = 1;
parameter_list.defect_list_header.dcrt = 1;
parameter_list.defect_list_header.extend = 0;
parameter_list.defect_list_header.fov = 1;
parameter_list.defect_list_header.status =
FMT_DEFECT_STATUS_FOV | FMT_DEFECT_STATUS_DCRT | FMT_DEFECT_STATUS_SINGLE_TRACK | (side & 1);
parameter_list.defect_list_header.defect_list_length_msb = 0; parameter_list.defect_list_header.defect_list_length_msb = 0;
parameter_list.defect_list_header.defect_list_length_lsb = 8; parameter_list.defect_list_header.defect_list_length_lsb = 8;
memcpy(&parameter_list.format_descriptor, (void *)format, sizeof(ufi_format_capacity_descriptor)); memcpy(&parameter_list.format_descriptor, (void *)format, sizeof(ufi_format_capacity_descriptor));

71
Source/HBIOS/ch376-native/source-doc/ufi-drv/class_ufi.h

@ -14,8 +14,7 @@ typedef struct {
typedef struct { typedef struct {
uint8_t operation_code; uint8_t operation_code;
uint8_t reserverd1 : 5;
uint8_t lun : 3;
uint8_t lun; // in top 3 bits
uint8_t reserved1[5]; uint8_t reserved1[5];
uint8_t allocation_length[2]; uint8_t allocation_length[2];
uint8_t reserved[3]; uint8_t reserved[3];
@ -29,8 +28,7 @@ typedef enum { UNFORMATTED_MEDIA = 1, FORMATTED_MEDIA = 2, NO_MEDIA = 3 } UFI_DE
typedef struct { typedef struct {
uint8_t number_of_blocks[4]; uint8_t number_of_blocks[4];
uint8_t descriptor_code : 2; // UFI_DESCRIPTOR_CODE
uint8_t reserved2 : 6;
uint8_t descriptor_codex; // UFI_DESCRIPTOR_CODE
uint8_t block_size[3]; uint8_t block_size[3];
} ufi_format_capacity_descriptor; } ufi_format_capacity_descriptor;
@ -48,9 +46,7 @@ typedef struct {
typedef struct { typedef struct {
uint8_t operation_code; uint8_t operation_code;
uint8_t evpd : 1;
uint8_t reserved1 : 4;
uint8_t lun : 3;
uint8_t lun_and_evpd;
uint8_t page_code; uint8_t page_code;
uint8_t reserved3; uint8_t reserved3;
uint8_t allocation_length; uint8_t allocation_length;
@ -59,8 +55,7 @@ typedef struct {
typedef struct { typedef struct {
uint8_t operation_code; uint8_t operation_code;
uint8_t reserverd1 : 5;
uint8_t lun : 3;
uint8_t lun; // top 3 bits
uint8_t reserved2; uint8_t reserved2;
uint8_t reserved3; uint8_t reserved3;
uint8_t allocation_length; uint8_t allocation_length;
@ -70,8 +65,7 @@ typedef struct {
typedef struct { typedef struct {
uint8_t error_code; uint8_t error_code;
uint8_t reserved1; uint8_t reserved1;
uint8_t sense_key : 4;
uint8_t reserved2 : 4;
uint8_t sense_key; // lower 4 bits
uint8_t information[4]; uint8_t information[4];
uint8_t additional_length; uint8_t additional_length;
uint8_t reserved3[4]; uint8_t reserved3[4];
@ -84,22 +78,17 @@ typedef struct {
// device_type: identifies the device currently connected to the requested logical unit. // device_type: identifies the device currently connected to the requested logical unit.
// 00h Direct-access device (floppy) // 00h Direct-access device (floppy)
// 1Fh none (no FDD connected to the requested logical unit) // 1Fh none (no FDD connected to the requested logical unit)
uint8_t device_type : 5;
uint8_t reserved1 : 3;
uint8_t device_typex; // lower 5 bits
uint8_t reserved2 : 7;
// Removable Media Bit: this shall be set to one to indicate removable media. // Removable Media Bit: this shall be set to one to indicate removable media.
uint8_t removable_media : 1;
uint8_t removable_mediax; // top bit
// ANSI Version: must contain a zero to comply with this version of the Specification. // ANSI Version: must contain a zero to comply with this version of the Specification.
uint8_t ansi_version : 3;
// ISO/ECMA: These fields shall be zero for the UFI device. // ISO/ECMA: These fields shall be zero for the UFI device.
uint8_t ecma : 3;
uint8_t iso_version : 2;
uint8_t version;
// Response Data Format: a value of 01h shall be used for UFI device // Response Data Format: a value of 01h shall be used for UFI device
uint8_t response_data_format : 4;
uint8_t reserved3 : 4;
uint8_t response_data_formatx; // lower 4 bits
// The Additional Length field shall specify the length in bytes of the parameters. If the Allocation Length of the // The Additional Length field shall specify the length in bytes of the parameters. If the Allocation Length of the
// Command Packet is too small to transfer all of the parameters, the Additional Length shall not be adjusted to // Command Packet is too small to transfer all of the parameters, the Additional Length shall not be adjusted to
@ -121,16 +110,8 @@ typedef struct {
typedef struct { typedef struct {
uint8_t operation_code; /*0*/ uint8_t operation_code; /*0*/
union { /*1*/
uint8_t byte_1;
struct {
uint8_t rel_adr : 1;
uint8_t reserved1 : 2;
uint8_t fua : 1;
uint8_t dpo : 1;
uint8_t lun : 3;
};
};
uint8_t byte_1; /*1*/
/* [7:5] lun, [4] dpo, [3] fua, [0]rel_adr*/
uint8_t lba[4]; /*2, 3, 4, 5*/ uint8_t lba[4]; /*2, 3, 4, 5*/
uint8_t reserved2; /*6*/ uint8_t reserved2; /*6*/
uint8_t transfer_length[2]; /*7, 8*/ uint8_t transfer_length[2]; /*7, 8*/
@ -140,13 +121,8 @@ typedef struct {
typedef struct { typedef struct {
struct { struct {
uint8_t reserved1; uint8_t reserved1;
uint8_t side : 1;
uint8_t immediate : 1;
uint8_t reserved2 : 2;
uint8_t single_track : 1;
uint8_t dcrt : 1;
uint8_t extend : 1;
uint8_t fov : 1;
/* [7] FOV, [6] Extend, [5] DCRT, [4] SingleTrack, [1] Immediate, [0] Side*/
uint8_t status;
uint8_t defect_list_length_msb; uint8_t defect_list_length_msb;
uint8_t defect_list_length_lsb; uint8_t defect_list_length_lsb;
} defect_list_header; } defect_list_header;
@ -154,12 +130,17 @@ typedef struct {
ufi_format_capacity_descriptor format_descriptor; ufi_format_capacity_descriptor format_descriptor;
} ufi_format_parameter_list; } ufi_format_parameter_list;
#define FMT_DEFECT_STATUS_FOV 0x80
#define FMT_DEFECT_STATUS_EXTEND 0x40
#define FMT_DEFECT_STATUS_DCRT 0x20
#define FMT_DEFECT_STATUS_SINGLE_TRACK 0x10
#define FMT_DEFECT_STATUS_IMMEDIATE 0x02
#define FMT_DEFECT_STATUS_SIDE 0x01
typedef struct { typedef struct {
uint8_t operation_code; /* 0x04 */ uint8_t operation_code; /* 0x04 */
uint8_t defect_list_format : 3;
uint8_t cmp_list : 1;
uint8_t format_data : 1;
uint8_t lun : 3;
/* [7:5] lun, [4]format_data, [3]cmp_list, [2:0] defect_list_format*/
uint8_t status;
uint8_t track_number; uint8_t track_number;
uint8_t interleave[2]; uint8_t interleave[2];
uint8_t reserved1[2]; uint8_t reserved1[2];
@ -169,12 +150,8 @@ typedef struct {
typedef struct { typedef struct {
uint8_t operation_code; /*0x1D*/ uint8_t operation_code; /*0x1D*/
uint8_t unit_of_l : 1;
uint8_t def_of_l : 1;
uint8_t self_test : 1;
uint8_t reserved1 : 1;
uint8_t pf : 1;
uint8_t lun : 3;
/* [7:5] lun, [4] pf, [2] self test, [1] def of l [0] unit of l*/
uint8_t status;
uint8_t reserved[10]; uint8_t reserved[10];
} ufi_send_diagnostic_command; } ufi_send_diagnostic_command;

6
Source/HBIOS/ch376-native/source-doc/ufi-drv/ufi_driver.c

@ -24,7 +24,7 @@ uint32_t usb_ufi_get_cap(const uint16_t dev_index) {
return convert_from_msb_first(response.descriptors[0].number_of_blocks); 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) {
usb_error 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); device_config_storage *const dev = (device_config_storage *)get_usb_device_config(dev_index);
if (wait_for_device_ready((device_config *)dev, 20) != 0) if (wait_for_device_ready((device_config *)dev, 20) != 0)
@ -46,7 +46,7 @@ uint8_t usb_ufi_read(const uint16_t dev_index, uint8_t *const buffer) {
const uint8_t asc = response.asc; const uint8_t asc = response.asc;
const uint8_t ascq = response.ascq; const uint8_t ascq = response.ascq;
const uint8_t sense_key = response.sense_key;
const uint8_t sense_key = response.sense_key & 15;
if (sense_key != 0) if (sense_key != 0)
return -1; return -1;
@ -76,7 +76,7 @@ usb_error usb_ufi_write(const uint16_t dev_index, uint8_t *const buffer) {
const uint8_t asc = response.asc; const uint8_t asc = response.asc;
const uint8_t ascq = response.ascq; const uint8_t ascq = response.ascq;
const uint8_t sense_key = response.sense_key;
const uint8_t sense_key = response.sense_key & 15;
if (sense_key != 0) if (sense_key != 0)
return -1; return -1;

2
Source/HBIOS/ch376-native/source-doc/ufi-drv/ufi_driver.h

@ -5,7 +5,7 @@
#include <stdint.h> #include <stdint.h>
extern uint32_t usb_ufi_get_cap(const uint16_t dev_index); 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_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); extern usb_error usb_ufi_write(const uint16_t dev_index, uint8_t *const buffer);
#endif #endif

114
Source/HBIOS/ch376-native/ufi-drv/class_ufi.c.s

@ -87,12 +87,10 @@ l_wait_for_device_ready_00132:
ld a, l ld a, l
pop bc pop bc
ld b, a ld b, a
;source-doc/ufi-drv/class_ufi.c:22: if ((result == USB_ERR_OK && sense.sense_key == 0) || timeout_counter-- == 0)
;source-doc/ufi-drv/class_ufi.c:22: if ((result == USB_ERR_OK && (sense.sense_key & 15) == 0) || timeout_counter-- == 0)
or a or a
jr NZ,l_wait_for_device_ready_00104 jr NZ,l_wait_for_device_ready_00104
ld hl,2
add hl, sp
ld a, (hl)
ld a,(ix-16)
and 0x0f and 0x0f
jr Z,l_wait_for_device_ready_00107 jr Z,l_wait_for_device_ready_00107
l_wait_for_device_ready_00104: l_wait_for_device_ready_00104:
@ -107,10 +105,8 @@ l_wait_for_device_ready_00104:
;source-doc/ufi-drv/class_ufi.c:27: } while (true); ;source-doc/ufi-drv/class_ufi.c:27: } while (true);
jr l_wait_for_device_ready_00105 jr l_wait_for_device_ready_00105
l_wait_for_device_ready_00107: l_wait_for_device_ready_00107:
;source-doc/ufi-drv/class_ufi.c:29: return result | sense.sense_key;
ld hl,2
add hl, sp
ld a, (hl)
;source-doc/ufi-drv/class_ufi.c:29: return result | (sense.sense_key & 15);
ld a,(ix-16)
and 0x0f and 0x0f
or b or b
ld l, a ld l, a
@ -120,7 +116,7 @@ l_wait_for_device_ready_00107:
ret ret
__ufi_cmd_request_sense: __ufi_cmd_request_sense:
DEFB +0x03 DEFB +0x03
DEFB 0x00
DEFB +0x00
DEFB +0x00 DEFB +0x00
DEFB +0x00 DEFB +0x00
DEFB +0x12 DEFB +0x12
@ -133,7 +129,7 @@ __ufi_cmd_request_sense:
DEFB +0x00 DEFB +0x00
__ufi_cmd_read_format_capacitie: __ufi_cmd_read_format_capacitie:
DEFB +0x23 DEFB +0x23
DEFB 0x00
DEFB +0x00
DEFB +0x00 DEFB +0x00
DEFB +0x00 DEFB +0x00
DEFB +0x00 DEFB +0x00
@ -146,7 +142,7 @@ __ufi_cmd_read_format_capacitie:
DEFB +0x00 DEFB +0x00
__ufi_cmd_inquiry: __ufi_cmd_inquiry:
DEFB +0x12 DEFB +0x12
DEFB 0x00
DEFB +0x00
DEFB +0x00 DEFB +0x00
DEFB +0x00 DEFB +0x00
DEFB +0x24 DEFB +0x24
@ -159,7 +155,7 @@ __ufi_cmd_inquiry:
DEFB +0x00 DEFB +0x00
__ufi_cmd_format: __ufi_cmd_format:
DEFB +0x04 DEFB +0x04
DEFB 0x17
DEFB +0x17
DEFB +0x00 DEFB +0x00
DEFB +0x00 DEFB +0x00
DEFB +0x00 DEFB +0x00
@ -172,7 +168,7 @@ __ufi_cmd_format:
DEFB +0x00 DEFB +0x00
__ufi_cmd_send_diagnostic: __ufi_cmd_send_diagnostic:
DEFB +0x1d DEFB +0x1d
DEFB 0x04
DEFB +0x04
DEFB +0x00 DEFB +0x00
DEFB +0x00 DEFB +0x00
DEFB +0x00 DEFB +0x00
@ -523,8 +519,6 @@ _ufi_format:
;source-doc/ufi-drv/class_ufi.c:130: const ufi_format_capacity_descriptor *const format) { ;source-doc/ufi-drv/class_ufi.c:130: const ufi_format_capacity_descriptor *const format) {
ld hl,2 ld hl,2
add hl, sp add hl, sp
ld e,l
ld d,h
ld b,0x06 ld b,0x06
l_ufi_format_00104: l_ufi_format_00104:
xor a xor a
@ -534,14 +528,12 @@ l_ufi_format_00104:
inc hl inc hl
djnz l_ufi_format_00104 djnz l_ufi_format_00104
;source-doc/ufi-drv/class_ufi.c:133: ufi_format_parameter_list parameter_list; ;source-doc/ufi-drv/class_ufi.c:133: ufi_format_parameter_list parameter_list;
push de
ld hl,16
ld hl,14
add hl, sp add hl, sp
ex de, hl ex de, hl
ld bc,0x000c ld bc,0x000c
ld hl,__ufi_cmd_format ld hl,__ufi_cmd_format
ldir ldir
pop de
;source-doc/ufi-drv/class_ufi.c:136: ufi_format_command cmd; ;source-doc/ufi-drv/class_ufi.c:136: ufi_format_command cmd;
ld a,(ix+7) ld a,(ix+7)
ld (ix-10),a ld (ix-10),a
@ -550,62 +542,24 @@ l_ufi_format_00104:
;source-doc/ufi-drv/class_ufi.c:138: // memcpy(&cmd, &_ufi_cmd_format, sizeof(cmd)); ;source-doc/ufi-drv/class_ufi.c:138: // memcpy(&cmd, &_ufi_cmd_format, sizeof(cmd));
ld (ix-4),0x0c ld (ix-4),0x0c
;source-doc/ufi-drv/class_ufi.c:140: cmd.track_number = track_number; ;source-doc/ufi-drv/class_ufi.c:140: cmd.track_number = track_number;
ld c, e
ld b, d
inc bc
;source-doc/ufi-drv/class_ufi.c:141: cmd.interleave[1] = 0;
ld a,(ix+6) ld a,(ix+6)
and 0x01 and 0x01
ld l, a
ld a, (bc)
and 0xfe
or l
ld (bc), a
;source-doc/ufi-drv/class_ufi.c:141: cmd.interleave[1] = 0;
ld l, e
ld h, d
inc hl
res 1, (hl)
or 0xb0
ld (ix-23),a
;source-doc/ufi-drv/class_ufi.c:142: cmd.parameter_list_length[1] = sizeof(parameter_list); ;source-doc/ufi-drv/class_ufi.c:142: cmd.parameter_list_length[1] = sizeof(parameter_list);
ld c, e
ld b, d
inc bc
ld a, (bc)
and 0xf3
ld (bc), a
;source-doc/ufi-drv/class_ufi.c:143:
ld l, e
ld h, d
inc hl
set 4, (hl)
;source-doc/ufi-drv/class_ufi.c:144: parameter_list.defect_list_header.side = side;
ld l, e
ld h, d
inc hl
set 5, (hl)
;source-doc/ufi-drv/class_ufi.c:145: parameter_list.defect_list_header.immediate = 0;
ld l, e
ld h, d
inc hl
res 6, (hl)
;source-doc/ufi-drv/class_ufi.c:146: parameter_list.defect_list_header.reserved2 = 0;
ld l, e
ld h, d
inc hl
set 7, (hl)
;source-doc/ufi-drv/class_ufi.c:147: parameter_list.defect_list_header.single_track = 1;
ld (ix-22),0x00 ld (ix-22),0x00
;source-doc/ufi-drv/class_ufi.c:148: parameter_list.defect_list_header.dcrt = 1;
;source-doc/ufi-drv/class_ufi.c:143:
ld (ix-21),0x08 ld (ix-21),0x08
;source-doc/ufi-drv/class_ufi.c:149: parameter_list.defect_list_header.extend = 0;
inc de
inc de
inc de
inc de
;source-doc/ufi-drv/class_ufi.c:144: parameter_list.defect_list_header.status =
ld hl,6
add hl, sp
ex de, hl
ld l,(ix+8) ld l,(ix+8)
ld h,(ix+9) ld h,(ix+9)
ld bc,0x0008 ld bc,0x0008
ldir ldir
;source-doc/ufi-drv/class_ufi.c:151: parameter_list.defect_list_header.defect_list_length_msb = 0;
;source-doc/ufi-drv/class_ufi.c:146: parameter_list.defect_list_header.defect_list_length_msb = 0;
ld hl,0 ld hl,0
add hl, sp add hl, sp
push hl push hl
@ -624,12 +578,12 @@ l_ufi_format_00104:
ld h,(ix+5) ld h,(ix+5)
push hl push hl
call _usb_execute_cbi call _usb_execute_cbi
;source-doc/ufi-drv/class_ufi.c:158: // trace_printf("ufi_format: %d, %02X %02X (len: %d)\r\n", result, sense_codes.bASC, sense_codes.bASCQ, sizeof(parameter_list));
;source-doc/ufi-drv/class_ufi.c:159:
;source-doc/ufi-drv/class_ufi.c:153: // trace_printf("ufi_format: %d, %02X %02X (len: %d)\r\n", result, sense_codes.bASC, sense_codes.bASCQ, sizeof(parameter_list));
;source-doc/ufi-drv/class_ufi.c:154:
ld sp,ix ld sp,ix
pop ix pop ix
ret ret
;source-doc/ufi-drv/class_ufi.c:161: done:
;source-doc/ufi-drv/class_ufi.c:156: done:
; --------------------------------- ; ---------------------------------
; Function ufi_send_diagnostics ; Function ufi_send_diagnostics
; --------------------------------- ; ---------------------------------
@ -640,14 +594,14 @@ _ufi_send_diagnostics:
ld hl, -12 ld hl, -12
add hl, sp add hl, sp
ld sp, hl ld sp, hl
;source-doc/ufi-drv/class_ufi.c:164:
;source-doc/ufi-drv/class_ufi.c:159:
ld hl,0 ld hl,0
add hl, sp add hl, sp
ex de, hl ex de, hl
ld bc,0x000c ld bc,0x000c
ld hl,__ufi_cmd_send_diagnostic ld hl,__ufi_cmd_send_diagnostic
ldir ldir
;source-doc/ufi-drv/class_ufi.c:166: ufi_send_diagnostic_command ufi_cmd_send_diagnostic;
;source-doc/ufi-drv/class_ufi.c:161: ufi_send_diagnostic_command ufi_cmd_send_diagnostic;
ld hl,0x0000 ld hl,0x0000
push hl push hl
push hl push hl
@ -662,11 +616,11 @@ _ufi_send_diagnostics:
ld h,(ix+5) ld h,(ix+5)
push hl push hl
call _usb_execute_cbi call _usb_execute_cbi
;source-doc/ufi-drv/class_ufi.c:167:
;source-doc/ufi-drv/class_ufi.c:162:
ld sp,ix ld sp,ix
pop ix pop ix
ret ret
;source-doc/ufi-drv/class_ufi.c:169:
;source-doc/ufi-drv/class_ufi.c:164:
; --------------------------------- ; ---------------------------------
; Function convert_from_msb_first ; Function convert_from_msb_first
; --------------------------------- ; ---------------------------------
@ -676,40 +630,40 @@ _convert_from_msb_first:
add ix,sp add ix,sp
push af push af
push af push af
;source-doc/ufi-drv/class_ufi.c:171: }
;source-doc/ufi-drv/class_ufi.c:166: }
ld hl,0 ld hl,0
add hl, sp add hl, sp
ex de, hl ex de, hl
;source-doc/ufi-drv/class_ufi.c:172:
;source-doc/ufi-drv/class_ufi.c:167:
ld l,(ix+4) ld l,(ix+4)
ld h,(ix+5) ld h,(ix+5)
inc hl inc hl
inc hl inc hl
inc hl inc hl
;source-doc/ufi-drv/class_ufi.c:174: uint32_t result;
;source-doc/ufi-drv/class_ufi.c:169: uint32_t result;
ld a, (hl) ld a, (hl)
dec hl dec hl
ld (de), a ld (de), a
inc de inc de
;source-doc/ufi-drv/class_ufi.c:175: uint8_t *p_output = ((uint8_t *)&result);
;source-doc/ufi-drv/class_ufi.c:170: uint8_t *p_output = ((uint8_t *)&result);
ld a, (hl) ld a, (hl)
dec hl dec hl
ld (de), a ld (de), a
inc de inc de
;source-doc/ufi-drv/class_ufi.c:176: const uint8_t *p_input = buffer + 3;
;source-doc/ufi-drv/class_ufi.c:171: const uint8_t *p_input = buffer + 3;
ld a, (hl) ld a, (hl)
ld (de), a ld (de), a
inc de inc de
;source-doc/ufi-drv/class_ufi.c:177:
;source-doc/ufi-drv/class_ufi.c:172:
dec hl dec hl
ld a, (hl) ld a, (hl)
ld (de), a ld (de), a
;source-doc/ufi-drv/class_ufi.c:179: *p_output++ = *p_input--;
;source-doc/ufi-drv/class_ufi.c:174: *p_output++ = *p_input--;
pop hl pop hl
push hl push hl
ld e,(ix-2) ld e,(ix-2)
ld d,(ix-1) ld d,(ix-1)
;source-doc/ufi-drv/class_ufi.c:180: *p_output++ = *p_input--;
;source-doc/ufi-drv/class_ufi.c:175: *p_output++ = *p_input--;
ld sp, ix ld sp, ix
pop ix pop ix
ret ret

2
Source/HBIOS/ch376-native/ufi-drv/ufi-init.c.s

@ -76,7 +76,7 @@ l_chufi_init_00103:
call _find_storage_dev call _find_storage_dev
ld (ix-2),l ld (ix-2),l
pop de pop de
;source-doc/ufi-drv/ufi-init.c:17: hbios_usb_storage_devices[dev_index].drive_index = dev_index+1;
;source-doc/ufi-drv/ufi-init.c:17: hbios_usb_storage_devices[dev_index].drive_index = dev_index + 1;
ld l,(ix-2) ld l,(ix-2)
ld h,0x00 ld h,0x00
add hl, hl add hl, hl

18
Source/HBIOS/ch376-native/ufi-drv/ufi_driver.c.s

@ -132,7 +132,7 @@ l_usb_ufi_get_cap_00103:
ld sp, ix ld sp, ix
pop ix pop ix
ret ret
;source-doc/ufi-drv/ufi_driver.c:27: uint8_t usb_ufi_read(const uint16_t dev_index, uint8_t *const buffer) {
;source-doc/ufi-drv/ufi_driver.c:27: usb_error usb_ufi_read(const uint16_t dev_index, uint8_t *const buffer) {
; --------------------------------- ; ---------------------------------
; Function usb_ufi_read ; Function usb_ufi_read
; --------------------------------- ; ---------------------------------
@ -237,13 +237,11 @@ l_usb_ufi_read_00139:
ld l,0xff ld l,0xff
jr l_usb_ufi_read_00109 jr l_usb_ufi_read_00109
l_usb_ufi_read_00106: 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)
;source-doc/ufi-drv/ufi_driver.c:49: const uint8_t sense_key = response.sense_key & 15;
ld a,(ix-16)
and 0x0f and 0x0f
jr Z,l_usb_ufi_read_00108 jr Z,l_usb_ufi_read_00108
;source-doc/ufi-drv/ufi_driver.c:51: if (sense_key != 0)
;source-doc/ufi-drv/ufi_driver.c:52: return -1; ;source-doc/ufi-drv/ufi_driver.c:52: return -1;
ld l,0xff ld l,0xff
jr l_usb_ufi_read_00109 jr l_usb_ufi_read_00109
@ -360,13 +358,11 @@ l_usb_ufi_write_00139:
ld l,0xff ld l,0xff
jr l_usb_ufi_write_00109 jr l_usb_ufi_write_00109
l_usb_ufi_write_00106: 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)
;source-doc/ufi-drv/ufi_driver.c:79: const uint8_t sense_key = response.sense_key & 15;
ld a,(ix-16)
and 0x0f and 0x0f
jr Z,l_usb_ufi_write_00108 jr Z,l_usb_ufi_write_00108
;source-doc/ufi-drv/ufi_driver.c:81: if (sense_key != 0)
;source-doc/ufi-drv/ufi_driver.c:82: return -1; ;source-doc/ufi-drv/ufi_driver.c:82: return -1;
ld l,0xff ld l,0xff
jr l_usb_ufi_write_00109 jr l_usb_ufi_write_00109

Loading…
Cancel
Save