mirror of
https://github.com/LIV2/lide.device.git
synced 2025-12-06 00:32:45 +00:00
MakeSCSICmd: add arg for CDB size
This commit is contained in:
parent
bb1a9ac3a1
commit
0add5f578b
14
atapi.c
14
atapi.c
@ -216,7 +216,7 @@ bool atapi_identify(struct IDEUnit *unit, UWORD *buffer) {
|
||||
BYTE atapi_translate(APTR io_Data, ULONG lba, ULONG count, ULONG *io_Actual, struct IDEUnit *unit, enum xfer_dir direction)
|
||||
{
|
||||
Trace("atapi_translate enter\n");
|
||||
struct SCSICmd *cmd = MakeSCSICmd();
|
||||
struct SCSICmd *cmd = MakeSCSICmd(SZ_CDB_10);
|
||||
if (cmd == NULL) return TDERR_NoMem;
|
||||
struct SCSI_CDB_10 *cdb = (struct SCSI_CDB_10 *)cmd->scsi_Command;
|
||||
UBYTE errorCode = 0;
|
||||
@ -490,7 +490,7 @@ end:
|
||||
* @returns nonzero if there was an error
|
||||
*/
|
||||
BYTE atapi_test_unit_ready(struct IDEUnit *unit) {
|
||||
struct SCSICmd *cmd = MakeSCSICmd();
|
||||
struct SCSICmd *cmd = MakeSCSICmd(SZ_CDB_10);
|
||||
if (cmd == NULL) return TDERR_NoMem;
|
||||
struct SCSI_CDB_10 *cdb = (struct SCSI_CDB_10 *)cmd->scsi_Command;
|
||||
|
||||
@ -564,7 +564,7 @@ done:
|
||||
* @return non-zero on error
|
||||
*/
|
||||
BYTE atapi_request_sense(struct IDEUnit *unit, UBYTE *errorCode, UBYTE *senseKey, UBYTE *asc, UBYTE *asq) {
|
||||
struct SCSICmd *cmd = MakeSCSICmd();
|
||||
struct SCSICmd *cmd = MakeSCSICmd(SZ_CDB_10);
|
||||
if (cmd == NULL) return TDERR_NoMem;
|
||||
UBYTE *cdb = (UBYTE *)cmd->scsi_Command;
|
||||
|
||||
@ -608,7 +608,7 @@ BYTE atapi_request_sense(struct IDEUnit *unit, UBYTE *errorCode, UBYTE *senseKey
|
||||
* @return non-zero on error
|
||||
*/
|
||||
BYTE atapi_get_capacity(struct IDEUnit *unit) {
|
||||
struct SCSICmd *cmd = MakeSCSICmd();
|
||||
struct SCSICmd *cmd = MakeSCSICmd(SZ_CDB_10);
|
||||
if (cmd == NULL) return TDERR_NoMem;
|
||||
struct SCSI_CDB_10 *cdb = (struct SCSI_CDB_10 *)cmd->scsi_Command;
|
||||
|
||||
@ -663,7 +663,7 @@ BYTE atapi_get_capacity(struct IDEUnit *unit) {
|
||||
* @return Non-zero on error
|
||||
*/
|
||||
BYTE atapi_mode_sense(struct IDEUnit *unit, BYTE page_code, UWORD *buffer, UWORD length, UWORD *actual) {
|
||||
struct SCSICmd *cmd = MakeSCSICmd();
|
||||
struct SCSICmd *cmd = MakeSCSICmd(SZ_CDB_10);
|
||||
if (cmd == NULL) return TDERR_NoMem;
|
||||
|
||||
UBYTE *cdb = cmd->scsi_Command;
|
||||
@ -778,7 +778,7 @@ BYTE atapi_scsi_mode_select_6(struct SCSICmd *cmd, struct IDEUnit *unit) {
|
||||
src = (UBYTE *)cmd->scsi_Data;
|
||||
dst = buf;
|
||||
|
||||
cmd_select = MakeSCSICmd();
|
||||
cmd_select = MakeSCSICmd(SZ_CDB_10);
|
||||
|
||||
if (cmd_select == NULL) {
|
||||
return TDERR_NoMem;
|
||||
@ -909,7 +909,7 @@ BYTE atapi_start_stop_unit(struct IDEUnit *unit, bool start, bool loej) {
|
||||
if (loej) operation |= (1<<1);
|
||||
if (start) operation |= (1<<0);
|
||||
|
||||
if ((cmd = MakeSCSICmd()) == NULL) return TDERR_NoMem;
|
||||
if ((cmd = MakeSCSICmd(SZ_CDB_10)) == NULL) return TDERR_NoMem;
|
||||
|
||||
cmd->scsi_Command[0] = SCSI_CMD_START_STOP_UNIT;
|
||||
cmd->scsi_Command[1] = (1<<0); // Immediate bit set
|
||||
|
||||
@ -288,7 +288,7 @@ static BYTE handle_scsi_command(struct IOStdReq *ioreq) {
|
||||
|
||||
Trace("Auto sense requested\n");
|
||||
|
||||
struct SCSICmd *cmd = MakeSCSICmd();
|
||||
struct SCSICmd *cmd = MakeSCSICmd(SZ_CDB_12);
|
||||
|
||||
if (cmd != NULL) {
|
||||
cmd->scsi_Command[0] = SCSI_CMD_REQUEST_SENSE;
|
||||
|
||||
@ -95,7 +95,7 @@ struct MountData
|
||||
|
||||
// Get Block size of unit by sending a SCSI READ CAPACITY 10 command
|
||||
int GetBlockSize(struct IOStdReq *req) {
|
||||
struct SCSICmd *cmd = MakeSCSICmd();
|
||||
struct SCSICmd *cmd = MakeSCSICmd(SZ_CDB_10);
|
||||
|
||||
if (cmd == NULL) return 0;
|
||||
|
||||
|
||||
17
scsi.c
17
scsi.c
@ -76,25 +76,28 @@ void scsi_sense(struct SCSICmd* command, ULONG info, ULONG specific, BYTE error)
|
||||
}
|
||||
|
||||
/**
|
||||
* MakeSCSICmd()
|
||||
* MakeSCSICmd
|
||||
*
|
||||
* Creates an new SCSICmd struct and CDB
|
||||
*
|
||||
* @param cdbSize Size of CDB to create
|
||||
* @returns Pointer to an initialized SCSICmd struct
|
||||
*/
|
||||
struct SCSICmd * MakeSCSICmd() {
|
||||
struct SCSICmd * MakeSCSICmd(ULONG cdbSize) {
|
||||
UBYTE *cdb = NULL;
|
||||
struct SCSICmd *cmd = NULL;
|
||||
|
||||
if ((cdb = AllocMem(sizeof(struct SCSI_CDB_10),MEMF_ANY|MEMF_CLEAR)) == NULL) {
|
||||
if ((cdb = AllocMem(cdbSize,MEMF_ANY|MEMF_CLEAR)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((cmd = AllocMem(sizeof(struct SCSICmd),MEMF_ANY|MEMF_CLEAR)) == NULL) {
|
||||
FreeMem(cdb,sizeof(struct SCSI_CDB_10));
|
||||
FreeMem(cdb,cdbSize);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cmd->scsi_Command = (UBYTE *)cdb;
|
||||
cmd->scsi_CmdLength = sizeof(struct SCSI_CDB_10);
|
||||
cmd->scsi_CmdLength = cdbSize;
|
||||
cmd->scsi_Data = NULL;
|
||||
cmd->scsi_Length = 0;
|
||||
cmd->scsi_SenseData = NULL;
|
||||
@ -106,11 +109,13 @@ struct SCSICmd * MakeSCSICmd() {
|
||||
* DeleteSCSICmd
|
||||
*
|
||||
* Delete a SCSICmd and its CDB
|
||||
*
|
||||
* @param cmd Pointer to a SCSICmd struct to be deleted
|
||||
*/
|
||||
void DeleteSCSICmd(struct SCSICmd *cmd) {
|
||||
if (cmd) {
|
||||
UBYTE *cdb = cmd->scsi_Command;
|
||||
if (cdb) FreeMem(cdb,sizeof(struct SCSI_CDB_10));
|
||||
if (cdb) FreeMem(cdb,(ULONG)cmd->scsi_CmdLength);
|
||||
FreeMem(cmd,sizeof(struct SCSICmd));
|
||||
}
|
||||
}
|
||||
5
scsi.h
5
scsi.h
@ -18,6 +18,9 @@
|
||||
|
||||
#define SCSI_CHECK_CONDITION 0x02
|
||||
|
||||
#define SZ_CDB_10 10
|
||||
#define SZ_CDB_12 12
|
||||
|
||||
struct __attribute__((packed)) SCSI_Inquiry {
|
||||
UBYTE peripheral_type;
|
||||
UBYTE removable_media;
|
||||
@ -77,5 +80,5 @@ struct __attribute__((packed)) SCSI_FIXED_SENSE {
|
||||
};
|
||||
|
||||
void scsi_sense(struct SCSICmd* command, ULONG info, ULONG specific, BYTE error);
|
||||
struct SCSICmd * MakeSCSICmd();
|
||||
struct SCSICmd * MakeSCSICmd(ULONG cdbSize);
|
||||
void DeleteSCSICmd(struct SCSICmd *cmd);
|
||||
Loading…
x
Reference in New Issue
Block a user