revert between 56095 -> 55830 in arch
[AROS.git] / rom / hidds / ata_pci / class_init.c
blob092af6ddf619258b8612d684015bea6f60922230
1 /*
2 Copyright © 2013-2019, The AROS Development Team. All rights reserved
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
11 #include <proto/exec.h>
13 /* We want all other bases obtained from our base */
14 #define __NOLIBBASE__
16 #include <proto/oop.h>
18 #include <aros/symbolsets.h>
19 #include <hidd/ata.h>
20 #include <hidd/storage.h>
21 #include <hidd/hidd.h>
22 #include <hidd/pci.h>
24 #include "bus_class.h"
26 static CONST_STRPTR attrBaseIDs[] =
28 IID_Hidd_PCIDevice,
29 IID_Hidd_PCIDriver,
30 IID_Hidd,
31 IID_Hidd_Bus,
32 IID_Hidd_ATABus,
33 IID_HW,
34 NULL
37 #define AB_MANDATORY 2
39 #if defined(__OOP_NOMETHODBASES__)
40 static CONST_STRPTR const methBaseIDs[] =
42 IID_HW,
43 IID_Hidd_StorageController,
44 NULL
46 #endif
48 static int pciata_init(struct atapciBase *base)
50 D(bug("[ATA:PCI] %s()\n", __PRETTY_FUNCTION__));
52 base->cs_UtilityBase = OpenLibrary("utility.library", 36);
53 if (!base->cs_UtilityBase)
54 return FALSE;
56 base->cs_KernelBase = OpenResource("kernel.resource");
57 if (!base->cs_KernelBase)
58 return FALSE;
61 * We handle also legacy ISA devices, so we can work without PCI subsystem.
62 * Because of this, we do not obtain PCI bases here. We do it later, in device
63 * discovery code.
65 if (OOP_ObtainAttrBasesArray(&base->hiddAttrBase, &attrBaseIDs[AB_MANDATORY]))
66 return FALSE;
68 base->storageRoot = OOP_NewObject(NULL, CLID_Hidd_Storage, NULL);
69 if (!base->storageRoot)
70 base->storageRoot = OOP_NewObject(NULL, CLID_HW_Root, NULL);
71 if (!base->storageRoot)
73 OOP_ReleaseAttrBasesArray(&base->hiddAttrBase, &attrBaseIDs[AB_MANDATORY]);
74 return FALSE;
76 D(bug("[ATA:PCI] %s: storage root @ 0x%p\n", __PRETTY_FUNCTION__, base->storageRoot);)
78 if ((base->ataClass = OOP_FindClass(CLID_Hidd_ATA)) == NULL)
80 OOP_ReleaseAttrBasesArray(&base->hiddAttrBase, &attrBaseIDs[AB_MANDATORY]);
81 return FALSE;
84 bug("[ATA:PCI] %s: Base %s Class @ 0x%p\n", __PRETTY_FUNCTION__, CLID_Hidd_ATA, base->ataClass);
85 bug("[ATA:PCI] %s: PCI %s Class @ 0x%p\n", __PRETTY_FUNCTION__, CLID_Hidd_ATABus, base->busClass);
88 #if defined(__OOP_NOMETHODBASES__)
89 if (OOP_ObtainMethodBasesArray(&base->HWMethodBase, methBaseIDs))
91 bug("[ATA:PCI] %s: Failed to obtain MethodBases!\n", __PRETTY_FUNCTION__);
92 bug("[ATA:PCI] %s: %s = %p\n", __PRETTY_FUNCTION__, methBaseIDs[0], base->HWMethodBase);
93 bug("[ATA:PCI] %s: %s = %p\n", __PRETTY_FUNCTION__, methBaseIDs[1], base->HiddSCMethodBase);
94 OOP_ReleaseAttrBasesArray(&base->hiddAttrBase, attrBaseIDs);
95 return FALSE;
97 #endif
99 return TRUE;
102 static int pciata_expunge(struct atapciBase *base)
104 /* Release all attribute bases */
105 OOP_ReleaseAttrBasesArray(&base->hiddAttrBase, &attrBaseIDs[AB_MANDATORY]);
107 if (base->cs_UtilityBase)
108 CloseLibrary(base->cs_UtilityBase);
110 return TRUE;
113 ADD2INITLIB(pciata_init, 0)
114 ADD2EXPUNGELIB(pciata_expunge, 0)