The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=2ddfcc013c251f13c8c9b24970b8134ddd49afea
commit 2ddfcc013c251f13c8c9b24970b8134ddd49afea Author: Bjoern A. Zeeb <b...@freebsd.org> AuthorDate: 2025-06-15 10:38:56 +0000 Commit: Bjoern A. Zeeb <b...@freebsd.org> CommitDate: 2025-07-04 03:22:22 +0000 LinuxKPI: acpi: provide union [linuxkpi]_acpi_(object|buffer) Provide union acpi_(object|buffer) as linuxkpi_ versions and in Linux native lower case spelling so that driver code compiles unmodified. Use the linuxkpi_ prefix to avoid name clashes with the native ACPI implementation which uses CamelCase. Use the linuxkpi_ names internally and redefine the linuxkpi_ unions to their native names so they are avail as expected in drivers. As a transition to not break drm-kmod which has in-place (no #ifdef) changes from Linux spelling ot FreeBSD spelling, introduce LINUXKPI_WANT_LINUX_ACPI so we have the Linux spelling as an opt-in. That way the transition can happen gracefully and once "top-of-trees" are all sorted we can remove the #ifdefs here again. Bump __FreeBSD_version to be able to detect this change. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: wulf (previous version), dumbbell Differential Revision: https://reviews.freebsd.org/D50863 --- sys/compat/linuxkpi/common/include/acpi/acpi.h | 76 ++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/acpi/acpi.h b/sys/compat/linuxkpi/common/include/acpi/acpi.h index e0218bdde12e..1e398d05ba20 100644 --- a/sys/compat/linuxkpi/common/include/acpi/acpi.h +++ b/sys/compat/linuxkpi/common/include/acpi/acpi.h @@ -3,6 +3,10 @@ * * Copyright (c) 2017 Mark Johnston <ma...@freebsd.org> * Copyright (c) 2020 Vladimir Kondratyev <w...@freebsd.org> + * Copyright (c) 2025 The FreeBSD Foundation + * + * Portions of this software were developed by Björn Zeeb + * under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,6 +34,13 @@ #ifndef _LINUXKPI_ACPI_ACPI_H_ #define _LINUXKPI_ACPI_ACPI_H_ +/* + * LINUXKPI_WANT_LINUX_ACPI is a temporary workaround to allow drm-kmod + * to update all needed branches without breaking builds. + * Once that happened and checks are implemented based on __FreeBSD_verison + * we will remove these conditions again. + */ + /* * FreeBSD import of ACPICA has a typedef for BOOLEAN which conflicts with * amdgpu driver. Workaround it on preprocessor level. @@ -46,8 +57,8 @@ typedef int64_t INT64; #include <contrib/dev/acpica/include/acpi.h> #undef BOOLEAN +typedef ACPI_IO_ADDRESS acpi_io_address; 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; @@ -55,12 +66,62 @@ typedef ACPI_STRING acpi_string; typedef ACPI_SIZE acpi_size; typedef ACPI_WALK_CALLBACK acpi_walk_callback; +union linuxkpi_acpi_object { + acpi_object_type type; + struct { + acpi_object_type type; + UINT64 value; + } integer; + struct { + acpi_object_type type; + UINT32 length; + char *pointer; + } string; + struct { + acpi_object_type type; + UINT32 length; + UINT8 *pointer; + } buffer; + struct { + acpi_object_type type; + UINT32 count; + union linuxkpi_acpi_object *elements; + } package; + struct { + acpi_object_type type; + acpi_object_type actual_type; + acpi_handle handle; + } reference; + struct { + acpi_object_type type; + UINT32 proc_id; + acpi_io_address pblk_address; + UINT32 pblk_length; + } processor; + struct { + acpi_object_type type; + UINT32 system_level; + UINT32 resource_order; + } power_resource; +}; + +#ifdef LINUXKPI_WANT_LINUX_ACPI +struct linuxkpi_acpi_buffer { + acpi_size length; /* Length in bytes of the buffer */ + void *pointer; /* pointer to buffer */ +}; + +typedef struct linuxkpi_acpi_buffer lkpi_acpi_buffer_t; +#else +typedef ACPI_BUFFER lkpi_acpi_buffer_t; +#endif + static inline ACPI_STATUS acpi_evaluate_object(ACPI_HANDLE Object, ACPI_STRING Pathname, - ACPI_OBJECT_LIST *ParameterObjects, ACPI_BUFFER *ReturnObjectBuffer) + ACPI_OBJECT_LIST *ParameterObjects, lkpi_acpi_buffer_t *ReturnObjectBuffer) { return (AcpiEvaluateObject( - Object, Pathname, ParameterObjects, ReturnObjectBuffer)); + Object, Pathname, ParameterObjects, (ACPI_BUFFER *)ReturnObjectBuffer)); } static inline const char * @@ -83,9 +144,9 @@ acpi_get_data(ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void **Data) } static inline ACPI_STATUS -acpi_get_name(ACPI_HANDLE Object, UINT32 NameType, ACPI_BUFFER *RetPathPtr) +acpi_get_name(ACPI_HANDLE Object, UINT32 NameType, lkpi_acpi_buffer_t *RetPathPtr) { - return (AcpiGetName(Object, NameType, RetPathPtr)); + return (AcpiGetName(Object, NameType, (ACPI_BUFFER *)RetPathPtr)); } static inline ACPI_STATUS @@ -101,4 +162,9 @@ acpi_put_table(ACPI_TABLE_HEADER *Table) AcpiPutTable(Table); } +#ifdef LINUXKPI_WANT_LINUX_ACPI +#define acpi_object linuxkpi_acpi_object +#define acpi_buffer linuxkpi_acpi_buffer +#endif + #endif /* _LINUXKPI_ACPI_ACPI_H_ */