Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi acpi: Add helper for querying DSM function 0.
details: https://anonhg.NetBSD.org/src/rev/c9a10be22425
branches: trunk
changeset: 359648:c9a10be22425
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Jan 15 14:40:22 2022 +0000
description:
acpi: Add helper for querying DSM function 0.
diffstat:
sys/dev/acpi/acpi_util.c | 36 ++++++++++++++++++++++++++++++++++--
sys/dev/acpi/acpi_util.h | 4 +++-
2 files changed, 37 insertions(+), 3 deletions(-)
diffs (75 lines):
diff -r c3ac7079aa3e -r c9a10be22425 sys/dev/acpi/acpi_util.c
--- a/sys/dev/acpi/acpi_util.c Sat Jan 15 14:33:36 2022 +0000
+++ b/sys/dev/acpi/acpi_util.c Sat Jan 15 14:40:22 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.c,v 1.30 2022/01/09 14:28:23 jmcneill Exp $ */
+/* $NetBSD: acpi_util.c,v 1.31 2022/01/15 14:40:22 jmcneill Exp $ */
/*-
* Copyright (c) 2003, 2007, 2021 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.30 2022/01/09 14:28:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.31 2022/01/15 14:40:22 jmcneill Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -1117,6 +1117,38 @@
}
ACPI_STATUS
+acpi_dsm_query(ACPI_HANDLE handle, uint8_t *uuid, ACPI_INTEGER rev,
+ ACPI_INTEGER *ret)
+{
+ ACPI_OBJECT *obj;
+ ACPI_STATUS status;
+ uint8_t *data;
+ u_int n;
+
+ status = acpi_dsm(handle, uuid, rev, 0, NULL, &obj);
+ if (ACPI_FAILURE(status)) {
+ return status;
+ }
+
+ if (obj->Type == ACPI_TYPE_INTEGER) {
+ *ret = obj->Integer.Value;
+ } else if (obj->Type == ACPI_TYPE_BUFFER &&
+ obj->Buffer.Length <= 8) {
+ *ret = 0;
+ data = (uint8_t *)obj->Buffer.Pointer;
+ for (n = 0; n < obj->Buffer.Length; n++) {
+ *ret |= (uint64_t)data[n] << (n * 8);
+ }
+ } else {
+ status = AE_TYPE;
+ }
+
+ ACPI_FREE(obj);
+
+ return status;
+}
+
+ACPI_STATUS
acpi_claim_childdevs(device_t dev, struct acpi_devnode *devnode)
{
struct acpi_devnode *ad;
diff -r c3ac7079aa3e -r c9a10be22425 sys/dev/acpi/acpi_util.h
--- a/sys/dev/acpi/acpi_util.h Sat Jan 15 14:33:36 2022 +0000
+++ b/sys/dev/acpi/acpi_util.h Sat Jan 15 14:40:22 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_util.h,v 1.12 2022/01/09 14:28:23 jmcneill Exp $ */
+/* $NetBSD: acpi_util.h,v 1.13 2022/01/15 14:40:33 jmcneill Exp $ */
/*-
* Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -108,6 +108,8 @@
ACPI_STATUS acpi_dsm_integer(ACPI_HANDLE, uint8_t *, ACPI_INTEGER,
ACPI_INTEGER, const ACPI_OBJECT *,
ACPI_INTEGER *);
+ACPI_STATUS acpi_dsm_query(ACPI_HANDLE, uint8_t *, ACPI_INTEGER,
+ ACPI_INTEGER *);
ACPI_STATUS acpi_claim_childdevs(device_t, struct acpi_devnode *);
Home |
Main Index |
Thread Index |
Old Index