John Looney has uploaded this change for review.

View Change

Patch an SSDT onto the end of the ACPI tables built for qemu-i440fx, and thus
qemu-q35 also.

This will allow qemu to setup cbmem, and allow VPD variables to be accessible
from operating systems booted by qemu.

This has been tested by booting a qemu-q35 instance from a coreboot image with
a VPD partition defined in the fmap. On booting, /sys/firmware/vpd/ro existed
as it does on real hardware.

A subsequent commit will contain default fmaps for qemu images, which will
include small VPD partitions.

Change-Id: I25e8f7876eb90384220ba95ef547911b92c74dfd
---
M src/mainboard/emulation/qemu-i440fx/Kconfig
M src/mainboard/emulation/qemu-i440fx/fw_cfg.c
M src/mainboard/emulation/qemu-q35/Kconfig
3 files changed, 39 insertions(+), 15 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/43/32143/1
diff --git a/src/mainboard/emulation/qemu-i440fx/Kconfig b/src/mainboard/emulation/qemu-i440fx/Kconfig
index 23526f9..f9577b6 100644
--- a/src/mainboard/emulation/qemu-i440fx/Kconfig
+++ b/src/mainboard/emulation/qemu-i440fx/Kconfig
@@ -46,4 +46,8 @@
hex
default 0x4000

+config FMDFILE
+ string
+ default "src/mainboard/$(CONFIG_MAINBOARD_DIR)/board.fmd"
+
endif # BOARD_EMULATION_QEMU_X86_I440FX
diff --git a/src/mainboard/emulation/qemu-i440fx/fw_cfg.c b/src/mainboard/emulation/qemu-i440fx/fw_cfg.c
index 3acb11e..1ee8b72 100644
--- a/src/mainboard/emulation/qemu-i440fx/fw_cfg.c
+++ b/src/mainboard/emulation/qemu-i440fx/fw_cfg.c
@@ -22,8 +22,8 @@
#include "fw_cfg.h"
#include "fw_cfg_if.h"

-#define FW_CFG_PORT_CTL 0x0510
-#define FW_CFG_PORT_DATA 0x0511
+#define FW_CFG_PORT_CTL 0x0510
+#define FW_CFG_PORT_DATA 0x0511

static int fw_cfg_detected;

@@ -37,7 +37,7 @@
fw_cfg_get(FW_CFG_SIGNATURE, sig, sizeof(sig));
detected = memcmp(sig, qsig, 4) == 0;
printk(BIOS_INFO, "QEMU: firmware config interface %s\n",
- detected ? "detected" : "not found");
+ detected ? "detected" : "not found");
fw_cfg_detected = detected + 1;
}
return fw_cfg_detected - 1;
@@ -97,7 +97,7 @@
}

static int fw_cfg_e820_read(FwCfgE820Entry *entry, uint32_t *size,
- uint32_t *pos)
+ uint32_t *pos)
{
if (*pos + sizeof(*entry) > *size)
return -1;
@@ -209,8 +209,8 @@
typedef struct BiosLinkerLoaderEntry BiosLinkerLoaderEntry;

enum {
- BIOS_LINKER_LOADER_COMMAND_ALLOCATE = 0x1,
- BIOS_LINKER_LOADER_COMMAND_ADD_POINTER = 0x2,
+ BIOS_LINKER_LOADER_COMMAND_ALLOCATE = 0x1,
+ BIOS_LINKER_LOADER_COMMAND_ADD_POINTER = 0x2,
BIOS_LINKER_LOADER_COMMAND_ADD_CHECKSUM = 0x3,
};

@@ -225,6 +225,8 @@
BiosLinkerLoaderEntry *s;
unsigned long *addrs, current;
uint8_t *ptr;
+ acpi_rsdp_t *rsdp = NULL;
+ acpi_header_t *ssdt;
int i, j, src, dst, max;

if (fw_cfg_check_file(&f, "etc/table-loader"))
@@ -251,13 +253,18 @@

printk(BIOS_DEBUG, "QEMU: loading \"%s\" to 0x%lx (len %d)\n",
s[i].alloc.file, current, f.size);
+ if (!strncmp(s[i].alloc.file, "etc/acpi/rsdp", 13)) {
+ printk(BIOS_DEBUG, "Found RSDP at 0x%lx\n", current);
+ rsdp = (acpi_rsdp_t *)current;
+ }
fw_cfg_get(f.select, (void *)current, f.size);
addrs[i] = current;
current += f.size;
break;

case BIOS_LINKER_LOADER_COMMAND_ADD_POINTER:
- src = -1; dst = -1;
+ src = -1;
+ dst = -1;
for (j = 0; j < i; j++) {
if (s[j].command != BIOS_LINKER_LOADER_COMMAND_ALLOCATE)
continue;
@@ -317,11 +324,21 @@

default:
printk(BIOS_DEBUG, "QEMU: acpi: unknown script cmd 0x%x @ %p\n",
- s[i].command, s+i);
+ s[i].command, s + i);
goto err;
};
}

+ if (rsdp) {
+ ssdt = (acpi_header_t *)current;
+ acpi_create_ssdt_generator(ssdt, ACPI_TABLE_CREATOR);
+ if (ssdt->length > sizeof(acpi_header_t)) {
+ current += ssdt->length;
+ acpi_add_table(rsdp, ssdt);
+ current = acpi_align_current(current);
+ }
+ }
+
printk(BIOS_DEBUG, "QEMU: loaded ACPI tables from fw_cfg.\n");
free(s);
free(addrs);
@@ -360,8 +377,7 @@
insb(FW_CFG_PORT_DATA, &entry, sizeof(entry));
buf = malloc(entry.length - sizeof(entry));
insb(FW_CFG_PORT_DATA, buf, entry.length - sizeof(entry));
- if (entry.headertype == SMBIOS_FIELD_ENTRY &&
- entry.tabletype == 1) {
+ if (entry.headertype == SMBIOS_FIELD_ENTRY && entry.tabletype == 1) {
switch (entry.fieldoffset) {
case offsetof(struct smbios_type1, manufacturer):
type1_manufacturer = strdup(buf);
@@ -393,10 +409,10 @@
int l, count = 0;
char *s;

- t0 = (void*)current;
+ t0 = (void *)current;
current += t0->length;
for (;;) {
- s = (void*)current;
+ s = (void *)current;
l = strlen(s);
if (!l)
return current + (count ? 1 : 2);
@@ -435,14 +451,14 @@
* see src/arch/x86/boot/smbios.c), then find type0 table.
*/
for (i = 0; i < 16384; i++) {
- str = (char*)(*current - i);
+ str = (char *)(*current - i);
if (strcmp(str, "coreboot") == 0)
break;
}
if (i == 16384)
return 0;
i += sizeof(struct smbios_type0) - 2;
- t0 = (struct smbios_type0*)(*current - i);
+ t0 = (struct smbios_type0 *)(*current - i);
if (t0->type != SMBIOS_BIOS_INFORMATION || t0->handle != 0)
return 0;
printk(BIOS_DEBUG, "QEMU: coreboot type0 table found at 0x%lx.\n",
@@ -457,7 +473,7 @@
fw_cfg_get(f.select, (void *)start, f.size);
end = start;
do {
- t0 = (struct smbios_type0*)end;
+ t0 = (struct smbios_type0 *)end;
if (t0->type == SMBIOS_END_OF_TABLE)
break;
end = smbios_next(end);
diff --git a/src/mainboard/emulation/qemu-q35/Kconfig b/src/mainboard/emulation/qemu-q35/Kconfig
index 815b93b..0672092 100644
--- a/src/mainboard/emulation/qemu-q35/Kconfig
+++ b/src/mainboard/emulation/qemu-q35/Kconfig
@@ -54,4 +54,8 @@
hex
default 0x4000

+config FMDFILE
+ string
+ default "src/mainboard/$(CONFIG_MAINBOARD_DIR)/board.fmd"
+
endif # BOARD_EMULATION_QEMU_X86_Q35

To view, visit change 32143. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I25e8f7876eb90384220ba95ef547911b92c74dfd
Gerrit-Change-Number: 32143
Gerrit-PatchSet: 1
Gerrit-Owner: John Looney <john.looney@gmail.com>
Gerrit-MessageType: newchange