another polish locale.
[AROS.git] / rom / devs / ata / unit_class.c
blob0cb70a8731ab4d6035198a8260c654df924e087d
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <hidd/ata.h>
8 #include <oop/oop.h>
9 #include <proto/exec.h>
11 #include "ata.h"
13 /*****************************************************************************************
15 NAME
16 --background--
18 LOCATION
19 IID_Hidd_ATAUnit
21 NOTES
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
24 about these devices.
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));
35 return CDERR_NOCMD;
38 static BYTE ata_STUB_IO32(struct ata_Unit *au, ULONG blk, ULONG len,
39 APTR buf, ULONG* act)
41 D(bug("[ATA%02ld] CALLED STUB FUNCTION (IO32). THIS OPERATION IS NOT "
42 "SUPPORTED BY DEVICE\n", au->au_UnitNum));
43 return CDERR_NOCMD;
46 static BYTE ata_STUB_IO64(struct ata_Unit *au, UQUAD blk, ULONG len,
47 APTR buf, ULONG* act)
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));
50 return CDERR_NOCMD;
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));
56 return CDERR_NOCMD;
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);
62 if (o)
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));
68 if (!unit->au_Drive)
70 OOP_MethodID disp_msg = msg->mID - moRoot_New + moRoot_Dispose;
72 OOP_DoSuperMethod(cl, o, &disp_msg);
73 return NULL;
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;
92 return o;
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 /*****************************************************************************************
106 NAME
107 aoHidd_ATAUnit_Number
109 SYNOPSIS
110 [..G], ULONG
112 LOCATION
113 IID_Hidd_ATAUnit
115 FUNCTION
116 Returns number of ata.device unit corresponding to this device.
118 NOTES
120 EXAMPLE
122 BUGS
124 SEE ALSO
126 INTERNALS
128 *****************************************************************************************/
129 /*****************************************************************************************
131 NAME
132 aoHidd_ATAUnit_Model
134 SYNOPSIS
135 [..G], CONST_STRPTR
137 LOCATION
138 IID_Hidd_ATAUnit
140 FUNCTION
141 Returns model ID string for this device.
143 NOTES
145 EXAMPLE
147 BUGS
149 SEE ALSO
150 aoHidd_ATAUnit_Revision, aoHidd_ATAUnit_Serial
152 INTERNALS
154 *****************************************************************************************/
155 /*****************************************************************************************
157 NAME
158 aoHidd_ATAUnit_Revision
160 SYNOPSIS
161 [..G], CONST_STRPTR
163 LOCATION
164 IID_Hidd_ATAUnit
166 FUNCTION
167 Returns revision ID string for this device.
169 NOTES
171 EXAMPLE
173 BUGS
175 SEE ALSO
176 aoHidd_ATAUnit_Model, aoHidd_ATAUnit_Serial
178 INTERNALS
180 *****************************************************************************************/
181 /*****************************************************************************************
183 NAME
184 aoHidd_ATAUnit_Serial
186 SYNOPSIS
187 [..G], CONST_STRPTR
189 LOCATION
190 IID_Hidd_ATAUnit
192 FUNCTION
193 Returns serial number string for this device.
195 NOTES
197 EXAMPLE
199 BUGS
201 SEE ALSO
202 aoHidd_ATAUnit_Model, aoHidd_ATAUnit_Revision
204 INTERNALS
206 *****************************************************************************************/
207 /*****************************************************************************************
209 NAME
210 aoHidd_ATAUnit_XferModes
212 SYNOPSIS
213 [..G], ULONG
215 LOCATION
216 IID_Hidd_ATAUnit
218 FUNCTION
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
231 NOTES
233 EXAMPLE
235 BUGS
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
239 attribute.
241 SEE ALSO
242 aoHidd_ATAUnit_ConfiguredModes
244 INTERNALS
246 *****************************************************************************************/
247 /*****************************************************************************************
249 NAME
250 aoHidd_ATAUnit_Removable
252 SYNOPSIS
253 [..G], BOOL
255 LOCATION
256 IID_Hidd_ATAUnit
258 FUNCTION
259 Tells if this drive has removable media.
261 NOTES
263 EXAMPLE
265 BUGS
267 SEE ALSO
269 INTERNALS
271 *****************************************************************************************/
272 /*****************************************************************************************
274 NAME
275 aoHidd_ATAUnit_MultiSector
277 SYNOPSIS
278 [..G], UBYTE
280 LOCATION
281 IID_Hidd_ATAUnit
283 FUNCTION
284 Tells maximum allowed number of sectors for multisector transfer.
286 NOTES
288 EXAMPLE
290 BUGS
292 SEE ALSO
294 INTERNALS
296 *****************************************************************************************/
297 /*****************************************************************************************
299 NAME
300 aoHidd_ATAUnit_ConfiguredModes
302 SYNOPSIS
303 [..G], ULONG
305 LOCATION
306 IID_Hidd_ATAUnit
308 FUNCTION
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.
313 NOTES
315 EXAMPLE
317 BUGS
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
320 PIO mode is used.
322 SEE ALSO
323 aoHidd_ATAUnit_XferModes
325 INTERNALS
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);
333 ULONG idx;
335 Hidd_ATAUnit_Switch (msg->attrID, idx)
337 case aoHidd_ATAUnit_Number:
338 *msg->storage = unit->au_UnitNum;
339 return;
341 case aoHidd_ATAUnit_Model:
342 *msg->storage = (IPTR)unit->au_Model;
343 return;
345 case aoHidd_ATAUnit_Revision:
346 *msg->storage = (IPTR)unit->au_FirmwareRev;
347 return;
349 case aoHidd_ATAUnit_Serial:
350 *msg->storage = (IPTR)unit->au_SerialNumber;
351 return;
353 case aoHidd_ATAUnit_XferModes:
354 *msg->storage = unit->au_XferModes;
355 return;
357 case aoHidd_ATAUnit_Removable:
358 *msg->storage = (unit->au_Flags & AF_Removable) ? TRUE : FALSE;
359 return;
361 case aoHidd_ATAUnit_MultiSector:
362 *msg->storage = unit->au_Drive->id_RWMultipleSize & 0xFF;
363 return;
365 case aoHidd_ATAUnit_ConfiguredModes:
366 *msg->storage = unit->au_UseModes;
367 return;
370 OOP_DoSuperMethod(cl, o, &msg->mID);