2 Copyright © 2004-2011, The AROS Development Team. All rights reserved
9 /* Maintainer: Jason S. McMullan <jason.mcmullan@gmail.com>
12 #include <aros/debug.h>
13 #include <aros/atomic.h>
14 #include <aros/symbolsets.h>
15 #include <exec/exec.h>
16 #include <exec/resident.h>
17 #include <exec/tasks.h>
18 #include <exec/memory.h>
19 #include <exec/nodes.h>
20 #include <utility/utility.h>
21 #include <libraries/expansion.h>
22 #include <libraries/configvars.h>
23 #include <devices/trackdisk.h>
24 #include <devices/newstyle.h>
26 #include <dos/dosextens.h>
28 #include <proto/exec.h>
29 #include <proto/timer.h>
30 #include <proto/bootloader.h>
31 #include <proto/expansion.h>
32 #include <proto/oop.h>
39 #include "ahci_intern.h"
42 u_int32_t AhciForceGen
;
43 u_int32_t AhciNoFeatures
;
45 #include LC_LIBDEFS_FILE
48 Here shall we start. Make function static as it shouldn't be visible from
51 static int AHCI_Init(LIBBASETYPEPTR LIBBASE
)
53 D(bug("[AHCI--] AHCI_Init: ahci.device Initialization\n"));
56 * I've decided to use memory pools again. Alloc everything needed from
57 * a pool, so that we avoid memory fragmentation.
59 LIBBASE
->ahci_MemPool
= CreatePool(MEMF_CLEAR
| MEMF_PUBLIC
| MEMF_SEM_PROTECTED
, 8192, 4096);
60 if (LIBBASE
->ahci_MemPool
== NULL
)
63 D(bug("[AHCI--] AHCI_Init: MemPool @ %p\n", LIBBASE
->ahci_MemPool
));
65 /* Initialize lists */
66 NEWLIST(&LIBBASE
->ahci_Units
);
67 LIBBASE
->ahci_HostCount
=0;
69 /* Get some useful bases */
70 LIBBASE
->ahci_HiddPCIDeviceAttrBase
= OOP_ObtainAttrBase(IID_Hidd_PCIDevice
);
71 LIBBASE
->ahci_HiddPCIDeviceMethodBase
= OOP_GetMethodID(IID_Hidd_PCIDevice
, 0);
73 LIBBASE
->ahci_HiddPCIDriverMethodBase
= OOP_GetMethodID(IID_Hidd_PCIDriver
, 0);
79 LIBBASETYPEPTR LIBBASE
,
80 struct IORequest
*iorq
,
85 struct cam_sim
*tmp
, *unit
= NULL
;
90 iorq
->io_Error
= IOERR_OPENFAIL
;
92 ForeachNode(&LIBBASE
->ahci_Units
, tmp
) {
93 if (tmp
->sim_Unit
== unitnum
) {
95 AROS_ATOMIC_INC(unit
->sim_UseCount
);
106 iorq
->io_Device
= &LIBBASE
->ahci_Device
;
107 iorq
->io_Unit
= (struct Unit
*)unit
;
113 /* Close given device */
114 static int AHCI_Close
116 LIBBASETYPEPTR LIBBASE
,
117 struct IORequest
*iorq
120 struct cam_sim
*unit
= (struct cam_sim
*)iorq
->io_Unit
;
122 /* First of all make the important fields of struct IORequest invalid! */
123 iorq
->io_Unit
= (struct Unit
*)~0;
125 /* Decrease use counters of unit */
126 AROS_ATOMIC_DEC(unit
->sim_UseCount
);
131 ADD2INITLIB(AHCI_Init
, 0)
132 ADD2OPENDEV(AHCI_Open
, 0)
133 ADD2CLOSEDEV(AHCI_Close
, 0)