2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
9 #include <proto/exec.h>
13 /*****************************************************************************************
22 Unit class is private to ata.device. Instances of this class represent
23 devices connected to IDE buses, and can be used to obtain information
26 *****************************************************************************************/
29 * a STUB function for commands not supported by this particular device
31 static BYTE
ata_STUB(struct ata_Unit
*au
)
33 D(bug("[ATA%02ld] CALLED STUB FUNCTION (GENERIC). THIS OPERATION IS NOT "
34 "SUPPORTED BY DEVICE\n", au
->au_UnitNum
));
38 static BYTE
ata_STUB_IO32(struct ata_Unit
*au
, ULONG blk
, ULONG len
,
41 D(bug("[ATA%02ld] CALLED STUB FUNCTION (IO32). THIS OPERATION IS NOT "
42 "SUPPORTED BY DEVICE\n", au
->au_UnitNum
));
46 static BYTE
ata_STUB_IO64(struct ata_Unit
*au
, UQUAD blk
, ULONG len
,
49 D(bug("[ATA%02ld] CALLED STUB FUNCTION -- IO ACCESS TO BLOCK %08lx:%08lx, LENGTH %08lx. THIS OPERATION IS NOT SUPPORTED BY DEVICE\n", au
->au_UnitNum
, (blk
>> 32), (blk
& 0xffffffff), len
));
53 static BYTE
ata_STUB_SCSI(struct ata_Unit
*au
, struct SCSICmd
* cmd
)
55 D(bug("[ATA%02ld] CALLED STUB FUNCTION. THIS OPERATION IS NOT SUPPORTED BY DEVICE\n", au
->au_UnitNum
));
59 OOP_Object
*ATAUnit__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
61 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, &msg
->mID
);
64 struct ataBase
*ATABase
= cl
->UserData
;
65 struct ata_Unit
*unit
= OOP_INST_DATA(cl
, o
);
67 unit
->au_Drive
= AllocPooled(ATABase
->ata_MemPool
, sizeof(struct DriveIdent
));
70 OOP_MethodID disp_msg
= msg
->mID
- moRoot_New
+ moRoot_Dispose
;
72 OOP_DoSuperMethod(cl
, o
, &disp_msg
);
76 unit
->au_SectorShift
= 9; /* this really has to be set here. */
78 NEWLIST(&unit
->au_SoftList
);
81 * since the stack is always handled by caller
82 * it's safe to stub all calls with one function
84 unit
->au_Read32
= ata_STUB_IO32
;
85 unit
->au_Read64
= ata_STUB_IO64
;
86 unit
->au_Write32
= ata_STUB_IO32
;
87 unit
->au_Write64
= ata_STUB_IO64
;
88 unit
->au_Eject
= ata_STUB
;
89 unit
->au_DirectSCSI
= ata_STUB_SCSI
;
90 unit
->au_Identify
= ata_STUB
;
95 void ATAUnit__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
97 struct ataBase
*ATABase
= cl
->UserData
;
98 struct ata_Unit
*unit
= OOP_INST_DATA(cl
, o
);
100 FreePooled(ATABase
->ata_MemPool
, unit
->au_Drive
, sizeof(struct DriveIdent
));
101 OOP_DoSuperMethod(cl
, o
, msg
);
104 /*****************************************************************************************
107 aoHidd_ATAUnit_Number
116 Returns number of ata.device unit corresponding to this device.
128 *****************************************************************************************/
129 /*****************************************************************************************
141 Returns model ID string for this device.
150 aoHidd_ATAUnit_Revision, aoHidd_ATAUnit_Serial
154 *****************************************************************************************/
155 /*****************************************************************************************
158 aoHidd_ATAUnit_Revision
167 Returns revision ID string for this device.
176 aoHidd_ATAUnit_Model, aoHidd_ATAUnit_Serial
180 *****************************************************************************************/
181 /*****************************************************************************************
184 aoHidd_ATAUnit_Serial
193 Returns serial number string for this device.
202 aoHidd_ATAUnit_Model, aoHidd_ATAUnit_Revision
206 *****************************************************************************************/
207 /*****************************************************************************************
210 aoHidd_ATAUnit_XferModes
219 Tells which transfer modes are supported by this device. The returned value
220 is a bitwise combination of the following flags (see include/hidd/ata.h):
222 AF_XFER_PIO(x) - PIO mode number x (0 - 4)
223 AF_XFER_MDMA(x) - multiword DMA mode number x (0 - 2)
224 AF_XFER_UDMA(x) - Ultra DMA mode number x (0 - 6)
225 AF_XFER_48BIT - LBA48 block addressing
226 AF_XFER_RWMILTI - Multisector PIO
227 AF_XFER_PACKET - ATAPI
228 AF_XFER_LBA - LBA28 block addressing
229 AF_XFER_PIO32 - 32-bit PIO
236 32-bit PIO is actually controller's property and not drive's property.
237 Because of this AF_XFER_PIO32 flag can never be returned by this attribute.
238 Nevertheless, it can be returned by aoHidd_ATAUnit_ConfiguredModes
242 aoHidd_ATAUnit_ConfiguredModes
246 *****************************************************************************************/
247 /*****************************************************************************************
250 aoHidd_ATAUnit_Removable
259 Tells if this drive has removable media.
271 *****************************************************************************************/
272 /*****************************************************************************************
275 aoHidd_ATAUnit_MultiSector
284 Tells maximum allowed number of sectors for multisector transfer.
296 *****************************************************************************************/
297 /*****************************************************************************************
300 aoHidd_ATAUnit_ConfiguredModes
309 Tells which transfer modes are currently configured for use with the drive.
310 The returned value is a bitmask of the same flags as for
311 aoHidd_ATAUnit_XferModes attribute.
318 Currently ata.device does not distinguish between PIO modes and does not
319 set any bit for them. Absence of DMA mode flags automatically means that
323 aoHidd_ATAUnit_XferModes
327 *****************************************************************************************/
329 void ATAUnit__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
331 struct ataBase
*ATABase
= cl
->UserData
;
332 struct ata_Unit
*unit
= OOP_INST_DATA(cl
, o
);
335 Hidd_ATAUnit_Switch (msg
->attrID
, idx
)
337 case aoHidd_ATAUnit_Number
:
338 *msg
->storage
= unit
->au_UnitNum
;
341 case aoHidd_ATAUnit_Model
:
342 *msg
->storage
= (IPTR
)unit
->au_Model
;
345 case aoHidd_ATAUnit_Revision
:
346 *msg
->storage
= (IPTR
)unit
->au_FirmwareRev
;
349 case aoHidd_ATAUnit_Serial
:
350 *msg
->storage
= (IPTR
)unit
->au_SerialNumber
;
353 case aoHidd_ATAUnit_XferModes
:
354 *msg
->storage
= unit
->au_XferModes
;
357 case aoHidd_ATAUnit_Removable
:
358 *msg
->storage
= (unit
->au_Flags
& AF_Removable
) ? TRUE
: FALSE
;
361 case aoHidd_ATAUnit_MultiSector
:
362 *msg
->storage
= unit
->au_Drive
->id_RWMultipleSize
& 0xFF;
365 case aoHidd_ATAUnit_ConfiguredModes
:
366 *msg
->storage
= unit
->au_UseModes
;
370 OOP_DoSuperMethod(cl
, o
, &msg
->mID
);