This patch allows loading ACPI DSDT from qemu via fw_cfg interface. So this patch makes it easy for users to replace existing DSDT embed in seabios binary.
Isaku Yamahata (2): util: add le32_to_cpu() seabios: acpi: allow qemu to load dsdt as external acpi table.
src/acpi.c | 47 +++++++++++++++++++++++++++++++++++++++-------- src/util.h | 5 +++++ 2 files changed, 44 insertions(+), 8 deletions(-)
this will be used later.
Signed-off-by: Isaku Yamahata yamahata@valinux.co.jp --- src/util.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/util.h b/src/util.h index 174e94b..eecba8b 100644 --- a/src/util.h +++ b/src/util.h @@ -129,6 +129,11 @@ static inline u32 cpu_to_le32(u32 x) return x; }
+static inline u32 le32_to_cpu(u32 x) +{ + return x; +} + static inline u32 getesp(void) { u32 esp; asm("movl %%esp, %0" : "=rm"(esp));
allow qemu to load dsdt as external acpi table.
Signed-off-by: Isaku Yamahata yamahata@valinux.co.jp
--- changes v2 -> v3. - typo. - check if fadt->dsdt is NULL. dsdt might be passed from qemu many times. Check it.
changes v1 -> v2. - load qemu table first and they try default dsdt table if qemu doesn't supply dsdt. Thus unnecessary malloc_high()/free() is avoided. --- src/acpi.c | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/src/acpi.c b/src/acpi.c index 27a939e..8d8618e 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -53,6 +53,11 @@ struct facs_descriptor_rev1
/* + * Differentiated System Description Table (DSDT) + */ +#define DSDT_SIGNATURE 0x54445344 // DSDT + +/* * MADT values and structures */
@@ -236,14 +241,23 @@ static const struct pci_device_id fadt_init_tbl[] = { PCI_DEVICE_END };
+static void fill_dsdt(struct fadt_descriptor_rev1 *fadt, void *dsdt) +{ + if (fadt->dsdt) { + free((void *)le32_to_cpu(fadt->dsdt)); + } + fadt->dsdt = cpu_to_le32((u32)dsdt); + fadt->checksum -= checksum(fadt, sizeof(*fadt)); + dprintf(1, "ACPI DSDT=%p\n", dsdt); +} + static void * build_fadt(struct pci_device *pci) { struct fadt_descriptor_rev1 *fadt = malloc_high(sizeof(*fadt)); struct facs_descriptor_rev1 *facs = memalign_high(64, sizeof(*facs)); - void *dsdt = malloc_high(sizeof(AmlCode));
- if (!fadt || !facs || !dsdt) { + if (!fadt || !facs) { warn_noalloc(); return NULL; } @@ -253,13 +267,11 @@ build_fadt(struct pci_device *pci) facs->signature = FACS_SIGNATURE; facs->length = cpu_to_le32(sizeof(*facs));
- /* DSDT */ - memcpy(dsdt, AmlCode, sizeof(AmlCode)); - /* FADT */ memset(fadt, 0, sizeof(*fadt)); fadt->firmware_ctrl = cpu_to_le32((u32)facs); - fadt->dsdt = cpu_to_le32((u32)dsdt); + fadt->dsdt = 0; /* dsdt will be filled later in acpi_bios_init() + by fill_dsdt() */ fadt->model = 1; fadt->reserved1 = 0; int pm_sci_int = pci_config_readb(pci->bdf, PCI_INTERRUPT_LINE); @@ -630,7 +642,8 @@ acpi_bios_init(void) tbl_idx++; \ } while(0)
- ACPI_INIT_TABLE(build_fadt(pci)); + struct fadt_descriptor_rev1 *fadt = build_fadt(pci); + ACPI_INIT_TABLE(fadt); ACPI_INIT_TABLE(build_ssdt()); ACPI_INIT_TABLE(build_madt()); ACPI_INIT_TABLE(build_hpet()); @@ -645,12 +658,30 @@ acpi_bios_init(void) warn_noalloc(); continue; } - ACPI_INIT_TABLE(qemu_cfg_next_acpi_table_load(addr, len)); + struct acpi_table_header *header = + qemu_cfg_next_acpi_table_load(addr, len); + if (header->signature == DSDT_SIGNATURE) { + if (fadt) { + fill_dsdt(fadt, addr); + } + } else { + ACPI_INIT_TABLE(header); + } if (tbl_idx == MAX_ACPI_TABLES) { warn_noalloc(); break; } } + if (fadt && !fadt->dsdt) { + /* default DSDT */ + void *dsdt = malloc_high(sizeof(AmlCode)); + if (!dsdt) { + warn_noalloc(); + return; + } + memcpy(dsdt, AmlCode, sizeof(AmlCode)); + fill_dsdt(fadt, dsdt); + }
// Build final rsdt table struct rsdt_descriptor_rev1 *rsdt;
On Mon, Oct 24, 2011 at 05:11:06PM +0900, Isaku Yamahata wrote:
This patch allows loading ACPI DSDT from qemu via fw_cfg interface. So this patch makes it easy for users to replace existing DSDT embed in seabios binary.
It looks okay to me.
-Kevin
On Mon, Oct 24, 2011 at 05:11:06PM +0900, Isaku Yamahata wrote:
This patch allows loading ACPI DSDT from qemu via fw_cfg interface. So this patch makes it easy for users to replace existing DSDT embed in seabios binary.
Thanks - I applied these patches.
-Kevin