mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
tools: hvmloader: Refactor MP table setup into struct bios_config
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Keir Fraser <keir@xen.org>
This commit is contained in:
1 parent
9134c2f6cf
commit
575f9fbdfa
5 files changed
+63
-55
No files matched your search
@@ -36,6 +36,7 @@ struct bios_config {
|
||||
void (*e820_setup)(void);
|
||||
|
||||
void (*acpi_build_tables)(unsigned int physical);
|
||||
void (*create_mp_tables)(void);
|
||||
};
|
||||
|
||||
extern struct bios_config rombios_config;
|
||||
@@ -62,11 +63,6 @@ extern unsigned long pci_mem_start, pci_mem_end;
|
||||
#define RESERVED_MEMBASE 0xfc000000
|
||||
#define RESERVED_MEMSIZE 0x01000000
|
||||
|
||||
#define ROMBIOS_BEGIN 0x000F0000
|
||||
#define ROMBIOS_SIZE 0x00010000
|
||||
#define ROMBIOS_MAXOFFSET 0x0000FFFF
|
||||
#define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE)
|
||||
|
||||
#define SCRATCH_PHYSICAL_ADDRESS 0x00010000
|
||||
#define HYPERCALL_PHYSICAL_ADDRESS 0x00080000
|
||||
|
||||
|
||||
@@ -385,8 +385,9 @@ int main(void)
|
||||
if (bios->bios_high_setup)
|
||||
highbios = bios->bios_high_setup();
|
||||
|
||||
if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
|
||||
create_mp_tables();
|
||||
if ( bios->create_mp_tables &&
|
||||
( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) )
|
||||
bios->create_mp_tables();
|
||||
|
||||
switch ( virtual_vga )
|
||||
{
|
||||
|
||||
@@ -259,46 +259,9 @@ static void fill_mpfps(struct mp_floating_pointer_struct *mpfps, uint32_t mpct)
|
||||
mpfps->checksum = -checksum;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* find_mp_table_start - searchs through BIOS memory for '___HVMMP' signature
|
||||
*
|
||||
* The '___HVMMP' signature is created by the ROMBIOS and designates a chunk
|
||||
* of space inside the ROMBIOS that is safe for us to write our MP table info
|
||||
*/
|
||||
static void *get_mp_table_start(void)
|
||||
{
|
||||
char *bios_mem;
|
||||
|
||||
for ( bios_mem = (char *)ROMBIOS_BEGIN;
|
||||
bios_mem != (char *)ROMBIOS_END;
|
||||
bios_mem++ )
|
||||
{
|
||||
if ( strncmp(bios_mem, "___HVMMP", 8) == 0)
|
||||
return bios_mem;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* recalculate the new ROMBIOS checksum after adding MP tables */
|
||||
static void reset_bios_checksum(void)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t checksum;
|
||||
|
||||
checksum = 0;
|
||||
for (i = 0; i < ROMBIOS_MAXOFFSET; ++i)
|
||||
checksum += ((uint8_t *)(ROMBIOS_BEGIN))[i];
|
||||
|
||||
*((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum;
|
||||
}
|
||||
|
||||
/* create_mp_tables - creates MP tables for the guest based upon config data */
|
||||
void create_mp_tables(void)
|
||||
void create_mp_tables(void *mp_table_base)
|
||||
{
|
||||
void *mp_table_base;
|
||||
char *p;
|
||||
int vcpu_nr, i, length;
|
||||
struct mp_io_intr_entry *mpiie;
|
||||
@@ -307,14 +270,6 @@ void create_mp_tables(void)
|
||||
|
||||
printf("Creating MP tables ...\n");
|
||||
|
||||
/* Find the 'safe' place in ROMBIOS for the MP tables. */
|
||||
mp_table_base = get_mp_table_start();
|
||||
if ( mp_table_base == NULL )
|
||||
{
|
||||
printf("Couldn't find start point for MP tables\n");
|
||||
return;
|
||||
}
|
||||
|
||||
p = mp_table_base + sizeof(struct mp_config_table);
|
||||
|
||||
for ( i = 0; i < vcpu_nr; i++ )
|
||||
@@ -363,5 +318,4 @@ void create_mp_tables(void)
|
||||
(uint32_t)mp_table_base);
|
||||
|
||||
fill_mp_config_table((struct mp_config_table *)mp_table_base, length);
|
||||
reset_bios_checksum();
|
||||
}
|
||||
@@ -37,6 +37,11 @@
|
||||
#define ROM_INCLUDE_ROMBIOS
|
||||
#include "roms.inc"
|
||||
|
||||
#define ROMBIOS_BEGIN 0x000F0000
|
||||
#define ROMBIOS_SIZE 0x00010000
|
||||
#define ROMBIOS_MAXOFFSET 0x0000FFFF
|
||||
#define ROMBIOS_END (ROMBIOS_BEGIN + ROMBIOS_SIZE)
|
||||
|
||||
/*
|
||||
* Set up an empty TSS area for virtual 8086 mode to use.
|
||||
* The only important thing is that it musn't have any bits set
|
||||
@@ -303,6 +308,57 @@ static void rombios_pci_setup(void)
|
||||
pci_writew(devfn, PCI_COMMAND, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* find_mp_table_start - searchs through BIOS memory for '___HVMMP' signature
|
||||
*
|
||||
* The '___HVMMP' signature is created by the ROMBIOS and designates a chunk
|
||||
* of space inside the ROMBIOS that is safe for us to write our MP table info
|
||||
*/
|
||||
static void *get_mp_table_start(void)
|
||||
{
|
||||
char *bios_mem;
|
||||
|
||||
for ( bios_mem = (char *)ROMBIOS_BEGIN;
|
||||
bios_mem != (char *)ROMBIOS_END;
|
||||
bios_mem++ )
|
||||
{
|
||||
if ( strncmp(bios_mem, "___HVMMP", 8) == 0)
|
||||
return bios_mem;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* recalculate the new ROMBIOS checksum after adding MP tables */
|
||||
static void reset_bios_checksum(void)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t checksum;
|
||||
|
||||
checksum = 0;
|
||||
for (i = 0; i < ROMBIOS_MAXOFFSET; ++i)
|
||||
checksum += ((uint8_t *)(ROMBIOS_BEGIN))[i];
|
||||
|
||||
*((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum;
|
||||
}
|
||||
|
||||
static void rombios_create_mp_tables(void)
|
||||
{
|
||||
/* Find the 'safe' place in ROMBIOS for the MP tables. */
|
||||
void *table = get_mp_table_start();
|
||||
|
||||
if ( table == NULL )
|
||||
{
|
||||
printf("Couldn't find start point for MP tables\n");
|
||||
return;
|
||||
}
|
||||
|
||||
create_mp_tables(table);
|
||||
|
||||
reset_bios_checksum();
|
||||
}
|
||||
|
||||
//BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS));
|
||||
|
||||
struct bios_config rombios_config = {
|
||||
@@ -332,6 +388,7 @@ struct bios_config rombios_config = {
|
||||
.e820_setup = rombios_setup_e820,
|
||||
|
||||
.acpi_build_tables = acpi_build_tables,
|
||||
.create_mp_tables = rombios_create_mp_tables,
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -185,7 +185,7 @@ uint32_t rombios_highbios_setup(void);
|
||||
|
||||
/* Miscellaneous. */
|
||||
void cacheattr_init(void);
|
||||
void create_mp_tables(void);
|
||||
void create_mp_tables(void *table);
|
||||
int hvm_write_smbios_tables(unsigned long scratch,
|
||||
unsigned long smbios_start,
|
||||
unsigned long smbios_end);
|
||||
|
||||