Skip to content

Commit bdcf665

Browse files
committed
Add new msd os functions.
1 parent acdbdd7 commit bdcf665

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

src/ce/tice.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,62 @@ typedef uint8_t sk_key_t;
854854
*/
855855
sk_key_t os_GetCSC(void);
856856

857+
/**
858+
* Perform an MSD GetMaxLUN request, either through the USB port or with an ARM coprocessor.
859+
* @param value On input the wValue to use in the request (should be zero for usb?), on output the max logical unit number.
860+
*/
861+
void os_MSDGetMaxLUN(uint8_t *value);
862+
863+
/**
864+
* Perform an MSD mass storage reset request, either through the USB port or with an ARM coprocessor.
865+
* @param value Affects the wValue of the request, 1 for 0x55AA, 2 for 0xAA55, otherwise 0x0000 (for usb).
866+
*/
867+
void os_MSDReset(uint8_t value);
868+
869+
/**
870+
* Performs an MSD inquiry, either through the USB port or with an ARM coprocessor.
871+
* @param lun Logical unit number.
872+
* @param status Returns the status of the command.
873+
*/
874+
void os_MSDInquiry(uint8_t lun, uint8_t *status);
875+
876+
/**
877+
* Performs an MSD test unit ready command, either through the USB port or with an ARM coprocessor.
878+
* @param lun Logical unit number.
879+
* @param status Returns the status of the command.
880+
*/
881+
void os_MSDTestUnitReady(uint8_t lun, uint8_t *status);
882+
883+
/**
884+
* Performs an MSD read capacity command, either through the USB port or with an ARM coprocessor.
885+
* @param lun Logical unit number.
886+
* @param data Returns the returned logical block address and block byte length.
887+
* @return Error code, 0 for success, 5 for failed command, -5 for failed transfer.
888+
*/
889+
int8_t os_MSDReadCapacity(uint8_t lun, uint32_t data[2]);
890+
891+
/**
892+
* Performs an MSD read command, either through the USB port or with an ARM coprocessor.
893+
* @param lun Logical unit number.
894+
* @param blockCount Number of blocks to read.
895+
* @param lba Logical block address to start reading from.
896+
* @param blockSize Block size, obtained from os_MSDReadCapacity().
897+
* @param buffer Buffer to read data into, should be blockCount * blockSize bytes.
898+
* @return Error code, 0 for success, 5 for failed command, -5 for failed transfer.
899+
*/
900+
int8_t os_MSDRead(uint8_t lun, uint8_t blockCount, uint32_t lba, uint24_t blockSize, void *buffer);
901+
902+
/**
903+
* Performs an MSD write command, either through the USB port or with an ARM coprocessor.
904+
* @param lun Logical unit number.
905+
* @param blockCount Number of blocks to write.
906+
* @param lba Logical block address to start writing to.
907+
* @param blockSize Block size, obtained from os_MSDReadCapacity().
908+
* @param buffer Buffer of data to write, should be blockCount * blockSize bytes.
909+
* @return Error code, 0 for success, 5 for failed command, -5 for failed transfer.
910+
*/
911+
int8_t os_MSDWrite(uint8_t lun, uint8_t blockCount, uint32_t lba, uint24_t blockSize, void *buffer);
912+
857913
/**
858914
* Runs the calulator at 6 MHz
859915
*/

src/ce/tice.src

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@
103103
.def _os_FontDrawTransText
104104
.def _os_CreateAppVar
105105
.def _os_TestFlagBitsFast
106+
.def _os_MSDGetMaxLUN
107+
.def _os_MSDReset
108+
.def _os_MSDInquiry
109+
.def _os_MSDTestUnitReady
110+
.def _os_MSDReadCapacity
111+
.def _os_MSDRead
112+
.def _os_MSDWrite
106113

107114
.def _asm_MoveDown
108115
.def _asm_MoveUp
@@ -223,7 +230,14 @@ _os_FloatToReal equ 022170h
223230
_os_RealToFloat equ 022174h
224231
_os_FontDrawTransText equ 022178h
225232
_os_CreateAppVar equ 022184h
226-
_os_TestFlagBitsFast equ 0222FCh
233+
_os_TestFlagBitsFast equ 0222FCh
234+
_os_MSDGetMaxLUN equ 022280h
235+
_os_MSDReset equ 022284h
236+
_os_MSDInquiry equ 022288h
237+
_os_MSDTestUnitReady equ 02228Ch
238+
_os_MSDReadCapacity equ 022290h
239+
_os_MSDRead equ 022294h
240+
_os_MSDWrite equ 022298h
227241

228242
; ---
229243
; directly callable asm functions

0 commit comments

Comments
 (0)