1/****************************************************************************** 2 * 3 * Name: acmacros.h - C macros for the entire subsystem. |
4 * $Revision: 1.191 $ |
5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. --- 112 unchanged lines hidden (view full) --- 125#define ACPI_HIWORD(l) ((UINT16)((((UINT32)(l)) >> 16) & 0xFFFF)) 126#define ACPI_LOBYTE(l) ((UINT8)(UINT16)(l)) 127#define ACPI_HIBYTE(l) ((UINT8)((((UINT16)(l)) >> 8) & 0xFF)) 128 129#define ACPI_SET_BIT(target,bit) ((target) |= (bit)) 130#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) 131#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) 132 |
133/* Size calculation */ |
134 |
135#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) 136 137 |
138#if ACPI_MACHINE_WIDTH == 16 139 140/* 141 * For 16-bit addresses, we have to assume that the upper 32 bits 142 * (out of 64) are zero. 143 */ 144#define ACPI_LODWORD(l) ((UINT32)(l)) 145#define ACPI_HIDWORD(l) ((UINT32)(0)) --- 58 unchanged lines hidden (view full) --- 204#define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8,(a)) + (ACPI_NATIVE_UINT)(b))) 205#define ACPI_PTR_DIFF(a,b) (ACPI_NATIVE_UINT) (ACPI_CAST_PTR (UINT8,(a)) - ACPI_CAST_PTR (UINT8,(b))) 206 207/* Pointer/Integer type conversions */ 208 209#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void,(void *) NULL,(ACPI_NATIVE_UINT) i) 210#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) 211#define ACPI_OFFSET(d,f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) |
212 213#if ACPI_MACHINE_WIDTH == 16 214#define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) 215#define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) 216#define ACPI_PTR_TO_PHYSADDR(i) (UINT32) ACPI_CAST_PTR (UINT8,(i)) 217#else 218#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) 219#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) 220#endif 221 |
222#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED 223#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (UINT32,(a)) == *ACPI_CAST_PTR (UINT32,(b))) 224#else 225#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char,(a)), ACPI_CAST_PTR (char,(b)), ACPI_NAME_SIZE)) 226#endif 227 |
228/* 229 * Macros for moving data around to/from buffers that are possibly unaligned. 230 * If the hardware supports the transfer of unaligned data, just do the store. 231 * Otherwise, we have to move one byte at a time. 232 */ 233#ifdef ACPI_BIG_ENDIAN 234/* 235 * Macros for big-endian machines --- 230 unchanged lines hidden (view full) --- 466#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) 467 468 469/* Bitfields within ACPI registers */ 470 471#define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) ((Val << Pos) & Mask) 472#define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val) Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) 473 |
474#define ACPI_INSERT_BITS(Target, Mask, Source) Target = ((Target & (~(Mask))) | (Source & Mask)) 475 |
476/* Generate a UUID */ 477 478#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ 479 (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \ 480 (b) & 0xFF, ((b) >> 8) & 0xFF, \ 481 (c) & 0xFF, ((c) >> 8) & 0xFF, \ 482 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) 483 484/* 485 * An ACPI_NAMESPACE_NODE * can appear in some contexts, 486 * where a pointer to an ACPI_OPERAND_OBJECT can also 487 * appear. This macro is used to distinguish them. 488 * 489 * The "Descriptor" field is the first field in both structures. 490 */ |
491#define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType) 492#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType = t) |
493 494 495/* Macro to test the object type */ 496 497#define ACPI_GET_OBJECT_TYPE(d) (((ACPI_OPERAND_OBJECT *)(void *)(d))->Common.Type) 498 499/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */ 500 --- 64 unchanged lines hidden (view full) --- 565 */ 566#define ACPI_INFO(plist) AcpiUtInfo plist 567#define ACPI_WARNING(plist) AcpiUtWarning plist 568#define ACPI_EXCEPTION(plist) AcpiUtException plist 569#define ACPI_ERROR(plist) AcpiUtError plist 570#define ACPI_ERROR_NAMESPACE(s,e) AcpiNsReportError (AE_INFO, s, e); 571#define ACPI_ERROR_METHOD(s,n,p,e) AcpiNsReportMethodError (AE_INFO, s, n, p, e); 572 |
573#else 574 575/* No error messages */ 576 577#define ACPI_INFO(plist) 578#define ACPI_WARNING(plist) 579#define ACPI_EXCEPTION(plist) 580#define ACPI_ERROR(plist) 581#define ACPI_ERROR_NAMESPACE(s,e) 582#define ACPI_ERROR_METHOD(s,n,p,e) |
583#endif 584 585/* 586 * Debug macros that are conditionally compiled 587 */ 588#ifdef ACPI_DEBUG_OUTPUT 589 590/* --- 16 unchanged lines hidden (view full) --- 607#define ACPI_GET_FUNCTION_NAME _AcpiFunctionName 608/* 609 * The Name parameter should be the procedure name as a quoted string. 610 * This is declared as a local string ("MyFunctionName") so that it can 611 * be also used by the function exit macros below. 612 * Note: (const char) is used to be compatible with the debug interfaces 613 * and macros such as __FUNCTION__. 614 */ |
615#define ACPI_FUNCTION_NAME(Name) const char *_AcpiFunctionName = #Name; |
616 617#else 618/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ 619 620#define ACPI_FUNCTION_NAME(Name) 621#endif 622 623#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ --- 181 unchanged lines hidden (view full) --- 805 806/* 807 * Memory allocation tracking (DEBUG ONLY) 808 */ 809#ifndef ACPI_DBG_TRACK_ALLOCATIONS 810 811/* Memory allocation */ 812 |
813#define ACPI_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) 814#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroed((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) 815#define ACPI_FREE(a) AcpiOsFree(a) |
816#define ACPI_MEM_TRACKING(a) 817 818#else 819 820/* Memory allocation */ 821 |
822#define ACPI_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) 823#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroedAndTrack((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) 824#define ACPI_FREE(a) AcpiUtFreeAndTrack(a,_COMPONENT,_AcpiModuleName,__LINE__) 825#define ACPI_MEM_TRACKING(a) a |
826 827#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 828 829#endif /* ACMACROS_H */ |