1
0
mirror of https://github.com/acpica/acpica/ synced 2025-03-23 06:33:05 +03:00

Method locals and args now have their own NTEs in WALK_STATE

date	2000.01.27.22.16.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 19:39:41 +00:00
parent bdec17ecf1
commit d24d3ab18f
3 changed files with 368 additions and 332 deletions

@ -133,12 +133,6 @@
#define STACK_BOTTOM (UINT32) -1
/* For AmlMthStackSetValue */
#define MTH_TYPE_LOCAL 0
#define MTH_TYPE_ARG 1
/*
* iapi - External interpreter interfaces
@ -150,8 +144,9 @@ AmlLoadTable (
ACPI_STATUS
AmlExecuteMethod (
ACPI_OBJECT_INTERNAL *MthDesc,
ACPI_OBJECT_INTERNAL **Params);
ACPI_OBJECT_INTERNAL *MethodDesc,
ACPI_OBJECT_INTERNAL **Params,
ACPI_OBJECT_INTERNAL **ReturnObjDesc);
/*
@ -218,25 +213,42 @@ AmlGetNamedFieldValue (
ACPI_STATUS
AmlExecCreateField (
UINT16 Opcode);
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands);
ACPI_STATUS
AmlExecFatal (
ACPI_OBJECT_INTERNAL **Operands);
ACPI_STATUS
AmlExecIndex (
ACPI_OBJECT_INTERNAL **Operands,
ACPI_OBJECT_INTERNAL **ReturnDesc);
ACPI_STATUS
AmlExecMatch (
ACPI_OBJECT_INTERNAL **Operands,
ACPI_OBJECT_INTERNAL **ReturnDesc);
ACPI_STATUS
AmlExecCreateMutex (
OPERATING_MODE InterpreterMode);
OPERATING_MODE InterpreterMode,
ACPI_OBJECT_INTERNAL **Operands);
ACPI_STATUS
AmlExecCreateRegion (
UINT8 *AmlPtr,
UINT32 AmlLength,
ACPI_OBJECT_INTERNAL **Operands,
OPERATING_MODE InterpreterMode);
ACPI_STATUS
AmlExecCreateEvent (
void);
ACPI_OBJECT_INTERNAL **Operands);
ACPI_STATUS
AmlExecCreateAlias (
void);
ACPI_OBJECT_INTERNAL **Operands);
ACPI_STATUS
AmlExecCreateMethod (
@ -245,17 +257,7 @@ AmlExecCreateMethod (
UINT32 MethodFlags,
ACPI_HANDLE Method);
ACPI_STATUS
AmlExecFatal (
void);
ACPI_STATUS
AmlExecIndex (
void);
ACPI_STATUS
AmlExecMatch (
void);
/*
@ -266,10 +268,6 @@ ACPI_STATUS
AmlGetRvalue (
ACPI_OBJECT_INTERNAL **StackPtr);
BOOLEAN
AmlIsMethodValue (
ACPI_OBJECT_INTERNAL *ObjDesc);
/*
* ieprep - ACPI AML (p-code) execution - prep utilities
@ -277,6 +275,7 @@ AmlIsMethodValue (
ACPI_STATUS
AmlPrepDefFieldValue (
NAME_TABLE_ENTRY *ThisEntry,
ACPI_HANDLE Region,
UINT8 FldFlg,
INT32 FldPos,
@ -284,6 +283,7 @@ AmlPrepDefFieldValue (
ACPI_STATUS
AmlPrepBankFieldValue (
NAME_TABLE_ENTRY *ThisEntry,
ACPI_HANDLE Region,
ACPI_HANDLE BankReg,
UINT32 BankVal,
@ -293,116 +293,17 @@ AmlPrepBankFieldValue (
ACPI_STATUS
AmlPrepIndexFieldValue(
NAME_TABLE_ENTRY *ThisEntry,
ACPI_HANDLE IndexReg,
ACPI_HANDLE DataReg,
UINT8 FldFlg,
INT32 FldPos,
INT32 FldLen);
/*
* iemstack - method stack utilities
*/
INT32
AmlMthStackLevel (
void);
ACPI_OBJECT_TYPE
AmlMthStackGetType (
UINT32 Type,
UINT32 Index);
ACPI_STATUS
AmlMthStackGetValue (
UINT32 Type,
UINT32 Index,
ACPI_OBJECT_INTERNAL *ObjDesc);
ACPI_STATUS
AmlMthStackSetValue (
UINT32 Type,
UINT32 Index,
ACPI_OBJECT_INTERNAL *ObjDesc,
ACPI_OBJECT_INTERNAL *ObjDesc2);
ACPI_STATUS
AmlMthStackPop (
void);
ACPI_STATUS
AmlMthStackPush (
ACPI_OBJECT_INTERNAL **Params);
ACPI_STATUS
AmlMthStackDeleteValue (
UINT32 Type,
UINT32 Index) ;
/*
* ieostack - object stack utilities
*/
UINT32
AmlObjStackLevel (
void);
void
AmlObjStackClearAll (
void);
ACPI_STATUS
AmlPrepObjStack (
char *Types);
ACPI_STATUS
AmlObjStackPushIfExec (
OPERATING_MODE LoadExecMode);
ACPI_STATUS
AmlObjStackPush (
void);
void *
AmlObjStackPopValue (
void);
ACPI_STATUS
AmlObjStackPop (
UINT32 StackEntries);
ACPI_OBJECT_INTERNAL **
AmlObjStackGetPtr (
UINT32 OffsetFromStackTop);
void *
AmlObjStackGetValue (
UINT32 OffsetFromStackTop);
void
AmlObjStackSetValue (
UINT32 OffsetFromStackTop,
void *StackEntry);
void *
AmlObjStackRemoveValue (
UINT32 OffsetFromStackTop);
void
AmlObjStackDeleteValue (
UINT32 OffsetFromStackTop);
ACPI_STATUS
AmlObjStackClearUntil (
ACPI_OBJECT_TYPE Type);
ACPI_OBJECT_INTERNAL **
AmlObjStackGetTopPtr (
void);
void
AmlObjStackClearTop (
void);
AmlPrepOperands (
char *Types,
ACPI_OBJECT_INTERNAL **StackPtr);
@ -503,12 +404,6 @@ AmlExecStore (
ACPI_OBJECT_INTERNAL *op1,
ACPI_OBJECT_INTERNAL *res);
ACPI_STATUS
PsxExecute (
ACPI_OBJECT_INTERNAL *MthDesc,
ACPI_OBJECT_INTERNAL **Params);
/*
* iemonadic - ACPI AML (p-code) execution, monadic operators
@ -516,15 +411,20 @@ PsxExecute (
ACPI_STATUS
AmlExecMonadic1 (
UINT16 Opcode);
ACPI_STATUS
AmlExecMonadic2R (
UINT16 Opcode);
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands);
ACPI_STATUS
AmlExecMonadic2 (
UINT16 Opcode);
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands,
ACPI_OBJECT_INTERNAL **ReturnDesc);
ACPI_STATUS
AmlExecMonadic2R (
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands,
ACPI_OBJECT_INTERNAL **ReturnDesc);
/*
@ -533,33 +433,28 @@ AmlExecMonadic2 (
ACPI_STATUS
AmlExecDyadic1 (
UINT16 Opcode);
ACPI_STATUS
AmlExecDyadic2R (
UINT16 Opcode);
ACPI_STATUS
AmlExecDyadic2S (
UINT16 Opcode);
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands);
ACPI_STATUS
AmlExecDyadic2 (
UINT16 Opcode);
/*
* isatoms - interpreter/scanner atom load/execute
*/
ACPI_STATUS
AmlDoSuperName (
OPERATING_MODE LoadExecMode,
ACPI_OBJECT_TYPE Define);
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands,
ACPI_OBJECT_INTERNAL **ReturnDesc);
ACPI_STATUS
AmlDoLiteral (
OPERATING_MODE LoadExecMode);
AmlExecDyadic2R (
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands,
ACPI_OBJECT_INTERNAL **ReturnDesc);
ACPI_STATUS
AmlExecDyadic2S (
UINT16 Opcode,
ACPI_OBJECT_INTERNAL **Operands,
ACPI_OBJECT_INTERNAL **ReturnDesc);
/*
* iscode - Scanner AML code manipulation routines
@ -638,12 +533,13 @@ AmlDumpBuffer (
ACPI_STATUS
AmlDumpObjStackEntry (
AmlDumpOperand (
ACPI_OBJECT_INTERNAL *EntryDesc);
void
_AmlDumpObjStack (
OPERATING_MODE LoadExecMode,
AmlDumpOperands (
ACPI_OBJECT_INTERNAL **Operands,
OPERATING_MODE InterpreterMode,
char *Ident,
INT32 NumLevels,
char *Note,
@ -655,9 +551,6 @@ AmlDumpObjectDescriptor (
ACPI_OBJECT_INTERNAL *ObjDesc);
#define AmlDumpObjStack(a,b,c,d) _AmlDumpObjStack(a,b,c,d,_THIS_MODULE,__LINE__)
/*
* isnames - interpreter/scanner name load/execute
@ -721,6 +614,7 @@ AmlAppendOperandDiag(
char *Name,
INT32 Line,
UINT16 OpCode,
ACPI_OBJECT_INTERNAL **Operands,
INT32 NOperands);
UINT32

@ -125,9 +125,13 @@
typedef void* ACPI_MUTEX;
typedef UINT32 ACPI_MUTEX_HANDLE;
/* Object descriptor types */
#define DESC_TYPE_NTE 0xEE
#define DESC_TYPE_ACPI_OBJ 0xAA
/*
* Predefined handles for the mutex objects used within the subsystem
* All mutex objects are automatically created by CmMutexInitialize.
@ -174,19 +178,22 @@ typedef enum
* be the first byte in this structure.
*/
typedef struct NAME_TABLE_ENTRY
typedef struct NameTableEntry
{
UINT8 DataType;
UINT8 Type; /* Type associated with this name */
UINT16 Fill1;
struct NAME_TABLE_ENTRY *ParentScope; /* Previous level of names */
struct NAME_TABLE_ENTRY *ParentEntry; /* Actual parent NTE */
struct NAME_TABLE_ENTRY *Scope; /* Scope owned by this name */
UINT8 Fill1;
UINT8 Flags;
UINT32 Name; /* ACPI Name, always 4 chars per ACPI spec */
void *Object; /* Pointer to attached ACPI object */
struct NAME_TABLE_ENTRY *NextEntry; /* Next within this scope */
struct NAME_TABLE_ENTRY *PrevEntry; /* Previous within this scope */
void *Object; /* Pointer to attached ACPI object (optional) */
struct NameTableEntry *Scope; /* Scope owned by this name (optional) */
struct NameTableEntry *NextEntry; /* Next NTE within this scope */
struct NameTableEntry *PrevEntry; /* Previous NTE within this scope */
struct NameTableEntry *ParentEntry; /* Actual parent NTE */
struct NameTableEntry *ParentScope; /* Previous level of names */
} NAME_TABLE_ENTRY;
@ -195,22 +202,27 @@ typedef struct NAME_TABLE_ENTRY
#define NULL_HANDLE INVALID_HANDLE
/* NTE flags */
#define NTE_AML_ATTACHMENT 0x1
/*
* Stack of currently executing control methods
* Contains the arguments and local variables for each nested method.
*/
typedef struct
typedef struct Method_Stack
{
union AcpiObjInternal *Arguments[MTH_NUM_ARGS];
union AcpiObjInternal *LocalVariables[MTH_NUM_LOCALS];
struct Method_Stack *Next;
} METHOD_STACK;
/* Stack of currently-open scopes, and pointer to top of that stack */
typedef struct
typedef struct scope_stack
{
NAME_TABLE_ENTRY *Scope;
/*
@ -218,7 +230,7 @@ typedef struct
* (but not the same as the type of its parent's scope).
*/
ACPI_OBJECT_TYPE Type;
struct scope_stack *Next;
} SCOPE_STACK;
@ -278,6 +290,7 @@ typedef struct
UINT8 Enable; /* Current value of enable reg */
UINT16 StatusAddr; /* Address of status reg */
UINT16 EnableAddr; /* Address of enable reg */
UINT8 GpeBase; /* Base GPE number */
} GPE_REGISTERS;
@ -291,23 +304,223 @@ typedef struct
typedef struct
{
UINT8 Type; /* Level or Edge */
ACPI_HANDLE MethodHandle; /* Method handle for direct (fast) execution */
GPE_HANDLER Handler; /* Address of handler, if any */
void *Context; /* Context to be passed to handler */
} GPE_LEVEL_INFO;
/* Information about each particular fixed event */
typedef struct
{
FIXED_EVENT_HANDLER Handler; /* Address of handler. */
void *Context; /* Context to be passed to handler */
} FIXED_EVENT_INFO;
/* Information used during field processing */
typedef struct
{
UINT8 SkipField;
UINT8 FieldFlag;
UINT32 PkgLength;
} FIELD_INFO;
/*
* AML opcode, name, and argument layout
*/
typedef struct acpi_op_info
{
UINT16 Opcode; /* AML opcode */
UINT8 Type : 5;
UINT8 HasArgs : 1;
UINT8 ChildLocation : 2;
char *Args; /* argument format */
DEBUG_ONLY_MEMBERS (
char *Name) /* op name (debug only) */
} ACPI_OP_INFO;
typedef union acpi_op_value
{
UINT32 Integer; /* integer constant */
UINT32 Size; /* bytelist or field size */
char *String; /* NULL terminated string */
char *Name; /* NULL terminated string */
struct acpi_generic_op *Arg; /* arguments and contained ops */
NAME_TABLE_ENTRY *Entry; /* entry in interpreter namespace tbl */
} ACPI_OP_VALUE;
#define ACPI_COMMON_OP \
DEBUG_ONLY_MEMBERS (\
char OpName[16]) /* op name (debug only) */\
/* NON-DEBUG members below: */\
struct acpi_generic_op *Parent; /* parent op */\
struct acpi_generic_op *Next; /* next op */\
void *ResultObj; /* for use by interpreter */\
UINT32 AmlOffset; /* offset of declaration in AML */\
UINT32 Opcode; /* AML opcode */\
ACPI_OP_VALUE Value; /* Value or args associated with the opcode */\
/*
* generic operation (eg. If, While, Store)
*/
typedef struct acpi_generic_op
{
ACPI_COMMON_OP
} ACPI_GENERIC_OP;
/*
* operation with a name (eg. Scope, Method, Name, NamedField, ...)
*/
typedef struct acpi_named_op
{
ACPI_COMMON_OP
UINT32 Name; /* 4-byte name or zero if no name */
} ACPI_NAMED_OP;
/*
* special operation for methods and regions (parsing must be deferred
* until a first pass parse is completed)
*/
typedef struct acpi_deferred_op
{
ACPI_COMMON_OP
UINT32 Name; /* 4-byte name or 0 if none */
UINT32 BodyLength; /* AML body size */
UINT8 *Body; /* AML body */
} ACPI_DEFERRED_OP;
/*
* special operation for bytelists (ByteList only)
*/
typedef struct acpi_bytelist_op
{
ACPI_COMMON_OP
UINT8 *Data; /* bytelist data */
} ACPI_BYTELIST_OP;
/*
* Parse state - one state per parser invocation and each control
* method.
*/
typedef struct acpi_parse_state
{
UINT8 *AmlStart; /* first AML byte */
UINT8 *Aml; /* next AML byte */
UINT8 *AmlEnd; /* (last + 1) AML byte */
UINT8 *PkgEnd; /* current package end */
struct acpi_parse_scope *Scope; /* current scope */
struct acpi_parse_scope *ScopeAvail; /* unused (extra) scope structs */
struct acpi_parse_state *Next;
} ACPI_PARSE_STATE;
/*
* Parse scope - one per ACPI scope
*/
typedef struct acpi_parse_scope
{
ACPI_GENERIC_OP *Op; /* current op being parsed */
char *NextArg; /* next argument to parse */
UINT8 *ArgEnd; /* current argument end */
UINT8 *PkgEnd; /* current package end */
struct acpi_parse_scope *Parent; /* parent scope */
UINT32 ArgCount; /* Number of fixed arguments */
} ACPI_PARSE_SCOPE;
#define CONTROL_NORMAL 0xC0
#define CONTROL_CONDITIONAL_EXECUTING 0xC1
#define CONTROL_PREDICATE_EXECUTING 0xC2
#define CONTROL_PREDICATE_FALSE 0xC3
#define CONTROL_PREDICATE_TRUE 0xC4
typedef struct acpi_ctrl_state
{
UINT8 Exec; /* Execution state */
BOOLEAN Predicate; /* Result of predicate evaluation */
ACPI_GENERIC_OP *PredicateOp; /* Start of if/while predicate */
struct acpi_ctrl_state *Next;
} ACPI_CTRL_STATE;
#define NEXT_OP_DOWNWARD 1
#define NEXT_OP_UPWARD 2
typedef struct acpi_walk_state
{
ACPI_GENERIC_OP *Origin; /* Start of walk */
ACPI_GENERIC_OP *PrevOp; /* Last op that was processed */
ACPI_GENERIC_OP *NextOp; /* next op to be processed */
ACPI_CTRL_STATE *ControlState; /* List of control states (nested IFs) */
struct NameTableEntry Arguments[MTH_NUM_ARGS]; /* Control method arguments */
struct NameTableEntry LocalVariables[MTH_NUM_LOCALS]; /* Control method locals */
union AcpiObjInternal *ReturnDesc; /* Return object, if any */
union AcpiObjInternal *Operands[OBJ_NUM_OPERANDS]; /* Operands passed to the interpreter TBD: make max configurable */
struct acpi_walk_state *Next; /* Next WalkState in list */
BOOLEAN LastPredicate; /* Result of last predicate */
UINT8 NextOpInfo; /* Info about NextOp */
UINT8 NumOperands; /* Count of objects in the Operands[] array */
} ACPI_WALK_STATE;
typedef struct acpi_walk_list
{
ACPI_WALK_STATE *WalkState;
} ACPI_WALK_LIST;
typedef
ACPI_STATUS (*INTERPRETER_CALLBACK) (
ACPI_WALK_STATE *State,
ACPI_GENERIC_OP *Op);
/* Entry for a memory allocation (debug only) */
#ifdef ACPI_DEBUG
#define MEM_MALLOC 0
#define MEM_CALLOC 1
@ -325,5 +538,6 @@ typedef struct AllocationInfo
} ALLOCATION_INFO;
#endif
#endif

@ -1,6 +1,6 @@
/******************************************************************************
*
*
* Name: macros.h - C macros for the entire subsystem.
*
*****************************************************************************/
@ -38,9 +38,9 @@
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
@ -48,11 +48,11 @@
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
@ -86,7 +86,7 @@
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
@ -117,8 +117,8 @@
#ifndef __MACROS_H__
#define __MACROS_H__
/*
* Data manipulation macros
/*
* Data manipulation macros
*/
#ifndef LOWORD
@ -127,7 +127,7 @@
#ifndef HIWORD
#define HIWORD(l) ((UINT16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF))
#endif
#endif
#ifndef LOBYTE
#define LOBYTE(l) ((UINT8)(UINT16)(l))
@ -154,92 +154,62 @@
#define HI_LIMIT(b) ((UINT8) (((b) & 0x00FF0000) >> 16))
/*
* 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
*/
/* Extract data using a pointer */
#define GET8(addr) (*(UINT8*)(addr))
#define GET16(addr) (*(UINT16*)(addr))
#define GET32(addr) (*(UINT32*)(addr))
/*
* Macros for moving data around to/from buffers that are possibly unaligned.
* If the hardware supports the transfer of unaligned data, just do the store.
* Otherwise, we have to move one byte at a time.
*/
#ifdef _HW_ALIGNMENT_SUPPORT
/* The hardware supports unaligned transfers, just do the move */
#define MOVE_UNALIGNED16_TO_16(d,s) *(UINT16*)(d) = *(UINT16*)(s)
#define MOVE_UNALIGNED32_TO_32(d,s) *(UINT32*)(d) = *(UINT32*)(s)
#define MOVE_UNALIGNED16_TO_32(d,s) *(UINT32*)(d) = *(UINT16*)(s)
#else
/*
* The hardware does not support unaligned transfers. We must move the
* data one byte at a time. These macros work whether the source or
* the destination (or both) is/are unaligned.
*/
#define MOVE_UNALIGNED16_TO_16(d,s) {((char *)(d))[0] = ((char *)(s))[0];\
((char *)(d))[1] = ((char *)(s))[1];}
#define MOVE_UNALIGNED32_TO_32(d,s) {((char *)(d))[0] = ((char *)(s))[0];\
((char *)(d))[1] = ((char *)(s))[1];\
((char *)(d))[2] = ((char *)(s))[2];\
((char *)(d))[3] = ((char *)(s))[3];}
#define MOVE_UNALIGNED16_TO_32(d,s) {(*(UINT32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);}
#endif
/*
* Fast power-of-two math macros for non-optimized compilers
*/
#define _DIV(value,PowerOf2) ((value) >> (PowerOf2))
#define _MUL(value,PowerOf2) ((value) << (PowerOf2))
#define _MOD(value,Divisor) ((value) & ((Divisor) -1))
#define DIV_2(a) ((a)>>1)
#define MUL_2(a) ((a)<<1)
#define MOD_2(a) ((a)&0x01)
#define DIV_2(a) _DIV(a,1)
#define MUL_2(a) _MUL(a,1)
#define MOD_2(a) _MOD(a,2)
#define DIV_4(a) ((a)>>2)
#define MUL_4(a) ((a)<<2)
#define MOD_4(a) ((a)&0x03)
#define DIV_4(a) _DIV(a,2)
#define MUL_4(a) _MUL(a,2)
#define MOD_4(a) _MOD(a,4)
#define DIV_8(a) ((a)>>3)
#define MUL_8(a) ((a)<<3)
#define MOD_8(a) ((a)&0x07)
#define DIV_8(a) _DIV(a,3)
#define MUL_8(a) _MUL(a,3)
#define MOD_8(a) _MOD(a,8)
#define DIV_16(a) _DIV(a,4)
#define MUL_16(a) _MUL(a,4)
#define MOD_16(a) _MOD(a,16)
#define DIV_16(a) ((a)>>4)
#define MUL_16(a) ((a)<<4)
#define MOD_16(a) ((a)&0x0F)
/*
* 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)))
#define ROUND_DOWN_TO_32_BITS(a) ROUND_DOWN(a,4)
#define ROUND_DOWN_TO_NATIVE_WORD(a) ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY)
#define ROUND_UP_TO_32BITS(a) ROUND_UP(a,4)
#define ROUND_UP_TO_NATIVE_WORD(a) ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY)
#ifdef IA64
#define ALIGN64(bc) char Align[bc];
#else
#define ALIGN64(bc)
#endif
#ifdef DEBUG_ASSERT
#undef DEBUG_ASSERT
#endif
#ifdef _RPARSER
#define RPARSER_ONLY(s) s;
#else
#define RPARSER_ONLY(s)
#endif
/*
/* Register read/write Macros */
#define READ_ACPI_REGISTER(RegId) HwRegisterIO (ACPI_READ, (INT32)(RegId))
#define WRITE_ACPI_REGISTER(RegId,Val) HwRegisterIO (ACPI_WRITE, (INT32) (RegId), Val)
/*
* An ACPI_HANDLE (which is actually an NAME_TABLE_ENTRY *) can appear in some contexts,
* such as on apObjStack, where a pointer to an ACPI_OBJECT_INTERNAL can also
* appear. This macro is used to distinguish them.
@ -255,8 +225,8 @@
#define IS_THIS_OBJECT_TYPE(d,t) (((ACPI_OBJECT_INTERNAL *)d)->Common.Type == (UINT8)t)
/*
* There is an (nte *) prefix to each name table, containing either a NULL
/*
* There is an (nte *) prefix to each name table, containing either a NULL
* pointer or the address of the next array of nte's in the scope.
*
* This macro extracts a pointer to the NEXT table in the chain.
@ -264,57 +234,26 @@
#define NEXTSEG(NameTbl) ((NAME_TABLE_ENTRY **)NameTbl)[-1]
/*
/*
* Macro to check if a pointer is within an ACPI table.
* Parameter (a) is the pointer to check. Parameter (b) must be defined
* 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)))
#else
#define IS_IN_ACPI_TABLE(a,b) (_segment)(a) == (_segment)(b) &&\
(((UINT8 *)(a) >= (UINT8 *)(b + 1)) &&\
((UINT8 *)(a) < ((UINT8 *)b + b->Length)))
#endif
/*
* Macros for the master AML opcode table
*/
#ifdef ACPI_DEBUG
#define OP_INFO_ENTRY(Opcode,Flags,Name,PArgs,IArgs) {Opcode,Flags,PArgs,IArgs,Name}
#define OP_INFO_ENTRY(Opcode,Type,ArgBool,Reserved,Name,Args) {Opcode,Type,ArgBool,Reserved,Args,Name}
#else
#define OP_INFO_ENTRY(Opcode,Flags,Name,PArgs,IArgs) {Opcode,Flags,PArgs,IArgs}
#define OP_INFO_ENTRY(Opcode,Type,ArgBool,Reserved,Name,Args) {Opcode,Type,ArgBool,Reserved,Args}
#endif
#define ARG_TYPE_WIDTH 5
#define ARG_1(x) ((UINT32)(x))
#define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH))
#define ARG_3(x) ((UINT32)(x) << (2 * ARG_TYPE_WIDTH))
#define ARG_4(x) ((UINT32)(x) << (3 * ARG_TYPE_WIDTH))
#define ARG_5(x) ((UINT32)(x) << (4 * ARG_TYPE_WIDTH))
#define ARG_6(x) ((UINT32)(x) << (5 * ARG_TYPE_WIDTH))
#define ARGI_LIST1(a) (ARG_1(a))
#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a))
#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a))
#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
#define ARGI_LIST6(a,b,c,d,e,f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a))
#define ARGP_LIST1(a) (ARG_1(a))
#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b))
#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c))
#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
#define ARGP_LIST6(a,b,c,d,e,f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f))
#define GET_CURRENT_ARG_TYPE(List) (List & 0x1F)
#define INCREMENT_ARG_LIST(List) (List >>= ARG_TYPE_WIDTH)
/*
@ -351,7 +290,7 @@
/* Buffer dump macros */
#define DUMP_BUFFER(a,b) AcpiCmDumpBuffer((char *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
#define DUMP_BUFFER(a,b,c) DumpBuffer((char *)a,b,c,_COMPONENT)
/*
* Debug macros that are conditionally compiled
@ -361,8 +300,8 @@
#define MODULE_NAME(name) static char *_THIS_MODULE = name
/*
* Function entry tracing.
/*
* Function entry tracing.
* The first parameter should be the procedure name as a quoted string. This is declared
* as a local string ("_ProcName) so that it can be also used by the function exit macros below.
*/
@ -375,9 +314,9 @@
FunctionTraceU32(_THIS_MODULE,__LINE__,_COMPONENT,a,(UINT32)b)
#define FUNCTION_TRACE_STR(a,b) char * _ProcName = a;\
FunctionTraceStr(_THIS_MODULE,__LINE__,_COMPONENT,a,(char *)b)
/*
* Function exit tracing.
* WARNING: These macros include a return statement. This is usually considered
/*
* Function exit tracing.
* WARNING: These macros include a return statement. This is usually considered
* bad form, but having a separate exit macro is very ugly and difficult to maintain.
* One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
* so that "_ProcName" is defined.
@ -385,7 +324,6 @@
#define return_VOID {FunctionExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName);return;}
#define return_ACPI_STATUS(s) {FunctionStatusExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,s);return(s);}
#define return_VALUE(s) {FunctionValueExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(NATIVE_UINT)s);return(s);}
#define return_PTR(s) {FunctionPtrExit(_THIS_MODULE,__LINE__,_COMPONENT,_ProcName,(char *)s);return(s);}
/* Conditional execution */
@ -399,14 +337,14 @@
/* 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) AmlDumpOperand(a)
#define DUMP_OPERANDS(a,b,c,d,e) AmlDumpOperands(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 BREAK_MSG(a) AcpiOsBreakpoint (a)
#define DUMP_ENTRY(a,b) NsDumpEntry (a,b)
#define DUMP_TABLES(a,b) NsDumpTables(a,b)
#define DUMP_PATHNAME(a,b,c,d) NsDumpPathname(a,b,c,d)
#define BREAK_MSG(a) OsdBreakpoint (a)
/*
* Generate INT3 on ACPI_ERROR (Debug only!)
@ -414,13 +352,13 @@
#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) OsdBreakpoint("Fatal error encountered\n")
#else
#define BREAK_ON_ERROR(lvl)
#define BREAK_ON_ERROR(lvl)
#endif
/*
* Master debug print macros
/*
* Master debug print macros
* Print iff:
* 1) Debug print for the current component is enabled
* 2) Debug error level or trace level for the print statement is enabled
@ -429,10 +367,10 @@
#define PARAM_LIST(pl) pl
#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))
#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & DebugLevel) && (_COMPONENT & DebugLayer))
#define DEBUG_PRINT(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\
DebugPrintPrefix (_THIS_MODULE,__LINE__);\
DebugPrintPrefix (_THIS_MODULE,__LINE__,_COMPONENT);\
DebugPrintRaw PARAM_LIST(fp);\
BREAK_ON_ERROR(lvl);}
@ -443,14 +381,14 @@
/* Assert macros */
#define ACPI_ASSERT(exp) if(!(exp)) \
AcpiOsDbgAssert(#exp, __FILE__, __LINE__, "Failed Assertion")
OsdDbgAssert(#exp, __FILE__, __LINE__, "Failed Assertion")
#define DEBUG_ASSERT(msg, exp) if(!(exp)) \
AcpiOsDbgAssert(#exp, __FILE__, __LINE__, msg)
OsdDbgAssert(#exp, __FILE__, __LINE__, msg)
#else
/*
/*
* This is the non-debug case -- make everything go away,
* leaving no executable debug code!
*/
@ -458,10 +396,10 @@
#define MODULE_NAME(name)
#define _THIS_MODULE ""
#define DEBUG_EXEC(a)
#define DEBUG_EXEC(a)
#define NORMAL_EXEC(a) a;
#define DEBUG_DEFINE(a)
#define DEBUG_DEFINE(a)
#define DEBUG_ONLY_MEMBERS(a)
#define FUNCTION_TRACE(a)
#define FUNCTION_TRACE_PTR(a,b)
@ -476,13 +414,12 @@
#define DUMP_TABLES(a,b)
#define DUMP_PATHNAME(a,b,c,d)
#define DEBUG_PRINT(l,f)
#define DEBUG_PRINT_RAW(l,f)
#define DEBUG_PRINT_RAW(l,f)
#define BREAK_MSG(a)
#define return_VOID return
#define return_ACPI_STATUS(s) return(s)
#define return_VALUE(s) return(s)
#define return_PTR(s) return(s)
#define ACPI_ASSERT(exp)
#define DEBUG_ASSERT(msg, exp)
@ -490,16 +427,6 @@
#endif
/*
* For 16-bit code, we want to shrink some things even though
* we are using ACPI_DEBUG to get the debug output
*/
#ifdef _IA16
#undef DEBUG_ONLY_MEMBERS
#define DEBUG_ONLY_MEMBERS(a)
#undef OP_INFO_ENTRY
#define OP_INFO_ENTRY(Opcode,Flags,Name,PArgs,IArgs) {Opcode,Flags,PArgs,IArgs}
#endif
#ifndef ACPI_DEBUG
@ -515,9 +442,10 @@
*/
#define ADD_OBJECT_NAME(a,b) MEMSET (a->Common.Name, ' ', sizeof (a->Common.Name));\
STRNCPY (a->Common.Name, AcpiGbl_NsTypeNames[b], sizeof (a->Common.Name))
STRNCPY (a->Common.Name, Gbl_NsTypeNames[b], sizeof (a->Common.Name))
#endif
#endif /* MACROS_H */