Path: blob/main/sys/compat/linuxkpi/common/include/acpi/acpi.h
39604 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2017 Mark Johnston <[email protected]>4* Copyright (c) 2020 Vladimir Kondratyev <[email protected]>5* Copyright (c) 2025 The FreeBSD Foundation6*7* Portions of this software were developed by Björn Zeeb8* under sponsorship from the FreeBSD Foundation.9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions are12* met:13* 1. Redistributions of source code must retain the above copyright14* notice, this list of conditions and the following disclaimer.15* 2. Redistributions in binary form must reproduce the above copyright16* notice, this list of conditions and the following disclaimer in17* the documentation and/or other materials provided with the18* distribution.19*20* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#ifndef _LINUXKPI_ACPI_ACPI_H_34#define _LINUXKPI_ACPI_ACPI_H_3536/*37* LINUXKPI_WANT_LINUX_ACPI is a temporary workaround to allow drm-kmod38* to update all needed branches without breaking builds.39* Once that happened and checks are implemented based on __FreeBSD_version40* we will remove these conditions again.41*/4243/*44* FreeBSD import of ACPICA has a typedef for BOOLEAN which conflicts with45* amdgpu driver. Workaround it on preprocessor level.46*/47#define ACPI_USE_SYSTEM_INTTYPES48#define BOOLEAN unsigned char49typedef unsigned char UINT8;50typedef unsigned short UINT16;51typedef short INT16;52typedef unsigned int UINT32;53typedef int INT32;54typedef uint64_t UINT64;55typedef int64_t INT64;56#include <contrib/dev/acpica/include/acpi.h>57#undef BOOLEAN5859typedef ACPI_IO_ADDRESS acpi_io_address;60typedef ACPI_HANDLE acpi_handle;61typedef ACPI_OBJECT_HANDLER acpi_object_handler;62typedef ACPI_OBJECT_TYPE acpi_object_type;63typedef ACPI_STATUS acpi_status;64typedef ACPI_STRING acpi_string;65typedef ACPI_SIZE acpi_size;66typedef ACPI_WALK_CALLBACK acpi_walk_callback;6768union linuxkpi_acpi_object {69acpi_object_type type;70struct {71acpi_object_type type;72UINT64 value;73} integer;74struct {75acpi_object_type type;76UINT32 length;77char *pointer;78} string;79struct {80acpi_object_type type;81UINT32 length;82UINT8 *pointer;83} buffer;84struct {85acpi_object_type type;86UINT32 count;87union linuxkpi_acpi_object *elements;88} package;89struct {90acpi_object_type type;91acpi_object_type actual_type;92acpi_handle handle;93} reference;94struct {95acpi_object_type type;96UINT32 proc_id;97acpi_io_address pblk_address;98UINT32 pblk_length;99} processor;100struct {101acpi_object_type type;102UINT32 system_level;103UINT32 resource_order;104} power_resource;105};106107#ifdef LINUXKPI_WANT_LINUX_ACPI108struct linuxkpi_acpi_buffer {109acpi_size length; /* Length in bytes of the buffer */110void *pointer; /* pointer to buffer */111};112113typedef struct linuxkpi_acpi_buffer lkpi_acpi_buffer_t;114#else115typedef ACPI_BUFFER lkpi_acpi_buffer_t;116#endif117118static inline ACPI_STATUS119acpi_evaluate_object(ACPI_HANDLE Object, ACPI_STRING Pathname,120ACPI_OBJECT_LIST *ParameterObjects, lkpi_acpi_buffer_t *ReturnObjectBuffer)121{122return (AcpiEvaluateObject(123Object, Pathname, ParameterObjects, (ACPI_BUFFER *)ReturnObjectBuffer));124}125126static inline const char *127acpi_format_exception(ACPI_STATUS Exception)128{129return (AcpiFormatException(Exception));130}131132static inline ACPI_STATUS133acpi_get_handle(ACPI_HANDLE Parent, const char *Pathname,134ACPI_HANDLE *RetHandle)135{136return (AcpiGetHandle(Parent, Pathname, RetHandle));137}138139static inline ACPI_STATUS140acpi_get_data(ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void **Data)141{142return (AcpiGetData(ObjHandle, Handler, Data));143}144145static inline ACPI_STATUS146acpi_get_name(ACPI_HANDLE Object, UINT32 NameType, lkpi_acpi_buffer_t *RetPathPtr)147{148return (AcpiGetName(Object, NameType, (ACPI_BUFFER *)RetPathPtr));149}150151static inline ACPI_STATUS152acpi_get_table(ACPI_STRING Signature, UINT32 Instance,153ACPI_TABLE_HEADER **OutTable)154{155return (AcpiGetTable(Signature, Instance, OutTable));156}157158static inline void159acpi_put_table(ACPI_TABLE_HEADER *Table)160{161AcpiPutTable(Table);162}163164#ifdef LINUXKPI_WANT_LINUX_ACPI165#define acpi_object linuxkpi_acpi_object166#define acpi_buffer linuxkpi_acpi_buffer167#endif168169#endif /* _LINUXKPI_ACPI_ACPI_H_ */170171172