162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
262306a36Sopenharmony_ci/******************************************************************************
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Name: acenv.h - Host and compiler configuration
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (C) 2000 - 2023, Intel Corp.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci *****************************************************************************/
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef __ACENV_H__
1162306a36Sopenharmony_ci#define __ACENV_H__
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/*
1462306a36Sopenharmony_ci * Environment configuration. The purpose of this file is to interface ACPICA
1562306a36Sopenharmony_ci * to the local environment. This includes compiler-specific, OS-specific,
1662306a36Sopenharmony_ci * and machine-specific configuration.
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/* Types for ACPI_MUTEX_TYPE */
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define ACPI_BINARY_SEMAPHORE       0
2262306a36Sopenharmony_ci#define ACPI_OSL_MUTEX              1
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/* Types for DEBUGGER_THREADING */
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#define DEBUGGER_SINGLE_THREADED    0
2762306a36Sopenharmony_ci#define DEBUGGER_MULTI_THREADED     1
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/******************************************************************************
3062306a36Sopenharmony_ci *
3162306a36Sopenharmony_ci * Configuration for ACPI tools and utilities
3262306a36Sopenharmony_ci *
3362306a36Sopenharmony_ci *****************************************************************************/
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/* Common application configuration. All single threaded except for acpi_exec. */
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#if (defined ACPI_ASL_COMPILER) || \
3862306a36Sopenharmony_ci	(defined ACPI_BIN_APP)      || \
3962306a36Sopenharmony_ci	(defined ACPI_DUMP_APP)     || \
4062306a36Sopenharmony_ci	(defined ACPI_HELP_APP)     || \
4162306a36Sopenharmony_ci	(defined ACPI_NAMES_APP)    || \
4262306a36Sopenharmony_ci	(defined ACPI_SRC_APP)      || \
4362306a36Sopenharmony_ci	(defined ACPI_XTRACT_APP)   || \
4462306a36Sopenharmony_ci	(defined ACPI_EXAMPLE_APP)  || \
4562306a36Sopenharmony_ci	(defined ACPI_EFI_HELLO)
4662306a36Sopenharmony_ci#define ACPI_APPLICATION
4762306a36Sopenharmony_ci#define ACPI_SINGLE_THREADED
4862306a36Sopenharmony_ci#define USE_NATIVE_ALLOCATE_ZEROED
4962306a36Sopenharmony_ci#endif
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci/* iASL configuration */
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#ifdef ACPI_ASL_COMPILER
5462306a36Sopenharmony_ci#define ACPI_DEBUG_OUTPUT
5562306a36Sopenharmony_ci#define ACPI_CONSTANT_EVAL_ONLY
5662306a36Sopenharmony_ci#define ACPI_LARGE_NAMESPACE_NODE
5762306a36Sopenharmony_ci#define ACPI_DATA_TABLE_DISASSEMBLY
5862306a36Sopenharmony_ci#define ACPI_32BIT_PHYSICAL_ADDRESS
5962306a36Sopenharmony_ci#define ACPI_DISASSEMBLER 1
6062306a36Sopenharmony_ci#endif
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci/* acpi_exec configuration. Multithreaded with full AML debugger */
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci#ifdef ACPI_EXEC_APP
6562306a36Sopenharmony_ci#define ACPI_APPLICATION
6662306a36Sopenharmony_ci#define ACPI_FULL_DEBUG
6762306a36Sopenharmony_ci#define ACPI_MUTEX_DEBUG
6862306a36Sopenharmony_ci#define ACPI_DBG_TRACK_ALLOCATIONS
6962306a36Sopenharmony_ci#endif
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/* acpi_help configuration. Error messages disabled. */
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci#ifdef ACPI_HELP_APP
7462306a36Sopenharmony_ci#define ACPI_NO_ERROR_MESSAGES
7562306a36Sopenharmony_ci#endif
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* acpi_names configuration. Debug output enabled. */
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#ifdef ACPI_NAMES_APP
8062306a36Sopenharmony_ci#define ACPI_DEBUG_OUTPUT
8162306a36Sopenharmony_ci#endif
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci/* acpi_exec/acpi_names/Example configuration. Native RSDP used. */
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#if (defined ACPI_EXEC_APP)     || \
8662306a36Sopenharmony_ci	(defined ACPI_EXAMPLE_APP)  || \
8762306a36Sopenharmony_ci	(defined ACPI_NAMES_APP)
8862306a36Sopenharmony_ci#define ACPI_USE_NATIVE_RSDP_POINTER
8962306a36Sopenharmony_ci#endif
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci/* acpi_dump configuration. Native mapping used if provided by the host */
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#ifdef ACPI_DUMP_APP
9462306a36Sopenharmony_ci#define ACPI_USE_NATIVE_MEMORY_MAPPING
9562306a36Sopenharmony_ci#endif
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci/* acpi_names/Example configuration. Hardware disabled */
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#if (defined ACPI_EXAMPLE_APP)  || \
10062306a36Sopenharmony_ci	(defined ACPI_NAMES_APP)
10162306a36Sopenharmony_ci#define ACPI_REDUCED_HARDWARE 1
10262306a36Sopenharmony_ci#endif
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci/* Linkable ACPICA library. Two versions, one with full debug. */
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci#ifdef ACPI_LIBRARY
10762306a36Sopenharmony_ci#define ACPI_USE_LOCAL_CACHE
10862306a36Sopenharmony_ci#define ACPI_DEBUGGER 1
10962306a36Sopenharmony_ci#define ACPI_DISASSEMBLER 1
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#ifdef _DEBUG
11262306a36Sopenharmony_ci#define ACPI_DEBUG_OUTPUT
11362306a36Sopenharmony_ci#endif
11462306a36Sopenharmony_ci#endif
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci/* Common for all ACPICA applications */
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci#ifdef ACPI_APPLICATION
11962306a36Sopenharmony_ci#define ACPI_USE_LOCAL_CACHE
12062306a36Sopenharmony_ci#endif
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci/* Common debug/disassembler support */
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci#ifdef ACPI_FULL_DEBUG
12562306a36Sopenharmony_ci#define ACPI_DEBUG_OUTPUT
12662306a36Sopenharmony_ci#define ACPI_DEBUGGER 1
12762306a36Sopenharmony_ci#define ACPI_DISASSEMBLER 1
12862306a36Sopenharmony_ci#endif
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci/*
13262306a36Sopenharmony_ci * acpisrc CR\LF support
13362306a36Sopenharmony_ci * Unix file line endings do not include the carriage return.
13462306a36Sopenharmony_ci * If the acpisrc utility is being built using a microsoft compiler, it means
13562306a36Sopenharmony_ci * that it will be running on a windows machine which means that the output is
13662306a36Sopenharmony_ci * expected to have CR/LF newlines. If the acpisrc utility is built with
13762306a36Sopenharmony_ci * anything else, it will likely run on a system with LF newlines. This flag
13862306a36Sopenharmony_ci * tells the acpisrc utility that newlines will be in the LF format.
13962306a36Sopenharmony_ci */
14062306a36Sopenharmony_ci#define ACPI_SRC_OS_LF_ONLY 0
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci/*! [Begin] no source code translation */
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci/******************************************************************************
14562306a36Sopenharmony_ci *
14662306a36Sopenharmony_ci * Host configuration files. The compiler configuration files are included
14762306a36Sopenharmony_ci * first.
14862306a36Sopenharmony_ci *
14962306a36Sopenharmony_ci *****************************************************************************/
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci#if defined(__GNUC__)
15262306a36Sopenharmony_ci#include <acpi/platform/acgcc.h>
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci#elif defined(_MSC_VER)
15562306a36Sopenharmony_ci#include "acmsvc.h"
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci#endif
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci#if defined(_LINUX) || defined(__linux__)
16062306a36Sopenharmony_ci#include <acpi/platform/aclinux.h>
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci#elif defined(_APPLE) || defined(__APPLE__)
16362306a36Sopenharmony_ci#include "acmacosx.h"
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci#elif defined(__DragonFly__)
16662306a36Sopenharmony_ci#include "acdragonfly.h"
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
16962306a36Sopenharmony_ci#include "acfreebsd.h"
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci#elif defined(__NetBSD__)
17262306a36Sopenharmony_ci#include "acnetbsd.h"
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci#elif defined(__sun)
17562306a36Sopenharmony_ci#include "acsolaris.h"
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci#elif defined(MODESTO)
17862306a36Sopenharmony_ci#include "acmodesto.h"
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_ci#elif defined(NETWARE)
18162306a36Sopenharmony_ci#include "acnetware.h"
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci#elif defined(_CYGWIN)
18462306a36Sopenharmony_ci#include "accygwin.h"
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci#elif defined(WIN32)
18762306a36Sopenharmony_ci#include "acwin.h"
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci#elif defined(WIN64)
19062306a36Sopenharmony_ci#include "acwin64.h"
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci#elif defined(_WRS_LIB_BUILD)
19362306a36Sopenharmony_ci#include "acvxworks.h"
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci#elif defined(__OS2__)
19662306a36Sopenharmony_ci#include "acos2.h"
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ci#elif defined(__HAIKU__)
19962306a36Sopenharmony_ci#include "achaiku.h"
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci#elif defined(__QNX__)
20262306a36Sopenharmony_ci#include "acqnx.h"
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci/*
20562306a36Sopenharmony_ci * EFI applications can be built with -nostdlib, in this case, it must be
20662306a36Sopenharmony_ci * included after including all other host environmental definitions, in
20762306a36Sopenharmony_ci * order to override the definitions.
20862306a36Sopenharmony_ci */
20962306a36Sopenharmony_ci#elif defined(_AED_EFI) || defined(_GNU_EFI) || defined(_EDK2_EFI)
21062306a36Sopenharmony_ci#include "acefi.h"
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci#elif defined(__ZEPHYR__)
21362306a36Sopenharmony_ci#include "aczephyr.h"
21462306a36Sopenharmony_ci#else
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci/* Unknown environment */
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci#error Unknown target environment
21962306a36Sopenharmony_ci#endif
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci/*! [End] no source code translation !*/
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci/******************************************************************************
22462306a36Sopenharmony_ci *
22562306a36Sopenharmony_ci * Setup defaults for the required symbols that were not defined in one of
22662306a36Sopenharmony_ci * the host/compiler files above.
22762306a36Sopenharmony_ci *
22862306a36Sopenharmony_ci *****************************************************************************/
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci/* 64-bit data types */
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci#ifndef COMPILER_DEPENDENT_INT64
23362306a36Sopenharmony_ci#define COMPILER_DEPENDENT_INT64   long long
23462306a36Sopenharmony_ci#endif
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci#ifndef COMPILER_DEPENDENT_UINT64
23762306a36Sopenharmony_ci#define COMPILER_DEPENDENT_UINT64  unsigned long long
23862306a36Sopenharmony_ci#endif
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci/* Type of mutex supported by host. Default is binary semaphores. */
24162306a36Sopenharmony_ci#ifndef ACPI_MUTEX_TYPE
24262306a36Sopenharmony_ci#define ACPI_MUTEX_TYPE             ACPI_BINARY_SEMAPHORE
24362306a36Sopenharmony_ci#endif
24462306a36Sopenharmony_ci
24562306a36Sopenharmony_ci/* Global Lock acquire/release */
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci#ifndef ACPI_ACQUIRE_GLOBAL_LOCK
24862306a36Sopenharmony_ci#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acquired) acquired = 1
24962306a36Sopenharmony_ci#endif
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci#ifndef ACPI_RELEASE_GLOBAL_LOCK
25262306a36Sopenharmony_ci#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, pending) pending = 0
25362306a36Sopenharmony_ci#endif
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci/* Flush CPU cache - used when going to sleep. Wbinvd or similar. */
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ci#ifndef ACPI_FLUSH_CPU_CACHE
25862306a36Sopenharmony_ci#define ACPI_FLUSH_CPU_CACHE()
25962306a36Sopenharmony_ci#endif
26062306a36Sopenharmony_ci
26162306a36Sopenharmony_ci/* "inline" keywords - configurable since inline is not standardized */
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_ci#ifndef ACPI_INLINE
26462306a36Sopenharmony_ci#define ACPI_INLINE
26562306a36Sopenharmony_ci#endif
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ci/* Use ordered initialization if compiler doesn't support designated. */
26862306a36Sopenharmony_ci#ifndef ACPI_STRUCT_INIT
26962306a36Sopenharmony_ci#define ACPI_STRUCT_INIT(field, value)  value
27062306a36Sopenharmony_ci#endif
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ci/*
27362306a36Sopenharmony_ci * Configurable calling conventions:
27462306a36Sopenharmony_ci *
27562306a36Sopenharmony_ci * ACPI_SYSTEM_XFACE        - Interfaces to host OS (handlers, threads)
27662306a36Sopenharmony_ci * ACPI_EXTERNAL_XFACE      - External ACPI interfaces
27762306a36Sopenharmony_ci * ACPI_INTERNAL_XFACE      - Internal ACPI interfaces
27862306a36Sopenharmony_ci * ACPI_INTERNAL_VAR_XFACE  - Internal variable-parameter list interfaces
27962306a36Sopenharmony_ci */
28062306a36Sopenharmony_ci#ifndef ACPI_SYSTEM_XFACE
28162306a36Sopenharmony_ci#define ACPI_SYSTEM_XFACE
28262306a36Sopenharmony_ci#endif
28362306a36Sopenharmony_ci
28462306a36Sopenharmony_ci#ifndef ACPI_EXTERNAL_XFACE
28562306a36Sopenharmony_ci#define ACPI_EXTERNAL_XFACE
28662306a36Sopenharmony_ci#endif
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ci#ifndef ACPI_INTERNAL_XFACE
28962306a36Sopenharmony_ci#define ACPI_INTERNAL_XFACE
29062306a36Sopenharmony_ci#endif
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_ci#ifndef ACPI_INTERNAL_VAR_XFACE
29362306a36Sopenharmony_ci#define ACPI_INTERNAL_VAR_XFACE
29462306a36Sopenharmony_ci#endif
29562306a36Sopenharmony_ci
29662306a36Sopenharmony_ci/*
29762306a36Sopenharmony_ci * Debugger threading model
29862306a36Sopenharmony_ci * Use single threaded if the entire subsystem is contained in an application
29962306a36Sopenharmony_ci * Use multiple threaded when the subsystem is running in the kernel.
30062306a36Sopenharmony_ci *
30162306a36Sopenharmony_ci * By default the model is single threaded if ACPI_APPLICATION is set,
30262306a36Sopenharmony_ci * multi-threaded if ACPI_APPLICATION is not set.
30362306a36Sopenharmony_ci */
30462306a36Sopenharmony_ci#ifndef DEBUGGER_THREADING
30562306a36Sopenharmony_ci#if !defined (ACPI_APPLICATION) || defined (ACPI_EXEC_APP)
30662306a36Sopenharmony_ci#define DEBUGGER_THREADING          DEBUGGER_MULTI_THREADED
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ci#else
30962306a36Sopenharmony_ci#define DEBUGGER_THREADING          DEBUGGER_SINGLE_THREADED
31062306a36Sopenharmony_ci#endif
31162306a36Sopenharmony_ci#endif				/* !DEBUGGER_THREADING */
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci/******************************************************************************
31462306a36Sopenharmony_ci *
31562306a36Sopenharmony_ci * C library configuration
31662306a36Sopenharmony_ci *
31762306a36Sopenharmony_ci *****************************************************************************/
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci/*
32062306a36Sopenharmony_ci * ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.
32162306a36Sopenharmony_ci *      Otherwise, local versions of string/memory functions will be used.
32262306a36Sopenharmony_ci * ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
32362306a36Sopenharmony_ci *      the standard header files may be used. Defining this implies that
32462306a36Sopenharmony_ci *      ACPI_USE_SYSTEM_CLIBRARY has been defined.
32562306a36Sopenharmony_ci *
32662306a36Sopenharmony_ci * The ACPICA subsystem only uses low level C library functions that do not
32762306a36Sopenharmony_ci * call operating system services and may therefore be inlined in the code.
32862306a36Sopenharmony_ci *
32962306a36Sopenharmony_ci * It may be necessary to tailor these include files to the target
33062306a36Sopenharmony_ci * generation environment.
33162306a36Sopenharmony_ci */
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci/* Use the standard C library headers. We want to keep these to a minimum. */
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci#ifdef ACPI_USE_STANDARD_HEADERS
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_ci/* Use the standard headers from the standard locations */
33862306a36Sopenharmony_ci
33962306a36Sopenharmony_ci#include <stdlib.h>
34062306a36Sopenharmony_ci#include <string.h>
34162306a36Sopenharmony_ci#include <ctype.h>
34262306a36Sopenharmony_ci#if defined (ACPI_APPLICATION) || defined(ACPI_LIBRARY)
34362306a36Sopenharmony_ci#include <stdio.h>
34462306a36Sopenharmony_ci#include <fcntl.h>
34562306a36Sopenharmony_ci#include <errno.h>
34662306a36Sopenharmony_ci#include <time.h>
34762306a36Sopenharmony_ci#include <signal.h>
34862306a36Sopenharmony_ci#endif
34962306a36Sopenharmony_ci
35062306a36Sopenharmony_ci#endif				/* ACPI_USE_STANDARD_HEADERS */
35162306a36Sopenharmony_ci
35262306a36Sopenharmony_ci#ifdef ACPI_APPLICATION
35362306a36Sopenharmony_ci#define ACPI_FILE              FILE *
35462306a36Sopenharmony_ci#define ACPI_FILE_OUT          stdout
35562306a36Sopenharmony_ci#define ACPI_FILE_ERR          stderr
35662306a36Sopenharmony_ci#else
35762306a36Sopenharmony_ci#define ACPI_FILE              void *
35862306a36Sopenharmony_ci#define ACPI_FILE_OUT          NULL
35962306a36Sopenharmony_ci#define ACPI_FILE_ERR          NULL
36062306a36Sopenharmony_ci#endif				/* ACPI_APPLICATION */
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_ci#ifndef ACPI_INIT_FUNCTION
36362306a36Sopenharmony_ci#define ACPI_INIT_FUNCTION
36462306a36Sopenharmony_ci#endif
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ci#endif				/* __ACENV_H__ */
367