aboutsummaryrefslogtreecommitdiffstats
path: root/include/acpi/acmacros.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/acpi/acmacros.h')
-rw-r--r--include/acpi/acmacros.h253
1 files changed, 120 insertions, 133 deletions
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index 74a9617776a8..a597207e2835 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -62,7 +62,7 @@
62#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) 62#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))
63 63
64/* 64/*
65 * Extract data using a pointer. Any more than a byte and we 65 * Extract data using a pointer. Any more than a byte and we
66 * get into potential aligment issues -- see the STORE macros below. 66 * get into potential aligment issues -- see the STORE macros below.
67 * Use with care. 67 * Use with care.
68 */ 68 */
@@ -80,21 +80,21 @@
80 */ 80 */
81#define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t) (p)) 81#define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t) (p))
82#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (acpi_uintptr_t) (p)) 82#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (acpi_uintptr_t) (p))
83#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8,(a)) + (acpi_size)(b))) 83#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_size)(b)))
84#define ACPI_PTR_DIFF(a, b) (acpi_size) (ACPI_CAST_PTR (u8,(a)) - ACPI_CAST_PTR (u8,(b))) 84#define ACPI_PTR_DIFF(a, b) (acpi_size) (ACPI_CAST_PTR (u8, (a)) - ACPI_CAST_PTR (u8, (b)))
85 85
86/* Pointer/Integer type conversions */ 86/* Pointer/Integer type conversions */
87 87
88#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL, (acpi_size) i) 88#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL, (acpi_size) i)
89#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) 89#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL)
90#define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) 90#define ACPI_OFFSET(d, f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL)
91#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) 91#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i)
92#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) 92#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
93 93
94#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED 94#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
95#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (u32,(a)) == *ACPI_CAST_PTR (u32,(b))) 95#define ACPI_COMPARE_NAME(a, b) (*ACPI_CAST_PTR (u32, (a)) == *ACPI_CAST_PTR (u32, (b)))
96#else 96#else
97#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char,(a)), ACPI_CAST_PTR (char,(b)), ACPI_NAME_SIZE)) 97#define ACPI_COMPARE_NAME(a, b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE))
98#endif 98#endif
99 99
100/* 100/*
@@ -114,7 +114,7 @@ struct acpi_integer_overlay {
114 114
115/* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */ 115/* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */
116 116
117#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) 117#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i)
118 118
119#if ACPI_MACHINE_WIDTH == 64 119#if ACPI_MACHINE_WIDTH == 64
120#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i) 120#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i)
@@ -132,37 +132,33 @@ struct acpi_integer_overlay {
132 * Macros for big-endian machines 132 * Macros for big-endian machines
133 */ 133 */
134 134
135/* This macro sets a buffer index, starting from the end of the buffer */
136
137#define ACPI_BUFFER_INDEX(buf_len,buf_offset,byte_gran) ((buf_len) - (((buf_offset)+1) * (byte_gran)))
138
139/* These macros reverse the bytes during the move, converting little-endian to big endian */ 135/* These macros reverse the bytes during the move, converting little-endian to big endian */
140 136
141 /* Big Endian <== Little Endian */ 137 /* Big Endian <== Little Endian */
142 /* Hi...Lo Lo...Hi */ 138 /* Hi...Lo Lo...Hi */
143/* 16-bit source, 16/32/64 destination */ 139/* 16-bit source, 16/32/64 destination */
144 140
145#define ACPI_MOVE_16_TO_16(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\ 141#define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\
146 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];} 142 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];}
147 143
148#define ACPI_MOVE_16_TO_32(d,s) {(*(u32 *)(void *)(d))=0;\ 144#define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d))=0;\
149 ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ 145 ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
150 ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} 146 ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
151 147
152#define ACPI_MOVE_16_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\ 148#define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\
153 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\ 149 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
154 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];} 150 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
155 151
156/* 32-bit source, 16/32/64 destination */ 152/* 32-bit source, 16/32/64 destination */
157 153
158#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 154#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
159 155
160#define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\ 156#define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\
161 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\ 157 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\
162 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ 158 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
163 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} 159 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
164 160
165#define ACPI_MOVE_32_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\ 161#define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\
166 ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\ 162 ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
167 ((u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\ 163 ((u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\
168 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\ 164 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
@@ -170,11 +166,11 @@ struct acpi_integer_overlay {
170 166
171/* 64-bit source, 16/32/64 destination */ 167/* 64-bit source, 16/32/64 destination */
172 168
173#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 169#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
174 170
175#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ 171#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
176 172
177#define ACPI_MOVE_64_TO_64(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7];\ 173#define ACPI_MOVE_64_TO_64(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7];\
178 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6];\ 174 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6];\
179 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[5];\ 175 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[5];\
180 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[4];\ 176 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[4];\
@@ -187,63 +183,59 @@ struct acpi_integer_overlay {
187 * Macros for little-endian machines 183 * Macros for little-endian machines
188 */ 184 */
189 185
190/* This macro sets a buffer index, starting from the beginning of the buffer */
191
192#define ACPI_BUFFER_INDEX(buf_len,buf_offset,byte_gran) (buf_offset)
193
194#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED 186#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
195 187
196/* The hardware supports unaligned transfers, just do the little-endian move */ 188/* The hardware supports unaligned transfers, just do the little-endian move */
197 189
198/* 16-bit source, 16/32/64 destination */ 190/* 16-bit source, 16/32/64 destination */
199 191
200#define ACPI_MOVE_16_TO_16(d,s) *(u16 *)(void *)(d) = *(u16 *)(void *)(s) 192#define ACPI_MOVE_16_TO_16(d, s) *(u16 *)(void *)(d) = *(u16 *)(void *)(s)
201#define ACPI_MOVE_16_TO_32(d,s) *(u32 *)(void *)(d) = *(u16 *)(void *)(s) 193#define ACPI_MOVE_16_TO_32(d, s) *(u32 *)(void *)(d) = *(u16 *)(void *)(s)
202#define ACPI_MOVE_16_TO_64(d,s) *(u64 *)(void *)(d) = *(u16 *)(void *)(s) 194#define ACPI_MOVE_16_TO_64(d, s) *(u64 *)(void *)(d) = *(u16 *)(void *)(s)
203 195
204/* 32-bit source, 16/32/64 destination */ 196/* 32-bit source, 16/32/64 destination */
205 197
206#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 198#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
207#define ACPI_MOVE_32_TO_32(d,s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s) 199#define ACPI_MOVE_32_TO_32(d, s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
208#define ACPI_MOVE_32_TO_64(d,s) *(u64 *)(void *)(d) = *(u32 *)(void *)(s) 200#define ACPI_MOVE_32_TO_64(d, s) *(u64 *)(void *)(d) = *(u32 *)(void *)(s)
209 201
210/* 64-bit source, 16/32/64 destination */ 202/* 64-bit source, 16/32/64 destination */
211 203
212#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 204#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
213#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ 205#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
214#define ACPI_MOVE_64_TO_64(d,s) *(u64 *)(void *)(d) = *(u64 *)(void *)(s) 206#define ACPI_MOVE_64_TO_64(d, s) *(u64 *)(void *)(d) = *(u64 *)(void *)(s)
215 207
216#else 208#else
217/* 209/*
218 * The hardware does not support unaligned transfers. We must move the 210 * The hardware does not support unaligned transfers. We must move the
219 * data one byte at a time. These macros work whether the source or 211 * data one byte at a time. These macros work whether the source or
220 * the destination (or both) is/are unaligned. (Little-endian move) 212 * the destination (or both) is/are unaligned. (Little-endian move)
221 */ 213 */
222 214
223/* 16-bit source, 16/32/64 destination */ 215/* 16-bit source, 16/32/64 destination */
224 216
225#define ACPI_MOVE_16_TO_16(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\ 217#define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
226 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];} 218 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];}
227 219
228#define ACPI_MOVE_16_TO_32(d,s) {(*(u32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d,s);} 220#define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
229#define ACPI_MOVE_16_TO_64(d,s) {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d,s);} 221#define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
230 222
231/* 32-bit source, 16/32/64 destination */ 223/* 32-bit source, 16/32/64 destination */
232 224
233#define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 225#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
234 226
235#define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\ 227#define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
236 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\ 228 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
237 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\ 229 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
238 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];} 230 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];}
239 231
240#define ACPI_MOVE_32_TO_64(d,s) {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d,s);} 232#define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d, s);}
241 233
242/* 64-bit source, 16/32/64 destination */ 234/* 64-bit source, 16/32/64 destination */
243 235
244#define ACPI_MOVE_64_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ 236#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
245#define ACPI_MOVE_64_TO_32(d,s) ACPI_MOVE_32_TO_32(d,s) /* Truncate to 32 */ 237#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
246#define ACPI_MOVE_64_TO_64(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\ 238#define ACPI_MOVE_64_TO_64(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
247 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\ 239 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
248 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\ 240 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
249 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];\ 241 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];\
@@ -257,10 +249,10 @@ struct acpi_integer_overlay {
257/* Macros based on machine integer width */ 249/* Macros based on machine integer width */
258 250
259#if ACPI_MACHINE_WIDTH == 32 251#if ACPI_MACHINE_WIDTH == 32
260#define ACPI_MOVE_SIZE_TO_16(d,s) ACPI_MOVE_32_TO_16(d,s) 252#define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_32_TO_16(d, s)
261 253
262#elif ACPI_MACHINE_WIDTH == 64 254#elif ACPI_MACHINE_WIDTH == 64
263#define ACPI_MOVE_SIZE_TO_16(d,s) ACPI_MOVE_64_TO_16(d,s) 255#define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_64_TO_16(d, s)
264 256
265#else 257#else
266#error unknown ACPI_MACHINE_WIDTH 258#error unknown ACPI_MACHINE_WIDTH
@@ -269,29 +261,29 @@ struct acpi_integer_overlay {
269/* 261/*
270 * Fast power-of-two math macros for non-optimized compilers 262 * Fast power-of-two math macros for non-optimized compilers
271 */ 263 */
272#define _ACPI_DIV(value,power_of2) ((u32) ((value) >> (power_of2))) 264#define _ACPI_DIV(value, power_of2) ((u32) ((value) >> (power_of2)))
273#define _ACPI_MUL(value,power_of2) ((u32) ((value) << (power_of2))) 265#define _ACPI_MUL(value, power_of2) ((u32) ((value) << (power_of2)))
274#define _ACPI_MOD(value,divisor) ((u32) ((value) & ((divisor) -1))) 266#define _ACPI_MOD(value, divisor) ((u32) ((value) & ((divisor) -1)))
275 267
276#define ACPI_DIV_2(a) _ACPI_DIV(a,1) 268#define ACPI_DIV_2(a) _ACPI_DIV(a, 1)
277#define ACPI_MUL_2(a) _ACPI_MUL(a,1) 269#define ACPI_MUL_2(a) _ACPI_MUL(a, 1)
278#define ACPI_MOD_2(a) _ACPI_MOD(a,2) 270#define ACPI_MOD_2(a) _ACPI_MOD(a, 2)
279 271
280#define ACPI_DIV_4(a) _ACPI_DIV(a,2) 272#define ACPI_DIV_4(a) _ACPI_DIV(a, 2)
281#define ACPI_MUL_4(a) _ACPI_MUL(a,2) 273#define ACPI_MUL_4(a) _ACPI_MUL(a, 2)
282#define ACPI_MOD_4(a) _ACPI_MOD(a,4) 274#define ACPI_MOD_4(a) _ACPI_MOD(a, 4)
283 275
284#define ACPI_DIV_8(a) _ACPI_DIV(a,3) 276#define ACPI_DIV_8(a) _ACPI_DIV(a, 3)
285#define ACPI_MUL_8(a) _ACPI_MUL(a,3) 277#define ACPI_MUL_8(a) _ACPI_MUL(a, 3)
286#define ACPI_MOD_8(a) _ACPI_MOD(a,8) 278#define ACPI_MOD_8(a) _ACPI_MOD(a, 8)
287 279
288#define ACPI_DIV_16(a) _ACPI_DIV(a,4) 280#define ACPI_DIV_16(a) _ACPI_DIV(a, 4)
289#define ACPI_MUL_16(a) _ACPI_MUL(a,4) 281#define ACPI_MUL_16(a) _ACPI_MUL(a, 4)
290#define ACPI_MOD_16(a) _ACPI_MOD(a,16) 282#define ACPI_MOD_16(a) _ACPI_MOD(a, 16)
291 283
292#define ACPI_DIV_32(a) _ACPI_DIV(a,5) 284#define ACPI_DIV_32(a) _ACPI_DIV(a, 5)
293#define ACPI_MUL_32(a) _ACPI_MUL(a,5) 285#define ACPI_MUL_32(a) _ACPI_MUL(a, 5)
294#define ACPI_MOD_32(a) _ACPI_MOD(a,32) 286#define ACPI_MOD_32(a) _ACPI_MOD(a, 32)
295 287
296/* 288/*
297 * Rounding macros (Power of two boundaries only) 289 * Rounding macros (Power of two boundaries only)
@@ -305,13 +297,13 @@ struct acpi_integer_overlay {
305 297
306/* Note: sizeof(acpi_size) evaluates to either 4 or 8 (32- vs 64-bit mode) */ 298/* Note: sizeof(acpi_size) evaluates to either 4 or 8 (32- vs 64-bit mode) */
307 299
308#define ACPI_ROUND_DOWN_TO_32BIT(a) ACPI_ROUND_DOWN(a,4) 300#define ACPI_ROUND_DOWN_TO_32BIT(a) ACPI_ROUND_DOWN(a, 4)
309#define ACPI_ROUND_DOWN_TO_64BIT(a) ACPI_ROUND_DOWN(a,8) 301#define ACPI_ROUND_DOWN_TO_64BIT(a) ACPI_ROUND_DOWN(a, 8)
310#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a,sizeof(acpi_size)) 302#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a, sizeof(acpi_size))
311 303
312#define ACPI_ROUND_UP_TO_32BIT(a) ACPI_ROUND_UP(a,4) 304#define ACPI_ROUND_UP_TO_32BIT(a) ACPI_ROUND_UP(a, 4)
313#define ACPI_ROUND_UP_TO_64BIT(a) ACPI_ROUND_UP(a,8) 305#define ACPI_ROUND_UP_TO_64BIT(a) ACPI_ROUND_UP(a, 8)
314#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,sizeof(acpi_size)) 306#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a, sizeof(acpi_size))
315 307
316#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) 308#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7)
317#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) 309#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a))
@@ -320,9 +312,9 @@ struct acpi_integer_overlay {
320 312
321/* Generic (non-power-of-two) rounding */ 313/* Generic (non-power-of-two) rounding */
322 314
323#define ACPI_ROUND_UP_TO(value,boundary) (((value) + ((boundary)-1)) / (boundary)) 315#define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary))
324 316
325#define ACPI_IS_MISALIGNED(value) (((acpi_size)value) & (sizeof(acpi_size)-1)) 317#define ACPI_IS_MISALIGNED(value) (((acpi_size) value) & (sizeof(acpi_size)-1))
326 318
327/* 319/*
328 * Bitmask creation 320 * Bitmask creation
@@ -333,8 +325,6 @@ struct acpi_integer_overlay {
333#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position)))) 325#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position))))
334#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position))) 326#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position)))
335 327
336#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7'))
337
338/* Bitfields within ACPI registers */ 328/* Bitfields within ACPI registers */
339 329
340#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) 330#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask)
@@ -342,39 +332,29 @@ struct acpi_integer_overlay {
342 332
343#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask)) 333#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask))
344 334
345/* Generate a UUID */
346
347#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
348 (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \
349 (b) & 0xFF, ((b) >> 8) & 0xFF, \
350 (c) & 0xFF, ((c) >> 8) & 0xFF, \
351 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)
352
353/* 335/*
354 * An struct acpi_namespace_node * can appear in some contexts, 336 * An struct acpi_namespace_node can appear in some contexts
355 * where a pointer to an union acpi_operand_object can also 337 * where a pointer to an union acpi_operand_object can also
356 * appear. This macro is used to distinguish them. 338 * appear. This macro is used to distinguish them.
357 * 339 *
358 * The "Descriptor" field is the first field in both structures. 340 * The "Descriptor" field is the first field in both structures.
359 */ 341 */
360#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type) 342#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type)
361#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t) 343#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t)
362 344
363/* Macro to test the object type */ 345/* Macro to test the object type */
364 346
365#define ACPI_GET_OBJECT_TYPE(d) (((union acpi_operand_object *)(void *)(d))->common.type) 347#define ACPI_GET_OBJECT_TYPE(d) (((union acpi_operand_object *)(void *)(d))->common.type)
366 348
367/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */
368
369#define ACPI_IS_SINGLE_TABLE(x) (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0)
370
371/* 349/*
372 * Macros for the master AML opcode table 350 * Macros for the master AML opcode table
373 */ 351 */
374#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) 352#if defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
375#define ACPI_OP(name,Pargs,Iargs,obj_type,class,type,flags) {name,(u32)(Pargs),(u32)(Iargs),(u32)(flags),obj_type,class,type} 353#define ACPI_OP(name, Pargs, Iargs, obj_type, class, type, flags) \
354 {name, (u32)(Pargs), (u32)(Iargs), (u32)(flags), obj_type, class, type}
376#else 355#else
377#define ACPI_OP(name,Pargs,Iargs,obj_type,class,type,flags) {(u32)(Pargs),(u32)(Iargs),(u32)(flags),obj_type,class,type} 356#define ACPI_OP(name, Pargs, Iargs, obj_type, class, type, flags) \
357 {(u32)(Pargs), (u32)(Iargs), (u32)(flags), obj_type, class, type}
378#endif 358#endif
379 359
380#ifdef ACPI_DISASSEMBLER 360#ifdef ACPI_DISASSEMBLER
@@ -392,18 +372,18 @@ struct acpi_integer_overlay {
392#define ARG_6(x) ((u32)(x) << (5 * ARG_TYPE_WIDTH)) 372#define ARG_6(x) ((u32)(x) << (5 * ARG_TYPE_WIDTH))
393 373
394#define ARGI_LIST1(a) (ARG_1(a)) 374#define ARGI_LIST1(a) (ARG_1(a))
395#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a)) 375#define ARGI_LIST2(a, b) (ARG_1(b)|ARG_2(a))
396#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) 376#define ARGI_LIST3(a, b, c) (ARG_1(c)|ARG_2(b)|ARG_3(a))
397#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) 377#define ARGI_LIST4(a, b, c, d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
398#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) 378#define ARGI_LIST5(a, b, c, d, e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
399#define ARGI_LIST6(a,b,c,d,e,f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) 379#define ARGI_LIST6(a, b, c, d, e, f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a))
400 380
401#define ARGP_LIST1(a) (ARG_1(a)) 381#define ARGP_LIST1(a) (ARG_1(a))
402#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b)) 382#define ARGP_LIST2(a, b) (ARG_1(a)|ARG_2(b))
403#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) 383#define ARGP_LIST3(a, b, c) (ARG_1(a)|ARG_2(b)|ARG_3(c))
404#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) 384#define ARGP_LIST4(a, b, c, d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
405#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) 385#define ARGP_LIST5(a, b, c, d, e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
406#define ARGP_LIST6(a,b,c,d,e,f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) 386#define ARGP_LIST6(a, b, c, d, e, f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f))
407 387
408#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F)) 388#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F))
409#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH)) 389#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH))
@@ -434,8 +414,8 @@ struct acpi_integer_overlay {
434#define ACPI_WARNING(plist) acpi_ut_warning plist 414#define ACPI_WARNING(plist) acpi_ut_warning plist
435#define ACPI_EXCEPTION(plist) acpi_ut_exception plist 415#define ACPI_EXCEPTION(plist) acpi_ut_exception plist
436#define ACPI_ERROR(plist) acpi_ut_error plist 416#define ACPI_ERROR(plist) acpi_ut_error plist
437#define ACPI_ERROR_NAMESPACE(s,e) acpi_ns_report_error (AE_INFO, s, e); 417#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e);
438#define ACPI_ERROR_METHOD(s,n,p,e) acpi_ns_report_method_error (AE_INFO, s, n, p, e); 418#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e);
439 419
440#else 420#else
441 421
@@ -445,8 +425,8 @@ struct acpi_integer_overlay {
445#define ACPI_WARNING(plist) 425#define ACPI_WARNING(plist)
446#define ACPI_EXCEPTION(plist) 426#define ACPI_EXCEPTION(plist)
447#define ACPI_ERROR(plist) 427#define ACPI_ERROR(plist)
448#define ACPI_ERROR_NAMESPACE(s,e) 428#define ACPI_ERROR_NAMESPACE(s, e)
449#define ACPI_ERROR_METHOD(s,n,p,e) 429#define ACPI_ERROR_METHOD(s, n, p, e)
450#endif 430#endif
451 431
452/* 432/*
@@ -489,18 +469,18 @@ struct acpi_integer_overlay {
489 469
490#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ 470#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
491 acpi_ut_trace(ACPI_DEBUG_PARAMETERS) 471 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
492#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ 472#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \
493 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b) 473 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS, (void *)b)
494#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ 474#define ACPI_FUNCTION_TRACE_U32(a, b) ACPI_FUNCTION_NAME(a) \
495 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS,(u32)b) 475 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS, (u32)b)
496#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ 476#define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_FUNCTION_NAME(a) \
497 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS,(char *)b) 477 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS, (char *)b)
498 478
499#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr() 479#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr()
500 480
501/* 481/*
502 * Function exit tracing. 482 * Function exit tracing.
503 * WARNING: These macros include a return statement. This is usually considered 483 * WARNING: These macros include a return statement. This is usually considered
504 * bad form, but having a separate exit macro is very ugly and difficult to maintain. 484 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
505 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros 485 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
506 * so that "_AcpiFunctionName" is defined. 486 * so that "_AcpiFunctionName" is defined.
@@ -596,13 +576,13 @@ struct acpi_integer_overlay {
596 576
597/* Stack and buffer dumping */ 577/* Stack and buffer dumping */
598 578
599#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a),0) 579#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0)
600#define ACPI_DUMP_OPERANDS(a,b,c) acpi_ex_dump_operands(a,b,c) 580#define ACPI_DUMP_OPERANDS(a, b, c) acpi_ex_dump_operands(a, b, c)
601 581
602#define ACPI_DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b) 582#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b)
603#define ACPI_DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d) 583#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d)
604#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a) 584#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a)
605#define ACPI_DUMP_BUFFER(a,b) acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) 585#define ACPI_DUMP_BUFFER(a, b) acpi_ut_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
606 586
607/* 587/*
608 * Master debug print macros 588 * Master debug print macros
@@ -625,20 +605,20 @@ struct acpi_integer_overlay {
625#define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while(0) 605#define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while(0)
626#define ACPI_FUNCTION_NAME(a) do { } while(0) 606#define ACPI_FUNCTION_NAME(a) do { } while(0)
627#define ACPI_FUNCTION_TRACE(a) do { } while(0) 607#define ACPI_FUNCTION_TRACE(a) do { } while(0)
628#define ACPI_FUNCTION_TRACE_PTR(a,b) do { } while(0) 608#define ACPI_FUNCTION_TRACE_PTR(a, b) do { } while(0)
629#define ACPI_FUNCTION_TRACE_U32(a,b) do { } while(0) 609#define ACPI_FUNCTION_TRACE_U32(a, b) do { } while(0)
630#define ACPI_FUNCTION_TRACE_STR(a,b) do { } while(0) 610#define ACPI_FUNCTION_TRACE_STR(a, b) do { } while(0)
631#define ACPI_FUNCTION_EXIT do { } while(0) 611#define ACPI_FUNCTION_EXIT do { } while(0)
632#define ACPI_FUNCTION_STATUS_EXIT(s) do { } while(0) 612#define ACPI_FUNCTION_STATUS_EXIT(s) do { } while(0)
633#define ACPI_FUNCTION_VALUE_EXIT(s) do { } while(0) 613#define ACPI_FUNCTION_VALUE_EXIT(s) do { } while(0)
634#define ACPI_FUNCTION_ENTRY() do { } while(0) 614#define ACPI_FUNCTION_ENTRY() do { } while(0)
635#define ACPI_DUMP_STACK_ENTRY(a) do { } while(0) 615#define ACPI_DUMP_STACK_ENTRY(a) do { } while(0)
636#define ACPI_DUMP_OPERANDS(a,b,c) do { } while(0) 616#define ACPI_DUMP_OPERANDS(a, b, c) do { } while(0)
637#define ACPI_DUMP_ENTRY(a,b) do { } while(0) 617#define ACPI_DUMP_ENTRY(a, b) do { } while(0)
638#define ACPI_DUMP_TABLES(a,b) do { } while(0) 618#define ACPI_DUMP_TABLES(a, b) do { } while(0)
639#define ACPI_DUMP_PATHNAME(a,b,c,d) do { } while(0) 619#define ACPI_DUMP_PATHNAME(a, b, c, d) do { } while(0)
640#define ACPI_DUMP_RESOURCE_LIST(a) do { } while(0) 620#define ACPI_DUMP_RESOURCE_LIST(a) do { } while(0)
641#define ACPI_DUMP_BUFFER(a,b) do { } while(0) 621#define ACPI_DUMP_BUFFER(a, b) do { } while(0)
642#define ACPI_DEBUG_PRINT(pl) do { } while(0) 622#define ACPI_DEBUG_PRINT(pl) do { } while(0)
643#define ACPI_DEBUG_PRINT_RAW(pl) do { } while(0) 623#define ACPI_DEBUG_PRINT_RAW(pl) do { } while(0)
644 624
@@ -677,15 +657,17 @@ struct acpi_integer_overlay {
677/* 657/*
678 * Memory allocation tracking (DEBUG ONLY) 658 * Memory allocation tracking (DEBUG ONLY)
679 */ 659 */
660#define ACPI_MEM_PARAMETERS _COMPONENT, _acpi_module_name, __LINE__
661
680#ifndef ACPI_DBG_TRACK_ALLOCATIONS 662#ifndef ACPI_DBG_TRACK_ALLOCATIONS
681 663
682/* Memory allocation */ 664/* Memory allocation */
683 665
684#ifndef ACPI_ALLOCATE 666#ifndef ACPI_ALLOCATE
685#define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) 667#define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a), ACPI_MEM_PARAMETERS)
686#endif 668#endif
687#ifndef ACPI_ALLOCATE_ZEROED 669#ifndef ACPI_ALLOCATE_ZEROED
688#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) 670#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size)(a), ACPI_MEM_PARAMETERS)
689#endif 671#endif
690#ifndef ACPI_FREE 672#ifndef ACPI_FREE
691#define ACPI_FREE(a) acpio_os_free(a) 673#define ACPI_FREE(a) acpio_os_free(a)
@@ -696,11 +678,16 @@ struct acpi_integer_overlay {
696 678
697/* Memory allocation */ 679/* Memory allocation */
698 680
699#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) 681#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS)
700#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) 682#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS)
701#define ACPI_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__) 683#define ACPI_FREE(a) acpi_ut_free_and_track(a, ACPI_MEM_PARAMETERS)
702#define ACPI_MEM_TRACKING(a) a 684#define ACPI_MEM_TRACKING(a) a
703 685
704#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 686#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
705 687
688/* Preemption point */
689#ifndef ACPI_PREEMPTION_POINT
690#define ACPI_PREEMPTION_POINT() /* no preemption */
691#endif
692
706#endif /* ACMACROS_H */ 693#endif /* ACMACROS_H */