added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / arch / x86_64-linux / pcilinux / pcilinux_init.c
blobb0c3e99a149a3b8917cadf4e86851b6ab2b3f2df
1 /*
2 Copyright © 2003-2006, 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 "/usr/include/asm/unistd.h"
24 #include <proto/exec.h>
25 #include <proto/oop.h>
27 #include <aros/symbolsets.h>
29 #define DEBUG 1
30 #include <aros/debug.h>
33 #include "pci.h"
35 #define __NR_iopl (110)
36 #define __NR_open (5)
37 #define __NR_close (6)
39 static int PCILx_Init(LIBBASETYPEPTR LIBBASE)
41 D(bug("LinuxPCI: Initializing\n"));
44 int ret;
45 asm volatile(
46 "int $0x80"
47 :"=a"(ret)
48 :"a"(__NR_iopl),"b"(3)
51 asm volatile(
52 "int $0x80"
53 :"=a"(LIBBASE->psd.fd)
54 :"a"(__NR_open),"b"("/dev/mem"),"c"(2)
57 D(bug("LinuxPCI: iopl(3)=%d\n", ret));
58 D(bug("LinuxPCI: /dev/mem fd=%d\n", LIBBASE->psd.fd));
60 if (ret==0)
62 return TRUE;
65 D(bug("LinuxPCI: has to be root in order to use this hidd\n"));
68 return FALSE;
71 static int PCILx_Expunge(LIBBASETYPEPTR LIBBASE)
73 BOOL ret = TRUE;
75 D(bug("[PCILinux] expunge\n"));
77 /* Try to open PCI subsystem */
78 OOP_Object *pci = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);
79 if (pci)
81 /* If PCI successed to open, remove your driver from subsystem */
82 struct pHidd_PCI_RemHardwareDriver msg;
84 msg.driverClass = LIBBASE->psd.driverClass;
85 msg.mID = OOP_GetMethodID(IID_Hidd_PCI, moHidd_PCI_RemHardwareDriver);
87 D(bug("[PCILinux] Removing driver\n"));
88 if (OOP_DoMethod(pci, (OOP_Msg)&msg) == FALSE)
90 ret = FALSE;
91 D(bug("[PCILinux] PCI class refused to remove driver for some reason. Delaying expunge then\n"));
93 OOP_DisposeObject(pci);
96 return ret;
99 ADD2INITLIB(PCILx_Init, 0)
100 ADD2EXPUNGELIB(PCILx_Expunge, 0)