xref: /freebsd/sys/compat/linuxkpi/common/include/acpi/acpi.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2017 Mark Johnston <markj@FreeBSD.org>
5  * Copyright (c) 2020 Vladimir Kondratyev <wulf@FreeBSD.org>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in
14  *    the documentation and/or other materials provided with the
15  *    distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #ifndef _LINUXKPI_ACPI_ACPI_H_
31 #define _LINUXKPI_ACPI_ACPI_H_
32 
33 /*
34  * FreeBSD import of ACPICA has a typedef for BOOLEAN which conflicts with
35  * amdgpu driver. Workaround it on preprocessor level.
36  */
37 #define	ACPI_USE_SYSTEM_INTTYPES
38 #define	BOOLEAN			unsigned char
39 typedef unsigned char		UINT8;
40 typedef unsigned short		UINT16;
41 typedef short			INT16;
42 typedef unsigned int		UINT32;
43 typedef int			INT32;
44 typedef uint64_t		UINT64;
45 typedef int64_t			INT64;
46 #include <contrib/dev/acpica/include/acpi.h>
47 #undef BOOLEAN
48 
49 typedef ACPI_HANDLE		acpi_handle;
50 typedef ACPI_OBJECT		acpi_object;
51 typedef ACPI_OBJECT_HANDLER	acpi_object_handler;
52 typedef ACPI_OBJECT_TYPE	acpi_object_type;
53 typedef ACPI_STATUS		acpi_status;
54 typedef ACPI_STRING		acpi_string;
55 typedef ACPI_SIZE		acpi_size;
56 typedef ACPI_WALK_CALLBACK	acpi_walk_callback;
57 
58 static inline ACPI_STATUS
59 acpi_evaluate_object(ACPI_HANDLE Object, ACPI_STRING Pathname,
60     ACPI_OBJECT_LIST *ParameterObjects, ACPI_BUFFER *ReturnObjectBuffer)
61 {
62 	return (AcpiEvaluateObject(
63 	    Object, Pathname, ParameterObjects, ReturnObjectBuffer));
64 }
65 
66 static inline const char *
67 acpi_format_exception(ACPI_STATUS Exception)
68 {
69 	return (AcpiFormatException(Exception));
70 }
71 
72 static inline ACPI_STATUS
73 acpi_get_handle(ACPI_HANDLE Parent, ACPI_STRING Pathname,
74     ACPI_HANDLE *RetHandle)
75 {
76 	return (AcpiGetHandle(Parent, Pathname, RetHandle));
77 }
78 
79 static inline ACPI_STATUS
80 acpi_get_data(ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void **Data)
81 {
82 	return (AcpiGetData(ObjHandle, Handler, Data));
83 }
84 
85 static inline ACPI_STATUS
86 acpi_get_name(ACPI_HANDLE Object, UINT32 NameType, ACPI_BUFFER *RetPathPtr)
87 {
88 	return (AcpiGetName(Object, NameType, RetPathPtr));
89 }
90 
91 static inline ACPI_STATUS
92 acpi_get_table(ACPI_STRING Signature, UINT32 Instance,
93     ACPI_TABLE_HEADER **OutTable)
94 {
95 	return (AcpiGetTable(Signature, Instance, OutTable));
96 }
97 
98 static inline void
99 acpi_put_table(ACPI_TABLE_HEADER *Table)
100 {
101 	AcpiPutTable(Table);
102 }
103 
104 #endif /* _LINUXKPI_ACPI_ACPI_H_ */
105