Fixes to GT-PCI driver extracted from
@@ -202,11 +202,13 @@ static void gt_pci_unmask_irq(gt_pci_state_t *gtpci, unsigned irq) {
gt_pci_set_icus(gtpci);
}
+pci_bus_driver_t gt_pci_bus;
+
static void gt_pci_intr_setup(device_t *pcib, unsigned irq,
intr_handler_t *handler) {
- klog("gt_pci_intr_setup(%p, %d, %p)", pcib, irq, handler);
+ assert(pcib->parent->driver == &gt_pci_bus.driver);
- gt_pci_state_t *gtpci = pcib->state;
+ gt_pci_state_t *gtpci = pcib->parent->state;
intr_chain_t *chain = &gtpci->intr_chain[irq];
CRITICAL_SECTION {
intr_chain_add_handler(chain, handler);
@@ -216,9 +218,9 @@ static void gt_pci_intr_setup(device_t *pcib, unsigned irq,
}
static void gt_pci_intr_teardown(device_t *pcib, intr_handler_t *handler) {
- klog("gt_pci_intr_teardown(%p, %p)", pcib, handler);
+ assert(pcib->parent->driver == &gt_pci_bus.driver);
- gt_pci_state_t *gtpci = pcib->state;
+ gt_pci_state_t *gtpci = pcib->parent->state;
intr_chain_t *chain = handler->ih_chain;
CRITICAL_SECTION {
if (chain->ic_count == 1)
@@ -295,6 +297,9 @@ static inline void gt_pci_intr_chain_init(gt_pci_state_t *gtpci, unsigned irq,
static int gt_pci_attach(device_t *pcib) {
gt_pci_state_t *gtpci = pcib->state;
+
+ pcib->bus = DEV_BUS_PCI;
+
gtpci->pci_bus.mem_space = &gt_pci_memory;
gtpci->pci_bus.io_space = &gt_pci_ioports;
gtpci->corectrl = &gt_pci_corectrl;
