Skip to contentSkip to conversation

move _PR to SSDT v2

PATCH In review Jes Sorensen 3 participants 6 messages Jun 12, 2009 – Jun 22, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 move _PR to SSDT v2

Hi,

I figured out why Windows wasn't booting with the previous version of the patch. It seems it didn't like the forward declaration of the _PR.PRSC method.

Instead I found that it does seem to work if I add the calling method _GRE.L02 in the SSDT, while the rest of the _GRE is declared in the DSDT.

It boots, it's perfect!

Cheers,
Jes

Move _PR block from the DSDT to a new SSDT in the KVM BIOS. As AML, or at least Windows doesn't allow forward declarations of Methods, it is necessary to declare the _GPE._L02 Method in the SSDT as well.

This will make it possible to plug in different SSDTs with different processor counts in the future.

---
 kvm/bios/Makefile      |   12 +++-
 kvm/bios/acpi-dsdt.dsl |  105 ------------------------------------
 kvm/bios/acpi-ssdt.dsl |  140 +++++++++++++++++++++++++++++++++++++++++++++++++
 kvm/bios/rombios32.c   |   16 ++++-
 4 files changed, 161 insertions(+), 112 deletions(-)
kvm/bios/Makefile +9 -3
Index: qemu-kvm/kvm/bios/Makefile
===================================================================
@@ -71,7 +71,7 @@ bios: biossums BIOS-bochs-latest BIOS-bo
 clean:
 	rm -f  *.o *.a *.s _rombios*_.c rombios*.txt rombios*.sym
 	rm -f  usage biossums rombios16.bin
-	rm -f  rombios32.bin rombios32.out acpi-dsdt.hex
+	rm -f  rombios32.bin rombios32.out acpi-dsdt.hex acpi-ssdt.hex
 
 dist-clean: clean
 	rm -f  Makefile
@@ -108,13 +108,19 @@ rombios32.bin: rombios32.out rombios.h
 rombios32.out: rombios32start.o rombios32.o vapic.o rombios32.ld
 	ld -o $@ -T rombios32.ld rombios32start.o vapic.o rombios32.o
 
-rombios32.o: rombios32.c acpi-dsdt.hex
+rombios32.o: rombios32.c acpi-dsdt.hex acpi-ssdt.hex
 	$(GCC) -m32 -O2 -Wall -c -o $@ $<
 
 acpi-dsdt.hex: acpi-dsdt.dsl
 	cpp -P $< $<.i
 	iasl -tc -p $@ $<.i
-	sed -i -e's/^unsigned/const unsigned/' $@
+	sed -i -e's/^unsigned char AmlCode/const unsigned char DSDTCode/' $@
+	rm $<.i
+
+acpi-ssdt.hex: acpi-ssdt.dsl
+	cpp -P $< $<.i
+	iasl -tc -p $@ $<.i
+	sed -i -e's/^unsigned char AmlCode/const unsigned char SSDTCode/' $@
 	rm $<.i
 
 rombios32start.o: rombios32start.S
kvm/bios/acpi-dsdt.dsl +0 -105

117 lines not on this page · raw message

kvm/bios/acpi-ssdt.dsl new file +140 -0

140 lines not on this page · raw message

kvm/bios/rombios32.c +12 -4
Index: qemu-kvm/kvm/bios/rombios32.c
===================================================================
@@ -1526,6 +1526,7 @@ struct madt_int_override
 #endif
 
 #include "acpi-dsdt.hex"
+#include "acpi-ssdt.hex"
 
 static inline uint16_t cpu_to_le16(uint16_t x)
 {
@@ -1646,7 +1647,11 @@ void acpi_bios_init(void)
 
     dsdt_addr = addr;
     dsdt = (void *)(addr);
-    addr += sizeof(AmlCode);
+    addr += sizeof(DSDTCode);
+
+    ssdt_addr = addr;
+    ssdt = (void *)(addr);
+    addr += sizeof(SSDTCode);
 
 #ifdef BX_QEMU
     qemu_cfg_select(QEMU_CFG_NUMA);
@@ -1739,7 +1744,10 @@ void acpi_bios_init(void)
     BX_INFO("Firmware waking vector %p\n", &facs->firmware_waking_vector);
 
     /* DSDT */
-    memcpy(dsdt, AmlCode, sizeof(AmlCode));
+    memcpy(dsdt, DSDTCode, sizeof(DSDTCode));
+
+    /* SSDT */
+    memcpy(ssdt, SSDTCode, sizeof(SSDTCode));
 
     /* MADT */
     {
@@ -1895,9 +1903,9 @@ void acpi_bios_init(void)
 
     /* RSDT */
     rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(fadt_addr);
+    /* On real hardware the SSDT seems to come before the MADT (APIC) */
+    rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(ssdt_addr);
     rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(madt_addr);
-    /* kvm has no ssdt (processors are in dsdt) */
-//  rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(ssdt_addr);
 #ifdef BX_QEMU
     /* No HPET (yet) */
 //  rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(hpet_addr);
#1 lore raw
Quoted 6 lines · Jes Sorensen

Hi,

I figured out why Windows wasn't booting with the previous version of the patch. It seems it didn't like the forward declaration of the _PR.PRSC method.

Quoted 6 lines

Instead I found that it does seem to work if I add the calling method _GRE.L02 in the SSDT, while the rest of the _GRE is declared in the DSDT.

It boots, it's perfect!

Works for me with windows XP/7, but can you add a comment in DSDT where _GRE.L02 should be why it is missing and where to find it.

--
Gleb.

#2 lore raw
Quoted 3 lines · Gleb Natapov

Works for me with windows XP/7, but can you add a comment in DSDT where _GRE.L02 should be why it is missing and where to find it.

Sure, here's an updated version with the comment. Thanks for testing it.

Cheers,
Jes

Move _PR block from the DSDT to a new SSDT in the KVM BIOS. As AML, or at least Windows doesn't allow forward declarations of Methods, it is necessary to declare the _GPE._L02 Method in the SSDT as well.

This will make it possible to plug in different SSDTs with different processor counts in the future.

---
 kvm/bios/Makefile      |   12 +++-
 kvm/bios/acpi-dsdt.dsl |  110 +-------------------------------------
 kvm/bios/acpi-ssdt.dsl |  140 +++++++++++++++++++++++++++++++++++++++++++++++++
 kvm/bios/rombios32.c   |   16 ++++-
 4 files changed, 166 insertions(+), 112 deletions(-)
kvm/bios/Makefile +9 -3
Index: qemu-kvm/kvm/bios/Makefile
===================================================================
@@ -71,7 +71,7 @@ bios: biossums BIOS-bochs-latest BIOS-bo
 clean:
 	rm -f  *.o *.a *.s _rombios*_.c rombios*.txt rombios*.sym
 	rm -f  usage biossums rombios16.bin
-	rm -f  rombios32.bin rombios32.out acpi-dsdt.hex
+	rm -f  rombios32.bin rombios32.out acpi-dsdt.hex acpi-ssdt.hex
 
 dist-clean: clean
 	rm -f  Makefile
@@ -108,13 +108,19 @@ rombios32.bin: rombios32.out rombios.h
 rombios32.out: rombios32start.o rombios32.o vapic.o rombios32.ld
 	ld -o $@ -T rombios32.ld rombios32start.o vapic.o rombios32.o
 
-rombios32.o: rombios32.c acpi-dsdt.hex
+rombios32.o: rombios32.c acpi-dsdt.hex acpi-ssdt.hex
 	$(GCC) -m32 -O2 -Wall -c -o $@ $<
 
 acpi-dsdt.hex: acpi-dsdt.dsl
 	cpp -P $< $<.i
 	iasl -tc -p $@ $<.i
-	sed -i -e's/^unsigned/const unsigned/' $@
+	sed -i -e's/^unsigned char AmlCode/const unsigned char DSDTCode/' $@
+	rm $<.i
+
+acpi-ssdt.hex: acpi-ssdt.dsl
+	cpp -P $< $<.i
+	iasl -tc -p $@ $<.i
+	sed -i -e's/^unsigned char AmlCode/const unsigned char SSDTCode/' $@
 	rm $<.i
 
 rombios32start.o: rombios32start.S
kvm/bios/acpi-dsdt.dsl +5 -105

122 lines not on this page · raw message

kvm/bios/acpi-ssdt.dsl new file +140 -0

140 lines not on this page · raw message

kvm/bios/rombios32.c +12 -4
Index: qemu-kvm/kvm/bios/rombios32.c
===================================================================
@@ -1528,6 +1528,7 @@ struct madt_int_override
 #endif
 
 #include "acpi-dsdt.hex"
+#include "acpi-ssdt.hex"
 
 static inline uint16_t cpu_to_le16(uint16_t x)
 {
@@ -1647,7 +1648,11 @@ void acpi_bios_init(void)
 
     dsdt_addr = addr;
     dsdt = (void *)(addr);
-    addr += sizeof(AmlCode);
+    addr += sizeof(DSDTCode);
+
+    ssdt_addr = addr;
+    ssdt = (void *)(addr);
+    addr += sizeof(SSDTCode);
 
 #ifdef BX_QEMU
     qemu_cfg_select(QEMU_CFG_NUMA);
@@ -1740,7 +1745,10 @@ void acpi_bios_init(void)
     BX_INFO("Firmware waking vector %p\n", &facs->firmware_waking_vector);
 
     /* DSDT */
-    memcpy(dsdt, AmlCode, sizeof(AmlCode));
+    memcpy(dsdt, DSDTCode, sizeof(DSDTCode));
+
+    /* SSDT */
+    memcpy(ssdt, SSDTCode, sizeof(SSDTCode));
 
     /* MADT */
     {
@@ -1887,9 +1895,9 @@ void acpi_bios_init(void)
 
     /* RSDT */
     rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(fadt_addr);
+    /* On real hardware the SSDT seems to come before the MADT (APIC) */
+    rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(ssdt_addr);
     rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(madt_addr);
-    /* kvm has no ssdt (processors are in dsdt) */
-//  rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(ssdt_addr);
 #ifdef BX_QEMU
     /* No HPET (yet) */
 //  rsdt->table_offset_entry[nb_rsdt_entries++] = cpu_to_le32(hpet_addr);
#3 lore raw
In reply to Gleb Natapov
Quoted 2 lines · Gleb Natapov

Works for me with windows XP/7, but can you add a comment in DSDT where _GRE.L02 should be why it is missing and where to find it.

Avi,

Are you happy with the last version of the SSDT patch? I have more piled up to go on top :-)

Thanks,
Jes

#4 lore raw
Quoted 8 lines · Jes Sorensen
Quoted 2 lines · Gleb Natapov

Works for me with windows XP/7, but can you add a comment in DSDT where _GRE.L02 should be why it is missing and where to find it.

Avi,

Are you happy with the last version of the SSDT patch? I have more piled up to go on top :-)

I don't want to use the word happy in acpi context, but the patch is good and I applied it. Thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function
#5 lore raw
Quoted 6 lines · Avi Kivity
Quoted 2 lines · Jes Sorensen

Are you happy with the last version of the SSDT patch? I have more piled up to go on top :-)

I don't want to use the word happy in acpi context, but the patch is good and I applied it. Thanks.

Argh I know, I'll call a doctor before it gets me completely ... I don't know what went over me there.

:-)