acgcc.h revision 85756
1245450Sganbold/****************************************************************************** 2245450Sganbold * 3245450Sganbold * Name: acgcc.h - GCC specific defines, etc. 4245450Sganbold * $Revision: 14 $ 5245450Sganbold * 6245450Sganbold *****************************************************************************/ 7245450Sganbold 8245450Sganbold/****************************************************************************** 9245450Sganbold * 10245450Sganbold * 1. Copyright Notice 11245450Sganbold * 12245450Sganbold * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 13245450Sganbold * All rights reserved. 14245450Sganbold * 15245450Sganbold * 2. License 16245450Sganbold * 17245450Sganbold * 2.1. This is your license from Intel Corp. under its intellectual property 18245450Sganbold * rights. You may have additional license terms from the party that provided 19245450Sganbold * you this software, covering your right to use that party's intellectual 20245450Sganbold * property rights. 21245450Sganbold * 22245450Sganbold * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23245450Sganbold * copy of the source code appearing in this file ("Covered Code") an 24245450Sganbold * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25245450Sganbold * base code distributed originally by Intel ("Original Intel Code") to copy, 26245450Sganbold * make derivatives, distribute, use and display any portion of the Covered 27245450Sganbold * Code in any form, with the right to sublicense such rights; and 28245450Sganbold * 29263245Simp * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30263245Simp * license (with the right to sublicense), under only those claims of Intel 31263245Simp * patents that are infringed by the Original Intel Code, to make, use, sell, 32263245Simp * offer to sell, and import the Covered Code and derivative works thereof 33263245Simp * solely to the minimum extent necessary to exercise the above copyright 34263301Simp * license, and in no event shall the patent license extend to any additions 35263245Simp * to or modifications of the Original Intel Code. No other license or right 36263245Simp * is granted directly or by implication, estoppel or otherwise; 37263245Simp * 38263245Simp * The above copyright and patent license is granted only if the following 39263245Simp * conditions are met: 40263245Simp * 41263245Simp * 3. Conditions 42263245Simp * 43263245Simp * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44263245Simp * Redistribution of source code of any substantial portion of the Covered 45263245Simp * Code or modification with rights to further distribute source must include 46263245Simp * the above Copyright Notice, the above License, this list of Conditions, 47263245Simp * and the following Disclaimer and Export Compliance provision. In addition, 48263245Simp * Licensee must cause all Covered Code to which Licensee contributes to 49263245Simp * contain a file documenting the changes Licensee made to create that Covered 50245450Sganbold * Code and the date of any change. Licensee must include in that file the 51245450Sganbold * documentation of any changes made by any predecessor Licensee. Licensee 52245450Sganbold * must include a prominent statement that the modification is derived, 53263245Simp * directly or indirectly, from Original Intel Code. 54245450Sganbold * 55245450Sganbold * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56263245Simp * Redistribution of source code of any substantial portion of the Covered 57245450Sganbold * Code or modification without rights to further distribute source must 58263245Simp * include the following Disclaimer and Export Compliance provision in the 59245450Sganbold * documentation and/or other materials provided with distribution. In 60263245Simp * addition, Licensee may not authorize further sublicense of source of any 61263245Simp * portion of the Covered Code, and must include terms to the effect that the 62263245Simp * license from Licensee to its licensee is limited to the intellectual 63263245Simp * property embodied in the software Licensee provides to its licensee, and 64263245Simp * not to intellectual property embodied in modifications its licensee may 65245450Sganbold * make. 66245450Sganbold * 67245450Sganbold * 3.3. Redistribution of Executable. Redistribution in executable form of any 68245450Sganbold * substantial portion of the Covered Code or modification must reproduce the 69263245Simp * above Copyright Notice, and the following Disclaimer and Export Compliance 70263245Simp * provision in the documentation and/or other materials provided with the 71245450Sganbold * distribution. 72245450Sganbold * 73263245Simp * 3.4. Intel retains all right, title, and interest in and to the Original 74245450Sganbold * Intel Code. 75245450Sganbold * 76245450Sganbold * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77245450Sganbold * Intel shall be used in advertising or otherwise to promote the sale, use or 78245450Sganbold * other dealings in products derived from or relating to the Covered Code 79245450Sganbold * without prior written authorization from Intel. 80245450Sganbold * 81245450Sganbold * 4. Disclaimer and Export Compliance 82245450Sganbold * 83245450Sganbold * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84245450Sganbold * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85263301Simp * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86245450Sganbold * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87245450Sganbold * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88263245Simp * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89263245Simp * PARTICULAR PURPOSE. 90263245Simp * 91245450Sganbold * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92245450Sganbold * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93247520Sganbold * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94247520Sganbold * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95245450Sganbold * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96245450Sganbold * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97245450Sganbold * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98245450Sganbold * LIMITED REMEDY. 99245450Sganbold * 100245450Sganbold * 4.3. Licensee shall not export, either directly or indirectly, any of this 101245450Sganbold * software or system incorporating such software without first obtaining any 102245450Sganbold * required license or other approval from the U. S. Department of Commerce or 103245450Sganbold * any other agency or department of the United States Government. In the 104245450Sganbold * event Licensee exports any such software from the United States or 105246342Sganbold * re-exports any such software from a foreign destination, Licensee shall 106245450Sganbold * ensure that the distribution and export/re-export of the software is in 107270912Simp * compliance with all laws, regulations, orders, or other restrictions of the 108245450Sganbold * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109245450Sganbold * any of its subsidiaries will export/re-export any technical data, process, 110245450Sganbold * software, or service, directly or indirectly, to any country for which the 111245450Sganbold * United States government or any agency thereof requires an export license, 112261572Sian * other governmental approval, or letter of assurance, without first obtaining 113246057Sganbold * such license, approval or letter. 114246057Sganbold * 115245450Sganbold *****************************************************************************/ 116245450Sganbold 117245450Sganbold#ifndef __ACGCC_H__ 118245450Sganbold#define __ACGCC_H__ 119246057Sganbold 120245450Sganbold 121246057Sganbold#ifdef __ia64__ 122245450Sganbold#define _IA64 123245450Sganbold 124245450Sganbold#define COMPILER_DEPENDENT_UINT64 unsigned long 125245450Sganbold/* Single threaded */ 126245450Sganbold#define ACPI_APPLICATION 127245450Sganbold 128245450Sganbold#define ACPI_ASM_MACROS 129245450Sganbold#define causeinterrupt(level) 130245450Sganbold#define BREAKPOINT3 131262711Sganbold#define disable() __cli() 132262711Sganbold#define enable() __sti() 133245450Sganbold 134245450Sganbold/*! [Begin] no source code translation */ 135245450Sganbold 136245450Sganbold#include <asm/pal.h> 137263301Simp 138263301Simp#define halt() ia64_pal_halt_light() /* PAL_HALT[_LIGHT] */ 139245450Sganbold#define safe_halt() ia64_pal_halt(1) /* PAL_HALT */ 140253845Sobrien 141 142#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ 143 do { \ 144 __asm__ volatile ("1: ld4 r29=%1\n" \ 145 ";;\n" \ 146 "mov ar.ccv=r29\n" \ 147 "mov r2=r29\n" \ 148 "shr.u r30=r29,1\n" \ 149 "and r29=-4,r29\n" \ 150 ";;\n" \ 151 "add r29=2,r29\n" \ 152 "and r30=1,r30\n" \ 153 ";;\n" \ 154 "add r29=r29,r30\n" \ 155 ";;\n" \ 156 "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ 157 ";;\n" \ 158 "cmp.eq p6,p7=r2,r30\n" \ 159 "(p7) br.dpnt.few 1b\n" \ 160 "cmp.gt p8,p9=3,r29\n" \ 161 ";;\n" \ 162 "(p8) mov %0=-1\n" \ 163 "(p9) mov %0=r0\n" \ 164 :"=r"(Acq):"m"(GLptr):"r2","r29","r30","memory"); \ 165 } while (0) 166 167#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ 168 do { \ 169 __asm__ volatile ("1: ld4 r29=%1\n" \ 170 ";;\n" \ 171 "mov ar.ccv=r29\n" \ 172 "mov r2=r29\n" \ 173 "and r29=-4,r29\n" \ 174 ";;\n" \ 175 "cmpxchg4.acq r30=%1,r29,ar.ccv\n" \ 176 ";;\n" \ 177 "cmp.eq p6,p7=r2,r30\n" \ 178 "(p7) br.dpnt.few 1b\n" \ 179 "and %0=1,r2\n" \ 180 ";;\n" \ 181 :"=r"(Acq):"m"(GLptr):"r2","r29","r30","memory"); \ 182 } while (0) 183/*! [End] no source code translation !*/ 184 185 186#else /* DO IA32 */ 187 188#define COMPILER_DEPENDENT_UINT64 unsigned long long 189#define ACPI_ASM_MACROS 190#define causeinterrupt(level) 191#define BREAKPOINT3 192#define disable() __cli() 193#define enable() __sti() 194#define halt() __asm__ __volatile__ ("sti; hlt":::"memory") 195 196/*! [Begin] no source code translation 197 * 198 * A brief explanation as GNU inline assembly is a bit hairy 199 * %0 is the output parameter in EAX ("=a") 200 * %1 and %2 are the input parameters in ECX ("c") 201 * and an immediate value ("i") respectively 202 * All actual register references are preceded with "%%" as in "%%edx" 203 * Immediate values in the assembly are preceded by "$" as in "$0x1" 204 * The final asm parameter are the operation altered non-output registers. 205 */ 206#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ 207 do { \ 208 int dummy; \ 209 asm("1: movl (%1),%%eax;" \ 210 "movl %%eax,%%edx;" \ 211 "andl %2,%%edx;" \ 212 "btsl $0x1,%%edx;" \ 213 "adcl $0x0,%%edx;" \ 214 "lock; cmpxchgl %%edx,(%1);" \ 215 "jnz 1b;" \ 216 "cmpb $0x3,%%dl;" \ 217 "sbbl %%eax,%%eax" \ 218 :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ 219 } while(0) 220 221#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ 222 do { \ 223 int dummy; \ 224 asm("1: movl (%1),%%eax;" \ 225 "movl %%eax,%%edx;" \ 226 "andl %2,%%edx;" \ 227 "lock; cmpxchgl %%edx,(%1);" \ 228 "jnz 1b;" \ 229 "andl $0x1,%%eax" \ 230 :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ 231 } while(0) 232 233 234/* 235 * Math helper asm macros 236 */ 237#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ 238 asm("divl %2;" \ 239 :"=a"(q32), "=d"(r32) \ 240 :"r"(d32), \ 241 "0"(n_lo), "1"(n_hi)) 242 243 244#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ 245 asm("shrl $1,%2;" \ 246 "rcrl $1,%3;" \ 247 :"=r"(n_hi), "=r"(n_lo) \ 248 :"0"(n_hi), "1"(n_lo)) 249 250/*! [End] no source code translation !*/ 251 252#endif /* IA 32 */ 253 254/* This macro is used to tag functions as "printf-like" because 255 * some compilers (like GCC) can catch printf format string problems. 256 */ 257#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 4, 5))) 258 259#endif /* __ACGCC_H__ */ 260