Re: [PATCH 2/5] libacpica: Add config for GNU

2021-04-03 Thread Samuel Thibault
Samuel Thibault, le sam. 03 avril 2021 14:41:59 +0200, a ecrit:
> Damien Zammit, le sam. 03 avril 2021 23:16:32 +1100, a ecrit:
> > +#define acpi_semaphore  sem_t*
> 
> ? Rather a sem_t, no ? Otherwise you have to uselessly handle
> allocations etc. while the caller can do it.

+acpi_os_wait_semaphore(acpi_semaphore handle, u32 units, u16 timeout)

Ah, no, ok, it's really meant to be a handle, so yes you have to make it
a *.

> > +#define acpi_spinlock   sem_t*

But for this one I believe it should be a sem_t, since:

acpi_os_create_lock(acpi_spinlock *lockp)

a pointer to it is given.

Samuel



Re: [PATCH 2/5] libacpica: Add config for GNU

2021-04-03 Thread Samuel Thibault
Damien Zammit, le sam. 03 avril 2021 23:16:32 +1100, a ecrit:
> +#define acpi_semaphore  sem_t*
> +#define acpi_spinlock   sem_t*

? Rather a sem_t, no ? Otherwise you have to uselessly handle
allocations etc. while the caller can do it.

Samuel



[PATCH 2/5] libacpica: Add config for GNU

2021-04-03 Thread Damien Zammit
---
 libacpica/acpi/platform/acenv.h   |   3 +
 libacpica/acpi/platform/acenvex.h |   3 +
 libacpica/acpi/platform/acgnu.h   | 159 ++
 libacpica/acpi/platform/acgnuex.h |  52 ++
 4 files changed, 217 insertions(+)
 create mode 100644 libacpica/acpi/platform/acgnu.h
 create mode 100644 libacpica/acpi/platform/acgnuex.h

diff --git a/libacpica/acpi/platform/acenv.h b/libacpica/acpi/platform/acenv.h
index 3689c2c6..b71ecea4 100644
--- a/libacpica/acpi/platform/acenv.h
+++ b/libacpica/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/libacpica/acpi/platform/acenvex.h 
b/libacpica/acpi/platform/acenvex.h
index 277fe2fa..ede92b70 100644
--- a/libacpica/acpi/platform/acenvex.h
+++ b/libacpica/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/libacpica/acpi/platform/acgnu.h b/libacpica/acpi/platform/acgnu.h
new file mode 100644
index ..17c62124
--- /dev/null
+++ b/libacpica/acpi/platform/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_tstruct 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_C