2 Copyright © 2004-2011, The AROS Development Team. All rights reserved
9 /* Maintainer: Jason S. McMullan <jason.mcmullan@gmail.com>
14 #include <aros/debug.h>
15 #include <aros/atomic.h>
16 #include <aros/symbolsets.h>
17 #include <exec/exec.h>
18 #include <exec/resident.h>
19 #include <exec/tasks.h>
20 #include <exec/memory.h>
21 #include <exec/nodes.h>
22 #include <utility/utility.h>
23 #include <libraries/expansion.h>
24 #include <libraries/configvars.h>
25 #include <devices/trackdisk.h>
26 #include <devices/newstyle.h>
28 #include <dos/dosextens.h>
30 #include <proto/exec.h>
31 #include <proto/timer.h>
32 #include <proto/bootloader.h>
33 #include <proto/expansion.h>
34 #include <proto/oop.h>
41 #include "ahci_intern.h"
44 u_int32_t AhciForceGen
;
45 u_int32_t AhciNoFeatures
;
47 #include LC_LIBDEFS_FILE
50 Here shall we start. Make function static as it shouldn't be visible from
53 static int AHCI_Init(LIBBASETYPEPTR LIBBASE
)
55 D(bug("[AHCI--] AHCI_Init: ahci.device Initialization\n"));
58 * I've decided to use memory pools again. Alloc everything needed from
59 * a pool, so that we avoid memory fragmentation.
61 LIBBASE
->ahci_MemPool
= CreatePool(MEMF_CLEAR
| MEMF_PUBLIC
| MEMF_SEM_PROTECTED
, 8192, 4096);
62 if (LIBBASE
->ahci_MemPool
== NULL
)
65 D(bug("[AHCI--] AHCI_Init: MemPool @ %p\n", LIBBASE
->ahci_MemPool
));
67 /* Initialize lists */
68 NEWLIST(&LIBBASE
->ahci_Units
);
69 LIBBASE
->ahci_UnitCount
=0;
71 /* Get some useful bases */
72 LIBBASE
->ahci_HiddPCIDeviceAttrBase
= OOP_ObtainAttrBase(IID_Hidd_PCIDevice
);
73 LIBBASE
->ahci_HiddPCIDeviceMethodBase
= OOP_GetMethodID(IID_Hidd_PCIDevice
, 0);
75 LIBBASE
->ahci_HiddPCIDriverMethodBase
= OOP_GetMethodID(IID_Hidd_PCIDriver
, 0);
81 LIBBASETYPEPTR LIBBASE
,
82 struct IORequest
*iorq
,
87 struct cam_sim
*tmp
, *unit
= NULL
;
92 iorq
->io_Error
= IOERR_OPENFAIL
;
94 ForeachNode(&LIBBASE
->ahci_Units
, tmp
) {
95 if (tmp
->sim_Unit
== unitnum
&&
96 !(tmp
->sim_Flags
& SIMF_OffLine
)) {
98 AROS_ATOMIC_INC(unit
->sim_UseCount
);
109 iorq
->io_Device
= &LIBBASE
->ahci_Device
;
110 iorq
->io_Unit
= (struct Unit
*)unit
;
116 /* Close given device */
117 static int AHCI_Close
119 LIBBASETYPEPTR LIBBASE
,
120 struct IORequest
*iorq
123 struct cam_sim
*unit
= (struct cam_sim
*)iorq
->io_Unit
;
125 /* First of all make the important fields of struct IORequest invalid! */
126 iorq
->io_Unit
= (struct Unit
*)~0;
128 /* Decrease use counters of unit */
129 AROS_ATOMIC_DEC(unit
->sim_UseCount
);
134 ADD2INITLIB(AHCI_Init
, 0)
135 ADD2OPENDEV(AHCI_Open
, 0)
136 ADD2CLOSEDEV(AHCI_Close
, 0)