Fixed use of negative indices when first directory entry has no long name.
[tangerine.git] / arch / common / hidd.pci / pci_init.c
blob971a3f3f344b57220de6390c1501dcb29ce61171
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);
34 LIBBASE->psd.MemPool = LIBBASE->MemPool;
36 InitSemaphore(&LIBBASE->psd.driver_lock);
37 NEWLIST(&LIBBASE->psd.drivers);
39 return LIBBASE->psd.MemPool != NULL;
42 static int PCI_Expunge(LIBBASETYPEPTR LIBBASE)
44 #if 0 // Removing of drivers already done by driver classes
46 Ok. Class is not used ATM and therefore it is safe (well
47 Disable/Enable protected) to iterate through driver lists and free
48 everything that can be freed
50 D(bug("[PCI] Expunging drivers and devices\n"));
51 ForeachNodeSafe(&LIBBASE->psd.drivers, (struct Node *)dn, (struct Node *)next)
53 struct PciDevice *dev, *next;
55 Remove((struct Node *)dn);
57 /* For every device */
58 ForeachNodeSafe(&dn->devices, (struct Node *)dev, (struct Node *)next)
60 /* Dispose PCIDevice object instance */
61 OOP_DisposeObject(dev->device);
63 /* Remove device from device list */
64 Remove((struct Node *)dev);
67 /* Dispose driver */
68 OOP_DisposeObject(dn->driverObject);
71 /* All objects deleted by now. Free classes */
72 #endif
74 D(bug("[PCI] Destroying MemoryPool\n"));
75 DeletePool(LIBBASE->MemPool);
77 D(bug("[PCI] Goodbye\n"));
79 return TRUE;
82 ADD2INITLIB(PCI_Init, 0)
83 ADD2EXPUNGELIB(PCI_Expunge, 0)