Author: jkim
Date: Tue Nov  9 00:14:39 2010
New Revision: 215023
URL: http://svn.freebsd.org/changeset/base/215023

Log:
  Reduce diff between platforms and fix style(9) bugs.

Modified:
  head/sys/amd64/acpica/OsdEnvironment.c
  head/sys/i386/acpica/OsdEnvironment.c
  head/sys/ia64/acpica/OsdEnvironment.c

Modified: head/sys/amd64/acpica/OsdEnvironment.c
==============================================================================
--- head/sys/amd64/acpica/OsdEnvironment.c      Mon Nov  8 23:15:10 2010        
(r215022)
+++ head/sys/amd64/acpica/OsdEnvironment.c      Tue Nov  9 00:14:39 2010        
(r215023)
@@ -28,9 +28,6 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-/*
- * 6.1 : Environmental support
- */
 #include <sys/types.h>
 #include <sys/bus.h>
 #include <sys/linker_set.h>
@@ -39,33 +36,56 @@ __FBSDID("$FreeBSD$");
 #include <contrib/dev/acpica/include/acpi.h>
 #include <contrib/dev/acpica/include/actables.h>
 
-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);
 }

Modified: head/sys/i386/acpica/OsdEnvironment.c
==============================================================================
--- head/sys/i386/acpica/OsdEnvironment.c       Mon Nov  8 23:15:10 2010        
(r215022)
+++ head/sys/i386/acpica/OsdEnvironment.c       Tue Nov  9 00:14:39 2010        
(r215023)
@@ -28,9 +28,6 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-/*
- * 6.1 : Environmental support
- */
 #include <sys/types.h>
 #include <sys/bus.h>
 #include <sys/linker_set.h>
@@ -39,33 +36,56 @@ __FBSDID("$FreeBSD$");
 #include <contrib/dev/acpica/include/acpi.h>
 #include <contrib/dev/acpica/include/actables.h>
 
-static u_long i386_acpi_root;
+static u_long acpi_root_phys;
 
-SYSCTL_ULONG(_machdep, OID_AUTO, acpi_root, CTLFLAG_RD, &i386_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 (i386_acpi_root == 0 &&
-           (resource_long_value("acpi", 0, "rsdp", (long *)&ptr) == 0 ||
-           AcpiFindRootPointer((ACPI_SIZE *)&ptr) == AE_OK) &&
-           ptr != 0)
-               i386_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 (i386_acpi_root);
+       return (acpi_root_phys);
 }

Modified: head/sys/ia64/acpica/OsdEnvironment.c
==============================================================================
--- head/sys/ia64/acpica/OsdEnvironment.c       Mon Nov  8 23:15:10 2010        
(r215022)
+++ head/sys/ia64/acpica/OsdEnvironment.c       Tue Nov  9 00:14:39 2010        
(r215023)
@@ -35,8 +35,6 @@ __FBSDID("$FreeBSD$");
 
 #include <contrib/dev/acpica/include/acpi.h>
 
-static struct uuid acpi_root_uuid = EFI_TABLE_ACPI20;
-
 static u_long acpi_root_phys;
 
 SYSCTL_ULONG(_machdep, OID_AUTO, acpi_root, CTLFLAG_RD, &acpi_root_phys, 0,
@@ -46,27 +44,35 @@ ACPI_STATUS
 AcpiOsInitialize(void)
 {
 
-       return(AE_OK);
+       return (AE_OK);
 }
 
 ACPI_STATUS
 AcpiOsTerminate(void)
 {
 
-       return(AE_OK);
+       return (AE_OK);
+}
+
+static u_long
+acpi_get_root_from_efi(void)
+{
+       static struct uuid acpi_root_uuid = EFI_TABLE_ACPI20;
+       void *acpi_root;
+
+       acpi_root = efi_get_table(&acpi_root_uuid);
+       if (acpi_root != NULL)
+               return (IA64_RR_MASK((uintptr_t)acpi_root));
+
+       return (0);
 }
 
 ACPI_PHYSICAL_ADDRESS
 AcpiOsGetRootPointer(void)
 {
-       void *acpi_root;
 
-       if (acpi_root_phys == 0) {
-               acpi_root = efi_get_table(&acpi_root_uuid);
-               if (acpi_root == NULL)
-                       return (0);
-               acpi_root_phys = IA64_RR_MASK((u_long)acpi_root);
-       }
+       if (acpi_root_phys == 0)
+               acpi_root_phys = acpi_get_root_from_efi();
 
        return (acpi_root_phys);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to