ia64/xen-unstable

changeset 14959:5754173c3d81

hvmloader: Place SMBIOS tables at 0xE9000. Previous location was lower
than nay native system would place them.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Apr 26 16:45:06 2007 +0100 (2007-04-26)
parents ac203df11e50
children 39383ac1aec8
files tools/firmware/hvmloader/acpi/acpi2_0.h tools/firmware/hvmloader/config.h tools/firmware/hvmloader/hvmloader.c tools/firmware/hvmloader/hypercall.h tools/firmware/hvmloader/smbios.c tools/firmware/hvmloader/smbios.h tools/firmware/hvmloader/util.c tools/firmware/hvmloader/util.h tools/firmware/rombios/rombios.c tools/libxc/xc_hvm_build.c
line diff
     1.1 --- a/tools/firmware/hvmloader/acpi/acpi2_0.h	Thu Apr 26 16:15:08 2007 +0100
     1.2 +++ b/tools/firmware/hvmloader/acpi/acpi2_0.h	Thu Apr 26 16:45:06 2007 +0100
     1.3 @@ -394,8 +394,6 @@ struct acpi_20_madt_intsrcovr {
     1.4  
     1.5  #pragma pack ()
     1.6  
     1.7 -#define ACPI_PHYSICAL_ADDRESS 0xEA000
     1.8 -
     1.9  int acpi_build_tables(uint8_t *);
    1.10  
    1.11  #endif /* _ACPI_2_0_H_ */
     2.1 --- a/tools/firmware/hvmloader/config.h	Thu Apr 26 16:15:08 2007 +0100
     2.2 +++ b/tools/firmware/hvmloader/config.h	Thu Apr 26 16:45:06 2007 +0100
     2.3 @@ -17,5 +17,14 @@
     2.4  #define ROMBIOS_MAXOFFSET      0x0000FFFF
     2.5  #define ROMBIOS_END            (ROMBIOS_BEGIN + ROMBIOS_SIZE)
     2.6  
     2.7 +/* Memory map. */
     2.8 +#define HYPERCALL_PHYSICAL_ADDRESS    0x00080000
     2.9 +#define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
    2.10 +#define ETHERBOOT_PHYSICAL_ADDRESS    0x000C8000
    2.11 +#define VMXASSIST_PHYSICAL_ADDRESS    0x000D0000
    2.12 +#define SMBIOS_PHYSICAL_ADDRESS       0x000E9000
    2.13 +#define SMBIOS_MAXIMUM_SIZE           0x00001000
    2.14 +#define ACPI_PHYSICAL_ADDRESS         0x000EA000
    2.15 +#define ROMBIOS_PHYSICAL_ADDRESS      0x000F0000
    2.16  
    2.17  #endif /* __HVMLOADER_CONFIG_H__ */
     3.1 --- a/tools/firmware/hvmloader/hvmloader.c	Thu Apr 26 16:15:08 2007 +0100
     3.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Thu Apr 26 16:45:06 2007 +0100
     3.3 @@ -19,24 +19,17 @@
     3.4   * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
     3.5   * Place - Suite 330, Boston, MA 02111-1307 USA.
     3.6   */
     3.7 +
     3.8  #include "roms.h"
     3.9 -#include "acpi/acpi2_0.h"  /* for ACPI_PHYSICAL_ADDRESS */
    3.10 +#include "acpi/acpi2_0.h"
    3.11  #include "hypercall.h"
    3.12  #include "util.h"
    3.13 -#include "smbios.h"
    3.14  #include "config.h"
    3.15  #include "apic_regs.h"
    3.16  #include "pci_regs.h"
    3.17  #include <xen/version.h>
    3.18  #include <xen/hvm/params.h>
    3.19  
    3.20 -/* memory map */
    3.21 -#define HYPERCALL_PHYSICAL_ADDRESS    0x00080000
    3.22 -#define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
    3.23 -#define ETHERBOOT_PHYSICAL_ADDRESS    0x000C8000
    3.24 -#define VMXASSIST_PHYSICAL_ADDRESS    0x000D0000
    3.25 -#define ROMBIOS_PHYSICAL_ADDRESS      0x000F0000
    3.26 -
    3.27  asm(
    3.28      "    .text                       \n"
    3.29      "    .globl _start               \n"
    3.30 @@ -103,7 +96,8 @@ asm(
    3.31      "stack_top:                      \n"
    3.32      );
    3.33  
    3.34 -extern void create_mp_tables(void);
    3.35 +void create_mp_tables(void);
    3.36 +int hvm_write_smbios_tables(void);
    3.37  
    3.38  static int
    3.39  cirrus_check(void)
    3.40 @@ -351,17 +345,20 @@ static void cmos_write_memory_size(void)
    3.41  
    3.42  int main(void)
    3.43  {
    3.44 -    int acpi_sz;
    3.45 +    int acpi_sz = 0, vgabios_sz = 0, etherboot_sz = 0, rombios_sz, smbios_sz;
    3.46  
    3.47      printf("HVM Loader\n");
    3.48  
    3.49      init_hypercalls();
    3.50  
    3.51      printf("Writing SMBIOS tables ...\n");
    3.52 -    hvm_write_smbios_tables();
    3.53 +    smbios_sz = hvm_write_smbios_tables();
    3.54  
    3.55      printf("Loading ROMBIOS ...\n");
    3.56 -    memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, sizeof(rombios));
    3.57 +    rombios_sz = sizeof(rombios);
    3.58 +    if ( rombios_sz > 0x10000 )
    3.59 +        rombios_sz = 0x10000;
    3.60 +    memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, rombios_sz);
    3.61      highbios_setup();
    3.62  
    3.63      apic_setup();
    3.64 @@ -375,12 +372,14 @@ int main(void)
    3.65          printf("Loading Cirrus VGABIOS ...\n");
    3.66          memcpy((void *)VGABIOS_PHYSICAL_ADDRESS,
    3.67                 vgabios_cirrusvga, sizeof(vgabios_cirrusvga));
    3.68 +        vgabios_sz = sizeof(vgabios_cirrusvga);
    3.69      }
    3.70      else
    3.71      {
    3.72          printf("Loading Standard VGABIOS ...\n");
    3.73          memcpy((void *)VGABIOS_PHYSICAL_ADDRESS,
    3.74                 vgabios_stdvga, sizeof(vgabios_stdvga));
    3.75 +        vgabios_sz = sizeof(vgabios_stdvga);
    3.76      }
    3.77  
    3.78      if ( must_load_nic() )
    3.79 @@ -388,9 +387,10 @@ int main(void)
    3.80          printf("Loading ETHERBOOT ...\n");
    3.81          memcpy((void *)ETHERBOOT_PHYSICAL_ADDRESS,
    3.82                 etherboot, sizeof(etherboot));
    3.83 +        etherboot_sz = sizeof(etherboot);
    3.84      }
    3.85  
    3.86 -    if ( get_acpi_enabled() != 0 )
    3.87 +    if ( get_acpi_enabled() )
    3.88      {
    3.89          printf("Loading ACPI ...\n");
    3.90          acpi_sz = acpi_build_tables((uint8_t *)ACPI_PHYSICAL_ADDRESS);
    3.91 @@ -399,6 +399,32 @@ int main(void)
    3.92  
    3.93      cmos_write_memory_size();
    3.94  
    3.95 +    printf("BIOS map:\n");
    3.96 +    if ( vgabios_sz )
    3.97 +        printf(" %05x-%05x: VGA BIOS\n",
    3.98 +               VGABIOS_PHYSICAL_ADDRESS,
    3.99 +               VGABIOS_PHYSICAL_ADDRESS + vgabios_sz - 1);
   3.100 +    if ( etherboot_sz )
   3.101 +        printf(" %05x-%05x: Etherboot ROM\n",
   3.102 +               ETHERBOOT_PHYSICAL_ADDRESS,
   3.103 +               ETHERBOOT_PHYSICAL_ADDRESS + etherboot_sz - 1);
   3.104 +    if ( !check_amd() )
   3.105 +        printf(" %05x-%05x: VMXAssist\n",
   3.106 +               VMXASSIST_PHYSICAL_ADDRESS,
   3.107 +               VMXASSIST_PHYSICAL_ADDRESS + sizeof(vmxassist) - 1);
   3.108 +    if ( smbios_sz )
   3.109 +        printf(" %05x-%05x: SMBIOS tables\n",
   3.110 +               SMBIOS_PHYSICAL_ADDRESS,
   3.111 +               SMBIOS_PHYSICAL_ADDRESS + smbios_sz - 1);
   3.112 +    if ( acpi_sz )
   3.113 +        printf(" %05x-%05x: ACPI tables\n",
   3.114 +               ACPI_PHYSICAL_ADDRESS,
   3.115 +               ACPI_PHYSICAL_ADDRESS + acpi_sz - 1);
   3.116 +    if ( rombios_sz )
   3.117 +        printf(" %05x-%05x: Main BIOS\n",
   3.118 +               ROMBIOS_PHYSICAL_ADDRESS,
   3.119 +               ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1);
   3.120 +
   3.121      if ( !check_amd() )
   3.122      {
   3.123          printf("Loading VMXAssist ...\n");
     4.1 --- a/tools/firmware/hvmloader/hypercall.h	Thu Apr 26 16:15:08 2007 +0100
     4.2 +++ b/tools/firmware/hvmloader/hypercall.h	Thu Apr 26 16:45:06 2007 +0100
     4.3 @@ -31,17 +31,18 @@
     4.4  #ifndef __HVMLOADER_HYPERCALL_H__
     4.5  #define __HVMLOADER_HYPERCALL_H__
     4.6  
     4.7 +#include <stdint.h>
     4.8  #include <xen/xen.h>
     4.9 +#include "config.h"
    4.10 +
    4.11 +#define __STR(...) #__VA_ARGS__
    4.12 +#define STR(...) __STR(__VA_ARGS__)
    4.13  
    4.14  /*
    4.15   * NB. Hypercall address needs to be relative to a linkage symbol for
    4.16   * some version of ld to relocate the relative calls properly.
    4.17 - * Keep this in sync with HYPERCALL_PHYSICAL_ADDRESS in hvmloader.c!
    4.18   */
    4.19 -#define hypercall_pa "_start - 0x80000"
    4.20 -
    4.21 -#define __STR(x) #x
    4.22 -#define STR(x) __STR(x)
    4.23 +#define hypercall_pa "_start - " STR(HYPERCALL_PHYSICAL_ADDRESS)
    4.24  
    4.25  #define _hypercall0(type, name)						\
    4.26  ({									\
     5.1 --- a/tools/firmware/hvmloader/smbios.c	Thu Apr 26 16:15:08 2007 +0100
     5.2 +++ b/tools/firmware/hvmloader/smbios.c	Thu Apr 26 16:45:06 2007 +0100
     5.3 @@ -22,12 +22,11 @@
     5.4  
     5.5  #include <stdint.h>
     5.6  #include <xen/version.h>
     5.7 -#include "smbios.h"
     5.8  #include "smbios_types.h"
     5.9  #include "util.h"
    5.10  #include "hypercall.h"
    5.11  
    5.12 -static size_t
    5.13 +static int
    5.14  write_smbios_tables(void *start,
    5.15                      uint32_t vcpus, uint64_t memsize,
    5.16                      uint8_t uuid[16], char *xen_version,
    5.17 @@ -82,7 +81,7 @@ get_cpu_manufacturer(char *buf, int len)
    5.18          strncpy(buf, "unknown", len);
    5.19  }
    5.20  
    5.21 -static size_t
    5.22 +static int
    5.23  write_smbios_tables(void *start,
    5.24                      uint32_t vcpus, uint64_t memsize,
    5.25                      uint8_t uuid[16], char *xen_version,
    5.26 @@ -125,7 +124,7 @@ write_smbios_tables(void *start,
    5.27          SMBIOS_PHYSICAL_ADDRESS + sizeof(struct smbios_entry_point),
    5.28          nr_structs);
    5.29  
    5.30 -    return (size_t)((char *)p - (char *)start);
    5.31 +    return ((char *)p - (char *)start);
    5.32  }
    5.33  
    5.34  /* Calculate how much pseudo-physical memory (in MB) is allocated to us. */
    5.35 @@ -156,7 +155,7 @@ get_memsize(void)
    5.36      return (memsize + (1 << 20) - 1) >> 20;
    5.37  }
    5.38  
    5.39 -void
    5.40 +int
    5.41  hvm_write_smbios_tables(void)
    5.42  {
    5.43      uint8_t uuid[16]; /* ** This will break if xen_domain_handle_t is
    5.44 @@ -221,16 +220,17 @@ hvm_write_smbios_tables(void)
    5.45                                get_vcpu_nr(), get_memsize(),
    5.46                                uuid, xen_version_str,
    5.47                                xen_major_version, xen_minor_version);
    5.48 -    if ( len > SMBIOS_SIZE_LIMIT )
    5.49 +    if ( len > SMBIOS_MAXIMUM_SIZE )
    5.50          goto error_out;
    5.51      /* Okay, not too large: copy out of scratch to final location. */
    5.52      memcpy((void *)SMBIOS_PHYSICAL_ADDRESS, (void *)0xC0000, len);
    5.53  
    5.54 -    return;
    5.55 +    return len;
    5.56  
    5.57   error_out:
    5.58      printf("Could not write SMBIOS tables, error in hvmloader.c:"
    5.59             "hvm_write_smbios_tables()\n");
    5.60 +    return 0;
    5.61  }
    5.62  
    5.63  
     6.1 --- a/tools/firmware/hvmloader/smbios.h	Thu Apr 26 16:15:08 2007 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,38 +0,0 @@
     6.4 -/*
     6.5 - * smbios.h - interface for Xen HVM SMBIOS generation
     6.6 - *
     6.7 - * This program is free software; you can redistribute it and/or modify
     6.8 - * it under the terms of the GNU General Public License as published by
     6.9 - * the Free Software Foundation; either version 2 of the License, or
    6.10 - * (at your option) any later version.
    6.11 - *
    6.12 - * This program is distributed in the hope that it will be useful,
    6.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.15 - * GNU General Public License for more details.
    6.16 - *
    6.17 - * You should have received a copy of the GNU General Public License
    6.18 - * along with this program; if not, write to the Free Software
    6.19 - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    6.20 - *
    6.21 - * Copyright (C) IBM Corporation, 2006
    6.22 - *
    6.23 - * Authors: Andrew D. Ball <aball@us.ibm.com>
    6.24 - */
    6.25 -
    6.26 -#ifndef SMBIOS_H
    6.27 -#define SMBIOS_H
    6.28 -
    6.29 -#include <stdint.h>
    6.30 -#include <stdlib.h>
    6.31 -
    6.32 -/* These constants must agree with the ACPI e820 memory map as defined
    6.33 -   in tools/libxc/xc_hvm_build.c and the address the ROMBIOS pulls the
    6.34 -   SMBIOS entry point from in the smbios_init subroutine.
    6.35 - */
    6.36 -#define SMBIOS_PHYSICAL_ADDRESS 0x9f000
    6.37 -#define SMBIOS_SIZE_LIMIT 0x800
    6.38 -
    6.39 -void hvm_write_smbios_tables(void);
    6.40 -
    6.41 -#endif /* SMBIOS_H */
     7.1 --- a/tools/firmware/hvmloader/util.c	Thu Apr 26 16:15:08 2007 +0100
     7.2 +++ b/tools/firmware/hvmloader/util.c	Thu Apr 26 16:45:06 2007 +0100
     7.3 @@ -18,7 +18,6 @@
     7.4   * Place - Suite 330, Boston, MA 02111-1307 USA.
     7.5   */
     7.6  
     7.7 -#include "acpi/acpi2_0.h"  /* for ACPI_PHYSICAL_ADDRESS */
     7.8  #include "util.h"
     7.9  #include "config.h"
    7.10  #include <stdint.h>
     8.1 --- a/tools/firmware/hvmloader/util.h	Thu Apr 26 16:15:08 2007 +0100
     8.2 +++ b/tools/firmware/hvmloader/util.h	Thu Apr 26 16:45:06 2007 +0100
     8.3 @@ -2,6 +2,7 @@
     8.4  #define __HVMLOADER_UTIL_H__
     8.5  
     8.6  #include <stdarg.h>
     8.7 +#include <stdint.h>
     8.8  
     8.9  #undef offsetof
    8.10  #define offsetof(t, m) ((unsigned long)&((t *)0)->m)
     9.1 --- a/tools/firmware/rombios/rombios.c	Thu Apr 26 16:15:08 2007 +0100
     9.2 +++ b/tools/firmware/rombios/rombios.c	Thu Apr 26 16:45:06 2007 +0100
     9.3 @@ -26,6 +26,8 @@
     9.4  
     9.5  // ROM BIOS for use with Bochs/Plex x86 emulation environment
     9.6  
     9.7 +#include "../hvmloader/config.h"
     9.8 +
     9.9  #define HVMASSIST
    9.10  #undef HVMTEST
    9.11  
    9.12 @@ -9409,9 +9411,9 @@ rom_scan_increment:
    9.13  
    9.14  #ifdef HVMASSIST
    9.15  
    9.16 -; Copy the SMBIOS entry point over from 0x9f000, where hvmloader left it.
    9.17 +; Copy the SMBIOS entry point from where hvmloader left it.
    9.18  ; The entry point must be somewhere in 0xf0000-0xfffff on a 16-byte boundary,
    9.19 -; but the tables themeselves can be elsewhere.
    9.20 +; but the tables themselves can be elsewhere.
    9.21  smbios_init:
    9.22    push ax
    9.23    push cx
    9.24 @@ -9424,9 +9426,9 @@ smbios_init:
    9.25    mov ax, #0xf000
    9.26    mov es, ax      ; destination segment is 0xf0000
    9.27    mov di, #smbios_entry_point ; destination offset
    9.28 -  mov ax, #0x9f00
    9.29 -  mov ds, ax      ; source segment is 0x9f000
    9.30 -  mov si, #0x0000 ; source offset is 0
    9.31 +  mov ax, #(SMBIOS_PHYSICAL_ADDRESS>>4)
    9.32 +  mov ds, ax
    9.33 +  mov si, #(SMBIOS_PHYSICAL_ADDRESS&15)
    9.34    cld
    9.35    rep
    9.36      movsb
    10.1 --- a/tools/libxc/xc_hvm_build.c	Thu Apr 26 16:15:08 2007 +0100
    10.2 +++ b/tools/libxc/xc_hvm_build.c	Thu Apr 26 16:45:06 2007 +0100
    10.3 @@ -47,20 +47,15 @@ static void build_e820map(void *e820_pag
    10.4          mem_size = HVM_BELOW_4G_RAM_END;
    10.5      }
    10.6  
    10.7 -    /* 0x0-0x9F000: Ordinary RAM. */
    10.8 +    /* 0x0-0x9FC00: Ordinary RAM. */
    10.9      e820entry[nr_map].addr = 0x0;
   10.10 -    e820entry[nr_map].size = 0x9F000;
   10.11 +    e820entry[nr_map].size = 0x9FC00;
   10.12      e820entry[nr_map].type = E820_RAM;
   10.13      nr_map++;
   10.14  
   10.15 -    /*
   10.16 -     * 0x9F000-0x9F800: SMBIOS tables.
   10.17 -     * 0x9FC00-0xA0000: Extended BIOS Data Area (EBDA).
   10.18 -     * TODO: SMBIOS tables should be moved higher (>=0xE0000).
   10.19 -     *       They are unusually low in our memory map: could cause problems?
   10.20 -     */
   10.21 -    e820entry[nr_map].addr = 0x9F000;
   10.22 -    e820entry[nr_map].size = 0x1000;
   10.23 +    /* 0x9FC00-0xA0000: Extended BIOS Data Area (EBDA). */
   10.24 +    e820entry[nr_map].addr = 0x9FC00;
   10.25 +    e820entry[nr_map].size = 0x400;
   10.26      e820entry[nr_map].type = E820_RESERVED;
   10.27      nr_map++;
   10.28