-#ifndef CONFIG_DEBUG_PCI
+#ifndef V3_CONFIG_DEBUG_PCI
#undef PrintDebug
#define PrintDebug(fmt, args...)
#endif
-#ifdef CONFIG_DEBUG_PCI
+#ifdef V3_CONFIG_DEBUG_PCI
static void pci_dump_state(struct pci_internal * pci_state) {
struct rb_node * node = v3_rb_first(&(pci_state->bus_list[0].devices));
-static int pci_free(struct vm_device * dev) {
-
- return 0;
-}
-
static void init_pci_busses(struct pci_internal * pci_state) {
}
+static int pci_free(struct pci_internal * pci_state) {
+ int i;
+
+
+ // cleanup devices
+ for (i = 0; i < PCI_BUS_COUNT; i++) {
+ struct pci_bus * bus = &(pci_state->bus_list[i]);
+ struct rb_node * node = v3_rb_first(&(bus->devices));
+ struct pci_device * dev = NULL;
+
+ while (node) {
+ dev = rb_entry(node, struct pci_device, dev_tree_node);
+ node = v3_rb_next(node);
+
+ v3_rb_erase(&(dev->dev_tree_node), &(bus->devices));
+ V3_Free(dev);
+ }
+
+ }
+
+ V3_Free(pci_state);
+ return 0;
+}
static struct v3_device_ops dev_ops = {
- .free = pci_free,
+ .free = (int (*)(void *))pci_free,
};
// add the device
add_device_to_bus(bus, pci_dev);
-#ifdef CONFIG_DEBUG_PCI
+#ifdef V3_CONFIG_DEBUG_PCI
pci_dump_state(pci_state);
#endif
// add the device
add_device_to_bus(bus, pci_dev);
-#ifdef CONFIG_DEBUG_PCI
+#ifdef V3_CONFIG_DEBUG_PCI
pci_dump_state(pci_state);
#endif