ia64/xen-unstable

changeset 17698:b259eebb0223

hvmloader: Fix pci_setup() to not skip BAR remapping for virtual VGA devices.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 22 11:04:02 2008 +0100 (2008-05-22)
parents e48453f82d30
children 74d0f17f3fa5 2195290728d4
files tools/firmware/hvmloader/hvmloader.c
line diff
     1.1 --- a/tools/firmware/hvmloader/hvmloader.c	Thu May 22 10:41:49 2008 +0100
     1.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Thu May 22 11:04:02 2008 +0100
     1.3 @@ -198,11 +198,8 @@ static void pci_setup(void)
     1.4                  virtual_vga = VGA_cirrus;
     1.5              break;
     1.6          case 0x0680:
     1.7 +            /* PIIX4 ACPI PM. Special device with special PCI config space. */
     1.8              ASSERT((vendor_id == 0x8086) && (device_id == 0x7113));
     1.9 -            /*
    1.10 -             * PIIX4 ACPI PM. Special device with special PCI config space.
    1.11 -             * No ordinary BARs.
    1.12 -             */
    1.13              pci_writew(devfn, 0x20, 0x0000); /* No smb bus IO enable */
    1.14              pci_writew(devfn, 0x22, 0x0000);
    1.15              pci_writew(devfn, 0x3c, 0x0009); /* Hardcoded IRQ9 */
    1.16 @@ -213,42 +210,41 @@ static void pci_setup(void)
    1.17              ASSERT((vendor_id == 0x8086) && (device_id == 0x7010));
    1.18              pci_writew(devfn, 0x40, 0x8000); /* enable IDE0 */
    1.19              pci_writew(devfn, 0x42, 0x8000); /* enable IDE1 */
    1.20 -            /* fall through */
    1.21 -        default:
    1.22 -            /* Default memory mappings. */
    1.23 -            for ( bar = 0; bar < 7; bar++ )
    1.24 -            {
    1.25 -                bar_reg = PCI_BASE_ADDRESS_0 + 4*bar;
    1.26 -                if ( bar == 6 )
    1.27 -                    bar_reg = PCI_ROM_ADDRESS;
    1.28 +            break;
    1.29 +        }
    1.30  
    1.31 -                bar_data = pci_readl(devfn, bar_reg);
    1.32 -                pci_writel(devfn, bar_reg, ~0);
    1.33 -                bar_sz = pci_readl(devfn, bar_reg);
    1.34 -                pci_writel(devfn, bar_reg, bar_data);
    1.35 -                if ( bar_sz == 0 )
    1.36 -                    continue;
    1.37 +        /* Map the I/O memory and port resources. */
    1.38 +        for ( bar = 0; bar < 7; bar++ )
    1.39 +        {
    1.40 +            bar_reg = PCI_BASE_ADDRESS_0 + 4*bar;
    1.41 +            if ( bar == 6 )
    1.42 +                bar_reg = PCI_ROM_ADDRESS;
    1.43 +
    1.44 +            bar_data = pci_readl(devfn, bar_reg);
    1.45 +            pci_writel(devfn, bar_reg, ~0);
    1.46 +            bar_sz = pci_readl(devfn, bar_reg);
    1.47 +            pci_writel(devfn, bar_reg, bar_data);
    1.48 +            if ( bar_sz == 0 )
    1.49 +                continue;
    1.50  
    1.51 -                bar_sz &= (((bar_data & PCI_BASE_ADDRESS_SPACE) ==
    1.52 -                           PCI_BASE_ADDRESS_SPACE_MEMORY) ?
    1.53 -                           PCI_BASE_ADDRESS_MEM_MASK :
    1.54 -                           (PCI_BASE_ADDRESS_IO_MASK & 0xffff));
    1.55 -                bar_sz &= ~(bar_sz - 1);
    1.56 -
    1.57 -                for ( i = 0; i < nr_bars; i++ )
    1.58 -                    if ( bars[i].bar_sz < bar_sz )
    1.59 -                        break;
    1.60 +            bar_sz &= (((bar_data & PCI_BASE_ADDRESS_SPACE) ==
    1.61 +                        PCI_BASE_ADDRESS_SPACE_MEMORY) ?
    1.62 +                       PCI_BASE_ADDRESS_MEM_MASK :
    1.63 +                       (PCI_BASE_ADDRESS_IO_MASK & 0xffff));
    1.64 +            bar_sz &= ~(bar_sz - 1);
    1.65  
    1.66 -                if ( i != nr_bars )
    1.67 -                    memmove(&bars[i+1], &bars[i], (nr_bars-i) * sizeof(*bars));
    1.68 +            for ( i = 0; i < nr_bars; i++ )
    1.69 +                if ( bars[i].bar_sz < bar_sz )
    1.70 +                    break;
    1.71  
    1.72 -                bars[i].devfn   = devfn;
    1.73 -                bars[i].bar_reg = bar_reg;
    1.74 -                bars[i].bar_sz  = bar_sz;
    1.75 +            if ( i != nr_bars )
    1.76 +                memmove(&bars[i+1], &bars[i], (nr_bars-i) * sizeof(*bars));
    1.77  
    1.78 -                nr_bars++;
    1.79 -            }
    1.80 -            break;
    1.81 +            bars[i].devfn   = devfn;
    1.82 +            bars[i].bar_reg = bar_reg;
    1.83 +            bars[i].bar_sz  = bar_sz;
    1.84 +
    1.85 +            nr_bars++;
    1.86          }
    1.87  
    1.88          /* Map the interrupt. */