aboutsummaryrefslogtreecommitdiffstats
path: root/include/acpi/acmacros.h
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-07-03 10:25:08 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2006-07-03 10:25:08 -0400
commit0a1340c185734a57fbf4775927966ad4a1347b02 (patch)
treed9ed8f0dd809a7c542a3356601125ea5b5aaa804 /include/acpi/acmacros.h
parentaf18ddb8864b096e3ed4732e2d4b21c956dcfe3a (diff)
parent29454dde27d8e340bb1987bad9aa504af7081eba (diff)
Merge rsync://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: include/linux/kernel.h
Diffstat (limited to 'include/acpi/acmacros.h')
-rw-r--r--include/acpi/acmacros.h83
1 files changed, 49 insertions, 34 deletions
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index f2be2a881730..4bb38068f40d 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -56,6 +56,10 @@
56#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) 56#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit))
57#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) 57#define ACPI_MIN(a,b) (((a)<(b))?(a):(b))
58 58
59/* Size calculation */
60
61#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))
62
59#if ACPI_MACHINE_WIDTH == 16 63#if ACPI_MACHINE_WIDTH == 16
60 64
61/* 65/*
@@ -99,7 +103,7 @@
99 * printf() format helpers 103 * printf() format helpers
100 */ 104 */
101 105
102/* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */ 106/* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */
103 107
104#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) 108#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i)
105 109
@@ -130,7 +134,6 @@
130#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void,(void *) NULL,(acpi_native_uint) i) 134#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void,(void *) NULL,(acpi_native_uint) i)
131#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) 135#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL)
132#define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) 136#define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL)
133#define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f)
134 137
135#if ACPI_MACHINE_WIDTH == 16 138#if ACPI_MACHINE_WIDTH == 16
136#define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) 139#define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s)
@@ -141,6 +144,12 @@
141#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) 144#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
142#endif 145#endif
143 146
147#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
148#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (u32,(a)) == *ACPI_CAST_PTR (u32,(b)))
149#else
150#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char,(a)), ACPI_CAST_PTR (char,(b)), ACPI_NAME_SIZE))
151#endif
152
144/* 153/*
145 * Macros for moving data around to/from buffers that are possibly unaligned. 154 * Macros for moving data around to/from buffers that are possibly unaligned.
146 * If the hardware supports the transfer of unaligned data, just do the store. 155 * If the hardware supports the transfer of unaligned data, just do the store.
@@ -341,29 +350,33 @@
341/* 350/*
342 * Rounding macros (Power of two boundaries only) 351 * Rounding macros (Power of two boundaries only)
343 */ 352 */
344#define ACPI_ROUND_DOWN(value,boundary) (((acpi_native_uint)(value)) & \ 353#define ACPI_ROUND_DOWN(value,boundary) (((acpi_native_uint)(value)) & \
345 (~(((acpi_native_uint) boundary)-1))) 354 (~(((acpi_native_uint) boundary)-1)))
346 355
347#define ACPI_ROUND_UP(value,boundary) ((((acpi_native_uint)(value)) + \ 356#define ACPI_ROUND_UP(value,boundary) ((((acpi_native_uint)(value)) + \
348 (((acpi_native_uint) boundary)-1)) & \ 357 (((acpi_native_uint) boundary)-1)) & \
349 (~(((acpi_native_uint) boundary)-1))) 358 (~(((acpi_native_uint) boundary)-1)))
350 359
351#define ACPI_ROUND_DOWN_TO_32_BITS(a) ACPI_ROUND_DOWN(a,4) 360/* Note: sizeof(acpi_native_uint) evaluates to either 2, 4, or 8 */
352#define ACPI_ROUND_DOWN_TO_64_BITS(a) ACPI_ROUND_DOWN(a,8) 361
353#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) 362#define ACPI_ROUND_DOWN_TO_32BIT(a) ACPI_ROUND_DOWN(a,4)
363#define ACPI_ROUND_DOWN_TO_64BIT(a) ACPI_ROUND_DOWN(a,8)
364#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a,sizeof(acpi_native_uint))
354 365
355#define ACPI_ROUND_UP_to_32_bITS(a) ACPI_ROUND_UP(a,4) 366#define ACPI_ROUND_UP_TO_32BIT(a) ACPI_ROUND_UP(a,4)
356#define ACPI_ROUND_UP_to_64_bITS(a) ACPI_ROUND_UP(a,8) 367#define ACPI_ROUND_UP_TO_64BIT(a) ACPI_ROUND_UP(a,8)
357#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) 368#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,sizeof(acpi_native_uint))
358 369
359#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) 370#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7)
360#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) 371#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a))
361 372
362#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10) 373#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10)
363 374
364/* Generic (non-power-of-two) rounding */ 375/* Generic (non-power-of-two) rounding */
365 376
366#define ACPI_ROUND_UP_TO(value,boundary) (((value) + ((boundary)-1)) / (boundary)) 377#define ACPI_ROUND_UP_TO(value,boundary) (((value) + ((boundary)-1)) / (boundary))
378
379#define ACPI_IS_MISALIGNED(value) (((acpi_native_uint)value) & (sizeof(acpi_native_uint)-1))
367 380
368/* 381/*
369 * Bitmask creation 382 * Bitmask creation
@@ -371,16 +384,18 @@
371 * MASK_BITS_ABOVE creates a mask starting AT the position and above 384 * MASK_BITS_ABOVE creates a mask starting AT the position and above
372 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position 385 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
373 */ 386 */
374#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position)))) 387#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position))))
375#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position))) 388#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position)))
376 389
377#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) 390#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7'))
378 391
379/* Bitfields within ACPI registers */ 392/* Bitfields within ACPI registers */
380 393
381#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) 394#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask)
382#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) 395#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
383 396
397#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask))
398
384/* Generate a UUID */ 399/* Generate a UUID */
385 400
386#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ 401#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
@@ -396,8 +411,8 @@
396 * 411 *
397 * The "Descriptor" field is the first field in both structures. 412 * The "Descriptor" field is the first field in both structures.
398 */ 413 */
399#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->descriptor_id) 414#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type)
400#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((union acpi_descriptor *)(void *)(d))->descriptor_id = t) 415#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t)
401 416
402/* Macro to test the object type */ 417/* Macro to test the object type */
403 418
@@ -486,7 +501,6 @@
486#define ACPI_ERROR(plist) 501#define ACPI_ERROR(plist)
487#define ACPI_ERROR_NAMESPACE(s,e) 502#define ACPI_ERROR_NAMESPACE(s,e)
488#define ACPI_ERROR_METHOD(s,n,p,e) 503#define ACPI_ERROR_METHOD(s,n,p,e)
489
490#endif 504#endif
491 505
492/* 506/*
@@ -514,12 +528,12 @@
514#define ACPI_GET_FUNCTION_NAME _acpi_function_name 528#define ACPI_GET_FUNCTION_NAME _acpi_function_name
515/* 529/*
516 * The Name parameter should be the procedure name as a quoted string. 530 * The Name parameter should be the procedure name as a quoted string.
517 * This is declared as a local string ("my_function_name") so that it can 531 * This is declared as a local string ("MyFunctionName") so that it can
518 * be also used by the function exit macros below. 532 * be also used by the function exit macros below.
519 * Note: (const char) is used to be compatible with the debug interfaces 533 * Note: (const char) is used to be compatible with the debug interfaces
520 * and macros such as __FUNCTION__. 534 * and macros such as __FUNCTION__.
521 */ 535 */
522#define ACPI_FUNCTION_NAME(name) const char *_acpi_function_name = name; 536#define ACPI_FUNCTION_NAME(name) const char *_acpi_function_name = #name;
523 537
524#else 538#else
525/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ 539/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */
@@ -528,13 +542,13 @@
528#endif 542#endif
529 543
530#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ 544#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
531 acpi_ut_trace(ACPI_DEBUG_PARAMETERS) 545 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
532#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ 546#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \
533 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b) 547 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b)
534#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ 548#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \
535 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS,(u32)b) 549 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS,(u32)b)
536#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ 550#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \
537 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS,(char *)b) 551 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS,(char *)b)
538 552
539#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr() 553#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr()
540 554
@@ -543,7 +557,7 @@
543 * WARNING: These macros include a return statement. This is usually considered 557 * WARNING: These macros include a return statement. This is usually considered
544 * bad form, but having a separate exit macro is very ugly and difficult to maintain. 558 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
545 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros 559 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
546 * so that "_acpi_function_name" is defined. 560 * so that "_AcpiFunctionName" is defined.
547 * 561 *
548 * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining 562 * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining
549 * about these constructs. 563 * about these constructs.
@@ -654,6 +668,7 @@
654#define ACPI_DUMP_STACK_ENTRY(a) 668#define ACPI_DUMP_STACK_ENTRY(a)
655#define ACPI_DUMP_OPERANDS(a,b,c,d,e) 669#define ACPI_DUMP_OPERANDS(a,b,c,d,e)
656#define ACPI_DUMP_ENTRY(a,b) 670#define ACPI_DUMP_ENTRY(a,b)
671#define ACPI_DUMP_TABLES(a,b)
657#define ACPI_DUMP_PATHNAME(a,b,c,d) 672#define ACPI_DUMP_PATHNAME(a,b,c,d)
658#define ACPI_DUMP_RESOURCE_LIST(a) 673#define ACPI_DUMP_RESOURCE_LIST(a)
659#define ACPI_DUMP_BUFFER(a,b) 674#define ACPI_DUMP_BUFFER(a,b)
@@ -709,19 +724,19 @@
709 724
710/* Memory allocation */ 725/* Memory allocation */
711 726
712#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) 727#define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__)
713#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) 728#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__)
714#define ACPI_MEM_FREE(a) acpi_os_free(a) 729#define ACPI_FREE(a) acpi_os_free(a)
715#define ACPI_MEM_TRACKING(a) 730#define ACPI_MEM_TRACKING(a)
716 731
717#else 732#else
718 733
719/* Memory allocation */ 734/* Memory allocation */
720 735
721#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) 736#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__)
722#define ACPI_MEM_CALLOCATE(a) acpi_ut_callocate_and_track((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__) 737#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track((acpi_size)(a), _COMPONENT,_acpi_module_name,__LINE__)
723#define ACPI_MEM_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__) 738#define ACPI_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__)
724#define ACPI_MEM_TRACKING(a) a 739#define ACPI_MEM_TRACKING(a) a
725 740
726#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 741#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
727 742