2 Copyright © 2019, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
8 #include <proto/exec.h>
10 /* We want all other bases obtained from our base */
13 #include <hidd/storage.h>
14 #include <hidd/scsi.h>
19 /*****************************************************************************************
28 Unit class is private to ata.device. Instances of this class represent
29 devices connected to IDE buses, and can be used to obtain information
32 *****************************************************************************************/
35 * a STUB function for commands not supported by this particular device
37 static BYTE
scsi_STUB(struct scsi_Unit
*su
)
39 D(bug("[SCSI%02ld] CALLED STUB FUNCTION (GENERIC). THIS OPERATION IS NOT "
40 "SUPPORTED BY DEVICE\n", su
->su_UnitNum
));
44 static BYTE
scsi_STUB_IO32(struct scsi_Unit
*su
, ULONG blk
, ULONG len
,
47 D(bug("[SCSI%02ld] CALLED STUB FUNCTION (IO32). THIS OPERATION IS NOT "
48 "SUPPORTED BY DEVICE\n", su
->su_UnitNum
));
52 static BYTE
scsi_STUB_IO64(struct scsi_Unit
*su
, UQUAD blk
, ULONG len
,
55 D(bug("[SCSI%02ld] CALLED STUB FUNCTION -- IO ACCESS TO BLOCK %08lx:%08lx, LENGTH %08lx. THIS OPERATION IS NOT SUPPORTED BY DEVICE\n", su
->su_UnitNum
, (blk
>> 32), (blk
& 0xffffffff), len
));
59 static BYTE
scsi_STUB_SCSI(struct scsi_Unit
*su
, struct SCSICmd
* cmd
)
61 D(bug("[SCSI%02ld] CALLED STUB FUNCTION. THIS OPERATION IS NOT SUPPORTED BY DEVICE\n", su
->su_UnitNum
));
65 OOP_Object
*SCSIUnit__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
67 D(bug("[SCSI:Unit] %s()\n", __PRETTY_FUNCTION__
));
69 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, &msg
->mID
);
72 struct scsiBase
*SCSIBase
= cl
->UserData
;
73 struct scsi_Unit
*unit
= OOP_INST_DATA(cl
, o
);
75 D(bug("[SCSI:Unit] %s: instance @ 0x%p\n", __PRETTY_FUNCTION__
, o
));
77 unit
->su_Drive
= AllocPooled(SCSIBase
->scsi_MemPool
, sizeof(struct DriveIdent
));
80 OOP_MethodID disp_msg
= msg
->mID
- moRoot_New
+ moRoot_Dispose
;
82 OOP_DoSuperMethod(cl
, o
, &disp_msg
);
86 unit
->su_SectorShift
= 9; /* this really has to be set here. */
88 NEWLIST(&unit
->su_SoftList
);
91 * since the stack is always handled by caller
92 * it's safe to stub all calls with one function
94 unit
->su_Read32
= scsi_STUB_IO32
;
95 unit
->su_Read64
= scsi_STUB_IO64
;
96 unit
->su_Write32
= scsi_STUB_IO32
;
97 unit
->su_Write64
= scsi_STUB_IO64
;
98 unit
->su_Eject
= scsi_STUB
;
99 unit
->su_DirectSCSI
= scsi_STUB_SCSI
;
100 unit
->su_Identify
= scsi_STUB
;
105 void SCSIUnit__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
107 struct scsiBase
*SCSIBase
= cl
->UserData
;
108 struct scsi_Unit
*unit
= OOP_INST_DATA(cl
, o
);
110 D(bug("[SCSI:Unit] %s()\n", __PRETTY_FUNCTION__
));
112 FreePooled(SCSIBase
->scsi_MemPool
, unit
->su_Drive
, sizeof(struct DriveIdent
));
113 OOP_DoSuperMethod(cl
, o
, msg
);
116 /*****************************************************************************************
119 aoHidd_SCSIUnit_XferModes
128 Tells which transfer modes are supported by this device. The returned value
129 is a bitwise combination of the following flags (see include/hidd/ata.h):
131 AF_XFER_PIO(x) - PIO mode number x (0 - 4)
132 AF_XFER_MDMA(x) - multiword DMA mode number x (0 - 2)
133 AF_XFER_UDMA(x) - Ultra DMA mode number x (0 - 6)
134 AF_XFER_48BIT - LBA48 block addressing
135 AF_XFER_RWMILTI - Multisector PIO
136 AF_XFER_PACKET - ATAPI
137 AF_XFER_LBA - LBA28 block addressing
138 AF_XFER_PIO32 - 32-bit PIO
145 32-bit PIO is actually controller's property and not drive's property.
146 Because of this AF_XFER_PIO32 flag can never be returned by this attribute.
147 Nevertheless, it can be returned by aoHidd_SCSIUnit_ConfiguredModes
151 aoHidd_SCSIUnit_ConfiguredModes
155 *****************************************************************************************/
156 /*****************************************************************************************
159 aoHidd_SCSIUnit_MultiSector
168 Tells maximum allowed number of sectors for multisector transfer.
180 *****************************************************************************************/
181 /*****************************************************************************************
184 aoHidd_SCSIUnit_ConfiguredModes
193 Tells which transfer modes are currently configured for use with the drive.
194 The returned value is a bitmask of the same flags as for
195 aoHidd_SCSIUnit_XferModes attribute.
202 Currently ata.device does not distinguish between PIO modes and does not
203 set any bit for them. Absence of DMA mode flags automatically means that
207 aoHidd_SCSIUnit_XferModes
211 *****************************************************************************************/
213 void SCSIUnit__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
215 struct scsiBase
*SCSIBase
= cl
->UserData
;
216 struct scsi_Unit
*unit
= OOP_INST_DATA(cl
, o
);
219 Hidd_StorageUnit_Switch (msg
->attrID
, idx
)
221 case aoHidd_StorageUnit_Device
:
222 *msg
->storage
= (IPTR
)"scsi.device";
225 case aoHidd_StorageUnit_Number
:
226 *msg
->storage
= unit
->su_UnitNum
;
229 case aoHidd_StorageUnit_Type
:
231 UBYTE u
= unit
->su_UnitNum
& 1;
232 switch (unit
->su_Bus
->sb_Dev
[u
])
236 *msg
->storage
= vHidd_StorageUnit_Type_FixedDisk
;
241 *msg
->storage
= vHidd_StorageUnit_Type_OpticalDisc
;
245 *msg
->storage
= vHidd_StorageUnit_Type_Unknown
;
251 case aoHidd_StorageUnit_Model
:
252 *msg
->storage
= (IPTR
)unit
->su_Model
;
255 case aoHidd_StorageUnit_Revision
:
256 *msg
->storage
= (IPTR
)unit
->su_FirmwareRev
;
259 case aoHidd_StorageUnit_Serial
:
260 *msg
->storage
= (IPTR
)unit
->su_SerialNumber
;
263 case aoHidd_StorageUnit_Removable
:
264 *msg
->storage
= (unit
->su_Flags
& AF_Removable
) ? TRUE
: FALSE
;
268 Hidd_SCSIUnit_Switch (msg
->attrID
, idx
)
270 case aoHidd_SCSIUnit_XferModes
:
271 *msg
->storage
= unit
->su_XferModes
;
274 case aoHidd_SCSIUnit_MultiSector
:
275 *msg
->storage
= unit
->su_Drive
->id_RWMultipleSize
& 0xFF;
278 case aoHidd_SCSIUnit_ConfiguredModes
:
279 *msg
->storage
= unit
->su_UseModes
;
283 OOP_DoSuperMethod(cl
, o
, &msg
->mID
);