v2.4.9.2 -> v2.4.9.3
[opensuse:kernel.git] / drivers / acpi / include / platform / acgcc.h
1 /******************************************************************************
2  *
3  * Name: acgcc.h - GCC specific defines, etc.
4  *       $Revision: 6 $
5  *
6  *****************************************************************************/
7
8 /*
9  *  Copyright (C) 2000, 2001 R. Byron Moore
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 #ifndef __ACGCC_H__
27 #define __ACGCC_H__
28
29
30 #ifdef __ia64__
31 #define _IA64
32
33 #define COMPILER_DEPENDENT_UINT64   unsigned long
34 /* Single threaded */
35 #define ACPI_APPLICATION
36
37 #define ACPI_ASM_MACROS
38 #define causeinterrupt(level)
39 #define BREAKPOINT3
40 #define disable() __cli()
41 #define enable()  __sti()
42
43 /*! [Begin] no source code translation */
44
45 #include <asm/pal.h>
46
47 #define halt()              ia64_pal_halt_light()           /* PAL_HALT[_LIGHT] */
48 #define safe_halt()         ia64_pal_halt(1)                /* PAL_HALT */
49
50
51 #define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
52         do { \
53         __asm__ volatile ("1:  ld4      r29=%1\n"  \
54                 ";;\n"                  \
55                 "mov    ar.ccv=r29\n"   \
56                 "mov    r2=r29\n"       \
57                 "shr.u  r30=r29,1\n"    \
58                 "and    r29=-4,r29\n"   \
59                 ";;\n"                  \
60                 "add    r29=2,r29\n"    \
61                 "and    r30=1,r30\n"    \
62                 ";;\n"                  \
63                 "add    r29=r29,r30\n"  \
64                 ";;\n"                  \
65                 "cmpxchg4.acq   r30=%1,r29,ar.ccv\n" \
66                 ";;\n"                  \
67                 "cmp.eq p6,p7=r2,r30\n" \
68                 "(p7) br.dpnt.few 1b\n" \
69                 "cmp.gt p8,p9=3,r29\n"  \
70                 ";;\n"                  \
71                 "(p8) mov %0=-1\n"      \
72                 "(p9) mov %0=r0\n"      \
73                 :"=r"(Acq):"m"(GLptr):"r2","r29","r30","memory"); \
74         } while (0)
75
76 #define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
77         do { \
78         __asm__ volatile ("1:  ld4      r29=%1\n" \
79                 ";;\n"                  \
80                 "mov    ar.ccv=r29\n"   \
81                 "mov    r2=r29\n"       \
82                 "and    r29=-4,r29\n"   \
83                 ";;\n"                  \
84                 "cmpxchg4.acq   r30=%1,r29,ar.ccv\n" \
85                 ";;\n"                  \
86                 "cmp.eq p6,p7=r2,r30\n" \
87                 "(p7) br.dpnt.few 1b\n" \
88                 "and    %0=1,r2\n"      \
89                 ";;\n"                  \
90                 :"=r"(Acq):"m"(GLptr):"r2","r29","r30","memory"); \
91         } while (0)
92 /*! [End] no source code translation !*/
93
94
95 #else /* DO IA32 */
96 #define COMPILER_DEPENDENT_UINT64   unsigned long long
97 #define ACPI_ASM_MACROS
98 #define causeinterrupt(level)
99 #define BREAKPOINT3
100 #define disable() __cli()
101 #define enable()  __sti()
102 #define halt()    __asm__ __volatile__ ("sti; hlt":::"memory")
103
104 /*! [Begin] no source code translation
105  *
106  * A brief explanation as GNU inline assembly is a bit hairy
107  *  %0 is the output parameter in EAX ("=a")
108  *  %1 and %2 are the input parameters in ECX ("c")
109  *  and an immediate value ("i") respectively
110  *  All actual register references are preceded with "%%" as in "%%edx"
111  *  Immediate values in the assembly are preceded by "$" as in "$0x1"
112  *  The final asm parameter are the operation altered non-output registers.
113  */
114 #define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
115         do { \
116                 int dummy; \
117                 asm("1:     movl (%1),%%eax;" \
118                         "movl   %%eax,%%edx;" \
119                         "andl   %2,%%edx;" \
120                         "btsl   $0x1,%%edx;" \
121                         "adcl   $0x0,%%edx;" \
122                         "lock;  cmpxchgl %%edx,(%1);" \
123                         "jnz    1b;" \
124                         "cmpb   $0x3,%%dl;" \
125                         "sbbl   %%eax,%%eax" \
126                         :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \
127         } while(0)
128
129 #define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
130         do { \
131                 int dummy; \
132                 asm("1:     movl (%1),%%eax;" \
133                         "movl   %%eax,%%edx;" \
134                         "andl   %2,%%edx;" \
135                         "lock;  cmpxchgl %%edx,(%1);" \
136                         "jnz    1b;" \
137                         "andl   $0x1,%%eax" \
138                         :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \
139         } while(0)
140
141 /*! [End] no source code translation !*/
142
143 #endif /* IA 32 */
144
145 #endif /* __ACGCC_H__ */