add stubs for the ata trim/smart commands. make sysexplorer's ata and ahci modules...
[AROS.git] / rom / devs / ata / ata_controllerclass.c
blob65ec6a44a43e840da1e4a4de98fc7cbd910019bf
1 /*
2 Copyright (C) 2013-2019, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
8 /* We want all other bases obtained from our base */
9 #define __NOLIBBASE__
11 #include <proto/utility.h>
13 #include <hidd/storage.h>
14 #include <hidd/ata.h>
15 #include <hidd/hidd.h>
16 #include <oop/oop.h>
17 #include <utility/tagitem.h>
19 #include "ata.h"
21 const char ata_IDEName[] = "IDE Controller";
23 OOP_Object *ATA__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
25 struct ataBase *ATABase = cl->UserData;
26 // char *ataControllerName = (char *)GetTagData(aHidd_HardwareName, (IPTR)ata_IDEName, msg->attrList);
28 OOP_Object *ataController = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
29 if (ataController)
31 struct ata_Controller *data = OOP_INST_DATA(cl, ataController);
32 // data->ac_Node.ln_Name = ataControllerName;
34 // D(bug ("[ATA:Controller] Root__New: New '%s' Controller Obj @ 0x%p\n", ataControllerName, ataController);)
36 /*register the controller in ata.device */
37 D(bug ("[ATA:Controller] Root__New: Controller Entry @ 0x%p\n", data);)
39 data->ac_Class = cl;
40 data->ac_Object = ataController;
42 AddTail(&ATABase->ata_Controllers, &data->ac_Node);
44 return ataController;
47 VOID ATA__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
49 struct ataBase *ATABase = cl->UserData;
50 struct ata_Controller *ataNode, *tmpNode;
52 D(bug ("[ATA:Controller] Root__Dispose(0x%p)\n", o);)
54 ForeachNodeSafe (&ATABase->ata_Controllers, ataNode, tmpNode)
56 if (ataNode->ac_Object == o)
58 D(bug ("[ATA:Controller] Root__Dispose: Destroying Controller Entry @ 0x%p\n", ataNode);)
59 Remove(&ataNode->ac_Node);
60 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
61 return;
66 void ATA__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
68 #if (0)
69 struct ata_Controller *data = OOP_INST_DATA(cl, o);
70 IPTR idx;
72 if (IS_ATA_ATTR(msg->attrID, idx))
74 switch (idx)
76 case aoHidd_HardwareName:
77 *msg->storage = (IPTR)data->ac_Node.ln_Name;
78 return;
81 #endif
82 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
85 BOOL ATA__Hidd_StorageController__RemoveBus(OOP_Class *cl, OOP_Object *o, struct pHidd_StorageController_RemoveBus *msg)
87 D(bug ("[ATA:Controller] Hidd_StorageController__RemoveBus(0x%p)\n", msg->busObject);)
89 * Currently we don't support unloading ATA bus drivers.
90 * This is a very-very big TODO.
92 return FALSE;
95 BOOL ATA__Hidd_StorageController__SetUpBus(OOP_Class *cl, OOP_Object *o, struct pHidd_StorageController_SetUpBus *msg)
97 struct ataBase *ATABase = cl->UserData;
99 D(bug ("[ATA:Controller] Hidd_StorageController__SetUpBus(0x%p)\n", msg->busObject);)
102 * Instantiate interfaces. PIO is mandatory, DMA is not.
103 * We don't keep interface pointers here because our bus class
104 * stores them itself.
105 * We do this in SetUpBus because the object must be fully
106 * created in order for this stuff to work.
108 if (!HIDD_ATABus_GetPIOInterface(msg->busObject))
109 return FALSE;
111 D(bug ("[ATA:Controller] Hidd_StorageController__SetUpBus: PIO Interfaces obtained\n");)
113 if (!ATABase->ata_NoDMA)
114 HIDD_ATABus_GetDMAInterface(msg->busObject);
116 D(bug ("[ATA:Controller] Hidd_StorageController__SetUpBus: Starting Bus...\n");)
118 /* Add the bus to the device and start service */
119 return Hidd_ATABus_Start(msg->busObject, ATABase);
122 void ATA__Hidd_StorageController__CleanUpBus(OOP_Class *cl, OOP_Object *o, struct pHidd_StorageController_CleanUpBus *msg)
124 D(bug ("[ATA:Controller] Hidd_StorageController__CleanUpBus(0x%p)\n", msg->busObject);)
125 /* By default we have nothing to do here */