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.h81
1 files changed, 47 insertions, 34 deletions
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index f2be2a881730..38f9aa4bef00 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,10 +384,10 @@
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
@@ -396,8 +409,8 @@
396 * 409 *
397 * The "Descriptor" field is the first field in both structures. 410 * The "Descriptor" field is the first field in both structures.
398 */ 411 */
399#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->descriptor_id) 412#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) 413#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t)
401 414
402/* Macro to test the object type */ 415/* Macro to test the object type */
403 416
@@ -486,7 +499,6 @@
486#define ACPI_ERROR(plist) 499#define ACPI_ERROR(plist)
487#define ACPI_ERROR_NAMESPACE(s,e) 500#define ACPI_ERROR_NAMESPACE(s,e)
488#define ACPI_ERROR_METHOD(s,n,p,e) 501#define ACPI_ERROR_METHOD(s,n,p,e)
489
490#endif 502#endif
491 503
492/* 504/*
@@ -514,12 +526,12 @@
514#define ACPI_GET_FUNCTION_NAME _acpi_function_name 526#define ACPI_GET_FUNCTION_NAME _acpi_function_name
515/* 527/*
516 * The Name parameter should be the procedure name as a quoted string. 528 * 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 529 * This is declared as a local string ("MyFunctionName") so that it can
518 * be also used by the function exit macros below. 530 * be also used by the function exit macros below.
519 * Note: (const char) is used to be compatible with the debug interfaces 531 * Note: (const char) is used to be compatible with the debug interfaces
520 * and macros such as __FUNCTION__. 532 * and macros such as __FUNCTION__.
521 */ 533 */
522#define ACPI_FUNCTION_NAME(name) const char *_acpi_function_name = name; 534#define ACPI_FUNCTION_NAME(name) const char *_acpi_function_name = #name;
523 535
524#else 536#else
525/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ 537/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */
@@ -528,13 +540,13 @@
528#endif 540#endif
529 541
530#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ 542#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
531 acpi_ut_trace(ACPI_DEBUG_PARAMETERS) 543 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
532#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ 544#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \
533 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b) 545 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS,(void *)b)
534#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ 546#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \
535 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS,(u32)b) 547 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS,(u32)b)
536#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ 548#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \
537 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS,(char *)b) 549 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS,(char *)b)
538 550
539#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr() 551#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr()
540 552
@@ -543,7 +555,7 @@
543 * WARNING: These macros include a return statement. This is usually considered 555 * 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. 556 * 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 557 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
546 * so that "_acpi_function_name" is defined. 558 * so that "_AcpiFunctionName" is defined.
547 * 559 *
548 * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining 560 * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining
549 * about these constructs. 561 * about these constructs.
@@ -654,6 +666,7 @@
654#define ACPI_DUMP_STACK_ENTRY(a) 666#define ACPI_DUMP_STACK_ENTRY(a)
655#define ACPI_DUMP_OPERANDS(a,b,c,d,e) 667#define ACPI_DUMP_OPERANDS(a,b,c,d,e)
656#define ACPI_DUMP_ENTRY(a,b) 668#define ACPI_DUMP_ENTRY(a,b)
669#define ACPI_DUMP_TABLES(a,b)
657#define ACPI_DUMP_PATHNAME(a,b,c,d) 670#define ACPI_DUMP_PATHNAME(a,b,c,d)
658#define ACPI_DUMP_RESOURCE_LIST(a) 671#define ACPI_DUMP_RESOURCE_LIST(a)
659#define ACPI_DUMP_BUFFER(a,b) 672#define ACPI_DUMP_BUFFER(a,b)
@@ -709,19 +722,19 @@
709 722
710/* Memory allocation */ 723/* Memory allocation */
711 724
712#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) 725#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__) 726#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) 727#define ACPI_FREE(a) acpi_os_free(a)
715#define ACPI_MEM_TRACKING(a) 728#define ACPI_MEM_TRACKING(a)
716 729
717#else 730#else
718 731
719/* Memory allocation */ 732/* Memory allocation */
720 733
721#define ACPI_MEM_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a),_COMPONENT,_acpi_module_name,__LINE__) 734#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__) 735#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__) 736#define ACPI_FREE(a) acpi_ut_free_and_track(a,_COMPONENT,_acpi_module_name,__LINE__)
724#define ACPI_MEM_TRACKING(a) a 737#define ACPI_MEM_TRACKING(a) a
725 738
726#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 739#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
727 740