Add acpi_error_string() and use it in the APIC setup diagnostics, so the
startup path can report why ACPI/APIC setup failed instead of a bare
number.
---
 i386/i386at/acpi_parse_apic.c | 17 +++++++++++++++++
 i386/i386at/acpi_parse_apic.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/i386/i386at/acpi_parse_apic.c b/i386/i386at/acpi_parse_apic.c
index 848585c2..d7a55dbf 100644
--- a/i386/i386at/acpi_parse_apic.c
+++ b/i386/i386at/acpi_parse_apic.c
@@ -36,6 +36,23 @@ static struct acpi_apic *apic_madt = NULL;
 unsigned lapic_addr;
 uint32_t *hpet_addr;
 
+const char *
+acpi_error_string(int err)
+{
+    switch (err) {
+    case ACPI_BAD_CHECKSUM:  return "bad ACPI table checksum";
+    case ACPI_BAD_ALIGN:     return "bad ACPI RSDP alignment";
+    case ACPI_NO_RSDP:       return "no ACPI RSDP found";
+    case ACPI_NO_RSDT:       return "no ACPI RSDT/XSDT found";
+    case ACPI_BAD_SIGNATURE: return "bad ACPI table signature";
+    case ACPI_NO_APIC:       return "no APIC/MADT table found";
+    case ACPI_NO_LAPIC:      return "cannot map the Local APIC";
+    case ACPI_APIC_FAILURE:  return "no usable APIC CPU topology";
+    case ACPI_FIT_FAILURE:   return "cannot size the accepted CPU list";
+    default:                 return "unknown ACPI/APIC error";
+    }
+}
+
 /*
  * acpi_print_info: shows by screen the ACPI's rsdp and rsdt virtual address
  * and the number of entries stored in RSDT table.
diff --git a/i386/i386at/acpi_parse_apic.h b/i386/i386at/acpi_parse_apic.h
index df8d4bae..64819213 100644
--- a/i386/i386at/acpi_parse_apic.h
+++ b/i386/i386at/acpi_parse_apic.h
@@ -197,6 +197,7 @@ struct acpi_hpet {
 
 int acpi_apic_init(void);
 void acpi_print_info(phys_addr_t rsdp, void *rsdt, int acpi_rsdt_n);
+const char *acpi_error_string(int err);
 
 extern unsigned lapic_addr;
 

Reply via email to