acmacros.h (30082d0c) | acmacros.h (27f7c583) |
---|---|
1/****************************************************************************** 2 * 3 * Name: acmacros.h - C macros for the entire subsystem. | 1/****************************************************************************** 2 * 3 * Name: acmacros.h - C macros for the entire subsystem. |
4 * $Revision: 1.180 $ | 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 | 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 */ |
|
133 | 134 |
135#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) 136 137 |
|
134#if ACPI_MACHINE_WIDTH == 16 135 136/* 137 * For 16-bit addresses, we have to assume that the upper 32 bits 138 * (out of 64) are zero. 139 */ 140#define ACPI_LODWORD(l) ((UINT32)(l)) 141#define ACPI_HIDWORD(l) ((UINT32)(0)) --- 58 unchanged lines hidden (view full) --- 200#define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8,(a)) + (ACPI_NATIVE_UINT)(b))) 201#define ACPI_PTR_DIFF(a,b) (ACPI_NATIVE_UINT) (ACPI_CAST_PTR (UINT8,(a)) - ACPI_CAST_PTR (UINT8,(b))) 202 203/* Pointer/Integer type conversions */ 204 205#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void,(void *) NULL,(ACPI_NATIVE_UINT) i) 206#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) 207#define ACPI_OFFSET(d,f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) | 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) |
208#define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f) | |
209 210#if ACPI_MACHINE_WIDTH == 16 211#define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) 212#define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) 213#define ACPI_PTR_TO_PHYSADDR(i) (UINT32) ACPI_CAST_PTR (UINT8,(i)) 214#else 215#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) 216#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) 217#endif 218 | 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 |
|
219/* 220 * Macros for moving data around to/from buffers that are possibly unaligned. 221 * If the hardware supports the transfer of unaligned data, just do the store. 222 * Otherwise, we have to move one byte at a time. 223 */ 224#ifdef ACPI_BIG_ENDIAN 225/* 226 * Macros for big-endian machines --- 230 unchanged lines hidden (view full) --- 457#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) 458 459 460/* Bitfields within ACPI registers */ 461 462#define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) ((Val << Pos) & Mask) 463#define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val) Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) 464 | 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 |
|
465/* Generate a UUID */ 466 467#define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ 468 (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \ 469 (b) & 0xFF, ((b) >> 8) & 0xFF, \ 470 (c) & 0xFF, ((c) >> 8) & 0xFF, \ 471 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) 472 473/* 474 * An ACPI_NAMESPACE_NODE * can appear in some contexts, 475 * where a pointer to an ACPI_OPERAND_OBJECT can also 476 * appear. This macro is used to distinguish them. 477 * 478 * The "Descriptor" field is the first field in both structures. 479 */ | 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 */ |
480#define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_DESCRIPTOR *)(void *)(d))->DescriptorId) 481#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((ACPI_DESCRIPTOR *)(void *)(d))->DescriptorId = t) | 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) |
482 483 484/* Macro to test the object type */ 485 486#define ACPI_GET_OBJECT_TYPE(d) (((ACPI_OPERAND_OBJECT *)(void *)(d))->Common.Type) 487 488/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */ 489 --- 64 unchanged lines hidden (view full) --- 554 */ 555#define ACPI_INFO(plist) AcpiUtInfo plist 556#define ACPI_WARNING(plist) AcpiUtWarning plist 557#define ACPI_EXCEPTION(plist) AcpiUtException plist 558#define ACPI_ERROR(plist) AcpiUtError plist 559#define ACPI_ERROR_NAMESPACE(s,e) AcpiNsReportError (AE_INFO, s, e); 560#define ACPI_ERROR_METHOD(s,n,p,e) AcpiNsReportMethodError (AE_INFO, s, n, p, e); 561 | 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 |
562/* Legacy interfaces. Remove when migration is complete */ 563 564#define ACPI_REPORT_INFO(fp) {AcpiUtReportInfo (AE_INFO); \ 565 AcpiOsPrintf fp;} 566#define ACPI_REPORT_ERROR(fp) {AcpiUtReportError (AE_INFO); \ 567 AcpiOsPrintf fp;} 568#define ACPI_REPORT_WARNING(fp) {AcpiUtReportWarning (AE_INFO); \ 569 AcpiOsPrintf fp;} | |
570#else 571 572/* No error messages */ 573 574#define ACPI_INFO(plist) 575#define ACPI_WARNING(plist) 576#define ACPI_EXCEPTION(plist) 577#define ACPI_ERROR(plist) 578#define ACPI_ERROR_NAMESPACE(s,e) 579#define ACPI_ERROR_METHOD(s,n,p,e) | 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) |
580 581#define ACPI_REPORT_INFO(fp) 582#define ACPI_REPORT_ERROR(fp) 583#define ACPI_REPORT_WARNING(fp) | |
584#endif 585 586/* 587 * Debug macros that are conditionally compiled 588 */ 589#ifdef ACPI_DEBUG_OUTPUT 590 591/* --- 16 unchanged lines hidden (view full) --- 608#define ACPI_GET_FUNCTION_NAME _AcpiFunctionName 609/* 610 * The Name parameter should be the procedure name as a quoted string. 611 * This is declared as a local string ("MyFunctionName") so that it can 612 * be also used by the function exit macros below. 613 * Note: (const char) is used to be compatible with the debug interfaces 614 * and macros such as __FUNCTION__. 615 */ | 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 */ |
616#define ACPI_FUNCTION_NAME(Name) const char *_AcpiFunctionName = Name; | 615#define ACPI_FUNCTION_NAME(Name) const char *_AcpiFunctionName = #Name; |
617 618#else 619/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ 620 621#define ACPI_FUNCTION_NAME(Name) 622#endif 623 624#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ --- 181 unchanged lines hidden (view full) --- 806 807/* 808 * Memory allocation tracking (DEBUG ONLY) 809 */ 810#ifndef ACPI_DBG_TRACK_ALLOCATIONS 811 812/* Memory allocation */ 813 | 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 |
814#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) 815#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocate((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) 816#define ACPI_MEM_FREE(a) AcpiOsFree(a) | 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) |
817#define ACPI_MEM_TRACKING(a) 818 819#else 820 821/* Memory allocation */ 822 | 816#define ACPI_MEM_TRACKING(a) 817 818#else 819 820/* Memory allocation */ 821 |
823#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) 824#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocateAndTrack((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) 825#define ACPI_MEM_FREE(a) AcpiUtFreeAndTrack(a,_COMPONENT,_AcpiModuleName,__LINE__) 826#define ACPI_MEM_TRACKING(a) a | 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 |
827 828#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 829 830#endif /* ACMACROS_H */ | 826 827#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ 828 829#endif /* ACMACROS_H */ |