svn commit: r209779 - in head/sys/ia64: acpica include

Marcel Moolenaar marcel at FreeBSD.org
Wed Jul 7 20:07:33 UTC 2010


Author: marcel
Date: Wed Jul  7 20:07:33 2010
New Revision: 209779
URL: http://svn.freebsd.org/changeset/base/209779

Log:
  Add acpi_find_table() -- a convenience function for looking up an
  ACPI table given the signature.

Modified:
  head/sys/ia64/acpica/acpi_machdep.c
  head/sys/ia64/include/md_var.h

Modified: head/sys/ia64/acpica/acpi_machdep.c
==============================================================================
--- head/sys/ia64/acpica/acpi_machdep.c	Wed Jul  7 20:06:48 2010	(r209778)
+++ head/sys/ia64/acpica/acpi_machdep.c	Wed Jul  7 20:07:33 2010	(r209779)
@@ -28,11 +28,12 @@
 
 #include <sys/param.h>
 #include <sys/bus.h>
+#include <machine/md_var.h>
+#include <machine/pal.h>
 
 #include <contrib/dev/acpica/include/acpi.h>
-
+#include <contrib/dev/acpica/include/actables.h>
 #include <dev/acpica/acpivar.h>
-#include <machine/pal.h>
 
 int
 acpi_machdep_init(device_t dev)
@@ -57,3 +58,37 @@ acpi_cpu_c1()
 {
 	ia64_call_pal_static(PAL_HALT_LIGHT, 0, 0, 0);
 }
+
+void *
+acpi_find_table(const char *sig)
+{
+	ACPI_PHYSICAL_ADDRESS rsdp_ptr;
+	ACPI_TABLE_RSDP *rsdp;
+	ACPI_TABLE_XSDT *xsdt;
+	ACPI_TABLE_HEADER *table;
+	UINT64 addr;
+	u_int i, count;
+
+	if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
+		return (NULL);
+
+	rsdp = (ACPI_TABLE_RSDP *)IA64_PHYS_TO_RR7(rsdp_ptr);
+	xsdt = (ACPI_TABLE_XSDT *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress);
+
+	count = (UINT64 *)((char *)xsdt + xsdt->Header.Length) -
+	    xsdt->TableOffsetEntry;
+
+	for (i = 0; i < count; i++) {
+		addr = xsdt->TableOffsetEntry[i];
+		table = (ACPI_TABLE_HEADER *)IA64_PHYS_TO_RR7(addr);
+
+		if (strncmp(table->Signature, sig, ACPI_NAME_SIZE) != 0)
+			continue;
+		if (ACPI_FAILURE(AcpiTbChecksum((void *)table, table->Length)))
+			continue;
+
+		return (table);
+	}
+
+	return (NULL);
+}

Modified: head/sys/ia64/include/md_var.h
==============================================================================
--- head/sys/ia64/include/md_var.h	Wed Jul  7 20:06:48 2010	(r209778)
+++ head/sys/ia64/include/md_var.h	Wed Jul  7 20:07:33 2010	(r209779)
@@ -77,6 +77,7 @@ extern uint64_t ia64_lapic_addr;
 extern long Maxmem;
 extern u_int busdma_swi_pending;
 
+void	*acpi_find_table(const char *sig);
 void	busdma_swi(void);
 int	copyout_regstack(struct thread *, uint64_t *, uint64_t *);
 void	cpu_mp_add(u_int, u_int, u_int);


More information about the svn-src-all mailing list