2005-04-16 16:20:36 -06:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2009-04-21 23:39:47 -06:00
|
|
|
* Name: aclinux.h - OS specific defines, etc. for Linux
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2009-04-21 23:39:47 -06:00
|
|
|
* Copyright (C) 2000 - 2009, Intel Corp.
|
2005-04-16 16:20:36 -06: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-21 23:39:47 -06:00
|
|
|
/* Common (in-kernel/user-space) ACPICA configuration */
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#define ACPI_USE_SYSTEM_CLIBRARY
|
|
|
|
#define ACPI_USE_DO_WHILE_0
|
2008-12-30 12:03:29 -07:00
|
|
|
#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2009-04-21 23:39:47 -06:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/kernel.h>
|
2006-10-02 22:00:00 -06:00
|
|
|
#include <linux/module.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/ctype.h>
|
2008-09-25 11:40:30 -06:00
|
|
|
#include <linux/sched.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/system.h>
|
|
|
|
#include <asm/atomic.h>
|
|
|
|
#include <asm/div64.h>
|
|
|
|
#include <asm/acpi.h>
|
2006-10-02 22:00:00 -06:00
|
|
|
#include <linux/slab.h>
|
2006-06-23 15:04:00 -06:00
|
|
|
#include <linux/spinlock_types.h>
|
2006-07-07 18:11:07 -06:00
|
|
|
#include <asm/current.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2009-04-21 23:39:47 -06:00
|
|
|
/* Host-dependent types and defines for in-kernel ACPICA */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-10-02 22:00:00 -06: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-23 22:00:00 -06:00
|
|
|
|
2009-04-21 23:39:47 -06:00
|
|
|
#define acpi_cache_t struct kmem_cache
|
|
|
|
#define acpi_spinlock spinlock_t *
|
|
|
|
#define acpi_cpu_flags unsigned long
|
|
|
|
#define acpi_thread_id struct task_struct *
|
|
|
|
|
|
|
|
#else /* !__KERNEL__ */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2009-04-21 23:39:47 -06:00
|
|
|
/* Host-dependent types and defines for user-space ACPICA */
|
|
|
|
|
|
|
|
#define ACPI_FLUSH_CPU_CACHE()
|
|
|
|
#define acpi_thread_id pthread_t
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#if defined(__ia64__) || defined(__x86_64__)
|
|
|
|
#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-27 18:25:46 -06:00
|
|
|
#ifndef __cdecl
|
2005-04-16 16:20:36 -06:00
|
|
|
#define __cdecl
|
2007-03-27 18:25:46 -06:00
|
|
|
#endif
|
|
|
|
|
2009-04-21 23:39:47 -06:00
|
|
|
#endif /* __KERNEL__ */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* Linux uses GCC */
|
|
|
|
|
|
|
|
#include "acgcc.h"
|
|
|
|
|
2006-04-01 03:12:23 -07:00
|
|
|
|
2009-04-21 23:39:47 -06:00
|
|
|
#ifdef __KERNEL__
|
|
|
|
/*
|
|
|
|
* Overrides for in-kernel ACPICA
|
|
|
|
*/
|
2007-05-09 21:34:35 -06:00
|
|
|
static inline acpi_thread_id acpi_os_get_thread_id(void)
|
|
|
|
{
|
|
|
|
return current;
|
|
|
|
}
|
2006-04-01 03:12:23 -07:00
|
|
|
|
2006-07-09 23:35:51 -06: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.
|
|
|
|
*/
|
|
|
|
#include <acpi/actypes.h>
|
2007-05-09 21:34:35 -06:00
|
|
|
static inline void *acpi_os_allocate(acpi_size size)
|
|
|
|
{
|
2009-04-21 23:39:47 -06:00
|
|
|
return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
|
2006-07-09 23:35:51 -06:00
|
|
|
}
|
2009-04-21 23:39:47 -06:00
|
|
|
|
2007-05-09 21:34:35 -06:00
|
|
|
static inline void *acpi_os_allocate_zeroed(acpi_size size)
|
|
|
|
{
|
2009-04-21 23:39:47 -06:00
|
|
|
return kzalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
|
2006-07-09 23:35:51 -06:00
|
|
|
}
|
|
|
|
|
2007-05-09 21:34:35 -06:00
|
|
|
static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
|
|
|
|
{
|
|
|
|
return kmem_cache_zalloc(cache,
|
2009-04-21 23:39:47 -06:00
|
|
|
irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
|
2006-07-09 23:35:51 -06:00
|
|
|
}
|
|
|
|
|
2009-04-21 23:39:47 -06:00
|
|
|
#define ACPI_ALLOCATE(a) acpi_os_allocate(a)
|
|
|
|
#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a)
|
|
|
|
#define ACPI_FREE(a) kfree(a)
|
2006-07-09 23:35:51 -06:00
|
|
|
|
2009-04-21 23:39:47 -06:00
|
|
|
/* Used within ACPICA to show where it is safe to preempt execution */
|
2009-08-28 13:29:38 -06:00
|
|
|
#include <linux/hardirq.h>
|
2009-04-21 23:39:47 -06:00
|
|
|
#define ACPI_PREEMPTION_POINT() \
|
|
|
|
do { \
|
2009-08-28 13:29:38 -06:00
|
|
|
if (!in_atomic_preempt_off()) \
|
2009-04-21 23:39:47 -06:00
|
|
|
cond_resched(); \
|
2008-11-25 23:35:22 -07:00
|
|
|
} while (0)
|
2008-09-25 11:40:30 -06:00
|
|
|
|
2009-04-21 23:39:47 -06:00
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
|
|
|
#endif /* __ACLINUX_H__ */
|