diff mbox

[25/25] q35: automatically load the q35 dsdt table

Message ID 98c6427441763d8673fcb33918945943e8396b05.1347561356.git.jbaron@redhat.com
State New
Headers show

Commit Message

Jason Baron Sept. 13, 2012, 8:12 p.m. UTC
Automatically, locate the required q35 dsdt table on load. Otherwise we error
out. This could be done in the bios, but its harder to produce a good error
message.

Signed-off-by: Jason Baron <jbaron@redhat.com>
---
 hw/pc_q35.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

Comments

Paolo Bonzini Sept. 14, 2012, 7:08 a.m. UTC | #1
Il 13/09/2012 22:12, Jason Baron ha scritto:
> Automatically, locate the required q35 dsdt table on load. Otherwise we error
> out. This could be done in the bios, but its harder to produce a good error
> message.
> 
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> ---
>  hw/pc_q35.c |   26 ++++++++++++++++++++++++++
>  1 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/pc_q35.c b/hw/pc_q35.c
> index b8c1196..08ae62b 100644
> --- a/hw/pc_q35.c
> +++ b/hw/pc_q35.c
> @@ -329,6 +329,25 @@ static void pc_q35_init_late(BusState **idebus, ISADevice *rtc_state,
>                        8, NULL, 0);
>  }
>  
> +static int find_and_load_dsdt(const char *dsdt_name)
> +{
> +    char *filename;
> +    char buf[256];
> +
> +    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dsdt_name);
> +    if (!filename) {
> +        return -1;
> +    }
> +
> +    snprintf(buf, 256, "file=%s", filename);
> +    if (acpi_table_add(buf) < 0) {
> +        fprintf(stderr, "Wrong acpi table provided\n");
> +        return -1;
> +    }
> +
> +    return 0;
> +}
> +
>  /* PC hardware initialisation */
>  static void pc_q35_init(ram_addr_t ram_size,
>                          const char *boot_device,
> @@ -356,6 +375,13 @@ static void pc_q35_init(ram_addr_t ram_size,
>      qemu_irq *i8259;
>      int i;
>  
> +    /* let's first see if we can find the proper dsdt */
> +    if (find_and_load_dsdt("q35-acpi-dsdt.aml")) {
> +        fprintf(stderr, "Couldn't find q35 dsdt table!\n"
> +                        "Try updating your bios.\n");
> +        exit(1);
> +    }
> +
>      pc_cpus_init(cpu_model);
>  
>      kvmclock_create();
> 

Should we take the PIIX4 DSDT into the QEMU tree, and do the same thing
for PIIX4?

Paolo
Gerd Hoffmann Sept. 14, 2012, 7:25 a.m. UTC | #2
On 09/14/12 09:08, Paolo Bonzini wrote:
> Il 13/09/2012 22:12, Jason Baron ha scritto:
>> Automatically, locate the required q35 dsdt table on load. Otherwise we error
>> out. This could be done in the bios, but its harder to produce a good error
>> message.

>>  /* PC hardware initialisation */
>>  static void pc_q35_init(ram_addr_t ram_size,
>>                          const char *boot_device,
>> @@ -356,6 +375,13 @@ static void pc_q35_init(ram_addr_t ram_size,
>>      qemu_irq *i8259;
>>      int i;
>>  
>> +    /* let's first see if we can find the proper dsdt */
>> +    if (find_and_load_dsdt("q35-acpi-dsdt.aml")) {
>> +        fprintf(stderr, "Couldn't find q35 dsdt table!\n"
>> +                        "Try updating your bios.\n");
>> +        exit(1);
>> +    }
>> +
>>      pc_cpus_init(cpu_model);
>>  
>>      kvmclock_create();
>>
> 
> Should we take the PIIX4 DSDT into the QEMU tree, and do the same thing
> for PIIX4?

We should surely have both at the same place.  Dunno what the best place
is, we have interactions with both seabios code and acpi tables and qemu
+ acpi tables.

I'd tend to put them into seabios.git, add a config option to select
piix/q35, then go build two bios binaries.

cheers,
  Gerd
Paolo Bonzini Sept. 14, 2012, 7:34 a.m. UTC | #3
Il 14/09/2012 09:25, Gerd Hoffmann ha scritto:
>> > 
>> > Should we take the PIIX4 DSDT into the QEMU tree, and do the same thing
>> > for PIIX4?
> We should surely have both at the same place.  Dunno what the best place
> is, we have interactions with both seabios code and acpi tables and qemu
> + acpi tables.
> 
> I'd tend to put them into seabios.git, add a config option to select
> piix/q35, then go build two bios binaries.

Let's discuss it in the SeaBIOS mailing list.

Paolo
diff mbox

Patch

diff --git a/hw/pc_q35.c b/hw/pc_q35.c
index b8c1196..08ae62b 100644
--- a/hw/pc_q35.c
+++ b/hw/pc_q35.c
@@ -329,6 +329,25 @@  static void pc_q35_init_late(BusState **idebus, ISADevice *rtc_state,
                       8, NULL, 0);
 }
 
+static int find_and_load_dsdt(const char *dsdt_name)
+{
+    char *filename;
+    char buf[256];
+
+    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dsdt_name);
+    if (!filename) {
+        return -1;
+    }
+
+    snprintf(buf, 256, "file=%s", filename);
+    if (acpi_table_add(buf) < 0) {
+        fprintf(stderr, "Wrong acpi table provided\n");
+        return -1;
+    }
+
+    return 0;
+}
+
 /* PC hardware initialisation */
 static void pc_q35_init(ram_addr_t ram_size,
                         const char *boot_device,
@@ -356,6 +375,13 @@  static void pc_q35_init(ram_addr_t ram_size,
     qemu_irq *i8259;
     int i;
 
+    /* let's first see if we can find the proper dsdt */
+    if (find_and_load_dsdt("q35-acpi-dsdt.aml")) {
+        fprintf(stderr, "Couldn't find q35 dsdt table!\n"
+                        "Try updating your bios.\n");
+        exit(1);
+    }
+
     pc_cpus_init(cpu_model);
 
     kvmclock_create();