2 * Acess2 USB Stack Mass Storage Driver
3 * - By John Hodge (thePowersGang)
6 * - "SCSI Transparent Command Set" handling code
13 Uint64 MSC_SCSI_GetSize(tUSBInterface *Dev, size_t *BlockSize);
14 int MSC_SCSI_ReadData(void *Ptr, Uint64 Block, size_t Count, void *Dest);
15 int MSC_SCSI_WriteData(void *Ptr, Uint64 Block, size_t Count, const void *Dest);
18 tLVM_VolType gMSC_SCSI_VolType = {
19 .Name = "USB-MSC-SCSI",
20 .Read = MSC_SCSI_ReadData,
21 .Write = MSC_SCSI_WriteData
25 Uint64 MSC_SCSI_GetSize(tUSBInterface *Dev, size_t *BlockSize)
27 struct sSCSI_Cmd_ReadCapacity16 cmd;
28 struct sSCSI_Ret_ReadCapacity16 ret;
32 cmd.LBA = BigEndian64( 0 );
33 cmd.AllocationLength = BigEndian32(sizeof(ret));
39 MSC_RecvData(Dev, sizeof(cmd), &cmd, sizeof(ret), &ret);
41 *BlockSize = BigEndian32(ret.BlockSize);
42 return BigEndian64(ret.BlockCount);
45 int MSC_SCSI_ReadData(void *Ptr, Uint64 Block, size_t Count, void *Dest)
47 tUSBInterface *Dev = Ptr;
48 tMSCInfo *info = USB_GetDeviceDataPtr(Dev);
49 struct sSCSI_Cmd_Read16 cmd;
51 // TODO: Bounds checking?
55 cmd.LBA = BigEndian64(Block);
56 cmd.Length = BigEndian32(Count);
60 MSC_RecvData(Dev, sizeof(cmd), &cmd, Count*info->BlockSize, Dest);
66 int MSC_SCSI_WriteData(void *Ptr, Uint64 Block, size_t Count, const void *Data)
68 Log_Warning("MSC_SCSI", "TODO: Impliment MSC_SCSI_WriteData");