2018-03-15 07:13:07 +08:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
|
2005-04-17 06:20:36 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2009-04-22 13:39:47 +08:00
|
|
|
* Name: aclinux.h - OS specific defines, etc. for Linux
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2018-01-05 02:06:38 +08:00
|
|
|
* Copyright (C) 2000 - 2018, Intel Corp.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2018-03-15 07:13:07 +08:00
|
|
|
*****************************************************************************/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifndef __ACLINUX_H__
|
|
|
|
#define __ACLINUX_H__
|
|
|
|
|
2014-07-16 16:58:53 +08:00
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
/* ACPICA external files should not include ACPICA headers directly. */
|
|
|
|
|
|
|
|
#if !defined(BUILDING_ACPICA) && !defined(_LINUX_ACPI_H)
|
|
|
|
#error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-04-22 13:39:47 +08:00
|
|
|
/* Common (in-kernel/user-space) ACPICA configuration */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define ACPI_USE_SYSTEM_CLIBRARY
|
|
|
|
#define ACPI_USE_DO_WHILE_0
|
2018-02-16 05:09:31 +08:00
|
|
|
#define ACPI_IGNORE_PACKAGE_RESOLUTION_ERRORS
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2014-02-11 10:51:43 +08:00
|
|
|
#define ACPI_USE_SYSTEM_INTTYPES
|
2018-03-15 07:12:59 +08:00
|
|
|
#define ACPI_USE_GPE_POLLING
|
2014-02-11 10:51:43 +08:00
|
|
|
|
2015-10-19 10:25:56 +08:00
|
|
|
/* Kernel specific ACPICA configuration */
|
2014-01-18 02:51:30 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY
|
|
|
|
#define ACPI_REDUCED_HARDWARE 1
|
|
|
|
#endif
|
|
|
|
|
2015-10-19 10:25:56 +08:00
|
|
|
#ifdef CONFIG_ACPI_DEBUGGER
|
|
|
|
#define ACPI_DEBUGGER
|
|
|
|
#endif
|
|
|
|
|
2016-07-05 13:53:04 +08:00
|
|
|
#ifdef CONFIG_ACPI_DEBUG
|
|
|
|
#define ACPI_MUTEX_DEBUG
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/ctype.h>
|
2008-09-26 01:40:30 +08:00
|
|
|
#include <linux/sched.h>
|
2011-07-27 07:09:06 +08:00
|
|
|
#include <linux/atomic.h>
|
2013-10-29 09:30:41 +08:00
|
|
|
#include <linux/math64.h>
|
2006-10-03 12:00:00 +08:00
|
|
|
#include <linux/slab.h>
|
2006-06-24 05:04:00 +08:00
|
|
|
#include <linux/spinlock_types.h>
|
2013-10-29 09:30:41 +08:00
|
|
|
#ifdef EXPORT_ACPI_INTERFACES
|
|
|
|
#include <linux/export.h>
|
|
|
|
#endif
|
2014-07-16 16:58:08 +08:00
|
|
|
#ifdef CONFIG_ACPI
|
2014-05-12 15:46:38 +08:00
|
|
|
#include <asm/acenv.h>
|
2014-07-16 16:58:08 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-08-04 16:43:19 +08:00
|
|
|
#define ACPI_INIT_FUNCTION __init
|
|
|
|
|
2014-04-30 10:05:15 +08:00
|
|
|
#ifndef CONFIG_ACPI
|
|
|
|
|
|
|
|
/* External globals for __KERNEL__, stubs is needed */
|
|
|
|
|
|
|
|
#define ACPI_GLOBAL(t,a)
|
|
|
|
#define ACPI_INIT_GLOBAL(t,a,b)
|
|
|
|
|
|
|
|
/* Generating stubs for configurable ACPICA macros */
|
|
|
|
|
|
|
|
#define ACPI_NO_MEM_ALLOCATIONS
|
|
|
|
|
|
|
|
/* Generating stubs for configurable ACPICA functions */
|
|
|
|
|
|
|
|
#define ACPI_NO_ERROR_MESSAGES
|
|
|
|
#undef ACPI_DEBUG_OUTPUT
|
|
|
|
|
|
|
|
/* External interface for __KERNEL__, stub is needed */
|
|
|
|
|
|
|
|
#define ACPI_EXTERNAL_RETURN_STATUS(prototype) \
|
|
|
|
static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);}
|
|
|
|
#define ACPI_EXTERNAL_RETURN_OK(prototype) \
|
|
|
|
static ACPI_INLINE prototype {return(AE_OK);}
|
|
|
|
#define ACPI_EXTERNAL_RETURN_VOID(prototype) \
|
|
|
|
static ACPI_INLINE prototype {return;}
|
|
|
|
#define ACPI_EXTERNAL_RETURN_UINT32(prototype) \
|
|
|
|
static ACPI_INLINE prototype {return(0);}
|
|
|
|
#define ACPI_EXTERNAL_RETURN_PTR(prototype) \
|
|
|
|
static ACPI_INLINE prototype {return(NULL);}
|
|
|
|
|
|
|
|
#endif /* CONFIG_ACPI */
|
|
|
|
|
2009-04-22 13:39:47 +08:00
|
|
|
/* Host-dependent types and defines for in-kernel ACPICA */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-10-03 12:00:00 +08:00
|
|
|
#define ACPI_MACHINE_WIDTH BITS_PER_LONG
|
2017-08-03 14:26:50 +08:00
|
|
|
#define ACPI_USE_NATIVE_MATH64
|
2006-10-03 12:00:00 +08:00
|
|
|
#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
|
|
|
|
#define strtoul simple_strtoul
|
ACPICA 20050617-0624 from Bob Moore <robert.moore@intel.com>
ACPICA 20050617:
Moved the object cache operations into the OS interface
layer (OSL) to allow the host OS to handle these operations
if desired (for example, the Linux OSL will invoke the
slab allocator). This support is optional; the compile
time define ACPI_USE_LOCAL_CACHE may be used to utilize
the original cache code in the ACPI CA core. The new OSL
interfaces are shown below. See utalloc.c for an example
implementation, and acpiosxf.h for the exact interface
definitions. Thanks to Alexey Starikovskiy.
acpi_os_create_cache
acpi_os_delete_cache
acpi_os_purge_cache
acpi_os_acquire_object
acpi_os_release_object
Modified the interfaces to acpi_os_acquire_lock and
acpi_os_release_lock to return and restore a flags
parameter. This fits better with many OS lock models.
Note: the current execution state (interrupt handler
or not) is no longer passed to these interfaces. If
necessary, the OSL must determine this state by itself, a
simple and fast operation. Thanks to Alexey Starikovskiy.
Fixed a problem in the ACPI table handling where a valid
XSDT was assumed present if the revision of the RSDP
was 2 or greater. According to the ACPI specification,
the XSDT is optional in all cases, and the table manager
therefore now checks for both an RSDP >=2 and a valid
XSDT pointer. Otherwise, the RSDT pointer is used.
Some ACPI 2.0 compliant BIOSs contain only the RSDT.
Fixed an interpreter problem with the Mid() operator in the
case of an input string where the resulting output string
is of zero length. It now correctly returns a valid,
null terminated string object instead of a string object
with a null pointer.
Fixed a problem with the control method argument handling
to allow a store to an Arg object that already contains an
object of type Device. The Device object is now correctly
overwritten. Previously, an error was returned.
ACPICA 20050624:
Modified the new OSL cache interfaces to use ACPI_CACHE_T
as the type for the host-defined cache object. This allows
the OSL implementation to define and type this object in
any manner desired, simplifying the OSL implementation.
For example, ACPI_CACHE_T is defined as kmem_cache_t for
Linux, and should be defined in the OS-specific header
file for other operating systems as required.
Changed the interface to AcpiOsAcquireObject to directly
return the requested object as the function return (instead
of ACPI_STATUS.) This change was made for performance
reasons, since this is the purpose of the interface in the
first place. acpi_os_acquire_object is now similar to the
acpi_os_allocate interface. Thanks to Alexey Starikovskiy.
Modified the initialization sequence in
acpi_initialize_subsystem to call the OSL interface
acpi_osl_initialize first, before any local initialization.
This change was required because the global initialization
now calls OSL interfaces.
Restructured the code base to split some files because
of size and/or because the code logically belonged in a
separate file. New files are listed below.
utilities/utcache.c /* Local cache interfaces */
utilities/utmutex.c /* Local mutex support */
utilities/utstate.c /* State object support */
parser/psloop.c /* Main AML parse loop */
Signed-off-by: Len Brown <len.brown@intel.com>
2005-06-24 12:00:00 +08:00
|
|
|
|
2009-04-22 13:39:47 +08:00
|
|
|
#define acpi_cache_t struct kmem_cache
|
|
|
|
#define acpi_spinlock spinlock_t *
|
|
|
|
#define acpi_cpu_flags unsigned long
|
|
|
|
|
2014-05-12 15:46:32 +08:00
|
|
|
/* Use native linux 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_acquire_object
|
|
|
|
#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
|
2016-12-28 15:28:07 +08:00
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_debugger
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_debugger
|
2014-05-12 15:46:32 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2016-08-04 16:42:49 +08:00
|
|
|
#define ACPI_MSG_ERROR KERN_ERR "ACPI Error: "
|
|
|
|
#define ACPI_MSG_EXCEPTION KERN_ERR "ACPI Exception: "
|
|
|
|
#define ACPI_MSG_WARNING KERN_WARNING "ACPI Warning: "
|
|
|
|
#define ACPI_MSG_INFO KERN_INFO "ACPI: "
|
|
|
|
|
|
|
|
#define ACPI_MSG_BIOS_ERROR KERN_ERR "ACPI BIOS Error (bug): "
|
|
|
|
#define ACPI_MSG_BIOS_WARNING KERN_WARNING "ACPI BIOS Warning (bug): "
|
|
|
|
|
2017-07-10 15:23:08 +08:00
|
|
|
/*
|
|
|
|
* Linux wants to use designated initializers for function pointer structs.
|
|
|
|
*/
|
2017-06-27 06:53:07 +08:00
|
|
|
#define ACPI_STRUCT_INIT(field, value) .field = value
|
|
|
|
|
2013-10-29 09:29:51 +08:00
|
|
|
#else /* !__KERNEL__ */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-08-04 16:44:44 +08:00
|
|
|
#define ACPI_USE_STANDARD_HEADERS
|
|
|
|
|
|
|
|
#ifdef ACPI_USE_STANDARD_HEADERS
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <unistd.h>
|
2016-08-04 16:44:44 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-04-04 12:37:59 +08:00
|
|
|
/* Define/disable kernel-specific declarators */
|
2014-02-11 10:51:33 +08:00
|
|
|
|
|
|
|
#ifndef __init
|
|
|
|
#define __init
|
|
|
|
#endif
|
2016-11-16 17:27:34 +08:00
|
|
|
#ifndef __iomem
|
|
|
|
#define __iomem
|
|
|
|
#endif
|
2014-02-11 10:51:33 +08:00
|
|
|
|
2009-04-22 13:39:47 +08:00
|
|
|
/* Host-dependent types and defines for user-space ACPICA */
|
|
|
|
|
|
|
|
#define ACPI_FLUSH_CPU_CACHE()
|
2010-09-15 13:55:13 +08:00
|
|
|
#define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
|
2009-04-22 13:39:47 +08:00
|
|
|
|
2018-01-25 07:42:29 +08:00
|
|
|
#if defined(__ia64__) || (defined(__x86_64__) && !defined(__ILP32__)) ||\
|
2016-12-28 15:28:56 +08:00
|
|
|
defined(__aarch64__) || defined(__PPC64__) ||\
|
|
|
|
defined(__s390x__)
|
2005-04-17 06:20:36 +08:00
|
|
|
#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
|
2017-08-03 14:26:50 +08:00
|
|
|
#define ACPI_USE_NATIVE_MATH64
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
2007-03-28 08:25:46 +08:00
|
|
|
#ifndef __cdecl
|
2005-04-17 06:20:36 +08:00
|
|
|
#define __cdecl
|
2007-03-28 08:25:46 +08:00
|
|
|
#endif
|
|
|
|
|
2013-10-29 09:29:51 +08:00
|
|
|
#endif /* __KERNEL__ */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-10-29 09:29:51 +08:00
|
|
|
#endif /* __ACLINUX_H__ */
|