seabios: load acpi tables from qemu
v2 cover seabios: load acpi tables from qemu
This is the seabios code that adds support for loading acpi tables from QEMU: it's working fine here and in fact, I am able to get exactly same tables with builtin tables and with tables coming from qemu.
Changes from v1:
- simplified linker interfaces along the lines suggested by Kevin
- fixed lots of bugs
Michael S. Tsirkin (5):
linker: utility to patch in-memory ROM files
pmm: add a way to test whether memory is in FSEG
acpi: pack rsdp
acpi: load and link tables from /etc/acpi/
acpi: add an option to disable builtin tables
Makefile | 2 +- src/Kconfig | 12 +++++- src/acpi.c | 39 +++++++++++++++++ src/acpi.h | 2 +- src/linker.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/linker.h | 72 +++++++++++++++++++++++++++++++ src/paravirt.c | 2 + src/pmm.c | 24 ++++++++--- src/util.h | 2 + 9 files changed, 278 insertions(+), 9 deletions(-) create mode 100644 src/linker.c create mode 100644 src/linker.h
Signature · 1 line
MST
PATCH v2 1/5 linker: utility to patch in-memory ROM files
Add ability for a ROM file to point to it's image in memory. When file is in memory, add utility that can patch it, storing pointers to one file within another file.
This is not a lot of code: together with the follow-up patch to load ACPI tables from ROM, we get:
Before:
Total size: 127880 Fixed: 59060 Free: 3192 (used 97.6% of 128KiB rom) After:
Total size: 128776 Fixed: 59100 Free: 2296 (used 98.2% of 128KiB rom)
--- Makefile | 2 +- src/linker.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/linker.h | 72 +++++++++++++++++++++++++++++++ src/paravirt.c | 2 + src/util.h | 1 + 5 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 src/linker.c create mode 100644 src/linker.h
Makefile +1 -1
@@ -18,7 +18,7 @@ SRC16=$(SRCBOTH) system.c disk.c font.c SRC32FLAT=$(SRCBOTH) post.c shadow.c memmap.c pmm.c coreboot.c boot.c \ acpi.c smm.c mptable.c pirtable.c smbios.c pciinit.c optionroms.c mtrr.c \ lzmadecode.c bootsplash.c jpeg.c usb-hub.c paravirt.c \ - biostables.c xen.c bmp.c romfile.c csm.c + biostables.c xen.c bmp.c romfile.c csm.c linker.c SRC32SEG=util.c output.c pci.c pcibios.c apm.c stacks.c # Default compiler flags
src/linker.c new file +132 -0
132 lines not on this page · raw message
src/linker.h new file +72 -0
72 lines not on this page · raw message
src/paravirt.c +2 -0
@@ -327,6 +327,8 @@ void qemu_cfg_init(void)for (e =0 ; e < count; e++) {struct QemuCfgFile qfile;qemu_cfg_read (&qfile,sizeof (qfile)); +if (!*qfile.name) +return ;qemu_romfile_add (qfile.name,be16_to_cpu (qfile.select) ,0 ,be32_to_cpu (qfile.size)); }
src/util.h +1 -0
@@ -436,6 +436,7 @@ struct romfile_s {char name[128 ];u32 size;int (*copy)(struct romfile_s *file,void *dest,u32 maxlen); +void *data; };void romfile_add (struct romfile_s *file);struct romfile_s *romfile_findprefix (const char *prefix,struct romfile_s *prev);
Signature · 1 line
MST
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 1/5] linker: utility to patch in-memory ROM files
Quoted 4 lines · Michael S. Tsirkin
Add ability for a ROM file to point to it's image in memory. When file is in memory, add utility that can patch it, storing pointers to one file within another file.
Thanks. See my comments below.
[...]
Quoted 2 lines
src/linker.c new file +0
-0
[...]
src/linker.c line 109
Quoted 9 lines
src/linker.c new file +9
-0+void linker_loader_execute (const char *name) +{ +struct linker_loader_entry_s *entry; +int size, offset =0 ; +void *data =romfile_loadfile (name, &size); +if (!data) +return ; + +for (offset =0 ; offset < size; offset +=sizeof *entry) {
For consistent style, please treat sizeof like a function (ie, sizeof(*entry) ).
src/linker.c line 118
Quoted 9 lines
src/linker.c new file +9
-0+ entry = data + offset; +/* Check that entry fits in buffer. */ +if (offset +sizeof *entry > size) { +warn_internalerror (); +break ; + } +switch (le32_to_cpu (entry->command)) { +case LINKER_LOADER_COMMAND_ALLOCATE : +linker_loader_allocate (entry);
SeaBIOS uses 4 spaces for indentation, and no tabs.
[...]
src/util.h struct romfile_s { · line 440
Quoted 8 lines
src/util.h +1
-0@@ -436,6 +436,7 @@ struct romfile_s {char name[128 ];u32 size;int (*copy)(struct romfile_s *file,void *dest,u32 maxlen); +void *data; };
I'd prefer to see this tracked within the "linker" code and not in the generic romfile struct.
Also, is there another name besides "linker" that could be used? SeaBIOS has code to self-relocate and fixup code relocations. I think having code in the repo called "linker" could cause confusion.
-Kevin
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 1/5] linker: utility to patch in-memory ROM files
Quoted 38 lines · Kevin O'Connor
Quoted 4 lines · Michael S. Tsirkin
Add ability for a ROM file to point to it's image in memory. When file is in memory, add utility that can patch it, storing pointers to one file within another file.
Thanks. See my comments below.
[...]
Quoted 2 lines
src/linker.c new file +0
-0[...]
src/linker.c line 109
Quoted 9 lines
src/linker.c new file +9
-0+void linker_loader_execute (const char *name) +{ +struct linker_loader_entry_s *entry; +int size, offset =0 ; +void *data =romfile_loadfile (name, &size); +if (!data) +return ; + +for (offset =0 ; offset < size; offset +=sizeof *entry) {For consistent style, please treat sizeof like a function (ie,
sizeof(*entry)).src/linker.c line 118
Quoted 9 lines
src/linker.c new file +9
-0+ entry = data + offset; +/* Check that entry fits in buffer. */ +if (offset +sizeof *entry > size) { +warn_internalerror (); +break ; + } +switch (le32_to_cpu (entry->command)) { +case LINKER_LOADER_COMMAND_ALLOCATE : +linker_loader_allocate (entry);SeaBIOS uses 4 spaces for indentation, and no tabs.
[...]
Quoted 11 lines
src/util.h struct romfile_s { · line 440
Quoted 8 lines
src/util.h +1
-0@@ -436,6 +436,7 @@ struct romfile_s {char name[128 ];u32 size;int (*copy)(struct romfile_s *file,void *dest,u32 maxlen); +void *data; };I'd prefer to see this tracked within the "linker" code and not in the generic romfile struct.
A way to associate a romfile instance with a value seems generally useful, no? Still, that's not too hard - it would only mean an extra linked list of
struct linker {
char name[56]
void *data;
struct hlist_node node;
}is this preferable?
Quoted 5 lines
Also, is there another name besides "linker" that could be used? SeaBIOS has code to self-relocate and fixup code relocations. I think having code in the repo called "linker" could cause confusion.
-Kevin
romfile_loader?
Signature · 1 line
MST
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 1/5] linker: utility to patch in-memory ROM files
Quoted 63 lines · Michael S. Tsirkin
Quoted 38 lines · Kevin O'Connor
Quoted 4 lines · Michael S. Tsirkin
Add ability for a ROM file to point to it's image in memory. When file is in memory, add utility that can patch it, storing pointers to one file within another file.
Thanks. See my comments below.
[...]
Quoted 2 lines
src/linker.c new file +0
-0[...]
src/linker.c line 109
Quoted 9 lines
src/linker.c new file +9
-0+void linker_loader_execute (const char *name) +{ +struct linker_loader_entry_s *entry; +int size, offset =0 ; +void *data =romfile_loadfile (name, &size); +if (!data) +return ; + +for (offset =0 ; offset < size; offset +=sizeof *entry) {For consistent style, please treat sizeof like a function (ie,
sizeof(*entry)).src/linker.c line 118
Quoted 9 lines
src/linker.c new file +9
-0+ entry = data + offset; +/* Check that entry fits in buffer. */ +if (offset +sizeof *entry > size) { +warn_internalerror (); +break ; + } +switch (le32_to_cpu (entry->command)) { +case LINKER_LOADER_COMMAND_ALLOCATE : +linker_loader_allocate (entry);SeaBIOS uses 4 spaces for indentation, and no tabs.
[...]
Quoted 11 lines
src/util.h struct romfile_s { · line 440
Quoted 8 lines
src/util.h +1
-0@@ -436,6 +436,7 @@ struct romfile_s {char name[128 ];u32 size;int (*copy)(struct romfile_s *file,void *dest,u32 maxlen); +void *data; };I'd prefer to see this tracked within the "linker" code and not in the generic romfile struct.
A way to associate a romfile instance with a value seems generally useful, no? Still, that's not too hard - it would only mean an extra linked list of
struct linker { char name[56] void *data; struct hlist_node node; }is this preferable?
Quoted 7 lines
Quoted 5 lines
Also, is there another name besides "linker" that could be used? SeaBIOS has code to self-relocate and fixup code relocations. I think having code in the repo called "linker" could cause confusion.
-Kevin
romfile_loader?
Could you respond on above please?
Quoted 2 lines
Signature · 1 line
MST
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 1/5] linker: utility to patch in-memory ROM files
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Michael S. Tsirkin
Quoted 2 lines · Kevin O'Connor
I'd prefer to see this tracked within the "linker" code and not in the generic romfile struct.
A way to associate a romfile instance with a value seems generally useful, no? Still, that's not too hard - it would only mean an extra linked list of
Quoted 7 lines
Quoted 7 lines
struct linker { char name[56] void *data; struct hlist_node node; }is this preferable?
Sure, but it's probably easier to do something like:
struct linkfiles { char *name; void *data; };
void linker_loader_execute(const char *name)
{
int size;
struct linker_loader_entry_s *entries = romfile_loadfile(name, &size);
int numentries = size/sizeof(entries[0]);
if (! entries)
return;
struct linkfiles *files = malloc_tmp(sizeof(files[0]) * numentries);and then just populate and use the array of filenames.
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Also, is there another name besides "linker" that could be used? SeaBIOS has code to self-relocate and fixup code relocations. I think having code in the repo called "linker" could cause confusion.
romfile_loader?
Shrug. How about "tabledeploy"?
-Kevin
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 1/5] linker: utility to patch in-memory ROM files
Quoted 31 lines · Kevin O'Connor
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Michael S. Tsirkin
Quoted 2 lines · Kevin O'Connor
I'd prefer to see this tracked within the "linker" code and not in the generic romfile struct.
A way to associate a romfile instance with a value seems generally useful, no? Still, that's not too hard - it would only mean an extra linked list of
Quoted 7 lines
Quoted 7 lines
struct linker { char name[56] void *data; struct hlist_node node; }is this preferable?
Sure, but it's probably easier to do something like:
struct linkfiles { char *name; void *data; };
void
linker_loader_execute(const char *name){ int size; struct linker_loader_entry_s *entries = romfile_loadfile(name, &size); int numentries = size/sizeof(entries[0]); if (! entries) return; struct linkfiles *files = malloc_tmp(sizeof(files[0]) * numentries);
Quoted 1 line
and then just populate and use the array of filenames.
OK I'll do this but it's more code as I can't use plain romfile_find anymore, and have to code up my own lookup.
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Also, is there another name besides "linker" that could be used? SeaBIOS has code to self-relocate and fixup code relocations. I think having code in the repo called "linker" could cause confusion.
romfile_loader?Shrug. How about "tabledeploy"?
-Kevin
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 1/5] linker: utility to patch in-memory ROM files
Quoted 32 lines · Michael S. Tsirkin
Quoted 31 lines · Kevin O'Connor
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Michael S. Tsirkin
Quoted 2 lines · Kevin O'Connor
I'd prefer to see this tracked within the "linker" code and not in the generic romfile struct.
A way to associate a romfile instance with a value seems generally useful, no? Still, that's not too hard - it would only mean an extra linked list of
Quoted 7 lines
Quoted 7 lines
struct linker { char name[56] void *data; struct hlist_node node; }is this preferable?
Sure, but it's probably easier to do something like:
struct linkfiles { char *name; void *data; };
void
linker_loader_execute(const char *name){ int size; struct linker_loader_entry_s *entries = romfile_loadfile(name, &size); int numentries = size/sizeof(entries[0]); if (! entries) return; struct linkfiles *files = malloc_tmp(sizeof(files[0]) * numentries);
Quoted 15 lines
Quoted 1 line
and then just populate and use the array of filenames.
OK I'll do this but it's more code as I can't use plain
romfile_findanymore, and have to code up my own lookup.Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Also, is there another name besides "linker" that could be used? SeaBIOS has code to self-relocate and fixup code relocations. I think having code in the repo called "linker" could cause confusion.
romfile_loader?Shrug. How about "tabledeploy"?
-Kevin
So I tried this out, and I don't like this much:
see below.
Lots of code, a single data pointer in file struct seems much easier.
Further, without a pointer from file to data, there's no way to find the tables in memory,
so I will have to make the loader interface ACPI-specific, make it look into tables loaded for the RSDP signature and return the address of RSDP.
src/util.h +0 -1
@@ -441,7 +441,6 @@ struct romfile_s {char name[128 ];u32 size;int (*copy)(struct romfile_s *file,void *dest,u32 maxlen); -void *data; };void romfile_add (struct romfile_s *file);struct romfile_s *romfile_findprefix (const char *prefix,struct romfile_s *prev);
src/acpi.c +3 -3
@@ -611,14 +611,14 @@ acpi_find_rsdp_rom(void)if (!file)break ; -if (!file->data || !pmm_test_fseg (file->data) || +if (/*!file->data ||*/ !pmm_test_fseg (NULL /*file->data*/ ) || file->size <sizeof (rsdp->signature))continue ;void *data; -for (data = file->data; - data +sizeof (*rsdp) <= file->data + file->size; +for (data =NULL /*file->data */ ; + data +sizeof (*rsdp) <=/* file->data */ NULL + file->size; data++) { rsdp = data;if (rsdp->signature ==cpu_to_le64 (RSDP_SIGNATURE ))
src/romfile_loader.c +62 -23
163 lines not on this page · raw message
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 1/5] linker: utility to patch in-memory ROM files
Quoted 43 lines · Michael S. Tsirkin
Quoted 42 lines · Michael S. Tsirkin
Quoted 31 lines · Kevin O'Connor
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Michael S. Tsirkin
Quoted 2 lines · Kevin O'Connor
I'd prefer to see this tracked within the "linker" code and not in the generic romfile struct.
A way to associate a romfile instance with a value seems generally useful, no? Still, that's not too hard - it would only mean an extra linked list of
Quoted 7 lines
Quoted 7 lines
struct linker { char name[56] void *data; struct hlist_node node; }is this preferable?
Sure, but it's probably easier to do something like:
struct linkfiles { char *name; void *data; };
void
linker_loader_execute(const char *name){ int size; struct linker_loader_entry_s *entries = romfile_loadfile(name, &size); int numentries = size/sizeof(entries[0]); if (! entries) return; struct linkfiles *files = malloc_tmp(sizeof(files[0]) * numentries);Quoted 1 line
and then just populate and use the array of filenames.
OK I'll do this but it's more code as I can't use plain
romfile_findanymore, and have to code up my own lookup.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Also, is there another name besides "linker" that could be used? SeaBIOS has code to self-relocate and fixup code relocations. I think having code in the repo called "linker" could cause confusion.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
romfile_loader?Shrug. How about "tabledeploy"?
-Kevin
So I tried this out
Latest version that I posted uses the approach suggested by Kevin here. It adds about 200 bytes to code size.
If we want to cut that out and go back to data pointer,
we can do this as a patch on top.
Pls let me know.
Signature · 1 line
MST
PATCH v2 2/5 pmm: add a way to test whether memory is in FSEG
In reply to Michael S. TsirkinWill be handy for looking for RSDP.
--- src/pmm.c | 24 ++++++++++++++++++------ src/util.h | 1 + 2 files changed, 19 insertions(+), 6 deletions(-)
src/pmm.c +18 -6
@@ -120,15 +120,23 @@ addSpace(struct zone_s *zone, void *start, void *end)// Search all zones for an allocation obtained from allocSpace() static struct allocinfo_s * +findAllocInZone (struct zone_s *zone,void *data) +{ +struct allocinfo_s *info; +hlist_for_each_entry (info, &zone->head, node) +if (info->data == data) +return info; +return NULL ; +} + +static struct allocinfo_s *findAlloc (void *data) {int i; -for (i=0 ; i<ARRAY_SIZE (Zones); i++) { -struct allocinfo_s *info; -hlist_for_each_entry (info, &Zones[i]->head, node) { -if (info->data == data) -return info; - } +for (i =0 ; i <ARRAY_SIZE (Zones); i++) { +struct allocinfo_s *info =findAllocInZone (Zones[i], data); +if (info) +return info; }return NULL ; }
@@ -241,6 +249,10 @@ pmm_find(u32 handle)return NULL ; } +int pmm_test_fseg (void *data) +{ +return !!findAllocInZone (&ZoneFSeg, data); +}/**************************************************************** * 0xc0000-0xf0000 management
src/util.h +1 -0
@@ -378,6 +378,7 @@ void malloc_init(void);void malloc_prepboot (void );void *pmm_malloc (struct zone_s *zone,u32 handle,u32 size,u32 align);int pmm_free (void *data); +int pmm_test_fseg (void *data);void pmm_init (void );void pmm_prepboot (void );#define PMM_DEFAULT_HANDLE 0xFFFFFFFF
Signature · 1 line
MST
PATCH v2 3/5 acpi: pack rsdp
In reply to Michael S. Tsirkinrsdp might not be aligned, so mark it packed.
--- src/acpi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/acpi.h +1 -1
@@ -47,7 +47,7 @@ struct rsdp_descriptor { /* Root System Descriptor Pointer */u64 xsdt_physical_address;/* 64-bit physical address of XSDT */ u8 extended_checksum;/* Checksum of entire table */ u8 reserved [3 ];/* Reserved field must be 0 */ -}; +}PACKED ;extern struct rsdp_descriptor *RsdpAddr;
Signature · 1 line
MST
PATCH v2 4/5 acpi: load and link tables from /etc/acpi/
In reply to Michael S. TsirkinLoad files in /etc/acpi/, link them using
a linker script and use for acpi tables, including the RSDP. Presense of RSDP in this directory completely disables generating and loading legacy acpi tables.
--- src/acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
src/acpi.c +39 -0
@@ -27,6 +27,7 @@#include "config.h" // CONFIG_* #include "paravirt.h" // RamSize #include "dev-q35.h" +#include "linker.h" #include "acpi-dsdt.hex"
@@ -599,6 +600,34 @@ static const struct pci_device_id acpi_find_tbl[] = {struct rsdp_descriptor *RsdpAddr; +/* Look for RSDP signature in files loaded in FSEG */ +struct rsdp_descriptor * +acpi_find_rsdp_rom (void ) +{ +struct romfile_s *file =NULL ; +struct rsdp_descriptor *rsdp =NULL ; +for (;;) { + file =romfile_findprefix ("" , file); +if (!file) +break ; + +if (!file->data || !pmm_test_fseg (file->data) || + file->size <sizeof (rsdp->signature)) +continue ; + +void *data; + +for (data = file->data; + data +sizeof (*rsdp) <= file->data + file->size; + data++) { + rsdp = data; +if (rsdp->signature ==cpu_to_le64 (RSDP_SIGNATURE )) +return rsdp; + } + } +return NULL ; +} +#define MAX_ACPI_TABLES 20void acpi_setup (void )
@@ -608,6 +637,16 @@ acpi_setup(void)dprintf (3 ,"init ACPI tables\n" ); +linker_loader_execute ("/etc/linker-script" ); + + RsdpAddr =acpi_find_rsdp_rom (); + +if (RsdpAddr) { +return ; + } + +dprintf (3 ,"generate ACPI tables\n" ); +// This code is hardcoded for PIIX4 Power Management device. struct pci_device *pci =pci_find_init_device (acpi_find_tbl,NULL );if (!pci)
Signature · 1 line
MST
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 4/5] acpi: load and link tables from /etc/acpi/
Quoted 58 lines · Michael S. Tsirkin
Load files in
/etc/acpi/, link them using
a linker script and use for acpi tables, including the RSDP. Presense of RSDP in this directory completely disables generating and loading legacy acpi tables.Signed-off-by Michael S. Tsirkin <[email protected]>--- src/acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)src/acpi.c +29
-0@@ -27,6 +27,7 @@#include "config.h" // CONFIG_* #include "paravirt.h" // RamSize #include "dev-q35.h" +#include "linker.h" #include "acpi-dsdt.hex" @@ -599,6 +600,34 @@ static const struct pci_device_id acpi_find_tbl[] = {struct rsdp_descriptor *RsdpAddr; +/* Look for RSDP signature in files loaded in FSEG */ +struct rsdp_descriptor * +acpi_find_rsdp_rom (void ) +{ +struct romfile_s *file =NULL ; +struct rsdp_descriptor *rsdp =NULL ; +for (;;) { + file =romfile_findprefix ("" , file); +if (!file) +break ; + +if (!file->data || !pmm_test_fseg (file->data) || + file->size <sizeof (rsdp->signature)) +continue ; + +void *data; + +for (data = file->data; + data +sizeof (*rsdp) <= file->data + file->size; + data++) { + rsdp = data; +if (rsdp->signature ==cpu_to_le64 (RSDP_SIGNATURE )) +return rsdp; + } + } +return NULL ; +} +#define MAX_ACPI_TABLES 20void acpi_setup (void )
src/acpi.c acpi_setup(void) · line 646
Quoted 10 lines
src/acpi.c +7
-0@@ -608,6 +637,16 @@ acpi_setup(void)dprintf (3 ,"init ACPI tables\n" ); +linker_loader_execute ("/etc/linker-script" ); + + RsdpAddr =acpi_find_rsdp_rom (); + +if (RsdpAddr) { +return ; + }
I don't understand this. Why not use the presence of "/etc/linker-script" to determine if ACPI should be produced.
Also, /etc/linker-script is not very informative - how about something like "/etc/biostables".
-Kevin
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 4/5] acpi: load and link tables from /etc/acpi/
Quoted 62 lines · Kevin O'Connor
Quoted 61 lines · Michael S. Tsirkin
Load files in
/etc/acpi/, link them using
a linker script and use for acpi tables, including the RSDP. Presense of RSDP in this directory completely disables generating and loading legacy acpi tables.Signed-off-by Michael S. Tsirkin <[email protected]>--- src/acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)src/acpi.c +29
-0@@ -27,6 +27,7 @@#include "config.h" // CONFIG_* #include "paravirt.h" // RamSize #include "dev-q35.h" +#include "linker.h" #include "acpi-dsdt.hex" @@ -599,6 +600,34 @@ static const struct pci_device_id acpi_find_tbl[] = {struct rsdp_descriptor *RsdpAddr; +/* Look for RSDP signature in files loaded in FSEG */ +struct rsdp_descriptor * +acpi_find_rsdp_rom (void ) +{ +struct romfile_s *file =NULL ; +struct rsdp_descriptor *rsdp =NULL ; +for (;;) { + file =romfile_findprefix ("" , file); +if (!file) +break ; + +if (!file->data || !pmm_test_fseg (file->data) || + file->size <sizeof (rsdp->signature)) +continue ; + +void *data; + +for (data = file->data; + data +sizeof (*rsdp) <= file->data + file->size; + data++) { + rsdp = data; +if (rsdp->signature ==cpu_to_le64 (RSDP_SIGNATURE )) +return rsdp; + } + } +return NULL ; +} +#define MAX_ACPI_TABLES 20void acpi_setup (void )@@ -608,6 +637,16 @@ acpi_setup(void)dprintf (3 ,"init ACPI tables\n" );
Quoted 10 lines
src/acpi.c acpi_setup(void) · line 646
Quoted 7 lines
src/acpi.c +7
-0+linker_loader_execute ("/etc/linker-script" ); + + RsdpAddr =acpi_find_rsdp_rom (); + +if (RsdpAddr) { +return ; + }I don't understand this. Why not use the presence of "
/etc/linker-script" to determine if ACPI should be produced.
We can do this but what do we do if linker script is there but no rsdp?
Maybe just add
test -e /etc/linker-script != RsdpAddr dprintf(1, "linker script found but no rsdp. Falling back on builtin tables\n");
Would this address your comment?
Quoted 4 lines
Also,
/etc/linker-scriptis not very informative - how about something like "/etc/biostables".-Kevin
Hmm bios seems redundant, and tables makes one think it's the tables themselves.
"/etc/acpi-linker"
"/etc/acpi-loader"?
Signature · 1 line
MST
Re: [Qemu-devel] [SeaBIOS] [PATCH v2 4/5] acpi: load and link tables from /etc/acpi/
Quoted 74 lines · Michael S. Tsirkin
Quoted 62 lines · Kevin O'Connor
Quoted 61 lines · Michael S. Tsirkin
Load files in
/etc/acpi/, link them using
a linker script and use for acpi tables, including the RSDP. Presense of RSDP in this directory completely disables generating and loading legacy acpi tables.Signed-off-by Michael S. Tsirkin <[email protected]>--- src/acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)src/acpi.c +29
-0@@ -27,6 +27,7 @@#include "config.h" // CONFIG_* #include "paravirt.h" // RamSize #include "dev-q35.h" +#include "linker.h" #include "acpi-dsdt.hex" @@ -599,6 +600,34 @@ static const struct pci_device_id acpi_find_tbl[] = {struct rsdp_descriptor *RsdpAddr; +/* Look for RSDP signature in files loaded in FSEG */ +struct rsdp_descriptor * +acpi_find_rsdp_rom (void ) +{ +struct romfile_s *file =NULL ; +struct rsdp_descriptor *rsdp =NULL ; +for (;;) { + file =romfile_findprefix ("" , file); +if (!file) +break ; + +if (!file->data || !pmm_test_fseg (file->data) || + file->size <sizeof (rsdp->signature)) +continue ; + +void *data; + +for (data = file->data; + data +sizeof (*rsdp) <= file->data + file->size; + data++) { + rsdp = data; +if (rsdp->signature ==cpu_to_le64 (RSDP_SIGNATURE )) +return rsdp; + } + } +return NULL ; +} +#define MAX_ACPI_TABLES 20void acpi_setup (void )@@ -608,6 +637,16 @@ acpi_setup(void)dprintf (3 ,"init ACPI tables\n" );Quoted 10 lines
src/acpi.c acpi_setup(void) · line 646
Quoted 7 lines
src/acpi.c +7
-0+linker_loader_execute ("/etc/linker-script" ); + + RsdpAddr =acpi_find_rsdp_rom (); + +if (RsdpAddr) { +return ; + }I don't understand this. Why not use the presence of "
/etc/linker-script" to determine if ACPI should be produced.
Quoted 8 lines
We can do this but what do we do if linker script is there but no rsdp?
Maybe just addtest -e /etc/linker-script != RsdpAddr dprintf(1, "linker script found but no rsdp. Falling back on builtin tables\n");Would this address your comment?
And just to clarify, in my eyes it's preferable to use acpi_find_rsdp_rom which is based on ACPI standard than look for a specific PV interface.
For example, one can imagine a hypervisor that maps ACPI tables directly into guest memory. Looking for rsdp in fseg memory will work, relying on the linker won't.
Quoted 14 lines
Quoted 4 lines
Also,
/etc/linker-scriptis not very informative - how about something like "/etc/biostables".-Kevin
Hmm bios seems redundant, and tables makes one think it's the tables themselves.
"
/etc/acpi-linker"
"/etc/acpi-loader"?Signature · 1 line
MST
PATCH v2 5/5 acpi: add an option to disable builtin tables
In reply to Michael S. TsirkinServes to save a bit of memory, and is helpful for debugging (making sure tables come from qemu).
Memory stats:
Enabled:
Total size: 128776 Fixed: 59100 Free: 2296 (used 98.2% of 128KiB rom) Disabled:
Total size: 119836 Fixed: 58996 Free: 11236 (used 91.4% of 128KiB rom)
--- src/Kconfig | 12 +++++++++++- src/acpi.c | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-)
src/Kconfig +11 -1
@@ -387,10 +387,20 @@ menu "BIOS Tables" default y help Support generation of ACPI tables. + config ACPI_BUILTIN + bool "Include built-in ACPI tables" + default y + depends on ACPI + help + Include built-in ACPI tables in BIOS. + Required for QEMU 1.5 and older. + This option can be disabled for QEMU 1.6 and newer + to save some space in the ROM file. + If unsure, say Y. config ACPI_DSDT bool "Include default ACPI DSDT" default y - depends on ACPI + depends on ACPI && ACPI_BUILTIN help Include default DSDT ACPI table in BIOS. Required for QEMU 1.3 and older.
src/acpi.c +1 -1
@@ -641,7 +641,7 @@ acpi_setup(void) RsdpAddr =acpi_find_rsdp_rom (); -if (RsdpAddr) { +if (!CONFIG_ACPI_BUILTIN || RsdpAddr) {return ; }
Signature · 1 line
MST