-
Notifications
You must be signed in to change notification settings - Fork 5
/
scsimsg.c
62 lines (49 loc) · 1.38 KB
/
scsimsg.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifdef DEBUG_SCSIMSG
#define USE_SERIAL_OUTPUT
#endif
#include "port.h"
#include "printf.h"
#include <exec/types.h>
#include <exec/io.h>
#include <devices/scsidisk.h>
#include "scsimsg.h"
int
dev_scsi_inquiry(struct IOExtTD *tio, uint unit, scsi_inquiry_data_t *inq)
{
scsi_generic_t cmd;
struct SCSICmd scmd;
uint lun = unit / 10;
BYTE ret;
#define SCSIPI_INQUIRY_LENGTH_SCSI2 36
memset(&cmd, 0, sizeof (cmd));
cmd.opcode = INQUIRY;
cmd.bytes[0] = lun << 5;
//cmd.bytes[1] = 0; // Page code
//cmd.bytes[2] = 0;
cmd.bytes[3] = sizeof (scsi_inquiry_data_t);
//cmd.bytes[4] = 0; // Control
memset(&scmd, 0, sizeof (scmd));
scmd.scsi_Data = (UWORD *) inq;
scmd.scsi_Length = sizeof (*inq);
scmd.scsi_Command = (UBYTE *) &cmd;
scmd.scsi_CmdLength = 6;
scmd.scsi_Flags = SCSIF_READ | SCSIF_AUTOSENSE;
scmd.scsi_SenseData = NULL;
scmd.scsi_SenseLength = 0;
tio->iotd_Req.io_Command = HD_SCSICMD;
tio->iotd_Req.io_Length = sizeof (scmd);
tio->iotd_Req.io_Data = &scmd;
ret = DoIO((struct IORequest *) tio);
tio->iotd_Req.io_Data = NULL;
return ret;
}
int
dev_scsi_get_drivegeometry(struct IOExtTD *tio, struct DriveGeometry *geom)
{
tio->iotd_Req.io_Command = TD_GETGEOMETRY;
tio->iotd_Req.io_Length = sizeof (*geom);
tio->iotd_Req.io_Data = geom;
tio->iotd_Req.io_Offset = 0;
tio->iotd_Req.io_Flags = 0;
return (DoIO((struct IORequest *) tio));
}