aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2009-10-29 17:15:22 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2009-10-29 17:15:22 +0000
commita70c0d78f8f4cc995b7a538f3e1e5b75eb0a3704 (patch)
tree60b66baa3888a99ee03090b8277e034b68ca3db9 /sys/dev
parent4a616dc5d08403145c2773627f8ffbe88036ac78 (diff)
Notes
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpica/acpi.c22
-rw-r--r--sys/dev/acpica/acpivar.h5
2 files changed, 27 insertions, 0 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index d6e5c4cb4946..541a5e068b6f 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -2166,6 +2166,28 @@ acpi_SetIntrModel(int model)
}
/*
+ * Walk subtables of a table and call a callback routine for each
+ * subtable. The caller should provide the first subtable and a
+ * pointer to the end of the table. This can be used to walk tables
+ * such as MADT and SRAT that use subtable entries.
+ */
+void
+acpi_walk_subtables(void *first, void *end, acpi_subtable_handler *handler,
+ void *arg)
+{
+ ACPI_SUBTABLE_HEADER *entry;
+
+ for (entry = first; (void *)entry < end; ) {
+ /* Avoid an infinite loop if we hit a bogus entry. */
+ if (entry->Length < sizeof(ACPI_SUBTABLE_HEADER))
+ return;
+
+ handler(entry, arg);
+ entry = ACPI_ADD_PTR(ACPI_SUBTABLE_HEADER, entry, entry->Length);
+ }
+}
+
+/*
* DEPRECATED. This interface has serious deficiencies and will be
* removed.
*
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 35bd66dc0926..e6f39a18fdfe 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -307,6 +307,9 @@ void acpi_EnterDebugger(void);
ACPI_DEVINFO_PRESENT(x, ACPI_STA_PRESENT | ACPI_STA_FUNCTIONAL | \
ACPI_STA_BATT_PRESENT)
+/* Callback function type for walking subtables within a table. */
+typedef void acpi_subtable_handler(ACPI_SUBTABLE_HEADER *, void *);
+
BOOLEAN acpi_DeviceIsPresent(device_t dev);
BOOLEAN acpi_BatteryIsPresent(device_t dev);
ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, char *path,
@@ -339,6 +342,8 @@ void acpi_UserNotify(const char *subsystem, ACPI_HANDLE h,
int acpi_bus_alloc_gas(device_t dev, int *type, int *rid,
ACPI_GENERIC_ADDRESS *gas, struct resource **res,
u_int flags);
+void acpi_walk_subtables(void *first, void *end,
+ acpi_subtable_handler *handler, void *arg);
struct acpi_parse_resource_set {
void (*set_init)(device_t dev, void *arg, void **context);