]> xenbits.xensource.com Git - seabios.git/commitdiff
Revert "Convert pciinit.c to use standard list manipulation code."
authorKevin O'Connor <kevin@koconnor.net>
Thu, 13 Jun 2013 12:42:29 +0000 (08:42 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 13 Jun 2013 12:42:29 +0000 (08:42 -0400)
This reverts commit aab42152881dc62b37f1833e79cbdb3dfa51603b.

src/pciinit.c

index 446dddf01facacd5c3ec0c2f5287a0d4dac6d3d1..bb9355fc3b24f16e18e1e01d1fe7402b7b132fec 100644 (file)
@@ -13,8 +13,7 @@
 #include "config.h" // CONFIG_*
 #include "memmap.h" // add_e820
 #include "paravirt.h" // RamSize
-#include "dev-q35.h" // Q35_HOST_BRIDGE_PCIEXBAR_ADDR
-#include "list.h" // struct hlist_node
+#include "dev-q35.h"
 
 /* PM Timer ticks per second (HZ) */
 #define PM_TIMER_FREQUENCY  3579545
@@ -48,13 +47,13 @@ struct pci_region_entry {
     u64 align;
     int is64;
     enum pci_region_type type;
-    struct hlist_node node;
+    struct pci_region_entry *next;
 };
 
 struct pci_region {
     /* pci region assignments */
     u64 base;
-    struct hlist_head list;
+    struct pci_region_entry *list;
 };
 
 struct pci_bus {
@@ -540,30 +539,30 @@ static int pci_bios_bridge_region_is64(struct pci_region *r,
     }
     if ((pmem & PCI_PREF_RANGE_TYPE_MASK) != PCI_PREF_RANGE_TYPE_64)
        return 0;
-    struct pci_region_entry *entry;
-    hlist_for_each_entry(entry, &r->list, node) {
+    struct pci_region_entry *entry = r->list;
+    while (entry) {
         if (!entry->is64)
             return 0;
+        entry = entry->next;
     }
     return 1;
 }
 
 static u64 pci_region_align(struct pci_region *r)
 {
-    struct pci_region_entry *entry;
-    hlist_for_each_entry(entry, &r->list, node) {
-        // The first entry in the sorted list has the largest alignment
-        return entry->align;
-    }
-    return 1;
+    if (!r->list)
+        return 1;
+    // The first entry in the sorted list has the largest alignment
+    return r->list->align;
 }
 
 static u64 pci_region_sum(struct pci_region *r)
 {
+    struct pci_region_entry *entry = r->list;
     u64 sum = 0;
-    struct pci_region_entry *entry;
-    hlist_for_each_entry(entry, &r->list, node) {
+    while (entry) {
         sum += entry->size;
+        entry = entry->next;
     }
     return sum;
 }
@@ -571,14 +570,18 @@ static u64 pci_region_sum(struct pci_region *r)
 static void pci_region_migrate_64bit_entries(struct pci_region *from,
                                              struct pci_region *to)
 {
-    struct hlist_node **pprev, **last = &to->list.first;
-    struct pci_region_entry *entry;
-    hlist_for_each_entry_safe(entry, pprev, &from->list, node) {
-        if (!entry->is64)
+    struct pci_region_entry **pprev = &from->list, **last = &to->list;
+    while (*pprev) {
+        struct pci_region_entry *entry = *pprev;
+        if (!entry->is64) {
+            pprev = &entry->next;
             continue;
+        }
         // Move from source list to destination list.
-        hlist_del(&entry->node);
-        hlist_add(&entry->node, last);
+        *pprev = entry->next;
+        entry->next = NULL;
+        *last = entry;
+        last = &entry->next;
     }
 }
 
@@ -599,13 +602,14 @@ pci_region_create_entry(struct pci_bus *bus, struct pci_device *dev,
     entry->is64 = is64;
     entry->type = type;
     // Insert into list in sorted order.
-    struct hlist_node **pprev;
-    struct pci_region_entry *pos;
-    hlist_for_each_entry_safe(pos, pprev, &bus->r[type].list, node) {
+    struct pci_region_entry **pprev;
+    for (pprev = &bus->r[type].list; *pprev; pprev = &(*pprev)->next) {
+        struct pci_region_entry *pos = *pprev;
         if (pos->align < align || (pos->align == align && pos->size < size))
             break;
     }
-    hlist_add(&entry->node, pprev);
+    entry->next = *pprev;
+    *pprev = entry;
     return entry;
 }
 
@@ -744,17 +748,17 @@ pci_region_map_one_entry(struct pci_region_entry *entry, u64 addr)
 
 static void pci_region_map_entries(struct pci_bus *busses, struct pci_region *r)
 {
-    struct hlist_node **pprev;
-    struct pci_region_entry *entry;
-    hlist_for_each_entry_safe(entry, pprev, &r->list, node) {
+    struct pci_region_entry *entry = r->list;
+    while (entry) {
         u64 addr = r->base;
         r->base += entry->size;
         if (entry->bar == -1)
             // Update bus base address if entry is a bridge region
             busses[entry->dev->secondary_bus].r[entry->type].base = addr;
         pci_region_map_one_entry(entry, addr);
-        hlist_del(&entry->node);
+        struct pci_region_entry *next = entry->next;
         free(entry);
+        entry = next;
     }
 }
 
@@ -762,8 +766,8 @@ static void pci_bios_map_devices(struct pci_bus *busses)
 {
     if (pci_bios_init_root_regions(busses)) {
         struct pci_region r64_mem, r64_pref;
-        r64_mem.list.first = NULL;
-        r64_pref.list.first = NULL;
+        r64_mem.list = NULL;
+        r64_pref.list = NULL;
         pci_region_migrate_64bit_entries(&busses[0].r[PCI_REGION_TYPE_MEM],
                                          &r64_mem);
         pci_region_migrate_64bit_entries(&busses[0].r[PCI_REGION_TYPE_PREFMEM],