From 36651dc0f06343169a69e006361c5b933ee37567 Mon Sep 17 00:00:00 2001 From: jkim Date: Tue, 9 Nov 2010 00:14:39 +0000 Subject: Reduce diff between platforms and fix style(9) bugs. --- sys/amd64/acpica/OsdEnvironment.c | 50 +++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'sys/amd64/acpica') diff --git a/sys/amd64/acpica/OsdEnvironment.c b/sys/amd64/acpica/OsdEnvironment.c index fb01a3f..a35a3e0 100644 --- a/sys/amd64/acpica/OsdEnvironment.c +++ b/sys/amd64/acpica/OsdEnvironment.c @@ -28,9 +28,6 @@ #include __FBSDID("$FreeBSD$"); -/* - * 6.1 : Environmental support - */ #include #include #include @@ -39,33 +36,56 @@ __FBSDID("$FreeBSD$"); #include #include -static u_long amd64_acpi_root; +static u_long acpi_root_phys; -SYSCTL_ULONG(_machdep, OID_AUTO, acpi_root, CTLFLAG_RD, &amd64_acpi_root, 0, - "The physical address of the RSDP"); +SYSCTL_ULONG(_machdep, OID_AUTO, acpi_root, CTLFLAG_RD, &acpi_root_phys, 0, + "The physical address of the RSDP"); ACPI_STATUS AcpiOsInitialize(void) { - return(0); + + return (AE_OK); } ACPI_STATUS AcpiOsTerminate(void) { - return(0); + + return (AE_OK); +} + +static u_long +acpi_get_root_from_loader(void) +{ + long acpi_root; + + if (resource_long_value("acpi", 0, "rsdp", &acpi_root) == 0) + return (acpi_root); + + return (0); +} + +static u_long +acpi_get_root_from_memory(void) +{ + ACPI_SIZE acpi_root; + + if (ACPI_SUCCESS(AcpiFindRootPointer(&acpi_root))) + return (acpi_root); + + return (0); } ACPI_PHYSICAL_ADDRESS AcpiOsGetRootPointer(void) { - u_long ptr; - if (amd64_acpi_root == 0 && - (resource_long_value("acpi", 0, "rsdp", (long *)&ptr) == 0 || - AcpiFindRootPointer((ACPI_SIZE *)&ptr) == AE_OK) && - ptr != 0) - amd64_acpi_root = ptr; + if (acpi_root_phys == 0) { + acpi_root_phys = acpi_get_root_from_loader(); + if (acpi_root_phys == 0) + acpi_root_phys = acpi_get_root_from_memory(); + } - return (amd64_acpi_root); + return (acpi_root_phys); } -- cgit v1.1