summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-02-05 15:51:11 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-02-05 15:51:11 +0000
commit85d734898291cc4e9269a03186973456309c81c5 (patch)
tree80a26c86b3dae72dce8ae99484a8419c3def62ae /sys
parent507b4e4b1c6763598c7221968bb736c9a1ac5e9a (diff)
Implement acpi_get_table_with_size(). Will soon be used to read VFCT
tables in radeondrm(4).
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/drm_linux.c37
-rw-r--r--sys/dev/pci/drm/drm_linux.h17
2 files changed, 52 insertions, 2 deletions
diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c
index 68a42ca7345..dede7bd87e6 100644
--- a/sys/dev/pci/drm/drm_linux.c
+++ b/sys/dev/pci/drm/drm_linux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.c,v 1.7 2016/01/01 15:28:26 kettenis Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.8 2016/02/05 15:51:10 kettenis Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
*
@@ -270,3 +270,38 @@ vga_put(struct pci_dev *pdev, int rsrc)
}
#endif
+
+/*
+ * ACPI types and interfaces.
+ */
+
+#if defined(__amd64__) || defined(__i386__)
+#include "acpi.h"
+#endif
+
+#if NACPI > 0
+
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+
+acpi_status
+acpi_get_table_with_size(const char *sig, int instance,
+ struct acpi_table_header **hdr, acpi_size *size)
+{
+ struct acpi_softc *sc = acpi_softc;
+ struct acpi_q *entry;
+
+ KASSERT(instance == 1);
+
+ SIMPLEQ_FOREACH(entry, &sc->sc_tables, q_next) {
+ if (memcmp(entry->q_table, sig, strlen(sig)) == 0) {
+ *hdr = entry->q_table;
+ *size = (*hdr)->length;
+ return 0;
+ }
+ }
+
+ return AE_NOT_FOUND;
+}
+
+#endif
diff --git a/sys/dev/pci/drm/drm_linux.h b/sys/dev/pci/drm/drm_linux.h
index 63708a7af1a..0e651ba323e 100644
--- a/sys/dev/pci/drm/drm_linux.h
+++ b/sys/dev/pci/drm/drm_linux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.h,v 1.44 2016/02/05 10:05:12 kettenis Exp $ */
+/* $OpenBSD: drm_linux.h,v 1.45 2016/02/05 15:51:10 kettenis Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
*
@@ -1376,3 +1376,18 @@ struct fb_info {
#define framebuffer_alloc(flags, device) \
kzalloc(sizeof(struct fb_info), GFP_KERNEL)
+
+/*
+ * ACPI types and interfaces.
+ */
+
+typedef size_t acpi_size;
+typedef int acpi_status;
+
+struct acpi_table_header;
+
+#define ACPI_SUCCESS(x) ((x) == 0)
+
+#define AE_NOT_FOUND 0x0005
+
+acpi_status acpi_get_table_with_size(const char *, int, struct acpi_table_header **, acpi_size *);