2 Copyright © 2003-2010, The AROS Development Team. All rights reserved.
6 #include <aros/libcall.h>
7 #include <aros/asmcall.h>
9 #include <exec/execbase.h>
10 #include <exec/types.h>
11 #include <exec/resident.h>
12 #include <exec/libraries.h>
13 #include <exec/memory.h>
14 #include <exec/lists.h>
20 #include <utility/utility.h>
24 #include <proto/exec.h>
25 #include <proto/kernel.h>
26 #include <proto/oop.h>
28 #include <aros/symbolsets.h>
31 #include <aros/debug.h>
36 #define __NR_iopl (110)
38 #define __NR_close (6)
40 static int PCILx_Init(LIBBASETYPEPTR LIBBASE
)
46 D(bug("LinuxPCI: Initializing\n"));
48 KernelBase
= OpenResource("kernel.resource");
52 /* Make sure we are running on Linux. Otherwise we will just
53 crash at first syscall. */
54 arch
= (STRPTR
)KrnGetSystemAttr(KATTR_Architecture
);
55 if (strncmp(arch
, "linux", 5))
57 D(bug("LinuxPCI: Running on %s, not on Linux\n", arch
));
61 ret
= syscall1(__NR_iopl
, 3);
62 D(bug("LinuxPCI: iopl(3)=%d\n", ret
));
64 LIBBASE
->psd
.fd
= syscall2(__NR_open
, (IPTR
)"/dev/mem", 2);
65 D(bug("LinuxPCI: /dev/mem fd=%d\n", LIBBASE
->psd
.fd
));
70 D(bug("LinuxPCI: has to be root in order to use this hidd\n"));
75 static int PCILx_Expunge(LIBBASETYPEPTR LIBBASE
)
79 D(bug("[PCILinux] expunge\n"));
81 /* Try to open PCI subsystem */
82 OOP_Object
*pci
= OOP_NewObject(NULL
, CLID_Hidd_PCI
, NULL
);
85 /* If PCI successed to open, remove your driver from subsystem */
86 struct pHidd_PCI_RemHardwareDriver msg
;
88 msg
.driverClass
= LIBBASE
->psd
.driverClass
;
89 msg
.mID
= OOP_GetMethodID(IID_Hidd_PCI
, moHidd_PCI_RemHardwareDriver
);
91 D(bug("[PCILinux] Removing driver\n"));
92 if (OOP_DoMethod(pci
, (OOP_Msg
)&msg
) == FALSE
)
95 D(bug("[PCILinux] PCI class refused to remove driver for some reason. Delaying expunge then\n"));
97 OOP_DisposeObject(pci
);
103 ADD2INITLIB(PCILx_Init
, 0)
104 ADD2EXPUNGELIB(PCILx_Expunge
, 0)
105 ADD2LIBS((STRPTR
)"pci.hidd", 0, static struct Library
*, __pcibase
);