Added a test for MUIA_Listview_SelectChange.
[AROS.git] / arch / all-linux / hidd / pcilinux / pcilinux_init.c
blobdc6a3c9641a56c51601f58d74d41c44455d8fe56
1 /*
2 Copyright © 2003-2010, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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>
16 #include <dos/bptr.h>
18 #include <hidd/pci.h>
20 #include <utility/utility.h>
22 #include <unistd.h>
24 #include <proto/exec.h>
25 #include <proto/kernel.h>
26 #include <proto/oop.h>
28 #include <aros/symbolsets.h>
30 #define DEBUG 1
31 #include <aros/debug.h>
33 #include "pci.h"
34 #include "syscall.h"
36 #define __NR_iopl (110)
37 #define __NR_open (5)
38 #define __NR_close (6)
40 static int PCILx_Init(LIBBASETYPEPTR LIBBASE)
42 APTR KernelBase;
43 STRPTR arch;
44 int ret;
46 D(bug("LinuxPCI: Initializing\n"));
48 KernelBase = OpenResource("kernel.resource");
49 if (!KernelBase)
50 return FALSE;
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));
58 return FALSE;
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));
67 if (ret==0)
68 return TRUE;
70 D(bug("LinuxPCI: has to be root in order to use this hidd\n"));
72 return FALSE;
75 static int PCILx_Expunge(LIBBASETYPEPTR LIBBASE)
77 BOOL ret = TRUE;
79 D(bug("[PCILinux] expunge\n"));
81 /* Try to open PCI subsystem */
82 OOP_Object *pci = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);
83 if (pci)
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)
94 ret = FALSE;
95 D(bug("[PCILinux] PCI class refused to remove driver for some reason. Delaying expunge then\n"));
97 OOP_DisposeObject(pci);
100 return ret;
103 ADD2INITLIB(PCILx_Init, 0)
104 ADD2EXPUNGELIB(PCILx_Expunge, 0)
105 ADD2LIBS((STRPTR)"pci.hidd", 0, static struct Library *, __pcibase);