debuggers.hg

changeset 18065:b41e07aa555a

hvmloader, rombios: Make use of new rom-lock facility in ioemu platform device.
Signed-off-by: Trolle Selander <trolle.selander@eu.citrix.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jul 11 12:31:32 2008 +0100 (2008-07-11)
parents 27aaff984b36
children 657bdd581db2
files tools/firmware/hvmloader/acpi/build.c tools/firmware/hvmloader/config.h tools/firmware/hvmloader/hvmloader.c tools/firmware/rombios/rombios.c
line diff
     1.1 --- a/tools/firmware/hvmloader/acpi/build.c	Thu Jul 10 17:33:23 2008 +0100
     1.2 +++ b/tools/firmware/hvmloader/acpi/build.c	Fri Jul 11 12:31:32 2008 +0100
     1.3 @@ -70,12 +70,7 @@ static int hpet_exists(unsigned long hpe
     1.4  
     1.5  static int construct_bios_info_table(uint8_t *buf)
     1.6  {
     1.7 -    struct bios_info {
     1.8 -        uint8_t  com1_present:1;
     1.9 -        uint8_t  com2_present:1;
    1.10 -        uint8_t  hpet_present:1;
    1.11 -        uint32_t pci_min, pci_len;
    1.12 -    } *bios_info = (struct bios_info *)buf;
    1.13 +    struct bios_info *bios_info = (struct bios_info *)buf;
    1.14  
    1.15      memset(bios_info, 0, sizeof(*bios_info));
    1.16  
    1.17 @@ -86,6 +81,7 @@ static int construct_bios_info_table(uin
    1.18  
    1.19      bios_info->pci_min = PCI_MEMBASE;
    1.20      bios_info->pci_len = PCI_MEMSIZE;
    1.21 +    bios_info->xen_pfiob = 0xdead;
    1.22  
    1.23      return align16(sizeof(*bios_info));
    1.24  }
     2.1 --- a/tools/firmware/hvmloader/config.h	Thu Jul 10 17:33:23 2008 +0100
     2.2 +++ b/tools/firmware/hvmloader/config.h	Fri Jul 11 12:31:32 2008 +0100
     2.3 @@ -31,4 +31,15 @@
     2.4  #define ROMBIOS_PHYSICAL_ADDRESS      0x000F0000
     2.5  #define SCRATCH_PHYSICAL_ADDRESS      0x00010000
     2.6  
     2.7 +/* Xen Platform Device */
     2.8 +#define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
     2.9 +
    2.10 +struct bios_info {
    2.11 +    uint8_t  com1_present:1;
    2.12 +    uint8_t  com2_present:1;
    2.13 +    uint8_t  hpet_present:1;
    2.14 +    uint32_t pci_min, pci_len;
    2.15 +    uint16_t xen_pfiob;
    2.16 +};
    2.17 +
    2.18  #endif /* __HVMLOADER_CONFIG_H__ */
     3.1 --- a/tools/firmware/hvmloader/hvmloader.c	Thu Jul 10 17:33:23 2008 +0100
     3.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Fri Jul 11 12:31:32 2008 +0100
     3.3 @@ -434,6 +434,23 @@ static void cmos_write_memory_size(void)
     3.4      cmos_outb(0x35, (uint8_t)( alt_mem >> 8));
     3.5  }
     3.6  
     3.7 +static void init_xen_platform_io_base(void)
     3.8 +{
     3.9 +    struct bios_info *bios_info = (struct bios_info *)ACPI_PHYSICAL_ADDRESS;
    3.10 +    uint32_t devfn, bar_data;
    3.11 +    uint16_t vendor_id, device_id;
    3.12 +
    3.13 +    for ( devfn = 0; devfn < 128; devfn++ )
    3.14 +    {
    3.15 +        vendor_id = pci_readw(devfn, PCI_VENDOR_ID);
    3.16 +        device_id = pci_readw(devfn, PCI_DEVICE_ID);
    3.17 +        if ( (vendor_id != 0x5853) || (device_id != 0x0001) )
    3.18 +            continue;
    3.19 +        bar_data = pci_readl(devfn, PCI_BASE_ADDRESS_0);
    3.20 +        bios_info->xen_pfiob = bar_data & PCI_BASE_ADDRESS_IO_MASK;
    3.21 +    }
    3.22 +}
    3.23 +
    3.24  int main(void)
    3.25  {
    3.26      int acpi_sz = 0, vgabios_sz = 0, etherboot_sz = 0, rombios_sz, smbios_sz;
    3.27 @@ -527,6 +544,8 @@ int main(void)
    3.28                 ROMBIOS_PHYSICAL_ADDRESS,
    3.29                 ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1);
    3.30  
    3.31 +    init_xen_platform_io_base();
    3.32 +
    3.33      printf("Invoking ROMBIOS ...\n");
    3.34      return 0;
    3.35  }
     4.1 --- a/tools/firmware/rombios/rombios.c	Thu Jul 10 17:33:23 2008 +0100
     4.2 +++ b/tools/firmware/rombios/rombios.c	Fri Jul 11 12:31:32 2008 +0100
     4.3 @@ -26,6 +26,9 @@
     4.4  
     4.5  // ROM BIOS for use with Bochs/Plex x86 emulation environment
     4.6  
     4.7 +#define uint8_t unsigned char
     4.8 +#define uint16_t unsigned short
     4.9 +#define uint32_t unsigned long
    4.10  #include "../hvmloader/config.h"
    4.11  
    4.12  #define HVMASSIST
    4.13 @@ -1459,6 +1462,23 @@ copy_e820_table()
    4.14    base_mem = read_dword(0x9000, 0x2d0 + 8);
    4.15    write_word(0x40, 0x13, base_mem >> 10);
    4.16  }
    4.17 +
    4.18 +void
    4.19 +disable_rom_write_access()
    4.20 +{
    4.21 +    Bit16u off = (Bit16u)&((struct bios_info *)0)->xen_pfiob;
    4.22 +ASM_START
    4.23 +    mov si,.disable_rom_write_access.off[bp]
    4.24 +    push ds
    4.25 +    mov ax,#(ACPI_PHYSICAL_ADDRESS >> 4)
    4.26 +    mov ds,ax
    4.27 +    mov dx,[si]
    4.28 +    pop ds
    4.29 +    mov ax,#PFFLAG_ROM_LOCK
    4.30 +    out dx,al
    4.31 +ASM_END
    4.32 +}
    4.33 +    
    4.34  #endif /* HVMASSIST */
    4.35  
    4.36  #if BX_DEBUG_SERIAL
    4.37 @@ -10155,6 +10175,10 @@ post_default_ints:
    4.38    call tcpa_post_part2
    4.39  #endif
    4.40  
    4.41 +#ifdef HVMASSIST
    4.42 +  call _disable_rom_write_access
    4.43 +#endif 
    4.44 +
    4.45    ;; Start the boot sequence.   See the comments in int19_relocated 
    4.46    ;; for why we use INT 18h instead of INT 19h here.
    4.47    int  #0x18