2 Copyright (C)©2005 Neil Cafferkey.
5 Desc: Prometheus initialisation code.
9 #include <exec/types.h>
10 #include <exec/resident.h>
11 #include <utility/utility.h>
13 #include <proto/exec.h>
14 #include <proto/oop.h>
15 #include <proto/alib.h>
17 #include LC_LIBDEFS_FILE
18 #include "prometheus_intern.h"
19 #include <aros/symbolsets.h>
29 /* Private prototypes */
31 AROS_UFP3(static VOID
, EnumHook
, AROS_UFPA(struct Hook
*, hook
, A0
),
32 AROS_UFPA(OOP_Object
*, aros_board
, A2
), AROS_UFPA(APTR
, message
, A1
));
33 static int DeleteLibrary(LIBBASETYPE
*base
);
38 static const TEXT oop_name
[] = AROSOOP_NAME
;
39 static const TEXT utility_name
[] = UTILITYNAME
;
42 static int LibInit(LIBBASETYPEPTR base
)
46 struct HookContext
*hook_context
;
50 NewList((APTR
)&base
->boards
);
52 base
->pci_hidd
= OOP_NewObject(NULL
, CLID_Hidd_PCI
, NULL
);
53 base
->irq_hidd
= OOP_NewObject(NULL
, CLID_Hidd_IRQ
, NULL
);
54 base
->pcidevice_attr_base
= OOP_ObtainAttrBase(IID_Hidd_PCIDevice
);
55 if(base
->pci_hidd
== NULL
|| base
->irq_hidd
== NULL
56 || base
->pcidevice_attr_base
== 0)
59 /* Make a list of all boards in the system */
61 hook
= AllocMem(sizeof(struct Hook
), MEMF_PUBLIC
| MEMF_CLEAR
);
62 hook_context
= AllocMem(sizeof(struct HookContext
),
63 MEMF_PUBLIC
| MEMF_CLEAR
);
64 if(hook
== NULL
|| hook_context
== NULL
)
69 hook
->h_Entry
= (APTR
)EnumHook
;
70 hook
->h_Data
= hook_context
;
71 hook_context
->library
= base
;
72 hook_context
->success
= TRUE
;
74 HIDD_PCI_EnumDevices(base
->pci_hidd
, hook
, NULL
);
76 success
= hook_context
->success
;
80 FreeMem(hook
, sizeof(struct Hook
));
81 if(hook_context
!= NULL
)
82 FreeMem(hook_context
, sizeof(struct HookContext
));
92 AROS_UFH3(static VOID
, EnumHook
, AROS_UFHA(struct Hook
*, hook
, A0
),
93 AROS_UFHA(OOP_Object
*, aros_board
, A2
), AROS_UFHA(APTR
, message
, A1
))
98 struct PCIBoard
*board
;
99 struct HookContext
*context
;
100 OOP_AttrBase HiddPCIDeviceAttrBase
;
102 /* Add board to our list */
104 context
= hook
->h_Data
;
105 base
= context
->library
;
106 HiddPCIDeviceAttrBase
= OOP_ObtainAttrBase(IID_Hidd_PCIDevice
);
108 if(HiddPCIDeviceAttrBase
!= 0)
110 board
= AllocMem(sizeof(struct PCIBoard
), MEMF_PUBLIC
| MEMF_CLEAR
);
113 board
->aros_board
= aros_board
;
114 AddTail((APTR
)&base
->boards
, (APTR
)board
);
117 context
->success
= FALSE
;
118 OOP_ReleaseAttrBase(IID_Hidd_PCIDevice
);
128 static int DeleteLibrary(LIBBASETYPE
*base
)
130 struct PCIBoard
*board
;
132 /* Free the list of boards */
134 while((board
= (APTR
)RemTail((struct List
*)&base
->boards
)) != NULL
)
135 FreeMem(board
, sizeof(struct PCIBoard
));
139 if(base
->pcidevice_attr_base
!= 0)
140 OOP_ReleaseAttrBase(IID_Hidd_PCIDevice
);
141 if(base
->irq_hidd
!= NULL
)
142 OOP_DisposeObject(base
->irq_hidd
);
143 if(base
->pci_hidd
!= NULL
)
144 OOP_DisposeObject(base
->pci_hidd
);
151 ADD2INITLIB(LibInit
, 0);
152 ADD2EXPUNGELIB(DeleteLibrary
, 0);
153 ADD2LIBS("irq.hidd", 0, static struct Library
*, __irqhidd
);