Call CloseDevice() before DeleteIORequest(), and don't call
[AROS.git] / rom / hidds / hidd.pci / pci_init.c
blobcd29cfe708425699d519aa5a76efb7ae98140e00
1 /*
2 Copyright © 2003-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/symbolsets.h>
8 #include <exec/execbase.h>
9 #include <exec/types.h>
10 #include <exec/resident.h>
11 #include <exec/libraries.h>
12 #include <exec/memory.h>
13 #include <exec/lists.h>
14 #include <exec/semaphores.h>
15 #include <dos/bptr.h>
17 #include <utility/utility.h>
19 #define DEBUG 1
21 #include <proto/exec.h>
22 #include <proto/oop.h>
23 #include <aros/debug.h>
26 #include "pci.h"
27 #include LC_LIBDEFS_FILE
29 static int PCI_Init(LIBBASETYPEPTR LIBBASE)
31 D(bug("[PCI] Initializing PCI system\n"));
32 LIBBASE->MemPool = CreatePool(MEMF_CLEAR | MEMF_PUBLIC, 8192, 4096);
33 D(bug("[PCI] Created pool 0x%p\n", LIBBASE->MemPool));
35 LIBBASE->psd.MemPool = LIBBASE->MemPool;
37 InitSemaphore(&LIBBASE->psd.driver_lock);
38 NEWLIST(&LIBBASE->psd.drivers);
40 return LIBBASE->psd.MemPool != NULL;
43 static int PCI_Expunge(LIBBASETYPEPTR LIBBASE)
45 #if 0 // Removing of drivers already done by driver classes
47 Ok. Class is not used ATM and therefore it is safe (well
48 Disable/Enable protected) to iterate through driver lists and free
49 everything that can be freed
51 D(bug("[PCI] Expunging drivers and devices\n"));
52 ForeachNodeSafe(&LIBBASE->psd.drivers, (struct Node *)dn, (struct Node *)next)
54 struct PciDevice *dev, *next;
56 Remove((struct Node *)dn);
58 /* For every device */
59 ForeachNodeSafe(&dn->devices, (struct Node *)dev, (struct Node *)next)
61 /* Dispose PCIDevice object instance */
62 OOP_DisposeObject(dev->device);
64 /* Remove device from device list */
65 Remove((struct Node *)dev);
68 /* Dispose driver */
69 OOP_DisposeObject(dn->driverObject);
72 /* All objects deleted by now. Free classes */
73 #endif
75 D(bug("[PCI] Destroying MemoryPool\n"));
76 DeletePool(LIBBASE->MemPool);
78 D(bug("[PCI] Goodbye\n"));
80 return TRUE;
83 ADD2INITLIB(PCI_Init, 0)
84 ADD2EXPUNGELIB(PCI_Expunge, 0)