Module Name: src Committed By: jmcneill Date: Fri Oct 12 21:20:54 UTC 2018
Modified Files: src/sys/dev/acpi: acpi.c acpivar.h Log Message: Add helper functions for walking GTDT subtables. To generate a diff of this commit: cvs rdiff -u -r1.272 -r1.273 src/sys/dev/acpi/acpi.c cvs rdiff -u -r1.75 -r1.76 src/sys/dev/acpi/acpivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/acpi/acpi.c diff -u src/sys/dev/acpi/acpi.c:1.272 src/sys/dev/acpi/acpi.c:1.273 --- src/sys/dev/acpi/acpi.c:1.272 Thu Oct 11 22:58:36 2018 +++ src/sys/dev/acpi/acpi.c Fri Oct 12 21:20:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi.c,v 1.272 2018/10/11 22:58:36 jmcneill Exp $ */ +/* $NetBSD: acpi.c,v 1.273 2018/10/12 21:20:54 jmcneill Exp $ */ /*- * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc. @@ -100,7 +100,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.272 2018/10/11 22:58:36 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.273 2018/10/12 21:20:54 jmcneill Exp $"); #include "pci.h" #include "opt_acpi.h" @@ -148,6 +148,7 @@ static uint64_t acpi_root_pointer; extern kmutex_t acpi_interrupt_list_mtx; static ACPI_HANDLE acpi_scopes[4]; ACPI_TABLE_HEADER *madt_header; +ACPI_TABLE_HEADER *gtdt_header; /* * This structure provides a context for the ACPI @@ -1708,6 +1709,28 @@ acpi_madt_unmap(void) madt_header = NULL; } +ACPI_STATUS +acpi_gtdt_map(void) +{ + ACPI_STATUS rv; + + if (gtdt_header != NULL) + return AE_ALREADY_EXISTS; + + rv = AcpiGetTable(ACPI_SIG_GTDT, 1, >dt_header); + + if (ACPI_FAILURE(rv)) + return rv; + + return AE_OK; +} + +void +acpi_gtdt_unmap(void) +{ + gtdt_header = NULL; +} + /* * XXX: Refactor to be a generic function that walks tables. */ @@ -1731,6 +1754,26 @@ acpi_madt_walk(ACPI_STATUS (*func)(ACPI_ } } +void +acpi_gtdt_walk(ACPI_STATUS (*func)(ACPI_GTDT_HEADER *, void *), void *aux) +{ + ACPI_GTDT_HEADER *hdrp; + char *gtdtend, *where; + + gtdtend = (char *)gtdt_header + gtdt_header->Length; + where = (char *)gtdt_header + sizeof (ACPI_TABLE_GTDT); + + while (where < gtdtend) { + + hdrp = (ACPI_GTDT_HEADER *)where; + + if (ACPI_FAILURE(func(hdrp, aux))) + break; + + where += hdrp->Length; + } +} + /* * Miscellaneous. */ Index: src/sys/dev/acpi/acpivar.h diff -u src/sys/dev/acpi/acpivar.h:1.75 src/sys/dev/acpi/acpivar.h:1.76 --- src/sys/dev/acpi/acpivar.h:1.75 Sat May 5 17:16:23 2018 +++ src/sys/dev/acpi/acpivar.h Fri Oct 12 21:20:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpivar.h,v 1.75 2018/05/05 17:16:23 christos Exp $ */ +/* $NetBSD: acpivar.h,v 1.76 2018/10/12 21:20:54 jmcneill Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -351,6 +351,14 @@ void acpi_madt_walk(ACPI_STATUS (*)(AC void *), void *); /* + * GTDT. + */ +ACPI_STATUS acpi_gtdt_map(void); +void acpi_gtdt_unmap(void); +void acpi_gtdt_walk(ACPI_STATUS (*)(ACPI_GTDT_HEADER *, + void *), void *); + +/* * Quirk handling. */ struct acpi_quirk {