[SeaBIOS] [PATCH] Add acpi_reboot() function for invoking ACPI reset

David Woodhouse dwmw2 at infradead.org
Wed Feb 20 12:33:09 CET 2013


On Tue, 2013-02-19 at 20:09 -0500, Kevin O'Connor wrote:
> On Tue, Feb 19, 2013 at 06:08:31PM +0000, David Woodhouse wrote:
> > Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
> > ---
> > 
> > Nothing actually sets it yet. We'll do that from the ACPI table parser
> > for CSM and Xen, and we can put it in our own tables for the native
> > case.
> 
> Looks okay to me.  I'd like to see the follow up patches that make use
> of it before committing though.

Looks something like this. Not properly tested though, because first I
have to make OVMF (or Xen or Coreboot) actually pass in an ACPI 2.0
table with the RESET_REG present...

We probably want a structure for the 2.0 FADT rather than screwing
around with magic pointer arithmetic, and we probably want to combine
find_pmtimer() and find_reset_reg() into one function too.

diff --git a/src/acpi.c b/src/acpi.c
index 97ade3f..8c53dd3 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -930,6 +930,21 @@ static struct acpi_20_generic_address acpi_reset_reg;
 static u8 acpi_reset_val;
 
 void
+find_reset_reg(void)
+{
+    struct fadt_descriptor_rev1 *fadt = find_fadt();
+    if (!fadt || fadt->length < 129)
+        return;
+
+    // Theoretically we should check the 'reset_reg_sup' flag, but Windows
+    // doesn't and thus nobody seems to *set* it. If the table is large enough
+    // to include it, let the sanity checks in acpi_set_reset_reg() suffice.
+
+    void *p = fadt;
+    acpi_set_reset_reg(p + 116, *(u8 *)(p + 128));
+}
+
+void
 acpi_reboot(void)
 {
     // Must be a single byte;
diff --git a/src/acpi.h b/src/acpi.h
index 3f85814..2d4cc86 100644
--- a/src/acpi.h
+++ b/src/acpi.h
@@ -18,6 +18,7 @@ struct acpi_20_generic_address {
 void acpi_setup(void);
 u32 find_resume_vector(void);
 void find_pmtimer(void);
+void find_reset_reg(void);
 void acpi_set_reset_reg(struct acpi_20_generic_address *reg, u8 val);
 void acpi_reboot(void);
 
diff --git a/src/coreboot.c b/src/coreboot.c
index 0d44834..522b686 100644
--- a/src/coreboot.c
+++ b/src/coreboot.c
@@ -230,6 +230,7 @@ coreboot_platform_setup(void)
     }
 
     find_pmtimer();
+    find_reset_reg();
 }
 
 
diff --git a/src/csm.c b/src/csm.c
index ab66042..bd0ffd1 100644
--- a/src/csm.c
+++ b/src/csm.c
@@ -157,6 +157,7 @@ handle_csm_0002(struct bregs *regs)
         dprintf(3, "CSM ACPI RSDP at %p\n", RsdpAddr);
 
         find_pmtimer();
+        find_reset_reg();
     }
 
     // SMBIOS table needs to be copied into the f-seg
diff --git a/src/xen.c b/src/xen.c
index 2dbd9df..f18c5c3 100644
--- a/src/xen.c
+++ b/src/xen.c
@@ -126,6 +126,7 @@ void xen_biostable_setup(void)
         copy_table(tables[i]);
 
     find_pmtimer();
+    find_reset_reg();
 }
 
 void xen_preinit(void)


-- 
dwmw2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6171 bytes
Desc: not available
URL: <http://www.seabios.org/pipermail/seabios/attachments/20130220/fca62c46/attachment.bin>


More information about the SeaBIOS mailing list