📄 scsi.c
字号:
process Write And Verify 10 command (0x2e)
Arguments:
pSCSI - pointer to SCSI command
pSize - data size processed
Return Value:
valid command or not
--*/
{
PSCSICMD_10BYTE pSCSI10;
pSCSI10 = (PSCSICMD_10BYTE) pSCSI;
G_USBMSDC_ulLogicalBlockAddress = (ULONG) pSCSI10->logicalBlockAddress * (ULONG) G_Card_BytePerSector;
*pSize = (ULONG) pSCSI10->dataLength * (ULONG) G_Card_BytePerSector;
return(TRUE);
}
#endif
//-----------------------------------------------------------------------------
//SCSICMD_Verify10
//-----------------------------------------------------------------------------
UCHAR SCSICMD_Verify10(PUCHAR pSCSI, PULONG pSize) USING_1
/*++
Routine Description:
process Verify 10 command (0x2f)
Arguments:
pSCSI - pointer to SCSI command
pSize - data size processed
Return Value:
valid command or not
--*/
{
PSCSICMD_10BYTE pSCSI10;
pSCSI10 = (PSCSICMD_10BYTE) pSCSI;
G_USBMSDC_ulLogicalBlockAddress = (ULONG) pSCSI10->logicalBlockAddress * (ULONG) G_Card_BytePerSector;
*pSize = 0;
return(TRUE);
}
// 110102@wyeo
#if 0
//-----------------------------------------------------------------------------
//SCSICMD_ModeSelect10
//-----------------------------------------------------------------------------
UCHAR SCSICMD_ModeSelect10(PUCHAR pSCSI, PULONG pSize) USING_1
/*++
Routine Description:
process Mode Select 10 command (0x55)
Arguments:
pSCSI - pointer to SCSI command
pSize - data size processed
Return Value:
valid command or not
--*/
{
UCHAR status = TRUE;
PSCSICMD_10BYTE pSCSI10;
pSCSI10 = (PSCSICMD_10BYTE) pSCSI;
*pSize = pSCSI10->dataLength;
return(status);
}
#endif
//patch4.5@richie@wp xp begin
//-----------------------------------------------------------------------------
//SCSICMD_ModeSense10
//-----------------------------------------------------------------------------
UCHAR SCSICMD_ModeSense10(PUCHAR pSCSI, PULONG pSize) USING_1
/*++
Routine Description:
process Mode Sense 10 command (0x5a)
Arguments:
pSCSI - pointer to SCSI command
pSize - data size processed
Return Value:
valid command or not
--*/
{
UCHAR status = TRUE;
PSCSICMD_10BYTE pSCSI10;
ULONG size = SCSIDATA_MODE10_PARAMETER_HEADER_SIZE;
pSCSI10 = (PSCSICMD_10BYTE) pSCSI;
//richie@1203 if no medium then set sensekey = 02
if (G_ucStorageType != G_Card_Type)
{
G_USBMSDC_ucCSWStatus = K_USBMSDC_NoMedium;
*pSize = 0;
return (FALSE);
}
switch (pSCSI10->logicalBlockAddress & 0x3f000000)
{
case 0x01000000: //Media Type and Write Protect Page
size += SCSICMD_ModePage01(G_pucStorDataPointer + size);
break;
case 0x1b000000: //Removable Block Access Capacities Page
size += SCSICMD_ModePage1b(G_pucStorDataPointer + size);
break;
case 0x1c000000: //Timer and Protect Page
size += SCSICMD_ModePage1c(G_pucStorDataPointer + size);
break;
case 0x3f000000: //Return All Pages
size += SCSICMD_ModePage01(G_pucStorDataPointer + size);
size += SCSICMD_ModePage1b(G_pucStorDataPointer + size);
size += SCSICMD_ModePage1c(G_pucStorDataPointer + size);
break;
default:
status = FALSE;
break;
}
if (status)
{
SCSICMD_Mode10ParameterHeader(G_pucStorDataPointer, size);
*pSize = size;
}
return(status);
}
//patch4.5@richie@wp xp end
//Chamber@031103
#if 0
//-----------------------------------------------------------------------------
//SCSICMD_Read12
//-----------------------------------------------------------------------------
UCHAR SCSICMD_Read12(PUCHAR pSCSI, PULONG pSize) USING_1
/*++
Routine Description:
process Read 12 command (0xa8)
Arguments:
pSCSI - pointer to SCSI command
pSize - data size processed
Return Value:
valid command or not
--*/
{
PSCSICMD_12BYTE pSCSI12;
pSCSI12 = (PSCSICMD_12BYTE) pSCSI;
//richie@1203 if no medium then set sensekey = 02
if (G_ucStorageType != G_Card_Type)
{
G_USBMSDC_ucCSWStatus = K_USBMSDC_NoMedium;
*pSize = 0;
return (FALSE);
}
G_USBMSDC_ulLogicalBlockAddress = (ULONG) pSCSI12->logicalBlockAddress * (ULONG) G_DOS_SectorSize;
*pSize = (ULONG) pSCSI12->dataLength * (ULONG) G_DOS_SectorSize;
return(TRUE);
}
//-----------------------------------------------------------------------------
//SCSICMD_Write12
//-----------------------------------------------------------------------------
UCHAR SCSICMD_Write12(PUCHAR pSCSI, PULONG pSize) USING_1
/*++
Routine Description:
process Write 12 command (0xaa)
Arguments:
pSCSI - pointer to SCSI command
pSize - data size processed
Return Value:
valid command or not
--*/
{
PSCSICMD_12BYTE pSCSI12;
pSCSI12 = (PSCSICMD_12BYTE) pSCSI;
//richie@1203 if no medium then set sensekey = 02
if (G_ucStorageType != G_Card_Type)
{
G_USBMSDC_ucCSWStatus = K_USBMSDC_NoMedium;
*pSize = 0;
return (FALSE);
}
G_USBMSDC_ulLogicalBlockAddress = (ULONG) pSCSI12->logicalBlockAddress * (ULONG) G_DOS_SectorSize;
*pSize = (ULONG) pSCSI12->dataLength * (ULONG) G_DOS_SectorSize;
//patch5.0@richie@sdram mapping
// G_USBMSDC_ulSdramBufferAddress = K_SDRAM_FrameBufAAddr;
return(TRUE);
}
#endif
//-----------------------------------------------------------------------------
//SCSIDATA_FormatUnit
//-----------------------------------------------------------------------------
UCHAR SCSIDATA_FormatUnit(PUCHAR pSCSI) USING_1
/*++
Routine Description:
process Format Unit Data (0x04)
Arguments:
pSCSI - pointer to SCSI command
Return Value:
success or failure of action performed
--*/
{
PSCSICMD_06BYTE pSCSI06;
PSCSIDATA_FORMAT_UNIT pFormatUnit;
UCHAR status = TRUE;
pSCSI06 = (PSCSICMD_06BYTE) pSCSI;
//G_ulStorDataLength is the size required
//G_ulStorDataIndex is the size received
pFormatUnit = (PSCSIDATA_FORMAT_UNIT) G_pucStorDataPointer;
//STORAGE_Format(); //????
return(status);
}
//-----------------------------------------------------------------------------
//SCSIDATA_ModeSelect06
//-----------------------------------------------------------------------------
UCHAR SCSIDATA_ModeSelect06(PUCHAR pSCSI) USING_1
/*++
Routine Description:
process Mode Select 06 Data (0x15)
Arguments:
pSCSI - pointer to SCSI command
Return Value:
success or failure of action performed
--*/
{
PSCSICMD_06BYTE pSCSI06;
//patch4.5@richie@wp xp
PSCSIDATA_MODE06_PARAMETER_HEADER pHeader;
UCHAR status = TRUE;
pSCSI06 = (PSCSICMD_06BYTE) pSCSI;
//G_ulStorDataLength is the size required
//G_ulStorDataIndex is the size received
//patch4.5@richie@wp xp
pHeader = (PSCSIDATA_MODE06_PARAMETER_HEADER) G_pucStorDataPointer;
return(status);
}
//-----------------------------------------------------------------------------
//SCSIDATA_ModeSelect10
//-----------------------------------------------------------------------------
UCHAR SCSIDATA_ModeSelect10(PUCHAR pSCSI) USING_1
/*++
Routine Description:
process Mode Select 10 Data (0x55)
Arguments:
pSCSI - pointer to SCSI command
Return Value:
success or failure of action performed
--*/
{
PSCSICMD_10BYTE pSCSI10;
//patch4.5@richie@wp xp
PSCSIDATA_MODE10_PARAMETER_HEADER pHeader;
UCHAR status = TRUE;
pSCSI10 = (PSCSICMD_10BYTE) pSCSI;
//G_ulStorDataLength is the size required
//G_ulStorDataIndex is the size received
//patch4.5@richie@wp xp
pHeader = (PSCSIDATA_MODE10_PARAMETER_HEADER) G_pucStorDataPointer;
return(status);
}
// 110102@wyeo
#if 0
//richie@1129
//-----------------------------------------------------------------------------
//SCSIDATA_ReadFormatCapacities
//-----------------------------------------------------------------------------
UCHAR SCSIDATA_ReadFormatCapacities(PUCHAR pSCSI, PULONG pSize) USING_1
/*++
Routine Description:
process Read format capacities (0x23)
Arguments:
pSCSI - pointer to SCSI command
Return Value:
success or failure of action performed
--*/
{
PSCSICMD_12BYTE pSCSI12;
PSCSIDATA_READ_FORMAT_MAXIMUM pMax;
PSCSIDATA_READ_CAPACITY_LIST_HEADER pHeader;
WORD allocLength;
pSCSI12 = (PSCSICMD_12BYTE) pSCSI;
allocLength = (UCHAR)pSCSI[7];
allocLength = allocLength << 8;
allocLength |= (UCHAR)pSCSI[8];
//DbgPrint("alloclen %d\n",allocLength);
pHeader = (PSCSIDATA_READ_CAPACITY_LIST_HEADER) G_pucStorDataPointer;
//richei@1203 if no CF in device return zero length data
//*pSize = 0;
//return TRUE;
//richie@1129 if no CF in device
if (G_ucStorageType != G_Card_Type)
{
pHeader->reserved0 = 0;
pHeader->reserved1 = 0;
pHeader->reserved2 = 0;
pHeader->capacityListLength = SCSIDATA_READ_FORMAT_MAXIMUM_SIZE;
pMax = (PSCSIDATA_READ_FORMAT_MAXIMUM) (G_pucStorDataPointer + SCSIDATA_READ_FORMAT_CAPACITY_LIST_HEADER_SIZE);
pMax->numberOfBlocks = 0; //richie ???? not sure
pMax->BYTE4.reserved = 3;
pMax->BYTE4.descCode = 0; //richie no media
pMax->blockLength[0] = 0;
pMax->blockLength[1] = 2;
pMax->blockLength[2] = 0; //richie ???? not sure
}
else
{
//richie@1211 not finish yet
}
G_pucStorDataPointer[0] = 0x00;
G_pucStorDataPointer[1] = 0x00;
G_pucStorDataPointer[2] = 0x00;
G_pucStorDataPointer[3] = 0x10;
G_pucStorDataPointer[4] = 0x00;
G_pucStorDataPointer[5] = 0x07;
G_pucStorDataPointer[6] = 0x78;
G_pucStorDataPointer[7] = 0x3c;
G_pucStorDataPointer[8] = 0x03;
G_pucStorDataPointer[9] = 0x00;
G_pucStorDataPointer[10] = 0x02;
G_pucStorDataPointer[11] = 0x00;
G_pucStorDataPointer[12] = 0x00;
G_pucStorDataPointer[13] = 0x07;
G_pucStorDataPointer[14] = 0x78;
G_pucStorDataPointer[15] = 0x3c;
G_pucStorDataPointer[16] = 0x00;
G_pucStorDataPointer[17] = 0x00;
G_pucStorDataPointer[18] = 0x02;
G_pucStorDataPointer[19] = 0x00;
*pSize = 20;
return 20;
*pSize = SCSIDATA_READ_FORMAT_CAPACITY_LIST_HEADER_SIZE + SCSIDATA_READ_FORMAT_MAXIMUM_SIZE;
return(SCSIDATA_READ_FORMAT_CAPACITY_LIST_HEADER_SIZE + SCSIDATA_READ_FORMAT_MAXIMUM_SIZE);
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -