2005-04-17 05:20:36 +07:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2009-04-22 12:39:47 +07:00
|
|
|
* Name: aclinux.h - OS specific defines, etc. for Linux
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2014-02-08 08:42:25 +07:00
|
|
|
* Copyright (C) 2000 - 2014, Intel Corp.
|
2005-04-17 05:20:36 +07: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__
|
|
|
|
|
2009-04-22 12:39:47 +07:00
|
|
|
/* Common (in-kernel/user-space) ACPICA configuration */
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#define ACPI_USE_SYSTEM_CLIBRARY
|
|
|
|
#define ACPI_USE_DO_WHILE_0
|
2008-12-31 02:03:29 +07:00
|
|
|
#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2014-02-11 09:51:43 +07:00
|
|
|
#define ACPI_USE_SYSTEM_INTTYPES
|
|
|
|
|
2014-01-18 01:51:30 +07:00
|
|
|
/* Compile for reduced hardware mode only with this kernel config */
|
|
|
|
|
|
|
|
#ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY
|
|
|
|
#define ACPI_REDUCED_HARDWARE 1
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/ctype.h>
|
2008-09-26 00:40:30 +07:00
|
|
|
#include <linux/sched.h>
|
2011-07-27 06:09:06 +07:00
|
|
|
#include <linux/atomic.h>
|
2013-10-29 08:30:41 +07:00
|
|
|
#include <linux/math64.h>
|
2006-10-03 11:00:00 +07:00
|
|
|
#include <linux/slab.h>
|
2006-06-24 04:04:00 +07:00
|
|
|
#include <linux/spinlock_types.h>
|
2013-10-29 08:30:41 +07:00
|
|
|
#ifdef EXPORT_ACPI_INTERFACES
|
|
|
|
#include <linux/export.h>
|
|
|
|
#endif
|
|
|
|
#include <asm/acpi.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-04-30 09:05:15 +07: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 12:39:47 +07:00
|
|
|
/* Host-dependent types and defines for in-kernel ACPICA */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-10-03 11:00:00 +07: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 11:00:00 +07:00
|
|
|
|
2009-04-22 12:39:47 +07:00
|
|
|
#define acpi_cache_t struct kmem_cache
|
|
|
|
#define acpi_spinlock spinlock_t *
|
|
|
|
#define acpi_cpu_flags unsigned long
|
|
|
|
|
2013-10-29 08:29:51 +07:00
|
|
|
#else /* !__KERNEL__ */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2014-04-04 11:37:59 +07:00
|
|
|
/* Define/disable kernel-specific declarators */
|
2014-02-11 09:51:33 +07:00
|
|
|
|
|
|
|
#ifndef __init
|
|
|
|
#define __init
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __iomem
|
|
|
|
#define __iomem
|
|
|
|
#endif
|
|
|
|
|
2009-04-22 12:39:47 +07:00
|
|
|
/* Host-dependent types and defines for user-space ACPICA */
|
|
|
|
|
|
|
|
#define ACPI_FLUSH_CPU_CACHE()
|
2010-09-15 12:55:13 +07:00
|
|
|
#define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
|
2009-04-22 12:39:47 +07:00
|
|
|
|
2014-04-04 11:38:05 +07:00
|
|
|
#if defined(__ia64__) || defined(__x86_64__) ||\
|
|
|
|
defined(__aarch64__) || defined(__PPC64__)
|
2005-04-17 05:20:36 +07: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 07:25:46 +07:00
|
|
|
#ifndef __cdecl
|
2005-04-17 05:20:36 +07:00
|
|
|
#define __cdecl
|
2007-03-28 07:25:46 +07:00
|
|
|
#endif
|
|
|
|
|
2013-10-29 08:29:51 +07:00
|
|
|
#endif /* __KERNEL__ */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Linux uses GCC */
|
|
|
|
|
2012-10-03 00:01:25 +07:00
|
|
|
#include <acpi/platform/acgcc.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-04-22 12:39:47 +07:00
|
|
|
#ifdef __KERNEL__
|
2013-10-29 08:30:41 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME: Inclusion of actypes.h
|
|
|
|
* Linux kernel need this before defining inline OSL interfaces as
|
|
|
|
* actypes.h need to be included to find ACPICA type definitions.
|
|
|
|
* Since from ACPICA's perspective, the actypes.h should be included after
|
|
|
|
* acenv.h (aclinux.h), this leads to a inclusion mis-ordering issue.
|
|
|
|
*/
|
2010-09-15 12:55:13 +07:00
|
|
|
#include <acpi/actypes.h>
|
2013-10-29 08:30:41 +07:00
|
|
|
|
2009-04-22 12:39:47 +07:00
|
|
|
/*
|
|
|
|
* Overrides for in-kernel ACPICA
|
|
|
|
*/
|
2013-10-29 08:30:41 +07:00
|
|
|
acpi_status __init acpi_os_initialize(void);
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
|
|
|
|
|
|
|
|
acpi_status acpi_os_terminate(void);
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
|
2006-04-01 17:12:23 +07:00
|
|
|
|
2013-10-29 08:29:27 +07:00
|
|
|
/*
|
|
|
|
* Memory allocation/deallocation
|
|
|
|
*/
|
|
|
|
|
2006-07-10 12:35:51 +07:00
|
|
|
/*
|
|
|
|
* The irqs_disabled() check is for resume from RAM.
|
|
|
|
* Interrupts are off during resume, just like they are for boot.
|
|
|
|
* However, boot has (system_state != SYSTEM_RUNNING)
|
|
|
|
* to quiet __might_sleep() in kmalloc() and resume does not.
|
|
|
|
*/
|
2007-05-10 10:34:35 +07:00
|
|
|
static inline void *acpi_os_allocate(acpi_size size)
|
|
|
|
{
|
2013-10-29 08:30:41 +07:00
|
|
|
return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
|
2006-07-10 12:35:51 +07:00
|
|
|
}
|
2009-04-22 12:39:47 +07:00
|
|
|
|
2013-10-29 08:30:41 +07:00
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
|
|
|
|
|
|
|
|
/* Use native linux version of acpi_os_allocate_zeroed */
|
|
|
|
|
2007-05-10 10:34:35 +07:00
|
|
|
static inline void *acpi_os_allocate_zeroed(acpi_size size)
|
|
|
|
{
|
2013-10-29 08:30:41 +07:00
|
|
|
return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
|
|
|
|
#define USE_NATIVE_ALLOCATE_ZEROED
|
|
|
|
|
|
|
|
static inline void acpi_os_free(void *memory)
|
|
|
|
{
|
|
|
|
kfree(memory);
|
2006-07-10 12:35:51 +07:00
|
|
|
}
|
|
|
|
|
2013-10-29 08:30:41 +07:00
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
|
|
|
|
|
2007-05-10 10:34:35 +07:00
|
|
|
static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
|
|
|
|
{
|
|
|
|
return kmem_cache_zalloc(cache,
|
2013-10-29 08:30:41 +07:00
|
|
|
irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
|
2006-07-10 12:35:51 +07:00
|
|
|
}
|
|
|
|
|
2013-10-29 08:30:41 +07:00
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
|
|
|
|
|
|
|
|
static inline acpi_thread_id acpi_os_get_thread_id(void)
|
2013-10-29 08:29:27 +07:00
|
|
|
{
|
2013-10-29 08:30:41 +07:00
|
|
|
return (acpi_thread_id) (unsigned long)current;
|
2013-10-29 08:29:27 +07:00
|
|
|
}
|
2006-07-10 12:35:51 +07:00
|
|
|
|
2013-10-29 08:30:41 +07:00
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
|
|
|
|
|
2011-07-07 01:44:25 +07:00
|
|
|
/*
|
|
|
|
* When lockdep is enabled, the spin_lock_init() macro stringifies it's
|
|
|
|
* argument and uses that as a name for the lock in debugging.
|
|
|
|
* By executing spin_lock_init() in a macro the key changes from "lock" for
|
|
|
|
* all locks to the name of the argument of acpi_os_create_lock(), which
|
|
|
|
* prevents lockdep from reporting false positives for ACPICA locks.
|
|
|
|
*/
|
2013-10-29 08:30:41 +07:00
|
|
|
#define acpi_os_create_lock(__handle) \
|
|
|
|
({ \
|
|
|
|
spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
|
|
|
|
if (lock) { \
|
|
|
|
*(__handle) = lock; \
|
|
|
|
spin_lock_init(*(__handle)); \
|
|
|
|
} \
|
|
|
|
lock ? AE_OK : AE_NO_MEMORY; \
|
|
|
|
})
|
2013-10-29 08:30:35 +07:00
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
|
2011-07-07 01:44:25 +07:00
|
|
|
|
2013-10-29 08:30:41 +07:00
|
|
|
void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_size length);
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory
|
|
|
|
|
|
|
|
void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size);
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OSL interfaces used by debugger/disassembler
|
|
|
|
*/
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OSL interfaces used by utilities
|
|
|
|
*/
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
|
|
|
|
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line
|
|
|
|
#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
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OSL interfaces added by Linux
|
|
|
|
*/
|
|
|
|
void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size);
|
|
|
|
|
2013-10-29 08:29:51 +07:00
|
|
|
#endif /* __KERNEL__ */
|
2009-04-22 12:39:47 +07:00
|
|
|
|
2013-10-29 08:29:51 +07:00
|
|
|
#endif /* __ACLINUX_H__ */
|