17c478bd9Sstevel@tonic-gate /****************************************************************************** 27c478bd9Sstevel@tonic-gate * 3aa2aa9a6SDana Myers * Name: aclinux.h - OS specific defines, etc. for Linux 47c478bd9Sstevel@tonic-gate * 57c478bd9Sstevel@tonic-gate *****************************************************************************/ 67c478bd9Sstevel@tonic-gate 726f3cdf0SGordon Ross /* 8*7b1019a6SJerry Jelinek * Copyright (C) 2000 - 2016, Intel Corp. 97c478bd9Sstevel@tonic-gate * All rights reserved. 107c478bd9Sstevel@tonic-gate * 1126f3cdf0SGordon Ross * Redistribution and use in source and binary forms, with or without 1226f3cdf0SGordon Ross * modification, are permitted provided that the following conditions 1326f3cdf0SGordon Ross * are met: 1426f3cdf0SGordon Ross * 1. Redistributions of source code must retain the above copyright 1526f3cdf0SGordon Ross * notice, this list of conditions, and the following disclaimer, 1626f3cdf0SGordon Ross * without modification. 1726f3cdf0SGordon Ross * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1826f3cdf0SGordon Ross * substantially similar to the "NO WARRANTY" disclaimer below 1926f3cdf0SGordon Ross * ("Disclaimer") and any redistribution must be conditioned upon 2026f3cdf0SGordon Ross * including a substantially similar Disclaimer requirement for further 2126f3cdf0SGordon Ross * binary redistribution. 2226f3cdf0SGordon Ross * 3. Neither the names of the above-listed copyright holders nor the names 2326f3cdf0SGordon Ross * of any contributors may be used to endorse or promote products derived 2426f3cdf0SGordon Ross * from this software without specific prior written permission. 2526f3cdf0SGordon Ross * 2626f3cdf0SGordon Ross * Alternatively, this software may be distributed under the terms of the 2726f3cdf0SGordon Ross * GNU General Public License ("GPL") version 2 as published by the Free 2826f3cdf0SGordon Ross * Software Foundation. 2926f3cdf0SGordon Ross * 3026f3cdf0SGordon Ross * NO WARRANTY 3126f3cdf0SGordon Ross * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3226f3cdf0SGordon Ross * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3326f3cdf0SGordon Ross * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3426f3cdf0SGordon Ross * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3526f3cdf0SGordon Ross * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3626f3cdf0SGordon Ross * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3726f3cdf0SGordon Ross * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3826f3cdf0SGordon Ross * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3926f3cdf0SGordon Ross * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4026f3cdf0SGordon Ross * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4126f3cdf0SGordon Ross * POSSIBILITY OF SUCH DAMAGES. 4226f3cdf0SGordon Ross */ 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #ifndef __ACLINUX_H__ 457c478bd9Sstevel@tonic-gate #define __ACLINUX_H__ 467c478bd9Sstevel@tonic-gate 47*7b1019a6SJerry Jelinek #ifdef __KERNEL__ 48*7b1019a6SJerry Jelinek 49*7b1019a6SJerry Jelinek /* ACPICA external files should not include ACPICA headers directly. */ 50*7b1019a6SJerry Jelinek 51*7b1019a6SJerry Jelinek #if !defined(BUILDING_ACPICA) && !defined(_LINUX_ACPI_H) 52*7b1019a6SJerry Jelinek #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead." 53*7b1019a6SJerry Jelinek #endif 54*7b1019a6SJerry Jelinek 55*7b1019a6SJerry Jelinek #endif 56*7b1019a6SJerry Jelinek 57aa2aa9a6SDana Myers /* Common (in-kernel/user-space) ACPICA configuration */ 58aa2aa9a6SDana Myers 597c478bd9Sstevel@tonic-gate #define ACPI_USE_SYSTEM_CLIBRARY 607c478bd9Sstevel@tonic-gate #define ACPI_USE_DO_WHILE_0 61aa2aa9a6SDana Myers 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate #ifdef __KERNEL__ 647c478bd9Sstevel@tonic-gate 65*7b1019a6SJerry Jelinek #define ACPI_USE_SYSTEM_INTTYPES 66*7b1019a6SJerry Jelinek 67*7b1019a6SJerry Jelinek /* Kernel specific ACPICA configuration */ 68*7b1019a6SJerry Jelinek 69*7b1019a6SJerry Jelinek #ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY 70*7b1019a6SJerry Jelinek #define ACPI_REDUCED_HARDWARE 1 71*7b1019a6SJerry Jelinek #endif 72*7b1019a6SJerry Jelinek 73*7b1019a6SJerry Jelinek #ifdef CONFIG_ACPI_DEBUGGER 74*7b1019a6SJerry Jelinek #define ACPI_DEBUGGER 75*7b1019a6SJerry Jelinek #endif 76*7b1019a6SJerry Jelinek 777c478bd9Sstevel@tonic-gate #include <linux/string.h> 787c478bd9Sstevel@tonic-gate #include <linux/kernel.h> 797c478bd9Sstevel@tonic-gate #include <linux/ctype.h> 80aa2aa9a6SDana Myers #include <linux/sched.h> 81*7b1019a6SJerry Jelinek #include <linux/atomic.h> 82*7b1019a6SJerry Jelinek #include <linux/math64.h> 83aa2aa9a6SDana Myers #include <linux/slab.h> 84aa2aa9a6SDana Myers #include <linux/spinlock_types.h> 85*7b1019a6SJerry Jelinek #ifdef EXPORT_ACPI_INTERFACES 86*7b1019a6SJerry Jelinek #include <linux/export.h> 87*7b1019a6SJerry Jelinek #endif 88*7b1019a6SJerry Jelinek #ifdef CONFIG_ACPI 89*7b1019a6SJerry Jelinek #include <asm/acenv.h> 90*7b1019a6SJerry Jelinek #endif 91*7b1019a6SJerry Jelinek 92*7b1019a6SJerry Jelinek #ifndef CONFIG_ACPI 93*7b1019a6SJerry Jelinek 94*7b1019a6SJerry Jelinek /* External globals for __KERNEL__, stubs is needed */ 95*7b1019a6SJerry Jelinek 96*7b1019a6SJerry Jelinek #define ACPI_GLOBAL(t,a) 97*7b1019a6SJerry Jelinek #define ACPI_INIT_GLOBAL(t,a,b) 98*7b1019a6SJerry Jelinek 99*7b1019a6SJerry Jelinek /* Generating stubs for configurable ACPICA macros */ 100*7b1019a6SJerry Jelinek 101*7b1019a6SJerry Jelinek #define ACPI_NO_MEM_ALLOCATIONS 102*7b1019a6SJerry Jelinek 103*7b1019a6SJerry Jelinek /* Generating stubs for configurable ACPICA functions */ 104*7b1019a6SJerry Jelinek 105*7b1019a6SJerry Jelinek #define ACPI_NO_ERROR_MESSAGES 106*7b1019a6SJerry Jelinek #undef ACPI_DEBUG_OUTPUT 107*7b1019a6SJerry Jelinek 108*7b1019a6SJerry Jelinek /* External interface for __KERNEL__, stub is needed */ 109*7b1019a6SJerry Jelinek 110*7b1019a6SJerry Jelinek #define ACPI_EXTERNAL_RETURN_STATUS(Prototype) \ 111*7b1019a6SJerry Jelinek static ACPI_INLINE Prototype {return(AE_NOT_CONFIGURED);} 112*7b1019a6SJerry Jelinek #define ACPI_EXTERNAL_RETURN_OK(Prototype) \ 113*7b1019a6SJerry Jelinek static ACPI_INLINE Prototype {return(AE_OK);} 114*7b1019a6SJerry Jelinek #define ACPI_EXTERNAL_RETURN_VOID(Prototype) \ 115*7b1019a6SJerry Jelinek static ACPI_INLINE Prototype {return;} 116*7b1019a6SJerry Jelinek #define ACPI_EXTERNAL_RETURN_UINT32(Prototype) \ 117*7b1019a6SJerry Jelinek static ACPI_INLINE Prototype {return(0);} 118*7b1019a6SJerry Jelinek #define ACPI_EXTERNAL_RETURN_PTR(Prototype) \ 119*7b1019a6SJerry Jelinek static ACPI_INLINE Prototype {return(NULL);} 120*7b1019a6SJerry Jelinek 121*7b1019a6SJerry Jelinek #endif /* CONFIG_ACPI */ 1227c478bd9Sstevel@tonic-gate 123aa2aa9a6SDana Myers /* Host-dependent types and defines for in-kernel ACPICA */ 124450d6964Smyers 12527f7c583Smyers #define ACPI_MACHINE_WIDTH BITS_PER_LONG 126aa2aa9a6SDana Myers #define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); 12727f7c583Smyers #define strtoul simple_strtoul 128450d6964Smyers 129aa2aa9a6SDana Myers #define ACPI_CACHE_T struct kmem_cache 130aa2aa9a6SDana Myers #define ACPI_SPINLOCK spinlock_t * 131aa2aa9a6SDana Myers #define ACPI_CPU_FLAGS unsigned long 132aa2aa9a6SDana Myers 133*7b1019a6SJerry Jelinek /* Use native linux version of AcpiOsAllocateZeroed */ 134*7b1019a6SJerry Jelinek 135*7b1019a6SJerry Jelinek #define USE_NATIVE_ALLOCATE_ZEROED 136*7b1019a6SJerry Jelinek 137*7b1019a6SJerry Jelinek /* 138*7b1019a6SJerry Jelinek * Overrides for in-kernel ACPICA 139*7b1019a6SJerry Jelinek */ 140*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitialize 141*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminate 142*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocate 143*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAllocateZeroed 144*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsFree 145*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsAcquireObject 146*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetThreadId 147*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCreateLock 148*7b1019a6SJerry Jelinek 149*7b1019a6SJerry Jelinek /* 150*7b1019a6SJerry Jelinek * OSL interfaces used by debugger/disassembler 151*7b1019a6SJerry Jelinek */ 152*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable 153*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable 154*7b1019a6SJerry Jelinek 155*7b1019a6SJerry Jelinek /* 156*7b1019a6SJerry Jelinek * OSL interfaces used by utilities 157*7b1019a6SJerry Jelinek */ 158*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsRedirectOutput 159*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByName 160*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByIndex 161*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetTableByAddress 162*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenDirectory 163*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetNextFilename 164*7b1019a6SJerry Jelinek #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseDirectory 165*7b1019a6SJerry Jelinek 166*7b1019a6SJerry Jelinek #define ACPI_MSG_ERROR KERN_ERR "ACPI Error: " 167*7b1019a6SJerry Jelinek #define ACPI_MSG_EXCEPTION KERN_ERR "ACPI Exception: " 168*7b1019a6SJerry Jelinek #define ACPI_MSG_WARNING KERN_WARNING "ACPI Warning: " 169*7b1019a6SJerry Jelinek #define ACPI_MSG_INFO KERN_INFO "ACPI: " 170*7b1019a6SJerry Jelinek 171*7b1019a6SJerry Jelinek #define ACPI_MSG_BIOS_ERROR KERN_ERR "ACPI BIOS Error (bug): " 172*7b1019a6SJerry Jelinek #define ACPI_MSG_BIOS_WARNING KERN_WARNING "ACPI BIOS Warning (bug): " 173*7b1019a6SJerry Jelinek 1747c478bd9Sstevel@tonic-gate #else /* !__KERNEL__ */ 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate #include <stdarg.h> 1777c478bd9Sstevel@tonic-gate #include <string.h> 1787c478bd9Sstevel@tonic-gate #include <stdlib.h> 1797c478bd9Sstevel@tonic-gate #include <ctype.h> 1807c478bd9Sstevel@tonic-gate #include <unistd.h> 1817c478bd9Sstevel@tonic-gate 182*7b1019a6SJerry Jelinek /* Define/disable kernel-specific declarators */ 183*7b1019a6SJerry Jelinek 184*7b1019a6SJerry Jelinek #ifndef __init 185*7b1019a6SJerry Jelinek #define __init 186*7b1019a6SJerry Jelinek #endif 187*7b1019a6SJerry Jelinek 188aa2aa9a6SDana Myers /* Host-dependent types and defines for user-space ACPICA */ 189aa2aa9a6SDana Myers 190aa2aa9a6SDana Myers #define ACPI_FLUSH_CPU_CACHE() 191*7b1019a6SJerry Jelinek #define ACPI_CAST_PTHREAD_T(Pthread) ((ACPI_THREAD_ID) (Pthread)) 192aa2aa9a6SDana Myers 193*7b1019a6SJerry Jelinek #if defined(__ia64__) || defined(__x86_64__) ||\ 194*7b1019a6SJerry Jelinek defined(__aarch64__) || defined(__PPC64__) 1957c478bd9Sstevel@tonic-gate #define ACPI_MACHINE_WIDTH 64 1967c478bd9Sstevel@tonic-gate #define COMPILER_DEPENDENT_INT64 long 1977c478bd9Sstevel@tonic-gate #define COMPILER_DEPENDENT_UINT64 unsigned long 1987c478bd9Sstevel@tonic-gate #else 1997c478bd9Sstevel@tonic-gate #define ACPI_MACHINE_WIDTH 32 2007c478bd9Sstevel@tonic-gate #define COMPILER_DEPENDENT_INT64 long long 2017c478bd9Sstevel@tonic-gate #define COMPILER_DEPENDENT_UINT64 unsigned long long 2027c478bd9Sstevel@tonic-gate #define ACPI_USE_NATIVE_DIVIDE 2037c478bd9Sstevel@tonic-gate #endif 2047c478bd9Sstevel@tonic-gate 205db2bae30SDana Myers #ifndef __cdecl 2067c478bd9Sstevel@tonic-gate #define __cdecl 207db2bae30SDana Myers #endif 208db2bae30SDana Myers 2097c478bd9Sstevel@tonic-gate #endif /* __KERNEL__ */ 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate /* Linux uses GCC */ 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate #include "acgcc.h" 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate #endif /* __ACLINUX_H__ */ 216