#ifndef __ACEFI_H__
#define __ACEFI_H__
+/*
+ * Single threaded environment where Mutex/Event/Sleep are fake. This model is
+ * sufficient for pre-boot AcpiExec.
+ */
+#ifndef DEBUGGER_THREADING
+#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
+#endif /* !DEBUGGER_THREADING */
+
/* EDK2 EFI environemnt */
#if defined(_EDK2_EFI)
-#define _GNU_EFI
+#ifdef USE_STDLIB
+#define ACPI_USE_STANDARD_HEADERS
+#define ACPI_USE_SYSTEM_CLIBRARY
+#define ACPI_USE_NATIVE_DIVIDE
+#define ACPI_USE_NATIVE_MATH64
+#endif
#endif
#endif
+#ifndef USE_STDLIB
#define UINTN uint64_t
#define INTN int64_t
+#endif
#define ACPI_EFI_ERR(a) (0x8000000000000000 | a)
#define ACPI_MACHINE_WIDTH 32
+#ifndef USE_STDLIB
#define UINTN uint32_t
#define INTN int32_t
+#endif
#define ACPI_EFI_ERR(a) (0x80000000 | a)
#endif
-/* GNU EFI definitions */
-
-#if defined(_GNU_EFI)
+/* EFI math64 definitions */
+#if defined(_GNU_EFI) || defined(_EDK2_EFI)
/*
- * Math helpers
+ * Math helpers, GNU EFI provided a platform independent 64-bit math
+ * support.
*/
-#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
+#ifndef ACPI_DIV_64_BY_32
+#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
+ do { \
+ UINT64 __n = ((UINT64) n_hi) << 32 | (n_lo); \
+ (q32) = (UINT32) DivU64x32 ((__n), (d32), &(r32)); \
+ } while (0)
+#endif
+
+#ifndef ACPI_MUL_64_BY_32
+#define ACPI_MUL_64_BY_32(n_hi, n_lo, m32, p32, c32) \
+ do { \
+ UINT64 __n = ((UINT64) n_hi) << 32 | (n_lo); \
+ UINT64 __p = MultU64x32 (__n, (m32)); \
+ (p32) = (UINT32) __p; \
+ (c32) = (UINT32) (__p >> 32); \
+ } while (0)
+#endif
+
+#ifndef ACPI_SHIFT_LEFT_64_by_32
+#define ACPI_SHIFT_LEFT_64_BY_32(n_hi, n_lo, s32) \
+ do { \
+ UINT64 __n = ((UINT64) n_hi) << 32 | (n_lo); \
+ UINT64 __r = LShiftU64 (__n, (s32)); \
+ (n_lo) = (UINT32) __r; \
+ (n_hi) = (UINT32) (__r >> 32); \
+ } while (0)
+#endif
+
+#ifndef ACPI_SHIFT_RIGHT_64_BY_32
+#define ACPI_SHIFT_RIGHT_64_BY_32(n_hi, n_lo, s32) \
do { \
UINT64 __n = ((UINT64) n_hi) << 32 | (n_lo); \
- (q32) = DivU64x32 ((__n), (d32), &(r32)); \
+ UINT64 __r = RShiftU64 (__n, (s32)); \
+ (n_lo) = (UINT32) __r; \
+ (n_hi) = (UINT32) (__r >> 32); \
} while (0)
+#endif
+#ifndef ACPI_SHIFT_RIGHT_64
#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
do { \
(n_lo) >>= 1; \
(n_lo) |= (((n_hi) & 1) << 31); \
(n_hi) >>= 1; \
} while (0)
-
+#endif
#endif
struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE;
struct _ACPI_EFI_FILE_IO_INTERFACE;
struct _ACPI_EFI_FILE_HANDLE;
struct _ACPI_EFI_BOOT_SERVICES;
+struct _ACPI_EFI_RUNTIME_SERVICES;
struct _ACPI_EFI_SYSTEM_TABLE;
struct _ACPI_EFI_PCI_IO;
extern struct _ACPI_EFI_SYSTEM_TABLE *ST;
extern struct _ACPI_EFI_BOOT_SERVICES *BS;
+extern struct _ACPI_EFI_RUNTIME_SERVICES *RT;
+#ifndef USE_STDLIB
typedef union acpi_efi_file ACPI_EFI_FILE;
#define FILE ACPI_EFI_FILE
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
+#endif
#endif /* __ACEFI_H__ */