/******************************************************************************1*2* Name: acenv.h - Generation environment specific items3*4*****************************************************************************/56/*7* Copyright (C) 2000 - 2011, Intel Corp.8* All rights reserved.9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions12* are met:13* 1. Redistributions of source code must retain the above copyright14* notice, this list of conditions, and the following disclaimer,15* without modification.16* 2. Redistributions in binary form must reproduce at minimum a disclaimer17* substantially similar to the "NO WARRANTY" disclaimer below18* ("Disclaimer") and any redistribution must be conditioned upon19* including a substantially similar Disclaimer requirement for further20* binary redistribution.21* 3. Neither the names of the above-listed copyright holders nor the names22* of any contributors may be used to endorse or promote products derived23* from this software without specific prior written permission.24*25* Alternatively, this software may be distributed under the terms of the26* GNU General Public License ("GPL") version 2 as published by the Free27* Software Foundation.28*29* NO WARRANTY30* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS31* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT32* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR33* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT34* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL35* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS36* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)37* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,38* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING39* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE40* POSSIBILITY OF SUCH DAMAGES.41*/4243#ifndef __ACENV_H__44#define __ACENV_H__4546/* Types for ACPI_MUTEX_TYPE */4748#define ACPI_BINARY_SEMAPHORE 049#define ACPI_OSL_MUTEX 15051/* Types for DEBUGGER_THREADING */5253#define DEBUGGER_SINGLE_THREADED 054#define DEBUGGER_MULTI_THREADED 15556/******************************************************************************57*58* Configuration for ACPI tools and utilities59*60*****************************************************************************/6162#ifdef ACPI_LIBRARY63/*64* Note: The non-debug version of the acpi_library does not contain any65* debug support, for minimal size. The debug version uses ACPI_FULL_DEBUG66*/67#define ACPI_USE_LOCAL_CACHE68#endif6970#ifdef ACPI_ASL_COMPILER71#define ACPI_DEBUG_OUTPUT72#define ACPI_APPLICATION73#define ACPI_DISASSEMBLER74#define ACPI_CONSTANT_EVAL_ONLY75#define ACPI_LARGE_NAMESPACE_NODE76#define ACPI_DATA_TABLE_DISASSEMBLY77#endif7879#ifdef ACPI_EXEC_APP80#undef DEBUGGER_THREADING81#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED82#define ACPI_FULL_DEBUG83#define ACPI_APPLICATION84#define ACPI_DEBUGGER85#define ACPI_MUTEX_DEBUG86#define ACPI_DBG_TRACK_ALLOCATIONS87#endif8889#ifdef ACPI_APPLICATION90#define ACPI_USE_SYSTEM_CLIBRARY91#define ACPI_USE_LOCAL_CACHE92#endif9394#ifdef ACPI_FULL_DEBUG95#define ACPI_DEBUGGER96#define ACPI_DEBUG_OUTPUT97#define ACPI_DISASSEMBLER98#endif99100/*101* Environment configuration. The purpose of this file is to interface to the102* local generation environment.103*104* 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.105* Otherwise, local versions of string/memory functions will be used.106* 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and107* the standard header files may be used.108*109* The ACPI subsystem only uses low level C library functions that do not call110* operating system services and may therefore be inlined in the code.111*112* It may be necessary to tailor these include files to the target113* generation environment.114*115*116* Functions and constants used from each header:117*118* string.h: memcpy119* memset120* strcat121* strcmp122* strcpy123* strlen124* strncmp125* strncat126* strncpy127*128* stdlib.h: strtoul129*130* stdarg.h: va_list131* va_arg132* va_start133* va_end134*135*/136137/*! [Begin] no source code translation */138139#if defined(_LINUX) || defined(__linux__)140#include "aclinux.h"141142#elif defined(_AED_EFI)143#include "acefi.h"144145#elif defined(WIN32)146#include "acwin.h"147148#elif defined(WIN64)149#include "acwin64.h"150151#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */152#include "acdos16.h"153154#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)155#include "acfreebsd.h"156157#elif defined(__NetBSD__)158#include "acnetbsd.h"159160#elif defined(MODESTO)161#include "acmodesto.h"162163#elif defined(NETWARE)164#include "acnetware.h"165166#elif defined(__sun)167#include "acsolaris.h"168169#else170171/* All other environments */172173#define ACPI_USE_STANDARD_HEADERS174175#define COMPILER_DEPENDENT_INT64 long long176#define COMPILER_DEPENDENT_UINT64 unsigned long long177178#endif179180/*! [End] no source code translation !*/181182/******************************************************************************183*184* Miscellaneous configuration185*186*****************************************************************************/187188/*189* Are mutexes supported by the host? default is no, use binary semaphores.190*/191#ifndef ACPI_MUTEX_TYPE192#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE193#endif194195/* "inline" keywords - configurable since inline is not standardized */196197#ifndef ACPI_INLINE198#define ACPI_INLINE199#endif200201/*202* Debugger threading model203* Use single threaded if the entire subsystem is contained in an application204* Use multiple threaded when the subsystem is running in the kernel.205*206* By default the model is single threaded if ACPI_APPLICATION is set,207* multi-threaded if ACPI_APPLICATION is not set.208*/209#ifndef DEBUGGER_THREADING210#ifdef ACPI_APPLICATION211#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED212213#else214#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED215#endif216#endif /* !DEBUGGER_THREADING */217218/******************************************************************************219*220* C library configuration221*222*****************************************************************************/223224#define ACPI_IS_ASCII(c) ((c) < 0x80)225226#ifdef ACPI_USE_SYSTEM_CLIBRARY227/*228* Use the standard C library headers.229* We want to keep these to a minimum.230*/231#ifdef ACPI_USE_STANDARD_HEADERS232/*233* Use the standard headers from the standard locations234*/235#include <stdarg.h>236#include <stdlib.h>237#include <string.h>238#include <ctype.h>239240#endif /* ACPI_USE_STANDARD_HEADERS */241242/*243* We will be linking to the standard Clib functions244*/245#define ACPI_STRSTR(s1,s2) strstr((s1), (s2))246#define ACPI_STRCHR(s1,c) strchr((s1), (c))247#define ACPI_STRLEN(s) (acpi_size) strlen((s))248#define ACPI_STRCPY(d,s) (void) strcpy((d), (s))249#define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (acpi_size)(n))250#define ACPI_STRNCMP(d,s,n) strncmp((d), (s), (acpi_size)(n))251#define ACPI_STRCMP(d,s) strcmp((d), (s))252#define ACPI_STRCAT(d,s) (void) strcat((d), (s))253#define ACPI_STRNCAT(d,s,n) strncat((d), (s), (acpi_size)(n))254#define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (acpi_size)(n))255#define ACPI_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(s2), (acpi_size)(n))256#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (acpi_size)(n))257#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (acpi_size)(n))258259#define ACPI_TOUPPER(i) toupper((int) (i))260#define ACPI_TOLOWER(i) tolower((int) (i))261#define ACPI_IS_XDIGIT(i) isxdigit((int) (i))262#define ACPI_IS_DIGIT(i) isdigit((int) (i))263#define ACPI_IS_SPACE(i) isspace((int) (i))264#define ACPI_IS_UPPER(i) isupper((int) (i))265#define ACPI_IS_PRINT(i) isprint((int) (i))266#define ACPI_IS_ALPHA(i) isalpha((int) (i))267268#else269270/******************************************************************************271*272* Not using native C library, use local implementations273*274*****************************************************************************/275276/*277* Use local definitions of C library macros and functions278* NOTE: The function implementations may not be as efficient279* as an inline or assembly code implementation provided by a280* native C library.281*/282283#ifndef va_arg284285#ifndef _VALIST286#define _VALIST287typedef char *va_list;288#endif /* _VALIST */289290/*291* Storage alignment properties292*/293#define _AUPBND (sizeof (acpi_native_int) - 1)294#define _ADNBND (sizeof (acpi_native_int) - 1)295296/*297* Variable argument list macro definitions298*/299#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))300#define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))301#define va_end(ap) (void) 0302#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))303304#endif /* va_arg */305306#define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2))307#define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c))308#define ACPI_STRLEN(s) (acpi_size) acpi_ut_strlen ((s))309#define ACPI_STRCPY(d,s) (void) acpi_ut_strcpy ((d), (s))310#define ACPI_STRNCPY(d,s,n) (void) acpi_ut_strncpy ((d), (s), (acpi_size)(n))311#define ACPI_STRNCMP(d,s,n) acpi_ut_strncmp ((d), (s), (acpi_size)(n))312#define ACPI_STRCMP(d,s) acpi_ut_strcmp ((d), (s))313#define ACPI_STRCAT(d,s) (void) acpi_ut_strcat ((d), (s))314#define ACPI_STRNCAT(d,s,n) acpi_ut_strncat ((d), (s), (acpi_size)(n))315#define ACPI_STRTOUL(d,s,n) acpi_ut_strtoul ((d), (s), (acpi_size)(n))316#define ACPI_MEMCMP(s1,s2,n) acpi_ut_memcmp((const char *)(s1), (const char *)(s2), (acpi_size)(n))317#define ACPI_MEMCPY(d,s,n) (void) acpi_ut_memcpy ((d), (s), (acpi_size)(n))318#define ACPI_MEMSET(d,v,n) (void) acpi_ut_memset ((d), (v), (acpi_size)(n))319#define ACPI_TOUPPER(c) acpi_ut_to_upper ((int) (c))320#define ACPI_TOLOWER(c) acpi_ut_to_lower ((int) (c))321322#endif /* ACPI_USE_SYSTEM_CLIBRARY */323324/******************************************************************************325*326* Assembly code macros327*328*****************************************************************************/329330/*331* Handle platform- and compiler-specific assembly language differences.332* These should already have been defined by the platform includes above.333*334* Notes:335* 1) Interrupt 3 is used to break into a debugger336* 2) Interrupts are turned off during ACPI register setup337*/338339/* Unrecognized compiler, use defaults */340341#ifndef ACPI_ASM_MACROS342343/*344* Calling conventions:345*346* ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)347* ACPI_EXTERNAL_XFACE - External ACPI interfaces348* ACPI_INTERNAL_XFACE - Internal ACPI interfaces349* ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces350*/351#define ACPI_SYSTEM_XFACE352#define ACPI_EXTERNAL_XFACE353#define ACPI_INTERNAL_XFACE354#define ACPI_INTERNAL_VAR_XFACE355356#define ACPI_ASM_MACROS357#define BREAKPOINT3358#define ACPI_DISABLE_IRQS()359#define ACPI_ENABLE_IRQS()360#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq)361#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq)362363#endif /* ACPI_ASM_MACROS */364365#ifdef ACPI_APPLICATION366367/* Don't want software interrupts within a ring3 application */368369#undef BREAKPOINT3370#define BREAKPOINT3371#endif372373/******************************************************************************374*375* Compiler-specific information is contained in the compiler-specific376* headers.377*378*****************************************************************************/379#endif /* __ACENV_H__ */380381382