2 Copyright © 2018, 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 <proto/utility.h>
15 #include <hidd/storage.h>
16 #include <hidd/ahci.h>
22 static void ahci_strcpy(const UBYTE
*str1
, UBYTE
*str2
, ULONG size
)
24 register int i
= size
;
35 /*****************************************************************************************
38 --background_unitclass--
44 Unit class is private to ahci.device. Instances of this class represent
45 devices connected to AHCI buses, and can be used to obtain information
48 *****************************************************************************************/
50 OOP_Object
*AHCIUnit__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
52 struct AHCIBase
*AHCIBase
= cl
->UserData
;
53 struct ahci_Bus
*uBus
= (struct ahci_Bus
*)GetTagData(aHidd_DriverData
, 0, msg
->attrList
);
55 D(bug ("[AHCI:Unit] Root__New()\n");)
60 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
63 struct ahci_Unit
*unit
= OOP_INST_DATA(cl
, o
);
64 struct ata_port
*at
= uBus
->ab_Port
->ap_ata
[0];
66 D(bug ("[AHCI:Unit] Root__New: Unit Obj @ %p\n", o
);)
71 ahci_strcpy(at
->at_identify
.model
, unit
->au_Model
, 40);
72 D(bug ("[AHCI:Unit] Root__New: Model %s\n", unit
->au_Model
);)
73 ahci_strcpy(at
->at_identify
.serial
, unit
->au_SerialNumber
, 20);
74 D(bug ("[AHCI:Unit] Root__New: Serial %s\n", unit
->au_SerialNumber
);)
75 ahci_strcpy(at
->at_identify
.firmware
, unit
->au_FirmwareRev
, 8);
76 D(bug ("[AHCI:Unit] Root__New: FW Revis %s\n", unit
->au_FirmwareRev
);)
81 void AHCIUnit__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
84 struct AHCIBase
*AHCIBase
= cl
->UserData
;
85 struct ahci_Unit
*unit
= OOP_INST_DATA(cl
, o
);
87 D(bug ("[AHCI:Unit] Root__Dispose(%p)\n", o
);)
89 OOP_DoSuperMethod(cl
, o
, msg
);
92 void AHCIUnit__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
94 struct AHCIBase
*AHCIBase
= cl
->UserData
;
95 struct ahci_Unit
*unit
= OOP_INST_DATA(cl
, o
);
96 struct ata_port
*at
= unit
->au_Bus
->ab_Port
->ap_ata
[0];
99 Hidd_StorageUnit_Switch (msg
->attrID
, idx
)
101 case aoHidd_StorageUnit_Device
:
102 *msg
->storage
= (IPTR
)"ahci.device";
105 case aoHidd_StorageUnit_Number
:
106 *msg
->storage
= unit
->au_UnitNum
;
109 case aoHidd_StorageUnit_Type
:
111 switch (unit
->au_Bus
->ab_Port
->ap_type
)
113 case ATA_PORT_T_DISK
:
115 if (at
->at_identify
.support_dsm
& ATA_SUPPORT_DSM_TRIM
)
116 *msg
->storage
= vHidd_StorageUnit_Type_SolidStateDisk
;
118 *msg
->storage
= vHidd_StorageUnit_Type_FixedDisk
;
121 case ATA_PORT_T_ATAPI
:
122 *msg
->storage
= vHidd_StorageUnit_Type_OpticalDisc
;
126 *msg
->storage
= vHidd_StorageUnit_Type_Unknown
;
132 case aoHidd_StorageUnit_Model
:
133 *msg
->storage
= (IPTR
)unit
->au_Model
;
136 case aoHidd_StorageUnit_Revision
:
137 *msg
->storage
= (IPTR
)unit
->au_FirmwareRev
;
140 case aoHidd_StorageUnit_Serial
:
141 *msg
->storage
= (IPTR
)unit
->au_SerialNumber
;
144 case aoHidd_StorageUnit_Removable
:
146 if (at
->at_identify
.config
& (1 << 7))
147 *msg
->storage
= (IPTR
)TRUE
;
149 *msg
->storage
= (IPTR
)FALSE
;
154 Hidd_AHCIUnit_Switch (msg
->attrID
, idx
)
156 case aoHidd_AHCIUnit_Features
:
157 *msg
->storage
= (IPTR
)at
->at_features
;
161 OOP_DoSuperMethod(cl
, o
, &msg
->mID
);