From 271c7d36d58a90c77e0cc49e6f746939e2312a30 Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Sat, 20 Aug 2022 13:28:39 +1000 Subject: Initial commit: Can refresh source from upstream --- Makefile.refreshsrc | 23 +++++++ patches/acenv.patch | 29 ++++++++ src/Makefile | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/acgnu.h | 159 +++++++++++++++++++++++++++++++++++++++++++ src/acgnuex.h | 52 ++++++++++++++ 5 files changed, 453 insertions(+) create mode 100644 Makefile.refreshsrc create mode 100644 patches/acenv.patch create mode 100644 src/Makefile create mode 100644 src/acgnu.h create mode 100644 src/acgnuex.h diff --git a/Makefile.refreshsrc b/Makefile.refreshsrc new file mode 100644 index 0000000..2adf99f --- /dev/null +++ b/Makefile.refreshsrc @@ -0,0 +1,23 @@ +RELEASE=R03_31_22 + +fetch-source: + rm -fr acpica src/drivers src/include + git clone https://github.com/acpica/acpica.git + cd acpica && git checkout ${RELEASE} + +format-source: fetch-source + cd acpica && ./generate/linux/gen-repo.sh + +prepare-source: format-source + cd acpica/linux-* && mv drivers include ../../src + rm -fr acpica + cp src/acgnuex.h src/acgnu.h src/include/acpi/platform + cp src/drivers/acpi/acpica/utglobal.c src/include/acpi + cd src && patch -p1 < ../patches/acenv.patch + +fix-struct-struct: prepare-source + find src/drivers -type f -exec sed -i -e 's/typedef struct struct/struct/g' {} \; + find src/include -type f -exec sed -i -e 's/typedef struct struct/struct/g' {} \; + +all: fix-struct-struct + @echo "Refreshed source code from upstream ${RELEASE}" diff --git a/patches/acenv.patch b/patches/acenv.patch new file mode 100644 index 0000000..a0a466b --- /dev/null +++ b/patches/acenv.patch @@ -0,0 +1,29 @@ +diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h +index 3689c2c6..b71ecea4 100644 +--- a/include/acpi/platform/acenv.h ++++ b/include/acpi/platform/acenv.h +@@ -161,6 +161,9 @@ + #if defined(_LINUX) || defined(__linux__) + #include + ++#elif defined(__GNU__) ++#include ++ + #elif defined(_APPLE) || defined(__APPLE__) + #include "acmacosx.h" + +diff --git a/include/acpi/platform/acenvex.h b/include/acpi/platform/acenvex.h +index 277fe2fa..ede92b70 100644 +--- a/include/acpi/platform/acenvex.h ++++ b/include/acpi/platform/acenvex.h +@@ -22,6 +22,9 @@ + #if defined(_LINUX) || defined(__linux__) + #include + ++#elif defined(__GNU__) ++#include ++ + #elif defined(__DragonFly__) + #include "acdragonflyex.h" + + diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..d8cbfa4 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,190 @@ +# Copyright (C) 2022 Free Software Foundation, Inc. +# +# This is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2, or (at your option) +# any later version. +# +# This makefile is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with the GNU Hurd; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +# __KERNEL__ is needed: +# even though we are in userspace, we are acting like a kernel +# from the point of view of ACPICA +CC=gcc + +CFLAGS += -Wall -O2 -D__KERNEL__ \ + -I./include \ + -I./include/acpi/platform + +BASE = ./drivers/acpi/acpica + +SRCS = \ + $(BASE)/dsargs.c \ + $(BASE)/dscontrol.c \ + $(BASE)/dsfield.c \ + $(BASE)/dsinit.c \ + $(BASE)/dsmethod.c \ + $(BASE)/dsmthdat.c \ + $(BASE)/dsobject.c \ + $(BASE)/dsopcode.c \ + $(BASE)/dspkginit.c \ + $(BASE)/dsutils.c \ + $(BASE)/dswexec.c \ + $(BASE)/dswload.c \ + $(BASE)/dswload2.c \ + $(BASE)/dswscope.c \ + $(BASE)/dswstate.c \ + $(BASE)/evevent.c \ + $(BASE)/evgpe.c \ + $(BASE)/evgpeblk.c \ + $(BASE)/evgpeinit.c \ + $(BASE)/evgpeutil.c \ + $(BASE)/evglock.c \ + $(BASE)/evhandler.c \ + $(BASE)/evmisc.c \ + $(BASE)/evregion.c \ + $(BASE)/evsci.c \ + $(BASE)/evxface.c \ + $(BASE)/evxfevnt.c \ + $(BASE)/evxfgpe.c \ + $(BASE)/evxfregn.c \ + $(BASE)/exconcat.c \ + $(BASE)/exconfig.c \ + $(BASE)/exconvrt.c \ + $(BASE)/excreate.c \ + $(BASE)/exdebug.c \ + $(BASE)/exdump.c \ + $(BASE)/exfield.c \ + $(BASE)/exfldio.c \ + $(BASE)/exmisc.c \ + $(BASE)/exmutex.c \ + $(BASE)/exnames.c \ + $(BASE)/exoparg1.c \ + $(BASE)/exoparg2.c \ + $(BASE)/exoparg3.c \ + $(BASE)/exoparg6.c \ + $(BASE)/exprep.c \ + $(BASE)/exresnte.c \ + $(BASE)/exresolv.c \ + $(BASE)/exresop.c \ + $(BASE)/exserial.c \ + $(BASE)/exstore.c \ + $(BASE)/exstoren.c \ + $(BASE)/exstorob.c \ + $(BASE)/exsystem.c \ + $(BASE)/extrace.c \ + $(BASE)/exutils.c \ + $(BASE)/hwacpi.c \ + $(BASE)/hwesleep.c \ + $(BASE)/hwgpe.c \ + $(BASE)/hwpci.c \ + $(BASE)/hwregs.c \ + $(BASE)/hwsleep.c \ + $(BASE)/hwvalid.c \ + $(BASE)/hwxface.c \ + $(BASE)/hwxfsleep.c \ + $(BASE)/nsaccess.c \ + $(BASE)/nsalloc.c \ + $(BASE)/nsarguments.c \ + $(BASE)/nsconvert.c \ + $(BASE)/nsdump.c \ + $(BASE)/nseval.c \ + $(BASE)/nsinit.c \ + $(BASE)/nsload.c \ + $(BASE)/nsnames.c \ + $(BASE)/nsobject.c \ + $(BASE)/nsparse.c \ + $(BASE)/nspredef.c \ + $(BASE)/nsprepkg.c \ + $(BASE)/nsrepair.c \ + $(BASE)/nsrepair2.c \ + $(BASE)/nssearch.c \ + $(BASE)/nsutils.c \ + $(BASE)/nswalk.c \ + $(BASE)/nsxfeval.c \ + $(BASE)/nsxfname.c \ + $(BASE)/nsxfobj.c \ + $(BASE)/psargs.c \ + $(BASE)/psloop.c \ + $(BASE)/psobject.c \ + $(BASE)/psopcode.c \ + $(BASE)/psopinfo.c \ + $(BASE)/psparse.c \ + $(BASE)/psscope.c \ + $(BASE)/pstree.c \ + $(BASE)/psutils.c \ + $(BASE)/pswalk.c \ + $(BASE)/psxface.c \ + $(BASE)/rsaddr.c \ + $(BASE)/rscalc.c \ + $(BASE)/rscreate.c \ + $(BASE)/rsdumpinfo.c \ + $(BASE)/rsinfo.c \ + $(BASE)/rsio.c \ + $(BASE)/rsirq.c \ + $(BASE)/rslist.c \ + $(BASE)/rsmemory.c \ + $(BASE)/rsmisc.c \ + $(BASE)/rsserial.c \ + $(BASE)/rsutils.c \ + $(BASE)/rsxface.c \ + $(BASE)/tbdata.c \ + $(BASE)/tbfadt.c \ + $(BASE)/tbfind.c \ + $(BASE)/tbinstal.c \ + $(BASE)/tbprint.c \ + $(BASE)/tbutils.c \ + $(BASE)/tbxface.c \ + $(BASE)/tbxfload.c \ + $(BASE)/tbxfroot.c \ + $(BASE)/utaddress.c \ + $(BASE)/utalloc.c \ + $(BASE)/utascii.c \ + $(BASE)/utbuffer.c \ + $(BASE)/utcache.c \ + $(BASE)/utcopy.c \ + $(BASE)/utexcep.c \ + $(BASE)/utdebug.c \ + $(BASE)/utdecode.c \ + $(BASE)/utdelete.c \ + $(BASE)/uterror.c \ + $(BASE)/uteval.c \ + $(BASE)/uthex.c \ + $(BASE)/utids.c \ + $(BASE)/utinit.c \ + $(BASE)/utlock.c \ + $(BASE)/utmath.c \ + $(BASE)/utmisc.c \ + $(BASE)/utmutex.c \ + $(BASE)/utnonansi.c \ + $(BASE)/utobject.c \ + $(BASE)/utosi.c \ + $(BASE)/utownerid.c \ + $(BASE)/utpredef.c \ + $(BASE)/utresdecode.c \ + $(BASE)/utresrc.c \ + $(BASE)/utstate.c \ + $(BASE)/utstring.c \ + $(BASE)/utstrsuppt.c \ + $(BASE)/utstrtoul64.c \ + $(BASE)/utxface.c \ + $(BASE)/utxfinit.c \ + $(BASE)/utxferror.c \ + $(BASE)/utxfmutex.c \ + + +OBJS = $(SRCS:.c=.o) + +libacpica.a: $(OBJS) + ar crs $@ $(OBJS) + +clean: + rm -f $(BASE)/*.o libacpica.a + diff --git a/src/acgnu.h b/src/acgnu.h new file mode 100644 index 0000000..17c6212 --- /dev/null +++ b/src/acgnu.h @@ -0,0 +1,159 @@ +#ifndef __ACGNU_H_ +#define __ACGNU_H__ + +/* Common (in-kernel/user-space) ACPICA configuration */ + +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_DO_WHILE_0 +#define ACPI_IGNORE_PACKAGE_RESOLUTION_ERRORS +#define ACPI_LIBRARY + +#ifdef __KERNEL__ + +#define ACPI_USE_SYSTEM_INTTYPES +#define ACPI_USE_GPE_POLLING + +/* Kernel specific ACPICA configuration */ + +#define ACPI_REDUCED_HARDWARE 0 + +#ifdef CONFIG_ACPI_DEBUGGER +#define ACPI_DEBUGGER +#endif + +#ifdef CONFIG_ACPI_DEBUG +#define ACPI_MUTEX_DEBUG +#endif + +#include +#include +#include +#include +#include +#include +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; + +#define ACPI_INIT_FUNCTION + +#ifndef CONFIG_ACPI + +#undef ACPI_NO_MEM_ALLOCATIONS +#undef ACPI_NO_ERROR_MESSAGES +#define ACPI_DEBUG_OUTPUT + +#define ACPI_MEM_MAPPING struct acpi_mem_mapping + +#endif /* CONFIG_ACPI */ + +/* Host-dependent types and defines for in-kernel ACPICA */ + +#if INTPTR_MAX == 9223372036854775807L +#define ACPI_MACHINE_WIDTH 64 +#else +#define ACPI_MACHINE_WIDTH 32 +#endif + +#define ACPI_USE_NATIVE_DIVIDE +#define ACPI_USE_NATIVE_MATH64 +#define ACPI_EXPORT_SYMBOL(symbol) + +#define acpi_semaphore sem_t* +#define acpi_spinlock sem_t* +#define acpi_cpu_flags unsigned long +#define acpi_cache_t struct acpi_memory_list + +/* Use native version of acpi_os_allocate_zeroed */ + +#define USE_NATIVE_ALLOCATE_ZEROED + +/* + * Overrides for in-kernel ACPICA + */ +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock + +/* + * OSL interfaces used by debugger/disassembler + */ +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_debugger +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_debugger + +/* + * OSL interfaces used by utilities + */ +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename +#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory + +#define ACPI_MSG_ERROR "ACPI Error: " +#define ACPI_MSG_EXCEPTION "ACPI Exception: " +#define ACPI_MSG_WARNING "ACPI Warning: " +#define ACPI_MSG_INFO "ACPI: " + +#define ACPI_MSG_BIOS_ERROR "ACPI BIOS Error (bug): " +#define ACPI_MSG_BIOS_WARNING "ACPI BIOS Warning (bug): " + +/* + * Use designated initializers for function pointer structs. + */ +#define ACPI_STRUCT_INIT(field, value) .field = value + +#else /* !__KERNEL__ */ + +#define ACPI_USE_STANDARD_HEADERS + +#ifdef ACPI_USE_STANDARD_HEADERS +#include +#endif + +/* Define/disable kernel-specific declarators */ + +#ifndef __init +#define __init +#endif +#ifndef __iomem +#define __iomem +#endif + +/* Host-dependent types and defines for user-space ACPICA */ + +#define ACPI_FLUSH_CPU_CACHE() +#define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread)) + +#if INTPTR_MAX == 9223372036854775807L +#define ACPI_MACHINE_WIDTH 64 +#define COMPILER_DEPENDENT_INT64 long +#define COMPILER_DEPENDENT_UINT64 unsigned long +#else +#define ACPI_MACHINE_WIDTH 32 +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE +#define ACPI_USE_NATIVE_MATH64 +#endif + +#ifndef __cdecl +#define __cdecl +#endif + +#endif /* __KERNEL__ */ + +#endif /* __ACGNU_H__ */ diff --git a/src/acgnuex.h b/src/acgnuex.h new file mode 100644 index 0000000..420364c --- /dev/null +++ b/src/acgnuex.h @@ -0,0 +1,52 @@ +#ifndef __ACGNUEX_H__ +#define __ACGNUEX_H__ + +#ifdef __KERNEL__ + +#define ACPI_USE_LOCAL_CACHE + +/* + * Overrides for in-kernel ACPICA + */ +acpi_status ACPI_INIT_FUNCTION acpi_os_initialize(void); + +acpi_status acpi_os_terminate(void); + +static inline void *acpi_os_allocate(acpi_size size) +{ + return (void *)malloc (size); +} + +static inline void *acpi_os_allocate_zeroed(acpi_size size) +{ + return (void *)calloc (1, size); +} + +static inline void acpi_os_free(void *memory) +{ + free (memory); +} + +static inline acpi_thread_id acpi_os_get_thread_id(void) +{ + return 1; +} + +static inline u8 acpi_os_readable(void *pointer, acpi_size length) +{ + return TRUE; +} + +static inline acpi_status acpi_os_initialize_debugger(void) +{ + return 0; +} + +static inline void acpi_os_terminate_debugger(void) +{ + return; +} + +#endif /* __KERNEL__ */ + +#endif /* __ACGNUEX_H__ */ -- cgit v1.2.3