aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/acpi
diff options
context:
space:
mode:
authorEmmanuel Vadot <manu@FreeBSD.org>2020-11-09 13:20:14 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2020-11-09 13:20:14 +0000
commitdab39c11afe9c741ea9f89690238162578aba1dd (patch)
tree1c192693ef0026b59929aa51ae418edb7fbfc683 /sys/compat/linuxkpi/common/include/acpi
parente597bae4ee46f208d58e5f9da7788398a6b6c372 (diff)
downloadsrc-dab39c11afe9c741ea9f89690238162578aba1dd.tar.gz
src-dab39c11afe9c741ea9f89690238162578aba1dd.zip
LinuxKPI: Implement ACPI bits required by drm-kmod in base system
It includes: ACPI_HANDLE() implementation. AC and VIDEO ACPI events notification support. Replacement of hand-rolled GPLed _DSM method evaluation helpers with in-base ones. Submitted by: wulf Differential Revision: https://reviews.freebsd.org/D26603
Notes
Notes: svn path=/head/; revision=367521
Diffstat (limited to 'sys/compat/linuxkpi/common/include/acpi')
-rw-r--r--sys/compat/linuxkpi/common/include/acpi/acpi.h100
-rw-r--r--sys/compat/linuxkpi/common/include/acpi/acpi_bus.h52
-rw-r--r--sys/compat/linuxkpi/common/include/acpi/video.h38
3 files changed, 190 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/acpi/acpi.h b/sys/compat/linuxkpi/common/include/acpi/acpi.h
new file mode 100644
index 000000000000..b6579f42774e
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/acpi/acpi.h
@@ -0,0 +1,100 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2017 Mark Johnston <markj@FreeBSD.org>
+ * Copyright (c) 2020 Vladimir Kondratyev <wulf@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _ACPI_ACPI_H_
+#define _ACPI_ACPI_H_
+
+/*
+ * FreeBSD import of ACPICA has a typedef for BOOLEAN which conflicts with
+ * amdgpu driver. Workaround it on preprocessor level.
+ */
+#define ACPI_USE_SYSTEM_INTTYPES
+#define BOOLEAN unsigned char
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef short INT16;
+typedef unsigned int UINT32;
+typedef int INT32;
+typedef uint64_t UINT64;
+typedef int64_t INT64;
+#include <contrib/dev/acpica/include/acpi.h>
+#undef BOOLEAN
+
+typedef ACPI_HANDLE acpi_handle;
+typedef ACPI_OBJECT acpi_object;
+typedef ACPI_OBJECT_HANDLER acpi_object_handler;
+typedef ACPI_OBJECT_TYPE acpi_object_type;
+typedef ACPI_STATUS acpi_status;
+typedef ACPI_STRING acpi_string;
+typedef ACPI_SIZE acpi_size;
+typedef ACPI_WALK_CALLBACK acpi_walk_callback;
+
+static inline ACPI_STATUS
+acpi_evaluate_object(ACPI_HANDLE Object, ACPI_STRING Pathname,
+ ACPI_OBJECT_LIST *ParameterObjects, ACPI_BUFFER *ReturnObjectBuffer)
+{
+ return (AcpiEvaluateObject(
+ Object, Pathname, ParameterObjects, ReturnObjectBuffer));
+}
+
+static inline const char *
+acpi_format_exception(ACPI_STATUS Exception)
+{
+ return (AcpiFormatException(Exception));
+}
+
+static inline ACPI_STATUS
+acpi_get_handle(ACPI_HANDLE Parent, ACPI_STRING Pathname,
+ ACPI_HANDLE *RetHandle)
+{
+ return (AcpiGetHandle(Parent, Pathname, RetHandle));
+}
+
+static inline ACPI_STATUS
+acpi_get_data(ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void **Data)
+{
+ return (AcpiGetData(ObjHandle, Handler, Data));
+}
+
+static inline ACPI_STATUS
+acpi_get_name(ACPI_HANDLE Object, UINT32 NameType, ACPI_BUFFER *RetPathPtr)
+{
+ return (AcpiGetName(Object, NameType, RetPathPtr));
+}
+
+static inline ACPI_STATUS
+acpi_get_table(ACPI_STRING Signature, UINT32 Instance,
+ ACPI_TABLE_HEADER **OutTable)
+{
+ return (AcpiGetTable(Signature, Instance, OutTable));
+}
+
+#endif /* _ACPI_ACPI_H_ */
diff --git a/sys/compat/linuxkpi/common/include/acpi/acpi_bus.h b/sys/compat/linuxkpi/common/include/acpi/acpi_bus.h
new file mode 100644
index 000000000000..abee5223af60
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/acpi/acpi_bus.h
@@ -0,0 +1,52 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2020 Vladimir Kondratyev <wulf@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _ACPI_ACPI_BUS_H_
+#define _ACPI_ACPI_BUS_H_
+
+typedef char acpi_device_class[20];
+
+struct acpi_bus_event {
+ acpi_device_class device_class;
+ uint32_t type;
+ uint32_t data;
+};
+
+ACPI_HANDLE bsd_acpi_get_handle(device_t bsddev);
+bool acpi_check_dsm(ACPI_HANDLE handle, const char *uuid, int rev,
+ uint64_t funcs);
+ACPI_OBJECT * acpi_evaluate_dsm_typed(ACPI_HANDLE handle, const char *uuid,
+ int rev, int func, ACPI_OBJECT *argv4,
+ ACPI_OBJECT_TYPE type);
+int register_acpi_notifier(struct notifier_block *nb);
+int unregister_acpi_notifier(struct notifier_block *nb);
+uint32_t acpi_target_system_state(void);
+
+#endif /* !_ACPI_ACPI_BUS_H_ */
diff --git a/sys/compat/linuxkpi/common/include/acpi/video.h b/sys/compat/linuxkpi/common/include/acpi/video.h
new file mode 100644
index 000000000000..5c42153356c0
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/acpi/video.h
@@ -0,0 +1,38 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2020 Vladimir Kondratyev <wulf@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _ACPI_VIDEO_H_
+#define _ACPI_VIDEO_H_
+
+#define ACPI_VIDEO_CLASS "video"
+
+#define ACPI_VIDEO_NOTIFY_PROBE 0x81
+
+#endif /* !_ACPI_VIDEO_H_ */