[SeaBIOS] [PATCH v3 1/6] pci: add two-pass pci initialization code

Michael S. Tsirkin mst at redhat.com
Fri Jul 8 16:34:53 CEST 2011


On Fri, Jul 08, 2011 at 09:35:39AM +0200, Gerd Hoffmann wrote:
>   Hi,
> 
> >>+#define ROOT_BASE(top, sum, align) ALIGN_DOWN((top)-(sum),(align))
> >>+
> >>+static int pci_bios_init_root_regions(u32 start, u32 end)
> >>+{
> >>+    struct pci_bus *bus =&busses[0];
> >>+
> >>+    bus->r[PCI_REGION_TYPE_IO].base = 0xc000;
> >>+
> >>+    if (bus->r[PCI_REGION_TYPE_MEM].sum<  bus->r[PCI_REGION_TYPE_PREFMEM].sum) {
> >>+        bus->r[PCI_REGION_TYPE_MEM].base =
> >>+            ROOT_BASE(end,
> >>+                      bus->r[PCI_REGION_TYPE_MEM].sum,
> >>+                      bus->r[PCI_REGION_TYPE_MEM].max);
> >
> >This aligns down which looks strange to me.
> >Shouldn't we align up to avoid overlap?
> 
> Depends on how you allocate.  This starts from the top of the pci
> address space, so we actually have to align down to avoid overlaps.
> 
> cheers,
>   Gerd

Hmm but within a bridge we allocate down to top, right?

+static u32 pci_bios_bus_get_addr(struct pci_bus *bus, int type, u32
size)
+{
+    u32 index, addr;
+
+    index = pci_size_to_index(size, type);
+    addr = bus->r[type].bases[index];
+    bus->r[type].bases[index] += pci_index_to_size(index, type);
+    return addr;
+}
+

This seems to fragment the memory more than necessary:
why not allocate everything from the top then?

-- 
MST



More information about the SeaBIOS mailing list