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  * $FreeBSD$
30  */
31 
32 #ifndef _LINUXKPI_ACPI_ACPI_H_
33 #define _LINUXKPI_ACPI_ACPI_H_
34 
35 /*
36  * FreeBSD import of ACPICA has a typedef for BOOLEAN which conflicts with
37  * amdgpu driver. Workaround it on preprocessor level.
38  */
39 #define	ACPI_USE_SYSTEM_INTTYPES
40 #define	BOOLEAN			unsigned char
41 typedef unsigned char		UINT8;
42 typedef unsigned short		UINT16;
43 typedef short			INT16;
44 typedef unsigned int		UINT32;
45 typedef int			INT32;
46 typedef uint64_t		UINT64;
47 typedef int64_t			INT64;
48 #include <contrib/dev/acpica/include/acpi.h>
49 #undef BOOLEAN
50 
51 typedef ACPI_HANDLE		acpi_handle;
52 typedef ACPI_OBJECT		acpi_object;
53 typedef ACPI_OBJECT_HANDLER	acpi_object_handler;
54 typedef ACPI_OBJECT_TYPE	acpi_object_type;
55 typedef ACPI_STATUS		acpi_status;
56 typedef ACPI_STRING		acpi_string;
57 typedef ACPI_SIZE		acpi_size;
58 typedef ACPI_WALK_CALLBACK	acpi_walk_callback;
59 
60 static inline ACPI_STATUS
61 acpi_evaluate_object(ACPI_HANDLE Object, ACPI_STRING Pathname,
62     ACPI_OBJECT_LIST *ParameterObjects, ACPI_BUFFER *ReturnObjectBuffer)
63 {
64 	return (AcpiEvaluateObject(
65 	    Object, Pathname, ParameterObjects, ReturnObjectBuffer));
66 }
67 
68 static inline const char *
69 acpi_format_exception(ACPI_STATUS Exception)
70 {
71 	return (AcpiFormatException(Exception));
72 }
73 
74 static inline ACPI_STATUS
75 acpi_get_handle(ACPI_HANDLE Parent, ACPI_STRING Pathname,
76     ACPI_HANDLE *RetHandle)
77 {
78 	return (AcpiGetHandle(Parent, Pathname, RetHandle));
79 }
80 
81 static inline ACPI_STATUS
82 acpi_get_data(ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void **Data)
83 {
84 	return (AcpiGetData(ObjHandle, Handler, Data));
85 }
86 
87 static inline ACPI_STATUS
88 acpi_get_name(ACPI_HANDLE Object, UINT32 NameType, ACPI_BUFFER *RetPathPtr)
89 {
90 	return (AcpiGetName(Object, NameType, RetPathPtr));
91 }
92 
93 static inline ACPI_STATUS
94 acpi_get_table(ACPI_STRING Signature, UINT32 Instance,
95     ACPI_TABLE_HEADER **OutTable)
96 {
97 	return (AcpiGetTable(Signature, Instance, OutTable));
98 }
99 
100 static inline void
101 acpi_put_table(ACPI_TABLE_HEADER *Table)
102 {
103 	AcpiPutTable(Table);
104 }
105 
106 #endif /* _LINUXKPI_ACPI_ACPI_H_ */
107