ia64/xen-unstable

changeset 16835:b006c58b055e

hvmloader: Expand iomem allocation pool to 0xf0000000-0xfc000000.

Check for exhaustion of allocation pool, warn user, and fail to
initialise the relevant PCI BAR.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jan 22 11:18:10 2008 +0000 (2008-01-22)
parents 824ffb1efa9c
children d5e22e766d1f
files tools/firmware/hvmloader/acpi/build.c tools/firmware/hvmloader/hvmloader.c
line diff
     1.1 --- a/tools/firmware/hvmloader/acpi/build.c	Tue Jan 22 10:54:00 2008 +0000
     1.2 +++ b/tools/firmware/hvmloader/acpi/build.c	Tue Jan 22 11:18:10 2008 +0000
     1.3 @@ -76,7 +76,7 @@ static int construct_bios_info_table(uin
     1.4      bios_info->com2_present = uart_exists(0x2f8);
     1.5  
     1.6      bios_info->pci_min = 0xf0000000;
     1.7 -    bios_info->pci_len = 0x05000000;
     1.8 +    bios_info->pci_len = 0x0c000000;
     1.9  
    1.10      return align16(sizeof(*bios_info));
    1.11  }
     2.1 --- a/tools/firmware/hvmloader/hvmloader.c	Tue Jan 22 10:54:00 2008 +0000
     2.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Tue Jan 22 11:18:10 2008 +0000
     2.3 @@ -183,11 +183,17 @@ static void apic_setup(void)
     2.4  
     2.5  static void pci_setup(void)
     2.6  {
     2.7 -    uint32_t devfn, bar_reg, bar_data, bar_sz, cmd;
     2.8 -    uint32_t *base, io_base = 0xc000, mem_base = HVM_BELOW_4G_MMIO_START;
     2.9 +    uint32_t base, devfn, bar_reg, bar_data, bar_sz, cmd;
    2.10      uint16_t class, vendor_id, device_id;
    2.11      unsigned int bar, pin, link, isa_irq;
    2.12  
    2.13 +    /* Resources assignable to PCI devices via BARs. */
    2.14 +    struct resource {
    2.15 +        uint32_t base, max;
    2.16 +    } *resource;
    2.17 +    struct resource mem_resource = { 0xf0000000, 0xfc000000 };
    2.18 +    struct resource io_resource  = { 0xc000, 0x10000 };
    2.19 +
    2.20      /* Create a list of device BARs in descending order of size. */
    2.21      struct bars {
    2.22          uint32_t devfn, bar_reg, bar_sz;
    2.23 @@ -301,22 +307,31 @@ static void pci_setup(void)
    2.24          if ( (bar_data & PCI_BASE_ADDRESS_SPACE) ==
    2.25               PCI_BASE_ADDRESS_SPACE_MEMORY )
    2.26          {
    2.27 -            base = &mem_base;
    2.28 +            resource = &mem_resource;
    2.29              bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK;
    2.30          }
    2.31          else
    2.32          {
    2.33 -            base = &io_base;
    2.34 +            resource = &io_resource;
    2.35              bar_data &= ~PCI_BASE_ADDRESS_IO_MASK;
    2.36          }
    2.37  
    2.38 -        *base = (*base + bar_sz - 1) & ~(bar_sz - 1);
    2.39 -        bar_data |= *base;
    2.40 -        *base += bar_sz;
    2.41 +        base = (resource->base + bar_sz - 1) & ~(bar_sz - 1);
    2.42 +        bar_data |= base;
    2.43 +        base += bar_sz;
    2.44 +
    2.45 +        if ( (base < resource->base) || (base > resource->max) )
    2.46 +        {
    2.47 +            printf("pci dev %02x:%x bar %02x size %08x: no space for "
    2.48 +                   "resource!\n", devfn>>3, devfn&7, bar_reg, bar_sz);
    2.49 +            continue;
    2.50 +        }
    2.51 +
    2.52 +        resource->base = base;
    2.53  
    2.54          pci_writel(devfn, bar_reg, bar_data);
    2.55 -        printf("pci dev %02x:%x bar %02x size %08x: %08x %08x/%08x\n",
    2.56 -               devfn>>3, devfn&7, bar_reg, bar_sz, bar_data, i, nr_bars);
    2.57 +        printf("pci dev %02x:%x bar %02x size %08x: %08x\n",
    2.58 +               devfn>>3, devfn&7, bar_reg, bar_sz, bar_data);
    2.59  
    2.60          /* Now enable the memory or I/O mapping. */
    2.61          cmd = pci_readw(devfn, PCI_COMMAND);