2005-04-17 02:20:36 +04:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2009-04-22 09:39:47 +04:00
|
|
|
* Name: aclinux.h - OS specific defines, etc. for Linux
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2016-01-15 03:17:03 +03:00
|
|
|
* Copyright (C) 2000 - 2016, Intel Corp.
|
2005-04-17 02:20:36 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ACLINUX_H__
|
|
|
|
#define __ACLINUX_H__
|
|
|
|
|
2014-07-16 12:58:53 +04: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 09:39:47 +04:00
|
|
|
/* Common (in-kernel/user-space) ACPICA configuration */
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#define ACPI_USE_SYSTEM_CLIBRARY
|
|
|
|
#define ACPI_USE_DO_WHILE_0
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2014-02-11 06:51:43 +04:00
|
|
|
#define ACPI_USE_SYSTEM_INTTYPES
|
|
|
|
|
2015-10-19 05:25:56 +03:00
|
|
|
/* Kernel specific ACPICA configuration */
|
2014-01-17 22:51:30 +04:00
|
|
|
|
|
|
|
#ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY
|
|
|
|
#define ACPI_REDUCED_HARDWARE 1
|
|
|
|
#endif
|
|
|
|
|
2015-10-19 05:25:56 +03:00
|
|
|
#ifdef CONFIG_ACPI_DEBUGGER
|
|
|
|
#define ACPI_DEBUGGER
|
|
|
|
#endif
|
|
|
|
|
2016-07-05 08:53:04 +03:00
|
|
|
#ifdef CONFIG_ACPI_DEBUG
|
|
|
|
#define ACPI_MUTEX_DEBUG
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/ctype.h>
|
2008-09-25 21:40:30 +04:00
|
|
|
#include <linux/sched.h>
|
2011-07-27 03:09:06 +04:00
|
|
|
#include <linux/atomic.h>
|
2013-10-29 05:30:41 +04:00
|
|
|
#include <linux/math64.h>
|
2006-10-03 08:00:00 +04:00
|
|
|
#include <linux/slab.h>
|
2006-06-24 01:04:00 +04:00
|
|
|
#include <linux/spinlock_types.h>
|
2013-10-29 05:30:41 +04:00
|
|
|
#ifdef EXPORT_ACPI_INTERFACES
|
|
|
|
#include <linux/export.h>
|
|
|
|
#endif
|
2014-07-16 12:58:08 +04:00
|
|
|
#ifdef CONFIG_ACPI
|
2014-05-12 11:46:38 +04:00
|
|
|
#include <asm/acenv.h>
|
2014-07-16 12:58:08 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2014-04-30 06:05:15 +04: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 09:39:47 +04:00
|
|
|
/* Host-dependent types and defines for in-kernel ACPICA */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-10-03 08:00:00 +04:00
|
|
|
#define ACPI_MACHINE_WIDTH BITS_PER_LONG
|
|
|
|
#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 08:00:00 +04:00
|
|
|
|
2009-04-22 09:39:47 +04:00
|
|
|
#define acpi_cache_t struct kmem_cache
|
|
|
|
#define acpi_spinlock spinlock_t *
|
|
|
|
#define acpi_cpu_flags unsigned long
|
|
|
|
|
2014-05-12 11:46:32 +04: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
|
2015-12-03 05:42:46 +03:00
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_command_signals
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_command_signals
|
2014-05-12 11:46:32 +04: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
|
|
|
|
|
2013-10-29 05:29:51 +04:00
|
|
|
#else /* !__KERNEL__ */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2014-04-04 08:37:59 +04:00
|
|
|
/* Define/disable kernel-specific declarators */
|
2014-02-11 06:51:33 +04:00
|
|
|
|
|
|
|
#ifndef __init
|
|
|
|
#define __init
|
|
|
|
#endif
|
|
|
|
|
2009-04-22 09:39:47 +04:00
|
|
|
/* Host-dependent types and defines for user-space ACPICA */
|
|
|
|
|
|
|
|
#define ACPI_FLUSH_CPU_CACHE()
|
2010-09-15 09:55:13 +04:00
|
|
|
#define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
|
2009-04-22 09:39:47 +04:00
|
|
|
|
2014-04-04 08:38:05 +04:00
|
|
|
#if defined(__ia64__) || defined(__x86_64__) ||\
|
|
|
|
defined(__aarch64__) || defined(__PPC64__)
|
2005-04-17 02:20:36 +04: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
|
|
|
|
#endif
|
|
|
|
|
2007-03-28 04:25:46 +04:00
|
|
|
#ifndef __cdecl
|
2005-04-17 02:20:36 +04:00
|
|
|
#define __cdecl
|
2007-03-28 04:25:46 +04:00
|
|
|
#endif
|
|
|
|
|
2013-10-29 05:29:51 +04:00
|
|
|
#endif /* __KERNEL__ */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* Linux uses GCC */
|
|
|
|
|
2012-10-02 21:01:25 +04:00
|
|
|
#include <acpi/platform/acgcc.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2013-10-29 05:29:51 +04:00
|
|
|
#endif /* __ACLINUX_H__ */
|