From 6bb2e615fcf472cc8075544bb9416aadf7053474 Mon Sep 17 00:00:00 2001 From: aystarik Date: Wed, 29 Jun 2005 19:44:22 +0000 Subject: [PATCH] Reimplemented inefficient opcode type checking with flags in opcode info table date 2001.08.22.16.56.00; author rmoore1; state Exp; --- source/include/aclocal.h | 20 +++- source/include/acmacros.h | 230 ++++++++++++++++++-------------------- 2 files changed, 127 insertions(+), 123 deletions(-) diff --git a/source/include/aclocal.h b/source/include/aclocal.h index fcb5b3f8f..7d5ae1c10 100644 --- a/source/include/aclocal.h +++ b/source/include/aclocal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: aclocal.h - Internal data types used across the ACPI subsystem - * $Revision: 1.127 $ + * $Revision: 1.128 $ * *****************************************************************************/ @@ -630,15 +630,31 @@ ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( #define ACPI_GET_OP_ARGS(a) ((a)->Flags & ACPI_OP_ARGS_MASK) #define ACPI_GET_OP_TYPE(a) ((a)->Flags & ACPI_OP_TYPE_MASK) +/* + * Flags byte: 0-4 (5 bits) = Opcode Class (0x001F + * 5 (1 bit) = Has arguments flag + * 6-7 (2 bits) = Reserved + */ +#define AML_NO_ARGS 0 +#define AML_HAS_ARGS 0x0020 +#define AML_NSOBJECT 0x0100 +#define AML_NSOPCODE 0x0200 +#define AML_NSNODE 0x0400 +#define AML_NAMED 0x0800 +#define AML_DEFER 0x1000 +#define AML_FIELD 0x2000 +#define AML_CREATE 0x4000 + + /* * AML opcode, name, and argument layout */ typedef struct acpi_opcode_info { - UINT8 Flags; /* Opcode type, HasArgs flag */ UINT32 ParseArgs; /* Grammar/Parse time arguments */ UINT32 RuntimeArgs; /* Interpret time arguments */ + UINT16 Flags; /* Opcode type, HasArgs flag */ #ifdef _OPCODE_NAMES NATIVE_CHAR *Name; /* op name (debug only) */ diff --git a/source/include/acmacros.h b/source/include/acmacros.h index b7aece6d9..029e1783e 100644 --- a/source/include/acmacros.h +++ b/source/include/acmacros.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acmacros.h - C macros for the entire subsystem. - * $Revision: 1.67 $ + * $Revision: 1.87 $ * *****************************************************************************/ @@ -117,18 +117,11 @@ #ifndef __ACMACROS_H__ #define __ACMACROS_H__ + /* * Data manipulation macros */ -#ifndef LODWORD -#define LODWORD(l) ((UINT32)(UINT64)(l)) -#endif - -#ifndef HIDWORD -#define HIDWORD(l) ((UINT32)((((UINT64)(l)) >> 32) & 0xFFFFFFFF)) -#endif - #ifndef LOWORD #define LOWORD(l) ((UINT16)(NATIVE_UINT)(l)) #endif @@ -167,24 +160,65 @@ * For 16-bit addresses, we have to assume that the upper 32 bits * are zero. */ +#ifndef LODWORD +#define LODWORD(l) (l) +#endif + +#ifndef HIDWORD +#define HIDWORD(l) (0) +#endif + #define ACPI_GET_ADDRESS(a) ((a).Lo) #define ACPI_STORE_ADDRESS(a,b) {(a).Hi=0;(a).Lo=(b);} #define ACPI_VALID_ADDRESS(a) ((a).Hi | (a).Lo) #else +#ifdef ACPI_NO_INTEGER64_SUPPORT /* - * Full 64-bit address on 32-bit and 64-bit platforms + * ACPI_INTEGER is 32-bits, no 64-bit support on this platform */ +#ifndef LODWORD +#define LODWORD(l) ((UINT32)(l)) +#endif + +#ifndef HIDWORD +#define HIDWORD(l) (0) +#endif + +#define ACPI_GET_ADDRESS(a) (a) +#define ACPI_STORE_ADDRESS(a,b) ((a)=(b)) +#define ACPI_VALID_ADDRESS(a) (a) + +#else + +/* + * Full 64-bit address/integer on both 32-bit and 64-bit platforms + */ +#ifndef LODWORD +#define LODWORD(l) ((UINT32)(UINT64)(l)) +#endif + +#ifndef HIDWORD +#define HIDWORD(l) ((UINT32)(((*(UINT64_STRUCT *)(&l))).Hi)) +#endif + #define ACPI_GET_ADDRESS(a) (a) #define ACPI_STORE_ADDRESS(a,b) ((a)=(b)) #define ACPI_VALID_ADDRESS(a) (a) #endif +#endif + /* * Extract a byte of data using a pointer. Any more than a byte and we * get into potential aligment issues -- see the STORE macros below */ #define GET8(addr) (*(UINT8*)(addr)) +/* Pointer arithmetic */ + + +#define POINTER_ADD(t,a,b) (t *) ((NATIVE_UINT)(a) + (NATIVE_UINT)(b)) +#define POINTER_DIFF(a,b) ((UINT32) ((NATIVE_UINT)(a) - (NATIVE_UINT)(b))) /* * Macros for moving data around to/from buffers that are possibly unaligned. @@ -263,7 +297,6 @@ /* * Rounding macros (Power of two boundaries only) */ - #define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) #define ROUND_UP(value,boundary) (((value) + ((boundary)-1)) & (~((boundary)-1))) @@ -279,30 +312,44 @@ #define ROUND_PTR_UP_TO_8(a,b) ((b *)(((NATIVE_UINT)(a) + 7) & ~7)) #define ROUND_BITS_UP_TO_BYTES(a) DIV_8((a) + 7) +#define ROUND_BITS_DOWN_TO_BYTES(a) DIV_8((a)) #define ROUND_UP_TO_1K(a) (((a) + 1023) >> 10) -#ifdef DEBUG_ASSERT -#undef DEBUG_ASSERT -#endif +/* Generic (non-power-of-two) rounding */ + +#define ROUND_UP_TO(value,boundary) (((value) + ((boundary)-1)) / (boundary)) + +/* + * Bitmask creation + * Bit positions start at zero. + * MASK_BITS_ABOVE creates a mask starting AT the position and above + * MASK_BITS_BELOW creates a mask starting one bit BELOW the position + */ +#define MASK_BITS_ABOVE(position) (~(((UINT32)(-1)) << ((UINT32) (position)))) +#define MASK_BITS_BELOW(position) (((UINT32)(-1)) << ((UINT32) (position))) + /* Macros for GAS addressing */ +#ifndef _IA16 + #define ACPI_PCI_DEVICE_MASK (UINT64) 0x0000FFFF00000000 #define ACPI_PCI_FUNCTION_MASK (UINT64) 0x00000000FFFF0000 #define ACPI_PCI_REGISTER_MASK (UINT64) 0x000000000000FFFF -#define ACPI_PCI_FUNCTION(a) (UINT32) ((((a) & ACPI_PCI_FUNCTION_MASK) >> 16)) -#define ACPI_PCI_DEVICE(a) (UINT32) ((((a) & ACPI_PCI_DEVICE_MASK) >> 32)) - -#ifndef _IA16 -#define ACPI_PCI_REGISTER(a) (UINT32) (((a) & ACPI_PCI_REGISTER_MASK)) -#define ACPI_PCI_DEVFUN(a) (UINT32) ((ACPI_PCI_DEVICE(a) << 16) | ACPI_PCI_FUNCTION(a)) +#define ACPI_PCI_FUNCTION(a) (UINT16) ((((a) & ACPI_PCI_FUNCTION_MASK) >> 16)) +#define ACPI_PCI_DEVICE(a) (UINT16) ((((a) & ACPI_PCI_DEVICE_MASK) >> 32)) +#define ACPI_PCI_REGISTER(a) (UINT16) (((a) & ACPI_PCI_REGISTER_MASK)) #else -#define ACPI_PCI_REGISTER(a) (UINT32) (((a) & 0x0000FFFF)) -#define ACPI_PCI_DEVFUN(a) (UINT32) ((((a) & 0xFFFF0000) >> 16)) + +/* No support for GAS and PCI IDs in 16-bit mode */ + +#define ACPI_PCI_FUNCTION(a) (UINT16) ((a) & 0xFFFF0000) +#define ACPI_PCI_DEVICE(a) (UINT16) ((a) & 0x0000FFFF) +#define ACPI_PCI_REGISTER(a) (UINT16) ((a) & 0x0000FFFF) #endif @@ -313,7 +360,6 @@ * * The DataType field is the first field in both structures. */ - #define VALID_DESCRIPTOR_TYPE(d,t) (((ACPI_NAMESPACE_NODE *)d)->DataType == t) @@ -325,13 +371,16 @@ #define IS_SINGLE_TABLE(x) (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0) +/* Check if ACPI has been initialized properly */ + +#define ACPI_IS_INITIALIZATION_COMPLETE(s) {if (AcpiGbl_RootNode) s = AE_OK; else s=AE_NO_NAMESPACE;} + /* * Macro to check if a pointer is within an ACPI table. * Parameter (a) is the pointer to check. Parameter (b) must be defined * as a pointer to an ACPI_TABLE_HEADER. (b+1) then points past the header, * and ((UINT8 *)b+b->Length) points one byte past the end of the table. */ - #ifndef _IA16 #define IS_IN_ACPI_TABLE(a,b) (((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\ ((UINT8 *)(a) < ((UINT8 *)b + b->Length))) @@ -345,11 +394,10 @@ /* * Macros for the master AML opcode table */ - #ifdef ACPI_DEBUG -#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs,Name} +#define ACPI_OP(Name,PArgs,IArgs,Flags) {PArgs,IArgs,Flags,Name} #else -#define OP_INFO_ENTRY(Flags,Name,PArgs,IArgs) {Flags,PArgs,IArgs} +#define ACPI_OP(Name,PArgs,IArgs,Flags) {PArgs,IArgs,Flags} #endif #define ARG_TYPE_WIDTH 5 @@ -413,35 +461,35 @@ #ifdef ACPI_DEBUG #define REPORT_INFO(fp) {_ReportInfo(_THIS_MODULE,__LINE__,_COMPONENT); \ - DebugPrintRaw PARAM_LIST(fp);} + AcpiOsPrintf PARAM_LIST(fp);} #define REPORT_ERROR(fp) {_ReportError(_THIS_MODULE,__LINE__,_COMPONENT); \ - DebugPrintRaw PARAM_LIST(fp);} + AcpiOsPrintf PARAM_LIST(fp);} #define REPORT_WARNING(fp) {_ReportWarning(_THIS_MODULE,__LINE__,_COMPONENT); \ - DebugPrintRaw PARAM_LIST(fp);} + AcpiOsPrintf PARAM_LIST(fp);} #else #define REPORT_INFO(fp) {_ReportInfo("ACPI",__LINE__,_COMPONENT); \ - DebugPrintRaw PARAM_LIST(fp);} + AcpiOsPrintf PARAM_LIST(fp);} #define REPORT_ERROR(fp) {_ReportError("ACPI",__LINE__,_COMPONENT); \ - DebugPrintRaw PARAM_LIST(fp);} + AcpiOsPrintf PARAM_LIST(fp);} #define REPORT_WARNING(fp) {_ReportWarning("ACPI",__LINE__,_COMPONENT); \ - DebugPrintRaw PARAM_LIST(fp);} + AcpiOsPrintf PARAM_LIST(fp);} #endif /* Error reporting. These versions pass thru the module and line# */ #define _REPORT_INFO(a,b,c,fp) {_ReportInfo(a,b,c); \ - DebugPrintRaw PARAM_LIST(fp);} + AcpiOsPrintf PARAM_LIST(fp);} #define _REPORT_ERROR(a,b,c,fp) {_ReportError(a,b,c); \ - DebugPrintRaw PARAM_LIST(fp);} + AcpiOsPrintf PARAM_LIST(fp);} #define _REPORT_WARNING(a,b,c,fp) {_ReportWarning(a,b,c); \ - DebugPrintRaw PARAM_LIST(fp);} + AcpiOsPrintf PARAM_LIST(fp);} /* Buffer dump macros */ -#define DUMP_BUFFER(a,b) AcpiCmDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) +#define DUMP_BUFFER(a,b) AcpiUtDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) /* * Debug macros that are conditionally compiled @@ -457,6 +505,7 @@ * as a local string ("_ProcName) so that it can be also used by the function exit macros below. */ +#define PROC_NAME(a) char * _ProcName = a; #define FUNCTION_TRACE(a) char * _ProcName = a;\ FunctionTrace(_THIS_MODULE,__LINE__,_COMPONENT,a) #define FUNCTION_TRACE_PTR(a,b) char * _ProcName = a;\ @@ -491,15 +540,16 @@ /* Stack and buffer dumping */ -#define DUMP_STACK_ENTRY(a) AcpiAmlDumpOperand(a) -#define DUMP_OPERANDS(a,b,c,d,e) AcpiAmlDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__) +#define DUMP_STACK_ENTRY(a) AcpiExDumpOperand(a) +#define DUMP_OPERANDS(a,b,c,d,e) AcpiExDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__) #define DUMP_ENTRY(a,b) AcpiNsDumpEntry (a,b) #define DUMP_TABLES(a,b) AcpiNsDumpTables(a,b) #define DUMP_PATHNAME(a,b,c,d) AcpiNsDumpPathname(a,b,c,d) #define DUMP_RESOURCE_LIST(a) AcpiRsDumpResourceList(a) -#define BREAK_MSG(a) AcpiOsBreakpoint (a) +#define BREAK_MSG(a) AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT,(a)) + /* * Generate INT3 on ACPI_ERROR (Debug only!) @@ -507,7 +557,7 @@ #define ERROR_BREAK #ifdef ERROR_BREAK -#define BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) AcpiOsBreakpoint("Fatal error encountered\n") +#define BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) AcpiOsSignal(ACPI_SIGNAL_BREAKPOINT,"Fatal error encountered\n") #else #define BREAK_ON_ERROR(lvl) #endif @@ -517,27 +567,10 @@ * Print iff: * 1) Debug print for the current component is enabled * 2) Debug error level or trace level for the print statement is enabled - * */ -#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer)) - -#define DEBUG_PRINT(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ - DebugPrintPrefix (_THIS_MODULE,__LINE__);\ - DebugPrintRaw PARAM_LIST(fp);\ - BREAK_ON_ERROR(lvl);} - -#define DEBUG_PRINT_RAW(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ - DebugPrintRaw PARAM_LIST(fp);} - - -/* Assert macros */ - -#define ACPI_ASSERT(exp) if(!(exp)) \ - AcpiOsDbgAssert(#exp, __FILE__, __LINE__, "Failed Assertion") - -#define DEBUG_ASSERT(msg, exp) if(!(exp)) \ - AcpiOsDbgAssert(#exp, __FILE__, __LINE__, msg) +#define ACPI_DEBUG_PRINT(pl) AcpiUtDebugPrint PARAM_LIST(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) AcpiUtDebugPrintRaw PARAM_LIST(pl) #else @@ -554,6 +587,7 @@ #define DEBUG_DEFINE(a) #define DEBUG_ONLY_MEMBERS(a) +#define PROC_NAME(a) #define FUNCTION_TRACE(a) #define FUNCTION_TRACE_PTR(a,b) #define FUNCTION_TRACE_U32(a,b) @@ -567,8 +601,8 @@ #define DUMP_TABLES(a,b) #define DUMP_PATHNAME(a,b,c,d) #define DUMP_RESOURCE_LIST(a) -#define DEBUG_PRINT(l,f) -#define DEBUG_PRINT_RAW(l,f) +#define ACPI_DEBUG_PRINT(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) #define BREAK_MSG(a) #define return_VOID return @@ -576,9 +610,6 @@ #define return_VALUE(s) return(s) #define return_PTR(s) return(s) -#define ACPI_ASSERT(exp) -#define DEBUG_ASSERT(msg, exp) - #endif /* @@ -625,69 +656,26 @@ * Memory allocation tracking (DEBUG ONLY) */ -#ifndef ACPI_DEBUG_TRACK_ALLOCATIONS +#ifndef ACPI_DBG_TRACK_ALLOCATIONS -#define AcpiCmAddElementToAllocList(a,b,c,d,e,f) -#define AcpiCmDeleteElementFromAllocList(a,b,c,d) -#define AcpiCmDumpCurrentAllocations(a,b) -#define AcpiCmDumpAllocationInfo() +/* Memory allocation */ + +#define ACPI_MEM_ALLOCATE(a) AcpiOsAllocate(a) +#define ACPI_MEM_CALLOCATE(a) AcpiOsCallocate(a) +#define ACPI_MEM_FREE(a) AcpiOsFree(a) +#define ACPI_MEM_TRACKING(a) -#define DECREMENT_OBJECT_METRICS(a) -#define INCREMENT_OBJECT_METRICS(a) -#define INITIALIZE_ALLOCATION_METRICS() -#define DECREMENT_NAME_TABLE_METRICS(a) -#define INCREMENT_NAME_TABLE_METRICS(a) #else -#define INITIALIZE_ALLOCATION_METRICS() \ - AcpiGbl_CurrentObjectCount = 0; \ - AcpiGbl_CurrentObjectSize = 0; \ - AcpiGbl_RunningObjectCount = 0; \ - AcpiGbl_RunningObjectSize = 0; \ - AcpiGbl_MaxConcurrentObjectCount = 0; \ - AcpiGbl_MaxConcurrentObjectSize = 0; \ - AcpiGbl_CurrentAllocSize = 0; \ - AcpiGbl_CurrentAllocCount = 0; \ - AcpiGbl_RunningAllocSize = 0; \ - AcpiGbl_RunningAllocCount = 0; \ - AcpiGbl_MaxConcurrentAllocSize = 0; \ - AcpiGbl_MaxConcurrentAllocCount = 0; \ - AcpiGbl_CurrentNodeCount = 0; \ - AcpiGbl_CurrentNodeSize = 0; \ - AcpiGbl_MaxConcurrentNodeCount = 0 +/* Memory allocation */ +#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocate(a,_COMPONENT,_THIS_MODULE,__LINE__) +#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocate(a, _COMPONENT,_THIS_MODULE,__LINE__) +#define ACPI_MEM_FREE(a) AcpiUtFree(a,_COMPONENT,_THIS_MODULE,__LINE__) +#define ACPI_MEM_TRACKING(a) a -#define DECREMENT_OBJECT_METRICS(a) \ - AcpiGbl_CurrentObjectCount--; \ - AcpiGbl_CurrentObjectSize -= a - -#define INCREMENT_OBJECT_METRICS(a) \ - AcpiGbl_CurrentObjectCount++; \ - AcpiGbl_RunningObjectCount++; \ - if (AcpiGbl_MaxConcurrentObjectCount < AcpiGbl_CurrentObjectCount) \ - { \ - AcpiGbl_MaxConcurrentObjectCount = AcpiGbl_CurrentObjectCount; \ - } \ - AcpiGbl_RunningObjectSize += a; \ - AcpiGbl_CurrentObjectSize += a; \ - if (AcpiGbl_MaxConcurrentObjectSize < AcpiGbl_CurrentObjectSize) \ - { \ - AcpiGbl_MaxConcurrentObjectSize = AcpiGbl_CurrentObjectSize; \ - } - -#define DECREMENT_NAME_TABLE_METRICS(a) \ - AcpiGbl_CurrentNodeCount--; \ - AcpiGbl_CurrentNodeSize -= (a) - -#define INCREMENT_NAME_TABLE_METRICS(a) \ - AcpiGbl_CurrentNodeCount++; \ - AcpiGbl_CurrentNodeSize+= (a); \ - if (AcpiGbl_MaxConcurrentNodeCount < AcpiGbl_CurrentNodeCount) \ - { \ - AcpiGbl_MaxConcurrentNodeCount = AcpiGbl_CurrentNodeCount; \ - } -#endif /* ACPI_DEBUG_TRACK_ALLOCATIONS */ +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ #endif /* ACMACROS_H */