diff options
| author | kochi <kochi@NetBSD.org> | 2005-05-02 14:52:09 +0000 |
|---|---|---|
| committer | kochi <kochi@NetBSD.org> | 2005-05-02 14:52:09 +0000 |
| commit | 57d7792cceabc7de73a94cf47dd74b7cb66e1dfe (patch) | |
| tree | 7a5ac87665f7a333a1b6ebe437ac7d93565cffe4 /sys/dev | |
| parent | 45aba3b6e2c7d117cfb777a34ad2bc5bb5b35e07 (diff) | |
Merge ACPI-CA 20050408
Diffstat (limited to 'sys/dev')
154 files changed, 12634 insertions, 9311 deletions
diff --git a/sys/dev/acpi/acpica/Subsystem/acconfig.h b/sys/dev/acpi/acpica/Subsystem/acconfig.h index c4b77250d04..4c42eab6954 100644 --- a/sys/dev/acpi/acpica/Subsystem/acconfig.h +++ b/sys/dev/acpi/acpica/Subsystem/acconfig.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acconfig.h - Global configuration constants - * xRevision: 148 $ + * xRevision: 183 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -137,11 +137,21 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20040211 +#define ACPI_CA_VERSION 0x20050408 + +/* + * OS name, used for the _OS object. The _OS object is essentially obsolete, + * but there is a large base of ASL/AML code in existing machines that check + * for the string below. The use of this string usually guarantees that + * the ASL will execute down the most tested code path. Also, there is some + * code that will not execute the _OSI method unless _OS matches the string + * below. Therefore, change this string at your own risk. + */ +#define ACPI_OS_NAME "Microsoft Windows NT" /* Maximum objects in the various object caches */ -#define ACPI_MAX_STATE_CACHE_DEPTH 64 /* State objects for stacks */ +#define ACPI_MAX_STATE_CACHE_DEPTH 64 /* State objects */ #define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ #define ACPI_MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */ #define ACPI_MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ @@ -162,7 +172,7 @@ /* Version of ACPI supported */ -#define ACPI_CA_SUPPORT_LEVEL 2 +#define ACPI_CA_SUPPORT_LEVEL 3 /* String size constants */ @@ -193,9 +203,8 @@ #define ACPI_MAX_GPE_BLOCKS 2 #define ACPI_GPE_REGISTER_WIDTH 8 -/* - * Method info (in WALK_STATE), containing local variables and argumetns - */ +/* Method info (in WALK_STATE), containing local variables and argumetns */ + #define ACPI_METHOD_NUM_LOCALS 8 #define ACPI_METHOD_MAX_LOCAL 7 @@ -225,10 +234,11 @@ /* Constants used in searching for the RSDP in low memory */ -#define ACPI_LO_RSDP_WINDOW_BASE 0 /* Physical Address */ -#define ACPI_HI_RSDP_WINDOW_BASE 0xE0000 /* Physical Address */ -#define ACPI_LO_RSDP_WINDOW_SIZE 0x400 -#define ACPI_HI_RSDP_WINDOW_SIZE 0x20000 +#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ +#define ACPI_EBDA_PTR_LENGTH 2 +#define ACPI_EBDA_WINDOW_SIZE 1024 +#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */ +#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000 #define ACPI_RSDP_SCAN_STEP 16 /* Operation regions */ @@ -258,6 +268,10 @@ #define ACPI_SMBUS_BUFFER_SIZE 34 +/* Number of strings associated with the _OSI reserved method */ + +#define ACPI_NUM_OSI_STRINGS 10 + /****************************************************************************** * diff --git a/sys/dev/acpi/acpica/Subsystem/acdebug.h b/sys/dev/acpi/acpica/Subsystem/acdebug.h index c01e6313f8a..a830f86fabc 100644 --- a/sys/dev/acpi/acpica/Subsystem/acdebug.h +++ b/sys/dev/acpi/acpica/Subsystem/acdebug.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdebug.h - ACPI/AML debugger - * xRevision: 73 $ + * xRevision: 79 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -136,9 +136,7 @@ typedef struct ArgumentInfo #define PARAM_LIST(pl) pl - #define DBTEST_OUTPUT_LEVEL(lvl) if (AcpiGbl_DbOpt_verbose) - #define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ AcpiOsPrintf PARAM_LIST(fp);} @@ -146,13 +144,9 @@ typedef struct ArgumentInfo #define EX_SINGLE_STEP 2 -/* Prototypes */ - - /* * dbxface - external debugger interfaces */ - ACPI_STATUS AcpiDbInitialize ( void); @@ -167,19 +161,13 @@ AcpiDbSingleStep ( ACPI_PARSE_OBJECT *Op, UINT32 OpType); -ACPI_STATUS -AcpiDbStartCommand ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op); - -void -AcpiDbMethodEnd ( - ACPI_WALK_STATE *WalkState); - /* * dbcmds - debug commands and output routines */ +ACPI_STATUS +AcpiDbDisassembleMethod ( + char *Name); void AcpiDbDisplayTableInfo ( @@ -239,62 +227,39 @@ void AcpiDbSetScope ( char *Name); +ACPI_STATUS +AcpiDbSleep ( + char *ObjectArg); + void AcpiDbFindReferences ( char *ObjectArg); void -AcpiDbDisplayLocks (void); - +AcpiDbDisplayLocks ( + void); void AcpiDbDisplayResources ( char *ObjectArg); void -AcpiDbDisplayGpes (void); +AcpiDbDisplayGpes ( + void); void AcpiDbCheckIntegrity ( void); -ACPI_STATUS -AcpiDbIntegrityWalk ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -ACPI_STATUS -AcpiDbWalkAndMatchName ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -ACPI_STATUS -AcpiDbWalkForReferences ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -ACPI_STATUS -AcpiDbWalkForSpecificObjects ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - void AcpiDbGenerateGpe ( char *GpeArg, char *BlockArg); + /* * dbdisply - debug display commands */ - void AcpiDbDisplayMethodInfo ( ACPI_PARSE_OBJECT *Op); @@ -338,19 +303,10 @@ AcpiDbDisplayArgumentObject ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState); -void -AcpiDbDumpParserDescriptor ( - ACPI_PARSE_OBJECT *Op); - -void * -AcpiDbGetPointer ( - void *Target); - /* * dbexec - debugger control method execution */ - void AcpiDbExecute ( char *Name, @@ -363,44 +319,15 @@ AcpiDbCreateExecutionThreads ( char *NumLoopsArg, char *MethodNameArg); -ACPI_STATUS -AcpiDbExecuteMethod ( - ACPI_DB_METHOD_INFO *Info, - ACPI_BUFFER *ReturnObj); - -void -AcpiDbExecuteSetup ( - ACPI_DB_METHOD_INFO *Info); - -UINT32 -AcpiDbGetOutstandingAllocations ( - void); - -void ACPI_SYSTEM_XFACE -AcpiDbMethodThread ( - void *Context); - -ACPI_STATUS -AcpiDbExecutionWalk ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - /* * dbfileio - Debugger file I/O commands */ - ACPI_OBJECT_TYPE AcpiDbMatchArgument ( char *UserArgument, ARGUMENT_INFO *Arguments); -ACPI_STATUS -AeLocalLoadTable ( - ACPI_TABLE_HEADER *TablePtr); - void AcpiDbCloseDebugFile ( void); @@ -423,16 +350,17 @@ AcpiDbReadTableFromFile ( char *Filename, ACPI_TABLE_HEADER **Table); + /* * dbhistry - debugger HISTORY command */ - void AcpiDbAddToHistory ( char *CommandLine); void -AcpiDbDisplayHistory (void); +AcpiDbDisplayHistory ( + void); char * AcpiDbGetFromHistory ( @@ -442,7 +370,6 @@ AcpiDbGetFromHistory ( /* * dbinput - user front-end to the AML debugger */ - ACPI_STATUS AcpiDbCommandDispatch ( char *InputBuffer, @@ -458,71 +385,28 @@ AcpiDbUserCommands ( char Prompt, ACPI_PARSE_OBJECT *Op); -void -AcpiDbDisplayHelp ( - char *HelpType); - -char * -AcpiDbGetNextToken ( - char *String, - char **Next); - -UINT32 -AcpiDbGetLine ( - char *InputBuffer); - -UINT32 -AcpiDbMatchCommand ( - char *UserCommand); - -void -AcpiDbSingleThread ( - void); - /* * dbstats - Generation and display of ACPI table statistics */ - void AcpiDbGenerateStatistics ( ACPI_PARSE_OBJECT *Root, BOOLEAN IsMethod); - ACPI_STATUS AcpiDbDisplayStatistics ( char *TypeArg); -ACPI_STATUS -AcpiDbClassifyOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -void -AcpiDbCountNamespaceObjects ( - void); - -void -AcpiDbEnumerateObject ( - ACPI_OPERAND_OBJECT *ObjDesc); - /* * dbutils - AML debugger utilities */ - void AcpiDbSetOutputDestination ( UINT32 Where); void -AcpiDbDumpBuffer ( - UINT32 Address); - -void AcpiDbDumpObject ( ACPI_OBJECT *ObjDesc, UINT32 Level); @@ -531,14 +415,8 @@ void AcpiDbPrepNamestring ( char *Name); - -ACPI_STATUS -AcpiDbSecondPassParse ( - ACPI_PARSE_OBJECT *Root); - ACPI_NAMESPACE_NODE * AcpiDbLocalNsLookup ( char *Name); - #endif /* __ACDEBUG_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/acdisasm.h b/sys/dev/acpi/acpica/Subsystem/acdisasm.h index 09546dd3133..f580cd2e081 100644 --- a/sys/dev/acpi/acpica/Subsystem/acdisasm.h +++ b/sys/dev/acpi/acpica/Subsystem/acdisasm.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdisasm.h - AML disassembler - * xRevision: 11 $ + * xRevision: 19 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,14 @@ #define BLOCK_BRACE 2 #define BLOCK_COMMA_LIST 4 +typedef struct acpi_external_list +{ + char *Path; + struct acpi_external_list *Next; + +} ACPI_EXTERNAL_LIST; + +extern ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList; extern const char *AcpiGbl_IoDecode[2]; extern const char *AcpiGbl_WordDecode[4]; extern const char *AcpiGbl_ConsumeDecode[2]; @@ -141,6 +149,11 @@ extern const char *AcpiGbl_SHRDecode[2]; extern const char *AcpiGbl_TYPDecode[4]; extern const char *AcpiGbl_BMDecode[2]; extern const char *AcpiGbl_SIZDecode[4]; +extern const char *AcpiGbl_TTPDecode[2]; +extern const char *AcpiGbl_MTPDecode[4]; +extern const char *AcpiGbl_TRSDecode[2]; + + extern const char *AcpiGbl_LockRule[ACPI_NUM_LOCK_RULES]; extern const char *AcpiGbl_AccessTypes[ACPI_NUM_ACCESS_TYPES]; extern const char *AcpiGbl_UpdateRules[ACPI_NUM_UPDATE_RULES]; @@ -164,58 +177,16 @@ ACPI_STATUS (*ASL_WALK_CALLBACK) ( /* * dmwalk */ - -void -AcpiDmWalkParseTree ( - ACPI_PARSE_OBJECT *Op, - ASL_WALK_CALLBACK DescendingCallback, - ASL_WALK_CALLBACK AscendingCallback, - void *Context); - -ACPI_STATUS -AcpiDmDescendingOp ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -AcpiDmAscendingOp ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - - -/* - * dmopcode - */ - -void -AcpiDmValidateName ( - char *Name, - ACPI_PARSE_OBJECT *Op); - -UINT32 -AcpiDmDumpName ( - char *Name); - -void -AcpiDmUnicode ( - ACPI_PARSE_OBJECT *Op); - void AcpiDmDisassemble ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Origin, UINT32 NumOpcodes); -void -AcpiDmNamestring ( - char *Name); - -void -AcpiDmDisplayPath ( - ACPI_PARSE_OBJECT *Op); +/* + * dmopcode + */ void AcpiDmDisassembleOneOp ( ACPI_WALK_STATE *WalkState, @@ -227,18 +198,9 @@ AcpiDmDecodeInternalObject ( ACPI_OPERAND_OBJECT *ObjDesc); UINT32 -AcpiDmBlockType ( - ACPI_PARSE_OBJECT *Op); - -UINT32 AcpiDmListType ( ACPI_PARSE_OBJECT *Op); -ACPI_STATUS -AcpiPsDisplayObjectPathname ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op); - void AcpiDmMethodFlags ( ACPI_PARSE_OBJECT *Op); @@ -259,10 +221,6 @@ void AcpiDmMatchOp ( ACPI_PARSE_OBJECT *Op); -void -AcpiDmMatchKeyword ( - ACPI_PARSE_OBJECT *Op); - BOOLEAN AcpiDmCommaIfListMember ( ACPI_PARSE_OBJECT *Op); @@ -273,13 +231,25 @@ AcpiDmCommaIfFieldMember ( /* - * dmobject + * dmnames */ +UINT32 +AcpiDmDumpName ( + char *Name); + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); void -AcpiDmDecodeNode ( - ACPI_NAMESPACE_NODE *Node); +AcpiDmNamestring ( + char *Name); + +/* + * dmobject + */ void AcpiDmDisplayInternalObject ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -303,6 +273,16 @@ AcpiDmDumpMethodInfo ( /* * dmbuffer */ +void +AcpiDmDisasmByteList ( + UINT32 Level, + UINT8 *ByteData, + UINT32 ByteCount); + +void +AcpiDmByteList ( + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op); void AcpiIsEisaId ( @@ -324,18 +304,6 @@ AcpiDmIsStringBuffer ( /* * dmresrc */ - -void -AcpiDmDisasmByteList ( - UINT32 Level, - UINT8 *ByteData, - UINT32 ByteCount); - -void -AcpiDmByteList ( - ACPI_OP_WALK_INFO *Info, - ACPI_PARSE_OBJECT *Op); - void AcpiDmResourceDescriptor ( ACPI_OP_WALK_INFO *Info, @@ -358,19 +326,10 @@ void AcpiDmDecodeAttribute ( UINT8 Attribute); + /* * dmresrcl */ - -void -AcpiDmIoFlags ( - UINT8 Flags); - -void -AcpiDmMemoryFlags ( - UINT8 Flags, - UINT8 SpecificFlags); - void AcpiDmWordDescriptor ( ASL_WORD_ADDRESS_DESC *Resource, @@ -384,6 +343,12 @@ AcpiDmDwordDescriptor ( UINT32 Level); void +AcpiDmExtendedDescriptor ( + ASL_EXTENDED_ADDRESS_DESC *Resource, + UINT32 Length, + UINT32 Level); + +void AcpiDmQwordDescriptor ( ASL_QWORD_ADDRESS_DESC *Resource, UINT32 Length, @@ -429,7 +394,6 @@ AcpiDmVendorLargeDescriptor ( /* * dmresrcs */ - void AcpiDmIrqDescriptor ( ASL_IRQ_FORMAT_DESC *Resource, @@ -473,4 +437,11 @@ AcpiDmVendorSmallDescriptor ( UINT32 Level); +/* + * dmutils + */ +void +AcpiDmAddToExternalList ( + char *Path); + #endif /* __ACDISASM_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/acdispat.h b/sys/dev/acpi/acpica/Subsystem/acdispat.h index afa5c37449e..4d02f132b3c 100644 --- a/sys/dev/acpi/acpica/Subsystem/acdispat.h +++ b/sys/dev/acpi/acpica/Subsystem/acdispat.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdispat.h - dispatcher (parser to interpreter interface) - * xRevision: 57 $ + * xRevision: 64 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,38 +123,9 @@ #define NAMEOF_ARG_NTE "__A0" -/* Common interfaces */ - -ACPI_STATUS -AcpiDsObjStackPush ( - void *Object, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiDsObjStackPop ( - UINT32 PopCount, - ACPI_WALK_STATE *WalkState); - -void * -AcpiDsObjStackGetValue ( - UINT32 Index, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiDsObjStackPopObject ( - ACPI_OPERAND_OBJECT **Object, - ACPI_WALK_STATE *WalkState); - - -/* dsopcode - support for late evaluation */ - -ACPI_STATUS -AcpiDsExecuteArguments ( - ACPI_NAMESPACE_NODE *Node, - ACPI_NAMESPACE_NODE *ScopeNode, - UINT32 AmlLength, - UINT8 *AmlStart); - +/* + * dsopcode - support for late evaluation + */ ACPI_STATUS AcpiDsGetBufferFieldArguments ( ACPI_OPERAND_OBJECT *ObjDesc); @@ -172,15 +143,6 @@ AcpiDsGetPackageArguments ( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS -AcpiDsInitBufferField ( - UINT16 AmlOpcode, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT *BufferDesc, - ACPI_OPERAND_OBJECT *OffsetDesc, - ACPI_OPERAND_OBJECT *LengthDesc, - ACPI_OPERAND_OBJECT *ResultDesc); - -ACPI_STATUS AcpiDsEvalBufferFieldOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op); @@ -201,9 +163,9 @@ AcpiDsInitializeRegion ( ACPI_HANDLE ObjHandle); -/* dsctrl - Parser/Interpreter interface, control stack routines */ - - +/* + * dsctrl - Parser/Interpreter interface, control stack routines + */ ACPI_STATUS AcpiDsExecBeginControlOp ( ACPI_WALK_STATE *WalkState, @@ -215,9 +177,9 @@ AcpiDsExecEndControlOp ( ACPI_PARSE_OBJECT *Op); -/* dsexec - Parser/Interpreter interface, method execution callbacks */ - - +/* + * dsexec - Parser/Interpreter interface, method execution callbacks + */ ACPI_STATUS AcpiDsGetPredicateValue ( ACPI_WALK_STATE *WalkState, @@ -233,14 +195,9 @@ AcpiDsExecEndOp ( ACPI_WALK_STATE *State); -/* dsfield - Parser/Interpreter interface for AML fields */ - -ACPI_STATUS -AcpiDsGetFieldNames ( - ACPI_CREATE_FIELD_INFO *Info, - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Arg); - +/* + * dsfield - Parser/Interpreter interface for AML fields + */ ACPI_STATUS AcpiDsCreateField ( ACPI_PARSE_OBJECT *Op, @@ -270,8 +227,9 @@ AcpiDsInitFieldObjects ( ACPI_WALK_STATE *WalkState); -/* dsload - Parser/Interpreter interface, namespace load callbacks */ - +/* + * dsload - Parser/Interpreter interface, namespace load callbacks + */ ACPI_STATUS AcpiDsLoad1BeginOp ( ACPI_WALK_STATE *WalkState, @@ -296,9 +254,9 @@ AcpiDsInitCallbacks ( UINT32 PassNumber); -/* dsmthdat - method data (locals/args) */ - - +/* + * dsmthdat - method data (locals/args) + */ ACPI_STATUS AcpiDsStoreObjectToLocal ( UINT16 Opcode, @@ -321,12 +279,6 @@ BOOLEAN AcpiDsIsMethodValue ( ACPI_OPERAND_OBJECT *ObjDesc); -ACPI_OBJECT_TYPE -AcpiDsMethodDataGetType ( - UINT16 Opcode, - UINT32 Index, - ACPI_WALK_STATE *WalkState); - ACPI_STATUS AcpiDsMethodDataGetValue ( UINT16 Opcode, @@ -334,12 +286,6 @@ AcpiDsMethodDataGetValue ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **DestDesc); -void -AcpiDsMethodDataDeleteValue ( - UINT16 Opcode, - UINT32 Index, - ACPI_WALK_STATE *WalkState); - ACPI_STATUS AcpiDsMethodDataInitArgs ( ACPI_OPERAND_OBJECT **Params, @@ -357,16 +303,10 @@ void AcpiDsMethodDataInit ( ACPI_WALK_STATE *WalkState); -ACPI_STATUS -AcpiDsMethodDataSetValue ( - UINT16 Opcode, - UINT32 Index, - ACPI_OPERAND_OBJECT *Object, - ACPI_WALK_STATE *WalkState); - - -/* dsmethod - Parser/Interpreter interface - control method parsing */ +/* + * dsmethod - Parser/Interpreter interface - control method parsing + */ ACPI_STATUS AcpiDsParseMethod ( ACPI_HANDLE ObjHandle); @@ -393,20 +333,18 @@ AcpiDsBeginMethodExecution ( ACPI_NAMESPACE_NODE *CallingMethodNode); -/* dsobj - Parser/Interpreter interface - object initialization and conversion */ - -ACPI_STATUS -AcpiDsInitOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); - +/* + * dsinit + */ ACPI_STATUS AcpiDsInitializeObjects ( ACPI_TABLE_DESC *TableDesc, ACPI_NAMESPACE_NODE *StartNode); + +/* + * dsobject - Parser/Interpreter interface - object initialization and conversion + */ ACPI_STATUS AcpiDsBuildInternalBufferObj ( ACPI_WALK_STATE *WalkState, @@ -422,12 +360,6 @@ AcpiDsBuildInternalPackageObj ( ACPI_OPERAND_OBJECT **ObjDesc); ACPI_STATUS -AcpiDsBuildInternalObject ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op, - ACPI_OPERAND_OBJECT **ObjDescPtr); - -ACPI_STATUS AcpiDsInitObjectFromOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, @@ -441,7 +373,18 @@ AcpiDsCreateNode ( ACPI_PARSE_OBJECT *Op); -/* dsutils - Parser/Interpreter interface utility routines */ +/* + * dsutils - Parser/Interpreter interface utility routines + */ +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference); BOOLEAN AcpiDsIsResultUsed ( @@ -477,7 +420,6 @@ AcpiDsClearOperands ( /* * dswscope - Scope Stack manipulation */ - ACPI_STATUS AcpiDsScopeStackPush ( ACPI_NAMESPACE_NODE *Node, @@ -494,7 +436,18 @@ AcpiDsScopeStackClear ( ACPI_WALK_STATE *WalkState); -/* dswstate - parser WALK_STATE management routines */ +/* + * dswstate - parser WALK_STATE management routines + */ +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); ACPI_WALK_STATE * AcpiDsCreateWalkState ( @@ -510,15 +463,10 @@ AcpiDsInitAmlWalk ( ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc, + ACPI_PARAMETER_INFO *Info, UINT32 PassNumber); ACPI_STATUS -AcpiDsObjStackDeleteAll ( - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS AcpiDsObjStackPopAndDelete ( UINT32 PopCount, ACPI_WALK_STATE *WalkState); @@ -552,16 +500,6 @@ ACPI_WALK_STATE * AcpiDsGetCurrentWalkState ( ACPI_THREAD_STATE *Thread); -void -AcpiDsDeleteWalkStateCache ( - void); - -ACPI_STATUS -AcpiDsResultInsert ( - void *Object, - UINT32 Index, - ACPI_WALK_STATE *WalkState); - ACPI_STATUS AcpiDsResultRemove ( ACPI_OPERAND_OBJECT **Object, @@ -583,4 +521,10 @@ AcpiDsResultPopFromBottom ( ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState); +#ifdef ACPI_ENABLE_OBJECT_CACHE +void +AcpiDsDeleteWalkStateCache ( + void); +#endif + #endif /* _ACDISPAT_H_ */ diff --git a/sys/dev/acpi/acpica/Subsystem/acenv.h b/sys/dev/acpi/acpica/Subsystem/acenv.h index a25921affb4..ce50a6b9c8e 100644 --- a/sys/dev/acpi/acpica/Subsystem/acenv.h +++ b/sys/dev/acpi/acpica/Subsystem/acenv.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acenv.h - Generation environment specific items - * xRevision: 106 $ + * xRevision: 114 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -130,6 +130,7 @@ #define ACPI_DISASSEMBLER #define ACPI_NO_METHOD_EXECUTION #define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_ENABLE_OBJECT_CACHE #endif #ifdef _ACPI_EXEC_APP @@ -140,6 +141,7 @@ #define ACPI_DEBUGGER #define ACPI_DISASSEMBLER #define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_ENABLE_OBJECT_CACHE #endif #ifdef _ACPI_ASL_COMPILER @@ -148,6 +150,7 @@ #define ACPI_DISASSEMBLER #define ACPI_CONSTANT_EVAL_ONLY #define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_ENABLE_OBJECT_CACHE #endif /* @@ -225,12 +228,8 @@ #define COMPILER_DEPENDENT_INT64 long long #define COMPILER_DEPENDENT_UINT64 unsigned long long - -/* Name of host operating system (returned by the _OS_ namespace object) */ - -#define ACPI_OS_NAME "Intel ACPI/CA Core Subsystem" - -/* This macro is used to tag functions as "printf-like" because +/* + * This macro is used to tag functions as "printf-like" because * some compilers can catch printf format string problems. MSVC * doesn't, so this is proprocessed away. */ @@ -272,6 +271,7 @@ #endif #endif /* !DEBUGGER_THREADING */ + /****************************************************************************** * * C library configuration @@ -283,7 +283,6 @@ * Use the standard C library headers. * We want to keep these to a minimum. */ - #ifdef ACPI_USE_STANDARD_HEADERS /* * Use the standard headers from the standard locations @@ -298,9 +297,8 @@ /* * We will be linking to the standard Clib functions */ - #define ACPI_STRSTR(s1,s2) strstr((s1), (s2)) -#define ACPI_STRUPR(s) (void) AcpiUtStrupr ((s)) +#define ACPI_STRCHR(s1,c) strchr((s1), (c)) #define ACPI_STRLEN(s) (ACPI_SIZE) strlen((s)) #define ACPI_STRCPY(d,s) (void) strcpy((d), (s)) #define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (ACPI_SIZE)(n)) @@ -309,6 +307,7 @@ #define ACPI_STRCAT(d,s) (void) strcat((d), (s)) #define ACPI_STRNCAT(d,s,n) strncat((d), (s), (ACPI_SIZE)(n)) #define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMCMP(s1,s2,n) memcmp((s1), (s2), (ACPI_SIZE)(n)) #define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (ACPI_SIZE)(n)) #define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (ACPI_SIZE)(n)) @@ -322,14 +321,15 @@ #define ACPI_IS_ALPHA isalpha #define ACPI_IS_ASCII isascii +#else + /****************************************************************************** * * Not using native C library, use local implementations * *****************************************************************************/ -#else -/* + /* * Use local definitions of C library macros and functions * NOTE: The function implementations may not be as efficient * as an inline or assembly code implementation provided by a @@ -346,14 +346,12 @@ typedef char *va_list; /* * Storage alignment properties */ - #define _AUPBND (sizeof (ACPI_NATIVE_INT) - 1) #define _ADNBND (sizeof (ACPI_NATIVE_INT) - 1) /* * Variable argument list macro definitions */ - #define _Bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) #define va_arg(ap, T) (*(T *)(((ap) += (_Bnd (T, _AUPBND))) - (_Bnd (T,_ADNBND)))) #define va_end(ap) (void) 0 @@ -362,18 +360,19 @@ typedef char *va_list; #endif /* va_arg */ -#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2)) -#define ACPI_STRUPR(s) (void) AcpiUtStrupr ((s)) -#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s)) -#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s)) +#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2)) +#define ACPI_STRCHR(s1,c) AcpiUtStrchr ((s1), (c)) +#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s)) +#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s)) #define ACPI_STRNCPY(d,s,n) (void) AcpiUtStrncpy ((d), (s), (ACPI_SIZE)(n)) #define ACPI_STRNCMP(d,s,n) AcpiUtStrncmp ((d), (s), (ACPI_SIZE)(n)) -#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s)) -#define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s)) +#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s)) +#define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s)) #define ACPI_STRNCAT(d,s,n) AcpiUtStrncat ((d), (s), (ACPI_SIZE)(n)) #define ACPI_STRTOUL(d,s,n) AcpiUtStrtoul ((d), (s), (ACPI_SIZE)(n)) -#define ACPI_MEMCPY(d,s,n) (void) AcpiUtMemcpy ((d), (s), (ACPI_SIZE)(n)) -#define ACPI_MEMSET(d,v,n) (void) AcpiUtMemset ((d), (v), (ACPI_SIZE)(n)) +#define ACPI_MEMCMP(s1,s2,n) AcpiUtMemcmp((s1), (s2), (ACPI_SIZE)(n)) +#define ACPI_MEMCPY(d,s,n) (void) AcpiUtMemcpy ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMSET(d,v,n) (void) AcpiUtMemset ((d), (v), (ACPI_SIZE)(n)) #define ACPI_TOUPPER AcpiUtToUpper #define ACPI_TOLOWER AcpiUtToLower diff --git a/sys/dev/acpi/acpica/Subsystem/acevents.h b/sys/dev/acpi/acpica/Subsystem/acevents.h index 7d02ceaeecf..9d0f2fbc970 100644 --- a/sys/dev/acpi/acpica/Subsystem/acevents.h +++ b/sys/dev/acpi/acpica/Subsystem/acevents.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acevents.h - Event subcomponent prototypes and defines - * xRevision: 93 $ + * xRevision: 100 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -118,36 +118,26 @@ #define __ACEVENTS_H__ -ACPI_STATUS -AcpiEvInitialize ( - void); - -ACPI_STATUS -AcpiEvHandlerInitialize ( - void); - /* - * Evfixed - Fixed event handling + * evevent */ +ACPI_STATUS +AcpiEvInitializeEvents ( + void); ACPI_STATUS -AcpiEvFixedEventInitialize ( +AcpiEvInstallXruptHandlers ( void); UINT32 AcpiEvFixedEventDetect ( void); -UINT32 -AcpiEvFixedEventDispatch ( - UINT32 Event); - /* - * Evmisc + * evmisc */ - BOOLEAN AcpiEvIsNotifyObject ( ACPI_NAMESPACE_NODE *Node); @@ -173,21 +163,22 @@ AcpiEvQueueNotifyRequest ( ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue); -void ACPI_SYSTEM_XFACE -AcpiEvNotifyDispatch ( - void *Context); - /* - * Evgpe - GPE handling and dispatch + * evgpe - GPE handling and dispatch */ +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); ACPI_STATUS -AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback); +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware); -BOOLEAN -AcpiEvValidGpeEvent ( +ACPI_STATUS +AcpiEvDisableGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo); ACPI_GPE_EVENT_INFO * @@ -195,9 +186,23 @@ AcpiEvGetGpeEventInfo ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber); + +/* + * evgpeblk + */ +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + ACPI_STATUS -AcpiEvGpeInitialize ( - void); +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + UINT32 Flags); + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock); ACPI_STATUS AcpiEvCreateGpeBlock ( @@ -221,12 +226,29 @@ UINT32 AcpiEvGpeDetect ( ACPI_GPE_XRUPT_INFO *GpeXruptList); +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); + +ACPI_STATUS +AcpiEvCheckForWakeOnlyGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiEvGpeInitialize ( + void); + + /* - * Evregion - Address Space handling + * evregion - Address Space handling */ +ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void); ACPI_STATUS -AcpiEvInitAddressSpaces ( +AcpiEvInitializeOpRegions ( void); ACPI_STATUS @@ -238,13 +260,6 @@ AcpiEvAddressSpaceDispatch ( void *Value); ACPI_STATUS -AcpiEvInstallHandler ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); - -ACPI_STATUS AcpiEvAttachRegion ( ACPI_OPERAND_OBJECT *HandlerObj, ACPI_OPERAND_OBJECT *RegionObj, @@ -256,21 +271,27 @@ AcpiEvDetachRegion ( BOOLEAN AcpiNsIsLocked); ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId); + +ACPI_STATUS AcpiEvExecuteRegMethod ( ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function); -ACPI_STATUS -AcpiEvRegRun ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); /* - * Evregini - Region initialization and setup + * evregini - Region initialization and setup */ - ACPI_STATUS AcpiEvSystemMemoryRegionSetup ( ACPI_HANDLE Handle, @@ -320,9 +341,8 @@ AcpiEvInitializeRegion ( /* - * Evsci - SCI (System Control Interrupt) handling/dispatch + * evsci - SCI (System Control Interrupt) handling/dispatch */ - UINT32 ACPI_SYSTEM_XFACE AcpiEvGpeXruptHandler ( void *Context); diff --git a/sys/dev/acpi/acpica/Subsystem/acexcep.h b/sys/dev/acpi/acpica/Subsystem/acexcep.h index 55c1ea8a0b8..86946564fc7 100644 --- a/sys/dev/acpi/acpica/Subsystem/acexcep.h +++ b/sys/dev/acpi/acpica/Subsystem/acexcep.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acexcep.h - Exception codes returned by the ACPI subsystem - * xRevision: 70 $ + * xRevision: 74 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,7 +121,6 @@ /* * Exceptions returned by external ACPI interfaces */ - #define AE_CODE_ENVIRONMENTAL 0x0000 #define AE_CODE_PROGRAMMER 0x1000 #define AE_CODE_ACPI_TABLES 0x2000 @@ -168,8 +167,10 @@ #define AE_LOGICAL_ADDRESS (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL) #define AE_ABORT_METHOD (ACPI_STATUS) (0x001C | AE_CODE_ENVIRONMENTAL) #define AE_SAME_HANDLER (ACPI_STATUS) (0x001D | AE_CODE_ENVIRONMENTAL) +#define AE_WAKE_ONLY_GPE (ACPI_STATUS) (0x001E | AE_CODE_ENVIRONMENTAL) + +#define AE_CODE_ENV_MAX 0x001E -#define AE_CODE_ENV_MAX 0x001D /* * Programmer exceptions @@ -238,7 +239,8 @@ #define AE_AML_CIRCULAR_REFERENCE (ACPI_STATUS) (0x0020 | AE_CODE_AML) #define AE_AML_BAD_RESOURCE_LENGTH (ACPI_STATUS) (0x0021 | AE_CODE_AML) -#define AE_CODE_AML_MAX 0x0020 +#define AE_CODE_AML_MAX 0x0021 + /* * Internal exceptions used for control @@ -260,6 +262,7 @@ #ifdef DEFINE_ACPI_GLOBALS + /* * String versions of the exception codes above * These strings must match the corresponding defines exactly @@ -295,7 +298,8 @@ char const *AcpiGbl_ExceptionNames_Env[] = "AE_NO_GLOBAL_LOCK", "AE_LOGICAL_ADDRESS", "AE_ABORT_METHOD", - "AE_SAME_HANDLER" + "AE_SAME_HANDLER", + "AE_WAKE_ONLY_GPE" }; char const *AcpiGbl_ExceptionNames_Pgm[] = @@ -375,5 +379,4 @@ char const *AcpiGbl_ExceptionNames_Ctrl[] = #endif /* ACPI GLOBALS */ - #endif /* __ACEXCEP_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/acgcc.h b/sys/dev/acpi/acpica/Subsystem/acgcc.h index f1150caacf7..5825d3ca3ce 100644 --- a/sys/dev/acpi/acpica/Subsystem/acgcc.h +++ b/sys/dev/acpi/acpica/Subsystem/acgcc.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acgcc.h - GCC specific defines, etc. - * xRevision: 26 $ + * xRevision: 27 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/dev/acpi/acpica/Subsystem/acglobal.h b/sys/dev/acpi/acpica/Subsystem/acglobal.h index c3534769203..25ae1d46c8a 100644 --- a/sys/dev/acpi/acpica/Subsystem/acglobal.h +++ b/sys/dev/acpi/acpica/Subsystem/acglobal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acglobal.h - Declarations for global variables - * xRevision: 145 $ + * xRevision: 164 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -119,17 +119,26 @@ /* - * Ensure that the globals are actually defined only once. + * Ensure that the globals are actually defined and initialized only once. * - * The use of these defines allows a single list of globals (here) in order + * The use of these macros allows a single list of globals (here) in order * to simplify maintenance of the code. */ #ifdef DEFINE_ACPI_GLOBALS #define ACPI_EXTERN +#define ACPI_INIT_GLOBAL(a,b) a=b #else #define ACPI_EXTERN extern +#define ACPI_INIT_GLOBAL(a,b) a #endif +/* + * Keep local copies of these FADT-based registers. NOTE: These globals + * are first in this file for alignment reasons on 64-bit systems. + */ +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; + /***************************************************************************** * @@ -149,6 +158,50 @@ extern UINT32 AcpiGbl_NestingLevel; /***************************************************************************** * + * Runtime configuration (static defaults that can be overriden at runtime) + * + ****************************************************************************/ + +/* + * Enable "slack" in the AML interpreter? Default is FALSE, and the + * interpreter strictly follows the ACPI specification. Setting to TRUE + * allows the interpreter to forgive certain bad AML constructs. Currently: + * 1) Allow "implicit return" of last value in a control method + * 2) Allow access beyond end of operation region + * 3) Allow access to uninitialized locals/args (auto-init to integer 0) + * 4) Allow ANY object type to be a source operand for the Store() operator + */ +#ifdef ACPICA_PEDANTIC +ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); +#else +ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, TRUE); +#endif + +/* + * Automatically serialize ALL control methods? Default is FALSE, meaning + * to use the Serialized/NotSerialized method flags on a per method basis. + * Only change this if the ASL code is poorly written and cannot handle + * reentrancy even though methods are marked "NotSerialized". + */ +ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE); + +/* + * Create the predefined _OSI method in the namespace? Default is TRUE + * because ACPI CA is fully compatible with other ACPI implementations. + * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. + */ +ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); + +/* + * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and + * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only + * be enabled just before going to sleep. + */ +ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE); + + +/***************************************************************************** + * * ACPI Table globals * ****************************************************************************/ @@ -160,7 +213,6 @@ extern UINT32 AcpiGbl_NestingLevel; * * These tables are single-table only; meaning that there can be at most one * of each in the system. Each global points to the actual table. - * */ ACPI_EXTERN UINT32 AcpiGbl_TableFlags; ACPI_EXTERN UINT32 AcpiGbl_RsdtTableCount; @@ -170,26 +222,20 @@ ACPI_EXTERN FADT_DESCRIPTOR *AcpiGbl_FADT; ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DSDT; ACPI_EXTERN FACS_DESCRIPTOR *AcpiGbl_FACS; ACPI_EXTERN ACPI_COMMON_FACS AcpiGbl_CommonFACS; - /* - * Handle both ACPI 1.0 and ACPI 2.0 Integer widths - * If we are running a method that exists in a 32-bit ACPI table. - * Use only 32 bits of the Integer for conversion. + * Since there may be multiple SSDTs and PSDTs, a single pointer is not + * sufficient; Therefore, there isn't one! */ -ACPI_EXTERN UINT8 AcpiGbl_IntegerBitWidth; -ACPI_EXTERN UINT8 AcpiGbl_IntegerByteWidth; -ACPI_EXTERN UINT8 AcpiGbl_IntegerNybbleWidth; -/* Keep local copies of these FADT-based registers */ - -ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; -ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; /* - * Since there may be multiple SSDTs and PSDTS, a single pointer is not - * sufficient; Therefore, there isn't one! + * Handle both ACPI 1.0 and ACPI 2.0 Integer widths: + * If we are executing a method that exists in a 32-bit ACPI table, + * use only the lower 32 bits of the (internal) 64-bit Integer. */ - +ACPI_EXTERN UINT8 AcpiGbl_IntegerBitWidth; +ACPI_EXTERN UINT8 AcpiGbl_IntegerByteWidth; +ACPI_EXTERN UINT8 AcpiGbl_IntegerNybbleWidth; /* * ACPI Table info arrays @@ -215,6 +261,7 @@ ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[NUM_MUTEX]; ACPI_EXTERN ACPI_MEMORY_LIST AcpiGbl_MemoryLists[ACPI_NUM_MEM_LISTS]; ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_DeviceNotify; ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_SystemNotify; +ACPI_EXTERN ACPI_EXCEPTION_HANDLER AcpiGbl_ExceptionHandler; ACPI_EXTERN ACPI_INIT_HANDLER AcpiGbl_InitHandler; ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; ACPI_EXTERN ACPI_HANDLE AcpiGbl_GlobalLockSemaphore; @@ -234,13 +281,16 @@ ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; ACPI_EXTERN BOOLEAN AcpiGbl_EventsInitialized; +ACPI_EXTERN BOOLEAN AcpiGbl_SystemAwakeAndRunning; extern BOOLEAN AcpiGbl_Shutdown; extern UINT32 AcpiGbl_StartupFlags; extern const UINT8 AcpiGbl_DecodeTo8bit[8]; -extern const char *AcpiGbl_DbSleepStates[ACPI_S_STATE_COUNT]; +extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]; +extern const char *AcpiGbl_HighestDstateNames[4]; extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; +extern const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS]; /***************************************************************************** @@ -251,7 +301,7 @@ extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_ #define NUM_NS_TYPES ACPI_TYPE_INVALID+1 -#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) +#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) #define NUM_PREDEFINED_NAMES 10 #else #define NUM_PREDEFINED_NAMES 9 @@ -259,6 +309,7 @@ extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_ ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_FadtGpeDevice; extern const UINT8 AcpiGbl_NsProperties[NUM_NS_TYPES]; extern const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; @@ -272,6 +323,7 @@ ACPI_EXTERN ACPI_SIZE AcpiGbl_LowestStackPointer; ACPI_EXTERN UINT32 AcpiGbl_DeepestNesting; #endif + /***************************************************************************** * * Interpreter globals @@ -294,6 +346,7 @@ ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; ACPI_EXTERN ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot; + /***************************************************************************** * * Hardware globals @@ -324,7 +377,6 @@ ACPI_EXTERN ACPI_HANDLE AcpiGbl_GpeLock; * ****************************************************************************/ - ACPI_EXTERN UINT8 AcpiGbl_DbOutputFlags; #ifdef ACPI_DISASSEMBLER @@ -379,5 +431,4 @@ ACPI_EXTERN UINT32 AcpiGbl_SizeOfAcpiObjects; #endif /* ACPI_DEBUGGER */ - #endif /* __ACGLOBAL_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/achware.h b/sys/dev/acpi/acpica/Subsystem/achware.h index 28ecf9e614b..1f3a33da5b3 100644 --- a/sys/dev/acpi/acpica/Subsystem/achware.h +++ b/sys/dev/acpi/acpica/Subsystem/achware.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: achware.h -- hardware specific interfaces - * xRevision: 68 $ + * xRevision: 77 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -119,22 +119,26 @@ /* PM Timer ticks per second (HZ) */ + #define PM_TIMER_FREQUENCY 3579545 +/* Values for the _SST reserved method */ -/* Prototypes */ +#define ACPI_SST_INDICATOR_OFF 0 +#define ACPI_SST_WORKING 1 +#define ACPI_SST_WAKING 2 +#define ACPI_SST_SLEEPING 3 +#define ACPI_SST_SLEEP_CONTEXT 4 -ACPI_STATUS -AcpiHwInitialize ( - void); +/* Prototypes */ -ACPI_STATUS -AcpiHwShutdown ( - void); +/* + * hwacpi - high level functions + */ ACPI_STATUS -AcpiHwInitializeSystemInfo ( +AcpiHwInitialize ( void); ACPI_STATUS @@ -145,12 +149,10 @@ UINT32 AcpiHwGetMode ( void); -UINT32 -AcpiHwGetModeCapabilities ( - void); - -/* Register I/O Prototypes */ +/* + * hwregs - ACPI Register I/O + */ ACPI_BIT_REGISTER_INFO * AcpiHwGetBitRegisterInfo ( UINT32 RegisterId); @@ -184,18 +186,11 @@ AcpiHwClearAcpiStatus ( UINT32 Flags); -/* GPE support */ - -ACPI_STATUS -AcpiHwEnableGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); - -void -AcpiHwEnableGpeForWakeup ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); - +/* + * hwgpe - GPE support + */ ACPI_STATUS -AcpiHwDisableGpe ( +AcpiHwWriteGpeEnableReg ( ACPI_GPE_EVENT_INFO *GpeEventInfo); ACPI_STATUS @@ -203,10 +198,6 @@ AcpiHwDisableGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock); -void -AcpiHwDisableGpeForWakeup ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); - ACPI_STATUS AcpiHwClearGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo); @@ -222,16 +213,26 @@ AcpiHwGetGpeStatus ( ACPI_EVENT_STATUS *EventStatus); ACPI_STATUS -AcpiHwDisableNonWakeupGpes ( - void); +AcpiHwDisableAllGpes ( + UINT32 Flags); ACPI_STATUS -AcpiHwEnableNonWakeupGpes ( - void); +AcpiHwEnableAllRuntimeGpes ( + UINT32 Flags); + +ACPI_STATUS +AcpiHwEnableAllWakeupGpes ( + UINT32 Flags); +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock); -/* ACPI Timer prototypes */ +/* + * hwtimer - ACPI Timer prototypes + */ ACPI_STATUS AcpiGetTimerResolution ( UINT32 *Resolution); diff --git a/sys/dev/acpi/acpica/Subsystem/acinterp.h b/sys/dev/acpi/acpica/Subsystem/acinterp.h index 36b6c31b24f..87f179d75ed 100644 --- a/sys/dev/acpi/acpica/Subsystem/acinterp.h +++ b/sys/dev/acpi/acpica/Subsystem/acinterp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acinterp.h - Interpreter subcomponent prototypes and defines - * xRevision: 147 $ + * xRevision: 162 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,56 +121,32 @@ #define ACPI_WALK_OPERANDS (&(WalkState->Operands [WalkState->NumOperands -1])) -ACPI_STATUS -AcpiExResolveOperands ( - UINT16 Opcode, - ACPI_OPERAND_OBJECT **StackPtr, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiExCheckObjectType ( - ACPI_OBJECT_TYPE TypeNeeded, - ACPI_OBJECT_TYPE ThisType, - void *Object); - -/* - * exxface - External interpreter interfaces - */ - -ACPI_STATUS -AcpiExLoadTable ( - ACPI_TABLE_TYPE TableId); - -ACPI_STATUS -AcpiExExecuteMethod ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc); - - /* * exconvrt - object conversion */ - ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - ACPI_WALK_STATE *WalkState); + UINT32 Flags); ACPI_STATUS AcpiExConvertToBuffer ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc, - ACPI_WALK_STATE *WalkState); + ACPI_OPERAND_OBJECT **ResultDesc); ACPI_STATUS AcpiExConvertToString ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - UINT32 Base, - UINT32 MaxLength, - ACPI_WALK_STATE *WalkState); + UINT32 Type); + +/* Types for ->String conversion */ + +#define ACPI_EXPLICIT_BYTE_COPY 0x00000000 +#define ACPI_EXPLICIT_CONVERT_HEX 0x00000001 +#define ACPI_IMPLICIT_CONVERT_HEX 0x00000002 +#define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003 ACPI_STATUS AcpiExConvertToTargetType ( @@ -179,52 +155,15 @@ AcpiExConvertToTargetType ( ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState); -UINT32 -AcpiExConvertToAscii ( - ACPI_INTEGER Integer, - UINT32 Base, - UINT8 *String, - UINT8 MaxLength); /* * exfield - ACPI AML (p-code) execution - field manipulation */ - -ACPI_STATUS -AcpiExExtractFromField ( - ACPI_OPERAND_OBJECT *ObjDesc, - void *Buffer, - UINT32 BufferLength); - -ACPI_STATUS -AcpiExInsertIntoField ( - ACPI_OPERAND_OBJECT *ObjDesc, - void *Buffer, - UINT32 BufferLength); - -ACPI_STATUS -AcpiExSetupRegion ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset); - -ACPI_STATUS -AcpiExAccessRegion ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset, - ACPI_INTEGER *Value, - UINT32 ReadWrite); - -BOOLEAN -AcpiExRegisterOverflow ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_INTEGER Value); - ACPI_STATUS -AcpiExFieldDatumIo ( +AcpiExCommonBufferSetup ( ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset, - ACPI_INTEGER *Value, - UINT32 ReadWrite); + UINT32 BufferLength, + UINT32 *DatumCount); ACPI_STATUS AcpiExWriteWithUpdateRule ( @@ -261,28 +200,33 @@ AcpiExWriteDataToField ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc); + /* - * exmisc - ACPI AML (p-code) execution - specific opcodes + * exfldio - low level field I/O */ - ACPI_STATUS -AcpiExOpcode_3A_0T_0R ( - ACPI_WALK_STATE *WalkState); +AcpiExExtractFromField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); ACPI_STATUS -AcpiExOpcode_3A_1T_1R ( - ACPI_WALK_STATE *WalkState); +AcpiExInsertIntoField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); ACPI_STATUS -AcpiExOpcode_6A_0T_1R ( - ACPI_WALK_STATE *WalkState); +AcpiExAccessRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); -BOOLEAN -AcpiExDoMatch ( - UINT32 MatchOp, - ACPI_INTEGER PackageValue, - ACPI_INTEGER MatchValue); +/* + * exmisc - misc support routines + */ ACPI_STATUS AcpiExGetObjectReference ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -290,13 +234,6 @@ AcpiExGetObjectReference ( ACPI_WALK_STATE *WalkState); ACPI_STATUS -AcpiExResolveMultiple ( - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT *Operand, - ACPI_OBJECT_TYPE *ReturnType, - ACPI_OPERAND_OBJECT **ReturnDesc); - -ACPI_STATUS AcpiExConcatTemplate ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *ObjDesc2, @@ -310,11 +247,19 @@ AcpiExDoConcatenate ( ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState); -BOOLEAN +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult); + +ACPI_STATUS AcpiExDoLogicalOp ( UINT16 Opcode, - ACPI_INTEGER Operand0, - ACPI_INTEGER Operand1); + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult); ACPI_INTEGER AcpiExDoMathOp ( @@ -363,13 +308,6 @@ AcpiExCreateMethod ( /* * exconfig - dynamic table load/unload */ - -ACPI_STATUS -AcpiExAddTable ( - ACPI_TABLE_HEADER *Table, - ACPI_NAMESPACE_NODE *ParentNode, - ACPI_OPERAND_OBJECT **DdbHandle); - ACPI_STATUS AcpiExLoadOp ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -389,7 +327,6 @@ AcpiExUnloadTable ( /* * exmutex - mutex support */ - ACPI_STATUS AcpiExAcquireMutex ( ACPI_OPERAND_OBJECT *TimeDesc, @@ -409,15 +346,10 @@ void AcpiExUnlinkMutex ( ACPI_OPERAND_OBJECT *ObjDesc); -void -AcpiExLinkMutex ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_THREAD_STATE *Thread); /* - * exprep - ACPI AML (p-code) execution - prep utilities + * exprep - ACPI AML execution - prep utilities */ - ACPI_STATUS AcpiExPrepCommonFieldObject ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -430,10 +362,10 @@ ACPI_STATUS AcpiExPrepFieldValue ( ACPI_CREATE_FIELD_INFO *Info); + /* * exsystem - Interface to OS services */ - ACPI_STATUS AcpiExSystemDoNotifyOp ( ACPI_OPERAND_OBJECT *Value, @@ -441,7 +373,7 @@ AcpiExSystemDoNotifyOp ( ACPI_STATUS AcpiExSystemDoSuspend( - UINT32 Time); + ACPI_INTEGER Time); ACPI_STATUS AcpiExSystemDoStall ( @@ -476,8 +408,11 @@ AcpiExSystemWaitSemaphore ( /* - * exmonadic - ACPI AML (p-code) execution, monadic operators + * exoparg1 - ACPI AML execution, 1 operand */ +ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExOpcode_1A_0T_0R ( @@ -496,9 +431,8 @@ AcpiExOpcode_1A_1T_0R ( ACPI_WALK_STATE *WalkState); /* - * exdyadic - ACPI AML (p-code) execution, dyadic operators + * exoparg2 - ACPI AML execution, 2 operands */ - ACPI_STATUS AcpiExOpcode_2A_0T_0R ( ACPI_WALK_STATE *WalkState); @@ -517,32 +451,67 @@ AcpiExOpcode_2A_2T_1R ( /* - * exresolv - Object resolution and get value functions + * exoparg3 - ACPI AML execution, 3 operands */ +ACPI_STATUS +AcpiExOpcode_3A_0T_0R ( + ACPI_WALK_STATE *WalkState); ACPI_STATUS +AcpiExOpcode_3A_1T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exoparg6 - ACPI AML execution, 6 operands + */ +ACPI_STATUS +AcpiExOpcode_6A_0T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exresolv - Object resolution and get value functions + */ +ACPI_STATUS AcpiExResolveToValue ( ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState); ACPI_STATUS +AcpiExResolveMultiple ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *Operand, + ACPI_OBJECT_TYPE *ReturnType, + ACPI_OPERAND_OBJECT **ReturnDesc); + + +/* + * exresnte - resolve namespace node + */ +ACPI_STATUS AcpiExResolveNodeToValue ( ACPI_NAMESPACE_NODE **StackPtr, ACPI_WALK_STATE *WalkState); + +/* + * exresop - resolve operand to value + */ ACPI_STATUS -AcpiExResolveObjectToValue ( +AcpiExResolveOperands ( + UINT16 Opcode, ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState); /* - * exdump - Scanner debug output routines + * exdump - Interpreter debug output routines */ - void AcpiExDumpOperand ( - ACPI_OPERAND_OBJECT *EntryDesc); + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth); void AcpiExDumpOperands ( @@ -564,45 +533,10 @@ AcpiExDumpNode ( ACPI_NAMESPACE_NODE *Node, UINT32 Flags); -void -AcpiExOutString ( - char *Title, - char *Value); - -void -AcpiExOutPointer ( - char *Title, - void *Value); - -void -AcpiExOutInteger ( - char *Title, - UINT32 Value); - -void -AcpiExOutAddress ( - char *Title, - ACPI_PHYSICAL_ADDRESS Value); - /* - * exnames - interpreter/scanner name load/execute + * exnames - AML namestring support */ - -char * -AcpiExAllocateNameString ( - UINT32 PrefixCount, - UINT32 NumNameSegs); - -UINT32 -AcpiExGoodChar ( - UINT32 Character); - -ACPI_STATUS -AcpiExNameSegment ( - UINT8 **InAmlAddress, - char *NameString); - ACPI_STATUS AcpiExGetNameString ( ACPI_OBJECT_TYPE DataType, @@ -610,16 +544,10 @@ AcpiExGetNameString ( char **OutNameString, UINT32 *OutNameLength); -ACPI_STATUS -AcpiExDoName ( - ACPI_OBJECT_TYPE DataType, - ACPI_INTERPRETER_MODE LoadExecMode); - /* * exstore - Object store support */ - ACPI_STATUS AcpiExStore ( ACPI_OPERAND_OBJECT *ValDesc, @@ -627,22 +555,19 @@ AcpiExStore ( ACPI_WALK_STATE *WalkState); ACPI_STATUS -AcpiExStoreObjectToIndex ( - ACPI_OPERAND_OBJECT *ValDesc, - ACPI_OPERAND_OBJECT *DestDesc, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS AcpiExStoreObjectToNode ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node, - ACPI_WALK_STATE *WalkState); + ACPI_WALK_STATE *WalkState, + UINT8 ImplicitConversion); + +#define ACPI_IMPLICIT_CONVERSION TRUE +#define ACPI_NO_IMPLICIT_CONVERSION FALSE /* - * exstoren + * exstoren - resolve/store object */ - ACPI_STATUS AcpiExResolveObject ( ACPI_OPERAND_OBJECT **SourceDescPtr, @@ -658,9 +583,8 @@ AcpiExStoreObjectToObject ( /* - * excopy - object copy + * exstorob - store object - buffer/string */ - ACPI_STATUS AcpiExStoreBufferToBuffer ( ACPI_OPERAND_OBJECT *SourceDesc, @@ -671,6 +595,10 @@ AcpiExStoreStringToString ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc); + +/* + * excopy - object copy + */ ACPI_STATUS AcpiExCopyIntegerToIndexField ( ACPI_OPERAND_OBJECT *SourceDesc, @@ -691,10 +619,10 @@ AcpiExCopyIntegerToBufferField ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc); + /* * exutils - interpreter/scanner utilities */ - ACPI_STATUS AcpiExEnterInterpreter ( void); @@ -715,11 +643,6 @@ void AcpiExReleaseGlobalLock ( BOOLEAN Locked); -UINT32 -AcpiExDigitsNeeded ( - ACPI_INTEGER Value, - UINT32 Base); - void AcpiExEisaIdToString ( UINT32 NumericId, @@ -734,7 +657,6 @@ AcpiExUnsignedIntegerToString ( /* * exregion - default OpRegion handlers */ - ACPI_STATUS AcpiExSystemMemorySpaceHandler ( UINT32 Function, diff --git a/sys/dev/acpi/acpica/Subsystem/aclocal.h b/sys/dev/acpi/acpica/Subsystem/aclocal.h index 9acd82ee69d..588edcf0d7c 100644 --- a/sys/dev/acpi/acpica/Subsystem/aclocal.h +++ b/sys/dev/acpi/acpica/Subsystem/aclocal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: aclocal.h - Internal data types used across the ACPI subsystem - * xRevision: 198 $ + * xRevision: 206 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -126,7 +126,7 @@ typedef UINT32 ACPI_MUTEX_HANDLE; /* Total number of aml opcodes defined */ -#define AML_NUM_OPCODES 0x7E +#define AML_NUM_OPCODES 0x7F /***************************************************************************** @@ -145,7 +145,6 @@ typedef UINT32 ACPI_MUTEX_HANDLE; * * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames table also! */ - #define ACPI_MTX_EXECUTE 0 #define ACPI_MTX_INTERPRETER 1 #define ACPI_MTX_PARSER 2 @@ -225,13 +224,13 @@ typedef UINT16 ACPI_OWNER_ID; #define ACPI_FIELD_DWORD_GRANULARITY 4 #define ACPI_FIELD_QWORD_GRANULARITY 8 + /***************************************************************************** * * Namespace typedefs and structs * ****************************************************************************/ - /* Operational modes of the AML interpreter/scanner */ typedef enum @@ -250,7 +249,6 @@ typedef enum * DataType is used to differentiate between internal descriptors, and MUST * be the first byte in this structure. */ - typedef union acpi_name_union { UINT32 Integer; @@ -264,8 +262,6 @@ typedef struct acpi_namespace_node UINT8 Type; /* Type associated with this name */ UINT16 OwnerId; ACPI_NAME_UNION Name; /* ACPI Name, always 4 chars per ACPI spec */ - - union acpi_operand_object *Object; /* Pointer to attached ACPI object (optional) */ struct acpi_namespace_node *Child; /* First child */ struct acpi_namespace_node *Peer; /* Next peer*/ @@ -287,10 +283,8 @@ typedef struct acpi_namespace_node #define ANOBJ_METHOD_LOCAL 0x10 #define ANOBJ_METHOD_NO_RETVAL 0x20 #define ANOBJ_METHOD_SOME_NO_RETVAL 0x40 - #define ANOBJ_IS_BIT_OFFSET 0x80 - /* * ACPI Table Descriptor. One per ACPI table */ @@ -392,16 +386,33 @@ typedef struct acpi_create_field_info * ****************************************************************************/ -/* Information about a GPE, one per each GPE in an array */ +/* Dispatch info for each GPE -- either a method or handler, cannot be both */ -typedef struct acpi_gpe_event_info +typedef struct acpi_handler_info { - ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level */ - ACPI_GPE_HANDLER Handler; /* Address of handler, if any */ + ACPI_EVENT_HANDLER Address; /* Address of handler, if any */ void *Context; /* Context to be passed to handler */ + ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level (saved) */ + +} ACPI_HANDLER_INFO; + +typedef union acpi_gpe_dispatch_info +{ + ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level */ + struct acpi_handler_info *Handler; + +} ACPI_GPE_DISPATCH_INFO; + +/* + * Information about a GPE, one per each GPE in an array. + * NOTE: Important to keep this struct as small as possible. + */ +typedef struct acpi_gpe_event_info +{ + union acpi_gpe_dispatch_info Dispatch; /* Either Method or Handler */ struct acpi_gpe_register_info *RegisterInfo; /* Backpointer to register info */ - UINT8 Flags; /* Level or Edge */ - UINT8 BitMask; /* This GPE within the register */ + UINT8 Flags; /* Misc info about this GPE */ + UINT8 RegisterBit; /* This GPE bit within the register */ } ACPI_GPE_EVENT_INFO; @@ -411,9 +422,8 @@ typedef struct acpi_gpe_register_info { ACPI_GENERIC_ADDRESS StatusAddress; /* Address of status reg */ ACPI_GENERIC_ADDRESS EnableAddress; /* Address of enable reg */ - UINT8 Status; /* Current value of status reg */ - UINT8 Enable; /* Current value of enable reg */ - UINT8 WakeEnable; /* Mask of bits to keep enabled when sleeping */ + UINT8 EnableForWake; /* GPEs to keep enabled when sleeping */ + UINT8 EnableForRun; /* GPEs to keep enabled when running */ UINT8 BaseGpeNumber; /* Base GPE number for this register */ } ACPI_GPE_REGISTER_INFO; @@ -424,6 +434,7 @@ typedef struct acpi_gpe_register_info */ typedef struct acpi_gpe_block_info { + ACPI_NAMESPACE_NODE *Node; struct acpi_gpe_block_info *Previous; struct acpi_gpe_block_info *Next; struct acpi_gpe_xrupt_info *XruptBlock; /* Backpointer to interrupt block */ @@ -447,6 +458,14 @@ typedef struct acpi_gpe_xrupt_info } ACPI_GPE_XRUPT_INFO; +typedef struct acpi_gpe_walk_info +{ + ACPI_NAMESPACE_NODE *GpeDevice; + ACPI_GPE_BLOCK_INFO *GpeBlock; + +} ACPI_GPE_WALK_INFO; + + typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock); @@ -487,7 +506,6 @@ typedef struct acpi_field_info * ****************************************************************************/ - #define ACPI_CONTROL_NORMAL 0xC0 #define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1 #define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2 @@ -496,6 +514,7 @@ typedef struct acpi_field_info /* Forward declarations */ + struct acpi_walk_state; struct acpi_obj_mutex; union acpi_parse_object; @@ -590,7 +609,7 @@ typedef struct acpi_thread_state struct acpi_walk_state *WalkStateList; /* Head of list of WalkStates for this thread */ union acpi_operand_object *AcquiredMutexList; /* List of all currently acquired mutexes */ UINT32 ThreadId; /* Running thread ID */ - UINT16 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ + UINT8 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ } ACPI_THREAD_STATE; @@ -683,7 +702,6 @@ typedef struct acpi_opcode_info } ACPI_OPCODE_INFO; - typedef union acpi_parse_value { ACPI_INTEGER Integer; /* Integer constant (Up to 64 bits) */ @@ -696,7 +714,6 @@ typedef union acpi_parse_value } ACPI_PARSE_VALUE; - #define ACPI_PARSE_COMMON \ UINT8 DataType; /* To differentiate various internal objs */\ UINT8 Flags; /* Type of Op */\ @@ -776,7 +793,6 @@ typedef struct acpi_parse_obj_asl } ACPI_PARSE_OBJ_ASL; - typedef union acpi_parse_object { ACPI_PARSE_OBJ_COMMON Common; @@ -862,6 +878,7 @@ typedef struct acpi_bit_register_info #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ #define ACPI_BITMASK_WAKE_STATUS 0x8000 #define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \ @@ -877,6 +894,7 @@ typedef struct acpi_bit_register_info #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ #define ACPI_BITMASK_SCI_ENABLE 0x0001 #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 @@ -895,6 +913,7 @@ typedef struct acpi_bit_register_info #define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 #define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ #define ACPI_BITPOSITION_WAKE_STATUS 0x0F #define ACPI_BITPOSITION_TIMER_ENABLE 0x00 @@ -902,6 +921,7 @@ typedef struct acpi_bit_register_info #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 #define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ #define ACPI_BITPOSITION_SCI_ENABLE 0x00 #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 @@ -918,7 +938,6 @@ typedef struct acpi_bit_register_info * ****************************************************************************/ - /* ResourceType values */ #define ACPI_RESOURCE_TYPE_MEMORY_RANGE 0 @@ -950,7 +969,6 @@ typedef struct acpi_bit_register_info /* * Large resource descriptor types */ - #define ACPI_RDESC_TYPE_MEMORY_24 0x81 #define ACPI_RDESC_TYPE_GENERAL_REGISTER 0x82 #define ACPI_RDESC_TYPE_LARGE_VENDOR 0x84 @@ -960,6 +978,7 @@ typedef struct acpi_bit_register_info #define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE 0x88 #define ACPI_RDESC_TYPE_EXTENDED_XRUPT 0x89 #define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A +#define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B /***************************************************************************** diff --git a/sys/dev/acpi/acpica/Subsystem/acmacros.h b/sys/dev/acpi/acpica/Subsystem/acmacros.h index 95cafc5ff52..6d38582bd89 100644 --- a/sys/dev/acpi/acpica/Subsystem/acmacros.h +++ b/sys/dev/acpi/acpica/Subsystem/acmacros.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acmacros.h - C macros for the entire subsystem. - * xRevision: 148 $ + * xRevision: 158 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -126,6 +126,10 @@ #define ACPI_LOBYTE(l) ((UINT8)(UINT16)(l)) #define ACPI_HIBYTE(l) ((UINT8)((((UINT16)(l)) >> 8) & 0xFF)) +#define ACPI_SET_BIT(target,bit) ((target) |= (bit)) +#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) +#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) + #if ACPI_MACHINE_WIDTH == 16 @@ -170,7 +174,7 @@ * printf() format helpers */ -/* Split 64-bit integer into two 32-bit values. Use with %8,8X%8.8X */ +/* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */ #define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) @@ -434,24 +438,6 @@ #define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) -/* Macros for GAS addressing */ - -#if ACPI_MACHINE_WIDTH != 16 - -#define ACPI_PCI_DEVICE(a) (UINT16) ((ACPI_HIDWORD ((a))) & 0x0000FFFF) -#define ACPI_PCI_FUNCTION(a) (UINT16) ((ACPI_LODWORD ((a))) >> 16) -#define ACPI_PCI_REGISTER(a) (UINT16) ((ACPI_LODWORD ((a))) & 0x0000FFFF) - -#else - -/* 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 - /* Bitfields within ACPI registers */ @@ -575,19 +561,19 @@ * 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. */ -#define ACPI_FUNCTION_NAME(a) ACPI_DEBUG_PRINT_INFO _Dbg; \ - _Dbg.ComponentId = _COMPONENT; \ - _Dbg.ProcName = a; \ - _Dbg.ModuleName = _THIS_MODULE; +#define ACPI_FUNCTION_NAME(a) ACPI_DEBUG_PRINT_INFO _DebugInfo; \ + _DebugInfo.ComponentId = _COMPONENT; \ + _DebugInfo.ProcName = a; \ + _DebugInfo.ModuleName = _THIS_MODULE; #define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ - AcpiUtTrace(__LINE__,&_Dbg) + AcpiUtTrace(__LINE__,&_DebugInfo) #define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTracePtr(__LINE__,&_Dbg,(void *)b) + AcpiUtTracePtr(__LINE__,&_DebugInfo,(void *)b) #define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTraceU32(__LINE__,&_Dbg,(UINT32)b) + AcpiUtTraceU32(__LINE__,&_DebugInfo,(UINT32)b) #define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTraceStr(__LINE__,&_Dbg,(char *)b) + AcpiUtTraceStr(__LINE__,&_DebugInfo,(char *)b) #define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr() @@ -604,10 +590,10 @@ #define ACPI_DO_WHILE0(a) a #endif -#define return_VOID ACPI_DO_WHILE0 ({AcpiUtExit(__LINE__,&_Dbg);return;}) -#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({AcpiUtStatusExit(__LINE__,&_Dbg,(s));return((s));}) -#define return_VALUE(s) ACPI_DO_WHILE0 ({AcpiUtValueExit(__LINE__,&_Dbg,(ACPI_INTEGER)(s));return((s));}) -#define return_PTR(s) ACPI_DO_WHILE0 ({AcpiUtPtrExit(__LINE__,&_Dbg,(UINT8 *)(s));return((s));}) +#define return_VOID ACPI_DO_WHILE0 ({AcpiUtExit(__LINE__,&_DebugInfo);return;}) +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({AcpiUtStatusExit(__LINE__,&_DebugInfo,(s));return((s));}) +#define return_VALUE(s) ACPI_DO_WHILE0 ({AcpiUtValueExit(__LINE__,&_DebugInfo,(ACPI_INTEGER)(s));return((s));}) +#define return_PTR(s) ACPI_DO_WHILE0 ({AcpiUtPtrExit(__LINE__,&_DebugInfo,(UINT8 *)(s));return((s));}) /* Conditional execution */ @@ -621,12 +607,11 @@ /* Stack and buffer dumping */ -#define ACPI_DUMP_STACK_ENTRY(a) AcpiExDumpOperand(a) +#define ACPI_DUMP_STACK_ENTRY(a) AcpiExDumpOperand((a),0) #define ACPI_DUMP_OPERANDS(a,b,c,d,e) AcpiExDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__) #define ACPI_DUMP_ENTRY(a,b) AcpiNsDumpEntry (a,b) -#define ACPI_DUMP_TABLES(a,b) AcpiNsDumpTables(a,b) #define ACPI_DUMP_PATHNAME(a,b,c,d) AcpiNsDumpPathname(a,b,c,d) #define ACPI_DUMP_RESOURCE_LIST(a) AcpiRsDumpResourceList(a) #define ACPI_DUMP_BUFFER(a,b) AcpiUtDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) @@ -754,7 +739,4 @@ #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ - -#define ACPI_GET_STACK_POINTER _asm {mov eax, ebx} - #endif /* ACMACROS_H */ diff --git a/sys/dev/acpi/acpica/Subsystem/acnames.h b/sys/dev/acpi/acpica/Subsystem/acnames.h index c993cad23a5..700616d97a3 100644 --- a/sys/dev/acpi/acpica/Subsystem/acnames.h +++ b/sys/dev/acpi/acpica/Subsystem/acnames.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acnames.h - Global names and strings - * $Revision: 1.1.1.1 $ + * xRevision: 1 $ * *****************************************************************************/ diff --git a/sys/dev/acpi/acpica/Subsystem/acnamesp.h b/sys/dev/acpi/acpica/Subsystem/acnamesp.h index 0a722439229..7b53b89bf2e 100644 --- a/sys/dev/acpi/acpica/Subsystem/acnamesp.h +++ b/sys/dev/acpi/acpica/Subsystem/acnamesp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acnamesp.h - Namespace subcomponent prototypes and defines - * xRevision: 135 $ + * xRevision: 140 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -130,17 +130,6 @@ #define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ #define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ - -/* Definitions of the predefined namespace names */ - -#define ACPI_UNKNOWN_NAME (UINT32) 0x3F3F3F3F /* Unknown name is "????" */ -#define ACPI_ROOT_NAME (UINT32) 0x5F5F5F5C /* Root name is "\___" */ -#define ACPI_SYS_BUS_NAME (UINT32) 0x5F53425F /* Sys bus name is "_SB_" */ - -#define ACPI_NS_ROOT_PATH "\\" -#define ACPI_NS_SYSTEM_BUS "_SB_" - - /* Flags for AcpiNsLookup, AcpiNsSearchAndEnter */ #define ACPI_NS_NO_UPSEARCH 0 @@ -153,10 +142,9 @@ #define ACPI_NS_WALK_NO_UNLOCK FALSE -ACPI_STATUS -AcpiNsLoadNamespace ( - void); - +/* + * nsinit - Namespace initialization + */ ACPI_STATUS AcpiNsInitializeObjects ( void); @@ -166,23 +154,22 @@ AcpiNsInitializeDevices ( void); -/* Namespace init - nsxfinit */ - +/* + * nsload - Namespace loading + */ ACPI_STATUS -AcpiNsInitOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); +AcpiNsLoadNamespace ( + void); ACPI_STATUS -AcpiNsInitOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); +AcpiNsLoadTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *Node); +/* + * nswalk - walk the namespace + */ ACPI_STATUS AcpiNsWalkNamespace ( ACPI_OBJECT_TYPE Type, @@ -199,37 +186,24 @@ AcpiNsGetNextNode ( ACPI_NAMESPACE_NODE *Parent, ACPI_NAMESPACE_NODE *Child); -void -AcpiNsDeleteNamespaceByOwner ( - UINT16 TableId); - - -/* Namespace loading - nsload */ - -ACPI_STATUS -AcpiNsOneCompleteParse ( - UINT32 PassNumber, - ACPI_TABLE_DESC *TableDesc); +/* + * nsparse - table parsing + */ ACPI_STATUS AcpiNsParseTable ( ACPI_TABLE_DESC *TableDesc, ACPI_NAMESPACE_NODE *Scope); ACPI_STATUS -AcpiNsLoadTable ( - ACPI_TABLE_DESC *TableDesc, - ACPI_NAMESPACE_NODE *Node); - -ACPI_STATUS -AcpiNsLoadTableByType ( - ACPI_TABLE_TYPE TableType); +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + ACPI_TABLE_DESC *TableDesc); /* - * Top-level namespace access - nsaccess + * nsaccess - Top-level namespace access */ - ACPI_STATUS AcpiNsRootInitialize ( void); @@ -246,9 +220,8 @@ AcpiNsLookup ( /* - * Named object allocation/deallocation - nsalloc + * nsalloc - Named object allocation/deallocation */ - ACPI_NAMESPACE_NODE * AcpiNsCreateNode ( UINT32 Name); @@ -262,6 +235,10 @@ AcpiNsDeleteNamespaceSubtree ( ACPI_NAMESPACE_NODE *ParentHandle); void +AcpiNsDeleteNamespaceByOwner ( + UINT16 TableId); + +void AcpiNsDetachObject ( ACPI_NAMESPACE_NODE *Node); @@ -274,28 +251,10 @@ AcpiNsCompareNames ( char *Name1, char *Name2); -void -AcpiNsRemoveReference ( - ACPI_NAMESPACE_NODE *Node); - - -/* - * Namespace modification - nsmodify - */ - -ACPI_STATUS -AcpiNsUnloadNamespace ( - ACPI_HANDLE Handle); - -ACPI_STATUS -AcpiNsDeleteSubtree ( - ACPI_HANDLE StartHandle); - /* - * Namespace dump/print utilities - nsdump + * nsdump - Namespace dump/print utilities */ - void AcpiNsDumpTables ( ACPI_HANDLE SearchBase, @@ -319,17 +278,6 @@ AcpiNsPrintPathname ( char *Pathname); ACPI_STATUS -AcpiNsDumpOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); - -void -AcpiNsDumpRootDevices ( - void); - -ACPI_STATUS AcpiNsDumpOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -346,63 +294,30 @@ AcpiNsDumpObjects ( /* - * Namespace evaluation functions - nseval + * nseval - Namespace evaluation functions */ - ACPI_STATUS AcpiNsEvaluateByHandle ( - ACPI_NAMESPACE_NODE *PrefixNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject); + ACPI_PARAMETER_INFO *Info); ACPI_STATUS AcpiNsEvaluateByName ( char *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject); + ACPI_PARAMETER_INFO *Info); ACPI_STATUS AcpiNsEvaluateRelative ( - ACPI_NAMESPACE_NODE *PrefixNode, char *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject); - -ACPI_STATUS -AcpiNsExecuteControlMethod ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc); - -ACPI_STATUS -AcpiNsGetObjectValue ( - ACPI_NAMESPACE_NODE *ObjectNode, - ACPI_OPERAND_OBJECT **ReturnObjDesc); - - -/* - * Parent/Child/Peer utility functions - */ - -ACPI_NAME -AcpiNsFindParentName ( - ACPI_NAMESPACE_NODE *NodeToSearch); + ACPI_PARAMETER_INFO *Info); /* - * Name and Scope manipulation - nsnames + * nsnames - Name and Scope manipulation */ - UINT32 AcpiNsOpensScope ( ACPI_OBJECT_TYPE Type); -void -AcpiNsBuildExternalPath ( - ACPI_NAMESPACE_NODE *Node, - ACPI_SIZE Size, - char *NameBuffer); - char * AcpiNsGetExternalPathname ( ACPI_NAMESPACE_NODE *Node); @@ -434,9 +349,8 @@ AcpiNsGetPathnameLength ( /* - * Object management for namespace nodes - nsobject + * nsobject - Object management for namespace nodes */ - ACPI_STATUS AcpiNsAttachObject ( ACPI_NAMESPACE_NODE *Node, @@ -470,9 +384,8 @@ AcpiNsGetAttachedData ( /* - * Namespace searching and entry - nssearch + * nssearch - Namespace searching and entry */ - ACPI_STATUS AcpiNsSearchAndEnter ( UINT32 EntryName, @@ -499,17 +412,12 @@ AcpiNsInstallNode ( /* - * Utility functions - nsutils + * nsutils - Utility functions */ - BOOLEAN AcpiNsValidRootPrefix ( char Prefix); -BOOLEAN -AcpiNsValidPathSeparator ( - char Sep); - ACPI_OBJECT_TYPE AcpiNsGetType ( ACPI_NAMESPACE_NODE *Node); @@ -582,5 +490,4 @@ ACPI_NAMESPACE_NODE * AcpiNsGetNextValidNode ( ACPI_NAMESPACE_NODE *Node); - #endif /* __ACNAMESP_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/acnetbsd.h b/sys/dev/acpi/acpica/Subsystem/acnetbsd.h index 7127e66ff27..6339facf0a6 100644 --- a/sys/dev/acpi/acpica/Subsystem/acnetbsd.h +++ b/sys/dev/acpi/acpica/Subsystem/acnetbsd.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acnetbsd.h - OS specific defines, etc. - * $Revision: 1.12 $ + * $Revision: 1.13 $ * *****************************************************************************/ @@ -117,16 +117,6 @@ #ifndef __ACNETBSD_H__ #define __ACNETBSD_H__ -#if 0 -/* - * XXX this is technically correct, but will cause problems with some ASL - * which only works if the string names a Microsoft operating system. - */ -#define ACPI_OS_NAME "NetBSD" -#else -#define ACPI_OS_NAME "Microsoft Windows NT" -#endif - /* NetBSD uses GCC */ #include "acgcc.h" diff --git a/sys/dev/acpi/acpica/Subsystem/acobject.h b/sys/dev/acpi/acpica/Subsystem/acobject.h index ea3b2085c1c..83c5588e40b 100644 --- a/sys/dev/acpi/acpica/Subsystem/acobject.h +++ b/sys/dev/acpi/acpica/Subsystem/acobject.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) - * xRevision: 123 $ + * xRevision: 129 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -167,9 +167,7 @@ UINT32 BitLength; /* Length of field in bits */\ UINT32 BaseByteOffset; /* Byte offset within containing object */\ UINT8 StartFieldBitOffset;/* Bit offset within first field datum (0-63) */\ - UINT8 DatumValidBits; /* Valid bit in first "Field datum" */\ - UINT8 EndFieldValidBits; /* Valid bits in the last "field datum" */\ - UINT8 EndBufferValidBits; /* Valid bits in the last "buffer datum" */\ + UINT8 AccessBitWidth; /* Read/Write size in bits (8-64) */\ UINT32 Value; /* Value to store into the Bank or Index register */\ ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ @@ -211,6 +209,10 @@ typedef struct acpi_object_integer } ACPI_OBJECT_INTEGER; +/* + * Note: The String and Buffer object must be identical through the Pointer + * element. There is code that depends on this. + */ typedef struct acpi_object_string /* Null terminated, ASCII characters only */ { ACPI_OBJECT_COMMON_HEADER @@ -259,7 +261,11 @@ typedef struct acpi_object_event } ACPI_OBJECT_EVENT; -#define INFINITE_CONCURRENCY 0xFF +#define ACPI_INFINITE_CONCURRENCY 0xFF + +typedef +ACPI_STATUS (*ACPI_INTERNAL_METHOD) ( + struct acpi_walk_state *WalkState); typedef struct acpi_object_method { @@ -269,6 +275,7 @@ typedef struct acpi_object_method UINT32 AmlLength; void *Semaphore; UINT8 *AmlStart; + ACPI_INTERNAL_METHOD Implementation; UINT8 Concurrency; UINT8 ThreadCount; ACPI_OWNER_ID OwningId; @@ -279,14 +286,14 @@ typedef struct acpi_object_method typedef struct acpi_object_mutex { ACPI_OBJECT_COMMON_HEADER - UINT16 SyncLevel; - UINT16 PreviousSyncLevel; - UINT16 AcquisitionDepth; - struct acpi_thread_state *OwnerThread; - void *Semaphore; + UINT8 SyncLevel; /* 0-15, specified in Mutex() call */ + UINT16 AcquisitionDepth; /* Allow multiple Acquires, same thread */ + struct acpi_thread_state *OwnerThread; /* Current owner of the mutex */ + void *Semaphore; /* Actual OS synchronization object */ union acpi_operand_object *Prev; /* Link for list of acquired mutexes */ union acpi_operand_object *Next; /* Link for list of acquired mutexes */ - ACPI_NAMESPACE_NODE *Node; /* containing object */ + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ + UINT8 OriginalSyncLevel; /* Owner's original sync level (0-15) */ } ACPI_OBJECT_MUTEX; @@ -297,7 +304,7 @@ typedef struct acpi_object_region UINT8 SpaceId; union acpi_operand_object *Handler; /* Handler for region access */ - ACPI_NAMESPACE_NODE *Node; /* containing object */ + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ union acpi_operand_object *Next; UINT32 Length; ACPI_PHYSICAL_ADDRESS Address; @@ -560,7 +567,6 @@ typedef union acpi_operand_object * *****************************************************************************/ - /* Object descriptor types */ #define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */ diff --git a/sys/dev/acpi/acpica/Subsystem/acopcode.h b/sys/dev/acpi/acpica/Subsystem/acopcode.h index 24b404020f5..b423c81edac 100644 --- a/sys/dev/acpi/acpica/Subsystem/acopcode.h +++ b/sys/dev/acpi/acpica/Subsystem/acopcode.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acopcode.h - AML opcode information for the AML parser and interpreter - * $Revision: 1.1.1.1 $ + * xRevision: 2 $ * *****************************************************************************/ diff --git a/sys/dev/acpi/acpica/Subsystem/acoutput.h b/sys/dev/acpi/acpica/Subsystem/acoutput.h index c7ffb10920a..701d3964b42 100644 --- a/sys/dev/acpi/acpica/Subsystem/acoutput.h +++ b/sys/dev/acpi/acpica/Subsystem/acoutput.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acoutput.h -- debug output - * xRevision: 94 $ + * xRevision: 96 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -209,7 +209,7 @@ /* * Debug level macros that are used in the DEBUG_PRINT macros */ -#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,__LINE__,&_Dbg +#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,__LINE__,&_DebugInfo /* Exception level -- used in the global "DebugLevel" */ diff --git a/sys/dev/acpi/acpica/Subsystem/acparser.h b/sys/dev/acpi/acpica/Subsystem/acparser.h index 33d774ec3c8..bd812eda497 100644 --- a/sys/dev/acpi/acpica/Subsystem/acparser.h +++ b/sys/dev/acpi/acpica/Subsystem/acparser.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: acparser.h - AML Parser subcomponent prototypes and defines - * xRevision: 66 $ + * xRevision: 73 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -137,8 +137,17 @@ #define ACPI_PARSE_DEFERRED_OP 0x0100 -/* Parser external interfaces */ +/****************************************************************************** + * + * Parser interfaces + * + *****************************************************************************/ + + +/* + * psxface - Parser external interfaces + */ ACPI_STATUS AcpiPsxLoadTable ( UINT8 *PcodeAddr, @@ -146,28 +155,16 @@ AcpiPsxLoadTable ( ACPI_STATUS AcpiPsxExecute ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc); - + ACPI_PARAMETER_INFO *Info); -/****************************************************************************** - * - * Parser interfaces - * - *****************************************************************************/ - - -/* psargs - Parse AML opcode arguments */ +/* + * psargs - Parse AML opcode arguments + */ UINT8 * AcpiPsGetNextPackageEnd ( ACPI_PARSE_STATE *ParserState); -UINT32 -AcpiPsGetNextPackageLength ( - ACPI_PARSE_STATE *ParserState); - char * AcpiPsGetNextNamestring ( ACPI_PARSE_STATE *ParserState); @@ -185,10 +182,6 @@ AcpiPsGetNextNamepath ( ACPI_PARSE_OBJECT *Arg, BOOLEAN MethodCall); -ACPI_PARSE_OBJECT * -AcpiPsGetNextField ( - ACPI_PARSE_STATE *ParserState); - ACPI_STATUS AcpiPsGetNextArg ( ACPI_WALK_STATE *WalkState, @@ -197,8 +190,9 @@ AcpiPsGetNextArg ( ACPI_PARSE_OBJECT **ReturnArg); -/* psfind */ - +/* + * psfind + */ ACPI_PARSE_OBJECT * AcpiPsFindName ( ACPI_PARSE_OBJECT *Scope, @@ -210,8 +204,9 @@ AcpiPsGetParent ( ACPI_PARSE_OBJECT *Op); -/* psopcode - AML Opcode information */ - +/* + * psopcode - AML Opcode information + */ const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo ( UINT16 Opcode); @@ -221,56 +216,25 @@ AcpiPsGetOpcodeName ( UINT16 Opcode); -/* psparse - top level parsing routines */ - -UINT32 -AcpiPsGetOpcodeSize ( - UINT32 Opcode); - -void -AcpiPsCompleteThisOp ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op); - -ACPI_STATUS -AcpiPsNextParseState ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op, - ACPI_STATUS CallbackStatus); - -ACPI_STATUS -AcpiPsFindObject ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT **OutOp); - -void -AcpiPsDeleteParseTree ( - ACPI_PARSE_OBJECT *root); - -ACPI_STATUS -AcpiPsParseLoop ( - ACPI_WALK_STATE *WalkState); - +/* + * psparse - top level parsing routines + */ ACPI_STATUS AcpiPsParseAml ( ACPI_WALK_STATE *WalkState); -ACPI_STATUS -AcpiPsParseTable ( - UINT8 *aml, - UINT32 amlSize, - ACPI_PARSE_DOWNWARDS DescendingCallback, - ACPI_PARSE_UPWARDS AscendingCallback, - ACPI_PARSE_OBJECT **RootObject); +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode); UINT16 AcpiPsPeekOpcode ( ACPI_PARSE_STATE *state); -/* psscope - Scope stack management routines */ - - +/* + * psscope - Scope stack management routines + */ ACPI_STATUS AcpiPsInitScope ( ACPI_PARSE_STATE *ParserState, @@ -303,8 +267,9 @@ AcpiPsCleanupScope ( ACPI_PARSE_STATE *state); -/* pstree - parse tree manipulation routines */ - +/* + * pstree - parse tree manipulation routines + */ void AcpiPsAppendArg( ACPI_PARSE_OBJECT *op, @@ -323,17 +288,14 @@ AcpiPsGetArg( UINT32 argn); ACPI_PARSE_OBJECT * -AcpiPsGetChild ( - ACPI_PARSE_OBJECT *op); - -ACPI_PARSE_OBJECT * AcpiPsGetDepthNext ( ACPI_PARSE_OBJECT *Origin, ACPI_PARSE_OBJECT *Op); -/* pswalk - parse tree walk routines */ - +/* + * pswalk - parse tree walk routines + */ ACPI_STATUS AcpiPsWalkParsedAml ( ACPI_PARSE_OBJECT *StartOp, @@ -356,9 +318,14 @@ ACPI_STATUS AcpiPsDeleteCompletedOp ( ACPI_WALK_STATE *WalkState); +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *root); -/* psutils - parser utilities */ +/* + * psutils - parser utilities + */ ACPI_PARSE_OBJECT * AcpiPsCreateScopeOp ( void); @@ -376,10 +343,6 @@ void AcpiPsFreeOp ( ACPI_PARSE_OBJECT *Op); -void -AcpiPsDeleteParseCache ( - void); - BOOLEAN AcpiPsIsLeadingChar ( UINT32 c); @@ -397,9 +360,16 @@ AcpiPsSetName( ACPI_PARSE_OBJECT *op, UINT32 name); +#ifdef ACPI_ENABLE_OBJECT_CACHE +void +AcpiPsDeleteParseCache ( + void); +#endif -/* psdump - display parser tree */ +/* + * psdump - display parser tree + */ UINT32 AcpiPsSprintPath ( char *BufferStart, diff --git a/sys/dev/acpi/acpica/Subsystem/acpi.h b/sys/dev/acpi/acpica/Subsystem/acpi.h index 748e0eeca34..6343508f0af 100644 --- a/sys/dev/acpi/acpica/Subsystem/acpi.h +++ b/sys/dev/acpi/acpica/Subsystem/acpi.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acpi.h - Master include file, Publics and external data. - * xRevision: 57 $ + * xRevision: 59 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -122,6 +122,7 @@ * We put them here because we don't want to duplicate them * in the rest of the source code again and again. */ +#include "acnames.h" /* Global ACPI names and strings */ #include "acconfig.h" /* Configuration constants */ #include "acenv.h" /* Target environment specific items */ #include "actypes.h" /* Fundamental common data types */ diff --git a/sys/dev/acpi/acpica/Subsystem/acpiosxf.h b/sys/dev/acpi/acpica/Subsystem/acpiosxf.h index eeedeaedd9f..d41ca0e5bed 100644 --- a/sys/dev/acpi/acpica/Subsystem/acpiosxf.h +++ b/sys/dev/acpi/acpica/Subsystem/acpiosxf.h @@ -12,7 +12,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -153,7 +153,6 @@ typedef struct acpi_signal_fatal_info /* * OSL Initialization and shutdown primitives */ - ACPI_STATUS AcpiOsInitialize ( void); @@ -166,7 +165,6 @@ AcpiOsTerminate ( /* * ACPI Table interfaces */ - ACPI_STATUS AcpiOsGetRootPointer ( UINT32 Flags, @@ -186,7 +184,6 @@ AcpiOsTableOverride ( /* * Synchronization primitives */ - ACPI_STATUS AcpiOsCreateSemaphore ( UINT32 MaxUnits, @@ -230,7 +227,6 @@ AcpiOsReleaseLock ( /* * Memory allocation and mapping */ - void * AcpiOsAllocate ( ACPI_SIZE Size); @@ -259,23 +255,21 @@ AcpiOsGetPhysicalAddress ( /* * Interrupt handlers */ - ACPI_STATUS AcpiOsInstallInterruptHandler ( UINT32 InterruptNumber, - OSD_HANDLER ServiceRoutine, + ACPI_OSD_HANDLER ServiceRoutine, void *Context); ACPI_STATUS AcpiOsRemoveInterruptHandler ( UINT32 InterruptNumber, - OSD_HANDLER ServiceRoutine); + ACPI_OSD_HANDLER ServiceRoutine); /* * Threads and Scheduling */ - UINT32 AcpiOsGetThreadId ( void); @@ -283,13 +277,16 @@ AcpiOsGetThreadId ( ACPI_STATUS AcpiOsQueueForExecution ( UINT32 Priority, - OSD_EXECUTION_CALLBACK Function, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context); + +void +AcpiOsWaitEventsComplete ( void *Context); void AcpiOsSleep ( - UINT32 Seconds, - UINT32 Milliseconds); + ACPI_INTEGER Milliseconds); void AcpiOsStall ( @@ -299,7 +296,6 @@ AcpiOsStall ( /* * Platform and hardware-independent I/O interfaces */ - ACPI_STATUS AcpiOsReadPort ( ACPI_IO_ADDRESS Address, @@ -316,7 +312,6 @@ AcpiOsWritePort ( /* * Platform and hardware-independent physical memory interfaces */ - ACPI_STATUS AcpiOsReadMemory ( ACPI_PHYSICAL_ADDRESS Address, @@ -332,19 +327,20 @@ AcpiOsWriteMemory ( /* * Platform and hardware-independent PCI configuration space access + * Note: Can't use "Register" as a parameter, changed to "Reg" -- + * certain compilers complain. */ - ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 Reg, void *Value, UINT32 Width); ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 Reg, ACPI_INTEGER Value, UINT32 Width); @@ -353,14 +349,13 @@ AcpiOsWritePciConfiguration ( */ void AcpiOsDerivePciId( - ACPI_HANDLE rhandle, - ACPI_HANDLE chandle, + ACPI_HANDLE Rhandle, + ACPI_HANDLE Chandle, ACPI_PCI_ID **PciId); /* * Miscellaneous */ - BOOLEAN AcpiOsReadable ( void *Pointer, @@ -371,7 +366,7 @@ AcpiOsWritable ( void *Pointer, ACPI_SIZE Length); -UINT32 +UINT64 AcpiOsGetTimer ( void); @@ -383,7 +378,6 @@ AcpiOsSignal ( /* * Debug print routines */ - void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf ( const char *Format, @@ -402,7 +396,6 @@ AcpiOsRedirectOutput ( /* * Debug input */ - UINT32 AcpiOsGetLine ( char *Buffer); @@ -411,7 +404,6 @@ AcpiOsGetLine ( /* * Directory manipulation */ - void * AcpiOsOpenDirectory ( char *Pathname, @@ -435,7 +427,6 @@ AcpiOsCloseDirectory ( /* * Debug */ - void AcpiOsDbgAssert( void *FailedAssertion, @@ -443,5 +434,4 @@ AcpiOsDbgAssert( UINT32 LineNumber, char *Message); - #endif /* __ACPIOSXF_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/acpixf.h b/sys/dev/acpi/acpica/Subsystem/acpixf.h index d836f58b9e5..29519bd0aef 100644 --- a/sys/dev/acpi/acpica/Subsystem/acpixf.h +++ b/sys/dev/acpi/acpica/Subsystem/acpixf.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -122,10 +122,9 @@ #include "actbl.h" - /* +/* * Global interfaces */ - ACPI_STATUS AcpiInitializeSubsystem ( void); @@ -172,9 +171,8 @@ AcpiInstallInitializationHandler ( UINT32 Function); /* - * ACPI Memory manager + * ACPI Memory managment */ - void * AcpiAllocate ( UINT32 Size); @@ -191,7 +189,6 @@ AcpiFree ( /* * ACPI table manipulation interfaces */ - ACPI_STATUS AcpiFindRootPointer ( UINT32 Flags, @@ -232,7 +229,6 @@ AcpiGetFirmwareTable ( /* * Namespace and name interfaces */ - ACPI_STATUS AcpiWalkNamespace ( ACPI_OBJECT_TYPE Type, @@ -282,7 +278,6 @@ AcpiGetData ( /* * Object manipulation and enumeration */ - ACPI_STATUS AcpiEvaluateObject ( ACPI_HANDLE Object, @@ -324,7 +319,6 @@ AcpiGetParent ( /* * Event handler interfaces */ - ACPI_STATUS AcpiInstallFixedEventHandler ( UINT32 AcpiEvent, @@ -368,10 +362,18 @@ AcpiInstallGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT32 Type, - ACPI_GPE_HANDLER Handler, + ACPI_EVENT_HANDLER Address, void *Context); ACPI_STATUS +AcpiInstallExceptionHandler ( + ACPI_EXCEPTION_HANDLER Handler); + + +/* + * Event interfaces + */ +ACPI_STATUS AcpiAcquireGlobalLock ( UINT16 Timeout, UINT32 *Handle); @@ -384,7 +386,7 @@ ACPI_STATUS AcpiRemoveGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - ACPI_GPE_HANDLER Handler); + ACPI_EVENT_HANDLER Address); ACPI_STATUS AcpiEnableEvent ( @@ -406,6 +408,12 @@ AcpiGetEventStatus ( ACPI_EVENT_STATUS *EventStatus); ACPI_STATUS +AcpiSetGpeType ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT8 Type); + +ACPI_STATUS AcpiEnableGpe ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, @@ -445,7 +453,6 @@ AcpiRemoveGpeBlock ( /* * Resource interfaces */ - typedef ACPI_STATUS (*ACPI_WALK_RESOURCE_CALLBACK) ( ACPI_RESOURCE *Resource, @@ -487,7 +494,6 @@ AcpiResourceToAddress64 ( /* * Hardware (ACPI device) interfaces */ - ACPI_STATUS AcpiGetRegister ( UINT32 RegisterId, diff --git a/sys/dev/acpi/acpica/Subsystem/acresrc.h b/sys/dev/acpi/acpica/Subsystem/acresrc.h index d96d38bda2a..9936cf6645f 100644 --- a/sys/dev/acpi/acpica/Subsystem/acresrc.h +++ b/sys/dev/acpi/acpica/Subsystem/acresrc.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acresrc.h - Resource Manager function prototypes - * xRevision: 38 $ + * xRevision: 42 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -122,7 +122,6 @@ /* * Function prototypes called from Acpi* APIs */ - ACPI_STATUS AcpiRsGetPrtMethodData ( ACPI_HANDLE Handle, @@ -167,61 +166,9 @@ AcpiRsCreatePciRoutingTable ( /* - * Function prototypes called from AcpiRsCreate* + * rsdump */ void -AcpiRsDumpIrq ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpAddress16 ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpAddress32 ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpAddress64 ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpDma ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpIo ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpExtendedIrq ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpFixedIo ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpFixedMemory32 ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpMemory24 ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpMemory32 ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpStartDependFns ( - ACPI_RESOURCE_DATA *Data); - -void -AcpiRsDumpVendorSpecific ( - ACPI_RESOURCE_DATA *Data); - -void AcpiRsDumpResourceList ( ACPI_RESOURCE *Resource); @@ -229,6 +176,10 @@ void AcpiRsDumpIrqList ( UINT8 *RouteTable); + +/* + * rscalc + */ ACPI_STATUS AcpiRsGetByteStreamStart ( UINT8 *ByteStreamBuffer, diff --git a/sys/dev/acpi/acpica/Subsystem/acstruct.h b/sys/dev/acpi/acpica/Subsystem/acstruct.h index 2a6dc57ed67..ede6bef51b9 100644 --- a/sys/dev/acpi/acpica/Subsystem/acstruct.h +++ b/sys/dev/acpi/acpica/Subsystem/acstruct.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acstruct.h - Internal structs - * xRevision: 27 $ + * xRevision: 31 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -129,7 +129,6 @@ * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through * the tree (for whatever reason), and for control method execution. */ - #define ACPI_NEXT_OP_DOWNWARD 1 #define ACPI_NEXT_OP_UPWARD 2 @@ -142,13 +141,14 @@ typedef struct acpi_walk_state { UINT8 DataType; /* To differentiate various internal objs MUST BE FIRST!*/\ + UINT8 WalkType; ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ BOOLEAN LastPredicate; /* Result of last predicate */ + UINT8 Reserved; /* For alignment */ UINT8 CurrentResult; /* */ UINT8 NextOpInfo; /* Info about NextOp */ UINT8 NumOperands; /* Stack pointer for Operands[] array */ UINT8 ReturnUsed; - UINT8 WalkType; UINT16 Opcode; /* Current AML opcode */ UINT8 ScopeDepth; UINT8 Reserved1; @@ -164,7 +164,9 @@ typedef struct acpi_walk_state struct acpi_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ union acpi_operand_object **CallerReturnDesc; ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ - struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ + struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ + struct acpi_gpe_event_info *GpeEventInfo; /* Info for GPE (_Lxx/_Exx methods only */ + union acpi_operand_object *ImplicitReturnObj; struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ struct acpi_namespace_node *MethodCallNode; /* Called method Node*/ ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ @@ -279,4 +281,22 @@ typedef union acpi_aml_operands } ACPI_AML_OPERANDS; +/* Internal method parameter list */ + +typedef struct acpi_parameter_info +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT **Parameters; + ACPI_OPERAND_OBJECT *ReturnObject; + UINT8 ParameterType; + UINT8 ReturnObjectType; + +} ACPI_PARAMETER_INFO; + +/* Types for ParameterType above */ + +#define ACPI_PARAM_ARGS 0 +#define ACPI_PARAM_GPE 1 + + #endif diff --git a/sys/dev/acpi/acpica/Subsystem/actables.h b/sys/dev/acpi/acpica/Subsystem/actables.h index bb5825c5b0e..cb6d28753ea 100644 --- a/sys/dev/acpi/acpica/Subsystem/actables.h +++ b/sys/dev/acpi/acpica/Subsystem/actables.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actables.h - ACPI table management - * xRevision: 46 $ + * xRevision: 50 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,15 +123,9 @@ #define SIZE_IN_HEADER 0 -ACPI_STATUS -AcpiTbHandleToObject ( - UINT16 TableId, - ACPI_TABLE_DESC **TableDesc); - /* * tbconvrt - Table conversion routines */ - ACPI_STATUS AcpiTbConvertToXsdt ( ACPI_TABLE_DESC *TableInfo); @@ -149,10 +143,10 @@ AcpiTbGetTableCount ( RSDP_DESCRIPTOR *RSDP, ACPI_TABLE_HEADER *RSDT); + /* * tbget - Table "get" routines */ - ACPI_STATUS AcpiTbGetTable ( ACPI_POINTER *Address, @@ -170,17 +164,6 @@ AcpiTbGetTableBody ( ACPI_TABLE_DESC *TableInfo); ACPI_STATUS -AcpiTbGetThisTable ( - ACPI_POINTER *Address, - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo); - -ACPI_STATUS -AcpiTbTableOverride ( - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo); - -ACPI_STATUS AcpiTbGetTablePtr ( ACPI_TABLE_TYPE TableType, UINT32 Instance, @@ -198,36 +181,23 @@ ACPI_STATUS AcpiTbValidateRsdt ( ACPI_TABLE_HEADER *TablePtr); + +/* + * tbgetall - get multiple required tables + */ ACPI_STATUS AcpiTbGetRequiredTables ( void); -ACPI_STATUS -AcpiTbGetPrimaryTable ( - ACPI_POINTER *Address, - ACPI_TABLE_DESC *TableInfo); - -ACPI_STATUS -AcpiTbGetSecondaryTable ( - ACPI_POINTER *Address, - ACPI_STRING Signature, - ACPI_TABLE_DESC *TableInfo); /* * tbinstall - Table installation */ - ACPI_STATUS AcpiTbInstallTable ( ACPI_TABLE_DESC *TableInfo); ACPI_STATUS -AcpiTbMatchSignature ( - char *Signature, - ACPI_TABLE_DESC *TableInfo, - UINT8 SearchType); - -ACPI_STATUS AcpiTbRecognizeTable ( ACPI_TABLE_DESC *TableInfo, UINT8 SearchType); @@ -241,7 +211,6 @@ AcpiTbInitTableDescriptor ( /* * tbremove - Table removal and deletion */ - void AcpiTbDeleteAllTables ( void); @@ -260,35 +229,23 @@ AcpiTbUninstallTable ( /* - * tbrsd - RSDP, RSDT utilities + * tbxfroot - RSDP, RSDT utilities */ +ACPI_STATUS +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + ACPI_TABLE_HEADER **TablePtr); ACPI_STATUS AcpiTbGetTableRsdt ( void); -UINT8 * -AcpiTbScanMemoryForRsdp ( - UINT8 *StartAddress, - UINT32 Length); - -ACPI_STATUS -AcpiTbFindRsdp ( - ACPI_TABLE_DESC *TableInfo, - UINT32 Flags); - /* * tbutils - common table utilities */ - -ACPI_STATUS -AcpiTbFindTable ( - char *Signature, - char *OemId, - char *OemTableId, - ACPI_TABLE_HEADER **TablePtr); - ACPI_STATUS AcpiTbVerifyTableChecksum ( ACPI_TABLE_HEADER *TableHeader); @@ -302,5 +259,4 @@ ACPI_STATUS AcpiTbValidateTableHeader ( ACPI_TABLE_HEADER *TableHeader); - #endif /* __ACTABLES_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/actbl.h b/sys/dev/acpi/acpica/Subsystem/actbl.h index 0062efcc6fd..18a240ad71c 100644 --- a/sys/dev/acpi/acpica/Subsystem/actbl.h +++ b/sys/dev/acpi/acpica/Subsystem/actbl.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actbl.h - Table data structures defined in ACPI specification - * xRevision: 64 $ + * xRevision: 69 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -209,7 +209,6 @@ typedef struct acpi_table_header /* ACPI common table header */ #define DUAL_PIC 0 #define MULTIPLE_APIC 1 - /* Master MADT */ typedef struct multiple_apic_table @@ -221,7 +220,6 @@ typedef struct multiple_apic_table } MULTIPLE_APIC_TABLE; - /* Values for Type in APIC_HEADER_DEF */ #define APIC_PROCESSOR 0 @@ -345,6 +343,8 @@ typedef struct madt_local_sapic UINT8 LocalSapicEid; /* SAPIC EID */ UINT8 Reserved [3]; /* Reserved - must be zero */ LOCAL_APIC_FLAGS + UINT32 ProcessorUID; /* Numeric UID - ACPI 3.0 */ + char ProcessorUIDString[1]; /* String UID - ACPI 3.0 */ } MADT_LOCAL_SAPIC; @@ -357,7 +357,7 @@ typedef struct madt_interrupt_source UINT8 ProcessorEid; /* Processor EID */ UINT8 IoSapicVector; /* Vector value for PMI interrupts */ UINT32 Interrupt; /* Global system interrupt */ - UINT32 Reserved; /* Reserved - must be zero */ + UINT32 Flags; /* Interrupt Source Flags */ } MADT_INTERRUPT_SOURCE; @@ -375,20 +375,6 @@ typedef struct smart_battery_table } SMART_BATTERY_TABLE; -/* - * High performance timer - */ -typedef struct hpet_table -{ - ACPI_TABLE_HEADER_DEF - UINT32 HardwareId; - UINT32 BaseAddress [3]; - UINT8 HpetNumber; - UINT16 ClockTick; - UINT8 Attributes; - -} HPET_TABLE; - #pragma pack() @@ -433,4 +419,21 @@ typedef struct acpi_table_support #include "actbl2.h" /* Acpi 2.0 table definitions */ +#pragma pack(1) +/* + * High performance timer + */ +typedef struct hpet_table +{ + ACPI_TABLE_HEADER_DEF + UINT32 HardwareId; + ACPI_GENERIC_ADDRESS BaseAddress; + UINT8 HpetNumber; + UINT16 ClockTick; + UINT8 Attributes; + +} HPET_TABLE; + +#pragma pack() + #endif /* __ACTBL_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/actbl1.h b/sys/dev/acpi/acpica/Subsystem/actbl1.h index 3053d732394..e3049423129 100644 --- a/sys/dev/acpi/acpica/Subsystem/actbl1.h +++ b/sys/dev/acpi/acpica/Subsystem/actbl1.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actbl1.h - ACPI 1.0 tables - * xRevision: 28 $ + * xRevision: 29 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/dev/acpi/acpica/Subsystem/actbl2.h b/sys/dev/acpi/acpica/Subsystem/actbl2.h index f6319ab365a..7abcb475a62 100644 --- a/sys/dev/acpi/acpica/Subsystem/actbl2.h +++ b/sys/dev/acpi/acpica/Subsystem/actbl2.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actbl2.h - ACPI Specification Revision 2.0 Tables - * xRevision: 35 $ + * xRevision: 41 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -135,6 +135,7 @@ #define BAF_8042_KEYBOARD_CONTROLLER 0x0002 #define FADT2_REVISION_ID 3 +#define FADT2_MINUS_REVISION_ID 2 #pragma pack(1) @@ -171,7 +172,7 @@ typedef struct facs_descriptor_rev2 UINT32 HardwareSignature; /* Hardware configuration signature */ UINT32 FirmwareWakingVector; /* 32bit physical address of the Firmware Waking Vector. */ UINT32 GlobalLock; /* Global Lock used to synchronize access to shared hardware resources */ - UINT32 S4Bios_f : 1; /* S4Bios_f - Indicates if S4BIOS support is present */ + UINT32_BIT S4Bios_f : 1; /* S4Bios_f - Indicates if S4BIOS support is present */ UINT32_BIT Reserved1 : 31; /* Must be 0 */ UINT64 XFirmwareWakingVector; /* 64bit physical address of the Firmware Waking Vector. */ UINT8 Version; /* Version of this table */ @@ -181,61 +182,64 @@ typedef struct facs_descriptor_rev2 /* - * ACPI 2.0 Generic Address Structure (GAS) + * ACPI 2.0+ Generic Address Structure (GAS) */ typedef struct acpi_generic_address { UINT8 AddressSpaceId; /* Address space where struct or register exists. */ UINT8 RegisterBitWidth; /* Size in bits of given register */ UINT8 RegisterBitOffset; /* Bit offset within the register */ - UINT8 Reserved; /* Must be 0 */ + UINT8 AccessWidth; /* Minimum Access size (ACPI 3.0) */ UINT64 Address; /* 64-bit address of struct or register */ } ACPI_GENERIC_ADDRESS; +#define FADT_REV2_COMMON \ + UINT32 V1_FirmwareCtrl; /* 32-bit physical address of FACS */ \ + UINT32 V1_Dsdt; /* 32-bit physical address of DSDT */ \ + UINT8 Reserved1; /* System Interrupt Model isn't used in ACPI 2.0*/ \ + UINT8 Prefer_PM_Profile; /* Conveys preferred power management profile to OSPM. */ \ + UINT16 SciInt; /* System vector of SCI interrupt */ \ + UINT32 SmiCmd; /* Port address of SMI command port */ \ + UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */ \ + UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */ \ + UINT8 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */ \ + UINT8 PstateCnt; /* Processor performance state control*/ \ + UINT32 V1_Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */ \ + UINT32 V1_Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */ \ + UINT32 V1_Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */ \ + UINT32 V1_Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */ \ + UINT32 V1_Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */ \ + UINT32 V1_PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ \ + UINT32 V1_Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */ \ + UINT32 V1_Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */ \ + UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */ \ + UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */ \ + UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */ \ + UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */ \ + UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */ \ + UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */ \ + UINT8 Gpe1Base; /* Offset in gpe model where gpe1 events start */ \ + UINT8 CstCnt; /* Support for the _CST object and C States change notification.*/ \ + UINT16 Plvl2Lat; /* Worst case HW latency to enter/exit C2 state */ \ + UINT16 Plvl3Lat; /* Worst case HW latency to enter/exit C3 state */ \ + UINT16 FlushSize; /* Number of flush strides that need to be read */ \ + UINT16 FlushStride; /* Processor's memory cache line width, in bytes */ \ + UINT8 DutyOffset; /* Processor's duty cycle index in processor's P_CNT reg*/ \ + UINT8 DutyWidth; /* Processor's duty cycle value bit width in P_CNT register.*/ \ + UINT8 DayAlrm; /* Index to day-of-month alarm in RTC CMOS RAM */ \ + UINT8 MonAlrm; /* Index to month-of-year alarm in RTC CMOS RAM */ \ + UINT8 Century; /* Index to century in RTC CMOS RAM */ \ + UINT16 IapcBootArch; /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/ + /* - * ACPI 2.0 Fixed ACPI Description Table (FADT) + * ACPI 2.0+ Fixed ACPI Description Table (FADT) */ typedef struct fadt_descriptor_rev2 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT32 V1_FirmwareCtrl; /* 32-bit physical address of FACS */ - UINT32 V1_Dsdt; /* 32-bit physical address of DSDT */ - UINT8 Reserved1; /* System Interrupt Model isn't used in ACPI 2.0*/ - UINT8 Prefer_PM_Profile; /* Conveys preferred power management profile to OSPM. */ - UINT16 SciInt; /* System vector of SCI interrupt */ - UINT32 SmiCmd; /* Port address of SMI command port */ - UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */ - UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */ - UINT8 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */ - UINT8 PstateCnt; /* Processor performance state control*/ - UINT32 V1_Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */ - UINT32 V1_Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */ - UINT32 V1_Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */ - UINT32 V1_Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */ - UINT32 V1_Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */ - UINT32 V1_PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ - UINT32 V1_Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */ - UINT32 V1_Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */ - UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */ - UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */ - UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */ - UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */ - UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */ - UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */ - UINT8 Gpe1Base; /* Offset in gpe model where gpe1 events start */ - UINT8 CstCnt; /* Support for the _CST object and C States change notification.*/ - UINT16 Plvl2Lat; /* Worst case HW latency to enter/exit C2 state */ - UINT16 Plvl3Lat; /* Worst case HW latency to enter/exit C3 state */ - UINT16 FlushSize; /* Number of flush strides that need to be read */ - UINT16 FlushStride; /* Processor's memory cache line width, in bytes */ - UINT8 DutyOffset; /* Processor's duty cycle index in processor's P_CNT reg*/ - UINT8 DutyWidth; /* Processor's duty cycle value bit width in P_CNT register.*/ - UINT8 DayAlrm; /* Index to day-of-month alarm in RTC CMOS RAM */ - UINT8 MonAlrm; /* Index to month-of-year alarm in RTC CMOS RAM */ - UINT8 Century; /* Index to century in RTC CMOS RAM */ - UINT16 IapcBootArch; /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/ + FADT_REV2_COMMON UINT8 Reserved2; /* Reserved */ UINT32_BIT WbInvd : 1; /* The wbinvd instruction works properly */ UINT32_BIT WbInvdFlush : 1; /* The wbinvd flushes but does not invalidate */ @@ -245,17 +249,25 @@ typedef struct fadt_descriptor_rev2 UINT32_BIT SleepButton : 1; /* Sleep button is handled as a generic feature, or not present */ UINT32_BIT FixedRTC : 1; /* RTC wakeup stat not in fixed register space */ UINT32_BIT Rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ - UINT32_BIT TmrValExt : 1; /* Indicates tmr_val is 32 bits 0=24-bits*/ + UINT32_BIT TmrValExt : 1; /* Indicates tmr_val is 32 bits 0=24-bits */ UINT32_BIT DockCap : 1; /* Supports Docking */ - UINT32_BIT ResetRegSup : 1; /* Indicates system supports system reset via the FADT RESET_REG*/ - UINT32_BIT SealedCase : 1; /* Indicates system has no internal expansion capabilities and case is sealed. */ - UINT32_BIT Headless : 1; /* Indicates system does not have local video capabilities or local input devices.*/ + UINT32_BIT ResetRegSup : 1; /* Indicates system supports system reset via the FADT RESET_REG */ + UINT32_BIT SealedCase : 1; /* Indicates system has no internal expansion capabilities and case is sealed */ + UINT32_BIT Headless : 1; /* Indicates system does not have local video capabilities or local input devices */ UINT32_BIT CpuSwSleep : 1; /* Indicates to OSPM that a processor native instruction */ - /* Must be executed after writing the SLP_TYPx register. */ - UINT32_BIT Reserved6 : 18; /* Reserved - must be zero */ + /* must be executed after writing the SLP_TYPx register */ + /* ACPI 3.0 flag bits */ + + UINT32_BIT PciExpWak : 1; /* System supports PCIEXP_WAKE (STS/EN) bits */ + UINT32_BIT UsePlatformClock : 1; /* OSPM should use platform-provided timer */ + UINT32_BIT S4RtcStsValid : 1; /* Contents of RTC_STS valid after S4 wake */ + UINT32_BIT RemotePowerOnCapable : 1; /* System is compatible with remote power on */ + UINT32_BIT ForceApicClusterModel : 1; /* All local APICs must use cluster model */ + UINT32_BIT ForceApicPhysicalDestinationMode : 1; /* All local xAPICs must use physical dest mode */ + UINT32_BIT Reserved6 : 12;/* Reserved - must be zero */ ACPI_GENERIC_ADDRESS ResetRegister; /* Reset register address in GAS format */ - UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system. */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ UINT8 Reserved7[3]; /* These three bytes must be zero */ UINT64 XFirmwareCtrl; /* 64-bit physical address of FACS */ UINT64 XDsdt; /* 64-bit physical address of DSDT */ @@ -271,7 +283,22 @@ typedef struct fadt_descriptor_rev2 } FADT_DESCRIPTOR_REV2; -/* Embedded Controller */ +/* "Down-revved" ACPI 2.0 FADT descriptor */ + +typedef struct fadt_descriptor_rev2_minus +{ + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + FADT_REV2_COMMON + UINT8 Reserved2; /* Reserved */ + UINT32 Flags; + ACPI_GENERIC_ADDRESS ResetRegister; /* Reset register address in GAS format */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system. */ + UINT8 Reserved7[3]; /* These three bytes must be zero */ + +} FADT_DESCRIPTOR_REV2_MINUS; + + +/* ECDT - Embedded Controller Boot Resources Table */ typedef struct ec_boot_resources { @@ -285,6 +312,59 @@ typedef struct ec_boot_resources } EC_BOOT_RESOURCES; +/* SRAT - System Resource Affinity Table */ + +typedef struct static_resource_alloc +{ + UINT8 Type; + UINT8 Length; + UINT8 ProximityDomainLo; + UINT8 ApicId; + UINT32_BIT Enabled :1; + UINT32_BIT Reserved3 :31; + UINT8 LocalSapicEid; + UINT8 ProximityDomainHi[3]; + UINT32 Reserved4; + +} STATIC_RESOURCE_ALLOC; + +typedef struct memory_affinity +{ + UINT8 Type; + UINT8 Length; + UINT32 ProximityDomain; + UINT16 Reserved3; + UINT64 BaseAddress; + UINT64 AddressLength; + UINT32 Reserved4; + UINT32_BIT Enabled :1; + UINT32_BIT HotPluggable :1; + UINT32_BIT NonVolatile :1; + UINT32_BIT Reserved5 :29; + UINT64 Reserved6; + +} MEMORY_AFFINITY; + +typedef struct system_resource_affinity +{ + ACPI_TABLE_HEADER_DEF + UINT32 Reserved1; /* Must be value '1' */ + UINT64 Reserved2; + +} SYSTEM_RESOURCE_AFFINITY; + + +/* SLIT - System Locality Distance Information Table */ + +typedef struct system_locality_info +{ + ACPI_TABLE_HEADER_DEF + UINT64 LocalityCount; + UINT8 Entry[1][1]; + +} SYSTEM_LOCALITY_INFO; + + #pragma pack() #endif /* __ACTBL2_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/actypes.h b/sys/dev/acpi/acpica/Subsystem/actypes.h index 7e492a66282..44719dc2c5d 100644 --- a/sys/dev/acpi/acpica/Subsystem/actypes.h +++ b/sys/dev/acpi/acpica/Subsystem/actypes.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem - * xRevision: 263 $ + * xRevision: 278 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -382,7 +382,7 @@ typedef struct uint32_struct typedef UINT32 ACPI_INTEGER; #define ACPI_INTEGER_MAX ACPI_UINT32_MAX #define ACPI_INTEGER_BIT_SIZE 32 -#define ACPI_MAX_DECIMAL_DIGITS 10 +#define ACPI_MAX_DECIMAL_DIGITS 10 /* 2^32 = 4,294,967,296 */ #define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */ @@ -394,13 +394,18 @@ typedef UINT32 ACPI_INTEGER; typedef UINT64 ACPI_INTEGER; #define ACPI_INTEGER_MAX ACPI_UINT64_MAX #define ACPI_INTEGER_BIT_SIZE 64 -#define ACPI_MAX_DECIMAL_DIGITS 19 +#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ + #if ACPI_MACHINE_WIDTH == 64 #define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ #endif #endif +#define ACPI_MAX64_DECIMAL_DIGITS 20 +#define ACPI_MAX32_DECIMAL_DIGITS 10 +#define ACPI_MAX16_DECIMAL_DIGITS 5 +#define ACPI_MAX8_DECIMAL_DIGITS 3 /* * Constants with special meanings @@ -428,7 +433,6 @@ typedef UINT64 ACPI_INTEGER; /* * Power state values */ - #define ACPI_STATE_UNKNOWN (UINT8) 0xFF #define ACPI_STATE_S0 (UINT8) 0 @@ -472,7 +476,6 @@ typedef UINT64 ACPI_INTEGER; #define ACPI_NOTIFY_BUS_MODE_MISMATCH (UINT8) 6 #define ACPI_NOTIFY_POWER_FAULT (UINT8) 7 - /* * Table types. These values are passed to the table related APIs */ @@ -488,14 +491,13 @@ typedef UINT32 ACPI_TABLE_TYPE; #define ACPI_TABLE_MAX 6 #define NUM_ACPI_TABLE_TYPES (ACPI_TABLE_MAX+1) - /* * Types associated with ACPI names and objects. The first group of * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore, * only add to the first group if the spec changes. * - * Types must be kept in sync with the global AcpiNsProperties + * NOTE: Types must be kept in sync with the global AcpiNsProperties * and AcpiNsTypeNames arrays. */ typedef UINT32 ACPI_OBJECT_TYPE; @@ -532,29 +534,29 @@ typedef UINT32 ACPI_OBJECT_TYPE; #define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13 #define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, RefOf, Index */ #define ACPI_TYPE_LOCAL_ALIAS 0x15 -#define ACPI_TYPE_LOCAL_NOTIFY 0x16 -#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x17 -#define ACPI_TYPE_LOCAL_RESOURCE 0x18 -#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x19 -#define ACPI_TYPE_LOCAL_SCOPE 0x1A /* 1 Name, multiple ObjectList Nodes */ +#define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16 +#define ACPI_TYPE_LOCAL_NOTIFY 0x17 +#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18 +#define ACPI_TYPE_LOCAL_RESOURCE 0x19 +#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A +#define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple ObjectList Nodes */ -#define ACPI_TYPE_NS_NODE_MAX 0x1A /* Last typecode used within a NS Node */ +#define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */ /* * These are special object types that never appear in * a Namespace node, only in an ACPI_OPERAND_OBJECT */ -#define ACPI_TYPE_LOCAL_EXTRA 0x1B -#define ACPI_TYPE_LOCAL_DATA 0x1C +#define ACPI_TYPE_LOCAL_EXTRA 0x1C +#define ACPI_TYPE_LOCAL_DATA 0x1D -#define ACPI_TYPE_LOCAL_MAX 0x1C +#define ACPI_TYPE_LOCAL_MAX 0x1D /* All types above here are invalid */ -#define ACPI_TYPE_INVALID 0x1D +#define ACPI_TYPE_INVALID 0x1E #define ACPI_TYPE_NOT_FOUND 0xFF - /* * Bitmapped ACPI types. Used internally only */ @@ -593,9 +595,8 @@ typedef UINT32 ACPI_OBJECT_TYPE; #define ACPI_WRITE 1 #define ACPI_IO_MASK 1 - /* - * Acpi Event Types: Fixed & General Purpose + * Event Types: Fixed & General Purpose */ typedef UINT32 ACPI_EVENT_TYPE; @@ -610,25 +611,8 @@ typedef UINT32 ACPI_EVENT_TYPE; #define ACPI_EVENT_MAX 4 #define ACPI_NUM_FIXED_EVENTS ACPI_EVENT_MAX + 1 -#define ACPI_GPE_INVALID 0xFF -#define ACPI_GPE_MAX 0xFF -#define ACPI_NUM_GPE 256 - -#define ACPI_EVENT_LEVEL_TRIGGERED 1 -#define ACPI_EVENT_EDGE_TRIGGERED 2 - /* - * Flags for GPE and Lock interfaces - */ -#define ACPI_EVENT_WAKE_ENABLE 0x2 -#define ACPI_EVENT_WAKE_DISABLE 0x2 - -#define ACPI_NOT_ISR 0x1 -#define ACPI_ISR 0x0 - - -/* - * AcpiEvent Status: + * Event Status - Per event * ------------- * The encoding of ACPI_EVENT_STATUS is illustrated below. * Note that a set bit (1) indicates the property is TRUE @@ -649,12 +633,74 @@ typedef UINT32 ACPI_EVENT_STATUS; #define ACPI_EVENT_FLAG_WAKE_ENABLED (ACPI_EVENT_STATUS) 0x02 #define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x04 +/* + * General Purpose Events (GPE) + */ +#define ACPI_GPE_INVALID 0xFF +#define ACPI_GPE_MAX 0xFF +#define ACPI_NUM_GPE 256 + +#define ACPI_GPE_ENABLE 0 +#define ACPI_GPE_DISABLE 1 + + +/* + * GPE info flags - Per GPE + * +-+-+-+---+---+-+ + * |7|6|5|4:3|2:1|0| + * +-+-+-+---+---+-+ + * | | | | | | + * | | | | | +--- Interrupt type: Edge or Level Triggered + * | | | | +--- Type: Wake-only, Runtime-only, or wake/runtime + * | | | +--- Type of dispatch -- to method, handler, or none + * | | +--- Enabled for runtime? + * | +--- Enabled for wake? + * +--- System state when GPE ocurred (running/waking) + */ +#define ACPI_GPE_XRUPT_TYPE_MASK (UINT8) 0x01 +#define ACPI_GPE_LEVEL_TRIGGERED (UINT8) 0x01 +#define ACPI_GPE_EDGE_TRIGGERED (UINT8) 0x00 + +#define ACPI_GPE_TYPE_MASK (UINT8) 0x06 +#define ACPI_GPE_TYPE_WAKE_RUN (UINT8) 0x06 +#define ACPI_GPE_TYPE_WAKE (UINT8) 0x02 +#define ACPI_GPE_TYPE_RUNTIME (UINT8) 0x04 /* Default */ + +#define ACPI_GPE_DISPATCH_MASK (UINT8) 0x18 +#define ACPI_GPE_DISPATCH_HANDLER (UINT8) 0x08 +#define ACPI_GPE_DISPATCH_METHOD (UINT8) 0x10 +#define ACPI_GPE_DISPATCH_NOT_USED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_RUN_ENABLE_MASK (UINT8) 0x20 +#define ACPI_GPE_RUN_ENABLED (UINT8) 0x20 +#define ACPI_GPE_RUN_DISABLED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_WAKE_ENABLE_MASK (UINT8) 0x40 +#define ACPI_GPE_WAKE_ENABLED (UINT8) 0x40 +#define ACPI_GPE_WAKE_DISABLED (UINT8) 0x00 /* Default */ + +#define ACPI_GPE_ENABLE_MASK (UINT8) 0x60 /* Both run/wake */ + +#define ACPI_GPE_SYSTEM_MASK (UINT8) 0x80 +#define ACPI_GPE_SYSTEM_RUNNING (UINT8) 0x80 +#define ACPI_GPE_SYSTEM_WAKING (UINT8) 0x00 + +/* + * Flags for GPE and Lock interfaces + */ +#define ACPI_EVENT_WAKE_ENABLE 0x2 /* AcpiGpeEnable */ +#define ACPI_EVENT_WAKE_DISABLE 0x2 /* AcpiGpeDisable */ + +#define ACPI_NOT_ISR 0x1 +#define ACPI_ISR 0x0 + /* Notify types */ -#define ACPI_SYSTEM_NOTIFY 0 -#define ACPI_DEVICE_NOTIFY 1 -#define ACPI_MAX_NOTIFY_HANDLER_TYPE 1 +#define ACPI_SYSTEM_NOTIFY 0x1 +#define ACPI_DEVICE_NOTIFY 0x2 +#define ACPI_ALL_NOTIFY 0x3 +#define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3 #define ACPI_MAX_SYS_NOTIFY 0x7f @@ -685,24 +731,26 @@ typedef UINT8 ACPI_ADR_SPACE_TYPE; #define ACPI_BITREG_SLEEP_BUTTON_STATUS 0x04 #define ACPI_BITREG_RT_CLOCK_STATUS 0x05 #define ACPI_BITREG_WAKE_STATUS 0x06 - -#define ACPI_BITREG_TIMER_ENABLE 0x07 -#define ACPI_BITREG_GLOBAL_LOCK_ENABLE 0x08 -#define ACPI_BITREG_POWER_BUTTON_ENABLE 0x09 -#define ACPI_BITREG_SLEEP_BUTTON_ENABLE 0x0A -#define ACPI_BITREG_RT_CLOCK_ENABLE 0x0B -#define ACPI_BITREG_WAKE_ENABLE 0x0C - -#define ACPI_BITREG_SCI_ENABLE 0x0D -#define ACPI_BITREG_BUS_MASTER_RLD 0x0E -#define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x0F -#define ACPI_BITREG_SLEEP_TYPE_A 0x10 -#define ACPI_BITREG_SLEEP_TYPE_B 0x11 -#define ACPI_BITREG_SLEEP_ENABLE 0x12 - -#define ACPI_BITREG_ARB_DISABLE 0x13 - -#define ACPI_BITREG_MAX 0x13 +#define ACPI_BITREG_PCIEXP_WAKE_STATUS 0x07 + +#define ACPI_BITREG_TIMER_ENABLE 0x08 +#define ACPI_BITREG_GLOBAL_LOCK_ENABLE 0x09 +#define ACPI_BITREG_POWER_BUTTON_ENABLE 0x0A +#define ACPI_BITREG_SLEEP_BUTTON_ENABLE 0x0B +#define ACPI_BITREG_RT_CLOCK_ENABLE 0x0C +#define ACPI_BITREG_WAKE_ENABLE 0x0D +#define ACPI_BITREG_PCIEXP_WAKE_DISABLE 0x0E + +#define ACPI_BITREG_SCI_ENABLE 0x0F +#define ACPI_BITREG_BUS_MASTER_RLD 0x10 +#define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x11 +#define ACPI_BITREG_SLEEP_TYPE_A 0x12 +#define ACPI_BITREG_SLEEP_TYPE_B 0x13 +#define ACPI_BITREG_SLEEP_ENABLE 0x14 + +#define ACPI_BITREG_ARB_DISABLE 0x15 + +#define ACPI_BITREG_MAX 0x15 #define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 @@ -838,13 +886,12 @@ typedef struct acpi_system_info /* * Types specific to the OS service interfaces */ - typedef UINT32 -(ACPI_SYSTEM_XFACE *OSD_HANDLER) ( +(ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) ( void *Context); typedef void -(ACPI_SYSTEM_XFACE *OSD_EXECUTION_CALLBACK) ( +(ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) ( void *Context); /* @@ -855,10 +902,6 @@ UINT32 (*ACPI_EVENT_HANDLER) ( void *Context); typedef -void (*ACPI_GPE_HANDLER) ( - void *Context); - -typedef void (*ACPI_NOTIFY_HANDLER) ( ACPI_HANDLE Device, UINT32 Value, @@ -877,8 +920,16 @@ ACPI_STATUS (*ACPI_INIT_HANDLER) ( #define ACPI_INIT_DEVICE_INI 1 +typedef +ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) ( + ACPI_STATUS AmlStatus, + ACPI_NAME Name, + UINT16 Opcode, + UINT32 AmlOffset, + void *Context); + -/* Address Spaces (Operation Regions */ +/* Address Spaces (For Operation Regions) */ typedef ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) ( @@ -948,6 +999,7 @@ typedef struct acpi_compatible_id_list #define ACPI_VALID_HID 0x0004 #define ACPI_VALID_UID 0x0008 #define ACPI_VALID_CID 0x0010 +#define ACPI_VALID_SXDS 0x0020 #define ACPI_COMMON_OBJ_INFO \ @@ -968,11 +1020,12 @@ typedef struct acpi_device_info { ACPI_COMMON_OBJ_INFO; - UINT32 Valid; /* Indicates which fields are valid */ + UINT32 Valid; /* Indicates which fields below are valid */ UINT32 CurrentStatus; /* _STA value */ ACPI_INTEGER Address; /* _ADR value if any */ ACPI_DEVICE_ID HardwareId; /* _HID value if any */ ACPI_DEVICE_ID UniqueId; /* _UID value if any */ + UINT8 HighestDstates[4]; /* _SxD values: 0xFF indicates not valid */ ACPI_COMPATIBLE_ID_LIST CompatibilityId; /* List of _CIDs if any */ } ACPI_DEVICE_INFO; @@ -1261,6 +1314,7 @@ typedef struct acpi_resource_address64 UINT64 MaxAddressRange; UINT64 AddressTranslationOffset; UINT64 AddressLength; + UINT64 TypeSpecificAttributes; ACPI_RESOURCE_SOURCE ResourceSource; } ACPI_RESOURCE_ADDRESS64; diff --git a/sys/dev/acpi/acpica/Subsystem/acutils.h b/sys/dev/acpi/acpica/Subsystem/acutils.h index 404f0c10bb0..2403bb3c8bf 100644 --- a/sys/dev/acpi/acpica/Subsystem/acutils.h +++ b/sys/dev/acpi/acpica/Subsystem/acutils.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures - * xRevision: 158 $ + * xRevision: 172 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,15 +125,6 @@ ACPI_STATUS (*ACPI_PKG_CALLBACK) ( ACPI_GENERIC_STATE *State, void *Context); - -ACPI_STATUS -AcpiUtWalkPackageTree ( - ACPI_OPERAND_OBJECT *SourceObject, - void *TargetObject, - ACPI_PKG_CALLBACK WalkCallback, - void *Context); - - typedef struct acpi_pkg_info { UINT8 *FreeSpace; @@ -155,37 +146,13 @@ typedef struct acpi_pkg_info #define DB_QWORD_DISPLAY 8 -/* Global initialization interfaces */ - -void -AcpiUtInitGlobals ( - void); - -void -AcpiUtTerminate ( - void); - - /* - * UtInit - miscellaneous initialization and shutdown + * utglobal - Global data structures and procedures */ - -ACPI_STATUS -AcpiUtHardwareInitialize ( - void); - void -AcpiUtSubsystemShutdown ( - void); - -ACPI_STATUS -AcpiUtValidateFadt ( +AcpiUtInitGlobals ( void); -/* - * UtGlobal - Global data structures and procedures - */ - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) char * @@ -233,9 +200,24 @@ AcpiUtAllocateOwnerId ( /* - * UtClib - Local implementations of C library functions + * utinit - miscellaneous initialization and shutdown */ +ACPI_STATUS +AcpiUtHardwareInitialize ( + void); + +void +AcpiUtSubsystemShutdown ( + void); + +ACPI_STATUS +AcpiUtValidateFadt ( + void); + +/* + * utclib - Local implementations of C library functions + */ #ifndef ACPI_USE_SYSTEM_CLIBRARY ACPI_SIZE @@ -254,6 +236,12 @@ AcpiUtStrncpy ( ACPI_SIZE Count); int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count); + +int AcpiUtStrncmp ( const char *String1, const char *String2, @@ -330,10 +318,10 @@ extern const UINT8 _acpi_ctype[]; #endif /* ACPI_USE_SYSTEM_CLIBRARY */ + /* - * UtCopy - Object construction and conversion interfaces + * utcopy - Object construction and conversion interfaces */ - ACPI_STATUS AcpiUtBuildSimpleObject( ACPI_OPERAND_OBJECT *Obj, @@ -348,30 +336,11 @@ AcpiUtBuildPackageObject ( UINT32 *SpaceUsed); ACPI_STATUS -AcpiUtCopyIelementToEelement ( - UINT8 ObjectType, - ACPI_OPERAND_OBJECT *SourceObject, - ACPI_GENERIC_STATE *State, - void *Context); - -ACPI_STATUS -AcpiUtCopyIelementToIelement ( - UINT8 ObjectType, - ACPI_OPERAND_OBJECT *SourceObject, - ACPI_GENERIC_STATE *State, - void *Context); - -ACPI_STATUS AcpiUtCopyIobjectToEobject ( ACPI_OPERAND_OBJECT *Obj, ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiUtCopyEsimpleToIsimple( - ACPI_OBJECT *UserObj, - ACPI_OPERAND_OBJECT **ReturnObj); - -ACPI_STATUS AcpiUtCopyEobjectToIobject ( ACPI_OBJECT *Obj, ACPI_OPERAND_OBJECT **InternalObj); @@ -382,17 +351,6 @@ AcpiUtCopyISimpleToIsimple ( ACPI_OPERAND_OBJECT *DestObj); ACPI_STATUS -AcpiUtCopyIpackageToIpackage ( - ACPI_OPERAND_OBJECT *SourceObj, - ACPI_OPERAND_OBJECT *DestObj, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiUtCopySimpleObject ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *DestDesc); - -ACPI_STATUS AcpiUtCopyIobjectToIobject ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **DestDesc, @@ -400,9 +358,8 @@ AcpiUtCopyIobjectToIobject ( /* - * UtCreate - Object creation + * utcreate - Object creation */ - ACPI_STATUS AcpiUtUpdateObjectReference ( ACPI_OPERAND_OBJECT *Object, @@ -410,9 +367,8 @@ AcpiUtUpdateObjectReference ( /* - * UtDebug - Debug interfaces + * utdebug - Debug interfaces */ - void AcpiUtInitStackPtrTrace ( void); @@ -510,11 +466,14 @@ AcpiUtDebugPrintRaw ( /* - * UtDelete - Object deletion + * utdelete - Object deletion and reference counts */ +void +AcpiUtAddReference ( + ACPI_OPERAND_OBJECT *Object); void -AcpiUtDeleteInternalObj ( +AcpiUtRemoveReference ( ACPI_OPERAND_OBJECT *Object); void @@ -531,23 +490,11 @@ AcpiUtDeleteInternalObjectList ( /* - * UtEval - object evaluation + * uteval - object evaluation */ - -/* Method name strings */ - -#define METHOD_NAME__HID "_HID" -#define METHOD_NAME__CID "_CID" -#define METHOD_NAME__UID "_UID" -#define METHOD_NAME__ADR "_ADR" -#define METHOD_NAME__STA "_STA" -#define METHOD_NAME__REG "_REG" -#define METHOD_NAME__SEG "_SEG" -#define METHOD_NAME__BBN "_BBN" -#define METHOD_NAME__PRT "_PRT" -#define METHOD_NAME__CRS "_CRS" -#define METHOD_NAME__PRS "_PRS" - +ACPI_STATUS +AcpiUtOsiImplementation ( + ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiUtEvaluateObject ( @@ -582,40 +529,15 @@ AcpiUtExecute_UID ( ACPI_NAMESPACE_NODE *DeviceNode, ACPI_DEVICE_ID *Uid); - -/* - * UtMutex - mutual exclusion interfaces - */ - -ACPI_STATUS -AcpiUtMutexInitialize ( - void); - -void -AcpiUtMutexTerminate ( - void); - -ACPI_STATUS -AcpiUtCreateMutex ( - ACPI_MUTEX_HANDLE MutexId); - -ACPI_STATUS -AcpiUtDeleteMutex ( - ACPI_MUTEX_HANDLE MutexId); - -ACPI_STATUS -AcpiUtAcquireMutex ( - ACPI_MUTEX_HANDLE MutexId); - ACPI_STATUS -AcpiUtReleaseMutex ( - ACPI_MUTEX_HANDLE MutexId); +AcpiUtExecute_Sxds ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT8 *Highest); /* - * UtObject - internal object create/delete/cache routines + * utobject - internal object create/delete/cache routines */ - ACPI_OPERAND_OBJECT * AcpiUtCreateInternalObjectDbg ( char *ModuleName, @@ -644,50 +566,19 @@ ACPI_OPERAND_OBJECT * AcpiUtCreateBufferObject ( ACPI_SIZE BufferSize); - -/* - * UtRefCnt - Object reference count management - */ - -void -AcpiUtAddReference ( - ACPI_OPERAND_OBJECT *Object); - -void -AcpiUtRemoveReference ( - ACPI_OPERAND_OBJECT *Object); - -/* - * UtSize - Object size routines - */ - -ACPI_STATUS -AcpiUtGetSimpleObjectSize ( - ACPI_OPERAND_OBJECT *Obj, - ACPI_SIZE *ObjLength); - -ACPI_STATUS -AcpiUtGetPackageObjectSize ( - ACPI_OPERAND_OBJECT *Obj, - ACPI_SIZE *ObjLength); +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize); ACPI_STATUS AcpiUtGetObjectSize( ACPI_OPERAND_OBJECT *Obj, ACPI_SIZE *ObjLength); -ACPI_STATUS -AcpiUtGetElementLength ( - UINT8 ObjectType, - ACPI_OPERAND_OBJECT *SourceObject, - ACPI_GENERIC_STATE *State, - void *Context); - /* - * UtState - Generic state creation/cache routines + * utstate - Generic state creation/cache routines */ - void AcpiUtPushGenericState ( ACPI_GENERIC_STATE **ListHead, @@ -738,6 +629,7 @@ void AcpiUtDeleteGenericState ( ACPI_GENERIC_STATE *State); +#ifdef ACPI_ENABLE_OBJECT_CACHE void AcpiUtDeleteGenericStateCache ( void); @@ -745,30 +637,45 @@ AcpiUtDeleteGenericStateCache ( void AcpiUtDeleteObjectCache ( void); +#endif + /* - * utmisc + * utmath */ - -void -AcpiUtPrintString ( - char *String, - UINT8 MaxLength); - ACPI_STATUS AcpiUtDivide ( - ACPI_INTEGER *InDividend, - ACPI_INTEGER *InDivisor, + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, ACPI_INTEGER *OutQuotient, ACPI_INTEGER *OutRemainder); ACPI_STATUS AcpiUtShortDivide ( - ACPI_INTEGER *InDividend, + ACPI_INTEGER InDividend, UINT32 Divisor, ACPI_INTEGER *OutQuotient, UINT32 *OutRemainder); +/* + * utmisc + */ +ACPI_STATUS +AcpiUtWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context); + +char * +AcpiUtStrupr ( + char *SrcString); + +void +AcpiUtPrintString ( + char *String, + UINT8 MaxLength); + BOOLEAN AcpiUtValidAcpiName ( UINT32 Name); @@ -783,9 +690,25 @@ AcpiUtStrtoul64 ( UINT32 Base, ACPI_INTEGER *RetInteger); -char * -AcpiUtStrupr ( - char *SrcString); +/* Values for Base above (16=Hex, 10=Decimal) */ + +#define ACPI_ANY_BASE 0 + +ACPI_STATUS +AcpiUtMutexInitialize ( + void); + +void +AcpiUtMutexTerminate ( + void); + +ACPI_STATUS +AcpiUtAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiUtReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId); UINT8 * AcpiUtGetResourceEndTag ( @@ -815,9 +738,8 @@ AcpiUtDisplayInitPathname ( /* - * Utalloc - memory allocation and object caching + * utalloc - memory allocation and object caching */ - void * AcpiUtAcquireFromCache ( UINT32 ListId); @@ -827,9 +749,11 @@ AcpiUtReleaseToCache ( UINT32 ListId, void *Object); +#ifdef ACPI_ENABLE_OBJECT_CACHE void AcpiUtDeleteGenericCache ( UINT32 ListId); +#endif ACPI_STATUS AcpiUtValidateBuffer ( @@ -840,9 +764,6 @@ AcpiUtInitializeBuffer ( ACPI_BUFFER *Buffer, ACPI_SIZE RequiredLength); - -/* Memory allocation functions */ - void * AcpiUtAllocate ( ACPI_SIZE Size, @@ -857,9 +778,7 @@ AcpiUtCallocate ( char *Module, UINT32 Line); - #ifdef ACPI_DBG_TRACK_ALLOCATIONS - void * AcpiUtAllocateAndTrack ( ACPI_SIZE Size, @@ -881,29 +800,6 @@ AcpiUtFreeAndTrack ( char *Module, UINT32 Line); -ACPI_DEBUG_MEM_BLOCK * -AcpiUtFindAllocation ( - UINT32 ListId, - void *Allocation); - -ACPI_STATUS -AcpiUtTrackAllocation ( - UINT32 ListId, - ACPI_DEBUG_MEM_BLOCK *Address, - ACPI_SIZE Size, - UINT8 AllocType, - UINT32 Component, - char *Module, - UINT32 Line); - -ACPI_STATUS -AcpiUtRemoveAllocation ( - UINT32 ListId, - ACPI_DEBUG_MEM_BLOCK *Address, - UINT32 Component, - char *Module, - UINT32 Line); - void AcpiUtDumpAllocationInfo ( void); @@ -914,5 +810,4 @@ AcpiUtDumpAllocations ( char *Module); #endif - #endif /* _ACUTILS_H */ diff --git a/sys/dev/acpi/acpica/Subsystem/amlcode.h b/sys/dev/acpi/acpica/Subsystem/amlcode.h index 8d03ad5084d..1c69d0e0921 100644 --- a/sys/dev/acpi/acpica/Subsystem/amlcode.h +++ b/sys/dev/acpi/acpica/Subsystem/amlcode.h @@ -3,7 +3,7 @@ * Name: amlcode.h - Definitions for AML, as included in "definition blocks" * Declarations and definitions contained herein are derived * directly from the ACPI specification. - * xRevision: 74 $ + * xRevision: 81 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -219,8 +219,7 @@ /* prefixed opcodes */ -#define AML_EXTOP (UINT16) 0x005b - +#define AML_EXTOP (UINT16) 0x005b /* prefix for 2-byte opcodes */ #define AML_MUTEX_OP (UINT16) 0x5b01 #define AML_EVENT_OP (UINT16) 0x5b02 @@ -243,6 +242,7 @@ #define AML_REVISION_OP (UINT16) 0x5b30 #define AML_DEBUG_OP (UINT16) 0x5b31 #define AML_FATAL_OP (UINT16) 0x5b32 +#define AML_TIMER_OP (UINT16) 0x5b33 /* ACPI 3.0 */ #define AML_REGION_OP (UINT16) 0x5b80 #define AML_FIELD_OP (UINT16) 0x5b81 #define AML_DEVICE_OP (UINT16) 0x5b82 @@ -266,7 +266,6 @@ * Use only "Unknown" AML opcodes, don't attempt to use * any valid ACPI ASCII values (A-Z, 0-9, '-') */ - #define AML_INT_NAMEPATH_OP (UINT16) 0x002d #define AML_INT_NAMEDFIELD_OP (UINT16) 0x0030 #define AML_INT_RESERVEDFIELD_OP (UINT16) 0x0031 @@ -286,7 +285,6 @@ * There can be up to 31 unique argument types * Zero is reserved as end-of-list indicator */ - #define ARGP_BYTEDATA 0x01 #define ARGP_BYTELIST 0x02 #define ARGP_CHARLIST 0x03 @@ -350,6 +348,7 @@ #define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ #define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ #define ARGI_REGION_OR_FIELD 0x15 /* Used by LOAD op only */ +#define ARGI_DATAREFOBJ 0x16 /* Note: types above can expand to 0x1F maximum */ @@ -366,7 +365,6 @@ /* * opcode groups and types */ - #define OPGRP_NAMED 0x01 #define OPGRP_FIELD 0x02 #define OPGRP_BYTELIST 0x04 @@ -378,22 +376,25 @@ /* Opcode flags */ -#define AML_HAS_ARGS 0x0800 -#define AML_HAS_TARGET 0x0400 -#define AML_HAS_RETVAL 0x0200 -#define AML_NSOBJECT 0x0100 -#define AML_NSOPCODE 0x0080 -#define AML_NSNODE 0x0040 -#define AML_NAMED 0x0020 -#define AML_DEFER 0x0010 -#define AML_FIELD 0x0008 -#define AML_CREATE 0x0004 -#define AML_MATH 0x0002 #define AML_LOGICAL 0x0001 -#define AML_CONSTANT 0x1000 +#define AML_LOGICAL_NUMERIC 0x0002 +#define AML_MATH 0x0004 +#define AML_CREATE 0x0008 +#define AML_FIELD 0x0010 +#define AML_DEFER 0x0020 +#define AML_NAMED 0x0040 +#define AML_NSNODE 0x0080 +#define AML_NSOPCODE 0x0100 +#define AML_NSOBJECT 0x0200 +#define AML_HAS_RETVAL 0x0400 +#define AML_HAS_TARGET 0x0800 +#define AML_HAS_ARGS 0x1000 +#define AML_CONSTANT 0x2000 +#define AML_NO_OPERAND_RESOLVE 0x4000 /* Convenient flag groupings */ +#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL #define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ #define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ #define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET @@ -411,17 +412,18 @@ * The opcode Type is used in a dispatch table, do not change * without updating the table. */ -#define AML_TYPE_EXEC_1A_0T_0R 0x00 /* Monadic1 */ -#define AML_TYPE_EXEC_1A_0T_1R 0x01 /* Monadic2 */ -#define AML_TYPE_EXEC_1A_1T_0R 0x02 -#define AML_TYPE_EXEC_1A_1T_1R 0x03 /* Monadic2R */ -#define AML_TYPE_EXEC_2A_0T_0R 0x04 /* Dyadic1 */ -#define AML_TYPE_EXEC_2A_0T_1R 0x05 /* Dyadic2 */ -#define AML_TYPE_EXEC_2A_1T_1R 0x06 /* Dyadic2R */ -#define AML_TYPE_EXEC_2A_2T_1R 0x07 -#define AML_TYPE_EXEC_3A_0T_0R 0x08 -#define AML_TYPE_EXEC_3A_1T_1R 0x09 -#define AML_TYPE_EXEC_6A_0T_1R 0x0A +#define AML_TYPE_EXEC_0A_0T_1R 0x00 +#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */ +#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */ +#define AML_TYPE_EXEC_1A_1T_0R 0x03 +#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* Monadic2R */ +#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */ +#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */ +#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* Dyadic2R */ +#define AML_TYPE_EXEC_2A_2T_1R 0x08 +#define AML_TYPE_EXEC_3A_0T_0R 0x09 +#define AML_TYPE_EXEC_3A_1T_1R 0x0A +#define AML_TYPE_EXEC_6A_0T_1R 0x0B /* End of types used in dispatch table */ #define AML_TYPE_LITERAL 0x0B @@ -448,6 +450,12 @@ #define AML_TYPE_UNDEFINED 0x19 #define AML_TYPE_BOGUS 0x1A +/* AML Package Length encodings */ + +#define ACPI_AML_PACKAGE_TYPE1 0x40 +#define ACPI_AML_PACKAGE_TYPE2 0x4000 +#define ACPI_AML_PACKAGE_TYPE3 0x400000 +#define ACPI_AML_PACKAGE_TYPE4 0x40000000 /* * Opcode classes @@ -569,11 +577,17 @@ typedef enum } AML_ACCESS_ATTRIBUTE; -/* bit fields in MethodFlags byte */ +/* Bit fields in MethodFlags byte */ + +#define AML_METHOD_ARG_COUNT 0x07 +#define AML_METHOD_SERIALIZED 0x08 +#define AML_METHOD_SYNCH_LEVEL 0xF0 + +/* METHOD_FLAGS_ARG_COUNT is not used internally, define additional flags */ -#define METHOD_FLAGS_ARG_COUNT 0x07 -#define METHOD_FLAGS_SERIALIZED 0x08 -#define METHOD_FLAGS_SYNCH_LEVEL 0xF0 +#define AML_METHOD_INTERNAL_ONLY 0x01 +#define AML_METHOD_RESERVED1 0x02 +#define AML_METHOD_RESERVED2 0x04 #endif /* __AMLCODE_H__ */ diff --git a/sys/dev/acpi/acpica/Subsystem/amlresrc.h b/sys/dev/acpi/acpica/Subsystem/amlresrc.h index 68b2f07917c..b9537c18a79 100644 --- a/sys/dev/acpi/acpica/Subsystem/amlresrc.h +++ b/sys/dev/acpi/acpica/Subsystem/amlresrc.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amlresrc.h - AML resource descriptors - * xRevision: 24 $ + * xRevision: 29 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,8 @@ #define ASL_RESNAME_ADDRESS "_ADR" #define ASL_RESNAME_ALIGNMENT "_ALN" #define ASL_RESNAME_ADDRESSSPACE "_ASI" +#define ASL_RESNAME_ACCESSSIZE "_ASZ" +#define ASL_RESNAME_TYPESPECIFICATTRIBUTES "_ATT" #define ASL_RESNAME_BASEADDRESS "_BAS" #define ASL_RESNAME_BUSMASTER "_BM_" /* Master(1), Slave(0) */ #define ASL_RESNAME_DECODE "_DEC" @@ -173,7 +175,7 @@ typedef struct asl_resource_node /* * Resource descriptors defined in the ACPI specification. * - * Alignment must be BYTE because these descriptors + * Packing/alignment must be BYTE because these descriptors * are used to overlay the AML byte stream. */ #pragma pack(1) @@ -311,6 +313,28 @@ typedef struct asl_fixed_memory_32_desc } ASL_FIXED_MEMORY_32_DESC; +typedef struct asl_extended_address_desc +{ + UINT8 DescriptorType; + UINT16 Length; + UINT8 ResourceType; + UINT8 Flags; + UINT8 SpecificFlags; + UINT8 RevisionID; + UINT8 Reserved; + UINT64 Granularity; + UINT64 AddressMin; + UINT64 AddressMax; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecificAttributes; + UINT8 OptionalFields[2]; /* Used for length calculation only */ + +} ASL_EXTENDED_ADDRESS_DESC; + +#define ASL_EXTENDED_ADDRESS_DESC_REVISION 1 /* ACPI 3.0 */ + + typedef struct asl_qword_address_desc { UINT8 DescriptorType; @@ -381,7 +405,7 @@ typedef struct asl_general_register_desc UINT8 AddressSpaceId; UINT8 BitWidth; UINT8 BitOffset; - UINT8 Reserved; + UINT8 AccessSize; /* ACPI 3.0, was Reserved */ UINT64 Address; } ASL_GENERAL_REGISTER_DESC; @@ -390,7 +414,7 @@ typedef struct asl_general_register_desc #pragma pack() -/* Union of all resource descriptors, sow we can allocate the worst case */ +/* Union of all resource descriptors, so we can allocate the worst case */ typedef union asl_resource_desc { @@ -410,6 +434,7 @@ typedef union asl_resource_desc ASL_QWORD_ADDRESS_DESC Qas; ASL_DWORD_ADDRESS_DESC Das; ASL_WORD_ADDRESS_DESC Was; + ASL_EXTENDED_ADDRESS_DESC Eas; ASL_EXTENDED_XRUPT_DESC Exx; ASL_GENERAL_REGISTER_DESC Grg; UINT32 U32Item; diff --git a/sys/dev/acpi/acpica/Subsystem/dbcmds.c b/sys/dev/acpi/acpica/Subsystem/dbcmds.c index 3a4441d3430..f48c5d63a94 100644 --- a/sys/dev/acpi/acpica/Subsystem/dbcmds.c +++ b/sys/dev/acpi/acpica/Subsystem/dbcmds.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbcmds - debug commands and output routines - * xRevision: 110 $ + * xRevision: 121 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbcmds.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbcmds.c,v 1.13 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acdispat.h" @@ -127,11 +127,44 @@ __KERNEL_RCSID(0, "$NetBSD: dbcmds.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); #include "acresrc.h" #include "acdisasm.h" + +#include "acparser.h" + #ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbcmds") +/* Local prototypes */ + +static ACPI_STATUS +AcpiDbIntegrityWalk ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbWalkAndMatchName ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbWalkForReferences ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbWalkForSpecificObjects ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + /* * Arguments for the Objects command @@ -162,6 +195,53 @@ static ARGUMENT_INFO AcpiDbObjectTypes [] = /******************************************************************************* * + * FUNCTION: AcpiDbSleep + * + * PARAMETERS: ObjectArg - Desired sleep state (0-5) + * + * RETURN: Status + * + * DESCRIPTION: Simulate a sleep/wake sequence + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbSleep ( + char *ObjectArg) +{ +#if ACPI_MACHINE_WIDTH == 16 + return (AE_OK); +#else + ACPI_STATUS Status; + UINT8 SleepState; + + + SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); + + AcpiOsPrintf ("**** Prepare to sleep ****\n"); + Status = AcpiEnterSleepStatePrep (SleepState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiOsPrintf ("**** Going to sleep ****\n"); + Status = AcpiEnterSleepState (SleepState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiOsPrintf ("**** returning from sleep ****\n"); + Status = AcpiLeaveSleepState (SleepState); + + return (Status); +#endif +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbWalkForReferences * * PARAMETERS: Callback from WalkNamespace @@ -175,7 +255,7 @@ static ARGUMENT_INFO AcpiDbObjectTypes [] = * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbWalkForReferences ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -249,7 +329,8 @@ AcpiDbFindReferences ( ******************************************************************************/ void -AcpiDbDisplayLocks (void) +AcpiDbDisplayLocks ( + void) { UINT32 i; @@ -395,7 +476,8 @@ AcpiDbSetMethodBreakpoint ( Address = ACPI_STRTOUL (Location, NULL, 16); if (Address <= Op->Common.AmlOffset) { - AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->Common.AmlOffset); + AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", + Address, Op->Common.AmlOffset); } /* Save breakpoint in current walk */ @@ -473,6 +555,71 @@ AcpiDbDisassembleAml ( /******************************************************************************* * + * FUNCTION: AcpiDbDisassembleMethod + * + * PARAMETERS: Name - Name of control method + * + * RETURN: None + * + * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number + * of statements specified. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbDisassembleMethod ( + char *Name) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Method; + + + Method = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ACPI_STRTOUL (Name, NULL, 16)); + if (!Method) + { + return (AE_BAD_PARAMETER); + } + + ObjDesc = Method->Object; + + Op = AcpiPsCreateScopeOp (); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL); + if (!WalkState) + { + return (AE_NO_MEMORY); + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, NULL, 1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Parse the AML */ + + WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; + Status = AcpiPsParseAml (WalkState); + + AcpiDmDisassemble (NULL, Op, 0); + AcpiPsDeleteParseTree (Op); + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbDumpNamespace * * PARAMETERS: StartArg - Node to begin namespace dump @@ -505,7 +652,8 @@ AcpiDbDumpNamespace ( SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16)); if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE))) { - AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry); + AcpiOsPrintf ("Address %p is invalid in this address space\n", + SubtreeEntry); return; } @@ -519,8 +667,9 @@ AcpiDbDumpNamespace ( else { /* Alpha argument */ - /* The parameter is a name string that must be resolved to a Named obj*/ - + /* The parameter is a name string that must be resolved to a + * Named obj + */ SubtreeEntry = AcpiDbLocalNsLookup (StartArg); if (!SubtreeEntry) { @@ -542,7 +691,8 @@ AcpiDbDumpNamespace ( /* Display the subtree */ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry); + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, + ACPI_UINT32_MAX, SubtreeEntry); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } @@ -585,7 +735,8 @@ AcpiDbDumpNamespaceByOwner ( /* Display the subtree */ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry); + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, + SubtreeEntry); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } @@ -675,7 +826,7 @@ AcpiDbSetMethodData ( /* Validate TypeArg */ - ACPI_STRUPR (TypeArg); + AcpiUtStrupr (TypeArg); Type = TypeArg[0]; if ((Type != 'L') && (Type != 'A')) @@ -721,7 +872,8 @@ AcpiDbSetMethodData ( return; } - Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState); + Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, + WalkState); if (ACPI_FAILURE (Status)) { return; @@ -743,7 +895,8 @@ AcpiDbSetMethodData ( return; } - Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState); + Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, + WalkState); if (ACPI_FAILURE (Status)) { return; @@ -773,7 +926,7 @@ AcpiDbSetMethodData ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbWalkForSpecificObjects ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -804,6 +957,8 @@ AcpiDbWalkForSpecificObjects ( if (ObjDesc) { + AcpiOsPrintf (" %p/%p", ObjHandle, ObjDesc); + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_METHOD: @@ -877,7 +1032,8 @@ AcpiDbDisplayObjects ( } AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); - AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", + AcpiOsPrintf ( + "Objects of type [%s] defined in the current ACPI Namespace: \n", AcpiUtGetTypeName (Type)); AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); @@ -905,7 +1061,7 @@ AcpiDbDisplayObjects ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbWalkAndMatchName ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -1019,7 +1175,8 @@ AcpiDbSetScope ( { /* Validate new scope from the root */ - Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node); + Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -1032,7 +1189,8 @@ AcpiDbSetScope ( { /* Validate new scope relative to old scope */ - Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node); + Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -1048,7 +1206,8 @@ AcpiDbSetScope ( ErrorExit: - AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status)); + AcpiOsPrintf ("Could not attach scope: %s, %s\n", + Name, AcpiFormatException (Status)); } @@ -1091,10 +1250,11 @@ AcpiDbDisplayResources ( AcpiOsPrintf ("Evaluating _PRT\n"); - Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj); + Status = AcpiEvaluateObject (ObjDesc, METHOD_NAME__PRT, NULL, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("Could not obtain _PRT: %s\n", + AcpiFormatException (Status)); goto GetCrs; } @@ -1104,7 +1264,8 @@ AcpiDbDisplayResources ( Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", + AcpiFormatException (Status)); } else { @@ -1120,10 +1281,11 @@ GetCrs: ReturnObj.Pointer = AcpiGbl_DbBuffer; ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj); + Status = AcpiEvaluateObject (ObjDesc, METHOD_NAME__CRS, NULL, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("Could not obtain _CRS: %s\n", + AcpiFormatException (Status)); goto GetPrs; } @@ -1133,18 +1295,21 @@ GetCrs: Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", + AcpiFormatException (Status)); goto GetPrs; } else { - AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); + AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, + AcpiGbl_DbBuffer)); } Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", + AcpiFormatException (Status)); goto GetPrs; } @@ -1157,10 +1322,11 @@ GetPrs: ReturnObj.Pointer = AcpiGbl_DbBuffer; ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj); + Status = AcpiEvaluateObject (ObjDesc, METHOD_NAME__PRS, NULL, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("Could not obtain _PRS: %s\n", + AcpiFormatException (Status)); goto Cleanup; } @@ -1170,7 +1336,8 @@ GetPrs: Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", + AcpiFormatException (Status)); } else { @@ -1197,7 +1364,7 @@ Cleanup: * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbIntegrityWalk ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -1255,7 +1422,8 @@ AcpiDbIntegrityWalk ( ******************************************************************************/ void -AcpiDbCheckIntegrity (void) +AcpiDbCheckIntegrity ( + void) { ACPI_INTEGRITY_INFO Info = {0,0}; @@ -1264,7 +1432,8 @@ AcpiDbCheckIntegrity (void) (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, AcpiDbIntegrityWalk, (void *) &Info, NULL); - AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info.Nodes, Info.Objects); + AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", + Info.Nodes, Info.Objects); } @@ -1272,7 +1441,9 @@ AcpiDbCheckIntegrity (void) * * FUNCTION: AcpiDbGenerateGpe * - * PARAMETERS: None + * PARAMETERS: GpeArg - Raw GPE number, ascii string + * BlockArg - GPE block number, ascii string + * 0 or 1 for FADT GPE blocks * * RETURN: None * @@ -1294,14 +1465,15 @@ AcpiDbGenerateGpe ( BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); - GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), GpeNumber); + GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), + GpeNumber); if (!GpeEventInfo) { AcpiOsPrintf ("Invalid GPE\n"); return; } - AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); + (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); } #endif /* ACPI_DEBUGGER */ diff --git a/sys/dev/acpi/acpica/Subsystem/dbdisply.c b/sys/dev/acpi/acpica/Subsystem/dbdisply.c index f88930c932a..3ed9ab28d6a 100644 --- a/sys/dev/acpi/acpica/Subsystem/dbdisply.c +++ b/sys/dev/acpi/acpica/Subsystem/dbdisply.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbdisply - debug display commands - * xRevision: 100 $ + * xRevision: 111 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbdisply.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbdisply.c,v 1.13 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "amlcode.h" @@ -130,12 +130,21 @@ __KERNEL_RCSID(0, "$NetBSD: dbdisply.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); #ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbdisply") +/* Local prototypes */ -/****************************************************************************** +static void +AcpiDbDumpParserDescriptor ( + ACPI_PARSE_OBJECT *Op); + +static void * +AcpiDbGetPointer ( + void *Target); + + +/******************************************************************************* * * FUNCTION: AcpiDbGetPointer * @@ -145,9 +154,9 @@ __KERNEL_RCSID(0, "$NetBSD: dbdisply.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); * * DESCRIPTION: Convert an ascii pointer value to a real value * - *****************************************************************************/ + ******************************************************************************/ -void * +static void * AcpiDbGetPointer ( void *Target) { @@ -188,7 +197,7 @@ AcpiDbGetPointer ( * ******************************************************************************/ -void +static void AcpiDbDumpParserDescriptor ( ACPI_PARSE_OBJECT *Op) { @@ -200,7 +209,8 @@ AcpiDbDumpParserDescriptor ( AcpiOsPrintf ("Parser Op Descriptor:\n"); AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode); - ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", Info->Name)); + ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", + Info->Name)); AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg); AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent); @@ -246,7 +256,7 @@ AcpiDbDecodeAndDisplayObject ( if (OutputType) { - ACPI_STRUPR (OutputType); + AcpiUtStrupr (OutputType); if (OutputType[0] == 'W') { Display = DB_WORD_DISPLAY; @@ -271,7 +281,8 @@ AcpiDbDecodeAndDisplayObject ( ObjPtr = AcpiDbGetPointer (Target); if (!AcpiOsReadable (ObjPtr, 16)) { - AcpiOsPrintf ("Address %p is invalid in this address space\n", ObjPtr); + AcpiOsPrintf ("Address %p is invalid in this address space\n", + ObjPtr); return; } @@ -285,12 +296,13 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) { - AcpiOsPrintf ("Cannot read entire Named object at address %p\n", ObjPtr); + AcpiOsPrintf ( + "Cannot read entire Named object at address %p\n", ObjPtr); return; } Node = ObjPtr; - goto DumpNte; + goto DumpNode; case ACPI_DESC_TYPE_OPERAND: @@ -299,11 +311,13 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) { - AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", ObjPtr); + AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", + ObjPtr); return; } - AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, + ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjPtr, 1); break; @@ -314,11 +328,13 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) { - AcpiOsPrintf ("Cannot read entire Parser object at address %p\n", ObjPtr); + AcpiOsPrintf ( + "Cannot read entire Parser object at address %p\n", ObjPtr); return; } - AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, ACPI_UINT32_MAX); + AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, + ACPI_UINT32_MAX); AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); break; @@ -351,8 +367,8 @@ AcpiDbDecodeAndDisplayObject ( } -DumpNte: - /* Now dump the Named obj */ +DumpNode: + /* Now dump the NS node */ Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); if (ACPI_FAILURE (Status)) @@ -362,7 +378,8 @@ DumpNte: else { - AcpiOsPrintf ("Object (%p) Pathname: %s\n", Node, (char *) RetBuf.Pointer); + AcpiOsPrintf ("Object (%p) Pathname: %s\n", + Node, (char *) RetBuf.Pointer); } if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) @@ -371,7 +388,8 @@ DumpNte: return; } - AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX); + AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), + Display, ACPI_UINT32_MAX); AcpiExDumpNode (Node, 1); ObjDesc = AcpiNsGetAttachedObject (Node); @@ -380,11 +398,13 @@ DumpNte: AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc); if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT))) { - AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", ObjDesc); + AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", + ObjDesc); return; } - AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), + Display, ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjDesc, 1); } } @@ -495,11 +515,13 @@ AcpiDbDisplayMethodInfo ( Op = AcpiPsGetDepthNext (StartOp, Op); } - AcpiOsPrintf ("Method contains: %X AML Opcodes - %X Operators, %X Operands\n", - NumOps, NumOperators, NumOperands); + AcpiOsPrintf ( + "Method contains: %X AML Opcodes - %X Operators, %X Operands\n", + NumOps, NumOperators, NumOperands); - AcpiOsPrintf ("Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n", - NumRemainingOps, NumRemainingOperators, NumRemainingOperands); + AcpiOsPrintf ( + "Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n", + NumRemainingOps, NumRemainingOperators, NumRemainingOperands); } @@ -516,7 +538,8 @@ AcpiDbDisplayMethodInfo ( ******************************************************************************/ void -AcpiDbDisplayLocals (void) +AcpiDbDisplayLocals ( + void) { ACPI_WALK_STATE *WalkState; @@ -545,7 +568,8 @@ AcpiDbDisplayLocals (void) ******************************************************************************/ void -AcpiDbDisplayArguments (void) +AcpiDbDisplayArguments ( + void) { ACPI_WALK_STATE *WalkState; @@ -574,7 +598,8 @@ AcpiDbDisplayArguments (void) ******************************************************************************/ void -AcpiDbDisplayResults (void) +AcpiDbDisplayResults ( + void) { UINT32 i; ACPI_WALK_STATE *WalkState; @@ -623,7 +648,8 @@ AcpiDbDisplayResults (void) ******************************************************************************/ void -AcpiDbDisplayCallingTree (void) +AcpiDbDisplayCallingTree ( + void) { ACPI_WALK_STATE *WalkState; ACPI_NAMESPACE_NODE *Node; @@ -680,16 +706,20 @@ AcpiDbDisplayObjectType ( if (ACPI_SUCCESS (Status)) { Info = Buffer.Pointer; - AcpiOsPrintf ("HID: %s, ADR: %8.8X%8.8X, Status %8.8X\n", - Info->HardwareId.Value, - ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus); + AcpiOsPrintf ( + "S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X HID: %s, ADR: %8.8X%8.8X, Status %8.8X\n", + Info->HighestDstates[0], Info->HighestDstates[1], + Info->HighestDstates[2], Info->HighestDstates[3], + Info->HardwareId.Value, + ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus); if (Info->Valid & ACPI_VALID_CID) { for (i = 0; i < Info->CompatibilityId.Count; i++) { - AcpiOsPrintf ("CID #%d: %s\n", (UINT32) i, Info->CompatibilityId.Id[i].Value); + AcpiOsPrintf ("CID #%d: %s\n", (UINT32) i, + Info->CompatibilityId.Id[i].Value); } } @@ -780,12 +810,28 @@ AcpiDbDisplayArgumentObject ( ******************************************************************************/ void -AcpiDbDisplayGpes (void) +AcpiDbDisplayGpes ( + void) { ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_GPE_XRUPT_INFO *GpeXruptInfo; - UINT32 i = 0; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT32 GpeIndex; + UINT32 Block = 0; + UINT32 i; + UINT32 j; + char Buffer[80]; + ACPI_BUFFER RetBuf; + ACPI_STATUS Status; + + RetBuf.Length = sizeof (Buffer); + RetBuf.Pointer = Buffer; + + Block = 0; + + /* Walk the GPE lists */ GpeXruptInfo = AcpiGbl_GpeXruptListHead; while (GpeXruptInfo) @@ -793,21 +839,134 @@ AcpiDbDisplayGpes (void) GpeBlock = GpeXruptInfo->GpeBlockListHead; while (GpeBlock) { - AcpiOsPrintf ("Block %d - %p\n", i, GpeBlock); - AcpiOsPrintf (" Registers: %d\n", GpeBlock->RegisterCount); - AcpiOsPrintf (" GPE range: %d to %d\n", GpeBlock->BlockBaseNumber, - GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8) -1); - AcpiOsPrintf (" RegisterInfo: %p\n", GpeBlock->RegisterInfo); + Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not convert name to pathname\n"); + } + + AcpiOsPrintf ("\nBlock %d - Info %p DeviceNode %p [%s]\n", + Block, GpeBlock, GpeBlock->Node, Buffer); + + AcpiOsPrintf (" Registers: %u (%u GPEs) \n", + GpeBlock->RegisterCount, + ACPI_MUL_8 (GpeBlock->RegisterCount)); + + AcpiOsPrintf (" GPE range: 0x%X to 0x%X\n", + GpeBlock->BlockBaseNumber, + GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8) -1); + + AcpiOsPrintf ( + " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", + GpeBlock->RegisterInfo, + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->StatusAddress.Address)), + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->EnableAddress.Address))); + AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); - i++; + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; + + AcpiOsPrintf ( + " Reg %u: WakeEnable %2.2X, RunEnable %2.2X Status %8.8X%8.8X Enable %8.8X%8.8X\n", + i, GpeRegisterInfo->EnableForWake, + GpeRegisterInfo->EnableForRun, + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->StatusAddress.Address)), + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address))); + + /* Now look at the individual GPEs in this byte register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; + GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; + + if (!(GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)) + { + /* This GPE is not used (no method or handler) */ + + continue; + } + + AcpiOsPrintf ( + " GPE %.3X: %p Bit %2.2X Flags %2.2X: ", + GpeBlock->BlockBaseNumber + GpeIndex, + GpeEventInfo, GpeEventInfo->RegisterBit, + GpeEventInfo->Flags); + + if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) + { + AcpiOsPrintf ("Level, "); + } + else + { + AcpiOsPrintf ("Edge, "); + } + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + AcpiOsPrintf ("WakeOnly: "); + break; + case ACPI_GPE_TYPE_RUNTIME: + AcpiOsPrintf (" RunOnly: "); + break; + case ACPI_GPE_TYPE_WAKE_RUN: + AcpiOsPrintf (" WakeRun: "); + break; + default: + AcpiOsPrintf (" NotUsed: "); + break; + } + + if (GpeEventInfo->Flags & ACPI_GPE_WAKE_ENABLED) + { + AcpiOsPrintf ("[Wake 1 "); + } + else + { + AcpiOsPrintf ("[Wake 0 "); + } + + if (GpeEventInfo->Flags & ACPI_GPE_RUN_ENABLED) + { + AcpiOsPrintf ("Run 1], "); + } + else + { + AcpiOsPrintf ("Run 0], "); + } + + switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) + { + case ACPI_GPE_DISPATCH_NOT_USED: + AcpiOsPrintf ("NotUsed"); + break; + case ACPI_GPE_DISPATCH_HANDLER: + AcpiOsPrintf ("Handler"); + break; + case ACPI_GPE_DISPATCH_METHOD: + AcpiOsPrintf ("Method"); + break; + default: + AcpiOsPrintf ("UNKNOWN: %X", + GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK); + break; + } + + AcpiOsPrintf ("\n"); + } + } + Block++; GpeBlock = GpeBlock->Next; } - GpeXruptInfo = GpeXruptInfo->Next; } } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/dev/acpi/acpica/Subsystem/dbexec.c b/sys/dev/acpi/acpica/Subsystem/dbexec.c index cdf9e1d9d79..47c8a2e5429 100644 --- a/sys/dev/acpi/acpica/Subsystem/dbexec.c +++ b/sys/dev/acpi/acpica/Subsystem/dbexec.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbexec - debugger control method execution - * xRevision: 57 $ + * xRevision: 66 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbexec.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbexec.c,v 1.13 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acdebug.h" @@ -130,6 +130,32 @@ __KERNEL_RCSID(0, "$NetBSD: dbexec.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; +/* Local prototypes */ + +static ACPI_STATUS +AcpiDbExecuteMethod ( + ACPI_DB_METHOD_INFO *Info, + ACPI_BUFFER *ReturnObj); + +static void +AcpiDbExecuteSetup ( + ACPI_DB_METHOD_INFO *Info); + +static UINT32 +AcpiDbGetOutstandingAllocations ( + void); + +static void ACPI_SYSTEM_XFACE +AcpiDbMethodThread ( + void *Context); + +static ACPI_STATUS +AcpiDbExecutionWalk ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + /******************************************************************************* * @@ -144,7 +170,7 @@ static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbExecuteMethod ( ACPI_DB_METHOD_INFO *Info, ACPI_BUFFER *ReturnObj) @@ -166,37 +192,38 @@ AcpiDbExecuteMethod ( { for (i = 0; Info->Args[i] && i < ACPI_METHOD_NUM_ARGS; i++) { - Params[i].Type = ACPI_TYPE_INTEGER; - Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); + Params[i].Type = ACPI_TYPE_INTEGER; + Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); } - ParamObjects.Pointer = Params; - ParamObjects.Count = i; + ParamObjects.Pointer = Params; + ParamObjects.Count = i; } else { /* Setup default parameters */ - Params[0].Type = ACPI_TYPE_INTEGER; - Params[0].Integer.Value = 0x01020304; + Params[0].Type = ACPI_TYPE_INTEGER; + Params[0].Integer.Value = 0x01020304; - Params[1].Type = ACPI_TYPE_STRING; - Params[1].String.Length = 12; - Params[1].String.Pointer = "AML Debugger"; + Params[1].Type = ACPI_TYPE_STRING; + Params[1].String.Length = 12; + Params[1].String.Pointer = "AML Debugger"; - ParamObjects.Pointer = Params; - ParamObjects.Count = 2; + ParamObjects.Pointer = Params; + ParamObjects.Count = 2; } /* Prepare for a return object of arbitrary size */ - ReturnObj->Pointer = AcpiGbl_DbBuffer; - ReturnObj->Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj->Pointer = AcpiGbl_DbBuffer; + ReturnObj->Length = ACPI_DEBUG_BUFFER_SIZE; /* Do the actual method execution */ AcpiGbl_MethodExecuting = TRUE; - Status = AcpiEvaluateObject (NULL, Info->Pathname, &ParamObjects, ReturnObj); + Status = AcpiEvaluateObject (NULL, + Info->Pathname, &ParamObjects, ReturnObj); AcpiGbl_CmSingleStep = FALSE; AcpiGbl_MethodExecuting = FALSE; @@ -211,13 +238,13 @@ AcpiDbExecuteMethod ( * * PARAMETERS: Info - Valid method info * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Setup info segment prior to method execution * ******************************************************************************/ -void +static void AcpiDbExecuteSetup ( ACPI_DB_METHOD_INFO *Info) { @@ -266,7 +293,7 @@ AcpiDbExecuteSetup ( * ******************************************************************************/ -UINT32 +static UINT32 AcpiDbGetOutstandingAllocations ( void) { @@ -301,7 +328,7 @@ AcpiDbGetOutstandingAllocations ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbExecutionWalk ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -348,7 +375,7 @@ AcpiDbExecutionWalk ( * Args - Parameters to the method * Flags - single step/no single step * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Execute a control method. Name is relative to the current * scope. @@ -377,8 +404,8 @@ AcpiDbExecute ( if (*Name == '*') { - (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbExecutionWalk, NULL, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL); return; } else @@ -398,7 +425,7 @@ AcpiDbExecute ( * Allow any handlers in separate threads to complete. * (Such as Notify handlers invoked from AML executed above). */ - AcpiOsSleep (0, 10); + AcpiOsSleep (10); #ifdef ACPI_DEBUG_OUTPUT @@ -411,7 +438,7 @@ AcpiDbExecute ( if (Allocations > 0) { - AcpiOsPrintf ("Outstanding: %u allocations after execution\n", + AcpiOsPrintf ("Outstanding: 0x%X allocations after execution\n", Allocations); } #endif @@ -421,7 +448,6 @@ AcpiDbExecute ( AcpiOsPrintf ("Execution of %s failed with status %s\n", AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); } - else { /* Display a return object, if any */ @@ -457,7 +483,7 @@ AcpiDbExecute ( * ******************************************************************************/ -void ACPI_SYSTEM_XFACE +static void ACPI_SYSTEM_XFACE AcpiDbMethodThread ( void *Context) { @@ -477,15 +503,17 @@ AcpiDbMethodThread ( #endif Status = AcpiDbExecuteMethod (Info, &ReturnObj); - if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("%s During execution of %s at iteration %X\n", AcpiFormatException (Status), Info->Pathname, i); - break; + if (Status == AE_ABORT_METHOD) + { + break; + } } - if ((i % 1000) == 0) + if ((i % 100) == 0) { AcpiOsPrintf ("%d executions\n", i); } @@ -544,7 +572,8 @@ AcpiDbCreateExecutionThreads ( if (!NumThreads || !NumLoops) { - AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", NumThreads, NumLoops); + AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", + NumThreads, NumLoops); return; } @@ -553,7 +582,8 @@ AcpiDbCreateExecutionThreads ( Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not create semaphore, %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("Could not create semaphore, %s\n", + AcpiFormatException (Status)); return; } @@ -569,11 +599,13 @@ AcpiDbCreateExecutionThreads ( /* Create the threads */ - AcpiOsPrintf ("Creating %X threads to execute %X times each\n", NumThreads, NumLoops); + AcpiOsPrintf ("Creating %X threads to execute %X times each\n", + NumThreads, NumLoops); for (i = 0; i < (NumThreads); i++) { - Status = AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, &AcpiGbl_DbMethodInfo); + Status = AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, + &AcpiGbl_DbMethodInfo); if (ACPI_FAILURE (Status)) { break; @@ -583,7 +615,7 @@ AcpiDbCreateExecutionThreads ( /* Wait for all threads to complete */ i = NumThreads; - while (i) /* Brain damage for OSD implementations that only support wait of 1 unit */ + while (i) /* Brain damage for host OSs that only support wait of 1 unit */ { Status = AcpiOsWaitSemaphore (ThreadGate, 1, ACPI_WAIT_FOREVER); i--; @@ -598,7 +630,6 @@ AcpiDbCreateExecutionThreads ( AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/dev/acpi/acpica/Subsystem/dbfileio.c b/sys/dev/acpi/acpica/Subsystem/dbfileio.c index 26193b56953..e76a56ff74c 100644 --- a/sys/dev/acpi/acpica/Subsystem/dbfileio.c +++ b/sys/dev/acpi/acpica/Subsystem/dbfileio.c @@ -2,7 +2,7 @@ * * Module Name: dbfileio - Debugger file I/O commands. These can't usually * be used when running the debugger in Ring 0 (Kernel mode) - * xRevision: 76 $ + * xRevision: 81 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbfileio.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbfileio.c,v 1.12 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acdebug.h" @@ -129,7 +129,6 @@ __KERNEL_RCSID(0, "$NetBSD: dbfileio.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbfileio") - /* * NOTE: this is here for lack of a better place. It is used in all * flavors of the debugger, need LCD file @@ -139,6 +138,22 @@ __KERNEL_RCSID(0, "$NetBSD: dbfileio.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); FILE *AcpiGbl_DebugFile = NULL; #endif +/* Local prototypes */ + +#ifdef ACPI_APPLICATION + +static ACPI_STATUS +AcpiDbCheckTextModeCorruption ( + UINT8 *Table, + UINT32 TableLength, + UINT32 FileLength); + +static ACPI_STATUS +AeLocalLoadTable ( + ACPI_TABLE_HEADER *TablePtr); + +#endif + #ifdef ACPI_DEBUGGER /******************************************************************************* @@ -147,7 +162,7 @@ FILE *AcpiGbl_DebugFile = NULL; * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * * DESCRIPTION: If open, close the current debug output file * @@ -177,7 +192,7 @@ AcpiDbCloseDebugFile ( * * PARAMETERS: Name - Filename to open * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Open a file where debug output will be directed. * @@ -238,8 +253,9 @@ AcpiDbCheckTextModeCorruption ( if (TableLength != FileLength) { - ACPI_REPORT_WARNING (("File length (0x%X) is not the same as the table length (0x%X)\n", - FileLength, TableLength)); + ACPI_REPORT_WARNING (( + "File length (0x%X) is not the same as the table length (0x%X)\n", + FileLength, TableLength)); } /* Scan entire table to determine if each LF has been prefixed with a CR */ @@ -250,7 +266,7 @@ AcpiDbCheckTextModeCorruption ( { if (Table[i - 1] != 0x0D) { - /* the LF does not have a preceeding CR, table is not corrupted */ + /* The LF does not have a preceeding CR, table not corrupted */ return (AE_OK); } @@ -311,20 +327,30 @@ AcpiDbReadTable ( /* Read the table header */ - if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != sizeof (ACPI_TABLE_HEADER)) + if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != + sizeof (ACPI_TABLE_HEADER)) { - AcpiOsPrintf ("Couldn't read the table header\n"); - return (AE_BAD_SIGNATURE); + AcpiOsPrintf ("Could not read the table header\n"); + return (AE_BAD_HEADER); } /* Validate the table header/length */ Status = AcpiTbValidateTableHeader (&TableHeader); - if ((ACPI_FAILURE (Status)) || - (TableHeader.Length > 0x800000)) /* 8 Mbyte should be enough */ + if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Table header is invalid!\n"); - return (AE_ERROR); + return (Status); + } + + /* File size must be at least as long as the Header-specified length */ + + if (TableHeader.Length > FileSize) + { + AcpiOsPrintf ( + "TableHeader length [0x%X] greater than the input file size [0x%X]\n", + TableHeader.Length, FileSize); + return (AE_BAD_HEADER); } /* We only support a limited number of table types */ @@ -333,7 +359,8 @@ AcpiDbReadTable ( ACPI_STRNCMP ((char *) TableHeader.Signature, PSDT_SIG, 4) && ACPI_STRNCMP ((char *) TableHeader.Signature, SSDT_SIG, 4)) { - AcpiOsPrintf ("Table signature is invalid\n"); + AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", + (char *) TableHeader.Signature); ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); return (AE_ERROR); } @@ -344,8 +371,9 @@ AcpiDbReadTable ( *Table = AcpiOsAllocate ((size_t) (FileSize)); if (!*Table) { - AcpiOsPrintf ("Could not allocate memory for ACPI table %4.4s (size=%X)\n", - TableHeader.Signature, TableHeader.Length); + AcpiOsPrintf ( + "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", + TableHeader.Signature, TableHeader.Length); return (AE_NO_MEMORY); } @@ -382,7 +410,6 @@ AcpiDbReadTable ( return (AE_ERROR); } -#endif /******************************************************************************* @@ -401,7 +428,7 @@ AcpiDbReadTable ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AeLocalLoadTable ( ACPI_TABLE_HEADER *Table) { @@ -451,7 +478,6 @@ AeLocalLoadTable ( } -#ifdef ACPI_APPLICATION /******************************************************************************* * * FUNCTION: AcpiDbReadTableFromFile @@ -492,7 +518,7 @@ AcpiDbReadTableFromFile ( if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Couldn't get table from the file\n"); + AcpiOsPrintf ("Could not get table from the file\n"); return (Status); } @@ -505,8 +531,8 @@ AcpiDbReadTableFromFile ( * * FUNCTION: AcpiDbGetTableFromFile * - * PARAMETERS: Filename - File where table is located - * Table - Where a pointer to the table is returned + * PARAMETERS: Filename - File where table is located + * ReturnTable - Where a pointer to the table is returned * * RETURN: Status * diff --git a/sys/dev/acpi/acpica/Subsystem/dbhistry.c b/sys/dev/acpi/acpica/Subsystem/dbhistry.c index c17298300b2..20f4e7417bb 100644 --- a/sys/dev/acpi/acpica/Subsystem/dbhistry.c +++ b/sys/dev/acpi/acpica/Subsystem/dbhistry.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dbhistry - debugger HISTORY command - * xRevision: 29 $ + * xRevision: 32 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbhistry.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbhistry.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acdebug.h" @@ -166,7 +166,8 @@ AcpiDbAddToHistory ( /* Put command into the next available slot */ - ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, CommandLine); + ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, + CommandLine); AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum = AcpiGbl_NextCmdNum; @@ -209,7 +210,8 @@ AcpiDbAddToHistory ( ******************************************************************************/ void -AcpiDbDisplayHistory (void) +AcpiDbDisplayHistory ( + void) { ACPI_NATIVE_UINT i; UINT16 HistoryIndex; @@ -240,7 +242,7 @@ AcpiDbDisplayHistory (void) * PARAMETERS: CommandNumArg - String containing the number of the * command to be retrieved * - * RETURN: None + * RETURN: Pointer to the retrieved command. Null on error. * * DESCRIPTION: Get a command from the history buffer * @@ -289,6 +291,5 @@ AcpiDbGetFromHistory ( return (NULL); } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/dev/acpi/acpica/Subsystem/dbinput.c b/sys/dev/acpi/acpica/Subsystem/dbinput.c index ac357538afb..8c13ed080a8 100644 --- a/sys/dev/acpi/acpica/Subsystem/dbinput.c +++ b/sys/dev/acpi/acpica/Subsystem/dbinput.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbinput - user front-end to the AML debugger - * xRevision: 98 $ + * xRevision: 107 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbinput.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbinput.c,v 1.13 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acdebug.h" @@ -127,6 +127,29 @@ __KERNEL_RCSID(0, "$NetBSD: dbinput.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbinput") +/* Local prototypes */ + +static char * +AcpiDbGetNextToken ( + char *String, + char **Next); + +static UINT32 +AcpiDbGetLine ( + char *InputBuffer); + +static UINT32 +AcpiDbMatchCommand ( + char *UserCommand); + +static void +AcpiDbSingleThread ( + void); + +static void +AcpiDbDisplayHelp ( + char *HelpType); + /* * Top-level debugger commands. @@ -144,6 +167,7 @@ enum AcpiExDebuggerCommands CMD_CALL, CMD_CLOSE, CMD_DEBUG, + CMD_DISASSEMBLE, CMD_DUMP, CMD_ENABLEACPI, CMD_EVENT, @@ -178,6 +202,7 @@ enum AcpiExDebuggerCommands CMD_RESOURCES, CMD_RESULTS, CMD_SET, + CMD_SLEEP, CMD_STATS, CMD_STOP, CMD_TABLES, @@ -190,7 +215,6 @@ enum AcpiExDebuggerCommands #define CMD_FIRST_VALID 2 - static const COMMAND_INFO AcpiGbl_DbCommands[] = { {"<NOT FOUND>", 0}, @@ -202,6 +226,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"CALL", 0}, {"CLOSE", 0}, {"DEBUG", 1}, + {"DISASSEMBLE", 1}, {"DUMP", 1}, {"ENABLEACPI", 0}, {"EVENT", 1}, @@ -236,6 +261,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"RESOURCES", 1}, {"RESULTS", 0}, {"SET", 3}, + {"SLEEP", 1}, {"STATS", 0}, {"STOP", 0}, {"TABLES", 0}, @@ -260,12 +286,11 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = * ******************************************************************************/ -void +static void AcpiDbDisplayHelp ( char *HelpType) { - /* No parameter, just give the overview */ if (!HelpType) @@ -276,6 +301,7 @@ AcpiDbDisplayHelp ( AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n"); AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n"); AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n"); + AcpiOsPrintf (" [STATISTICS] Statistical Information\n"); AcpiOsPrintf (" [FILE] File I/O Commands\n"); return; } @@ -299,17 +325,32 @@ AcpiDbDisplayHelp ( AcpiOsPrintf ("Locks Current status of internal mutexes\n"); AcpiOsPrintf ("Quit or Exit Exit this command\n"); AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n"); - AcpiOsPrintf (" |Objects|Tables] Display namespace and memory statistics\n"); + AcpiOsPrintf (" |Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n"); AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n"); AcpiOsPrintf ("Unload <TableSig> [Instance] Unload an ACPI table\n"); AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n"); AcpiOsPrintf ("!! Execute last command again\n"); return; + case 'S': + AcpiOsPrintf ("\nStats Subcommands\n\n"); + AcpiOsPrintf ("Allocations Display list of current memory allocations\n"); + AcpiOsPrintf ("Memory Dump internal memory lists\n"); + AcpiOsPrintf ("Misc Namespace search and mutex stats\n"); + AcpiOsPrintf ("Objects Summary of namespace objects\n"); + AcpiOsPrintf ("Sizes Sizes for each of the internal objects\n"); + AcpiOsPrintf ("Stack Display CPU stack usage\n"); + AcpiOsPrintf ("Tables Info about current ACPI table(s)\n"); + return; + case 'N': AcpiOsPrintf ("\nNamespace Access Commands\n\n"); + AcpiOsPrintf ("Disassemble <Method> Disassemble a control method\n"); AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n"); AcpiOsPrintf ("Find <Name> (? is wildcard) Find ACPI name(s) with wildcards\n"); + AcpiOsPrintf ("Gpe <GpeNum> <GpeBlock> Simulate a GPE\n"); + AcpiOsPrintf ("Gpes Display info on all GPEs\n"); + AcpiOsPrintf ("Integrity Validate namespace integrity\n"); AcpiOsPrintf ("Method Display list of loaded control methods\n"); AcpiOsPrintf ("Namespace [<Addr>|<Path>] [Depth] Display loaded namespace tree/subtree\n"); AcpiOsPrintf ("Notify <NamePath> <Value> Send a notification\n"); @@ -318,8 +359,10 @@ AcpiDbDisplayHelp ( AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n"); AcpiOsPrintf ("References <Addr> Find all references to object at addr\n"); AcpiOsPrintf ("Resources xxx Get and display resources\n"); + AcpiOsPrintf ("Sleep <SleepState> Simulate sleep/wake sequence\n"); AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n"); + AcpiOsPrintf ("Type <Object> Display object type\n"); return; case 'M': @@ -368,7 +411,7 @@ AcpiDbDisplayHelp ( * ******************************************************************************/ -char * +static char * AcpiDbGetNextToken ( char *String, char **Next) @@ -427,14 +470,14 @@ AcpiDbGetNextToken ( * * PARAMETERS: InputBuffer - Command line buffer * - * RETURN: None + * RETURN: Count of arguments to the command * * DESCRIPTION: Get the next command line from the user. Gets entire line * up to the next newline * ******************************************************************************/ -UINT32 +static UINT32 AcpiDbGetLine ( char *InputBuffer) { @@ -445,7 +488,7 @@ AcpiDbGetLine ( ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer); - ACPI_STRUPR (AcpiGbl_DbParsedBuf); + AcpiUtStrupr (AcpiGbl_DbParsedBuf); This = AcpiGbl_DbParsedBuf; for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) @@ -463,7 +506,7 @@ AcpiDbGetLine ( if (AcpiGbl_DbArgs[0]) { - ACPI_STRUPR (AcpiGbl_DbArgs[0]); + AcpiUtStrupr (AcpiGbl_DbArgs[0]); } Count = i; @@ -488,7 +531,7 @@ AcpiDbGetLine ( * ******************************************************************************/ -UINT32 +static UINT32 AcpiDbMatchCommand ( char *UserCommand) { @@ -525,7 +568,7 @@ AcpiDbMatchCommand ( * * RETURN: Status * - * DESCRIPTION: Command dispatcher. Called from two places: + * DESCRIPTION: Command dispatcher. * ******************************************************************************/ @@ -558,7 +601,9 @@ AcpiDbCommandDispatch ( if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs) { AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n", - ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, AcpiGbl_DbCommands[CommandIndex].MinArgs); + ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, + AcpiGbl_DbCommands[CommandIndex].MinArgs); + return (AE_CTRL_TRUE); } @@ -602,6 +647,10 @@ AcpiDbCommandDispatch ( AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP); break; + case CMD_DISASSEMBLE: + AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]); + break; + case CMD_DUMP: AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; @@ -620,11 +669,12 @@ AcpiDbCommandDispatch ( break; case CMD_EXECUTE: - AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP); + AcpiDbExecute (AcpiGbl_DbArgs[1], + &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP); break; case CMD_FIND: - AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]); + Status = AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]); break; case CMD_GO: @@ -656,10 +706,6 @@ AcpiDbCommandDispatch ( } Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_TRUE; - } return (Status); case CMD_HISTORY_LAST: @@ -670,10 +716,6 @@ AcpiDbCommandDispatch ( } Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_TRUE; - } return (Status); case CMD_INFORMATION: @@ -695,20 +737,27 @@ AcpiDbCommandDispatch ( case CMD_LEVEL: if (ParamCount == 0) { - AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", AcpiGbl_DbDebugLevel); - AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", AcpiGbl_DbConsoleDebugLevel); + AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", + AcpiGbl_DbDebugLevel); + AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", + AcpiGbl_DbConsoleDebugLevel); } else if (ParamCount == 2) { Temp = AcpiGbl_DbConsoleDebugLevel; - AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); - AcpiOsPrintf ("Debug Level for console output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbConsoleDebugLevel); + AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], + NULL, 16); + AcpiOsPrintf ( + "Debug Level for console output was %8.8lX, now %8.8lX\n", + Temp, AcpiGbl_DbConsoleDebugLevel); } else { Temp = AcpiGbl_DbDebugLevel; AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); - AcpiOsPrintf ("Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel); + AcpiOsPrintf ( + "Debug Level for file output was %8.8lX, now %8.8lX\n", + Temp, AcpiGbl_DbDebugLevel); } break; @@ -718,10 +767,6 @@ AcpiDbCommandDispatch ( case CMD_LOAD: Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL); - if (ACPI_FAILURE (Status)) - { - return (Status); - } break; case CMD_LOCKS: @@ -733,7 +778,7 @@ AcpiDbCommandDispatch ( break; case CMD_METHODS: - AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]); + Status = AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]); break; case CMD_NAMESPACE: @@ -746,8 +791,8 @@ AcpiDbCommandDispatch ( break; case CMD_OBJECT: - ACPI_STRUPR (AcpiGbl_DbArgs[1]); - AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); + AcpiUtStrupr (AcpiGbl_DbArgs[1]); + Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; case CMD_OPEN: @@ -775,11 +820,16 @@ AcpiDbCommandDispatch ( break; case CMD_SET: - AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); + AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], + AcpiGbl_DbArgs[3]); + break; + + case CMD_SLEEP: + Status = AcpiDbSleep (AcpiGbl_DbArgs[1]); break; case CMD_STATS: - AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); + Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]); break; case CMD_STOP: @@ -793,13 +843,17 @@ AcpiDbCommandDispatch ( AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); AcpiUtSubsystemShutdown (); - /* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */ + /* + * TBD: [Restructure] Need some way to re-initialize without + * re-creating the semaphores! + */ /* AcpiInitialize (NULL); */ break; case CMD_THREADS: - AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); + AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], + AcpiGbl_DbArgs[3]); break; case CMD_TREE: @@ -827,13 +881,8 @@ AcpiDbCommandDispatch ( AcpiDbgLevel = ACPI_DEBUG_DEFAULT; } - /* Shutdown */ - - /* AcpiUtSubsystemShutdown (); */ AcpiDbCloseDebugFile (); - AcpiGbl_DbTerminateThreads = TRUE; - return (AE_CTRL_TERMINATE); case CMD_NOT_FOUND: @@ -842,6 +891,10 @@ AcpiDbCommandDispatch ( return (AE_CTRL_TRUE); } + if (ACPI_SUCCESS (Status)) + { + Status = AE_CTRL_TRUE; + } /* Add all commands that come here to the history buffer */ @@ -906,7 +959,7 @@ AcpiDbExecuteThread ( * ******************************************************************************/ -void +static void AcpiDbSingleThread ( void) { @@ -992,13 +1045,12 @@ AcpiDbUserCommands ( } /* - * Only this thread (the original thread) should actually terminate the subsystem, - * because all the semaphores are deleted during termination + * Only this thread (the original thread) should actually terminate the + * subsystem, because all the semaphores are deleted during termination */ Status = AcpiTerminate (); return (Status); } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/dev/acpi/acpica/Subsystem/dbstats.c b/sys/dev/acpi/acpica/Subsystem/dbstats.c index fe88609c8f3..532b3440b99 100644 --- a/sys/dev/acpi/acpica/Subsystem/dbstats.c +++ b/sys/dev/acpi/acpica/Subsystem/dbstats.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbstats - Generation and display of ACPI table statistics - * xRevision: 70 $ + * xRevision: 75 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbstats.c,v 1.13 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbstats.c,v 1.14 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acdebug.h" @@ -127,6 +127,24 @@ __KERNEL_RCSID(0, "$NetBSD: dbstats.c,v 1.13 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbstats") +/* Local prototypes */ + +static void +AcpiDbCountNamespaceObjects ( + void); + +static void +AcpiDbEnumerateObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +static ACPI_STATUS +AcpiDbClassifyOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + /* * Statistics subcommands */ @@ -165,7 +183,7 @@ static ARGUMENT_INFO AcpiDbStatTypes [] = * ******************************************************************************/ -void +static void AcpiDbEnumerateObject ( ACPI_OPERAND_OBJECT *ObjDesc) { @@ -177,7 +195,6 @@ AcpiDbEnumerateObject ( return; } - /* Enumerate this object first */ AcpiGbl_NumObjects++; @@ -263,7 +280,7 @@ AcpiDbEnumerateObject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbClassifyOneObject ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -287,7 +304,6 @@ AcpiDbClassifyOneObject ( { AcpiGbl_NodeTypeCountMisc++; } - else { AcpiGbl_NodeTypeCount [Type]++; @@ -296,8 +312,10 @@ AcpiDbClassifyOneObject ( return AE_OK; +#if ACPI_FUTURE_IMPLEMENTATION + /* TBD: These need to be counted during the initial parsing phase */ - /* + if (AcpiPsIsNamedOp (Op->Opcode)) { NumNodes++; @@ -311,12 +329,12 @@ AcpiDbClassifyOneObject ( NumGrammarElements++; Op = AcpiPsGetDepthNext (Root, Op); - SizeOfParseTree = (NumGrammarElements - NumMethodElements) * (UINT32) sizeof (ACPI_PARSE_OBJECT); - SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT); - SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE); - SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT); - - */ + SizeOfParseTree = (NumGrammarElements - NumMethodElements) * + (UINT32) sizeof (ACPI_PARSE_OBJECT); + SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT); + SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE); + SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT); +#endif } @@ -326,14 +344,14 @@ AcpiDbClassifyOneObject ( * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Count and classify the entire namespace, including all * namespace nodes and attached objects. * ******************************************************************************/ -void +static void AcpiDbCountNamespaceObjects ( void) { @@ -350,8 +368,8 @@ AcpiDbCountNamespaceObjects ( AcpiGbl_NodeTypeCount [i] = 0; } - (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - FALSE, AcpiDbClassifyOneObject, NULL, NULL); + (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL); } @@ -390,7 +408,7 @@ AcpiDbDisplayStatistics ( return (AE_OK); } - ACPI_STRUPR (TypeArg); + AcpiUtStrupr (TypeArg); Type = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); if (Type == (UINT32) -1) { @@ -402,6 +420,7 @@ AcpiDbDisplayStatistics ( switch (Type) { case CMD_STAT_ALLOCATIONS: + #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiUtDumpAllocationInfo (); #endif @@ -412,7 +431,8 @@ AcpiDbDisplayStatistics ( AcpiOsPrintf ("ACPI Table Information:\n\n"); if (AcpiGbl_DSDT) { - AcpiOsPrintf ("DSDT Length:................% 7ld (%X)\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length); + AcpiOsPrintf ("DSDT Length:................% 7ld (%X)\n", + AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length); } break; @@ -422,7 +442,8 @@ AcpiDbDisplayStatistics ( AcpiOsPrintf ("\nObjects defined in the current namespace:\n\n"); - AcpiOsPrintf ("%16.16s %10.10s %10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS"); + AcpiOsPrintf ("%16.16s %10.10s %10.10s\n", + "ACPI_TYPE", "NODES", "OBJECTS"); for (i = 0; i < ACPI_TYPE_NS_NODE_MAX; i++) { @@ -447,17 +468,19 @@ AcpiDbDisplayStatistics ( if (AcpiGbl_MemoryLists[i].MaxCacheDepth > 0) { - AcpiOsPrintf (" Cache: [Depth Max Avail Size] % 7d % 7d % 7d % 7d B\n", - AcpiGbl_MemoryLists[i].CacheDepth, - AcpiGbl_MemoryLists[i].MaxCacheDepth, - AcpiGbl_MemoryLists[i].MaxCacheDepth - AcpiGbl_MemoryLists[i].CacheDepth, - (AcpiGbl_MemoryLists[i].CacheDepth * AcpiGbl_MemoryLists[i].ObjectSize)); - - AcpiOsPrintf (" Cache: [Requests Hits Misses ObjSize] % 7d % 7d % 7d % 7d B\n", - AcpiGbl_MemoryLists[i].CacheRequests, - AcpiGbl_MemoryLists[i].CacheHits, - AcpiGbl_MemoryLists[i].CacheRequests - AcpiGbl_MemoryLists[i].CacheHits, - AcpiGbl_MemoryLists[i].ObjectSize); + AcpiOsPrintf ( + " Cache: [Depth Max Avail Size] % 7d % 7d % 7d % 7d B\n", + AcpiGbl_MemoryLists[i].CacheDepth, + AcpiGbl_MemoryLists[i].MaxCacheDepth, + AcpiGbl_MemoryLists[i].MaxCacheDepth - AcpiGbl_MemoryLists[i].CacheDepth, + (AcpiGbl_MemoryLists[i].CacheDepth * AcpiGbl_MemoryLists[i].ObjectSize)); + + AcpiOsPrintf ( + " Cache: [Requests Hits Misses ObjSize] % 7d % 7d % 7d % 7d B\n", + AcpiGbl_MemoryLists[i].CacheRequests, + AcpiGbl_MemoryLists[i].CacheHits, + AcpiGbl_MemoryLists[i].CacheRequests - AcpiGbl_MemoryLists[i].CacheHits, + AcpiGbl_MemoryLists[i].ObjectSize); } Outstanding = AcpiGbl_MemoryLists[i].TotalAllocated - @@ -473,10 +496,11 @@ AcpiDbDisplayStatistics ( Size = ACPI_ROUND_UP_TO_1K (AcpiGbl_MemoryLists[i].CurrentTotalSize); } - AcpiOsPrintf (" Mem: [Alloc Free Outstanding Size] % 7d % 7d % 7d % 7d Kb\n", - AcpiGbl_MemoryLists[i].TotalAllocated, - AcpiGbl_MemoryLists[i].TotalFreed, - Outstanding, Size); + AcpiOsPrintf ( + " Mem: [Alloc Free Outstanding Size] % 7d % 7d % 7d % 7d Kb\n", + AcpiGbl_MemoryLists[i].TotalAllocated, + AcpiGbl_MemoryLists[i].TotalFreed, + Outstanding, Size); } #endif @@ -485,15 +509,18 @@ AcpiDbDisplayStatistics ( case CMD_STAT_MISC: AcpiOsPrintf ("\nMiscellaneous Statistics:\n\n"); - AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n", AcpiGbl_PsFindCount); - AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n", AcpiGbl_NsLookupCount); + AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n", + AcpiGbl_PsFindCount); + AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n", + AcpiGbl_NsLookupCount); AcpiOsPrintf ("\n"); AcpiOsPrintf ("Mutex usage:\n\n"); for (i = 0; i < NUM_MUTEX; i++) { - AcpiOsPrintf ("%-28s: % 7ld\n", AcpiUtGetMutexName (i), AcpiGbl_MutexInfo[i].UseCount); + AcpiOsPrintf ("%-28s: % 7ld\n", + AcpiUtGetMutexName (i), AcpiGbl_MutexInfo[i].UseCount); } break; @@ -557,5 +584,4 @@ AcpiDbDisplayStatistics ( return (AE_OK); } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/dev/acpi/acpica/Subsystem/dbutils.c b/sys/dev/acpi/acpica/Subsystem/dbutils.c index 750aab17120..a2e7194c30c 100644 --- a/sys/dev/acpi/acpica/Subsystem/dbutils.c +++ b/sys/dev/acpi/acpica/Subsystem/dbutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbutils - AML debugger utilities - * xRevision: 66 $ + * xRevision: 73 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbutils.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbutils.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acparser.h" @@ -124,6 +124,7 @@ __KERNEL_RCSID(0, "$NetBSD: dbutils.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #include "acnamesp.h" #include "acdebug.h" #include "acdispat.h" +#include "acdisasm.h" #ifdef ACPI_DEBUGGER @@ -131,6 +132,18 @@ __KERNEL_RCSID(0, "$NetBSD: dbutils.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbutils") +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_STATUS +AcpiDbSecondPassParse ( + ACPI_PARSE_OBJECT *Root); + +void +AcpiDbDumpBuffer ( + UINT32 Address); +#endif + /******************************************************************************* * @@ -180,7 +193,7 @@ AcpiDbMatchArgument ( * * RETURN: None * - * DESCRIPTION: Set the current destination for debugger output. Alos sets + * DESCRIPTION: Set the current destination for debugger output. Also sets * the debug output level accordingly. * ******************************************************************************/ @@ -205,31 +218,6 @@ AcpiDbSetOutputDestination ( /******************************************************************************* * - * FUNCTION: AcpiDbDumpBuffer - * - * PARAMETERS: Address - Pointer to the buffer - * - * RETURN: None - * - * DESCRIPTION: Print a portion of a buffer - * - ******************************************************************************/ - -void -AcpiDbDumpBuffer ( - UINT32 Address) -{ - - AcpiOsPrintf ("\nLocation %X:\n", Address); - - AcpiDbgLevel |= ACPI_LV_TABLES; - AcpiUtDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY, - ACPI_UINT32_MAX); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDbDumpObject * * PARAMETERS: ObjDesc - External ACPI object to dump @@ -264,7 +252,8 @@ AcpiDbDumpObject ( { case ACPI_TYPE_ANY: - AcpiOsPrintf ("[Object Reference] = %p\n", ObjDesc->Reference.Handle); + AcpiOsPrintf ("[Object Reference] = ", ObjDesc->Reference.Handle); + AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); break; @@ -315,7 +304,8 @@ AcpiDbDumpObject ( case ACPI_TYPE_LOCAL_REFERENCE: - AcpiOsPrintf ("[Object Reference] = %p\n", ObjDesc->Reference.Handle); + AcpiOsPrintf ("[Object Reference] = ", ObjDesc->Reference.Handle); + AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); break; @@ -356,13 +346,12 @@ AcpiDbPrepNamestring ( char *Name) { - if (!Name) { return; } - ACPI_STRUPR (Name); + AcpiUtStrupr (Name); /* Convert a leading forward slash to a backslash */ @@ -395,6 +384,59 @@ AcpiDbPrepNamestring ( /******************************************************************************* * + * FUNCTION: AcpiDbLocalNsLookup + * + * PARAMETERS: Name - Name to lookup + * + * RETURN: Pointer to a namespace node, null on failure + * + * DESCRIPTION: Lookup a name in the ACPI namespace + * + * Note: Currently begins search from the root. Could be enhanced to use + * the current prefix (scope) node as the search beginning point. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + char *Name) +{ + char *InternalPath; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + + + AcpiDbPrepNamestring (Name); + + /* Build an internal namestring */ + + Status = AcpiNsInternalizeName (Name, &InternalPath); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Invalid namestring: %s\n", Name); + return (NULL); + } + + /* + * Lookup the name. + * (Uses root node as the search starting point) + */ + Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not locate name: %s %s\n", + Name, AcpiFormatException (Status)); + } + + ACPI_MEM_FREE (InternalPath); + return (Node); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * * FUNCTION: AcpiDbSecondPassParse * * PARAMETERS: Root - Root of the parse tree @@ -443,7 +485,8 @@ AcpiDbSecondPassParse ( WalkState->ParserState.Aml = WalkState->ParserState.AmlStart = Method->Named.Data; WalkState->ParserState.AmlEnd = - WalkState->ParserState.PkgEnd = Method->Named.Data + Method->Named.Length; + WalkState->ParserState.PkgEnd = Method->Named.Data + + Method->Named.Length; WalkState->ParserState.StartScope = Op; WalkState->DescendingCallback = AcpiDsLoad1BeginOp; @@ -488,55 +531,28 @@ AcpiDbSecondPassParse ( /******************************************************************************* * - * FUNCTION: AcpiDbLocalNsLookup - * - * PARAMETERS: Name - Name to lookup + * FUNCTION: AcpiDbDumpBuffer * - * RETURN: Pointer to a namespace node + * PARAMETERS: Address - Pointer to the buffer * - * DESCRIPTION: Lookup a name in the ACPI namespace + * RETURN: None * - * Note: Currently begins search from the root. Could be enhanced to use - * the current prefix (scope) node as the search beginning point. + * DESCRIPTION: Print a portion of a buffer * ******************************************************************************/ -ACPI_NAMESPACE_NODE * -AcpiDbLocalNsLookup ( - char *Name) +void +AcpiDbDumpBuffer ( + UINT32 Address) { - char *InternalPath; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node = NULL; + AcpiOsPrintf ("\nLocation %X:\n", Address); - AcpiDbPrepNamestring (Name); - - /* Build an internal namestring */ - - Status = AcpiNsInternalizeName (Name, &InternalPath); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Invalid namestring: %s\n", Name); - return (NULL); - } - - /* - * Lookup the name. - * (Uses root node as the search starting point) - */ - Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not locate name: %s %s\n", - Name, AcpiFormatException (Status)); - } - - ACPI_MEM_FREE (InternalPath); - return (Node); + AcpiDbgLevel |= ACPI_LV_TABLES; + AcpiUtDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY, + ACPI_UINT32_MAX); } - +#endif #endif /* ACPI_DEBUGGER */ diff --git a/sys/dev/acpi/acpica/Subsystem/dbxface.c b/sys/dev/acpi/acpica/Subsystem/dbxface.c index 57a6e261e84..ce145b5fbe2 100644 --- a/sys/dev/acpi/acpica/Subsystem/dbxface.c +++ b/sys/dev/acpi/acpica/Subsystem/dbxface.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbxface - AML Debugger external interfaces - * xRevision: 71 $ + * xRevision: 75 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dbxface.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dbxface.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "amlcode.h" @@ -130,11 +130,26 @@ __KERNEL_RCSID(0, "$NetBSD: dbxface.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); ACPI_MODULE_NAME ("dbxface") +/* Local prototypes */ + +static ACPI_STATUS +AcpiDbStartCommand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +void +AcpiDbMethodEnd ( + ACPI_WALK_STATE *WalkState); +#endif + + /******************************************************************************* * * FUNCTION: AcpiDbStartCommand * * PARAMETERS: WalkState - Current walk + * Op - Current executing Op, from AML interpreter * * RETURN: Status * @@ -142,7 +157,7 @@ __KERNEL_RCSID(0, "$NetBSD: dbxface.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbStartCommand ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) @@ -150,7 +165,7 @@ AcpiDbStartCommand ( ACPI_STATUS Status; - /* TBD: [Investigate] what are the namespace locking issues here */ + /* TBD: [Investigate] are there namespace locking issues here? */ /* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */ @@ -211,38 +226,10 @@ AcpiDbStartCommand ( /******************************************************************************* * - * FUNCTION: AcpiDbMethodEnd - * - * PARAMETERS: WalkState - Current walk - * - * RETURN: Status - * - * DESCRIPTION: - * - ******************************************************************************/ - -void -AcpiDbMethodEnd ( - ACPI_WALK_STATE *WalkState) -{ - - if (!AcpiGbl_CmSingleStep) - { - return; - } - - AcpiOsPrintf ("<Method Terminating>\n"); - - AcpiDbStartCommand (WalkState, NULL); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDbSingleStep * * PARAMETERS: WalkState - Current walk - * Op - Current executing op + * Op - Current executing op (from aml interpreter) * OpcodeClass - Class of the current AML Opcode * * RETURN: Status @@ -294,7 +281,8 @@ AcpiDbSingleStep ( else if (WalkState->UserBreakpoint && (WalkState->UserBreakpoint == Op->Common.AmlOffset)) { - AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", Op->Common.AmlOffset); + AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", + Op->Common.AmlOffset); AcpiGbl_CmSingleStep = TRUE; AcpiGbl_StepToNextCall = FALSE; WalkState->MethodBreakpoint = 0; @@ -334,9 +322,9 @@ AcpiDbSingleStep ( } /* - * Display this op (and only this op - zero out the NEXT field temporarily, - * and disable parser trace output for the duration of the display because - * we don't want the extraneous debug output) + * Display this op (and only this op - zero out the NEXT field + * temporarily, and disable parser trace output for the duration of + * the display because we don't want the extraneous debug output) */ OriginalDebugLevel = AcpiDbgLevel; AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS); @@ -349,7 +337,8 @@ AcpiDbSingleStep ( if (ParentOp) { if ((WalkState->ControlState) && - (WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING)) + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING)) { /* * We are executing the predicate of an IF or WHILE statement @@ -449,10 +438,14 @@ AcpiDbSingleStep ( */ if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP) { - AcpiGbl_CmSingleStep = FALSE; /* No more single step while executing called method */ + /* Force no more single stepping while executing called method */ - /* Set the breakpoint on/before the call, it will stop execution as soon as we return */ + AcpiGbl_CmSingleStep = FALSE; + /* + * Set the breakpoint on/before the call, it will stop execution + * as soon as we return + */ WalkState->MethodBreakpoint = 1; /* Must be non-zero! */ } @@ -478,7 +471,8 @@ AcpiDbSingleStep ( ******************************************************************************/ ACPI_STATUS -AcpiDbInitialize (void) +AcpiDbInitialize ( + void) { ACPI_STATUS Status; @@ -561,14 +555,15 @@ AcpiDbInitialize (void) * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Stop debugger * ******************************************************************************/ void -AcpiDbTerminate (void) +AcpiDbTerminate ( + void) { if (AcpiGbl_DbTablePtr) @@ -582,4 +577,33 @@ AcpiDbTerminate (void) } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiDbMethodEnd + * + * PARAMETERS: WalkState - Current walk + * + * RETURN: Status + * + * DESCRIPTION: Called at method termination + * + ******************************************************************************/ + +void +AcpiDbMethodEnd ( + ACPI_WALK_STATE *WalkState) +{ + + if (!AcpiGbl_CmSingleStep) + { + return; + } + + AcpiOsPrintf ("<Method Terminating>\n"); + + AcpiDbStartCommand (WalkState, NULL); +} +#endif + #endif /* ACPI_DEBUGGER */ diff --git a/sys/dev/acpi/acpica/Subsystem/dmbuffer.c b/sys/dev/acpi/acpica/Subsystem/dmbuffer.c index ddf54a4441c..0b8c9b08f7a 100644 --- a/sys/dev/acpi/acpica/Subsystem/dmbuffer.c +++ b/sys/dev/acpi/acpica/Subsystem/dmbuffer.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmbuffer - AML disassembler, buffer and string support - * xRevision: 13 $ + * xRevision: 17 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmbuffer.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmbuffer.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acdisasm.h" @@ -129,6 +129,12 @@ __KERNEL_RCSID(0, "$NetBSD: dmbuffer.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmbuffer") +/* Local prototypes */ + +static void +AcpiDmUnicode ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -140,7 +146,7 @@ __KERNEL_RCSID(0, "$NetBSD: dmbuffer.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); * * RETURN: None * - * DESCRIPTION: Dump a list of bytes in Hex format + * DESCRIPTION: Dump an AML "ByteList" in Hex format * ******************************************************************************/ @@ -324,7 +330,7 @@ AcpiDmIsUnicodeBuffer ( * * PARAMETERS: Op - Buffer Object to be examined * - * RETURN: TRUE if buffer contains a ASCII string + * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise * * DESCRIPTION: Determine if a buffer Op contains a ASCII string * @@ -396,7 +402,7 @@ AcpiDmIsStringBuffer ( * ******************************************************************************/ -void +static void AcpiDmUnicode ( ACPI_PARSE_OBJECT *Op) { diff --git a/sys/dev/acpi/acpica/Subsystem/dmnames.c b/sys/dev/acpi/acpica/Subsystem/dmnames.c index 5e0567bcb3f..89a33d470c2 100644 --- a/sys/dev/acpi/acpica/Subsystem/dmnames.c +++ b/sys/dev/acpi/acpica/Subsystem/dmnames.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmnames - AML disassembler, names, namestrings, pathnames - * xRevision: 7 $ + * xRevision: 11 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmnames.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmnames.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acparser.h" @@ -130,61 +130,14 @@ __KERNEL_RCSID(0, "$NetBSD: dmnames.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmnames") +/* Local prototypes */ -/******************************************************************************* - * - * FUNCTION: AcpiDmValidateName - * - * PARAMETERS: Name - 4 character ACPI name - * - * RETURN: None - * - * DESCRIPTION: Lookup the name - * - ******************************************************************************/ - +#ifdef ACPI_OBSOLETE_FUNCTIONS void -AcpiDmValidateName ( - char *Name, - ACPI_PARSE_OBJECT *Op) -{ - -#if 0 - if ((!Name) || - (!Op->Common.Parent)) - { - return; - } - - if (!Op->Common.Node) - { - AcpiOsPrintf (" /**** Name not found or not accessible from this scope ****/ "); - } - - ACPI_PARSE_OBJECT *TargetOp; - - - if ((!Name) || - (!Op->Common.Parent)) - { - return; - } - - TargetOp = AcpiPsFind (Op, Name, 0, 0); - if (!TargetOp) - { - /* - * Didn't find the name in the parse tree. This may be - * a problem, or it may simply be one of the predefined names - * (such as _OS_). Rather than worry about looking up all - * the predefined names, just display the name as given - */ - AcpiOsPrintf (" /**** Name not found or not accessible from this scope ****/ "); - } +AcpiDmDisplayPath ( + ACPI_PARSE_OBJECT *Op); #endif -} - /******************************************************************************* * @@ -264,8 +217,9 @@ AcpiPsDisplayObjectPathname ( { /* Node not defined in this scope, look it up */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { @@ -313,7 +267,7 @@ Exit: * * RETURN: None * - * DESCRIPTION: Decode an ACPI namestring. Handles prefix characters + * DESCRIPTION: Decode and dump an ACPI namestring. Handles prefix characters * ******************************************************************************/ @@ -378,6 +332,7 @@ AcpiDmNamestring ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * * FUNCTION: AcpiDmDisplayPath @@ -497,6 +452,61 @@ AcpiDmDisplayPath ( } } + +/******************************************************************************* + * + * FUNCTION: AcpiDmValidateName + * + * PARAMETERS: Name - 4 character ACPI name + * + * RETURN: None + * + * DESCRIPTION: Lookup the name + * + ******************************************************************************/ + +void +AcpiDmValidateName ( + char *Name, + ACPI_PARSE_OBJECT *Op) +{ + + if ((!Name) || + (!Op->Common.Parent)) + { + return; + } + + if (!Op->Common.Node) + { + AcpiOsPrintf ( + " /**** Name not found or not accessible from this scope ****/ "); + } + + ACPI_PARSE_OBJECT *TargetOp; + + + if ((!Name) || + (!Op->Common.Parent)) + { + return; + } + + TargetOp = AcpiPsFind (Op, Name, 0, 0); + if (!TargetOp) + { + /* + * Didn't find the name in the parse tree. This may be + * a problem, or it may simply be one of the predefined names + * (such as _OS_). Rather than worry about looking up all + * the predefined names, just display the name as given + */ + AcpiOsPrintf ( + " /**** Name not found or not accessible from this scope ****/ "); + } +} +#endif + #endif diff --git a/sys/dev/acpi/acpica/Subsystem/dmobject.c b/sys/dev/acpi/acpica/Subsystem/dmobject.c index 2c02356f1c3..0085a6a5c9b 100644 --- a/sys/dev/acpi/acpica/Subsystem/dmobject.c +++ b/sys/dev/acpi/acpica/Subsystem/dmobject.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmobject - ACPI object decode and display - * xRevision: 11 $ + * xRevision: 17 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmobject.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmobject.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "amlcode.h" @@ -130,8 +130,14 @@ __KERNEL_RCSID(0, "$NetBSD: dmobject.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmnames") +/* Local prototypes */ -/***************************************************************************** +static void +AcpiDmDecodeNode ( + ACPI_NAMESPACE_NODE *Node); + + +/******************************************************************************* * * FUNCTION: AcpiDmDumpMethodInfo * @@ -145,7 +151,7 @@ __KERNEL_RCSID(0, "$NetBSD: dmobject.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); * Dumps the method execution stack, and the method locals/args, * and disassembles the AML opcode that failed. * - ****************************************************************************/ + ******************************************************************************/ void AcpiDmDumpMethodInfo ( @@ -174,6 +180,17 @@ AcpiDmDumpMethodInfo ( return; } + /* + * If there is no Thread, we are not actually executing a method. + * This can happen when the iASL compiler calls the interpreter + * to perform constant folding. + */ + Thread = WalkState->Thread; + if (!Thread) + { + return; + } + /* Display exception and method name */ AcpiOsPrintf ("\n**** Exception %s during execution of method ", @@ -183,7 +200,6 @@ AcpiDmDumpMethodInfo ( /* Display stack of executing methods */ AcpiOsPrintf ("\n\nMethod Execution Stack:\n"); - Thread = WalkState->Thread; NextWalkState = Thread->WalkStateList; /* Walk list of linked walk states */ @@ -239,7 +255,7 @@ AcpiDmDumpMethodInfo ( * * RETURN: None * - * DESCRIPTION: Short display of an internal object. Numbers and Strings. + * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers. * ******************************************************************************/ @@ -319,12 +335,11 @@ AcpiDmDecodeInternalObject ( * ******************************************************************************/ -void +static void AcpiDmDecodeNode ( ACPI_NAMESPACE_NODE *Node) { - AcpiOsPrintf ("<Node> Name %4.4s", AcpiUtGetNodeName (Node)); @@ -408,7 +423,8 @@ AcpiDmDisplayInternalObject ( AcpiOsPrintf ("[Local%d] ", ObjDesc->Reference.Offset); if (WalkState) { - ObjDesc = WalkState->LocalVariables[ObjDesc->Reference.Offset].Object; + ObjDesc = WalkState->LocalVariables[ + ObjDesc->Reference.Offset].Object; AcpiOsPrintf ("%p", ObjDesc); AcpiDmDecodeInternalObject (ObjDesc); } @@ -420,7 +436,8 @@ AcpiDmDisplayInternalObject ( AcpiOsPrintf ("[Arg%d] ", ObjDesc->Reference.Offset); if (WalkState) { - ObjDesc = WalkState->Arguments[ObjDesc->Reference.Offset].Object; + ObjDesc = WalkState->Arguments[ + ObjDesc->Reference.Offset].Object; AcpiOsPrintf ("%p", ObjDesc); AcpiDmDecodeInternalObject (ObjDesc); } @@ -452,7 +469,8 @@ AcpiDmDisplayInternalObject ( } else { - AcpiDmDecodeInternalObject (*(ObjDesc->Reference.Where)); + AcpiDmDecodeInternalObject ( + *(ObjDesc->Reference.Where)); } break; @@ -496,6 +514,10 @@ AcpiDmDisplayInternalObject ( } break; + case AML_INT_NAMEPATH_OP: + + AcpiDmDecodeNode (ObjDesc->Reference.Node); + break; default: @@ -530,7 +552,7 @@ AcpiDmDisplayInternalObject ( * * FUNCTION: AcpiDmDisplayLocals * - * PARAMETERS: None + * PARAMETERS: WalkState - State for current method * * RETURN: None * @@ -551,7 +573,8 @@ AcpiDmDisplayLocals ( Node = WalkState->MethodNode; if (!Node) { - AcpiOsPrintf ("No method node (Executing subtree for buffer or opregion)\n"); + AcpiOsPrintf ( + "No method node (Executing subtree for buffer or opregion)\n"); return; } @@ -577,7 +600,7 @@ AcpiDmDisplayLocals ( * * FUNCTION: AcpiDmDisplayArguments * - * PARAMETERS: None + * PARAMETERS: WalkState - State for current method * * RETURN: None * @@ -600,7 +623,8 @@ AcpiDmDisplayArguments ( Node = WalkState->MethodNode; if (!Node) { - AcpiOsPrintf ("No method node (Executing subtree for buffer or opregion)\n"); + AcpiOsPrintf ( + "No method node (Executing subtree for buffer or opregion)\n"); return; } @@ -613,8 +637,9 @@ AcpiDmDisplayArguments ( NumArgs = ObjDesc->Method.ParamCount; Concurrency = ObjDesc->Method.Concurrency; - AcpiOsPrintf ("Arguments for Method [%4.4s]: (%X arguments defined, max concurrency = %X)\n", - AcpiUtGetNodeName (Node), NumArgs, Concurrency); + AcpiOsPrintf ( + "Arguments for Method [%4.4s]: (%X arguments defined, max concurrency = %X)\n", + AcpiUtGetNodeName (Node), NumArgs, Concurrency); for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { diff --git a/sys/dev/acpi/acpica/Subsystem/dmopcode.c b/sys/dev/acpi/acpica/Subsystem/dmopcode.c index 9e204edecc6..9e3900fe078 100644 --- a/sys/dev/acpi/acpica/Subsystem/dmopcode.c +++ b/sys/dev/acpi/acpica/Subsystem/dmopcode.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmopcode - AML disassembler, specific AML opcodes - * xRevision: 85 $ + * xRevision: 89 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmopcode.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmopcode.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acparser.h" @@ -127,6 +127,12 @@ __KERNEL_RCSID(0, "$NetBSD: dmopcode.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmopcode") +/* Local prototypes */ + +static void +AcpiDmMatchKeyword ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -331,7 +337,7 @@ AcpiDmMatchOp ( * ******************************************************************************/ -void +static void AcpiDmMatchKeyword ( ACPI_PARSE_OBJECT *Op) { @@ -343,7 +349,8 @@ AcpiDmMatchKeyword ( } else { - AcpiOsPrintf ("%s", (char *) AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]); + AcpiOsPrintf ("%s", (char *) + AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]); } } @@ -516,14 +523,14 @@ AcpiDmDisassembleOneOp ( case AML_INT_NAMEPATH_OP: AcpiDmNamestring (Op->Common.Value.Name); - AcpiDmValidateName (Op->Common.Value.Name, Op); break; case AML_INT_NAMEDFIELD_OP: Length = AcpiDmDumpName ((char *) &Op->Named.Name); - AcpiOsPrintf (",%*.s %d", (int) (5 - Length), " ", (UINT32) Op->Common.Value.Integer); + AcpiOsPrintf (",%*.s %d", (int) (5 - Length), " ", + (UINT32) Op->Common.Value.Integer); AcpiDmCommaIfFieldMember (Op); Info->BitOffset += (UINT32) Op->Common.Value.Integer; @@ -593,7 +600,8 @@ AcpiDmDisassembleOneOp ( (WalkState->Results->Results.NumResults)) { AcpiDmDecodeInternalObject ( - WalkState->Results->Results.ObjDesc [WalkState->Results->Results.NumResults-1]); + WalkState->Results->Results.ObjDesc [ + WalkState->Results->Results.NumResults-1]); } #endif break; diff --git a/sys/dev/acpi/acpica/Subsystem/dmresrc.c b/sys/dev/acpi/acpica/Subsystem/dmresrc.c index 4e85fcf87da..b02c74682f2 100644 --- a/sys/dev/acpi/acpica/Subsystem/dmresrc.c +++ b/sys/dev/acpi/acpica/Subsystem/dmresrc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmresrc.c - Resource Descriptor disassembly - * xRevision: 13 $ + * xRevision: 18 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmresrc.c,v 1.7 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmresrc.c,v 1.8 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "amlcode.h" @@ -217,7 +217,8 @@ AcpiDmResourceDescriptor ( if (CurrentByte & ACPI_RDESC_TYPE_LARGE) { DescriptorId = CurrentByte; - Length = (* (ACPI_CAST_PTR (UINT16, &ByteData[CurrentByteOffset + 1]))); + Length = (* (ACPI_CAST_PTR (UINT16, + &ByteData[CurrentByteOffset + 1]))); CurrentByteOffset += 3; } else @@ -296,8 +297,8 @@ AcpiDmResourceDescriptor ( if (DependentFns) { /* - * Close an open StartDependentDescriptor. This indicates a missing - * EndDependentDescriptor. + * Close an open StartDependentDescriptor. This indicates a + * missing EndDependentDescriptor. */ Level--; DependentFns = FALSE; @@ -305,11 +306,11 @@ AcpiDmResourceDescriptor ( AcpiOsPrintf ("}\n"); AcpiDmIndent (Level); - AcpiOsPrintf ("/*** Missing EndDependentFunctions descriptor */"); + AcpiOsPrintf ("//*** Missing EndDependentFunctions descriptor"); /* - * We could fix the problem, but then the ASL would not match the AML - * So, we don't do this: + * We could fix the problem, but then the ASL would not match + * the AML, so we don't do this: * AcpiDmEndDependentDescriptor (DescriptorBody, Length, Level); */ } @@ -373,6 +374,12 @@ AcpiDmResourceDescriptor ( break; + case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: + + AcpiDmExtendedDescriptor (DescriptorBody, Length, Level); + break; + + default: /* * Anything else is unrecognized. @@ -381,7 +388,7 @@ AcpiDmResourceDescriptor ( * validated, this is a very serious error indicating that someone * overwrote the buffer. */ - AcpiOsPrintf ("/* Unknown Resource type (%X) */\n", DescriptorId); + AcpiOsPrintf ("//*** Unknown Resource type (%X)\n", DescriptorId); return; } } @@ -463,7 +470,8 @@ AcpiDmIsResourceDescriptor ( if (CurrentByte & ACPI_RDESC_TYPE_LARGE) { DescriptorId = CurrentByte; - Length = (* (ACPI_CAST_PTR (UINT16, (&ByteData[CurrentByteOffset + 1])))); + Length = (* (ACPI_CAST_PTR (UINT16, + (&ByteData[CurrentByteOffset + 1])))); CurrentByteOffset += 3; } else @@ -502,6 +510,7 @@ AcpiDmIsResourceDescriptor ( case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: case ACPI_RDESC_TYPE_EXTENDED_XRUPT: case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: + case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: /* Valid descriptor ID, keep going */ @@ -535,5 +544,4 @@ AcpiDmIsResourceDescriptor ( return (FALSE); } - #endif diff --git a/sys/dev/acpi/acpica/Subsystem/dmresrcl.c b/sys/dev/acpi/acpica/Subsystem/dmresrcl.c index 46d3f83742e..2d66d8b8672 100644 --- a/sys/dev/acpi/acpica/Subsystem/dmresrcl.c +++ b/sys/dev/acpi/acpica/Subsystem/dmresrcl.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmresrcl.c - "Large" Resource Descriptor disassembly - * xRevision: 12 $ + * xRevision: 21 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmresrcl.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmresrcl.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acdisasm.h" @@ -127,6 +127,53 @@ __KERNEL_RCSID(0, "$NetBSD: dmresrcl.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbresrcl") +/* Local prototypes */ + +static void +AcpiDmSpaceFlags ( + UINT8 Flags); + +static void +AcpiDmIoFlags ( + UINT8 Flags); + +static void +AcpiDmIoFlags2 ( + UINT8 SpecificFlags); + +static void +AcpiDmMemoryFlags ( + UINT8 Flags, + UINT8 SpecificFlags); + +static void +AcpiDmMemoryFlags2 ( + UINT8 SpecificFlags); + + +/******************************************************************************* + * + * FUNCTION: AcpiDmSpaceFlags + * + * PARAMETERS: Flags - Flag byte to be decoded + * + * RETURN: None + * + * DESCRIPTION: Decode the flags specific to Space Address space descriptors + * + ******************************************************************************/ + +static void +AcpiDmSpaceFlags ( + UINT8 Flags) +{ + AcpiOsPrintf ("%s, %s, %s, %s,", + AcpiGbl_ConsumeDecode [(Flags & 1)], + AcpiGbl_DECDecode [(Flags & 0x2) >> 1], + AcpiGbl_MinDecode [(Flags & 0x4) >> 2], + AcpiGbl_MaxDecode [(Flags & 0x8) >> 3]); +} + /******************************************************************************* * @@ -140,7 +187,7 @@ __KERNEL_RCSID(0, "$NetBSD: dmresrcl.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); * ******************************************************************************/ -void +static void AcpiDmIoFlags ( UINT8 Flags) { @@ -154,6 +201,35 @@ AcpiDmIoFlags ( /******************************************************************************* * + * FUNCTION: AcpiDmIoFlags2 + * + * PARAMETERS: SpecificFlags - "Specific" flag byte to be decoded + * + * RETURN: None + * + * DESCRIPTION: Decode the flags specific to IO Address space descriptors + * + ******************************************************************************/ + +static void +AcpiDmIoFlags2 ( + UINT8 SpecificFlags) +{ + AcpiOsPrintf (", %s", + AcpiGbl_TTPDecode [(SpecificFlags & 0x10) >> 4]); + + /* TRS is only used if TTP is TypeTranslation */ + + if (SpecificFlags & 0x10) + { + AcpiOsPrintf (", %s", + AcpiGbl_TRSDecode [(SpecificFlags & 0x20) >> 5]); + } +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmMemoryFlags * * PARAMETERS: Flags - Flag byte to be decoded @@ -165,7 +241,7 @@ AcpiDmIoFlags ( * ******************************************************************************/ -void +static void AcpiDmMemoryFlags ( UINT8 Flags, UINT8 SpecificFlags) @@ -182,6 +258,28 @@ AcpiDmMemoryFlags ( /******************************************************************************* * + * FUNCTION: AcpiDmMemoryFlags2 + * + * PARAMETERS: SpecificFlags - "Specific" flag byte to be decoded + * + * RETURN: None + * + * DESCRIPTION: Decode flags specific to Memory Address Space descriptors + * + ******************************************************************************/ + +static void +AcpiDmMemoryFlags2 ( + UINT8 SpecificFlags) +{ + AcpiOsPrintf (", %s, %s", + AcpiGbl_MTPDecode [(SpecificFlags & 0x18) >> 3], + AcpiGbl_TTPDecode [(SpecificFlags & 0x20) >> 5]); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmWordDescriptor * * PARAMETERS: Resource - Pointer to the resource descriptor @@ -202,31 +300,40 @@ AcpiDmWordDescriptor ( { AcpiDmIndent (Level); - AcpiOsPrintf ("%s (", - AcpiGbl_WordDecode [(Resource->ResourceType & 3)]); + if (Resource->ResourceType >= 0xC0) + { + AcpiOsPrintf ("WordSpace (0x%2.2X, ", Resource->ResourceType); + AcpiDmSpaceFlags (Resource->Flags); + AcpiOsPrintf (" 0x%2.2X,", Resource->SpecificFlags); + } + else + { + AcpiOsPrintf ("%s (", + AcpiGbl_WordDecode [(Resource->ResourceType & 3)]); - AcpiDmIoFlags (Resource->Flags); + AcpiDmIoFlags (Resource->Flags); - if ((Resource->ResourceType & 0x3) == 1) - { - AcpiOsPrintf (" %s,", - AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); + if ((Resource->ResourceType & 0x3) == 1) + { + AcpiOsPrintf (" %s,", + AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); + } } /* The WORD values */ AcpiOsPrintf ("\n"); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%4.4X,\n", + AcpiOsPrintf ("0x%4.4X, // Address Space Granularity\n", (UINT32) Resource->Granularity); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%4.4X,\n", + AcpiOsPrintf ("0x%4.4X, // Address Range Minimum\n", (UINT32) Resource->AddressMin); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%4.4X,\n", + AcpiOsPrintf ("0x%4.4X, // Address Range Maximum\n", (UINT32) Resource->AddressMax); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%4.4X,\n", + AcpiOsPrintf ("0x%4.4X, // Address Translation Offset\n", (UINT32) Resource->TranslationOffset); AcpiDmIndent (Level + 1); AcpiOsPrintf ("0x%4.4X", @@ -238,12 +345,34 @@ AcpiDmWordDescriptor ( { AcpiOsPrintf (", 0x%2.2X", (UINT32) Resource->OptionalFields[0]); + if (Length > 14) + { + AcpiOsPrintf (", %s", + &Resource->OptionalFields[1]); + } + else + { + AcpiOsPrintf (",,"); + } + } + else + { + AcpiOsPrintf (",,,"); } - if (Length > 14) + /* Type-specific flags */ + + if (Resource->ResourceType == ACPI_IO_RANGE) { - AcpiOsPrintf (", %s", - &Resource->OptionalFields[1]); + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + AcpiDmIoFlags2 (Resource->SpecificFlags); + } + else if (Resource->ResourceType == ACPI_MEMORY_RANGE) + { + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + AcpiDmMemoryFlags2 (Resource->SpecificFlags); } AcpiOsPrintf (")\n"); } @@ -271,34 +400,43 @@ AcpiDmDwordDescriptor ( { AcpiDmIndent (Level); - AcpiOsPrintf ("D%s (", - AcpiGbl_WordDecode [(Resource->ResourceType & 3)]); - - if ((Resource->ResourceType & 0x3) == 1) + if (Resource->ResourceType >= 0xC0) { - AcpiDmIoFlags (Resource->Flags); - AcpiOsPrintf (" %s,", - AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); + AcpiOsPrintf ("DWordSpace (0x%2.2X, ", Resource->ResourceType); + AcpiDmSpaceFlags (Resource->Flags); + AcpiOsPrintf (" 0x%2.2X,", Resource->SpecificFlags); } else { - AcpiDmMemoryFlags (Resource->Flags, Resource->SpecificFlags); + AcpiOsPrintf ("D%s (", + AcpiGbl_WordDecode [(Resource->ResourceType & 3)]); + + if ((Resource->ResourceType & 0x3) == 1) + { + AcpiDmIoFlags (Resource->Flags); + AcpiOsPrintf (" %s,", + AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); + } + else + { + AcpiDmMemoryFlags (Resource->Flags, Resource->SpecificFlags); + } } /* The DWORD values */ AcpiOsPrintf ("\n"); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X,\n", + AcpiOsPrintf ("0x%8.8X, // Address Space Granularity\n", Resource->Granularity); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X,\n", + AcpiOsPrintf ("0x%8.8X, // Address Range Minimum\n", Resource->AddressMin); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X,\n", + AcpiOsPrintf ("0x%8.8X, // Address Range Maximum\n", Resource->AddressMax); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X,\n", + AcpiOsPrintf ("0x%8.8X, // Address Translation Offset\n", Resource->TranslationOffset); AcpiDmIndent (Level + 1); AcpiOsPrintf ("0x%8.8X", @@ -310,11 +448,34 @@ AcpiDmDwordDescriptor ( { AcpiOsPrintf (", 0x%2.2X", Resource->OptionalFields[0]); + if (Length > 24) + { + AcpiOsPrintf (", %s", + &Resource->OptionalFields[1]); + } + else + { + AcpiOsPrintf (",,"); + } } - if (Length > 24) + else { - AcpiOsPrintf (", %s", - &Resource->OptionalFields[1]); + AcpiOsPrintf (",,,"); + } + + /* Type-specific flags */ + + if (Resource->ResourceType == ACPI_IO_RANGE) + { + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + AcpiDmIoFlags2 (Resource->SpecificFlags); + } + else if (Resource->ResourceType == ACPI_MEMORY_RANGE) + { + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + AcpiDmMemoryFlags2 (Resource->SpecificFlags); } AcpiOsPrintf (")\n"); } @@ -322,6 +483,104 @@ AcpiDmDwordDescriptor ( /******************************************************************************* * + * FUNCTION: AcpiDmExtendedDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a Extended Address Space descriptor + * + ******************************************************************************/ + +void +AcpiDmExtendedDescriptor ( + ASL_EXTENDED_ADDRESS_DESC *Resource, + UINT32 Length, + UINT32 Level) +{ + + AcpiDmIndent (Level); + if (Resource->ResourceType >= 0xC0) + { + AcpiOsPrintf ("ExtendedSpace (0x%2.2X, ", Resource->ResourceType); + AcpiDmSpaceFlags (Resource->Flags); + AcpiOsPrintf (" 0x%2.2X,", Resource->SpecificFlags); + } + else + { + if (Resource->ResourceType == ACPI_IO_RANGE) + { + AcpiOsPrintf ("ExtendedIO ("); + AcpiDmIoFlags (Resource->Flags); + AcpiOsPrintf (" %s,", + AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); + } + else + { + AcpiOsPrintf ("ExtendedMemory ("); + AcpiDmMemoryFlags (Resource->Flags, Resource->SpecificFlags); + } + } + + /* The QWORD values */ + + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%8.8X%8.8X, // Address Space Granularity\n", + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->Granularity))); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%8.8X%8.8X, // Address Range Minimum\n", + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->AddressMin))); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%8.8X%8.8X, // Address Range Maximum\n", + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->AddressMax))); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%8.8X%8.8X, // Address Translation Offset\n", + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->TranslationOffset))); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%8.8X%8.8X, // Address Length\n", + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->AddressLength))); + + /* Type-specific flags */ + + AcpiDmIndent (Level + 1); + if (Resource->ResourceType == ACPI_IO_RANGE) + { + AcpiOsPrintf ("0x%8.8X%8.8X, // Type Specific Attributes\n", + ACPI_FORMAT_UINT64 ( + ACPI_GET_ADDRESS (Resource->TypeSpecificAttributes))); + AcpiDmIndent (Level + 1); + AcpiDmIoFlags2 (Resource->SpecificFlags); + AcpiOsPrintf (")\n"); + } + else if (Resource->ResourceType == ACPI_MEMORY_RANGE) + { + AcpiOsPrintf ("0x%8.8X%8.8X, // Type Specific Attributes\n", + ACPI_FORMAT_UINT64 ( + ACPI_GET_ADDRESS (Resource->TypeSpecificAttributes))); + AcpiDmIndent (Level + 1); + AcpiDmMemoryFlags2 (Resource->SpecificFlags); + AcpiOsPrintf (")\n"); + } + else + { + AcpiOsPrintf ("0x%8.8X%8.8X) // Type Specific Attributes\n", + ACPI_FORMAT_UINT64 ( + ACPI_GET_ADDRESS (Resource->TypeSpecificAttributes))); + } + +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmQwordDescriptor * * PARAMETERS: Resource - Pointer to the resource descriptor @@ -342,37 +601,46 @@ AcpiDmQwordDescriptor ( { AcpiDmIndent (Level); - AcpiOsPrintf ("Q%s (", - AcpiGbl_WordDecode [(Resource->ResourceType & 3)]); - - if ((Resource->ResourceType & 0x3) == 1) + if (Resource->ResourceType >= 0xC0) { - AcpiDmIoFlags (Resource->Flags); - AcpiOsPrintf (" %s,", - AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); + AcpiOsPrintf ("QWordSpace (0x%2.2X, ", Resource->ResourceType); + AcpiDmSpaceFlags (Resource->Flags); + AcpiOsPrintf (" 0x%2.2X,", Resource->SpecificFlags); } else { - AcpiDmMemoryFlags (Resource->Flags, Resource->SpecificFlags); + AcpiOsPrintf ("Q%s (", + AcpiGbl_WordDecode [(Resource->ResourceType & 3)]); + + if ((Resource->ResourceType & 0x3) == 1) + { + AcpiDmIoFlags (Resource->Flags); + AcpiOsPrintf (" %s,", + AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); + } + else + { + AcpiDmMemoryFlags (Resource->Flags, Resource->SpecificFlags); + } } /* The QWORD values */ AcpiOsPrintf ("\n"); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X%8.8X,\n", + AcpiOsPrintf ("0x%8.8X%8.8X, // Address Space Granularity\n", ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->Granularity))); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X%8.8X,\n", + AcpiOsPrintf ("0x%8.8X%8.8X, // Address Range Minimum\n", ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->AddressMin))); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X%8.8X,\n", + AcpiOsPrintf ("0x%8.8X%8.8X, // Address Range Maximum\n", ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->AddressMax))); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X%8.8X,\n", + AcpiOsPrintf ("0x%8.8X%8.8X, // Address Translation Offset\n", ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->TranslationOffset))); AcpiDmIndent (Level + 1); @@ -385,13 +653,35 @@ AcpiDmQwordDescriptor ( { AcpiOsPrintf (", 0x%2.2X", Resource->OptionalFields[0]); + if (Length > 44) + { + AcpiOsPrintf (", %s", + &Resource->OptionalFields[1]); + } + else + { + AcpiOsPrintf (",,"); + } } - if (Length > 44) + else { - AcpiOsPrintf (", %s", - &Resource->OptionalFields[1]); + AcpiOsPrintf (",,,"); } + /* Type-specific flags */ + + if (Resource->ResourceType == ACPI_IO_RANGE) + { + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + AcpiDmIoFlags2 (Resource->SpecificFlags); + } + else if (Resource->ResourceType == ACPI_MEMORY_RANGE) + { + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + AcpiDmMemoryFlags2 (Resource->SpecificFlags); + } AcpiOsPrintf (")\n"); } @@ -611,6 +901,5 @@ AcpiDmVendorLargeDescriptor ( AcpiOsPrintf ("}\n"); } - #endif diff --git a/sys/dev/acpi/acpica/Subsystem/dmresrcs.c b/sys/dev/acpi/acpica/Subsystem/dmresrcs.c index 7e717adcfac..8c9950580e9 100644 --- a/sys/dev/acpi/acpica/Subsystem/dmresrcs.c +++ b/sys/dev/acpi/acpica/Subsystem/dmresrcs.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmresrcs.c - "Small" Resource Descriptor disassembly - * xRevision: 5 $ + * xRevision: 6 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmresrcs.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmresrcs.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acdisasm.h" diff --git a/sys/dev/acpi/acpica/Subsystem/dmutils.c b/sys/dev/acpi/acpica/Subsystem/dmutils.c index 3c2e277ffeb..19271ea3627 100644 --- a/sys/dev/acpi/acpica/Subsystem/dmutils.c +++ b/sys/dev/acpi/acpica/Subsystem/dmutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmutils - AML disassembler utilities - * xRevision: 9 $ + * xRevision: 14 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,11 +116,12 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmutils.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmutils.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "amlcode.h" #include "acdisasm.h" +#include "acnamesp.h" #ifdef ACPI_DISASSEMBLER @@ -129,6 +130,9 @@ __KERNEL_RCSID(0, "$NetBSD: dmutils.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); ACPI_MODULE_NAME ("dmutils") +ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList = NULL; + + /* Data used in keeping track of fields */ #if 0 const char *AcpiGbl_FENames[ACPI_NUM_FIELD_NAMES] = @@ -221,28 +225,6 @@ const char *AcpiGbl_DECDecode[2] = "SubDecode" }; -const char *AcpiGbl_RNGDecode[4] = -{ - "InvalidRanges", - "NonISAOnlyRanges", - "ISAOnlyRanges", - "EntireRange" -}; - -const char *AcpiGbl_MEMDecode[4] = -{ - "NonCacheable", - "Cacheable", - "WriteCombining", - "Prefetchable" -}; - -const char *AcpiGbl_RWDecode[2] = -{ - "ReadOnly", - "ReadWrite" -}; - const char *AcpiGbl_IrqDecode[2] = { "IRQNoFlags", @@ -289,6 +271,101 @@ const char *AcpiGbl_SIZDecode[4] = "InvalidSize" }; +/* Type Specific Flags */ + +const char *AcpiGbl_TTPDecode[2] = +{ + "TypeStatic", + "TypeTranslation" +}; + +const char *AcpiGbl_MTPDecode[4] = +{ + "AddressRangeMemory", + "AddressRangeReserved", + "AddressRangeACPI", + "AddressRangeNVS" +}; + +const char *AcpiGbl_MEMDecode[4] = +{ + "NonCacheable", + "Cacheable", + "WriteCombining", + "Prefetchable" +}; + +const char *AcpiGbl_RWDecode[2] = +{ + "ReadOnly", + "ReadWrite" +}; + +const char *AcpiGbl_TRSDecode[2] = +{ + "DenseTranslation", + "SparseTranslation" +}; + +const char *AcpiGbl_RNGDecode[4] = +{ + "InvalidRanges", + "NonISAOnlyRanges", + "ISAOnlyRanges", + "EntireRange" +}; + + +#ifdef _ACPI_ASL_COMPILER +/******************************************************************************* + * + * FUNCTION: AcpiDmAddToExternalList + * + * PARAMETERS: Path - Internal (AML) path to the object + * + * RETURN: None + * + * DESCRIPTION: Insert a new path into the list of Externals which will in + * turn be emitted as an External() declaration in the disassembled + * output. + * + ******************************************************************************/ + +void +AcpiDmAddToExternalList ( + char *Path) +{ + char *ExternalPath; + ACPI_EXTERNAL_LIST *NewExternal; + ACPI_STATUS Status; + + + if (!Path) + { + return; + } + + /* Externalize the ACPI path */ + + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Path, + NULL, &ExternalPath); + if (ACPI_SUCCESS (Status)) + { + /* Allocate and init a new External() descriptor */ + + NewExternal = ACPI_MEM_CALLOCATE (sizeof (ACPI_EXTERNAL_LIST)); + NewExternal->Path = ExternalPath; + + /* Link the new descriptor into the global list */ + + if (AcpiGbl_ExternalList) + { + NewExternal->Next = AcpiGbl_ExternalList; + } + AcpiGbl_ExternalList = NewExternal; + } +} +#endif /******************************************************************************* * @@ -463,5 +540,4 @@ AcpiDmCommaIfFieldMember ( } } - #endif diff --git a/sys/dev/acpi/acpica/Subsystem/dmwalk.c b/sys/dev/acpi/acpica/Subsystem/dmwalk.c index 9993e4eb840..7f813e3990d 100644 --- a/sys/dev/acpi/acpica/Subsystem/dmwalk.c +++ b/sys/dev/acpi/acpica/Subsystem/dmwalk.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmwalk - AML disassembly tree walk - * xRevision: 11 $ + * xRevision: 18 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dmwalk.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dmwalk.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acparser.h" @@ -133,12 +133,38 @@ __KERNEL_RCSID(0, "$NetBSD: dmwalk.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); #define DB_FULL_OP_INFO "%5.5X #%4.4hX " +/* Local prototypes */ + +static ACPI_STATUS +AcpiDmDescendingOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +AcpiDmAscendingOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static void +AcpiDmWalkParseTree ( + ACPI_PARSE_OBJECT *Op, + ASL_WALK_CALLBACK DescendingCallback, + ASL_WALK_CALLBACK AscendingCallback, + void *Context); + +static UINT32 +AcpiDmBlockType ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * * FUNCTION: AcpiDmDisassemble * - * PARAMETERS: Origin - Starting object + * PARAMETERS: WalkState - Current state + * Origin - Starting object * NumOpcodes - Max number of opcodes to be displayed * * RETURN: None @@ -174,7 +200,8 @@ AcpiDmDisassemble ( * * FUNCTION: AcpiDmWalkParseTree * - * PARAMETERS: DescendingCallback - Called during tree descent + * PARAMETERS: Op - Root Op object + * DescendingCallback - Called during tree descent * AscendingCallback - Called during tree ascent * Context - To be passed to the callbacks * @@ -184,7 +211,7 @@ AcpiDmDisassemble ( * ******************************************************************************/ -void +static void AcpiDmWalkParseTree ( ACPI_PARSE_OBJECT *Op, ASL_WALK_CALLBACK DescendingCallback, @@ -284,13 +311,13 @@ AcpiDmWalkParseTree ( * * PARAMETERS: Op - Object to be examined * - * RETURN: Status + * RETURN: BlockType - not a block, parens, braces, or even both. * * DESCRIPTION: Type of block for this op (parens or braces) * ******************************************************************************/ -UINT32 +static UINT32 AcpiDmBlockType ( ACPI_PARSE_OBJECT *Op) { @@ -359,7 +386,7 @@ AcpiDmBlockType ( * * PARAMETERS: Op - Object to be examined * - * RETURN: Status + * RETURN: ListType - has commas or not. * * DESCRIPTION: Type of block for this op (parens or braces) * @@ -393,7 +420,7 @@ AcpiDmListType ( case AML_INDEX_FIELD_OP: case AML_BANK_FIELD_OP: - return (0); + return (BLOCK_NONE); case AML_BUFFER_OP: case AML_PACKAGE_OP: @@ -427,7 +454,7 @@ AcpiDmListType ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDmDescendingOp ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -437,6 +464,7 @@ AcpiDmDescendingOp ( const ACPI_OPCODE_INFO *OpInfo; UINT32 Name; ACPI_PARSE_OBJECT *NextOp; + ACPI_EXTERNAL_LIST *NextExternal; if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE) @@ -446,6 +474,7 @@ AcpiDmDescendingOp ( return (AE_CTRL_DEPTH); } + /* Level 0 is at the Definition Block level */ if (Level == 0) { @@ -456,7 +485,34 @@ AcpiDmDescendingOp ( if (Op->Common.AmlOpcode == AML_SCOPE_OP) { + /* This is the beginning of the Definition Block */ + AcpiOsPrintf ("{\n"); + + /* Emit all External() declarations here */ + + if (AcpiGbl_ExternalList) + { + AcpiOsPrintf ( + " /*\n * These objects were referenced but not defined in this table\n */\n"); + + /* + * Walk the list of externals (unresolved references) + * found during parsing + */ + while (AcpiGbl_ExternalList) + { + AcpiOsPrintf (" External (%s, DeviceObj)\n", + AcpiGbl_ExternalList->Path); + + NextExternal = AcpiGbl_ExternalList->Next; + ACPI_MEM_FREE (AcpiGbl_ExternalList->Path); + ACPI_MEM_FREE (AcpiGbl_ExternalList); + AcpiGbl_ExternalList = NextExternal; + } + AcpiOsPrintf ("\n"); + } + return (AE_OK); } } @@ -464,8 +520,10 @@ AcpiDmDescendingOp ( (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { - /* This is a first-level element of a term list, indent a new line */ - + /* + * This is a first-level element of a term list, + * indent a new line + */ AcpiDmIndent (Level); } @@ -520,10 +578,8 @@ AcpiDmDescendingOp ( AcpiDmDumpName ((char *) &Name); } - if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP) { - AcpiDmValidateName ((char *) &Name, Op); if (AcpiGbl_DbOpt_verbose) { (void) AcpiPsDisplayObjectPathname (NULL, Op); @@ -758,7 +814,7 @@ AcpiDmDescendingOp ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDmAscendingOp ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -798,8 +854,10 @@ AcpiDmAscendingOp ( (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { - /* This is a first-level element of a term list, start a new line */ - + /* + * This is a first-level element of a term list + * start a new line + */ AcpiOsPrintf ("\n"); } } @@ -857,8 +915,10 @@ AcpiDmAscendingOp ( (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { - /* This is a first-level element of a term list, start a new line */ - + /* + * This is a first-level element of a term list + * start a new line + */ AcpiOsPrintf ("\n"); } } @@ -903,7 +963,8 @@ AcpiDmAscendingOp ( } else { - Op->Common.Parent->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST; + Op->Common.Parent->Common.DisasmFlags |= + ACPI_PARSEOP_EMPTY_TERMLIST; AcpiOsPrintf (") {"); } } diff --git a/sys/dev/acpi/acpica/Subsystem/dsfield.c b/sys/dev/acpi/acpica/Subsystem/dsfield.c index 587834165b7..693cdaa9c01 100644 --- a/sys/dev/acpi/acpica/Subsystem/dsfield.c +++ b/sys/dev/acpi/acpica/Subsystem/dsfield.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsfield - Dispatcher field routines - * xRevision: 74 $ + * xRevision: 78 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsfield.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dsfield.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __DSFIELD_C__ @@ -130,13 +130,20 @@ __KERNEL_RCSID(0, "$NetBSD: dsfield.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsfield") +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsGetFieldNames ( + ACPI_CREATE_FIELD_INFO *Info, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg); + /******************************************************************************* * * FUNCTION: AcpiDsCreateBufferField * - * PARAMETERS: Opcode - The opcode to be executed - * Operands - List of operands for the opcode + * PARAMETERS: Op - Current parse op (CreateXXField) * WalkState - Current state * * RETURN: Status @@ -147,7 +154,7 @@ __KERNEL_RCSID(0, "$NetBSD: dsfield.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * CreateWordFieldOp, * CreateDWordFieldOp, * CreateQWordFieldOp, - * CreateFieldOp (all of which define fields in buffers) + * CreateFieldOp (all of which define a field in a buffer) * ******************************************************************************/ @@ -203,7 +210,8 @@ AcpiDsCreateBufferField ( } else { - Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND; + Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND; } /* @@ -219,16 +227,16 @@ AcpiDsCreateBufferField ( } } - /* We could put the returned object (Node) on the object stack for later, but - * for now, we will put it in the "op" object that the parser uses, so we - * can get it again at the end of this scope + /* We could put the returned object (Node) on the object stack for later, + * but for now, we will put it in the "op" object that the parser uses, + * so we can get it again at the end of this scope */ Op->Common.Node = Node; /* - * If there is no object attached to the node, this node was just created and - * we need to create the field object. Otherwise, this was a lookup of an - * existing node and we don't want to create the field object again. + * If there is no object attached to the node, this node was just created + * and we need to create the field object. Otherwise, this was a lookup + * of an existing node and we don't want to create the field object again. */ ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) @@ -293,7 +301,7 @@ Cleanup: * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsGetFieldNames ( ACPI_CREATE_FIELD_INFO *Info, ACPI_WALK_STATE *WalkState, @@ -329,7 +337,8 @@ AcpiDsGetFieldNames ( if (Position > ACPI_UINT32_MAX) { - ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n")); + ACPI_REPORT_ERROR (( + "Bit offset within field too large (> 0xFFFFFFFF)\n")); return_ACPI_STATUS (AE_SUPPORT); } @@ -341,12 +350,15 @@ AcpiDsGetFieldNames ( /* * Get a new AccessType and AccessAttribute -- to be used for all - * field units that follow, until field end or another AccessAs keyword. + * field units that follow, until field end or another AccessAs + * keyword. * - * In FieldFlags, preserve the flag bits other than the ACCESS_TYPE bits + * In FieldFlags, preserve the flag bits other than the + * ACCESS_TYPE bits */ - Info->FieldFlags = (UINT8) ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | - ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8))); + Info->FieldFlags = (UINT8) + ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | + ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8))); Info->Attribute = (UINT8) (Arg->Common.Value.Integer); break; @@ -358,7 +370,8 @@ AcpiDsGetFieldNames ( Status = AcpiNsLookup (WalkState->ScopeInfo, (char *) &Arg->Named.Name, - Info->FieldType, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, + Info->FieldType, ACPI_IMODE_EXECUTE, + ACPI_NS_DONT_OPEN_SCOPE, WalkState, &Info->FieldNode); if (ACPI_FAILURE (Status)) { @@ -391,8 +404,9 @@ AcpiDsGetFieldNames ( if (Position > ACPI_UINT32_MAX) { - ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", - (char *) &Info->FieldNode->Name)); + ACPI_REPORT_ERROR (( + "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", + (char *) &Info->FieldNode->Name)); return_ACPI_STATUS (AE_SUPPORT); } @@ -402,7 +416,8 @@ AcpiDsGetFieldNames ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid opcode in field list: %X\n", Arg->Common.AmlOpcode)); return_ACPI_STATUS (AE_AML_BAD_OPCODE); } @@ -536,7 +551,8 @@ AcpiDsInitFieldObjects ( Status = AcpiNsLookup (WalkState->ScopeInfo, (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND, WalkState, &Node); if (ACPI_FAILURE (Status)) { diff --git a/sys/dev/acpi/acpica/Subsystem/dsinit.c b/sys/dev/acpi/acpica/Subsystem/dsinit.c index d098300d70a..64af25631a9 100644 --- a/sys/dev/acpi/acpica/Subsystem/dsinit.c +++ b/sys/dev/acpi/acpica/Subsystem/dsinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsinit - Object initialization namespace walk - * xRevision: 10 $ + * xRevision: 15 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsinit.c,v 1.6 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dsinit.c,v 1.7 2005/05/02 14:52:09 kochi Exp $"); #define __DSINIT_C__ @@ -126,12 +126,21 @@ __KERNEL_RCSID(0, "$NetBSD: dsinit.c,v 1.6 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsinit") +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + /******************************************************************************* * * FUNCTION: AcpiDsInitOneObject * - * PARAMETERS: ObjHandle - Node + * PARAMETERS: ObjHandle - Node for the object * Level - Current nesting level * Context - Points to a init info struct * ReturnValue - Not used @@ -147,7 +156,7 @@ __KERNEL_RCSID(0, "$NetBSD: dsinit.c,v 1.6 2004/02/14 16:57:24 kochi Exp $"); * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsInitOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -185,7 +194,8 @@ AcpiDsInitOneObject ( Status = AcpiDsInitializeRegion (ObjHandle); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Region %p [%4.4s] - Init failure, %s\n", ObjHandle, AcpiUtGetNodeName (ObjHandle), AcpiFormatException (Status))); } @@ -198,8 +208,10 @@ AcpiDsInitOneObject ( Info->MethodCount++; - /* Print a dot for each method unless we are going to print the entire pathname */ - + /* + * Print a dot for each method unless we are going to print + * the entire pathname + */ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); @@ -223,7 +235,8 @@ AcpiDsInitOneObject ( Status = AcpiDsParseMethod (ObjHandle); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Method %p [%4.4s] - parse failure, %s\n", ObjHandle, AcpiUtGetNodeName (ObjHandle), AcpiFormatException (Status))); @@ -237,7 +250,8 @@ AcpiDsInitOneObject ( * for every execution since there isn't much overhead */ AcpiNsDeleteNamespaceSubtree (ObjHandle); - AcpiNsDeleteNamespaceByOwner (((ACPI_NAMESPACE_NODE *) ObjHandle)->Object->Method.OwningId); + AcpiNsDeleteNamespaceByOwner ( + ((ACPI_NAMESPACE_NODE *) ObjHandle)->Object->Method.OwningId); break; diff --git a/sys/dev/acpi/acpica/Subsystem/dsmethod.c b/sys/dev/acpi/acpica/Subsystem/dsmethod.c index a3920cf51dc..26261f3d359 100644 --- a/sys/dev/acpi/acpica/Subsystem/dsmethod.c +++ b/sys/dev/acpi/acpica/Subsystem/dsmethod.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsmethod - Parser/Interpreter interface - control method parsing - * xRevision: 93 $ + * xRevision: 105 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsmethod.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dsmethod.c,v 1.12 2005/05/02 14:52:09 kochi Exp $"); #define __DSMETHOD_C__ @@ -135,15 +135,12 @@ __KERNEL_RCSID(0, "$NetBSD: dsmethod.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); * * FUNCTION: AcpiDsParseMethod * - * PARAMETERS: ObjHandle - Node of the method - * Level - Current nesting level - * Context - Points to a method counter - * ReturnValue - Not used + * PARAMETERS: ObjHandle - Method node * * RETURN: Status * - * DESCRIPTION: Call the parser and parse the AML that is - * associated with the method. + * DESCRIPTION: Call the parser and parse the AML that is associated with the + * method. * * MUTEX: Assumes parser is locked * @@ -185,7 +182,7 @@ AcpiDsParseMethod ( /* Create a mutex for the method if there is a concurrency limit */ - if ((ObjDesc->Method.Concurrency != INFINITE_CONCURRENCY) && + if ((ObjDesc->Method.Concurrency != ACPI_INFINITE_CONCURRENCY) && (!ObjDesc->Method.Semaphore)) { Status = AcpiOsCreateSemaphore (ObjDesc->Method.Concurrency, @@ -228,8 +225,9 @@ AcpiDsParseMethod ( return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitAmlWalk (WalkState, Op, Node, ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, NULL, NULL, 1); + Status = AcpiDsInitAmlWalk (WalkState, Op, Node, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, NULL, 1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -239,12 +237,11 @@ AcpiDsParseMethod ( /* * Parse the method, first pass * - * The first pass load is where newly declared named objects are - * added into the namespace. Actual evaluation of - * the named objects (what would be called a "second - * pass") happens during the actual execution of the - * method so that operands to the named objects can - * take on dynamic run-time values. + * The first pass load is where newly declared named objects are added into + * the namespace. Actual evaluation of the named objects (what would be + * called a "second pass") happens during the actual execution of the + * method so that operands to the named objects can take on dynamic + * run-time values. */ Status = AcpiPsParseAml (WalkState); if (ACPI_FAILURE (Status)) @@ -275,8 +272,6 @@ AcpiDsParseMethod ( * increments the thread count, and waits at the method semaphore * for clearance to execute. * - * MUTEX: Locks/unlocks parser. - * ******************************************************************************/ ACPI_STATUS @@ -339,7 +334,8 @@ AcpiDsBeginMethodExecution ( * * FUNCTION: AcpiDsCallControlMethod * - * PARAMETERS: WalkState - Current state of the walk + * PARAMETERS: Thread - Info for this thread + * ThisWalkState - Current walk state * Op - Current Op to be walked * * RETURN: Status @@ -356,8 +352,9 @@ AcpiDsCallControlMethod ( { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *MethodNode; - ACPI_OPERAND_OBJECT *ObjDesc; ACPI_WALK_STATE *NextWalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARAMETER_INFO Info; UINT32 i; @@ -392,37 +389,40 @@ AcpiDsCallControlMethod ( return_ACPI_STATUS (Status); } - /* 1) Parse: Create a new walk state for the preempting walk */ - - NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId, - Op, ObjDesc, NULL); - if (!NextWalkState) + if (!(ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY)) { - return_ACPI_STATUS (AE_NO_MEMORY); - } + /* 1) Parse: Create a new walk state for the preempting walk */ - /* Create and init a Root Node */ + NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId, + Op, ObjDesc, NULL); + if (!NextWalkState) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } - Op = AcpiPsCreateScopeOp (); - if (!Op) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } + /* Create and init a Root Node */ - Status = AcpiDsInitAmlWalk (NextWalkState, Op, MethodNode, - ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, - NULL, NULL, 1); - if (ACPI_FAILURE (Status)) - { - AcpiDsDeleteWalkState (NextWalkState); - goto Cleanup; - } + Op = AcpiPsCreateScopeOp (); + if (!Op) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiDsInitAmlWalk (NextWalkState, Op, MethodNode, + ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, + NULL, 1); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (NextWalkState); + goto Cleanup; + } - /* Begin AML parse */ + /* Begin AML parse */ - Status = AcpiPsParseAml (NextWalkState); - AcpiPsDeleteParseTree (Op); + Status = AcpiPsParseAml (NextWalkState); + AcpiPsDeleteParseTree (Op); + } /* 2) Execute: Create a new state for the preempting walk */ @@ -433,7 +433,6 @@ AcpiDsCallControlMethod ( Status = AE_NO_MEMORY; goto Cleanup; } - /* * The resolved arguments were put on the previous walk state's operand * stack. Operands on the previous walk state stack always @@ -442,9 +441,12 @@ AcpiDsCallControlMethod ( */ ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL; + Info.Parameters = &ThisWalkState->Operands[0]; + Info.ParameterType = ACPI_PARAM_ARGS; + Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode, ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, - &ThisWalkState->Operands[0], NULL, 3); + &Info, 3); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -467,16 +469,27 @@ AcpiDsCallControlMethod ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Starting nested execution, newstate=%p\n", NextWalkState)); + if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + { + Status = ObjDesc->Method.Implementation (NextWalkState); + return_ACPI_STATUS (Status); + } + return_ACPI_STATUS (AE_OK); /* On error, we must delete the new walk state */ Cleanup: + if (NextWalkState && (NextWalkState->MethodDesc)) + { + /* Decrement the thread count on the method parse tree */ + + NextWalkState->MethodDesc->Method.ThreadCount--; + } (void) AcpiDsTerminateControlMethod (NextWalkState); AcpiDsDeleteWalkState (NextWalkState); return_ACPI_STATUS (Status); - } @@ -484,12 +497,13 @@ Cleanup: * * FUNCTION: AcpiDsRestartControlMethod * - * PARAMETERS: WalkState - State of the method when it was preempted - * Op - Pointer to new current op + * PARAMETERS: WalkState - State for preempted method (caller) + * ReturnDesc - Return value from the called method * * RETURN: Status * - * DESCRIPTION: Restart a method that was preempted + * DESCRIPTION: Restart a method that was preempted by another (nested) method + * invocation. Handle the return value (if any) from the callee. * ******************************************************************************/ @@ -504,22 +518,49 @@ AcpiDsRestartControlMethod ( ACPI_FUNCTION_TRACE_PTR ("DsRestartControlMethod", WalkState); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n", + (char *) &WalkState->MethodNode->Name, WalkState->MethodCallOp, + ReturnDesc)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n", + WalkState->ReturnUsed, + WalkState->Results, WalkState)); + + /* Did the called method return a value? */ + if (ReturnDesc) { + /* Are we actually going to use the return value? */ + if (WalkState->ReturnUsed) { - /* - * Get the return value (if any) from the previous method. - * NULL if no return value - */ + /* Save the return value from the previous method */ + Status = AcpiDsResultPush (ReturnDesc, WalkState); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); return_ACPI_STATUS (Status); } + + /* + * Save as THIS method's return value in case it is returned + * immediately to yet another method + */ + WalkState->ReturnDesc = ReturnDesc; } - else + + /* + * The following code is the + * optional support for a so-called "implicit return". Some AML code + * assumes that the last value of the method is "implicitly" returned + * to the caller. Just save the last result as the return value. + * NOTE: this is optional because the ASL language does not actually + * support this behavior. + */ + else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE)) { /* * Delete the return value if it will not be used by the @@ -529,11 +570,6 @@ AcpiDsRestartControlMethod ( } } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Method=%p Return=%p ReturnUsed?=%X ResStack=%p State=%p\n", - WalkState->MethodCallOp, ReturnDesc, WalkState->ReturnUsed, - WalkState->Results, WalkState)); - return_ACPI_STATUS (AE_OK); } @@ -607,12 +643,34 @@ AcpiDsTerminateControlMethod ( } } - /* Decrement the thread count on the method parse tree */ + if (WalkState->MethodDesc->Method.ThreadCount) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "*** Not deleting method namespace, there are still %d threads\n", + WalkState->MethodDesc->Method.ThreadCount)); + } - WalkState->MethodDesc->Method.ThreadCount--; if (!WalkState->MethodDesc->Method.ThreadCount) { /* + * Support to dynamically change a method from NotSerialized to + * Serialized if it appears that the method is written foolishly and + * does not support multiple thread execution. The best example of this + * is if such a method creates namespace objects and blocks. A second + * thread will fail with an AE_ALREADY_EXISTS exception + * + * This code is here because we must wait until the last thread exits + * before creating the synchronization semaphore. + */ + if ((WalkState->MethodDesc->Method.Concurrency == 1) && + (!WalkState->MethodDesc->Method.Semaphore)) + { + Status = AcpiOsCreateSemaphore (1, + 1, + &WalkState->MethodDesc->Method.Semaphore); + } + + /* * There are no more threads executing this method. Perform * additional cleanup. * diff --git a/sys/dev/acpi/acpica/Subsystem/dsmthdat.c b/sys/dev/acpi/acpica/Subsystem/dsmthdat.c index c157c54cb4f..5621f27db91 100644 --- a/sys/dev/acpi/acpica/Subsystem/dsmthdat.c +++ b/sys/dev/acpi/acpica/Subsystem/dsmthdat.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dsmthdat - control method arguments and local variables - * xRevision: 77 $ + * xRevision: 84 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsmthdat.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dsmthdat.c,v 1.12 2005/05/02 14:52:09 kochi Exp $"); #define __DSMTHDAT_C__ @@ -129,6 +129,29 @@ __KERNEL_RCSID(0, "$NetBSD: dsmthdat.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsmthdat") +/* Local prototypes */ + +static void +AcpiDsMethodDataDeleteValue ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT16 Opcode, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState); +#endif + /******************************************************************************* * @@ -139,8 +162,8 @@ __KERNEL_RCSID(0, "$NetBSD: dsmthdat.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); * RETURN: Status * * DESCRIPTION: Initialize the data structures that hold the method's arguments - * and locals. The data struct is an array of NTEs for each. - * This allows RefOf and DeRefOf to work properly for these + * and locals. The data struct is an array of namespace nodes for + * each - this allows RefOf and DeRefOf to work properly for these * special data types. * * NOTES: WalkState fields are initialized to zero by the @@ -170,7 +193,8 @@ AcpiDsMethodDataInit ( WalkState->Arguments[i].Name.Integer |= (i << 24); WalkState->Arguments[i].Descriptor = ACPI_DESC_TYPE_NAMED; WalkState->Arguments[i].Type = ACPI_TYPE_ANY; - WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; + WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | + ANOBJ_METHOD_ARG; } /* Init the method locals */ @@ -183,7 +207,8 @@ AcpiDsMethodDataInit ( WalkState->LocalVariables[i].Name.Integer |= (i << 24); WalkState->LocalVariables[i].Descriptor = ACPI_DESC_TYPE_NAMED; WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; - WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; + WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | + ANOBJ_METHOD_LOCAL; } return_VOID; @@ -282,16 +307,19 @@ AcpiDsMethodDataInitArgs ( return_ACPI_STATUS (AE_OK); } - /* Copy passed parameters into the new method stack frame */ + /* Copy passed parameters into the new method stack frame */ - while ((Index < ACPI_METHOD_NUM_ARGS) && (Index < MaxParamCount) && Params[Index]) + while ((Index < ACPI_METHOD_NUM_ARGS) && + (Index < MaxParamCount) && + Params[Index]) { /* * A valid parameter. * Store the argument in the method/walk descriptor. * Do not copy the arg in order to implement call by reference */ - Status = AcpiDsMethodDataSetValue (AML_ARG_OP, Index, Params[Index], WalkState); + Status = AcpiDsMethodDataSetValue (AML_ARG_OP, Index, + Params[Index], WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -310,11 +338,13 @@ AcpiDsMethodDataInitArgs ( * FUNCTION: AcpiDsMethodDataGetNode * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument whose type - * to get + * Index - Which Local or Arg whose type to get * WalkState - Current walk state object + * Node - Where the node is returned. + * + * RETURN: Status and node * - * RETURN: Get the Node associated with a local or arg. + * DESCRIPTION: Get the Node associated with a local or arg. * ******************************************************************************/ @@ -337,7 +367,8 @@ AcpiDsMethodDataGetNode ( if (Index > ACPI_METHOD_MAX_LOCAL) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Local index %d is invalid (max %d)\n", Index, ACPI_METHOD_MAX_LOCAL)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } @@ -351,7 +382,8 @@ AcpiDsMethodDataGetNode ( if (Index > ACPI_METHOD_MAX_ARG) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Arg index %d is invalid (max %d)\n", Index, ACPI_METHOD_MAX_ARG)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } @@ -375,7 +407,7 @@ AcpiDsMethodDataGetNode ( * FUNCTION: AcpiDsMethodDataSetValue * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument to get + * Index - Which Local or Arg to get * Object - Object to be inserted into the stack entry * WalkState - Current walk state object * @@ -386,7 +418,7 @@ AcpiDsMethodDataGetNode ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsMethodDataSetValue ( UINT16 Opcode, UINT32 Index, @@ -401,7 +433,7 @@ AcpiDsMethodDataSetValue ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "obj %p op %X, ref count = %d [%s]\n", Object, + "NewObj %p Opcode %X, Refs=%d [%s]\n", Object, Opcode, Object->Common.ReferenceCount, AcpiUtGetTypeName (Object->Common.Type))); @@ -430,69 +462,16 @@ AcpiDsMethodDataSetValue ( /******************************************************************************* * - * FUNCTION: AcpiDsMethodDataGetType - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument whose type - * to get - * WalkState - Current walk state object - * - * RETURN: Data type of current value of the selected Arg or Local - * - ******************************************************************************/ - -ACPI_OBJECT_TYPE -AcpiDsMethodDataGetType ( - UINT16 Opcode, - UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *Object; - - - ACPI_FUNCTION_TRACE ("DsMethodDataGetType"); - - - /* Get the namespace node for the arg/local */ - - Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); - if (ACPI_FAILURE (Status)) - { - return_VALUE ((ACPI_TYPE_NOT_FOUND)); - } - - /* Get the object */ - - Object = AcpiNsGetAttachedObject (Node); - if (!Object) - { - /* Uninitialized local/arg, return TYPE_ANY */ - - return_VALUE (ACPI_TYPE_ANY); - } - - /* Get the object type */ - - return_VALUE (ACPI_GET_OBJECT_TYPE (Object)); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDsMethodDataGetValue * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which localVar or argument to get * WalkState - Current walk state object - * *DestDesc - Ptr to Descriptor into which selected Arg - * or Local value should be copied + * DestDesc - Where Arg or Local value is returned * * RETURN: Status * - * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame - * at the current top of the method stack. + * DESCRIPTION: Retrieve value of selected Arg or Local for this method * Used only in AcpiExResolveToValue(). * ******************************************************************************/ @@ -543,18 +522,37 @@ AcpiDsMethodDataGetValue ( * was referenced by the method (via the ASL) * before it was initialized. Either case is an error. */ - switch (Opcode) + + /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */ + + if (AcpiGbl_EnableInterpreterSlack) + { + Object = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!Object) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Object->Integer.Value = 0; + Node->Object = Object; + } + + /* Otherwise, return the error */ + + else switch (Opcode) { case AML_ARG_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Uninitialized Arg[%d] at node %p\n", Index, Node)); return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); case AML_LOCAL_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Uninitialized Local[%d] at node %p\n", Index, Node)); return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); @@ -586,12 +584,12 @@ AcpiDsMethodDataGetValue ( * * RETURN: None * - * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts + * DESCRIPTION: Delete the entry at Opcode:Index. Inserts * a null into the stack slot after the object is deleted. * ******************************************************************************/ -void +static void AcpiDsMethodDataDeleteValue ( UINT16 Opcode, UINT32 Index, @@ -644,7 +642,7 @@ AcpiDsMethodDataDeleteValue ( * FUNCTION: AcpiDsStoreObjectToLocal * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument to set + * Index - Which Local or Arg to set * ObjDesc - Value to be stored * WalkState - Current walk state * @@ -670,7 +668,7 @@ AcpiDsStoreObjectToLocal ( ACPI_FUNCTION_TRACE ("DsStoreObjectToLocal"); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", Opcode, Index, ObjDesc)); /* Parameter validation */ @@ -740,20 +738,21 @@ AcpiDsStoreObjectToLocal ( if (Opcode == AML_ARG_OP) { /* - * Make sure that the object is the correct type. This may be overkill, but - * it is here because references were NS nodes in the past. Now they are - * operand objects of type Reference. + * Make sure that the object is the correct type. This may be + * overkill, butit is here because references were NS nodes in + * the past. Now they are operand objects of type Reference. */ if (ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) != ACPI_DESC_TYPE_OPERAND) { - ACPI_REPORT_ERROR (("Invalid descriptor type while storing to method arg: [%s]\n", - AcpiUtGetDescriptorName (CurrentObjDesc))); + ACPI_REPORT_ERROR (( + "Invalid descriptor type while storing to method arg: [%s]\n", + AcpiUtGetDescriptorName (CurrentObjDesc))); return_ACPI_STATUS (AE_AML_INTERNAL); } /* - * If we have a valid reference object that came from RefOf(), do the - * indirect store + * If we have a valid reference object that came from RefOf(), + * do the indirect store */ if ((CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (CurrentObjDesc->Reference.Opcode == AML_REF_OF_OP)) @@ -763,11 +762,13 @@ AcpiDsStoreObjectToLocal ( NewObjDesc, CurrentObjDesc)); /* - * Store this object to the Node - * (perform the indirect store) + * Store this object to the Node (perform the indirect store) + * NOTE: No implicit conversion is performed, as per the ACPI + * specification rules on storing to Locals/Args. */ Status = AcpiExStoreObjectToNode (NewObjDesc, - CurrentObjDesc->Reference.Object, WalkState); + CurrentObjDesc->Reference.Object, WalkState, + ACPI_NO_IMPLICIT_CONVERSION); /* Remove local reference if we copied the object above */ @@ -804,3 +805,57 @@ AcpiDsStoreObjectToLocal ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetType + * + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * Index - Which Local or Arg whose type to get + * WalkState - Current walk state object + * + * RETURN: Data type of current value of the selected Arg or Local + * + * DESCRIPTION: Get the type of the object stored in the Local or Arg + * + ******************************************************************************/ + +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE ("DsMethodDataGetType"); + + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_VALUE ((ACPI_TYPE_NOT_FOUND)); + } + + /* Get the object */ + + Object = AcpiNsGetAttachedObject (Node); + if (!Object) + { + /* Uninitialized local/arg, return TYPE_ANY */ + + return_VALUE (ACPI_TYPE_ANY); + } + + /* Get the object type */ + + return_VALUE (ACPI_GET_OBJECT_TYPE (Object)); +} +#endif + + diff --git a/sys/dev/acpi/acpica/Subsystem/dsobject.c b/sys/dev/acpi/acpica/Subsystem/dsobject.c index 44c01f16d7b..9730ca66061 100644 --- a/sys/dev/acpi/acpica/Subsystem/dsobject.c +++ b/sys/dev/acpi/acpica/Subsystem/dsobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines - * xRevision: 119 $ + * xRevision: 123 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsobject.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dsobject.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __DSOBJECT_C__ @@ -129,9 +129,15 @@ __KERNEL_RCSID(0, "$NetBSD: dsobject.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsobject") +static ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr); + #ifndef ACPI_NO_METHOD_EXECUTION -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsBuildInternalObject * @@ -144,9 +150,9 @@ __KERNEL_RCSID(0, "$NetBSD: dsobject.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * DESCRIPTION: Translate a parser Op object to the equivalent namespace object * Simple objects are any objects other than a package object! * - ****************************************************************************/ + ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsBuildInternalObject ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, @@ -169,9 +175,11 @@ AcpiDsBuildInternalObject ( */ if (!Op->Common.Node) { - Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, + Status = AcpiNsLookup (WalkState->ScopeInfo, + Op->Common.Value.String, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + NULL, (ACPI_NAMESPACE_NODE **) &(Op->Common.Node)); if (ACPI_FAILURE (Status)) @@ -184,13 +192,15 @@ AcpiDsBuildInternalObject ( /* Create and init the internal ACPI object */ - ObjDesc = AcpiUtCreateInternalObject ((AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); + ObjDesc = AcpiUtCreateInternalObject ( + (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, &ObjDesc); + Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, + &ObjDesc); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); @@ -202,7 +212,7 @@ AcpiDsBuildInternalObject ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsBuildInternalBufferObj * @@ -216,7 +226,7 @@ AcpiDsBuildInternalObject ( * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsBuildInternalBufferObj ( @@ -321,7 +331,7 @@ AcpiDsBuildInternalBufferObj ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsBuildInternalPackageObj * @@ -335,7 +345,7 @@ AcpiDsBuildInternalBufferObj ( * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsBuildInternalPackageObj ( @@ -432,12 +442,13 @@ AcpiDsBuildInternalPackageObj ( { /* Object (package or buffer) is already built */ - ObjDesc->Package.Elements[i] = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); + ObjDesc->Package.Elements[i] = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); } else { Status = AcpiDsBuildInternalObject (WalkState, Arg, - &ObjDesc->Package.Elements[i]); + &ObjDesc->Package.Elements[i]); } i++; @@ -450,7 +461,7 @@ AcpiDsBuildInternalPackageObj ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsCreateNode * @@ -462,7 +473,7 @@ AcpiDsBuildInternalPackageObj ( * * DESCRIPTION: Create the object to be associated with a namespace node * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsCreateNode ( @@ -496,7 +507,8 @@ AcpiDsCreateNode ( /* Build an internal object for the argument(s) */ - Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, &ObjDesc); + Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, + &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -519,7 +531,7 @@ AcpiDsCreateNode ( #endif /* ACPI_NO_METHOD_EXECUTION */ -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsInitObjectFromOp * @@ -534,7 +546,7 @@ AcpiDsCreateNode ( * associated arguments. The namespace object is a more compact * representation of the Op and its arguments. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsInitObjectFromOp ( @@ -569,7 +581,8 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Buffer TermArg operand */ - ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) + WalkState->Operands[0]; ObjDesc->Buffer.AmlStart = Op->Named.Data; ObjDesc->Buffer.AmlLength = Op->Named.Length; break; @@ -580,7 +593,8 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Package TermArg operand */ - ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) + WalkState->Operands[0]; ObjDesc->Package.AmlStart = Op->Named.Data; ObjDesc->Package.AmlLength = Op->Named.Length; break; @@ -594,9 +608,10 @@ AcpiDsInitObjectFromOp ( /* * Resolve AML Constants here - AND ONLY HERE! * All constants are integers. - * We mark the integer with a flag that indicates that it started life - * as a constant -- so that stores to constants will perform as expected (noop). - * (ZeroOp is used as a placeholder for optional target operands.) + * We mark the integer with a flag that indicates that it started + * life as a constant -- so that stores to constants will perform + * as expected (noop). ZeroOp is used as a placeholder for optional + * target operands. */ ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT; @@ -625,12 +640,13 @@ AcpiDsInitObjectFromOp ( case AML_REVISION_OP: - ObjDesc->Integer.Value = ACPI_CA_SUPPORT_LEVEL; + ObjDesc->Integer.Value = ACPI_CA_VERSION; break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown constant opcode %X\n", Opcode)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown constant opcode %X\n", Opcode)); Status = AE_AML_OPERAND_TYPE; break; } @@ -644,7 +660,8 @@ AcpiDsInitObjectFromOp ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", OpInfo->Type)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", + OpInfo->Type)); Status = AE_AML_OPERAND_TYPE; break; } @@ -680,8 +697,10 @@ AcpiDsInitObjectFromOp ( ObjDesc->Reference.Offset = Opcode - AML_LOCAL_OP; #ifndef ACPI_NO_METHOD_EXECUTION - Status = AcpiDsMethodDataGetNode (AML_LOCAL_OP, ObjDesc->Reference.Offset, - WalkState, (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); + Status = AcpiDsMethodDataGetNode (AML_LOCAL_OP, + ObjDesc->Reference.Offset, + WalkState, + (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); #endif break; @@ -694,8 +713,10 @@ AcpiDsInitObjectFromOp ( ObjDesc->Reference.Offset = Opcode - AML_ARG_OP; #ifndef ACPI_NO_METHOD_EXECUTION - Status = AcpiDsMethodDataGetNode (AML_ARG_OP, ObjDesc->Reference.Offset, - WalkState, (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); + Status = AcpiDsMethodDataGetNode (AML_ARG_OP, + ObjDesc->Reference.Offset, + WalkState, + (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); #endif break; diff --git a/sys/dev/acpi/acpica/Subsystem/dsopcode.c b/sys/dev/acpi/acpica/Subsystem/dsopcode.c index d5343cb178f..00ef3e4feba 100644 --- a/sys/dev/acpi/acpica/Subsystem/dsopcode.c +++ b/sys/dev/acpi/acpica/Subsystem/dsopcode.c @@ -2,7 +2,7 @@ * * Module Name: dsopcode - Dispatcher Op Region support and handling of * "control" opcodes - * xRevision: 93 $ + * xRevision: 102 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsopcode.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dsopcode.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __DSOPCODE_C__ @@ -131,12 +131,31 @@ __KERNEL_RCSID(0, "$NetBSD: dsopcode.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsopcode") +/* Local prototypes */ -/***************************************************************************** +static ACPI_STATUS +AcpiDsExecuteArguments ( + ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart); + +static ACPI_STATUS +AcpiDsInitBufferField ( + UINT16 AmlOpcode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *BufferDesc, + ACPI_OPERAND_OBJECT *OffsetDesc, + ACPI_OPERAND_OBJECT *LengthDesc, + ACPI_OPERAND_OBJECT *ResultDesc); + + +/******************************************************************************* * * FUNCTION: AcpiDsExecuteArguments * - * PARAMETERS: Node - Parent NS node + * PARAMETERS: Node - Object NS node + * ScopeNode - Parent NS node * AmlLength - Length of executable AML * AmlStart - Pointer to the AML * @@ -144,9 +163,9 @@ __KERNEL_RCSID(0, "$NetBSD: dsopcode.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * * DESCRIPTION: Late (deferred) execution of region or field arguments * - ****************************************************************************/ + ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsExecuteArguments ( ACPI_NAMESPACE_NODE *Node, ACPI_NAMESPACE_NODE *ScopeNode, @@ -156,7 +175,6 @@ AcpiDsExecuteArguments ( ACPI_STATUS Status; ACPI_PARSE_OBJECT *Op; ACPI_WALK_STATE *WalkState; - ACPI_PARSE_OBJECT *Arg; ACPI_FUNCTION_TRACE ("DsExecuteArguments"); @@ -184,7 +202,7 @@ AcpiDsExecuteArguments ( } Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, NULL, 1); + AmlLength, NULL, 1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -207,9 +225,7 @@ AcpiDsExecuteArguments ( /* Get and init the Op created above */ - Arg = Op->Common.Value.Arg; Op->Common.Node = Node; - Arg->Common.Node = Node; AcpiPsDeleteParseTree (Op); /* Evaluate the deferred arguments */ @@ -233,7 +249,7 @@ AcpiDsExecuteArguments ( /* Execute the opcode and arguments */ Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, - AmlLength, NULL, NULL, 3); + AmlLength, NULL, 3); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); @@ -249,7 +265,7 @@ AcpiDsExecuteArguments ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsGetBufferFieldArguments * @@ -260,7 +276,7 @@ AcpiDsExecuteArguments ( * DESCRIPTION: Get BufferField Buffer and Index. This implements the late * evaluation of these field attributes. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsGetBufferFieldArguments ( @@ -296,7 +312,7 @@ AcpiDsGetBufferFieldArguments ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsGetBufferArguments * @@ -307,7 +323,7 @@ AcpiDsGetBufferFieldArguments ( * DESCRIPTION: Get Buffer length and initializer byte list. This implements * the late evaluation of these attributes. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsGetBufferArguments ( @@ -345,7 +361,7 @@ AcpiDsGetBufferArguments ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsGetPackageArguments * @@ -356,7 +372,7 @@ AcpiDsGetBufferArguments ( * DESCRIPTION: Get Package length and initializer byte list. This implements * the late evaluation of these attributes. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsGetPackageArguments ( @@ -447,17 +463,17 @@ AcpiDsGetRegionArguments ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsInitializeRegion * - * PARAMETERS: Op - A valid region Op object + * PARAMETERS: ObjHandle - Region namespace node * * RETURN: Status * * DESCRIPTION: Front end to EvInitializeRegion * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsInitializeRegion ( @@ -476,7 +492,7 @@ AcpiDsInitializeRegion ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsInitBufferField * @@ -484,16 +500,16 @@ AcpiDsInitializeRegion ( * ObjDesc - BufferField object * BufferDesc - Host Buffer * OffsetDesc - Offset into buffer - * Length - Length of field (CREATE_FIELD_OP only) - * Result - Where to store the result + * LengthDesc - Length of field (CREATE_FIELD_OP only) + * ResultDesc - Where to store the result * * RETURN: Status * * DESCRIPTION: Perform actual initialization of a buffer field * - ****************************************************************************/ + ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsInitBufferField ( UINT16 AmlOpcode, ACPI_OPERAND_OBJECT *ObjDesc, @@ -531,8 +547,10 @@ AcpiDsInitBufferField ( */ if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination not a NS Node [%s]\n", - AcpiPsGetOpcodeName (AmlOpcode), AcpiUtGetDescriptorName (ResultDesc))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "(%s) destination not a NS Node [%s]\n", + AcpiPsGetOpcodeName (AmlOpcode), + AcpiUtGetDescriptorName (ResultDesc))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -549,9 +567,19 @@ AcpiDsInitBufferField ( /* Offset is in bits, count is in bits */ + FieldFlags = AML_FIELD_ACCESS_BYTE; BitOffset = Offset; BitCount = (UINT32) LengthDesc->Integer.Value; - FieldFlags = AML_FIELD_ACCESS_BYTE; + + /* Must have a valid (>0) bit count */ + + if (BitCount == 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Attempt to CreateField of length 0\n")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } break; case AML_CREATE_BIT_FIELD_OP: @@ -625,7 +653,8 @@ AcpiDsInitBufferField ( /* * Initialize areas of the field object that are common to all fields - * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE) + * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), + * UPDATE_RULE = 0 (UPDATE_PRESERVE) */ Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, BitOffset, BitCount); @@ -638,8 +667,8 @@ AcpiDsInitBufferField ( /* Reference count for BufferDesc inherits ObjDesc count */ - BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount + - ObjDesc->Common.ReferenceCount); + BufferDesc->Common.ReferenceCount = (UINT16) + (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount); Cleanup: @@ -671,7 +700,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsEvalBufferFieldOperands * @@ -683,7 +712,7 @@ Cleanup: * DESCRIPTION: Get BufferField Buffer and Index * Called from AcpiDsExecEndOp during BufferField parse tree walk * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsEvalBufferFieldOperands ( @@ -763,7 +792,7 @@ AcpiDsEvalBufferFieldOperands ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsEvalRegionOperands * @@ -775,7 +804,7 @@ AcpiDsEvalBufferFieldOperands ( * DESCRIPTION: Get region address and length * Called from AcpiDsExecEndOp during OpRegion parse tree walk * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsEvalRegionOperands ( @@ -793,7 +822,8 @@ AcpiDsEvalRegionOperands ( /* - * This is where we evaluate the address and length fields of the OpRegion declaration + * This is where we evaluate the address and length fields of the + * OpRegion declaration */ Node = Op->Common.Node; @@ -815,7 +845,8 @@ AcpiDsEvalRegionOperands ( /* Resolve the length and address operands to numbers */ - Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -846,7 +877,8 @@ AcpiDsEvalRegionOperands ( */ OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; - ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value; + ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) + OperandDesc->Integer.Value; AcpiUtRemoveReference (OperandDesc); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", @@ -862,7 +894,7 @@ AcpiDsEvalRegionOperands ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsEvalDataObjectOperands * @@ -872,11 +904,10 @@ AcpiDsEvalRegionOperands ( * * RETURN: Status * - * DESCRIPTION: Get the operands and complete the following data objec types: - * Buffer - * Package + * DESCRIPTION: Get the operands and complete the following data object types: + * Buffer, Package. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsEvalDataObjectOperands ( @@ -946,7 +977,7 @@ AcpiDsEvalDataObjectOperands ( if (ACPI_SUCCESS (Status)) { /* - * Return the object in the WalkState, unless the parent is a package -- + * Return the object in the WalkState, unless the parent is a package - * in this case, the return object will be stored in the parse tree * for the package. */ @@ -1110,7 +1141,8 @@ AcpiDsExecEndControlOp ( Status = AE_CTRL_PENDING; } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[WHILE_OP] termination! Op=%p\n",Op)); /* Pop this control state and free it */ @@ -1133,6 +1165,10 @@ AcpiDsExecEndControlOp ( */ if (Op->Common.Value.Arg) { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + /* Return statement has an immediate operand */ Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); @@ -1162,6 +1198,10 @@ AcpiDsExecEndControlOp ( else if ((WalkState->Results) && (WalkState->Results->Results.NumResults > 0)) { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + /* * The return value has come from a previous calculation. * diff --git a/sys/dev/acpi/acpica/Subsystem/dsutils.c b/sys/dev/acpi/acpica/Subsystem/dsutils.c index 0a34c4f1beb..5af9c7de5cc 100644 --- a/sys/dev/acpi/acpica/Subsystem/dsutils.c +++ b/sys/dev/acpi/acpica/Subsystem/dsutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dsutils - Dispatcher utilities - * xRevision: 102 $ + * xRevision: 113 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dsutils.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dsutils.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __DSUTILS_C__ @@ -131,17 +131,131 @@ __KERNEL_RCSID(0, "$NetBSD: dsutils.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); ACPI_MODULE_NAME ("dsutils") +/******************************************************************************* + * + * FUNCTION: AcpiDsClearImplicitReturn + * + * PARAMETERS: WalkState - Current State + * + * RETURN: None. + * + * DESCRIPTION: Clear and remove a reference on an implicit return value. Used + * to delete "stale" return values (if enabled, the return value + * from every operator is saved at least momentarily, in case the + * parent method exits.) + * + ******************************************************************************/ + +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME ("DsClearImplicitReturn"); + + + /* + * Slack must be enabled for this feature + */ + if (!AcpiGbl_EnableInterpreterSlack) + { + return; + } + + if (WalkState->ImplicitReturnObj) + { + /* + * Delete any "stale" implicit return. However, in + * complex statements, the implicit return value can be + * bubbled up several levels. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Removing reference on stale implicit return obj %p\n", + WalkState->ImplicitReturnObj)); + + AcpiUtRemoveReference (WalkState->ImplicitReturnObj); + WalkState->ImplicitReturnObj = NULL; + } +} + + #ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiDsDoImplicitReturn + * + * PARAMETERS: ReturnDesc - The return value + * WalkState - Current State + * AddReference - True if a reference should be added to the + * return object + * + * RETURN: TRUE if implicit return enabled, FALSE otherwise + * + * DESCRIPTION: Implements the optional "implicit return". We save the result + * of every ASL operator and control method invocation in case the + * parent method exit. Before storing a new return value, we + * delete the previous return value. + * + ******************************************************************************/ + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference) +{ + ACPI_FUNCTION_NAME ("DsDoImplicitReturn"); + + + /* + * Slack must be enabled for this feature, and we must + * have a valid return object + */ + if ((!AcpiGbl_EnableInterpreterSlack) || + (!ReturnDesc)) + { + return (FALSE); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result %p will be implicitly returned; Prev=%p\n", + ReturnDesc, + WalkState->ImplicitReturnObj)); + + /* + * Delete any "stale" implicit return value first. However, in + * complex statements, the implicit return value can be + * bubbled up several levels, so we don't clear the value if it + * is the same as the ReturnDesc. + */ + if (WalkState->ImplicitReturnObj) + { + if (WalkState->ImplicitReturnObj == ReturnDesc) + { + return (TRUE); + } + AcpiDsClearImplicitReturn (WalkState); + } + + /* Save the implicit return value, add a reference if requested */ + + WalkState->ImplicitReturnObj = ReturnDesc; + if (AddReference) + { + AcpiUtAddReference (ReturnDesc); + } + + return (TRUE); +} + /******************************************************************************* * * FUNCTION: AcpiDsIsResultUsed * - * PARAMETERS: Op - * ResultObj - * WalkState + * PARAMETERS: Op - Current Op + * WalkState - Current State * - * RETURN: Status + * RETURN: TRUE if result is used, FALSE otherwise * * DESCRIPTION: Check if a result object will be used by the parent * @@ -154,7 +268,6 @@ AcpiDsIsResultUsed ( { const ACPI_OPCODE_INFO *ParentInfo; - ACPI_FUNCTION_TRACE_PTR ("DsIsResultUsed", Op); @@ -167,23 +280,42 @@ AcpiDsIsResultUsed ( } /* - * If there is no parent, the result can't possibly be used! - * (An executing method typically has no parent, since each - * method is parsed separately) However, a method that is - * invoked from another method has a parent. + * We know that this operator is not a + * Return() operator (would not come here.) The following code is the + * optional support for a so-called "implicit return". Some AML code + * assumes that the last value of the method is "implicitly" returned + * to the caller. Just save the last result as the return value. + * NOTE: this is optional because the ASL language does not actually + * support this behavior. + */ + (void) AcpiDsDoImplicitReturn (WalkState->ResultObj, WalkState, TRUE); + + /* + * Now determine if the parent will use the result + * + * If there is no parent, or the parent is a ScopeOp, we are executing + * at the method level. An executing method typically has no parent, + * since each method is parsed separately. A method invoked externally + * via ExecuteControlMethod has a ScopeOp as the parent. */ - if (!Op->Common.Parent) + if ((!Op->Common.Parent) || + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) { + /* No parent, the return value cannot possibly be used */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "At Method level, result of [%s] not used\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode))); return_VALUE (FALSE); } - /* - * Get info on the parent. The root Op is AML_SCOPE - */ + /* Get info on the parent. The RootOp is AML_SCOPE */ + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); if (ParentInfo->Class == AML_CLASS_UNKNOWN) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown parent opcode. Op=%p\n", Op)); return_VALUE (FALSE); } @@ -268,17 +400,19 @@ AcpiDsIsResultUsed ( ResultUsed: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n", - AcpiPsGetOpcodeName (Op->Common.AmlOpcode), - AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); return_VALUE (TRUE); ResultNotUsed: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n", - AcpiPsGetOpcodeName (Op->Common.AmlOpcode), - AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] not used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); return_VALUE (FALSE); } @@ -288,9 +422,9 @@ ResultNotUsed: * * FUNCTION: AcpiDsDeleteResultIfNotUsed * - * PARAMETERS: Op - * ResultObj - * WalkState + * PARAMETERS: Op - Current parse Op + * ResultObj - Result of the operation + * WalkState - Current state * * RETURN: Status * @@ -327,9 +461,8 @@ AcpiDsDeleteResultIfNotUsed ( if (!AcpiDsIsResultUsed (Op, WalkState)) { - /* - * Must pop the result stack (ObjDesc should be equal to ResultObj) - */ + /* Must pop the result stack (ObjDesc should be equal to ResultObj) */ + Status = AcpiDsResultPop (&ObjDesc, WalkState); if (ACPI_SUCCESS (Status)) { @@ -403,12 +536,11 @@ AcpiDsClearOperands ( UINT32 i; - ACPI_FUNCTION_TRACE_PTR ("AcpiDsClearOperands", WalkState); + ACPI_FUNCTION_TRACE_PTR ("DsClearOperands", WalkState); - /* - * Remove a reference on each operand on the stack - */ + /* Remove a reference on each operand on the stack */ + for (i = 0; i < WalkState->NumOperands; i++) { /* @@ -429,8 +561,9 @@ AcpiDsClearOperands ( * * FUNCTION: AcpiDsCreateOperand * - * PARAMETERS: WalkState - * Arg + * PARAMETERS: WalkState - Current walk state + * Arg - Parse object for the argument + * ArgIndex - Which argument (zero based) * * RETURN: Status * @@ -477,11 +610,7 @@ AcpiDsCreateOperand ( return_ACPI_STATUS (Status); } - /* - * All prefixes have been handled, and the name is - * in NameString - */ - + /* All prefixes have been handled, and the name is in NameString */ /* * Special handling for BufferField declarations. This is a deferred @@ -496,7 +625,8 @@ AcpiDsCreateOperand ( (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) && (ArgIndex != 0)) { - ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, WalkState->DeferredNode); + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, WalkState->DeferredNode); Status = AE_OK; } else /* All other opcodes */ @@ -526,10 +656,10 @@ AcpiDsCreateOperand ( } Status = AcpiNsLookup (WalkState->ScopeInfo, NameString, - ACPI_TYPE_ANY, InterpreterMode, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc)); + ACPI_TYPE_ANY, InterpreterMode, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc)); /* * The only case where we pass through (ignore) a NOT_FOUND * error is for the CondRefOf opcode. @@ -544,7 +674,8 @@ AcpiDsCreateOperand ( * indicate this to the interpreter, set the * object to the root */ - ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); Status = AE_OK; } else @@ -597,7 +728,8 @@ AcpiDsCreateOperand ( */ Opcode = AML_ZERO_OP; /* Has no arguments! */ - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", Arg)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Null namepath: Arg=%p\n", Arg)); } else { @@ -631,7 +763,8 @@ AcpiDsCreateOperand ( * Only error is underflow, and this indicates * a missing or null operand! */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Missing or null operand, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } @@ -648,8 +781,8 @@ AcpiDsCreateOperand ( /* Initialize the new object */ - Status = AcpiDsInitObjectFromOp (WalkState, Arg, - Opcode, &ObjDesc); + Status = AcpiDsInitObjectFromOp ( + WalkState, Arg, Opcode, &ObjDesc); if (ACPI_FAILURE (Status)) { AcpiUtDeleteObjectDesc (ObjDesc); @@ -676,7 +809,8 @@ AcpiDsCreateOperand ( * * FUNCTION: AcpiDsCreateOperands * - * PARAMETERS: FirstArg - First argument of a parser argument tree + * PARAMETERS: WalkState - Current state + * FirstArg - First argument of a parser argument tree * * RETURN: Status * diff --git a/sys/dev/acpi/acpica/Subsystem/dswexec.c b/sys/dev/acpi/acpica/Subsystem/dswexec.c index 75ab18f6417..2dc5c95dfe6 100644 --- a/sys/dev/acpi/acpica/Subsystem/dswexec.c +++ b/sys/dev/acpi/acpica/Subsystem/dswexec.c @@ -2,7 +2,7 @@ * * Module Name: dswexec - Dispatcher method execution callbacks; * dispatch to interpreter. - * xRevision: 106 $ + * xRevision: 120 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dswexec.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dswexec.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __DSWEXEC_C__ @@ -137,23 +137,26 @@ __KERNEL_RCSID(0, "$NetBSD: dswexec.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * Dispatch table for opcode classes */ static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = { - AcpiExOpcode_1A_0T_0R, - AcpiExOpcode_1A_0T_1R, - AcpiExOpcode_1A_1T_0R, - AcpiExOpcode_1A_1T_1R, - AcpiExOpcode_2A_0T_0R, - AcpiExOpcode_2A_0T_1R, - AcpiExOpcode_2A_1T_1R, - AcpiExOpcode_2A_2T_1R, - AcpiExOpcode_3A_0T_0R, - AcpiExOpcode_3A_1T_1R, - AcpiExOpcode_6A_0T_1R}; + AcpiExOpcode_0A_0T_1R, + AcpiExOpcode_1A_0T_0R, + AcpiExOpcode_1A_0T_1R, + AcpiExOpcode_1A_1T_0R, + AcpiExOpcode_1A_1T_1R, + AcpiExOpcode_2A_0T_0R, + AcpiExOpcode_2A_0T_1R, + AcpiExOpcode_2A_1T_1R, + AcpiExOpcode_2A_2T_1R, + AcpiExOpcode_3A_0T_0R, + AcpiExOpcode_3A_1T_1R, + AcpiExOpcode_6A_0T_1R}; + /***************************************************************************** * * FUNCTION: AcpiDsGetPredicateValue * * PARAMETERS: WalkState - Current state of the parse tree walk + * ResultObj - if non-zero, pop result from result stack * * RETURN: Status * @@ -168,6 +171,7 @@ AcpiDsGetPredicateValue ( { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *LocalObjDesc = NULL; ACPI_FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState); @@ -206,20 +210,27 @@ AcpiDsGetPredicateValue ( if (!ObjDesc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No predicate ObjDesc=%p State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "No predicate ObjDesc=%p State=%p\n", ObjDesc, WalkState)); return_ACPI_STATUS (AE_AML_NO_OPERAND); } /* - * Result of predicate evaluation currently must - * be a number + * Result of predicate evaluation must be an Integer + * object. Implicitly convert the argument if necessary. */ - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) + Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, 16); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_GET_OBJECT_TYPE (LocalObjDesc) != ACPI_TYPE_INTEGER) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Bad predicate (not a number) ObjDesc=%p State=%p Type=%X\n", + "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X\n", ObjDesc, WalkState, ACPI_GET_OBJECT_TYPE (ObjDesc))); Status = AE_AML_OPERAND_TYPE; @@ -228,13 +239,13 @@ AcpiDsGetPredicateValue ( /* Truncate the predicate to 32-bits if necessary */ - AcpiExTruncateFor32bitTable (ObjDesc); + AcpiExTruncateFor32bitTable (LocalObjDesc); /* * Save the result of the predicate evaluation on * the control stack */ - if (ObjDesc->Integer.Value) + if (LocalObjDesc->Integer.Value) { WalkState->ControlState->Common.Value = TRUE; } @@ -256,12 +267,16 @@ Cleanup: /* Break to debugger to display result */ - ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (ObjDesc, WalkState)); + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (LocalObjDesc, WalkState)); /* * Delete the predicate result object (we know that * we don't need it anymore) */ + if (LocalObjDesc != ObjDesc) + { + AcpiUtRemoveReference (LocalObjDesc); + } AcpiUtRemoveReference (ObjDesc); WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL; @@ -274,7 +289,7 @@ Cleanup: * FUNCTION: AcpiDsExecBeginOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * OutOp - Return op if a new one is created + * OutOp - Where to return op if a new one is created * * RETURN: Status * @@ -313,7 +328,8 @@ AcpiDsExecBeginOp ( if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "(%s) Popping scope for Op %p\n", AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op)); Status = AcpiDsScopeStackPop (WalkState); @@ -385,11 +401,10 @@ AcpiDsExecBeginOp ( if (WalkState->WalkType == ACPI_WALK_METHOD) { /* - * Found a named object declaration during method - * execution; we must enter this object into the - * namespace. The created object is temporary and - * will be deleted upon completion of the execution - * of this method. + * Found a named object declaration during method execution; + * we must enter this object into the namespace. The created + * object is temporary and will be deleted upon completion of + * the execution of this method. */ Status = AcpiDsLoad2BeginOp (WalkState, NULL); } @@ -404,9 +419,10 @@ AcpiDsExecBeginOp ( case AML_CLASS_EXECUTE: case AML_CLASS_CREATE: - /* most operators with arguments */ - /* Start a new result/operand state */ - + /* + * Most operators with arguments. + * Start a new result/operand state + */ Status = AcpiDsResultStackPush (WalkState); break; @@ -426,8 +442,6 @@ AcpiDsExecBeginOp ( * FUNCTION: AcpiDsExecEndOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been completed in the - * walk; Arguments have now been evaluated. * * RETURN: Status * @@ -479,7 +493,7 @@ AcpiDsExecEndOp ( switch (OpClass) { - case AML_CLASS_ARGUMENT: /* constants, literals, etc. -- do nothing */ + case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */ break; @@ -501,23 +515,33 @@ AcpiDsExecEndOp ( goto Cleanup; } - /* Resolve all operands */ + /* + * All opcodes require operand resolution, with the only exceptions + * being the ObjectType and SizeOf operators. + */ + if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE)) + { + /* Resolve all operands */ - Status = AcpiExResolveOperands (WalkState->Opcode, + Status = AcpiExResolveOperands (WalkState->Opcode, &(WalkState->Operands [WalkState->NumOperands -1]), WalkState); + if (ACPI_SUCCESS (Status)) + { + ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, + AcpiPsGetOpcodeName (WalkState->Opcode), + WalkState->NumOperands, "after ExResolveOperands"); + } + } + if (ACPI_SUCCESS (Status)) { - ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, - AcpiPsGetOpcodeName (WalkState->Opcode), - WalkState->NumOperands, "after ExResolveOperands"); - /* * Dispatch the request to the appropriate interpreter handler * routine. There is one routine per opcode "type" based upon the * number of opcode arguments and return type. */ - Status = AcpiGbl_OpTypeDispatch [OpType] (WalkState); + Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState); } else { @@ -530,7 +554,9 @@ AcpiDsExecEndOp ( (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (WalkState->Operands[0]->Reference.Opcode == - WalkState->Operands[1]->Reference.Opcode)) + WalkState->Operands[1]->Reference.Opcode) && + (WalkState->Operands[0]->Reference.Offset == + WalkState->Operands[1]->Reference.Offset)) { Status = AE_OK; } @@ -569,21 +595,46 @@ AcpiDsExecEndOp ( /* 1 Operand, 0 ExternalResult, 0 InternalResult */ Status = AcpiDsExecEndControlOp (WalkState, Op); - if (ACPI_FAILURE (Status)) + + /* Make sure to properly pop the result stack */ + + if (ACPI_SUCCESS (Status)) { - break; + Status = AcpiDsResultStackPop (WalkState); + } + else if (Status == AE_CTRL_PENDING) + { + Status = AcpiDsResultStackPop (WalkState); + if (ACPI_SUCCESS (Status)) + { + Status = AE_CTRL_PENDING; + } } - - Status = AcpiDsResultStackPop (WalkState); break; case AML_TYPE_METHOD_CALL: + /* + * If the method is referenced from within a package + * declaration, it is not a invocation of the method, just + * a reference to it. + */ + if ((Op->Asl.Parent) && + ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) || + (Op->Asl.Parent->Asl.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Method Reference in a Package, Op=%p\n", Op)); + Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node->Object; + AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object); + return_ACPI_STATUS (AE_OK); + } + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op)); /* - * (AML_METHODCALL) Op->Value->Arg->Node contains + * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains * the method Node pointer */ /* NextOp points to the op that holds the method name */ @@ -655,13 +706,15 @@ AcpiDsExecEndOp ( case AML_NAME_OP: /* - * Put the Node on the object stack (Contains the ACPI Name of - * this object) + * Put the Node on the object stack (Contains the ACPI Name + * of this object) */ WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node; WalkState->NumOperands = 1; - Status = AcpiDsCreateNode (WalkState, Op->Common.Parent->Common.Node, Op->Common.Parent); + Status = AcpiDsCreateNode (WalkState, + Op->Common.Parent->Common.Node, + Op->Common.Parent); if (ACPI_FAILURE (Status)) { break; @@ -673,7 +726,7 @@ AcpiDsExecEndOp ( case AML_INT_EVAL_SUBTREE_OP: Status = AcpiDsEvalDataObjectOperands (WalkState, Op, - AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); + AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); break; default: @@ -682,12 +735,19 @@ AcpiDsExecEndOp ( break; } + /* Done with result state (Now that operand stack is built) */ + + Status = AcpiDsResultStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + /* * If a result object was returned from above, push it on the * current result stack */ - if (ACPI_SUCCESS (Status) && - WalkState->ResultObj) + if (WalkState->ResultObj) { Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); } @@ -724,7 +784,8 @@ AcpiDsExecEndOp ( case AML_TYPE_UNDEFINED: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Undefined opcode type Op=%p\n", Op)); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); @@ -758,7 +819,8 @@ AcpiDsExecEndOp ( * conditional predicate */ - if ((WalkState->ControlState) && + if ((ACPI_SUCCESS (Status)) && + (WalkState->ControlState) && (WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) && (WalkState->ControlState->Control.PredicateOp == Op)) @@ -769,11 +831,26 @@ AcpiDsExecEndOp ( Cleanup: + + /* Invoke exception handler on error */ + + if (ACPI_FAILURE (Status) && + AcpiGbl_ExceptionHandler && + !(Status & AE_CODE_CONTROL)) + { + AcpiExExitInterpreter (); + Status = AcpiGbl_ExceptionHandler (Status, + WalkState->MethodNode->Name.Integer, WalkState->Opcode, + WalkState->AmlOffset, NULL); + (void) AcpiExEnterInterpreter (); + } + if (WalkState->ResultObj) { /* Break to debugger to display result */ - ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, WalkState)); + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, + WalkState)); /* * Delete the result op if and only if: diff --git a/sys/dev/acpi/acpica/Subsystem/dswload.c b/sys/dev/acpi/acpica/Subsystem/dswload.c index b97bc72b972..f219576822a 100644 --- a/sys/dev/acpi/acpica/Subsystem/dswload.c +++ b/sys/dev/acpi/acpica/Subsystem/dswload.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswload - Dispatcher namespace load callbacks - * xRevision: 86 $ + * xRevision: 92 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dswload.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dswload.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __DSWLOAD_C__ @@ -127,6 +127,9 @@ __KERNEL_RCSID(0, "$NetBSD: dswload.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #include "acnamesp.h" #include "acevents.h" +#ifdef _ACPI_ASL_COMPILER +#include "acdisasm.h" +#endif #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dswload") @@ -154,20 +157,23 @@ AcpiDsInitCallbacks ( switch (PassNumber) { case 1: - WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; WalkState->DescendingCallback = AcpiDsLoad1BeginOp; WalkState->AscendingCallback = AcpiDsLoad1EndOp; break; case 2: - WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; WalkState->DescendingCallback = AcpiDsLoad2BeginOp; WalkState->AscendingCallback = AcpiDsLoad2EndOp; break; case 3: #ifndef ACPI_NO_METHOD_EXECUTION - WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | + ACPI_PARSE_DELETE_TREE; WalkState->DescendingCallback = AcpiDsExecBeginOp; WalkState->AscendingCallback = AcpiDsExecEndOp; #endif @@ -186,8 +192,7 @@ AcpiDsInitCallbacks ( * FUNCTION: AcpiDsLoad1BeginOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been reached in the - * walk; Arguments have not been evaluated yet. + * OutOp - Where to return op if a new one is created * * RETURN: Status * @@ -224,7 +229,8 @@ AcpiDsLoad1BeginOp ( if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) { - AcpiOsPrintf ("\n\n***EXECUTABLE OPCODE %s***\n\n", WalkState->OpInfo->Name); + AcpiOsPrintf ("\n\n***EXECUTABLE OPCODE %s***\n\n", + WalkState->OpInfo->Name); *OutOp = Op; return (AE_CTRL_SKIP); } @@ -262,6 +268,20 @@ AcpiDsLoad1BeginOp ( */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); +#ifdef _ACPI_ASL_COMPILER + if (Status == AE_NOT_FOUND) + { + /* + * Table disassembly: + * Target of Scope() not found. Generate an External for it, and + * insert the name into the namespace. + */ + AcpiDmAddToExternalList (Path); + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); + } +#endif if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR (Path, Status); @@ -294,10 +314,12 @@ AcpiDsLoad1BeginOp ( * Name (DEB, 0) * Scope (DEB) { ... } * - * Note: silently change the type here. On the second pass, we will report a warning + * Note: silently change the type here. On the second pass, we will report + * a warning */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", Path, AcpiUtGetTypeName (Node->Type))); Node->Type = ACPI_TYPE_ANY; @@ -308,7 +330,8 @@ AcpiDsLoad1BeginOp ( /* All other types are an error */ - ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", + ACPI_REPORT_ERROR (( + "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", AcpiUtGetTypeName (Node->Type), Path)); return (AE_AML_OPERAND_TYPE); @@ -319,7 +342,8 @@ AcpiDsLoad1BeginOp ( default: /* - * For all other named opcodes, we will enter the name into the namespace. + * For all other named opcodes, we will enter the name into + * the namespace. * * Setup the search flags. * Since we are entering a name into the namespace, we do not want to @@ -352,14 +376,16 @@ AcpiDsLoad1BeginOp ( } else { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Both Find or Create allowed\n", + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[%s] Both Find or Create allowed\n", AcpiUtGetTypeName (ObjectType))); } /* * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that involve - * arguments to the opcode must be created as we go back up the parse tree later. + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); @@ -411,8 +437,6 @@ AcpiDsLoad1BeginOp ( * FUNCTION: AcpiDsLoad1EndOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been completed in the - * walk; Arguments have now been evaluated. * * RETURN: Status * @@ -463,7 +487,9 @@ AcpiDsLoad1EndOp ( if (Op->Common.AmlOpcode == AML_REGION_OP) { Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, - (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), WalkState); + (ACPI_ADR_SPACE_TYPE) + ((Op->Common.Value.Arg)->Common.Value.Integer), + WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -477,7 +503,8 @@ AcpiDsLoad1EndOp ( if (Op->Common.Value.Arg) { - ObjectType = (AcpiPsGetOpcodeInfo ((Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; + ObjectType = (AcpiPsGetOpcodeInfo ( + (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; Op->Common.Node->Type = (UINT8) ObjectType; } } @@ -536,8 +563,7 @@ AcpiDsLoad1EndOp ( * FUNCTION: AcpiDsLoad2BeginOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been reached in the - * walk; Arguments have not been evaluated yet. + * OutOp - Wher to return op if a new one is created * * RETURN: Status * @@ -567,15 +593,22 @@ AcpiDsLoad2BeginOp ( { /* We only care about Namespace opcodes here */ - if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || + if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && + (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || (!(WalkState->OpInfo->Flags & AML_NAMED))) { + if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || + (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) + { + ACPI_REPORT_WARNING (( + "Encountered executable code at module level, [%s]\n", + AcpiPsGetOpcodeName (WalkState->Opcode))); + } return_ACPI_STATUS (AE_OK); } - /* - * Get the name we are going to enter or lookup in the namespace - */ + /* Get the name we are going to enter or lookup in the namespace */ + if (WalkState->Opcode == AML_INT_NAMEPATH_OP) { /* For Namepath op, get the path string */ @@ -623,24 +656,39 @@ AcpiDsLoad2BeginOp ( case AML_INT_NAMEPATH_OP: /* - * The NamePath is an object reference to an existing object. Don't enter the - * name into the namespace, but look it up for use later + * The NamePath is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); break; case AML_SCOPE_OP: /* - * The Path is an object reference to an existing object. Don't enter the - * name into the namespace, but look it up for use later + * The Path is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { +#ifdef _ACPI_ASL_COMPILER + if (Status == AE_NOT_FOUND) + { + Status = AE_OK; + } + else + { + ACPI_REPORT_NSERROR (BufferPtr, Status); + } +#else ACPI_REPORT_NSERROR (BufferPtr, Status); +#endif return_ACPI_STATUS (Status); } /* @@ -670,7 +718,8 @@ AcpiDsLoad2BeginOp ( * Scope (DEB) { ... } */ - ACPI_REPORT_WARNING (("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", + ACPI_REPORT_WARNING (( + "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", BufferPtr, AcpiUtGetTypeName (Node->Type))); Node->Type = ACPI_TYPE_ANY; @@ -681,7 +730,8 @@ AcpiDsLoad2BeginOp ( /* All other types are an error */ - ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s]\n", + ACPI_REPORT_ERROR (( + "Invalid type (%s) for target of Scope operator [%4.4s]\n", AcpiUtGetTypeName (Node->Type), BufferPtr)); return (AE_AML_OPERAND_TYPE); @@ -712,8 +762,9 @@ AcpiDsLoad2BeginOp ( /* * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that involve - * arguments to the opcode must be created as we go back up the parse tree later. + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. * * Note: Name may already exist if we are executing a deferred opcode. */ @@ -727,7 +778,8 @@ AcpiDsLoad2BeginOp ( } Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, + WalkState, &(Node)); break; } @@ -775,8 +827,6 @@ AcpiDsLoad2BeginOp ( * FUNCTION: AcpiDsLoad2EndOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been completed in the - * walk; Arguments have now been evaluated. * * RETURN: Status * @@ -837,7 +887,8 @@ AcpiDsLoad2EndOp ( /* Pop the scope stack */ - if (AcpiNsOpensScope (ObjectType) && (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) + if (AcpiNsOpensScope (ObjectType) && + (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", AcpiUtGetTypeName (ObjectType), Op)); @@ -906,7 +957,7 @@ AcpiDsLoad2EndOp ( case AML_INDEX_FIELD_OP: Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, - WalkState); + WalkState); break; case AML_BANK_FIELD_OP: @@ -991,14 +1042,16 @@ AcpiDsLoad2EndOp ( #ifndef ACPI_NO_METHOD_EXECUTION case AML_REGION_OP: /* - * The OpRegion is not fully parsed at this time. Only valid argument is the SpaceId. - * (We must save the address of the AML of the address and length operands) + * The OpRegion is not fully parsed at this time. Only valid + * argument is the SpaceId. (We must save the address of the + * AML of the address and length operands) */ /* * If we have a valid region, initialize it * Namespace is NOT locked at this point. */ - Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), FALSE); + Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), + FALSE); if (ACPI_FAILURE (Status)) { /* @@ -1052,16 +1105,17 @@ AcpiDsLoad2EndOp ( { /* * Make sure that what we found is indeed a method - * We didn't search for a method on purpose, to see if the name would resolve + * We didn't search for a method on purpose, to see if the name + * would resolve */ if (NewNode->Type != ACPI_TYPE_METHOD) { Status = AE_AML_OPERAND_TYPE; } - /* We could put the returned object (Node) on the object stack for later, but - * for now, we will put it in the "op" object that the parser uses, so we - * can get it again at the end of this scope + /* We could put the returned object (Node) on the object stack for + * later, but for now, we will put it in the "op" object that the + * parser uses, so we can get it again at the end of this scope */ Op->Common.Node = NewNode; } diff --git a/sys/dev/acpi/acpica/Subsystem/dswscope.c b/sys/dev/acpi/acpica/Subsystem/dswscope.c index 0aa4b53e960..87c2efb3499 100644 --- a/sys/dev/acpi/acpica/Subsystem/dswscope.c +++ b/sys/dev/acpi/acpica/Subsystem/dswscope.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswscope - Scope stack manipulation - * xRevision: 60 $ + * xRevision: 63 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dswscope.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dswscope.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __DSWSCOPE_C__ @@ -127,14 +127,13 @@ __KERNEL_RCSID(0, "$NetBSD: dswscope.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); ACPI_MODULE_NAME ("dswscope") -#define STACK_POP(head) head - - /**************************************************************************** * * FUNCTION: AcpiDsScopeStackClear * - * PARAMETERS: None + * PARAMETERS: WalkState - Current state + * + * RETURN: None * * DESCRIPTION: Pop (and free) everything on the scope stack except the * root scope object (which remains at the stack top.) @@ -158,7 +157,8 @@ AcpiDsScopeStackClear ( WalkState->ScopeInfo = ScopeInfo->Scope.Next; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Popped object type (%s)\n", AcpiUtGetTypeName (ScopeInfo->Common.Value))); + "Popped object type (%s)\n", + AcpiUtGetTypeName (ScopeInfo->Common.Value))); AcpiUtDeleteGenericState (ScopeInfo); } } @@ -168,8 +168,11 @@ AcpiDsScopeStackClear ( * * FUNCTION: AcpiDsScopeStackPush * - * PARAMETERS: *Node, - Name to be made current - * Type, - Type of frame being pushed + * PARAMETERS: Node - Name to be made current + * Type - Type of frame being pushed + * WalkState - Current state + * + * RETURN: Status * * DESCRIPTION: Push the current scope on the scope stack, and make the * passed Node current. @@ -201,7 +204,8 @@ AcpiDsScopeStackPush ( if (!AcpiUtValidObjectType (Type)) { - ACPI_REPORT_WARNING (("DsScopeStackPush: Invalid object type: 0x%X\n", Type)); + ACPI_REPORT_WARNING (( + "DsScopeStackPush: Invalid object type: 0x%X\n", Type)); } /* Allocate a new scope object */ @@ -253,16 +257,11 @@ AcpiDsScopeStackPush ( * * FUNCTION: AcpiDsScopeStackPop * - * PARAMETERS: Type - The type of frame to be found + * PARAMETERS: WalkState - Current state * - * DESCRIPTION: Pop the scope stack until a frame of the requested type - * is found. + * RETURN: Status * - * RETURN: Count of frames popped. If no frame of the requested type - * was found, the count is returned as a negative number and - * the scope stack is emptied (which sets the current scope - * to the root). If the scope stack was empty at entry, the - * function is a no-op and returns 0. + * DESCRIPTION: Pop the scope stack once. * ***************************************************************************/ diff --git a/sys/dev/acpi/acpica/Subsystem/dswstate.c b/sys/dev/acpi/acpica/Subsystem/dswstate.c index c14822bb041..d91325d59eb 100644 --- a/sys/dev/acpi/acpica/Subsystem/dswstate.c +++ b/sys/dev/acpi/acpica/Subsystem/dswstate.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines - * xRevision: 78 $ + * xRevision: 86 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dswstate.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dswstate.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __DSWSTATE_C__ @@ -128,67 +128,29 @@ __KERNEL_RCSID(0, "$NetBSD: dswstate.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dswstate") +/* Local prototypes */ -/******************************************************************************* - * - * FUNCTION: AcpiDsResultInsert - * - * PARAMETERS: Object - Object to push - * Index - Where to insert the object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Insert an object onto this walk's result stack - * - ******************************************************************************/ - +#ifdef ACPI_OBSOLETE_FUNCTIONS ACPI_STATUS AcpiDsResultInsert ( void *Object, UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_NAME ("DsResultInsert"); - + ACPI_WALK_STATE *WalkState); - State = WalkState->Results; - if (!State) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", - WalkState)); - return (AE_NOT_EXIST); - } - - if (Index >= ACPI_OBJ_NUM_OPERANDS) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index out of range: %X Obj=%p State=%p Num=%X\n", - Index, Object, WalkState, State->Results.NumResults)); - return (AE_BAD_PARAMETER); - } - - if (!Object) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null Object! Index=%X Obj=%p State=%p Num=%X\n", - Index, Object, WalkState, State->Results.NumResults)); - return (AE_BAD_PARAMETER); - } - - State->Results.ObjDesc [Index] = Object; - State->Results.NumResults++; +ACPI_STATUS +AcpiDsObjStackDeleteAll ( + ACPI_WALK_STATE *WalkState); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] State=%p Num=%X Cur=%X\n", - Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", - WalkState, State->Results.NumResults, WalkState->CurrentResult)); +ACPI_STATUS +AcpiDsObjStackPopObject ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState); - return (AE_OK); -} +void * +AcpiDsObjStackGetValue ( + UINT32 Index, + ACPI_WALK_STATE *WalkState); +#endif /******************************************************************************* @@ -311,15 +273,18 @@ AcpiDsResultPop ( *Object = State->Results.ObjDesc [Index -1]; State->Results.ObjDesc [Index -1] = NULL; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n", - *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj=%p [%s] Index=%X State=%p Num=%X\n", + *Object, + (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", (UINT32) Index -1, WalkState, State->Results.NumResults)); return (AE_OK); } } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "No result objects! State=%p\n", WalkState)); return (AE_AML_NO_RETURN_VALUE); } @@ -360,7 +325,8 @@ AcpiDsResultPopFromBottom ( if (!State->Results.NumResults) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", + WalkState)); return (AE_AML_NO_RETURN_VALUE); } @@ -381,7 +347,8 @@ AcpiDsResultPopFromBottom ( if (!*Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null operand! State=%p #Ops=%X, Index=%X\n", WalkState, State->Results.NumResults, (UINT32) Index)); return (AE_AML_NO_RETURN_VALUE); } @@ -435,7 +402,8 @@ AcpiDsResultPush ( if (!Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null Object! Obj=%p State=%p Num=%X\n", Object, WalkState, State->Results.NumResults)); return (AE_BAD_PARAMETER); } @@ -532,44 +500,6 @@ AcpiDsResultStackPop ( /******************************************************************************* * - * FUNCTION: AcpiDsObjStackDeleteAll - * - * PARAMETERS: WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Clear the object stack by deleting all objects that are on it. - * Should be used with great care, if at all! - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsObjStackDeleteAll ( - ACPI_WALK_STATE *WalkState) -{ - UINT32 i; - - - ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); - - - /* The stack size is configurable, but fixed */ - - for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) - { - if (WalkState->Operands[i]) - { - AcpiUtRemoveReference (WalkState->Operands[i]); - WalkState->Operands[i] = NULL; - } - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDsObjStackPush * * PARAMETERS: Object - Object to push @@ -612,69 +542,6 @@ AcpiDsObjStackPush ( } -#if 0 -/******************************************************************************* - * - * FUNCTION: AcpiDsObjStackPopObject - * - * PARAMETERS: PopCount - Number of objects/entries to pop - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT - * deleted by this routine. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsObjStackPopObject ( - ACPI_OPERAND_OBJECT **Object, - ACPI_WALK_STATE *WalkState) -{ - ACPI_FUNCTION_NAME ("DsObjStackPopObject"); - - - /* Check for stack underflow */ - - if (WalkState->NumOperands == 0) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Missing operand/stack empty! State=%p #Ops=%X\n", - WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); - } - - /* Pop the stack */ - - WalkState->NumOperands--; - - /* Check for a valid operand */ - - if (!WalkState->Operands [WalkState->NumOperands]) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X\n", - WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); - } - - /* Get operand and set stack entry to null */ - - *Object = WalkState->Operands [WalkState->NumOperands]; - WalkState->Operands [WalkState->NumOperands] = NULL; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", - *Object, AcpiUtGetObjectTypeName (*Object), - WalkState, WalkState->NumOperands)); - - return (AE_OK); -} -#endif - - /******************************************************************************* * * FUNCTION: AcpiDsObjStackPop @@ -782,49 +649,6 @@ AcpiDsObjStackPopAndDelete ( /******************************************************************************* * - * FUNCTION: AcpiDsObjStackGetValue - * - * PARAMETERS: Index - Stack index whose value is desired. Based - * on the top of the stack (index=0 == top) - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Retrieve an object from this walk's object stack. Index must - * be within the range of the current stack pointer. - * - ******************************************************************************/ - -void * -AcpiDsObjStackGetValue ( - UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - - ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); - - - /* Can't do it if the stack is empty */ - - if (WalkState->NumOperands == 0) - { - return_PTR (NULL); - } - - /* or if the index is past the top of the stack */ - - if (Index > (WalkState->NumOperands - (UINT32) 1)) - { - return_PTR (NULL); - } - - return_PTR (WalkState->Operands[(ACPI_NATIVE_UINT)(WalkState->NumOperands - 1) - - Index]); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDsGetCurrentWalkState * * PARAMETERS: Thread - Get current active state for this Thread @@ -861,11 +685,11 @@ AcpiDsGetCurrentWalkState ( * FUNCTION: AcpiDsPushWalkState * * PARAMETERS: WalkState - State to push - * WalkList - The list that owns the walk stack + * Thread - Thread state object * * RETURN: None * - * DESCRIPTION: Place the WalkState at the head of the state list. + * DESCRIPTION: Place the Thread state at the head of the state list. * ******************************************************************************/ @@ -888,9 +712,9 @@ AcpiDsPushWalkState ( * * FUNCTION: AcpiDsPopWalkState * - * PARAMETERS: WalkList - The list that owns the walk stack + * PARAMETERS: Thread - Current thread state * - * RETURN: A WalkState object popped from the stack + * RETURN: A WalkState object popped from the thread's stack * * DESCRIPTION: Remove and return the walkstate object that is at the head of * the walk stack for the given walk list. NULL indicates that @@ -919,7 +743,7 @@ AcpiDsPopWalkState ( /* * Don't clear the NEXT field, this serves as an indicator * that there is a parent WALK STATE - * NO: WalkState->Next = NULL; + * Do Not: WalkState->Next = NULL; */ } @@ -931,7 +755,9 @@ AcpiDsPopWalkState ( * * FUNCTION: AcpiDsCreateWalkState * - * PARAMETERS: Origin - Starting point for this walk + * PARAMETERS: OwnerId - ID for object creation + * Origin - Starting point for this walk + * MthDesc - Method object * Thread - Current thread state * * RETURN: Pointer to the new walk state. @@ -980,6 +806,7 @@ AcpiDsCreateWalkState ( Status = AcpiDsResultStackPush (WalkState); if (ACPI_FAILURE (Status)) { + AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState); return_PTR (NULL); } @@ -1003,8 +830,7 @@ AcpiDsCreateWalkState ( * MethodNode - Control method NS node, if any * AmlStart - Start of AML * AmlLength - Length of AML - * Params - Method args, if any - * ReturnObjDesc - Where to store a return object, if any + * Info - Method info block (params, etc.) * PassNumber - 1, 2, or 3 * * RETURN: Status @@ -1020,8 +846,7 @@ AcpiDsInitAmlWalk ( ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc, + ACPI_PARAMETER_INFO *Info, UINT32 PassNumber) { ACPI_STATUS Status; @@ -1039,9 +864,21 @@ AcpiDsInitAmlWalk ( /* The NextOp of the NextWalk will be the beginning of the method */ - WalkState->NextOp = NULL; - WalkState->Params = Params; - WalkState->CallerReturnDesc = ReturnObjDesc; + WalkState->NextOp = NULL; + + if (Info) + { + if (Info->ParameterType == ACPI_PARAM_GPE) + { + WalkState->GpeEventInfo = ACPI_CAST_PTR (ACPI_GPE_EVENT_INFO, + Info->Parameters); + } + else + { + WalkState->Params = Info->Parameters; + WalkState->CallerReturnDesc = &Info->ReturnObject; + } + } Status = AcpiPsInitScope (&WalkState->ParserState, Op); if (ACPI_FAILURE (Status)) @@ -1066,7 +903,8 @@ AcpiDsInitAmlWalk ( /* Init the method arguments */ - Status = AcpiDsMethodDataInitArgs (Params, ACPI_METHOD_NUM_ARGS, WalkState); + Status = AcpiDsMethodDataInitArgs (WalkState->Params, + ACPI_METHOD_NUM_ARGS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -1142,13 +980,15 @@ AcpiDsDeleteWalkState ( if (WalkState->DataType != ACPI_DESC_TYPE_WALK) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", + WalkState)); return; } if (WalkState->ParserState.Scope) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", + WalkState)); } /* Always must free any linked control states */ @@ -1186,13 +1026,14 @@ AcpiDsDeleteWalkState ( } +#ifdef ACPI_ENABLE_OBJECT_CACHE /****************************************************************************** * * FUNCTION: AcpiDsDeleteWalkStateCache * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Purge the global state object cache. Used during subsystem * termination. @@ -1209,5 +1050,212 @@ AcpiDsDeleteWalkStateCache ( AcpiUtDeleteGenericCache (ACPI_MEM_LIST_WALK); return_VOID; } +#endif + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiDsResultInsert + * + * PARAMETERS: Object - Object to push + * Index - Where to insert the object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Insert an object onto this walk's result stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultInsert ( + void *Object, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_NAME ("DsResultInsert"); + + + State = WalkState->Results; + if (!State) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", + WalkState)); + return (AE_NOT_EXIST); + } + + if (Index >= ACPI_OBJ_NUM_OPERANDS) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Index out of range: %X Obj=%p State=%p Num=%X\n", + Index, Object, WalkState, State->Results.NumResults)); + return (AE_BAD_PARAMETER); + } + + if (!Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null Object! Index=%X Obj=%p State=%p Num=%X\n", + Index, Object, WalkState, State->Results.NumResults)); + return (AE_BAD_PARAMETER); + } + + State->Results.ObjDesc [Index] = Object; + State->Results.NumResults++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj=%p [%s] State=%p Num=%X Cur=%X\n", + Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", + WalkState, State->Results.NumResults, WalkState->CurrentResult)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackDeleteAll + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Clear the object stack by deleting all objects that are on it. + * Should be used with great care, if at all! + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackDeleteAll ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); + + + /* The stack size is configurable, but fixed */ + + for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) + { + if (WalkState->Operands[i]) + { + AcpiUtRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPopObject + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT + * deleted by this routine. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPopObject ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME ("DsObjStackPopObject"); + + + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Missing operand/stack empty! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + *Object = NULL; + return (AE_AML_NO_OPERAND); + } + + /* Pop the stack */ + + WalkState->NumOperands--; + + /* Check for a valid operand */ + + if (!WalkState->Operands [WalkState->NumOperands]) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null operand! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + *Object = NULL; + return (AE_AML_NO_OPERAND); + } + + /* Get operand and set stack entry to null */ + + *Object = WalkState->Operands [WalkState->NumOperands]; + WalkState->Operands [WalkState->NumOperands] = NULL; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", + *Object, AcpiUtGetObjectTypeName (*Object), + WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackGetValue + * + * PARAMETERS: Index - Stack index whose value is desired. Based + * on the top of the stack (index=0 == top) + * WalkState - Current Walk state + * + * RETURN: Pointer to the requested operand + * + * DESCRIPTION: Retrieve an object from this walk's operand stack. Index must + * be within the range of the current stack pointer. + * + ******************************************************************************/ + +void * +AcpiDsObjStackGetValue ( + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); + + + /* Can't do it if the stack is empty */ + + if (WalkState->NumOperands == 0) + { + return_PTR (NULL); + } + + /* or if the index is past the top of the stack */ + + if (Index > (WalkState->NumOperands - (UINT32) 1)) + { + return_PTR (NULL); + } + + return_PTR (WalkState->Operands[(ACPI_NATIVE_UINT)(WalkState->NumOperands - 1) - + Index]); +} +#endif diff --git a/sys/dev/acpi/acpica/Subsystem/evevent.c b/sys/dev/acpi/acpica/Subsystem/evevent.c index 2d3f88b8ada..e5fe89d967b 100644 --- a/sys/dev/acpi/acpica/Subsystem/evevent.c +++ b/sys/dev/acpi/acpica/Subsystem/evevent.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evevent - Fixed Event handling and dispatch - * xRevision: 112 $ + * xRevision: 117 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evevent.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evevent.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acevents.h" @@ -123,27 +123,37 @@ __KERNEL_RCSID(0, "$NetBSD: evevent.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evevent") +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvFixedEventInitialize ( + void); + +static UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event); + /******************************************************************************* * - * FUNCTION: AcpiEvInitialize + * FUNCTION: AcpiEvInitializeEvents * * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Initialize global data structures for events. + * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE) * ******************************************************************************/ ACPI_STATUS -AcpiEvInitialize ( +AcpiEvInitializeEvents ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvInitialize"); + ACPI_FUNCTION_TRACE ("EvInitializeEvents"); /* Make sure we have ACPI tables */ @@ -155,9 +165,9 @@ AcpiEvInitialize ( } /* - * Initialize the Fixed and General Purpose Events. This is - * done prior to enabling SCIs to prevent interrupts from - * occurring before handers are installed. + * Initialize the Fixed and General Purpose Events. This is done prior to + * enabling SCIs to prevent interrupts from occurring before the handlers are + * installed. */ Status = AcpiEvFixedEventInitialize (); if (ACPI_FAILURE (Status)) @@ -183,7 +193,7 @@ AcpiEvInitialize ( /******************************************************************************* * - * FUNCTION: AcpiEvHandlerInitialize + * FUNCTION: AcpiEvInstallXruptHandlers * * PARAMETERS: None * @@ -194,13 +204,13 @@ AcpiEvInitialize ( ******************************************************************************/ ACPI_STATUS -AcpiEvHandlerInitialize ( +AcpiEvInstallXruptHandlers ( void) { ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("EvHandlerInitialize"); + ACPI_FUNCTION_TRACE ("EvInstallXruptHandlers"); /* Install the SCI handler */ @@ -242,7 +252,7 @@ AcpiEvHandlerInitialize ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiEvFixedEventInitialize ( void) { @@ -263,8 +273,9 @@ AcpiEvFixedEventInitialize ( if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) { - Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[i].EnableRegisterId, - 0, ACPI_MTX_LOCK); + Status = AcpiSetRegister ( + AcpiGbl_FixedEventInfo[i].EnableRegisterId, + 0, ACPI_MTX_LOCK); if (ACPI_FAILURE (Status)) { return (Status); @@ -284,7 +295,7 @@ AcpiEvFixedEventInitialize ( * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED * - * DESCRIPTION: Checks the PM status register for fixed events + * DESCRIPTION: Checks the PM status register for active fixed events * ******************************************************************************/ @@ -305,8 +316,10 @@ AcpiEvFixedEventDetect ( * Read the fixed feature status and enable registers, as all the cases * depend on their values. Ignore errors here. */ - (void) AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, &FixedStatus); - (void) AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, &FixedEnable); + (void) AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, + &FixedStatus); + (void) AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, + &FixedEnable); ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, "Fixed Event Block: Enable %08X Status %08X\n", @@ -345,7 +358,7 @@ AcpiEvFixedEventDetect ( * ******************************************************************************/ -UINT32 +static UINT32 AcpiEvFixedEventDispatch ( UINT32 Event) { diff --git a/sys/dev/acpi/acpica/Subsystem/evgpe.c b/sys/dev/acpi/acpica/Subsystem/evgpe.c index 44f30bd4d6d..c35608cd128 100644 --- a/sys/dev/acpi/acpica/Subsystem/evgpe.c +++ b/sys/dev/acpi/acpica/Subsystem/evgpe.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evgpe - General Purpose Event handling and dispatch - * xRevision: 33 $ + * xRevision: 49 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evgpe.c,v 1.7 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evgpe.c,v 1.8 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acevents.h" @@ -124,6 +124,270 @@ __KERNEL_RCSID(0, "$NetBSD: evgpe.c,v 1.7 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evgpe") +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchExecuteGpeMethod ( + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSetGpeType + * + * PARAMETERS: GpeEventInfo - GPE to set + * Type - New type + * + * RETURN: Status + * + * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvSetGpeType"); + + + /* Validate type and update register enable masks */ + + switch (Type) + { + case ACPI_GPE_TYPE_WAKE: + case ACPI_GPE_TYPE_RUNTIME: + case ACPI_GPE_TYPE_WAKE_RUN: + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Disable the GPE if currently enabled */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + + /* Type was validated above */ + + GpeEventInfo->Flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */ + GpeEventInfo->Flags |= Type; /* Insert type */ + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvUpdateGpeEnableMasks + * + * PARAMETERS: GpeEventInfo - GPE to update + * Type - What to do: ACPI_GPE_DISABLE or + * ACPI_GPE_ENABLE + * + * RETURN: Status + * + * DESCRIPTION: Updates GPE register enable masks based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT8 RegisterBit; + + + ACPI_FUNCTION_TRACE ("EvUpdateGpeEnableMasks"); + + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + RegisterBit = GpeEventInfo->RegisterBit; + + /* 1) Disable case. Simply clear all enable bits */ + + if (Type == ACPI_GPE_DISABLE) + { + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + return_ACPI_STATUS (AE_OK); + } + + /* 2) Enable case. Set/Clear the appropriate enable bits */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + break; + + case ACPI_GPE_TYPE_RUNTIME: + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvEnableGpe + * + * PARAMETERS: GpeEventInfo - GPE to enable + * WriteToHardware - Enable now, or just mark data structs + * (WAKE GPEs should be deferred) + * + * RETURN: Status + * + * DESCRIPTION: Enable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvEnableGpe"); + + + /* Make sure HW enable masks are updated */ + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_ENABLE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Mark wake-enabled or HW enable, or both */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + + /*lint -fallthrough */ + + case ACPI_GPE_TYPE_RUNTIME: + + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED); + + if (WriteToHardware) + { + /* Clear the GPE (of stale events), then enable it */ + + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Enable the requested runtime GPE */ + + Status = AcpiHwWriteGpeEnableReg (GpeEventInfo); + } + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDisableGpe + * + * PARAMETERS: GpeEventInfo - GPE to disable + * + * RETURN: Status + * + * DESCRIPTION: Disable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvDisableGpe"); + + + if (!(GpeEventInfo->Flags & ACPI_GPE_ENABLE_MASK)) + { + return_ACPI_STATUS (AE_OK); + } + + /* Make sure HW enable masks are updated */ + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Mark wake-disabled or HW disable, or both */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + + /*lint -fallthrough */ + + case ACPI_GPE_TYPE_RUNTIME: + + /* Disable the requested runtime GPE */ + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED); + Status = AcpiHwWriteGpeEnableReg (GpeEventInfo); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + /******************************************************************************* * @@ -167,9 +431,11 @@ AcpiEvGetGpeEventInfo ( if (GpeBlock) { if ((GpeNumber >= GpeBlock->BlockBaseNumber) && - (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8))) + (GpeNumber < GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8))) { - return (&GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]); + return (&GpeBlock->EventInfo[GpeNumber - + GpeBlock->BlockBaseNumber]); } } } @@ -179,9 +445,8 @@ AcpiEvGetGpeEventInfo ( return (NULL); } - /* - * A Non-null GpeDevice means this is a GPE Block Device. - */ + /* A Non-NULL GpeDevice means this is a GPE Block Device */ + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) GpeDevice); if (!ObjDesc || !ObjDesc->Device.GpeBlock) @@ -222,15 +487,22 @@ AcpiEvGpeDetect ( UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; UINT8 EnabledStatusByte; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - UINT32 InValue; + UINT32 StatusReg; + UINT32 EnableReg; ACPI_STATUS Status; ACPI_GPE_BLOCK_INFO *GpeBlock; - UINT32 i; - UINT32 j; + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT j; ACPI_FUNCTION_NAME ("EvGpeDetect"); + /* Check for the case where there are no GPEs */ + + if (!GpeXruptList) + { + return (IntStatus); + } /* Examine all GPE blocks attached to this interrupt level */ @@ -251,9 +523,8 @@ AcpiEvGpeDetect ( /* Read the Status Register */ - Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &InValue, + Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &StatusReg, &GpeRegisterInfo->StatusAddress); - GpeRegisterInfo->Status = (UINT8) InValue; if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -261,25 +532,20 @@ AcpiEvGpeDetect ( /* Read the Enable Register */ - Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &InValue, + Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &EnableReg, &GpeRegisterInfo->EnableAddress); - GpeRegisterInfo->Enable = (UINT8) InValue; if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, - "GPE pair: Status %8.8X%8.8X = %02X, Enable %8.8X%8.8X = %02X\n", - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->StatusAddress.Address)), - GpeRegisterInfo->Status, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address)), - GpeRegisterInfo->Enable)); + "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", + GpeRegisterInfo->BaseGpeNumber, StatusReg, EnableReg)); - /* First check if there is anything active at all in this register */ + /* Check if there is anything active at all in this register */ - EnabledStatusByte = (UINT8) (GpeRegisterInfo->Status & - GpeRegisterInfo->Enable); + EnabledStatusByte = (UINT8) (StatusReg & EnableReg); if (!EnabledStatusByte) { /* No active GPEs in this register, move on */ @@ -300,8 +566,8 @@ AcpiEvGpeDetect ( * or method. */ IntStatus |= AcpiEvGpeDispatch ( - &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j], - j + GpeRegisterInfo->BaseGpeNumber); + &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j], + (UINT32) j + GpeRegisterInfo->BaseGpeNumber); } } } @@ -340,6 +606,7 @@ AcpiEvAsynchExecuteGpeMethod ( UINT32 GpeNumber = 0; ACPI_STATUS Status; ACPI_GPE_EVENT_INFO LocalGpeEventInfo; + ACPI_PARAMETER_INFO Info; ACPI_FUNCTION_TRACE ("EvAsynchExecuteGpeMethod"); @@ -359,11 +626,16 @@ AcpiEvAsynchExecuteGpeMethod ( return_VOID; } + /* Set the GPE flags for return to enabled state */ + + (void) AcpiEvEnableGpe (GpeEventInfo, FALSE); + /* * Take a snapshot of the GPE info for this level - we copy the * info to prevent a race condition with RemoveHandler/RemoveBlock. */ - ACPI_MEMCPY (&LocalGpeEventInfo, GpeEventInfo, sizeof (ACPI_GPE_EVENT_INFO)); + ACPI_MEMCPY (&LocalGpeEventInfo, GpeEventInfo, + sizeof (ACPI_GPE_EVENT_INFO)); Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) @@ -371,26 +643,38 @@ AcpiEvAsynchExecuteGpeMethod ( return_VOID; } - if (LocalGpeEventInfo.MethodNode) + /* + * Must check for control method type dispatch one more + * time to avoid race with EvGpeInstallHandler + */ + if ((LocalGpeEventInfo.Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) { /* - * Invoke the GPE Method (_Lxx, _Exx): - * (Evaluate the _Lxx/_Exx control method that corresponds to this GPE.) + * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx + * control method that corresponds to this GPE */ - Status = AcpiNsEvaluateByHandle (LocalGpeEventInfo.MethodNode, NULL, NULL); + Info.Node = LocalGpeEventInfo.Dispatch.MethodNode; + Info.Parameters = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT *, GpeEventInfo); + Info.ParameterType = ACPI_PARAM_GPE; + + Status = AcpiNsEvaluateByHandle (&Info); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("%s while evaluating method [%4.4s] for GPE[%2X]\n", + ACPI_REPORT_ERROR (( + "%s while evaluating method [%4.4s] for GPE[%2X]\n", AcpiFormatException (Status), - AcpiUtGetNodeName (LocalGpeEventInfo.MethodNode), GpeNumber)); + AcpiUtGetNodeName (LocalGpeEventInfo.Dispatch.MethodNode), + GpeNumber)); } } - if (LocalGpeEventInfo.Flags & ACPI_EVENT_LEVEL_TRIGGERED) + if ((LocalGpeEventInfo.Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) { /* - * GPE is level-triggered, we clear the GPE status bit after handling - * the event. + * GPE is level-triggered, we clear the GPE status bit after + * handling the event. */ Status = AcpiHwClearGpe (&LocalGpeEventInfo); if (ACPI_FAILURE (Status)) @@ -401,7 +685,7 @@ AcpiEvAsynchExecuteGpeMethod ( /* Enable this GPE */ - (void) AcpiHwEnableGpe (&LocalGpeEventInfo); + (void) AcpiHwWriteGpeEnableReg (&LocalGpeEventInfo); return_VOID; } @@ -410,7 +694,7 @@ AcpiEvAsynchExecuteGpeMethod ( * * FUNCTION: AcpiEvGpeDispatch * - * PARAMETERS: GpeEventInfo - info for this GPE + * PARAMETERS: GpeEventInfo - Info for this GPE * GpeNumber - Number relative to the parent GPE block * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED @@ -437,17 +721,30 @@ AcpiEvGpeDispatch ( * If edge-triggered, clear the GPE status bit now. Note that * level-triggered events are cleared after the GPE is serviced. */ - if (GpeEventInfo->Flags & ACPI_EVENT_EDGE_TRIGGERED) + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_EDGE_TRIGGERED) { Status = AcpiHwClearGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to clear GPE[%2X]\n", - GpeNumber)); + ACPI_REPORT_ERROR (( + "AcpiEvGpeDispatch: %s, Unable to clear GPE[%2X]\n", + AcpiFormatException (Status), GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } } + /* Save current system state */ + + if (AcpiGbl_SystemAwakeAndRunning) + { + ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_SYSTEM_RUNNING); + } + else + { + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_SYSTEM_RUNNING); + } + /* * Dispatch the GPE to either an installed handler, or the control * method associated with this GPE (_Lxx or _Exx). @@ -455,38 +752,45 @@ AcpiEvGpeDispatch ( * If there is neither a handler nor a method, we disable the level to * prevent further events from coming in here. */ - if (GpeEventInfo->Handler) + switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) { - /* Invoke the installed handler (at interrupt level) */ + case ACPI_GPE_DISPATCH_HANDLER: - GpeEventInfo->Handler (GpeEventInfo->Context); + /* + * Invoke the installed handler (at interrupt level) + * Ignore return status for now. TBD: leave GPE disabled on error? + */ + (void) GpeEventInfo->Dispatch.Handler->Address ( + GpeEventInfo->Dispatch.Handler->Context); /* It is now safe to clear level-triggered events. */ - if (GpeEventInfo->Flags & ACPI_EVENT_LEVEL_TRIGGERED) + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) { Status = AcpiHwClearGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( - "AcpiEvGpeDispatch: Unable to clear GPE[%2X]\n", - GpeNumber)); + "AcpiEvGpeDispatch: %s, Unable to clear GPE[%2X]\n", + AcpiFormatException (Status), GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } } - } - else if (GpeEventInfo->MethodNode) - { + break; + + case ACPI_GPE_DISPATCH_METHOD: + /* * Disable GPE, so it doesn't keep firing before the method has a * chance to run. */ - Status = AcpiHwDisableGpe (GpeEventInfo); + Status = AcpiEvDisableGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( - "AcpiEvGpeDispatch: Unable to disable GPE[%2X]\n", - GpeNumber)); + "AcpiEvGpeDispatch: %s, Unable to disable GPE[%2X]\n", + AcpiFormatException (Status), GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } @@ -494,17 +798,18 @@ AcpiEvGpeDispatch ( * Execute the method associated with the GPE * NOTE: Level-triggered GPEs are cleared after the method completes. */ - if (ACPI_FAILURE (AcpiOsQueueForExecution (OSD_PRIORITY_GPE, - AcpiEvAsynchExecuteGpeMethod, - GpeEventInfo))) + Status = AcpiOsQueueForExecution (OSD_PRIORITY_GPE, + AcpiEvAsynchExecuteGpeMethod, GpeEventInfo); + if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( - "AcpiEvGpeDispatch: Unable to queue handler for GPE[%2X], event is disabled\n", - GpeNumber)); + "AcpiEvGpeDispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", + AcpiFormatException (Status), GpeNumber)); } - } - else - { + break; + + default: + /* No handler or method to run! */ ACPI_REPORT_ERROR (( @@ -515,16 +820,69 @@ AcpiEvGpeDispatch ( * Disable the GPE. The GPE will remain disabled until the ACPI * Core Subsystem is restarted, or a handler is installed. */ - Status = AcpiHwDisableGpe (GpeEventInfo); + Status = AcpiEvDisableGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( - "AcpiEvGpeDispatch: Unable to disable GPE[%2X]\n", - GpeNumber)); + "AcpiEvGpeDispatch: %s, Unable to disable GPE[%2X]\n", + AcpiFormatException (Status), GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } + break; } return_VALUE (ACPI_INTERRUPT_HANDLED); } + +#ifdef ACPI_GPE_NOTIFY_CHECK +/******************************************************************************* + * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED + * + * FUNCTION: AcpiEvCheckForWakeOnlyGpe + * + * PARAMETERS: GpeEventInfo - info for this GPE + * + * RETURN: Status + * + * DESCRIPTION: Determine if a a GPE is "wake-only". + * + * Called from Notify() code in interpreter when a "DeviceWake" + * Notify comes in. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvCheckForWakeOnlyGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvCheckForWakeOnlyGpe"); + + + if ((GpeEventInfo) && /* Only >0 for _Lxx/_Exx */ + ((GpeEventInfo->Flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ + { + /* This must be a wake-only GPE, disable it */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + + /* Set GPE to wake-only. Do not change wake disabled/enabled status */ + + AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE); + + ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n", + GpeEventInfo)); + + /* This was a wake-only GPE */ + + return_ACPI_STATUS (AE_WAKE_ONLY_GPE); + } + + return_ACPI_STATUS (AE_OK); +} +#endif + + diff --git a/sys/dev/acpi/acpica/Subsystem/evgpeblk.c b/sys/dev/acpi/acpica/Subsystem/evgpeblk.c index 8967d5f1304..d3fb675cffa 100644 --- a/sys/dev/acpi/acpica/Subsystem/evgpeblk.c +++ b/sys/dev/acpi/acpica/Subsystem/evgpeblk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evgpeblk - GPE block creation and initialization. - * xRevision: 27 $ + * xRevision: 43 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evgpeblk.c,v 1.7 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evgpeblk.c,v 1.8 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acevents.h" @@ -124,12 +124,45 @@ __KERNEL_RCSID(0, "$NetBSD: evgpeblk.c,v 1.7 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evgpeblk") +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvSaveMethodInfo ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc, + void **ReturnValue); + +static ACPI_STATUS +AcpiEvMatchPrwAndGpe ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Info, + void **ReturnValue); + +static ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptLevel); + +static ACPI_STATUS +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt); + +static ACPI_STATUS +AcpiEvInstallGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock, + UINT32 InterruptLevel); + +static ACPI_STATUS +AcpiEvCreateGpeInfoBlocks ( + ACPI_GPE_BLOCK_INFO *GpeBlock); + /******************************************************************************* * * FUNCTION: AcpiEvValidGpeEvent * - * PARAMETERS: GpeEventInfo - Info for this GPE + * PARAMETERS: GpeEventInfo - Info for this GPE * * RETURN: TRUE if the GpeEvent is valid * @@ -184,17 +217,18 @@ AcpiEvValidGpeEvent ( * FUNCTION: AcpiEvWalkGpeList * * PARAMETERS: GpeWalkCallback - Routine called for each GPE block + * Flags - ACPI_NOT_ISR or ACPI_ISR * * RETURN: Status * * DESCRIPTION: Walk the GPE lists. - * FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ ACPI_STATUS AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback) + ACPI_GPE_CALLBACK GpeWalkCallback, + UINT32 Flags) { ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_GPE_XRUPT_INFO *GpeXruptInfo; @@ -204,7 +238,7 @@ AcpiEvWalkGpeList ( ACPI_FUNCTION_TRACE ("EvWalkGpeList"); - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_ISR); + AcpiOsAcquireLock (AcpiGbl_GpeLock, Flags); /* Walk the interrupt level descriptor list */ @@ -231,13 +265,64 @@ AcpiEvWalkGpeList ( } UnlockAndExit: - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_ISR); + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } /******************************************************************************* * + * FUNCTION: AcpiEvDeleteGpeHandlers + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Delete all Handler objects found in the GPE data structs. + * Used only prior to termination. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT j; + + + ACPI_FUNCTION_TRACE ("EvDeleteGpeHandlers"); + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Now look at the individual GPEs in this byte register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + GpeEventInfo = &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j]; + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + ACPI_MEM_FREE (GpeEventInfo->Dispatch.Handler); + GpeEventInfo->Dispatch.Handler = NULL; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; + } + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: AcpiEvSaveMethodInfo * * PARAMETERS: Callback from WalkNamespace @@ -250,11 +335,11 @@ UnlockAndExit: * information for quick lookup during GPE dispatch * * The name of each GPE control method is of the form: - * "_Lnn" or "_Enn" - * Where: - * L - means that the GPE is level triggered - * E - means that the GPE is edge triggered - * nn - is the GPE number [in HEX] + * "_Lxx" or "_Exx" + * Where: + * L - means that the GPE is level triggered + * E - means that the GPE is edge triggered + * xx - is the GPE number [in HEX] * ******************************************************************************/ @@ -276,31 +361,37 @@ AcpiEvSaveMethodInfo ( ACPI_FUNCTION_TRACE ("EvSaveMethodInfo"); - /* Extract the name from the object and convert to a string */ - + /* + * _Lxx and _Exx GPE method support + * + * 1) Extract the name from the object and convert to a string + */ ACPI_MOVE_32_TO_32 (Name, &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Integer); Name[ACPI_NAME_SIZE] = 0; /* - * Edge/Level determination is based on the 2nd character - * of the method name + * 2) Edge/Level determination is based on the 2nd character + * of the method name + * + * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE + * if a _PRW object is found that points to this GPE. */ switch (Name[1]) { case 'L': - Type = ACPI_EVENT_LEVEL_TRIGGERED; + Type = ACPI_GPE_LEVEL_TRIGGERED; break; case 'E': - Type = ACPI_EVENT_EDGE_TRIGGERED; + Type = ACPI_GPE_EDGE_TRIGGERED; break; default: /* Unknown method type, just ignore it! */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n", + "Unknown GPE method type: %s (name not of form _Lxx or _Exx)\n", Name)); return_ACPI_STATUS (AE_OK); } @@ -313,7 +404,7 @@ AcpiEvSaveMethodInfo ( /* Conversion failed; invalid method, just ignore it */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not extract GPE number from name: %s (name is not of form _Lnn or _Enn)\n", + "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)\n", Name)); return_ACPI_STATUS (AE_OK); } @@ -333,24 +424,152 @@ AcpiEvSaveMethodInfo ( /* * Now we can add this information to the GpeEventInfo block - * for use during dispatch of this GPE. + * for use during dispatch of this GPE. Default type is RUNTIME, although + * this may change when the _PRW methods are executed later. */ GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]; - GpeEventInfo->Flags = Type; - GpeEventInfo->MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle; + GpeEventInfo->Flags = (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD | + ACPI_GPE_TYPE_RUNTIME); - /* Enable the GPE (SCIs should be disabled at this point) */ + GpeEventInfo->Dispatch.MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle; - Status = AcpiHwEnableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Update enable mask, but don't enable the HW GPE as of yet */ + + Status = AcpiEvEnableGpe (GpeEventInfo, FALSE); ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Registered GPE method %s as GPE number 0x%.2X\n", Name, GpeNumber)); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvMatchPrwAndGpe + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is + * not aborted on a single _PRW failure. + * + * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a + * Device. Run the _PRW method. If present, extract the GPE + * number and mark the GPE as a WAKE GPE. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvMatchPrwAndGpe ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Info, + void **ReturnValue) +{ + ACPI_GPE_WALK_INFO *GpeInfo = (void *) Info; + ACPI_NAMESPACE_NODE *GpeDevice; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_NAMESPACE_NODE *TargetGpeDevice; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_OPERAND_OBJECT *PkgDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + UINT32 GpeNumber; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvMatchPrwAndGpe"); + + + /* Check for a _PRW method under this device */ + + Status = AcpiUtEvaluateObject (ObjHandle, METHOD_NAME__PRW, + ACPI_BTYPE_PACKAGE, &PkgDesc); + if (ACPI_FAILURE (Status)) + { + /* Ignore all errors from _PRW, we don't want to abort the subsystem */ + + return_ACPI_STATUS (AE_OK); + } + + /* The returned _PRW package must have at least two elements */ + + if (PkgDesc->Package.Count < 2) + { + goto Cleanup; + } + + /* Extract pointers from the input context */ + + GpeDevice = GpeInfo->GpeDevice; + GpeBlock = GpeInfo->GpeBlock; + + /* + * The _PRW object must return a package, we are only interested + * in the first element + */ + ObjDesc = PkgDesc->Package.Elements[0]; + + if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) + { + /* Use FADT-defined GPE device (from definition of _PRW) */ + + TargetGpeDevice = AcpiGbl_FadtGpeDevice; + + /* Integer is the GPE number in the FADT described GPE blocks */ + + GpeNumber = (UINT32) ObjDesc->Integer.Value; + } + else if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE) + { + /* Package contains a GPE reference and GPE number within a GPE block */ + + if ((ObjDesc->Package.Count < 2) || + (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[0]) != ACPI_TYPE_LOCAL_REFERENCE) || + (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[1]) != ACPI_TYPE_INTEGER)) + { + goto Cleanup; + } + + /* Get GPE block reference and decode */ + + TargetGpeDevice = ObjDesc->Package.Elements[0]->Reference.Node; + GpeNumber = (UINT32) ObjDesc->Package.Elements[1]->Integer.Value; + } + else + { + /* Unknown type, just ignore it */ + + goto Cleanup; + } + + /* + * Is this GPE within this block? + * + * TRUE iff these conditions are true: + * 1) The GPE devices match. + * 2) The GPE index(number) is within the range of the Gpe Block + * associated with the GPE device. + */ + if ((GpeDevice == TargetGpeDevice) && + (GpeNumber >= GpeBlock->BlockBaseNumber) && + (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8))) + { + GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]; + + /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ + + GpeEventInfo->Flags &= ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); + Status = AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_DISABLE); + } + +Cleanup: + AcpiUtRemoveReference (PkgDesc); return_ACPI_STATUS (AE_OK); } @@ -382,7 +601,7 @@ AcpiEvGetGpeXruptBlock ( ACPI_FUNCTION_TRACE ("EvGetGpeXruptBlock"); - /* No need for spin lock since we are not changing any list elements here */ + /* No need for lock since we are not changing any list elements here */ NextGpeXrupt = AcpiGbl_GpeXruptListHead; while (NextGpeXrupt) @@ -544,7 +763,7 @@ AcpiEvInstallGpeBlock ( goto UnlockAndExit; } - /* Install the new block at the end of the list for this interrupt with lock */ + /* Install the new block at the end of the list with lock */ AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); if (GpeXruptBlock->GpeBlockListHead) @@ -692,11 +911,13 @@ AcpiEvCreateGpeInfoBlocks ( * per register. Initialization to zeros is sufficient. */ GpeEventInfo = ACPI_MEM_CALLOCATE ( - ((ACPI_SIZE) GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) * + ((ACPI_SIZE) GpeBlock->RegisterCount * + ACPI_GPE_REGISTER_WIDTH) * sizeof (ACPI_GPE_EVENT_INFO)); if (!GpeEventInfo) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the GpeEventInfo table\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not allocate the GpeEventInfo table\n")); Status = AE_NO_MEMORY; goto ErrorExit; } @@ -742,7 +963,7 @@ AcpiEvCreateGpeInfoBlocks ( for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { - ThisEvent->BitMask = AcpiGbl_DecodeTo8bit[j]; + ThisEvent->RegisterBit = AcpiGbl_DecodeTo8bit[j]; ThisEvent->RegisterInfo = ThisRegister; ThisEvent++; } @@ -813,7 +1034,13 @@ AcpiEvCreateGpeBlock ( ACPI_GPE_BLOCK_INFO **ReturnGpeBlock) { ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT j; + UINT32 WakeGpeCount; + UINT32 GpeEnabledCount; ACPI_STATUS Status; + ACPI_GPE_WALK_INFO GpeInfo; ACPI_FUNCTION_TRACE ("EvCreateGpeBlock"); @@ -836,8 +1063,10 @@ AcpiEvCreateGpeBlock ( GpeBlock->RegisterCount = RegisterCount; GpeBlock->BlockBaseNumber = GpeBlockBaseNumber; + GpeBlock->Node = GpeDevice; - ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, sizeof (ACPI_GENERIC_ADDRESS)); + ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, + sizeof (ACPI_GENERIC_ADDRESS)); /* Create the RegisterInfo and EventInfo sub-structures */ @@ -857,22 +1086,79 @@ AcpiEvCreateGpeBlock ( return_ACPI_STATUS (Status); } + /* Find all GPE methods (_Lxx, _Exx) for this block */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, AcpiEvSaveMethodInfo, + GpeBlock, NULL); + + /* + * Runtime option: Should Wake GPEs be enabled at runtime? The default + * is No,they should only be enabled just as the machine goes to sleep. + */ + if (AcpiGbl_LeaveWakeGpesDisabled) + { + /* + * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods. + * (Each GPE that has one or more _PRWs that reference it is by + * definition a WAKE GPE and will not be enabled while the machine + * is running.) + */ + GpeInfo.GpeBlock = GpeBlock; + GpeInfo.GpeDevice = GpeDevice; + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, AcpiEvMatchPrwAndGpe, + &GpeInfo, NULL); + } + + /* + * Enable all GPEs in this block that are 1) "runtime" or "run/wake" GPEs, + * and 2) have a corresponding _Lxx or _Exx method. All other GPEs must + * be enabled via the AcpiEnableGpe() external interface. + */ + WakeGpeCount = 0; + GpeEnabledCount = 0; + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + for (j = 0; j < 8; j++) + { + /* Get the info block for this particular GPE */ + + GpeEventInfo = &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j]; + + if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) && + (GpeEventInfo->Flags & ACPI_GPE_TYPE_RUNTIME)) + { + GpeEnabledCount++; + } + + if (GpeEventInfo->Flags & ACPI_GPE_TYPE_WAKE) + { + WakeGpeCount++; + } + } + } + /* Dump info about this GPE block */ - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "GPE %02d to %02d [%4.4s] %d regs at %8.8X%8.8X on int %d\n", - GpeBlock->BlockBaseNumber, + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", + (UINT32) GpeBlock->BlockBaseNumber, (UINT32) (GpeBlock->BlockBaseNumber + ((GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) -1)), GpeDevice->Name.Ascii, GpeBlock->RegisterCount, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address)), InterruptLevel)); - /* Find all GPE methods (_Lxx, _Exx) for this block */ + /* Enable all valid GPEs found above */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, - ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, AcpiEvSaveMethodInfo, - GpeBlock, NULL); + Status = AcpiHwEnableRuntimeGpeBlock (NULL, GpeBlock); + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Found %u Wake, Enabled %u Runtime GPEs in this block\n", + WakeGpeCount, GpeEnabledCount)); /* Return the new block */ @@ -898,28 +1184,26 @@ AcpiEvCreateGpeBlock ( ******************************************************************************/ ACPI_STATUS -AcpiEvGpeInitialize (void) +AcpiEvGpeInitialize ( + void) { UINT32 RegisterCount0 = 0; UINT32 RegisterCount1 = 0; UINT32 GpeNumberMax = 0; - ACPI_HANDLE GpeDevice; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvGpeInitialize"); - /* Get a handle to the predefined _GPE object */ - - Status = AcpiGetHandle (NULL, "\\_GPE", &GpeDevice); + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* - * Initialize the GPE Blocks defined in the FADT + * Initialize the GPE Block(s) defined in the FADT * * Why the GPE register block lengths are divided by 2: From the ACPI Spec, * section "General-Purpose Event Registers", we have: @@ -954,8 +1238,10 @@ AcpiEvGpeInitialize (void) /* Install GPE Block 0 */ - Status = AcpiEvCreateGpeBlock (GpeDevice, &AcpiGbl_FADT->XGpe0Blk, - RegisterCount0, 0, AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[0]); + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT->XGpe0Blk, RegisterCount0, 0, + AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[0]); + if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( @@ -990,9 +1276,11 @@ AcpiEvGpeInitialize (void) { /* Install GPE Block 1 */ - Status = AcpiEvCreateGpeBlock (GpeDevice, &AcpiGbl_FADT->XGpe1Blk, - RegisterCount1, AcpiGbl_FADT->Gpe1Base, + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT->XGpe1Blk, RegisterCount1, + AcpiGbl_FADT->Gpe1Base, AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[1]); + if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( @@ -1005,7 +1293,7 @@ AcpiEvGpeInitialize (void) * space. However, GPE0 always starts at GPE number zero. */ GpeNumberMax = AcpiGbl_FADT->Gpe1Base + - ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); } } @@ -1015,8 +1303,10 @@ AcpiEvGpeInitialize (void) { /* GPEs are not required by ACPI, this is OK */ - ACPI_REPORT_INFO (("There are no GPE blocks defined in the FADT\n")); - return_ACPI_STATUS (AE_OK); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "There are no GPE blocks defined in the FADT\n")); + Status = AE_OK; + goto Cleanup; } /* Check for Max GPE number out-of-range */ @@ -1025,9 +1315,12 @@ AcpiEvGpeInitialize (void) { ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n", GpeNumberMax)); - return_ACPI_STATUS (AE_BAD_VALUE); + Status = AE_BAD_VALUE; + goto Cleanup; } +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_OK); } diff --git a/sys/dev/acpi/acpica/Subsystem/evmisc.c b/sys/dev/acpi/acpica/Subsystem/evmisc.c index 7090e0af70c..19f551faf61 100644 --- a/sys/dev/acpi/acpica/Subsystem/evmisc.c +++ b/sys/dev/acpi/acpica/Subsystem/evmisc.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evmisc - Miscellaneous event manager support functions - * xRevision: 70 $ + * xRevision: 83 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evmisc.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evmisc.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acevents.h" @@ -126,6 +126,35 @@ __KERNEL_RCSID(0, "$NetBSD: evmisc.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); ACPI_MODULE_NAME ("evmisc") +#ifdef ACPI_DEBUG_OUTPUT +static const char *AcpiNotifyValueNames[] = +{ + "Bus Check", + "Device Check", + "Device Wake", + "Eject request", + "Device Check Light", + "Frequency Mismatch", + "Bus Mode Mismatch", + "Power Fault" +}; +#endif + +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvNotifyDispatch ( + void *Context); + +static void ACPI_SYSTEM_XFACE +AcpiEvGlobalLockThread ( + void *Context); + +static UINT32 +AcpiEvGlobalLockHandler ( + void *Context); + + /******************************************************************************* * * FUNCTION: AcpiEvIsNotifyObject @@ -165,9 +194,10 @@ AcpiEvIsNotifyObject ( * * FUNCTION: AcpiEvQueueNotifyRequest * - * PARAMETERS: + * PARAMETERS: Node - NS node for the notified object + * NotifyValue - Value from the Notify() request * - * RETURN: None. + * RETURN: Status * * DESCRIPTION: Dispatch a device notification event to a previously * installed handler. @@ -189,40 +219,29 @@ AcpiEvQueueNotifyRequest ( /* - * For value 1 (Ejection Request), some device method may need to be run. - * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run. + * For value 3 (Ejection Request), some device method may need to be run. + * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need + * to be run. * For value 0x80 (Status Change) on the power button or sleep button, - * initiate soft-off or sleep operation? + * initiate soft-off or sleep operation? */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Dispatching Notify(%X) on node %p\n", NotifyValue, Node)); - switch (NotifyValue) + if (NotifyValue <= 7) { - case 0: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Re-enumerate Devices\n")); - break; - - case 1: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Ejection Request\n")); - break; - - case 2: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Device Wake\n")); - break; - - case 0x80: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Status Change\n")); - break; - - default: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Unknown Notify Value: %X \n", NotifyValue)); - break; + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: %s\n", + AcpiNotifyValueNames[NotifyValue])); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Notify value: 0x%2.2X **Device Specific**\n", + NotifyValue)); } - /* - * Get the notify object attached to the NS Node - */ + /* Get the notify object attached to the NS Node */ + ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { @@ -278,11 +297,13 @@ AcpiEvQueueNotifyRequest ( if (!HandlerObj) { - /* There is no per-device notify handler for this device */ - + /* + * There is no per-device notify handler for this device. + * This may or may not be a problem. + */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "No notify handler for [%4.4s] node %p\n", - AcpiUtGetNodeName (Node), Node)); + "No notify handler for Notify(%4.4s, %X) node %p\n", + AcpiUtGetNodeName (Node), NotifyValue, Node)); } return (Status); @@ -293,7 +314,7 @@ AcpiEvQueueNotifyRequest ( * * FUNCTION: AcpiEvNotifyDispatch * - * PARAMETERS: + * PARAMETERS: Context - To be passed to the notify handler * * RETURN: None. * @@ -302,7 +323,7 @@ AcpiEvQueueNotifyRequest ( * ******************************************************************************/ -void ACPI_SYSTEM_XFACE +static void ACPI_SYSTEM_XFACE AcpiEvNotifyDispatch ( void *Context) { @@ -317,7 +338,8 @@ AcpiEvNotifyDispatch ( /* * We will invoke a global notify handler if installed. - * This is done _before_ we invoke the per-device handler attached to the device. + * This is done _before_ we invoke the per-device handler attached + * to the device. */ if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY) { @@ -344,7 +366,8 @@ AcpiEvNotifyDispatch ( if (GlobalHandler) { - GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, GlobalContext); + GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, + GlobalContext); } /* Now invoke the per-device handler, if present */ @@ -352,8 +375,9 @@ AcpiEvNotifyDispatch ( HandlerObj = NotifyInfo->Notify.HandlerObj; if (HandlerObj) { - HandlerObj->Notify.Handler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, - HandlerObj->Notify.Context); + HandlerObj->Notify.Handler (NotifyInfo->Notify.Node, + NotifyInfo->Notify.Value, + HandlerObj->Notify.Context); } /* All done with the info object */ @@ -366,6 +390,8 @@ AcpiEvNotifyDispatch ( * * FUNCTION: AcpiEvGlobalLockThread * + * PARAMETERS: Context - From thread interface, not used + * * RETURN: None * * DESCRIPTION: Invoked by SCI interrupt handler upon acquisition of the @@ -401,7 +427,9 @@ AcpiEvGlobalLockThread ( * * FUNCTION: AcpiEvGlobalLockHandler * - * RETURN: Status + * PARAMETERS: Context - From thread interface, not used + * + * RETURN: ACPI_INTERRUPT_HANDLED or ACPI_INTERRUPT_NOT_HANDLED * * DESCRIPTION: Invoked directly from the SCI handler when a global lock * release interrupt occurs. Grab the global lock and queue @@ -450,6 +478,8 @@ AcpiEvGlobalLockHandler ( * * FUNCTION: AcpiEvInitGlobalLockHandler * + * PARAMETERS: None + * * RETURN: Status * * DESCRIPTION: Install a handler for the global lock release event @@ -457,7 +487,8 @@ AcpiEvGlobalLockHandler ( ******************************************************************************/ ACPI_STATUS -AcpiEvInitGlobalLockHandler (void) +AcpiEvInitGlobalLockHandler ( + void) { ACPI_STATUS Status; @@ -467,7 +498,7 @@ AcpiEvInitGlobalLockHandler (void) AcpiGbl_GlobalLockPresent = TRUE; Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, - AcpiEvGlobalLockHandler, NULL); + AcpiEvGlobalLockHandler, NULL); /* * If the global lock does not exist on this platform, the attempt @@ -490,6 +521,8 @@ AcpiEvInitGlobalLockHandler (void) * * FUNCTION: AcpiEvAcquireGlobalLock * + * PARAMETERS: Timeout - Max time to wait for the lock, in millisec. + * * RETURN: Status * * DESCRIPTION: Attempt to gain ownership of the Global Lock. @@ -520,8 +553,10 @@ AcpiEvAcquireGlobalLock ( AcpiGbl_GlobalLockThreadCount++; - /* If we (OS side vs. BIOS side) have the hardware lock already, we are done */ - + /* + * If we (OS side vs. BIOS side) have the hardware lock already, + * we are done + */ if (AcpiGbl_GlobalLockAcquired) { return_ACPI_STATUS (AE_OK); @@ -560,12 +595,17 @@ AcpiEvAcquireGlobalLock ( * * FUNCTION: AcpiEvReleaseGlobalLock * + * PARAMETERS: None + * + * RETURN: Status + * * DESCRIPTION: Releases ownership of the Global Lock. * ******************************************************************************/ ACPI_STATUS -AcpiEvReleaseGlobalLock (void) +AcpiEvReleaseGlobalLock ( + void) { BOOLEAN Pending = FALSE; ACPI_STATUS Status = AE_OK; @@ -576,7 +616,8 @@ AcpiEvReleaseGlobalLock (void) if (!AcpiGbl_GlobalLockThreadCount) { - ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n")); + ACPI_REPORT_WARNING(( + "Cannot release HW Global Lock, it has not been acquired\n")); return_ACPI_STATUS (AE_NOT_ACQUIRED); } @@ -603,7 +644,8 @@ AcpiEvReleaseGlobalLock (void) */ if (Pending) { - Status = AcpiSetRegister (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK); + Status = AcpiSetRegister (ACPI_BITREG_GLOBAL_LOCK_RELEASE, + 1, ACPI_MTX_LOCK); } return_ACPI_STATUS (Status); @@ -623,7 +665,8 @@ AcpiEvReleaseGlobalLock (void) ******************************************************************************/ void -AcpiEvTerminate (void) +AcpiEvTerminate ( + void) { ACPI_NATIVE_UINT i; ACPI_STATUS Status; @@ -646,23 +689,29 @@ AcpiEvTerminate (void) Status = AcpiDisableEvent ((UINT32) i, 0); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable fixed event %d\n", (UINT32) i)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not disable fixed event %d\n", (UINT32) i)); } } /* Disable all GPEs in all GPE blocks */ - Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, ACPI_NOT_ISR); /* Remove SCI handler */ Status = AcpiEvRemoveSciHandler (); if (ACPI_FAILURE(Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not remove SCI handler\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not remove SCI handler\n")); } } + /* Deallocate all handler objects installed within GPE info structs */ + + Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, ACPI_NOT_ISR); + /* Return to original mode if necessary */ if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY) diff --git a/sys/dev/acpi/acpica/Subsystem/evregion.c b/sys/dev/acpi/acpica/Subsystem/evregion.c index 14f89994281..6a412ecf2ef 100644 --- a/sys/dev/acpi/acpica/Subsystem/evregion.c +++ b/sys/dev/acpi/acpica/Subsystem/evregion.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch - * xRevision: 149 $ + * xRevision: 156 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evregion.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evregion.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EVREGION_C__ @@ -136,10 +136,26 @@ static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = { ACPI_ADR_SPACE_PCI_CONFIG, ACPI_ADR_SPACE_DATA_TABLE}; +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvRegRun ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiEvInstallHandler ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + /******************************************************************************* * - * FUNCTION: AcpiEvInitAddressSpaces + * FUNCTION: AcpiEvInstallRegionHandlers * * PARAMETERS: None * @@ -150,16 +166,22 @@ static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = { ******************************************************************************/ ACPI_STATUS -AcpiEvInitAddressSpaces ( +AcpiEvInstallRegionHandlers ( void) { ACPI_STATUS Status; ACPI_NATIVE_UINT i; - ACPI_FUNCTION_TRACE ("EvInitAddressSpaces"); + ACPI_FUNCTION_TRACE ("EvInstallRegionHandlers"); + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* * All address spaces (PCI Config, EC, SMBus) are scope dependent * and registration must occur for a specific device. @@ -178,10 +200,9 @@ AcpiEvInitAddressSpaces ( * has already been installed (via AcpiInstallAddressSpaceHandler). * Similar for AE_SAME_HANDLER. */ - for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { - Status = AcpiInstallAddressSpaceHandler ((ACPI_HANDLE) AcpiGbl_RootNode, + Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode, AcpiGbl_DefaultAddressSpaces[i], ACPI_DEFAULT_HANDLER, NULL, NULL); switch (Status) @@ -192,15 +213,65 @@ AcpiEvInitAddressSpaces ( /* These exceptions are all OK */ + Status = AE_OK; break; default: - return_ACPI_STATUS (Status); + goto UnlockAndExit; } } - return_ACPI_STATUS (AE_OK); +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeOpRegions + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG methods for all Operation Regions that have + * an installed default region handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeOpRegions ( + void) +{ + ACPI_STATUS Status; + ACPI_NATIVE_UINT i; + + + ACPI_FUNCTION_TRACE ("EvInitializeOpRegions"); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Run the _REG methods for OpRegions in each default address space + */ + for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) + { + /* TBD: Make sure handler is the DEFAULT handler, otherwise + * _REG will have already been run. + */ + Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i]); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); } @@ -208,8 +279,8 @@ AcpiEvInitAddressSpaces ( * * FUNCTION: AcpiEvExecuteRegMethod * - * PARAMETERS: RegionObj - Object structure - * Function - On (1) or Off (0) + * PARAMETERS: RegionObj - Region object + * Function - Passed to _REG: On (1) or Off (0) * * RETURN: Status * @@ -219,11 +290,12 @@ AcpiEvInitAddressSpaces ( ACPI_STATUS AcpiEvExecuteRegMethod ( - ACPI_OPERAND_OBJECT *RegionObj, + ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function) { - ACPI_OPERAND_OBJECT *Params[3]; - ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_PARAMETER_INFO Info; + ACPI_OPERAND_OBJECT *Params[3]; + ACPI_OPERAND_OBJECT *RegionObj2; ACPI_STATUS Status; @@ -242,10 +314,11 @@ AcpiEvExecuteRegMethod ( } /* - * _REG method has two arguments - * Arg0: Integer: Operation region space ID + * The _REG method has two arguments: + * + * Arg0, Integer: Operation region space ID * Same value as RegionObj->Region.SpaceId - * Arg1: Integer: connection status + * Arg1, Integer: connection status * 1 for connecting the handler, * 0 for disconnecting the handler * Passed as a parameter @@ -263,16 +336,21 @@ AcpiEvExecuteRegMethod ( goto Cleanup; } - /* Set up the parameter objects */ + /* Setup the parameter objects */ Params[0]->Integer.Value = RegionObj->Region.SpaceId; Params[1]->Integer.Value = Function; Params[2] = NULL; + Info.Node = RegionObj2->Extra.Method_REG; + Info.Parameters = Params; + Info.ParameterType = ACPI_PARAM_ARGS; + /* Execute the method, no return value */ - ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, RegionObj2->Extra.Method_REG, NULL)); - Status = AcpiNsEvaluateByHandle (RegionObj2->Extra.Method_REG, Params, NULL); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, Info.Node, NULL)); + Status = AcpiNsEvaluateByHandle (&Info); AcpiUtRemoveReference (Params[1]); @@ -288,7 +366,6 @@ Cleanup: * FUNCTION: AcpiEvAddressSpaceDispatch * * PARAMETERS: RegionObj - Internal region object - * SpaceId - ID of the address space (0-255) * Function - Read or Write operation * Address - Where in the space to read or write * BitWidth - Field width in bits (8, 16, 32, or 64) @@ -354,14 +431,16 @@ AcpiEvAddressSpaceDispatch ( { /* No initialization routine, exit with error */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No init routine for region(%p) [%s]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "No init routine for region(%p) [%s]\n", RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId))); return_ACPI_STATUS (AE_NOT_EXIST); } /* - * We must exit the interpreter because the region setup will potentially - * execute control methods (e.g., _REG method for this region) + * We must exit the interpreter because the region + * setup will potentially execute control methods + * (e.g., _REG method for this region) */ AcpiExExitInterpreter (); @@ -420,7 +499,7 @@ AcpiEvAddressSpaceDispatch ( ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (RegionObj->Region.SpaceId))); - if (!(HandlerDesc->AddressSpace.Flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * For handlers other than the default (supplied) handlers, we must @@ -443,7 +522,7 @@ AcpiEvAddressSpaceDispatch ( AcpiFormatException (Status))); } - if (!(HandlerDesc->AddressSpace.Flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + if (!(HandlerDesc->AddressSpace.Hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { /* * We just returned from a non-default handler, we must re-enter the @@ -464,8 +543,8 @@ AcpiEvAddressSpaceDispatch ( * * FUNCTION: AcpiEvDetachRegion * - * PARAMETERS: RegionObj - Region Object - * AcpiNsIsLocked - Namespace Region Already Locked? + * PARAMETERS: RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? * * RETURN: None * @@ -609,9 +688,9 @@ AcpiEvDetachRegion( * * FUNCTION: AcpiEvAttachRegion * - * PARAMETERS: HandlerObj - Handler Object - * RegionObj - Region Object - * AcpiNsIsLocked - Namespace Region Already Locked? + * PARAMETERS: HandlerObj - Handler Object + * RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? * * RETURN: None * @@ -672,7 +751,7 @@ AcpiEvAttachRegion ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiEvInstallHandler ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -793,6 +872,289 @@ AcpiEvInstallHandler ( return (Status); } + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallSpaceHandler + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE Type; + UINT16 Flags = 0; + + + ACPI_FUNCTION_TRACE ("EvInstallSpaceHandler"); + + + /* + * This registration is valid for only the types below + * and the root. This is where the default handlers + * get placed. + */ + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if (Handler == ACPI_DEFAULT_HANDLER) + { + Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; + + switch (SpaceId) + { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + Handler = AcpiExSystemMemorySpaceHandler; + Setup = AcpiEvSystemMemoryRegionSetup; + break; + + case ACPI_ADR_SPACE_SYSTEM_IO: + Handler = AcpiExSystemIoSpaceHandler; + Setup = AcpiEvIoSpaceRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_CONFIG: + Handler = AcpiExPciConfigSpaceHandler; + Setup = AcpiEvPciConfigRegionSetup; + break; + + case ACPI_ADR_SPACE_CMOS: + Handler = AcpiExCmosSpaceHandler; + Setup = AcpiEvCmosRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_BAR_TARGET: + Handler = AcpiExPciBarSpaceHandler; + Setup = AcpiEvPciBarRegionSetup; + break; + + case ACPI_ADR_SPACE_DATA_TABLE: + Handler = AcpiExDataTableSpaceHandler; + Setup = NULL; + break; + + default: + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* If the caller hasn't specified a setup routine, use the default */ + + if (!Setup) + { + Setup = AcpiEvDefaultRegionSetup; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* + * The attached device object already exists. + * Make sure the handler is not already installed. + */ + HandlerObj = ObjDesc->Device.Handler; + + /* Walk the handler list for this device */ + + while (HandlerObj) + { + /* Same SpaceId indicates a handler already installed */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + if (HandlerObj->AddressSpace.Handler == Handler) + { + /* + * It is (relatively) OK to attempt to install the SAME + * handler twice. This can easily happen + * with PCI_Config space. + */ + Status = AE_SAME_HANDLER; + goto UnlockAndExit; + } + else + { + /* A handler is already installed */ + + Status = AE_ALREADY_EXISTS; + } + goto UnlockAndExit; + } + + /* Walk the linked list of handlers */ + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Creating object on Device %p while installing handler\n", Node)); + + /* ObjDesc does not exist, create one */ + + if (Node->Type == ACPI_TYPE_ANY) + { + Type = ACPI_TYPE_DEVICE; + } + else + { + Type = Node->Type; + } + + ObjDesc = AcpiUtCreateInternalObject (Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init new descriptor */ + + ObjDesc->Common.Type = (UINT8) Type; + + /* Attach the new object to the Node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", + AcpiUtGetRegionName (SpaceId), SpaceId, + AcpiUtGetNodeName (Node), Node, ObjDesc)); + + /* + * Install the handler + * + * At this point there is no existing handler. + * Just allocate the object for the handler and link it + * into the list. + */ + HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); + if (!HandlerObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init handler obj */ + + HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId; + HandlerObj->AddressSpace.Hflags = Flags; + HandlerObj->AddressSpace.RegionList = NULL; + HandlerObj->AddressSpace.Node = Node; + HandlerObj->AddressSpace.Handler = Handler; + HandlerObj->AddressSpace.Context = Context; + HandlerObj->AddressSpace.Setup = Setup; + + /* Install at head of Device.AddressSpace list */ + + HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; + + /* + * The Device object is the first reference on the HandlerObj. + * Each region that uses the handler adds a reference. + */ + ObjDesc->Device.Handler = HandlerObj; + + /* + * Walk the namespace finding all of the regions this + * handler will manage. + * + * Start at the device and search the branch toward + * the leaf nodes until either the leaf is encountered or + * a device is detected that has an address handler of the + * same type. + * + * In either case, back up and search down the remainder + * of the branch + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, + HandlerObj, NULL); + +UnlockAndExit: + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvExecuteRegMethods + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * + * RETURN: Status + * + * DESCRIPTION: Run all _REG methods for the input Space ID; + * Note: assumes namespace is locked, or system init time. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("EvExecuteRegMethods"); + + + /* + * Run all _REG methods for all Operation Regions for this + * space ID. This is a separate walk in order to handle any + * interdependencies between regions and _REG methods. (i.e. handlers + * must be installed for all regions of this Space ID before we + * can run any _REG methods) + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, + &SpaceId, NULL); + + return_ACPI_STATUS (Status); +} + + /******************************************************************************* * * FUNCTION: AcpiEvRegRun @@ -803,27 +1165,20 @@ AcpiEvInstallHandler ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiEvRegRun ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue) { - ACPI_OPERAND_OBJECT *HandlerObj; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; + ACPI_ADR_SPACE_TYPE SpaceId; ACPI_STATUS Status; - HandlerObj = (ACPI_OPERAND_OBJECT *) Context; - - /* Parameter validation */ - - if (!HandlerObj) - { - return (AE_OK); - } + SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context); /* Convert and validate the device handle */ @@ -853,10 +1208,9 @@ AcpiEvRegRun ( return (AE_OK); } - /* Object is a Region */ - if (ObjDesc->Region.SpaceId != HandlerObj->AddressSpace.SpaceId) + if (ObjDesc->Region.SpaceId != SpaceId) { /* * This region is for a different address space diff --git a/sys/dev/acpi/acpica/Subsystem/evrgnini.c b/sys/dev/acpi/acpica/Subsystem/evrgnini.c index a319c91e264..bcd8f1bfe36 100644 --- a/sys/dev/acpi/acpica/Subsystem/evrgnini.c +++ b/sys/dev/acpi/acpica/Subsystem/evrgnini.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init - * xRevision: 73 $ + * xRevision: 76 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evrgnini.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evrgnini.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EVRGNINI_C__ @@ -132,14 +132,14 @@ __KERNEL_RCSID(0, "$NetBSD: evrgnini.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * * FUNCTION: AcpiEvSystemMemoryRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling, a nop for now + * DESCRIPTION: Setup a SystemMemory operation region * ******************************************************************************/ @@ -189,14 +189,14 @@ AcpiEvSystemMemoryRegionSetup ( * * FUNCTION: AcpiEvIoSpaceRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Setup a IO operation region * ******************************************************************************/ @@ -227,14 +227,14 @@ AcpiEvIoSpaceRegionSetup ( * * FUNCTION: AcpiEvPciConfigRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Setup a PCI_Config operation region * * MUTEX: Assumes namespace is not locked * @@ -416,14 +416,14 @@ AcpiEvPciConfigRegionSetup ( * * FUNCTION: AcpiEvPciBarRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Setup a PciBAR operation region * * MUTEX: Assumes namespace is not locked * @@ -447,14 +447,14 @@ AcpiEvPciBarRegionSetup ( * * FUNCTION: AcpiEvCmosRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Setup a CMOS operation region * * MUTEX: Assumes namespace is not locked * @@ -478,14 +478,14 @@ AcpiEvCmosRegionSetup ( * * FUNCTION: AcpiEvDefaultRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Default region initialization * ******************************************************************************/ diff --git a/sys/dev/acpi/acpica/Subsystem/evsci.c b/sys/dev/acpi/acpica/Subsystem/evsci.c index 96145b3cf8a..96a2f17e0c1 100644 --- a/sys/dev/acpi/acpica/Subsystem/evsci.c +++ b/sys/dev/acpi/acpica/Subsystem/evsci.c @@ -2,7 +2,7 @@ * * Module Name: evsci - System Control Interrupt configuration and * legacy to ACPI mode state transition functions - * xRevision: 94 $ + * xRevision: 97 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evsci.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evsci.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acevents.h" @@ -126,6 +126,12 @@ __KERNEL_RCSID(0, "$NetBSD: evsci.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evsci") +/* Local prototypes */ + +static UINT32 ACPI_SYSTEM_XFACE +AcpiEvSciXruptHandler ( + void *Context); + /******************************************************************************* * @@ -223,7 +229,8 @@ AcpiEvGpeXruptHandler ( ******************************************************************************/ UINT32 -AcpiEvInstallSciHandler (void) +AcpiEvInstallSciHandler ( + void) { UINT32 Status = AE_OK; @@ -257,7 +264,8 @@ AcpiEvInstallSciHandler (void) ******************************************************************************/ ACPI_STATUS -AcpiEvRemoveSciHandler (void) +AcpiEvRemoveSciHandler ( + void) { ACPI_STATUS Status; diff --git a/sys/dev/acpi/acpica/Subsystem/evxface.c b/sys/dev/acpi/acpica/Subsystem/evxface.c index 03318eb7243..2dc8c8f9cbd 100644 --- a/sys/dev/acpi/acpica/Subsystem/evxface.c +++ b/sys/dev/acpi/acpica/Subsystem/evxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evxface - External interfaces for ACPI events - * xRevision: 142 $ + * xRevision: 149 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evxface.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evxface.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EVXFACE_C__ @@ -131,6 +131,53 @@ __KERNEL_RCSID(0, "$NetBSD: evxface.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); /******************************************************************************* * + * FUNCTION: AcpiInstallExceptionHandler + * + * PARAMETERS: Handler - Pointer to the handler function for the + * event + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallExceptionHandler ( + ACPI_EXCEPTION_HANDLER Handler) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("AcpiInstallExceptionHandler"); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow two handlers. */ + + if (AcpiGbl_ExceptionHandler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_ExceptionHandler = Handler; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * * FUNCTION: AcpiInstallFixedEventHandler * * PARAMETERS: Event - Event type to enable. @@ -275,6 +322,7 @@ AcpiRemoveFixedEventHandler ( * HandlerType - The type of handler: * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device * Handler - Address of the handler * Context - Value passed to the handler on each GPE * @@ -334,22 +382,23 @@ AcpiInstallNotifyHandler ( { /* Make sure the handler is not already installed */ - if (((HandlerType == ACPI_SYSTEM_NOTIFY) && - AcpiGbl_SystemNotify.Handler) || - ((HandlerType == ACPI_DEVICE_NOTIFY) && + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && AcpiGbl_DeviceNotify.Handler)) { Status = AE_ALREADY_EXISTS; goto UnlockAndExit; } - if (HandlerType == ACPI_SYSTEM_NOTIFY) + if (HandlerType & ACPI_SYSTEM_NOTIFY) { AcpiGbl_SystemNotify.Node = Node; AcpiGbl_SystemNotify.Handler = Handler; AcpiGbl_SystemNotify.Context = Context; } - else /* ACPI_DEVICE_NOTIFY */ + + if (HandlerType & ACPI_DEVICE_NOTIFY) { AcpiGbl_DeviceNotify.Node = Node; AcpiGbl_DeviceNotify.Handler = Handler; @@ -381,9 +430,9 @@ AcpiInstallNotifyHandler ( { /* Object exists - make sure there's no handler */ - if (((HandlerType == ACPI_SYSTEM_NOTIFY) && + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && ObjDesc->CommonNotify.SystemNotify) || - ((HandlerType == ACPI_DEVICE_NOTIFY) && + ((HandlerType & ACPI_DEVICE_NOTIFY) && ObjDesc->CommonNotify.DeviceNotify)) { Status = AE_ALREADY_EXISTS; @@ -408,7 +457,6 @@ AcpiInstallNotifyHandler ( /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); - if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -428,14 +476,22 @@ AcpiInstallNotifyHandler ( NotifyObj->Notify.Handler = Handler; NotifyObj->Notify.Context = Context; - if (HandlerType == ACPI_SYSTEM_NOTIFY) + if (HandlerType & ACPI_SYSTEM_NOTIFY) { ObjDesc->CommonNotify.SystemNotify = NotifyObj; } - else /* ACPI_DEVICE_NOTIFY */ + + if (HandlerType & ACPI_DEVICE_NOTIFY) { ObjDesc->CommonNotify.DeviceNotify = NotifyObj; } + + if (HandlerType == ACPI_ALL_NOTIFY) + { + /* Extra ref if installed in both */ + + AcpiUtAddReference (NotifyObj); + } } @@ -453,7 +509,9 @@ UnlockAndExit: * HandlerType - The type of handler: * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device * Handler - Address of the handler + * * RETURN: Status * * DESCRIPTION: Remove a handler for notifies on an ACPI device @@ -499,29 +557,30 @@ AcpiRemoveNotifyHandler ( goto UnlockAndExit; } - /* - * Root Object - */ + /* Root Object */ + if (Device == ACPI_ROOT_OBJECT) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Removing notify handler for ROOT object.\n")); - if (((HandlerType == ACPI_SYSTEM_NOTIFY) && - !AcpiGbl_SystemNotify.Handler) || - ((HandlerType == ACPI_DEVICE_NOTIFY) && + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + !AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && !AcpiGbl_DeviceNotify.Handler)) { Status = AE_NOT_EXIST; goto UnlockAndExit; } - if (HandlerType == ACPI_SYSTEM_NOTIFY) + if (HandlerType & ACPI_SYSTEM_NOTIFY) { AcpiGbl_SystemNotify.Node = NULL; AcpiGbl_SystemNotify.Handler = NULL; AcpiGbl_SystemNotify.Context = NULL; } - else + + if (HandlerType & ACPI_DEVICE_NOTIFY) { AcpiGbl_DeviceNotify.Node = NULL; AcpiGbl_DeviceNotify.Handler = NULL; @@ -529,9 +588,8 @@ AcpiRemoveNotifyHandler ( } } - /* - * All Other Objects - */ + /* All Other Objects */ + else { /* Notifies allowed on this object? */ @@ -553,34 +611,37 @@ AcpiRemoveNotifyHandler ( /* Object exists - make sure there's an existing handler */ - if (HandlerType == ACPI_SYSTEM_NOTIFY) + if (HandlerType & ACPI_SYSTEM_NOTIFY) { NotifyObj = ObjDesc->CommonNotify.SystemNotify; - } - else - { - NotifyObj = ObjDesc->CommonNotify.DeviceNotify; - } - - if ((!NotifyObj) || - (NotifyObj->Notify.Handler != Handler)) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } + if ((!NotifyObj) || + (NotifyObj->Notify.Handler != Handler)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } - /* Remove the handler */ + /* Remove the handler */ - if (HandlerType == ACPI_SYSTEM_NOTIFY) - { ObjDesc->CommonNotify.SystemNotify = NULL; + AcpiUtRemoveReference (NotifyObj); } - else + + if (HandlerType & ACPI_DEVICE_NOTIFY) { + NotifyObj = ObjDesc->CommonNotify.DeviceNotify; + if ((!NotifyObj) || + (NotifyObj->Notify.Handler != Handler)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Remove the handler */ + ObjDesc->CommonNotify.DeviceNotify = NULL; + AcpiUtRemoveReference (NotifyObj); } - - AcpiUtRemoveReference (NotifyObj); } @@ -594,11 +655,12 @@ UnlockAndExit: * * FUNCTION: AcpiInstallGpeHandler * - * PARAMETERS: GpeNumber - The GPE number within the GPE block - * GpeBlock - GPE block (NULL == FADT GPEs) + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The GPE number within the GPE block * Type - Whether this GPE should be treated as an * edge- or level-triggered interrupt. - * Handler - Address of the handler + * Address - Address of the handler * Context - Value passed to the handler on each GPE * * RETURN: Status @@ -612,11 +674,12 @@ AcpiInstallGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT32 Type, - ACPI_GPE_HANDLER Handler, + ACPI_EVENT_HANDLER Address, void *Context) { - ACPI_STATUS Status; ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiInstallGpeHandler"); @@ -624,7 +687,7 @@ AcpiInstallGpeHandler ( /* Parameter validation */ - if (!Handler) + if ((!Address) || (Type > ACPI_GPE_XRUPT_TYPE_MASK)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -646,29 +709,44 @@ AcpiInstallGpeHandler ( /* Make sure that there isn't a handler there already */ - if (GpeEventInfo->Handler) + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { Status = AE_ALREADY_EXISTS; goto UnlockAndExit; } - /* Install the handler */ + /* Allocate and init handler object */ - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); - GpeEventInfo->Handler = Handler; - GpeEventInfo->Context = Context; - GpeEventInfo->Flags = (UINT8) Type; - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + Handler = ACPI_MEM_CALLOCATE (sizeof (ACPI_HANDLER_INFO)); + if (!Handler) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } - /* Clear the GPE (of stale events), the enable it */ + Handler->Address = Address; + Handler->Context = Context; + Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode; - Status = AcpiHwClearGpe (GpeEventInfo); + /* Disable the GPE before installing the handler */ + + Status = AcpiEvDisableGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } - Status = AcpiHwEnableGpe (GpeEventInfo); + /* Install the handler */ + + AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + GpeEventInfo->Dispatch.Handler = Handler; + + /* Setup up dispatch flags to indicate handler (vs. method) */ + + GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ + GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER); + + AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); UnlockAndExit: @@ -681,9 +759,10 @@ UnlockAndExit: * * FUNCTION: AcpiRemoveGpeHandler * - * PARAMETERS: GpeNumber - The event to remove a handler - * GpeBlock - GPE block (NULL == FADT GPEs) - * Handler - Address of the handler + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The event to remove a handler + * Address - Address of the handler * * RETURN: Status * @@ -695,10 +774,11 @@ ACPI_STATUS AcpiRemoveGpeHandler ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - ACPI_GPE_HANDLER Handler) + ACPI_EVENT_HANDLER Address) { - ACPI_STATUS Status; ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiRemoveGpeHandler"); @@ -706,7 +786,7 @@ AcpiRemoveGpeHandler ( /* Parameter validation */ - if (!Handler) + if (!Address) { return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -726,30 +806,49 @@ AcpiRemoveGpeHandler ( goto UnlockAndExit; } - /* Disable the GPE before removing the handler */ + /* Make sure that a handler is indeed installed */ - Status = AcpiHwDisableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != ACPI_GPE_DISPATCH_HANDLER) { + Status = AE_NOT_EXIST; goto UnlockAndExit; } /* Make sure that the installed handler is the same */ - if (GpeEventInfo->Handler != Handler) + if (GpeEventInfo->Dispatch.Handler->Address != Address) { - (void) AcpiHwEnableGpe (GpeEventInfo); Status = AE_BAD_PARAMETER; goto UnlockAndExit; } + /* Disable the GPE before removing the handler */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + /* Remove the handler */ AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); - GpeEventInfo->Handler = NULL; - GpeEventInfo->Context = NULL; + Handler = GpeEventInfo->Dispatch.Handler; + + /* Restore Method node (if any), set dispatch flags */ + + GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; /* Clear bits */ + if (Handler->MethodNode) + { + GpeEventInfo->Flags |= ACPI_GPE_DISPATCH_METHOD; + } AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + /* Now we can free the handler object */ + + ACPI_MEM_FREE (Handler); + UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); @@ -762,7 +861,8 @@ UnlockAndExit: * FUNCTION: AcpiAcquireGlobalLock * * PARAMETERS: Timeout - How long the caller is willing to wait - * OutHandle - A handle to the lock if acquired + * Handle - Where the handle to the lock is returned + * (if acquired) * * RETURN: Status * @@ -810,7 +910,7 @@ AcpiAcquireGlobalLock ( * * RETURN: Status * - * DESCRIPTION: Release the ACPI Global Lock + * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid. * ******************************************************************************/ diff --git a/sys/dev/acpi/acpica/Subsystem/evxfevnt.c b/sys/dev/acpi/acpica/Subsystem/evxfevnt.c index 55df33fd5a6..fcf8236ddfc 100644 --- a/sys/dev/acpi/acpica/Subsystem/evxfevnt.c +++ b/sys/dev/acpi/acpica/Subsystem/evxfevnt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable - * xRevision: 74 $ + * xRevision: 81 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evxfevnt.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evxfevnt.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EVXFEVNT_C__ @@ -141,7 +141,8 @@ __KERNEL_RCSID(0, "$NetBSD: evxfevnt.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); ******************************************************************************/ ACPI_STATUS -AcpiEnable (void) +AcpiEnable ( + void) { ACPI_STATUS Status = AE_OK; @@ -172,7 +173,8 @@ AcpiEnable (void) return_ACPI_STATUS (Status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Transition to ACPI mode successful\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Transition to ACPI mode successful\n")); } return_ACPI_STATUS (Status); @@ -187,12 +189,13 @@ AcpiEnable (void) * * RETURN: Status * - * DESCRIPTION: Transfers the system into LEGACY mode. + * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode. * ******************************************************************************/ ACPI_STATUS -AcpiDisable (void) +AcpiDisable ( + void) { ACPI_STATUS Status = AE_OK; @@ -208,7 +211,8 @@ AcpiDisable (void) if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) { - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in legacy (non-ACPI) mode\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "System is already in legacy (non-ACPI) mode\n")); } else { @@ -218,7 +222,8 @@ AcpiDisable (void) if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not exit ACPI mode to legacy mode")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not exit ACPI mode to legacy mode")); return_ACPI_STATUS (Status); } @@ -294,43 +299,31 @@ AcpiEnableEvent ( /******************************************************************************* * - * FUNCTION: AcpiEnableGpe + * FUNCTION: AcpiSetGpeType * * PARAMETERS: GpeDevice - Parent GPE Device * GpeNumber - GPE level within the GPE block - * Flags - Just enable, or also wake enable? - * Called from ISR or not + * Type - New GPE type * * RETURN: Status * - * DESCRIPTION: Enable an ACPI event (general purpose) + * DESCRIPTION: Set the type of an individual GPE * ******************************************************************************/ ACPI_STATUS -AcpiEnableGpe ( +AcpiSetGpeType ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber, - UINT32 Flags) + UINT8 Type) { ACPI_STATUS Status = AE_OK; ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_FUNCTION_TRACE ("AcpiEnableGpe"); + ACPI_FUNCTION_TRACE ("AcpiSetGpeType"); - /* Use semaphore lock if not executing at interrupt level */ - - if (Flags & ACPI_NOT_ISR) - { - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - /* Ensure that we have a valid GPE number */ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); @@ -340,85 +333,77 @@ AcpiEnableGpe ( goto UnlockAndExit; } - /* Enable the requested GPE number */ - - Status = AcpiHwEnableGpe (GpeEventInfo); - if (ACPI_FAILURE (Status)) + if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type) { - goto UnlockAndExit; + return_ACPI_STATUS (AE_OK); } - if (Flags & ACPI_EVENT_WAKE_ENABLE) - { - AcpiHwEnableGpeForWakeup (GpeEventInfo); - } + /* Set the new type (will disable GPE if currently enabled) */ + + Status = AcpiEvSetGpeType (GpeEventInfo, Type); UnlockAndExit: - if (Flags & ACPI_NOT_ISR) - { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); - } return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiDisableEvent + * FUNCTION: AcpiEnableGpe * - * PARAMETERS: Event - The fixed eventto be enabled - * Flags - Reserved + * PARAMETERS: GpeDevice - Parent GPE Device + * GpeNumber - GPE level within the GPE block + * Flags - Just enable, or also wake enable? + * Called from ISR or not * * RETURN: Status * - * DESCRIPTION: Disable an ACPI event (fixed) + * DESCRIPTION: Enable an ACPI event (general purpose) * ******************************************************************************/ ACPI_STATUS -AcpiDisableEvent ( - UINT32 Event, +AcpiEnableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, UINT32 Flags) { ACPI_STATUS Status = AE_OK; - UINT32 Value; + ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_FUNCTION_TRACE ("AcpiDisableEvent"); + ACPI_FUNCTION_TRACE ("AcpiEnableGpe"); - /* Decode the Fixed Event */ + /* Use semaphore lock if not executing at interrupt level */ - if (Event > ACPI_EVENT_MAX) + if (Flags & ACPI_NOT_ISR) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } - /* - * Disable the requested fixed event (by writing a zero to the - * enable register bit) - */ - Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - 0, ACPI_MTX_LOCK); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Ensure that we have a valid GPE number */ - Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, - &Value, ACPI_MTX_LOCK); - if (ACPI_FAILURE (Status)) + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) { - return_ACPI_STATUS (Status); + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; } - if (Value != 0) + /* Perform the enable */ + + Status = AcpiEvEnableGpe (GpeEventInfo, TRUE); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not disable %s events\n", AcpiUtGetEventName (Event))); - return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); } - return_ACPI_STATUS (Status); } @@ -429,7 +414,7 @@ AcpiDisableEvent ( * * PARAMETERS: GpeDevice - Parent GPE Device * GpeNumber - GPE level within the GPE block - * Flags - Just enable, or also wake enable? + * Flags - Just disable, or also wake disable? * Called from ISR or not * * RETURN: Status @@ -471,24 +456,74 @@ AcpiDisableGpe ( goto UnlockAndExit; } + Status = AcpiEvDisableGpe (GpeEventInfo); + +UnlockAndExit: + if (Flags & ACPI_NOT_ISR) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDisableEvent + * + * PARAMETERS: Event - The fixed eventto be enabled + * Flags - Reserved + * + * RETURN: Status + * + * DESCRIPTION: Disable an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 Event, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value; + + + ACPI_FUNCTION_TRACE ("AcpiDisableEvent"); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + /* - * Only disable the requested GPE number for wake if specified. - * Otherwise, turn it totally off + * Disable the requested fixed event (by writing a zero to the + * enable register bit) */ - if (Flags & ACPI_EVENT_WAKE_DISABLE) + Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + 0, ACPI_MTX_LOCK); + if (ACPI_FAILURE (Status)) { - AcpiHwDisableGpeForWakeup (GpeEventInfo); + return_ACPI_STATUS (Status); } - else + + Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + &Value, ACPI_MTX_LOCK); + if (ACPI_FAILURE (Status)) { - Status = AcpiHwDisableGpe (GpeEventInfo); + return_ACPI_STATUS (Status); } -UnlockAndExit: - if (Flags & ACPI_NOT_ISR) + if (Value != 0) { - (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not disable %s events\n", AcpiUtGetEventName (Event))); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); } + return_ACPI_STATUS (Status); } @@ -596,7 +631,7 @@ UnlockAndExit: * FUNCTION: AcpiGetEventStatus * * PARAMETERS: Event - The fixed event - * Event Status - Where the current status of the event will + * EventStatus - Where the current status of the event will * be returned * * RETURN: Status @@ -644,7 +679,7 @@ AcpiGetEventStatus ( * PARAMETERS: GpeDevice - Parent GPE Device * GpeNumber - GPE level within the GPE block * Flags - Called from an ISR or not - * Event Status - Where the current status of the event will + * EventStatus - Where the current status of the event will * be returned * * RETURN: Status diff --git a/sys/dev/acpi/acpica/Subsystem/evxfregn.c b/sys/dev/acpi/acpica/Subsystem/evxfregn.c index 77fb14f2d9d..22a06ace073 100644 --- a/sys/dev/acpi/acpica/Subsystem/evxfregn.c +++ b/sys/dev/acpi/acpica/Subsystem/evxfregn.c @@ -2,7 +2,7 @@ * * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and * Address Spaces. - * xRevision: 61 $ + * xRevision: 64 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,14 +116,13 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: evxfregn.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evxfregn.c,v 1.12 2005/05/02 14:52:09 kochi Exp $"); #define __EVXFREGN_C__ #include "acpi.h" #include "acnamesp.h" #include "acevents.h" -#include "acinterp.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evxfregn") @@ -153,12 +152,8 @@ AcpiInstallAddressSpaceHandler ( ACPI_ADR_SPACE_SETUP Setup, void *Context) { - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *HandlerObj; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; - ACPI_OBJECT_TYPE Type; - UINT16 Flags = 0; ACPI_FUNCTION_TRACE ("AcpiInstallAddressSpaceHandler"); @@ -186,217 +181,17 @@ AcpiInstallAddressSpaceHandler ( goto UnlockAndExit; } - /* - * This registration is valid for only the types below - * and the root. This is where the default handlers - * get placed. - */ - if ((Node->Type != ACPI_TYPE_DEVICE) && - (Node->Type != ACPI_TYPE_PROCESSOR) && - (Node->Type != ACPI_TYPE_THERMAL) && - (Node != AcpiGbl_RootNode)) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - if (Handler == ACPI_DEFAULT_HANDLER) - { - Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; - - switch (SpaceId) - { - case ACPI_ADR_SPACE_SYSTEM_MEMORY: - Handler = AcpiExSystemMemorySpaceHandler; - Setup = AcpiEvSystemMemoryRegionSetup; - break; - - case ACPI_ADR_SPACE_SYSTEM_IO: - Handler = AcpiExSystemIoSpaceHandler; - Setup = AcpiEvIoSpaceRegionSetup; - break; - - case ACPI_ADR_SPACE_PCI_CONFIG: - Handler = AcpiExPciConfigSpaceHandler; - Setup = AcpiEvPciConfigRegionSetup; - break; - - case ACPI_ADR_SPACE_CMOS: - Handler = AcpiExCmosSpaceHandler; - Setup = AcpiEvCmosRegionSetup; - break; - - case ACPI_ADR_SPACE_PCI_BAR_TARGET: - Handler = AcpiExPciBarSpaceHandler; - Setup = AcpiEvPciBarRegionSetup; - break; - - case ACPI_ADR_SPACE_DATA_TABLE: - Handler = AcpiExDataTableSpaceHandler; - Setup = NULL; - break; - - default: - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - } - - /* If the caller hasn't specified a setup routine, use the default */ - - if (!Setup) - { - Setup = AcpiEvDefaultRegionSetup; - } - - /* Check for an existing internal object */ - - ObjDesc = AcpiNsGetAttachedObject (Node); - if (ObjDesc) - { - /* - * The attached device object already exists. - * Make sure the handler is not already installed. - */ - HandlerObj = ObjDesc->Device.Handler; - - /* Walk the handler list for this device */ - - while (HandlerObj) - { - /* Same SpaceId indicates a handler already installed */ - - if(HandlerObj->AddressSpace.SpaceId == SpaceId) - { - if (HandlerObj->AddressSpace.Handler == Handler) - { - /* - * It is (relatively) OK to attempt to install the SAME - * handler twice. This can easily happen with PCI_Config space. - */ - Status = AE_SAME_HANDLER; - goto UnlockAndExit; - } - else - { - /* A handler is already installed */ - - Status = AE_ALREADY_EXISTS; - } - goto UnlockAndExit; - } - - /* Walk the linked list of handlers */ - - HandlerObj = HandlerObj->AddressSpace.Next; - } - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Creating object on Device %p while installing handler\n", Node)); - - /* ObjDesc does not exist, create one */ - - if (Node->Type == ACPI_TYPE_ANY) - { - Type = ACPI_TYPE_DEVICE; - } - else - { - Type = Node->Type; - } - - ObjDesc = AcpiUtCreateInternalObject (Type); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* Init new descriptor */ - - ObjDesc->Common.Type = (UINT8) Type; - - /* Attach the new object to the Node */ - - Status = AcpiNsAttachObject (Node, ObjDesc, Type); - - /* Remove local reference to the object */ - - AcpiUtRemoveReference (ObjDesc); - - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - } + /* Install the handler for all Regions for this Space ID */ - ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", - AcpiUtGetRegionName (SpaceId), SpaceId, - AcpiUtGetNodeName (Node), Node, ObjDesc)); - - /* - * Install the handler - * - * At this point there is no existing handler. - * Just allocate the object for the handler and link it - * into the list. - */ - HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); - if (!HandlerObj) + Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context); + if (ACPI_FAILURE (Status)) { - Status = AE_NO_MEMORY; goto UnlockAndExit; } - /* Init handler obj */ - - HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId; - HandlerObj->AddressSpace.Hflags = Flags; - HandlerObj->AddressSpace.RegionList = NULL; - HandlerObj->AddressSpace.Node = Node; - HandlerObj->AddressSpace.Handler = Handler; - HandlerObj->AddressSpace.Context = Context; - HandlerObj->AddressSpace.Setup = Setup; - - /* Install at head of Device.AddressSpace list */ - - HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; - - /* - * The Device object is the first reference on the HandlerObj. - * Each region that uses the handler adds a reference. - */ - ObjDesc->Device.Handler = HandlerObj; - - /* - * Walk the namespace finding all of the regions this - * handler will manage. - * - * Start at the device and search the branch toward - * the leaf nodes until either the leaf is encountered or - * a device is detected that has an address handler of the - * same type. - * - * In either case, back up and search down the remainder - * of the branch - */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, - HandlerObj, NULL); - - /* - * Now we can run the _REG methods for all Regions for this - * space ID. This is a separate walk in order to handle any - * interdependencies between regions and _REG methods. (i.e. handlers - * must be installed for all regions of this Space ID before we - * can run any _REG methods. - */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, ACPI_UINT32_MAX, - ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, - HandlerObj, NULL); + /* Run all _REG methods for this address space */ + + Status = AcpiEvExecuteRegMethods (Node, SpaceId); UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); diff --git a/sys/dev/acpi/acpica/Subsystem/exconfig.c b/sys/dev/acpi/acpica/Subsystem/exconfig.c index 9fc9b6a2d3e..5b242e005ba 100644 --- a/sys/dev/acpi/acpica/Subsystem/exconfig.c +++ b/sys/dev/acpi/acpica/Subsystem/exconfig.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) - * xRevision: 75 $ + * xRevision: 83 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exconfig.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exconfig.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXCONFIG_C__ @@ -126,11 +126,20 @@ __KERNEL_RCSID(0, "$NetBSD: exconfig.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #include "acnamesp.h" #include "acevents.h" #include "actables.h" +#include "acdispat.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exconfig") +/* Local prototypes */ + +static ACPI_STATUS +AcpiExAddTable ( + ACPI_TABLE_HEADER *Table, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle); + /******************************************************************************* * @@ -147,7 +156,7 @@ __KERNEL_RCSID(0, "$NetBSD: exconfig.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExAddTable ( ACPI_TABLE_HEADER *Table, ACPI_NAMESPACE_NODE *ParentNode, @@ -173,10 +182,10 @@ AcpiExAddTable ( ACPI_MEMSET (&TableInfo, 0, sizeof (ACPI_TABLE_DESC)); - TableInfo.Type = 5; - TableInfo.Pointer = Table; - TableInfo.Length = (ACPI_SIZE) Table->Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; + TableInfo.Type = ACPI_TABLE_SSDT; + TableInfo.Pointer = Table; + TableInfo.Length = (ACPI_SIZE) Table->Length; + TableInfo.Allocation = ACPI_MEM_ALLOCATED; Status = AcpiTbInstallTable (&TableInfo); if (ACPI_FAILURE (Status)) @@ -314,11 +323,10 @@ AcpiExLoadTableOp ( StartNode = ParentNode; } - /* - * Find the node referenced by the ParameterPathString - */ + /* Find the node referenced by the ParameterPathString */ + Status = AcpiNsGetNodeByPath (Operand[4]->String.Pointer, StartNode, - ACPI_NS_SEARCH_PARENT, &ParameterNode); + ACPI_NS_SEARCH_PARENT, &ParameterNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -339,8 +347,9 @@ AcpiExLoadTableOp ( { /* Store the parameter data into the optional parameter object */ - Status = AcpiExStore (Operand[5], ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), - WalkState); + Status = AcpiExStore (Operand[5], + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), + WalkState); if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); @@ -378,7 +387,7 @@ AcpiExLoadOp ( ACPI_OPERAND_OBJECT *DdbHandle; ACPI_OPERAND_OBJECT *BufferDesc = NULL; ACPI_TABLE_HEADER *TablePtr = NULL; - UINT8 *TableDataPtr; + ACPI_PHYSICAL_ADDRESS Address; ACPI_TABLE_HEADER TableHeader; UINT32 i; @@ -394,13 +403,30 @@ AcpiExLoadOp ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); - /* Get the table header */ + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetRegionArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Get the base physical address of the region */ + + Address = ObjDesc->Region.Address; + + /* Get the table length from the table header */ TableHeader.Length = 0; - for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) + for (i = 0; i < 8; i++) { Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) i, 8, + (ACPI_PHYSICAL_ADDRESS) (i + Address), 8, ((UINT8 *) &TableHeader) + i); if (ACPI_FAILURE (Status)) { @@ -408,6 +434,13 @@ AcpiExLoadOp ( } } + /* Sanity check the table length */ + + if (TableHeader.Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_BAD_HEADER); + } + /* Allocate a buffer for the entire table */ TablePtr = ACPI_MEM_ALLOCATE (TableHeader.Length); @@ -416,18 +449,13 @@ AcpiExLoadOp ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* Copy the header to the buffer */ - - ACPI_MEMCPY (TablePtr, &TableHeader, sizeof (ACPI_TABLE_HEADER)); - TableDataPtr = ACPI_PTR_ADD (UINT8, TablePtr, sizeof (ACPI_TABLE_HEADER)); - - /* Get the table from the op region */ + /* Get the entire table from the op region */ for (i = 0; i < TableHeader.Length; i++) { Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, - (ACPI_PHYSICAL_ADDRESS) i, 8, - ((UINT8 *) TableDataPtr + i)); + (ACPI_PHYSICAL_ADDRESS) (i + Address), 8, + ((UINT8 *) TablePtr + i)); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -454,7 +482,15 @@ AcpiExLoadOp ( goto Cleanup; } - TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, BufferDesc->Buffer.Pointer); + TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, + BufferDesc->Buffer.Pointer); + + /* Sanity check the table length */ + + if (TablePtr->Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_BAD_HEADER); + } break; diff --git a/sys/dev/acpi/acpica/Subsystem/exconvrt.c b/sys/dev/acpi/acpica/Subsystem/exconvrt.c index d2c63406f50..86e2dd1c1c4 100644 --- a/sys/dev/acpi/acpica/Subsystem/exconvrt.c +++ b/sys/dev/acpi/acpica/Subsystem/exconvrt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exconvrt - Object conversion routines - * xRevision: 53 $ + * xRevision: 66 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exconvrt.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exconvrt.c,v 1.13 2005/05/02 14:52:09 kochi Exp $"); #define __EXCONVRT_C__ @@ -128,6 +128,15 @@ __KERNEL_RCSID(0, "$NetBSD: exconvrt.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exconvrt") +/* Local prototypes */ + +static UINT32 +AcpiExConvertToAscii ( + ACPI_INTEGER Integer, + UINT16 Base, + UINT8 *String, + UINT8 MaxLength); + /******************************************************************************* * @@ -136,7 +145,7 @@ __KERNEL_RCSID(0, "$NetBSD: exconvrt.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); * PARAMETERS: ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * ResultDesc - Where the new Integer object is returned - * WalkState - Current method state + * Flags - Used for string conversion * * RETURN: Status * @@ -148,13 +157,13 @@ ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - ACPI_WALK_STATE *WalkState) + UINT32 Flags) { - UINT32 i; - ACPI_OPERAND_OBJECT *RetDesc; - UINT32 Count; + ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *Pointer; ACPI_INTEGER Result; + UINT32 i; + UINT32 Count; ACPI_STATUS Status; @@ -164,15 +173,17 @@ AcpiExConvertToInteger ( switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_INTEGER: + + /* No conversion necessary */ + *ResultDesc = ObjDesc; return_ACPI_STATUS (AE_OK); + case ACPI_TYPE_BUFFER: case ACPI_TYPE_STRING: - Pointer = (UINT8 *) ObjDesc->String.Pointer; - Count = ObjDesc->String.Length; - break; - case ACPI_TYPE_BUFFER: + /* Note: Takes advantage of common buffer/string fields */ + Pointer = ObjDesc->Buffer.Pointer; Count = ObjDesc->Buffer.Length; break; @@ -192,25 +203,19 @@ AcpiExConvertToInteger ( */ Result = 0; - /* Transfer no more than an integer's worth of data */ - - if (Count > AcpiGbl_IntegerByteWidth) - { - Count = AcpiGbl_IntegerByteWidth; - } + /* String conversion is different than Buffer conversion */ - /* - * String conversion is different than Buffer conversion - */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_STRING: /* - * Convert string to an integer - * String must be hexadecimal as per the ACPI specification + * Convert string to an integer - for most cases, the string must be + * hexadecimal as per the ACPI specification. The only exception (as + * of ACPI 3.0) is that the ToInteger() operator allows both decimal + * and hexadecimal strings (hex prefixed with "0x"). */ - Status = AcpiUtStrtoul64 ((char *) Pointer, 16, &Result); + Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -220,9 +225,23 @@ AcpiExConvertToInteger ( case ACPI_TYPE_BUFFER: + /* Check for zero-length buffer */ + + if (!Count) + { + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + + /* Transfer no more than an integer's worth of data */ + + if (Count > AcpiGbl_IntegerByteWidth) + { + Count = AcpiGbl_IntegerByteWidth; + } + /* - * Buffer conversion - we simply grab enough raw data from the - * buffer to fill an integer + * Convert buffer to an integer - we simply grab enough raw data + * from the buffer to fill an integer */ for (i = 0; i < Count; i++) { @@ -241,33 +260,19 @@ AcpiExConvertToInteger ( break; } - /* - * Create a new integer - */ - RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!RetDesc) + /* Create a new integer */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Save the Result */ - RetDesc->Integer.Value = Result; - - /* - * If we are about to overwrite the original object on the operand stack, - * we must remove a reference on the original object because we are - * essentially removing it from the stack. - */ - if (*ResultDesc == ObjDesc) - { - if (WalkState->Opcode != AML_STORE_OP) - { - AcpiUtRemoveReference (ObjDesc); - } - } - - *ResultDesc = RetDesc; + ReturnDesc->Integer.Value = Result; + AcpiExTruncateFor32bitTable (ReturnDesc); + *ResultDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); } @@ -279,7 +284,6 @@ AcpiExConvertToInteger ( * PARAMETERS: ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * ResultDesc - Where the new buffer object is returned - * WalkState - Current method state * * RETURN: Status * @@ -290,11 +294,9 @@ AcpiExConvertToInteger ( ACPI_STATUS AcpiExConvertToBuffer ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc, - ACPI_WALK_STATE *WalkState) + ACPI_OPERAND_OBJECT **ResultDesc) { - ACPI_OPERAND_OBJECT *RetDesc; - UINT32 i; + ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *NewBuf; @@ -317,19 +319,18 @@ AcpiExConvertToBuffer ( * Create a new Buffer object. * Need enough space for one integer */ - RetDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); - if (!RetDesc) + ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); + if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - /* Copy the integer to the buffer */ + /* Copy the integer to the buffer, LSB first */ - NewBuf = RetDesc->Buffer.Pointer; - for (i = 0; i < AcpiGbl_IntegerByteWidth; i++) - { - NewBuf[i] = (UINT8) (ObjDesc->Integer.Value >> (i * 8)); - } + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_MEMCPY (NewBuf, + &ObjDesc->Integer.Value, + AcpiGbl_IntegerByteWidth); break; @@ -338,16 +339,22 @@ AcpiExConvertToBuffer ( /* * Create a new Buffer object * Size will be the string length + * + * NOTE: Add one to the string length to include the null terminator. + * The ACPI spec is unclear on this subject, but there is existing + * ASL/AML code that depends on the null being transferred to the new + * buffer. */ - RetDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) ObjDesc->String.Length); - if (!RetDesc) + ReturnDesc = AcpiUtCreateBufferObject ( + (ACPI_SIZE) ObjDesc->String.Length + 1); + if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Copy the string to the buffer */ - NewBuf = RetDesc->Buffer.Pointer; + NewBuf = ReturnDesc->Buffer.Pointer; ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, ObjDesc->String.Length); break; @@ -359,34 +366,20 @@ AcpiExConvertToBuffer ( /* Mark buffer initialized */ - RetDesc->Common.Flags |= AOPOBJ_DATA_VALID; - - /* - * If we are about to overwrite the original object on the operand stack, - * we must remove a reference on the original object because we are - * essentially removing it from the stack. - */ - if (*ResultDesc == ObjDesc) - { - if (WalkState->Opcode != AML_STORE_OP) - { - AcpiUtRemoveReference (ObjDesc); - } - } - - *ResultDesc = RetDesc; + ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID; + *ResultDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiExConvertAscii + * FUNCTION: AcpiExConvertToAscii * * PARAMETERS: Integer - Value to be converted - * Base - 10 or 16 + * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX * String - Where the string is returned - * DataWidth - Size of data item to be converted + * DataWidth - Size of data item to be converted, in bytes * * RETURN: Actual string length * @@ -394,60 +387,69 @@ AcpiExConvertToBuffer ( * ******************************************************************************/ -UINT32 +static UINT32 AcpiExConvertToAscii ( ACPI_INTEGER Integer, - UINT32 Base, + UINT16 Base, UINT8 *String, UINT8 DataWidth) { - UINT32 i; - UINT32 j; - UINT32 k = 0; - char HexDigit; ACPI_INTEGER Digit; + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT j; + ACPI_NATIVE_UINT k = 0; + ACPI_NATIVE_UINT HexLength; + ACPI_NATIVE_UINT DecimalLength; UINT32 Remainder; - UINT32 Length; - BOOLEAN LeadingZero; + BOOLEAN SupressZeros; ACPI_FUNCTION_ENTRY (); - if (DataWidth < sizeof (ACPI_INTEGER)) - { - LeadingZero = FALSE; - Length = DataWidth; - } - else - { - LeadingZero = TRUE; - Length = sizeof (ACPI_INTEGER); - } - switch (Base) { case 10: + /* Setup max length for the decimal number */ + + switch (DataWidth) + { + case 1: + DecimalLength = ACPI_MAX8_DECIMAL_DIGITS; + break; + + case 4: + DecimalLength = ACPI_MAX32_DECIMAL_DIGITS; + break; + + case 8: + default: + DecimalLength = ACPI_MAX64_DECIMAL_DIGITS; + break; + } + + SupressZeros = TRUE; /* No leading zeros */ Remainder = 0; - for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0; i--) + + for (i = DecimalLength; i > 0; i--) { /* Divide by nth factor of 10 */ Digit = Integer; for (j = 0; j < i; j++) { - (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Remainder); + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder); } - /* Create the decimal digit */ + /* Handle leading zeros */ if (Remainder != 0) { - LeadingZero = FALSE; + SupressZeros = FALSE; } - if (!LeadingZero) + if (!SupressZeros) { String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder); k++; @@ -455,31 +457,22 @@ AcpiExConvertToAscii ( } break; - case 16: - /* Copy the integer to the buffer */ + /* HexLength: 2 ascii hex chars per data byte */ - for (i = 0, j = ((Length * 2) -1); i < (Length * 2); i++, j--) + HexLength = ACPI_MUL_2 (DataWidth); + for (i = 0, j = (HexLength-1); i < HexLength; i++, j--) { + /* Get one hex digit, most significant digits first */ - HexDigit = AcpiUtHexToAsciiChar (Integer, (j * 4)); - if (HexDigit != ACPI_ASCII_ZERO) - { - LeadingZero = FALSE; - } - - if (!LeadingZero) - { - String[k] = (UINT8) HexDigit; - k++; - } + String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); + k++; } break; - default: - break; + return (0); } /* @@ -495,7 +488,7 @@ AcpiExConvertToAscii ( } String [k] = 0; - return (k); + return ((UINT32) k); } @@ -504,11 +497,9 @@ AcpiExConvertToAscii ( * FUNCTION: AcpiExConvertToString * * PARAMETERS: ObjDesc - Object to be converted. Must be an - * Integer, Buffer, or String + * Integer, Buffer, or String * ResultDesc - Where the string object is returned - * Base - 10 or 16 - * MaxLength - Max length of the returned string - * WalkState - Current method state + * Type - String flags (base and conversion type) * * RETURN: Status * @@ -520,15 +511,14 @@ ACPI_STATUS AcpiExConvertToString ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - UINT32 Base, - UINT32 MaxLength, - ACPI_WALK_STATE *WalkState) + UINT32 Type) { - ACPI_OPERAND_OBJECT *RetDesc; + ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *NewBuf; - UINT8 *Pointer; - UINT32 StringLength; UINT32 i; + UINT32 StringLength = 0; + UINT16 Base = 16; + UINT8 Separator = ','; ACPI_FUNCTION_TRACE_PTR ("ExConvertToString", ObjDesc); @@ -538,146 +528,157 @@ AcpiExConvertToString ( { case ACPI_TYPE_STRING: - if (MaxLength >= ObjDesc->String.Length) - { - *ResultDesc = ObjDesc; - return_ACPI_STATUS (AE_OK); - } - else - { - /* Must copy the string first and then truncate it */ + /* No conversion necessary */ - return_ACPI_STATUS (AE_NOT_IMPLEMENTED); - } + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); case ACPI_TYPE_INTEGER: - StringLength = AcpiGbl_IntegerByteWidth * 2; - if (Base == 10) + switch (Type) { + case ACPI_EXPLICIT_CONVERT_DECIMAL: + + /* Make room for maximum decimal number */ + StringLength = ACPI_MAX_DECIMAL_DIGITS; + Base = 10; + break; + + default: + + /* Two hex string characters for each integer byte */ + + StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth); + break; } /* * Create a new String + * Need enough space for one ASCII integer (plus null terminator) */ - RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); - if (!RetDesc) + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - /* Need enough space for one ASCII integer plus null terminator */ + NewBuf = ReturnDesc->Buffer.Pointer; - NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); - if (!NewBuf) - { - ACPI_REPORT_ERROR - (("ExConvertToString: Buffer allocation failure\n")); - AcpiUtRemoveReference (RetDesc); - return_ACPI_STATUS (AE_NO_MEMORY); - } + /* Convert integer to string */ - /* Convert */ - - i = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, NewBuf, sizeof (ACPI_INTEGER)); + StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, + NewBuf, AcpiGbl_IntegerByteWidth); /* Null terminate at the correct place */ - if (MaxLength < i) - { - NewBuf[MaxLength] = 0; - RetDesc->String.Length = MaxLength; - } - else - { - NewBuf [i] = 0; - RetDesc->String.Length = i; - } - - RetDesc->Buffer.Pointer = NewBuf; + ReturnDesc->String.Length = StringLength; + NewBuf [StringLength] = 0; break; case ACPI_TYPE_BUFFER: - /* Find the string length */ + /* Setup string length, base, and separator */ - Pointer = ObjDesc->Buffer.Pointer; - for (StringLength = 0; StringLength < ObjDesc->Buffer.Length; StringLength++) + switch (Type) { - /* Exit on null terminator */ + case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * decimal values separated by commas." + */ + Base = 10; - if (!Pointer[StringLength]) + /* + * Calculate the final string length. Individual string values + * are variable length (include separator for each) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) { - break; + if (ObjDesc->Buffer.Pointer[i] >= 100) + { + StringLength += 4; + } + else if (ObjDesc->Buffer.Pointer[i] >= 10) + { + StringLength += 3; + } + else + { + StringLength += 2; + } } - } + break; - if (MaxLength > ACPI_MAX_STRING_CONVERSION) - { - if (StringLength > ACPI_MAX_STRING_CONVERSION) - { - return_ACPI_STATUS (AE_AML_STRING_LIMIT); - } + case ACPI_IMPLICIT_CONVERT_HEX: + /* + * From the ACPI spec: + *"The entire contents of the buffer are converted to a string of + * two-character hexadecimal numbers, each separated by a space." + */ + Separator = ' '; + StringLength = (ObjDesc->Buffer.Length * 3); + break; + + case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * hexadecimal values separated by commas." + */ + StringLength = (ObjDesc->Buffer.Length * 3); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); } /* - * Create a new string object + * Perform the conversion. + * (-1 because of extra separator included in StringLength from above) */ - RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); - if (!RetDesc) + StringLength--; + if (StringLength > ACPI_MAX_STRING_CONVERSION) /* ACPI limit */ { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS (AE_AML_STRING_LIMIT); } - /* String length is the lesser of the Max or the actual length */ - - if (MaxLength < StringLength) - { - StringLength = MaxLength; - } + /* Create a new string object and string buffer */ - NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); - if (!NewBuf) + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) { - ACPI_REPORT_ERROR - (("ExConvertToString: Buffer allocation failure\n")); - AcpiUtRemoveReference (RetDesc); return_ACPI_STATUS (AE_NO_MEMORY); } - /* Copy the appropriate number of buffer characters */ + NewBuf = ReturnDesc->Buffer.Pointer; - ACPI_MEMCPY (NewBuf, Pointer, StringLength); - - /* Null terminate */ + /* + * Convert buffer bytes to hex or decimal values + * (separated by commas or spaces) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) + { + NewBuf += AcpiExConvertToAscii ( + (ACPI_INTEGER) ObjDesc->Buffer.Pointer[i], Base, + NewBuf, 1); + *NewBuf++ = Separator; /* each separated by a comma or space */ + } - NewBuf [StringLength] = 0; - RetDesc->Buffer.Pointer = NewBuf; - RetDesc->String.Length = StringLength; + /* + * Null terminate the string + * (overwrites final comma/space from above) + */ + NewBuf--; + *NewBuf = 0; break; - default: return_ACPI_STATUS (AE_TYPE); } - /* - * If we are about to overwrite the original object on the operand stack, - * we must remove a reference on the original object because we are - * essentially removing it from the stack. - */ - if (*ResultDesc == ObjDesc) - { - if (WalkState->Opcode != AML_STORE_OP) - { - AcpiUtRemoveReference (ObjDesc); - } - } - - *ResultDesc = RetDesc; + *ResultDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); } @@ -759,27 +760,27 @@ AcpiExConvertToTargetType ( * These types require an Integer operand. We can convert * a Buffer or a String to an Integer if necessary. */ - Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, WalkState); + Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, + 16); break; case ACPI_TYPE_STRING: - /* * The operand must be a String. We can convert an * Integer or Buffer if necessary */ - Status = AcpiExConvertToString (SourceDesc, ResultDesc, 16, ACPI_UINT32_MAX, WalkState); + Status = AcpiExConvertToString (SourceDesc, ResultDesc, + ACPI_IMPLICIT_CONVERT_HEX); break; case ACPI_TYPE_BUFFER: - /* * The operand must be a Buffer. We can convert an * Integer or String if necessary */ - Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc, WalkState); + Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc); break; diff --git a/sys/dev/acpi/acpica/Subsystem/excreate.c b/sys/dev/acpi/acpica/Subsystem/excreate.c index 5d398663c73..7604cdea4cf 100644 --- a/sys/dev/acpi/acpica/Subsystem/excreate.c +++ b/sys/dev/acpi/acpica/Subsystem/excreate.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: excreate - Named object creation - * xRevision: 101 $ + * xRevision: 106 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: excreate.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: excreate.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXCREATE_C__ @@ -133,7 +133,7 @@ __KERNEL_RCSID(0, "$NetBSD: excreate.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #ifndef ACPI_NO_METHOD_EXECUTION -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateAlias * @@ -143,7 +143,7 @@ __KERNEL_RCSID(0, "$NetBSD: excreate.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * * DESCRIPTION: Create a new named alias * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateAlias ( @@ -162,7 +162,8 @@ AcpiExCreateAlias ( AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; - if (TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) + if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) || + (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { /* * Dereference an existing alias so that we don't create a chain @@ -170,7 +171,7 @@ AcpiExCreateAlias ( * always exactly one level of indirection away from the * actual aliased name. */ - TargetNode = (ACPI_NAMESPACE_NODE *) TargetNode->Object; + TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object); } /* @@ -197,6 +198,17 @@ AcpiExCreateAlias ( AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); break; + case ACPI_TYPE_METHOD: + + /* + * The new alias has the type ALIAS and points to the original + * NS node, not the object itself. This is because for these + * types, the object can change dynamically via a Store. + */ + AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS; + AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); + break; + default: /* Attach the original source object to the new Alias Node */ @@ -208,8 +220,7 @@ AcpiExCreateAlias ( * target node or the alias Node */ Status = AcpiNsAttachObject (AliasNode, - AcpiNsGetAttachedObject (TargetNode), - TargetNode->Type); + AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); break; } @@ -219,7 +230,7 @@ AcpiExCreateAlias ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateEvent * @@ -229,7 +240,7 @@ AcpiExCreateAlias ( * * DESCRIPTION: Create a new event object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateEvent ( @@ -254,7 +265,7 @@ AcpiExCreateEvent ( * that the event is created in an unsignalled state */ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, - &ObjDesc->Event.Semaphore); + &ObjDesc->Event.Semaphore); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -263,7 +274,7 @@ AcpiExCreateEvent ( /* Attach object to the Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], - ObjDesc, ACPI_TYPE_EVENT); + ObjDesc, ACPI_TYPE_EVENT); Cleanup: /* @@ -275,7 +286,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateMutex * @@ -287,7 +298,7 @@ Cleanup: * * Mutex (Name[0], SyncLevel[1]) * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateMutex ( @@ -339,20 +350,20 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateRegion * * PARAMETERS: AmlStart - Pointer to the region declaration AML * AmlLength - Max length of the declaration AML - * Operands - List of operands for the opcode + * RegionSpace - SpaceID for the region * WalkState - Current state * * RETURN: Status * * DESCRIPTION: Create a new operation region object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateRegion ( @@ -395,7 +406,7 @@ AcpiExCreateRegion ( } ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", - AcpiUtGetRegionName (RegionSpace), RegionSpace)); + AcpiUtGetRegionName (RegionSpace), RegionSpace)); /* Create the region descriptor */ @@ -435,7 +446,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateTableRegion * @@ -445,7 +456,7 @@ Cleanup: * * DESCRIPTION: Create a new DataTableRegion object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateTableRegion ( @@ -537,7 +548,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateProcessor * @@ -549,7 +560,7 @@ Cleanup: * * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateProcessor ( @@ -571,9 +582,8 @@ AcpiExCreateProcessor ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * Initialize the processor object from the operands - */ + /* Initialize the processor object from the operands */ + ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; @@ -590,7 +600,7 @@ AcpiExCreateProcessor ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreatePowerResource * @@ -602,7 +612,7 @@ AcpiExCreateProcessor ( * * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreatePowerResource ( @@ -639,10 +649,10 @@ AcpiExCreatePowerResource ( AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } - #endif -/***************************************************************************** + +/******************************************************************************* * * FUNCTION: AcpiExCreateMethod * @@ -654,7 +664,7 @@ AcpiExCreatePowerResource ( * * DESCRIPTION: Create a new method object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateMethod ( @@ -684,29 +694,36 @@ AcpiExCreateMethod ( ObjDesc->Method.AmlStart = AmlStart; ObjDesc->Method.AmlLength = AmlLength; - /* disassemble the method flags */ - + /* + * Disassemble the method flags. Split off the Arg Count + * for efficiency + */ MethodFlags = (UINT8) Operand[1]->Integer.Value; - ObjDesc->Method.MethodFlags = MethodFlags; - ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & METHOD_FLAGS_ARG_COUNT); + ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT); + ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT); /* * Get the concurrency count. If required, a semaphore will be * created for this method when it is parsed. */ - if (MethodFlags & METHOD_FLAGS_SERIALIZED) + if (AcpiGbl_AllMethodsSerialized) + { + ObjDesc->Method.Concurrency = 1; + ObjDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED; + } + else if (MethodFlags & AML_METHOD_SERIALIZED) { /* * ACPI 1.0: Concurrency = 1 * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1) */ ObjDesc->Method.Concurrency = (UINT8) - (((MethodFlags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1); + (((MethodFlags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1); } else { - ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY; + ObjDesc->Method.Concurrency = ACPI_INFINITE_CONCURRENCY; } /* Attach the new object to the method Node */ diff --git a/sys/dev/acpi/acpica/Subsystem/exdump.c b/sys/dev/acpi/acpica/Subsystem/exdump.c index 94def5fd246..6a1786b75ff 100644 --- a/sys/dev/acpi/acpica/Subsystem/exdump.c +++ b/sys/dev/acpi/acpica/Subsystem/exdump.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exdump - Interpreter debug output routines - * xRevision: 172 $ + * xRevision: 182 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exdump.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exdump.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXDUMP_C__ @@ -128,33 +128,54 @@ __KERNEL_RCSID(0, "$NetBSD: exdump.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exdump") - /* * The following routines are used for debug output only */ - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) -/***************************************************************************** +/* Local prototypes */ + +static void +AcpiExOutString ( + char *Title, + char *Value); + +static void +AcpiExOutPointer ( + char *Title, + void *Value); + +static void +AcpiExOutInteger ( + char *Title, + UINT32 Value); + +static void +AcpiExOutAddress ( + char *Title, + ACPI_PHYSICAL_ADDRESS Value); + + +/******************************************************************************* * * FUNCTION: AcpiExDumpOperand * - * PARAMETERS: *ObjDesc - Pointer to entry to be dumped + * PARAMETERS: *ObjDesc - Pointer to entry to be dumped + * Depth - Current nesting depth * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Dump an operand object * - ****************************************************************************/ + ******************************************************************************/ void AcpiExDumpOperand ( - ACPI_OPERAND_OBJECT *ObjDesc) + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth) { - UINT8 *Buf = NULL; UINT32 Length; - ACPI_OPERAND_OBJECT **Element; - UINT16 ElementIndex; + UINT32 Index; ACPI_FUNCTION_NAME ("ExDumpOperand") @@ -167,10 +188,9 @@ AcpiExDumpOperand ( if (!ObjDesc) { - /* - * This usually indicates that something serious is wrong - */ - AcpiOsPrintf ("Null Object Descriptor\n"); + /* This could be a null element of a package */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); return; } @@ -184,15 +204,25 @@ AcpiExDumpOperand ( if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%p is not a node or operand object: [%s]\n", - ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); + "%p is not a node or operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)); return; } /* ObjDesc is a valid object */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc)); + if (Depth > 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ", + Depth, " ", Depth, ObjDesc)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc)); + } + + /* Decode object type */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -208,8 +238,8 @@ AcpiExDumpOperand ( case AML_NAME_OP: - ACPI_DUMP_PATHNAME (ObjDesc->Reference.Object, "Reference: Name: ", - ACPI_LV_INFO, _COMPONENT); + ACPI_DUMP_PATHNAME (ObjDesc->Reference.Object, + "Reference: Name: ", ACPI_LV_INFO, _COMPONENT); ACPI_DUMP_ENTRY (ObjDesc->Reference.Object, ACPI_LV_INFO); break; @@ -217,28 +247,28 @@ AcpiExDumpOperand ( case AML_INDEX_OP: AcpiOsPrintf ("Reference: Index %p\n", - ObjDesc->Reference.Object); + ObjDesc->Reference.Object); break; case AML_REF_OF_OP: AcpiOsPrintf ("Reference: (RefOf) %p\n", - ObjDesc->Reference.Object); + ObjDesc->Reference.Object); break; case AML_ARG_OP: AcpiOsPrintf ("Reference: Arg%d", - ObjDesc->Reference.Offset); + ObjDesc->Reference.Offset); if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { /* Value is an Integer */ AcpiOsPrintf (" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); } AcpiOsPrintf ("\n"); @@ -248,7 +278,7 @@ AcpiExDumpOperand ( case AML_LOCAL_OP: AcpiOsPrintf ("Reference: Local%d", - ObjDesc->Reference.Offset); + ObjDesc->Reference.Offset); if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { @@ -256,7 +286,7 @@ AcpiExDumpOperand ( /* Value is an Integer */ AcpiOsPrintf (" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); } AcpiOsPrintf ("\n"); @@ -266,7 +296,7 @@ AcpiExDumpOperand ( case AML_INT_NAMEPATH_OP: AcpiOsPrintf ("Reference.Node->Name %X\n", - ObjDesc->Reference.Node->Name.Integer); + ObjDesc->Reference.Node->Name.Integer); break; @@ -279,18 +309,15 @@ AcpiExDumpOperand ( break; } - break; case ACPI_TYPE_BUFFER: AcpiOsPrintf ("Buffer len %X @ %p \n", - ObjDesc->Buffer.Length, - ObjDesc->Buffer.Pointer); + ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer); Length = ObjDesc->Buffer.Length; - if (Length > 64) { Length = 64; @@ -302,44 +329,40 @@ AcpiExDumpOperand ( { AcpiOsPrintf ("Buffer Contents: "); - for (Buf = ObjDesc->Buffer.Pointer; Length--; ++Buf) + for (Index = 0; Index < Length; Index++) { - AcpiOsPrintf (" %02x", *Buf); + AcpiOsPrintf (" %02x", ObjDesc->Buffer.Pointer[Index]); } AcpiOsPrintf ("\n"); } - break; case ACPI_TYPE_INTEGER: AcpiOsPrintf ("Integer %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; case ACPI_TYPE_PACKAGE: - AcpiOsPrintf ("Package count %X @ %p\n", - ObjDesc->Package.Count, ObjDesc->Package.Elements); + AcpiOsPrintf ("Package [Len %X] ElementArray %p\n", + ObjDesc->Package.Count, ObjDesc->Package.Elements); /* - * If elements exist, package vector pointer is valid, + * If elements exist, package element pointer is valid, * and debug_level exceeds 1, dump package's elements. */ if (ObjDesc->Package.Count && ObjDesc->Package.Elements && AcpiDbgLevel > 1) { - for (ElementIndex = 0, Element = ObjDesc->Package.Elements; - ElementIndex < ObjDesc->Package.Count; - ++ElementIndex, ++Element) + for (Index = 0; Index < ObjDesc->Package.Count; Index++) { - AcpiExDumpOperand (*Element); + AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1); } } - AcpiOsPrintf ("\n"); break; @@ -369,7 +392,9 @@ AcpiExDumpOperand ( case ACPI_TYPE_STRING: AcpiOsPrintf ("String length %X @ %p ", - ObjDesc->String.Length, ObjDesc->String.Pointer); + ObjDesc->String.Length, + ObjDesc->String.Pointer); + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); AcpiOsPrintf ("\n"); break; @@ -385,11 +410,14 @@ AcpiExDumpOperand ( AcpiOsPrintf ( "RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", - ObjDesc->Field.BitLength, ObjDesc->Field.AccessByteWidth, + ObjDesc->Field.BitLength, + ObjDesc->Field.AccessByteWidth, ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK, - ObjDesc->Field.BaseByteOffset, ObjDesc->Field.StartFieldBitOffset); - ACPI_DUMP_STACK_ENTRY (ObjDesc->Field.RegionObj); + ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.StartFieldBitOffset); + + AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1); break; @@ -403,22 +431,23 @@ AcpiExDumpOperand ( AcpiOsPrintf ( "BufferField: %X bits at byte %X bit %X of \n", - ObjDesc->BufferField.BitLength, ObjDesc->BufferField.BaseByteOffset, + ObjDesc->BufferField.BitLength, + ObjDesc->BufferField.BaseByteOffset, ObjDesc->BufferField.StartFieldBitOffset); if (!ObjDesc->BufferField.BufferObj) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n")); } - else if (ACPI_GET_OBJECT_TYPE (ObjDesc->BufferField.BufferObj) != ACPI_TYPE_BUFFER) + else if (ACPI_GET_OBJECT_TYPE (ObjDesc->BufferField.BufferObj) != + ACPI_TYPE_BUFFER) { AcpiOsPrintf ("*not a Buffer* \n"); } else { - ACPI_DUMP_STACK_ENTRY (ObjDesc->BufferField.BufferObj); + AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1); } - break; @@ -430,10 +459,10 @@ AcpiExDumpOperand ( case ACPI_TYPE_METHOD: - AcpiOsPrintf ( - "Method(%X) @ %p:%X\n", + AcpiOsPrintf ("Method(%X) @ %p:%X\n", ObjDesc->Method.ParamCount, - ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength); + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength); break; @@ -478,18 +507,21 @@ AcpiExDumpOperand ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExDumpOperands * - * PARAMETERS: InterpreterMode - Load or Exec - * *Ident - Identification + * PARAMETERS: Operands - Operand list + * InterpreterMode - Load or Exec + * Ident - Identification * NumLevels - # of stack entries to dump above line - * *Note - Output notation + * Note - Output notation + * ModuleName - Caller's module name + * LineNumber - Caller's invocation line number * * DESCRIPTION: Dump the object stack * - ****************************************************************************/ + ******************************************************************************/ void AcpiExDumpOperands ( @@ -502,7 +534,6 @@ AcpiExDumpOperands ( UINT32 LineNumber) { ACPI_NATIVE_UINT i; - ACPI_OPERAND_OBJECT **ObjDesc; ACPI_FUNCTION_NAME ("ExDumpOperands"); @@ -531,8 +562,7 @@ AcpiExDumpOperands ( for (i = 0; NumLevels > 0; i--, NumLevels--) { - ObjDesc = &Operands[i]; - AcpiExDumpOperand (*ObjDesc); + AcpiExDumpOperand (Operands[i], 0); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, @@ -542,9 +572,9 @@ AcpiExDumpOperands ( } -/***************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiExOut* + * FUNCTION: AcpiExOut* functions * * PARAMETERS: Title - Descriptive text * Value - Value to be displayed @@ -553,9 +583,9 @@ AcpiExDumpOperands ( * reduce the number of format strings required and keeps them * all in one place for easy modification. * - ****************************************************************************/ + ******************************************************************************/ -void +static void AcpiExOutString ( char *Title, char *Value) @@ -563,7 +593,7 @@ AcpiExOutString ( AcpiOsPrintf ("%20s : %s\n", Title, Value); } -void +static void AcpiExOutPointer ( char *Title, void *Value) @@ -571,7 +601,7 @@ AcpiExOutPointer ( AcpiOsPrintf ("%20s : %p\n", Title, Value); } -void +static void AcpiExOutInteger ( char *Title, UINT32 Value) @@ -579,7 +609,7 @@ AcpiExOutInteger ( AcpiOsPrintf ("%20s : %X\n", Title, Value); } -void +static void AcpiExOutAddress ( char *Title, ACPI_PHYSICAL_ADDRESS Value) @@ -588,22 +618,21 @@ AcpiExOutAddress ( #if ACPI_MACHINE_WIDTH == 16 AcpiOsPrintf ("%20s : %p\n", Title, Value); #else - AcpiOsPrintf ("%20s : %8.8X%8.8X\n", Title, - ACPI_FORMAT_UINT64 (Value)); + AcpiOsPrintf ("%20s : %8.8X%8.8X\n", Title, ACPI_FORMAT_UINT64 (Value)); #endif } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExDumpNode * - * PARAMETERS: *Node - Descriptor to dump - * Flags - Force display + * PARAMETERS: *Node - Descriptor to dump + * Flags - Force display if TRUE * * DESCRIPTION: Dumps the members of the given.Node * - ****************************************************************************/ + ******************************************************************************/ void AcpiExDumpNode ( @@ -634,16 +663,16 @@ AcpiExDumpNode ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExDumpObjectDescriptor * * PARAMETERS: *Object - Descriptor to dump - * Flags - Force display + * Flags - Force display if TRUE * * DESCRIPTION: Dumps the members of the object descriptor given. * - ****************************************************************************/ + ******************************************************************************/ void AcpiExDumpObjectDescriptor ( @@ -656,6 +685,11 @@ AcpiExDumpObjectDescriptor ( ACPI_FUNCTION_TRACE ("ExDumpObjectDescriptor"); + if (!ObjDesc) + { + return_VOID; + } + if (!Flags) { if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) @@ -667,23 +701,26 @@ AcpiExDumpObjectDescriptor ( if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) { AcpiExDumpNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags); - AcpiOsPrintf ("\nAttached Object (%p):\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object); - AcpiExDumpObjectDescriptor (((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags); - return; + AcpiOsPrintf ("\nAttached Object (%p):\n", + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object); + AcpiExDumpObjectDescriptor ( + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags); + return_VOID; } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) { - AcpiOsPrintf ("ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n", - ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); + AcpiOsPrintf ( + "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); return_VOID; } /* Common Fields */ - AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); - AcpiExOutInteger ("Reference Count", ObjDesc->Common.ReferenceCount); - AcpiExOutInteger ("Flags", ObjDesc->Common.Flags); + AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); + AcpiExOutInteger ("Reference Count", ObjDesc->Common.ReferenceCount); + AcpiExOutInteger ("Flags", ObjDesc->Common.Flags); /* Object-specific Fields */ @@ -698,7 +735,7 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_STRING: - AcpiExOutInteger ("Length", ObjDesc->String.Length); + AcpiExOutInteger ("Length", ObjDesc->String.Length); AcpiOsPrintf ("%20s : %p ", "Pointer", ObjDesc->String.Pointer); AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); @@ -708,17 +745,17 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_BUFFER: - AcpiExOutInteger ("Length", ObjDesc->Buffer.Length); - AcpiExOutPointer ("Pointer", ObjDesc->Buffer.Pointer); + AcpiExOutInteger ("Length", ObjDesc->Buffer.Length); + AcpiExOutPointer ("Pointer", ObjDesc->Buffer.Pointer); ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); break; case ACPI_TYPE_PACKAGE: - AcpiExOutInteger ("Flags", ObjDesc->Package.Flags); - AcpiExOutInteger ("Count", ObjDesc->Package.Count); - AcpiExOutPointer ("Elements", ObjDesc->Package.Elements); + AcpiExOutInteger ("Flags", ObjDesc->Package.Flags); + AcpiExOutInteger ("Count", ObjDesc->Package.Count); + AcpiExOutPointer ("Elements", ObjDesc->Package.Elements); /* Dump the package contents */ @@ -730,7 +767,8 @@ AcpiExDumpObjectDescriptor ( AcpiOsPrintf ("[%.3d] %p", i, ObjDesc->Package.Elements[i]); if (ObjDesc->Package.Elements[i]) { - AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[i])); + AcpiOsPrintf (" %s", + AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[i])); } AcpiOsPrintf ("\n"); } @@ -748,66 +786,66 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_EVENT: - AcpiExOutPointer ("Semaphore", ObjDesc->Event.Semaphore); + AcpiExOutPointer ("Semaphore", ObjDesc->Event.Semaphore); break; case ACPI_TYPE_METHOD: - AcpiExOutInteger ("ParamCount", ObjDesc->Method.ParamCount); - AcpiExOutInteger ("Concurrency", ObjDesc->Method.Concurrency); - AcpiExOutPointer ("Semaphore", ObjDesc->Method.Semaphore); - AcpiExOutInteger ("OwningId", ObjDesc->Method.OwningId); - AcpiExOutInteger ("AmlLength", ObjDesc->Method.AmlLength); - AcpiExOutPointer ("AmlStart", ObjDesc->Method.AmlStart); + AcpiExOutInteger ("ParamCount", ObjDesc->Method.ParamCount); + AcpiExOutInteger ("Concurrency", ObjDesc->Method.Concurrency); + AcpiExOutPointer ("Semaphore", ObjDesc->Method.Semaphore); + AcpiExOutInteger ("OwningId", ObjDesc->Method.OwningId); + AcpiExOutInteger ("AmlLength", ObjDesc->Method.AmlLength); + AcpiExOutPointer ("AmlStart", ObjDesc->Method.AmlStart); break; case ACPI_TYPE_MUTEX: - AcpiExOutInteger ("SyncLevel", ObjDesc->Mutex.SyncLevel); - AcpiExOutPointer ("OwnerThread", ObjDesc->Mutex.OwnerThread); - AcpiExOutInteger ("AcquisitionDepth",ObjDesc->Mutex.AcquisitionDepth); - AcpiExOutPointer ("Semaphore", ObjDesc->Mutex.Semaphore); + AcpiExOutInteger ("SyncLevel", ObjDesc->Mutex.SyncLevel); + AcpiExOutPointer ("OwnerThread", ObjDesc->Mutex.OwnerThread); + AcpiExOutInteger ("AcquireDepth", ObjDesc->Mutex.AcquisitionDepth); + AcpiExOutPointer ("Semaphore", ObjDesc->Mutex.Semaphore); break; case ACPI_TYPE_REGION: - AcpiExOutInteger ("SpaceId", ObjDesc->Region.SpaceId); - AcpiExOutInteger ("Flags", ObjDesc->Region.Flags); - AcpiExOutAddress ("Address", ObjDesc->Region.Address); - AcpiExOutInteger ("Length", ObjDesc->Region.Length); - AcpiExOutPointer ("Handler", ObjDesc->Region.Handler); - AcpiExOutPointer ("Next", ObjDesc->Region.Next); + AcpiExOutInteger ("SpaceId", ObjDesc->Region.SpaceId); + AcpiExOutInteger ("Flags", ObjDesc->Region.Flags); + AcpiExOutAddress ("Address", ObjDesc->Region.Address); + AcpiExOutInteger ("Length", ObjDesc->Region.Length); + AcpiExOutPointer ("Handler", ObjDesc->Region.Handler); + AcpiExOutPointer ("Next", ObjDesc->Region.Next); break; case ACPI_TYPE_POWER: - AcpiExOutInteger ("SystemLevel", ObjDesc->PowerResource.SystemLevel); - AcpiExOutInteger ("ResourceOrder", ObjDesc->PowerResource.ResourceOrder); - AcpiExOutPointer ("SystemNotify", ObjDesc->PowerResource.SystemNotify); - AcpiExOutPointer ("DeviceNotify", ObjDesc->PowerResource.DeviceNotify); + AcpiExOutInteger ("SystemLevel", ObjDesc->PowerResource.SystemLevel); + AcpiExOutInteger ("ResourceOrder", ObjDesc->PowerResource.ResourceOrder); + AcpiExOutPointer ("SystemNotify", ObjDesc->PowerResource.SystemNotify); + AcpiExOutPointer ("DeviceNotify", ObjDesc->PowerResource.DeviceNotify); break; case ACPI_TYPE_PROCESSOR: - AcpiExOutInteger ("Processor ID", ObjDesc->Processor.ProcId); - AcpiExOutInteger ("Length", ObjDesc->Processor.Length); - AcpiExOutAddress ("Address", (ACPI_PHYSICAL_ADDRESS) ObjDesc->Processor.Address); - AcpiExOutPointer ("SystemNotify", ObjDesc->Processor.SystemNotify); - AcpiExOutPointer ("DeviceNotify", ObjDesc->Processor.DeviceNotify); - AcpiExOutPointer ("Handler", ObjDesc->Processor.Handler); + AcpiExOutInteger ("Processor ID", ObjDesc->Processor.ProcId); + AcpiExOutInteger ("Length", ObjDesc->Processor.Length); + AcpiExOutAddress ("Address", (ACPI_PHYSICAL_ADDRESS) ObjDesc->Processor.Address); + AcpiExOutPointer ("SystemNotify", ObjDesc->Processor.SystemNotify); + AcpiExOutPointer ("DeviceNotify", ObjDesc->Processor.DeviceNotify); + AcpiExOutPointer ("Handler", ObjDesc->Processor.Handler); break; case ACPI_TYPE_THERMAL: - AcpiExOutPointer ("SystemNotify", ObjDesc->ThermalZone.SystemNotify); - AcpiExOutPointer ("DeviceNotify", ObjDesc->ThermalZone.DeviceNotify); - AcpiExOutPointer ("Handler", ObjDesc->ThermalZone.Handler); + AcpiExOutPointer ("SystemNotify", ObjDesc->ThermalZone.SystemNotify); + AcpiExOutPointer ("DeviceNotify", ObjDesc->ThermalZone.DeviceNotify); + AcpiExOutPointer ("Handler", ObjDesc->ThermalZone.Handler); break; @@ -816,36 +854,33 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - AcpiExOutInteger ("FieldFlags", ObjDesc->CommonField.FieldFlags); - AcpiExOutInteger ("AccessByteWidth", ObjDesc->CommonField.AccessByteWidth); - AcpiExOutInteger ("BitLength", ObjDesc->CommonField.BitLength); - AcpiExOutInteger ("FldBitOffset", ObjDesc->CommonField.StartFieldBitOffset); - AcpiExOutInteger ("BaseByteOffset", ObjDesc->CommonField.BaseByteOffset); - AcpiExOutInteger ("DatumValidBits", ObjDesc->CommonField.DatumValidBits); - AcpiExOutInteger ("EndFldValidBits", ObjDesc->CommonField.EndFieldValidBits); - AcpiExOutInteger ("EndBufValidBits", ObjDesc->CommonField.EndBufferValidBits); - AcpiExOutPointer ("ParentNode", ObjDesc->CommonField.Node); + AcpiExOutInteger ("FieldFlags", ObjDesc->CommonField.FieldFlags); + AcpiExOutInteger ("AccessByteWidth",ObjDesc->CommonField.AccessByteWidth); + AcpiExOutInteger ("BitLength", ObjDesc->CommonField.BitLength); + AcpiExOutInteger ("FldBitOffset", ObjDesc->CommonField.StartFieldBitOffset); + AcpiExOutInteger ("BaseByteOffset", ObjDesc->CommonField.BaseByteOffset); + AcpiExOutPointer ("ParentNode", ObjDesc->CommonField.Node); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_BUFFER_FIELD: - AcpiExOutPointer ("BufferObj", ObjDesc->BufferField.BufferObj); + AcpiExOutPointer ("BufferObj", ObjDesc->BufferField.BufferObj); break; case ACPI_TYPE_LOCAL_REGION_FIELD: - AcpiExOutPointer ("RegionObj", ObjDesc->Field.RegionObj); + AcpiExOutPointer ("RegionObj", ObjDesc->Field.RegionObj); break; case ACPI_TYPE_LOCAL_BANK_FIELD: - AcpiExOutInteger ("Value", ObjDesc->BankField.Value); - AcpiExOutPointer ("RegionObj", ObjDesc->BankField.RegionObj); - AcpiExOutPointer ("BankObj", ObjDesc->BankField.BankObj); + AcpiExOutInteger ("Value", ObjDesc->BankField.Value); + AcpiExOutPointer ("RegionObj", ObjDesc->BankField.RegionObj); + AcpiExOutPointer ("BankObj", ObjDesc->BankField.BankObj); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: - AcpiExOutInteger ("Value", ObjDesc->IndexField.Value); - AcpiExOutPointer ("Index", ObjDesc->IndexField.IndexObj); - AcpiExOutPointer ("Data", ObjDesc->IndexField.DataObj); + AcpiExOutInteger ("Value", ObjDesc->IndexField.Value); + AcpiExOutPointer ("Index", ObjDesc->IndexField.IndexObj); + AcpiExOutPointer ("Data", ObjDesc->IndexField.DataObj); break; default: @@ -857,38 +892,47 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_LOCAL_REFERENCE: - AcpiExOutInteger ("TargetType", ObjDesc->Reference.TargetType); - AcpiExOutString ("Opcode", (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name); - AcpiExOutInteger ("Offset", ObjDesc->Reference.Offset); - AcpiExOutPointer ("ObjDesc", ObjDesc->Reference.Object); - AcpiExOutPointer ("Node", ObjDesc->Reference.Node); - AcpiExOutPointer ("Where", ObjDesc->Reference.Where); + AcpiExOutInteger ("TargetType", ObjDesc->Reference.TargetType); + AcpiExOutString ("Opcode", (AcpiPsGetOpcodeInfo ( + ObjDesc->Reference.Opcode))->Name); + AcpiExOutInteger ("Offset", ObjDesc->Reference.Offset); + AcpiExOutPointer ("ObjDesc", ObjDesc->Reference.Object); + AcpiExOutPointer ("Node", ObjDesc->Reference.Node); + AcpiExOutPointer ("Where", ObjDesc->Reference.Where); + + if (ObjDesc->Reference.Object) + { + AcpiOsPrintf ("\nReferenced Object:\n"); + AcpiExDumpObjectDescriptor (ObjDesc->Reference.Object, Flags); + } break; case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: - AcpiExOutInteger ("SpaceId", ObjDesc->AddressSpace.SpaceId); - AcpiExOutPointer ("Next", ObjDesc->AddressSpace.Next); - AcpiExOutPointer ("RegionList", ObjDesc->AddressSpace.RegionList); - AcpiExOutPointer ("Node", ObjDesc->AddressSpace.Node); - AcpiExOutPointer ("Context", ObjDesc->AddressSpace.Context); + AcpiExOutInteger ("SpaceId", ObjDesc->AddressSpace.SpaceId); + AcpiExOutPointer ("Next", ObjDesc->AddressSpace.Next); + AcpiExOutPointer ("RegionList", ObjDesc->AddressSpace.RegionList); + AcpiExOutPointer ("Node", ObjDesc->AddressSpace.Node); + AcpiExOutPointer ("Context", ObjDesc->AddressSpace.Context); break; case ACPI_TYPE_LOCAL_NOTIFY: - AcpiExOutPointer ("Node", ObjDesc->Notify.Node); - AcpiExOutPointer ("Context", ObjDesc->Notify.Context); + AcpiExOutPointer ("Node", ObjDesc->Notify.Node); + AcpiExOutPointer ("Context", ObjDesc->Notify.Context); break; case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_METHOD_ALIAS: case ACPI_TYPE_LOCAL_EXTRA: case ACPI_TYPE_LOCAL_DATA: default: - AcpiOsPrintf ("ExDumpObjectDescriptor: Display not implemented for object type %s\n", + AcpiOsPrintf ( + "ExDumpObjectDescriptor: Display not implemented for object type %s\n", AcpiUtGetObjectTypeName (ObjDesc)); break; } diff --git a/sys/dev/acpi/acpica/Subsystem/exfield.c b/sys/dev/acpi/acpica/Subsystem/exfield.c index a1f827011db..696c3d7eaf9 100644 --- a/sys/dev/acpi/acpica/Subsystem/exfield.c +++ b/sys/dev/acpi/acpica/Subsystem/exfield.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfield - ACPI AML (p-code) execution - field manipulation - * xRevision: 120 $ + * xRevision: 123 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exfield.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exfield.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXFIELD_C__ @@ -204,8 +204,8 @@ AcpiExReadDataFromField ( * Note: Smbus protocol value is passed in upper 16-bits of Function */ Status = AcpiExAccessRegion (ObjDesc, 0, - ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), - ACPI_READ | (ObjDesc->Field.Attribute << 16)); + ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), + ACPI_READ | (ObjDesc->Field.Attribute << 16)); AcpiExReleaseGlobalLock (Locked); goto Exit; } @@ -286,6 +286,7 @@ Exit: * * PARAMETERS: SourceDesc - Contains data to write * ObjDesc - The named field + * ResultDesc - Where the return value is returned, if any * * RETURN: Status * @@ -346,13 +347,16 @@ AcpiExWriteDataToField ( { ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n", AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } if (SourceDesc->Buffer.Length < ACPI_SMBUS_BUFFER_SIZE) { - ACPI_REPORT_ERROR (("SMBus write requires Buffer of length %X, found length %X\n", + ACPI_REPORT_ERROR (( + "SMBus write requires Buffer of length %X, found length %X\n", ACPI_SMBUS_BUFFER_SIZE, SourceDesc->Buffer.Length)); + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); } @@ -363,14 +367,16 @@ AcpiExWriteDataToField ( } Buffer = BufferDesc->Buffer.Pointer; - ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, ACPI_SMBUS_BUFFER_SIZE); + ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, + ACPI_SMBUS_BUFFER_SIZE); /* Lock entire transaction if requested */ Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); /* - * Perform the write (returns status and perhaps data in the same buffer) + * Perform the write (returns status and perhaps data in the + * same buffer) * Note: SMBus protocol type is passed in upper 16-bits of Function. */ Status = AcpiExAccessRegion (ObjDesc, 0, @@ -382,9 +388,8 @@ AcpiExWriteDataToField ( return_ACPI_STATUS (Status); } - /* - * Get a pointer to the data to be written - */ + /* Get a pointer to the data to be written */ + switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) { case ACPI_TYPE_INTEGER: @@ -413,7 +418,8 @@ AcpiExWriteDataToField ( * the ACPI specification. */ NewBuffer = NULL; - RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); + RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength); if (Length < RequiredLength) { @@ -439,6 +445,7 @@ AcpiExWriteDataToField ( "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n", SourceDesc, AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (SourceDesc)), ACPI_GET_OBJECT_TYPE (SourceDesc), Buffer, Length)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n", ObjDesc, AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc)), diff --git a/sys/dev/acpi/acpica/Subsystem/exfldio.c b/sys/dev/acpi/acpica/Subsystem/exfldio.c index f594b88d2f0..393a5664415 100644 --- a/sys/dev/acpi/acpica/Subsystem/exfldio.c +++ b/sys/dev/acpi/acpica/Subsystem/exfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfldio - Aml Field I/O - * xRevision: 103 $ + * xRevision: 116 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exfldio.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exfldio.c,v 1.12 2005/05/02 14:52:09 kochi Exp $"); #define __EXFLDIO_C__ @@ -130,12 +130,31 @@ __KERNEL_RCSID(0, "$NetBSD: exfldio.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exfldio") +/* Local prototypes */ + +static ACPI_STATUS +AcpiExFieldDatumIo ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); + +static BOOLEAN +AcpiExRegisterOverflow ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Value); + +static ACPI_STATUS +AcpiExSetupRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset); + /******************************************************************************* * * FUNCTION: AcpiExSetupRegion * - * PARAMETERS: *ObjDesc - Field to be read or written + * PARAMETERS: ObjDesc - Field to be read or written * FieldDatumByteOffset - Byte offset of this datum within the * parent field * @@ -147,7 +166,7 @@ __KERNEL_RCSID(0, "$NetBSD: exfldio.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExSetupRegion ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset) @@ -211,10 +230,27 @@ AcpiExSetupRegion ( * length of one field datum (access width) must fit within the region. * (Region length is specified in bytes) */ - if (RgnDesc->Region.Length < (ObjDesc->CommonField.BaseByteOffset - + FieldDatumByteOffset - + ObjDesc->CommonField.AccessByteWidth)) + if (RgnDesc->Region.Length < (ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset + + ObjDesc->CommonField.AccessByteWidth)) { + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Slack mode only: We will go ahead and allow access to this + * field if it is within the region length rounded up to the next + * access width boundary. + */ + if (ACPI_ROUND_UP (RgnDesc->Region.Length, + ObjDesc->CommonField.AccessByteWidth) >= + (ObjDesc->CommonField.BaseByteOffset + + (ACPI_NATIVE_UINT) ObjDesc->CommonField.AccessByteWidth + + FieldDatumByteOffset)) + { + return_ACPI_STATUS (AE_OK); + } + } + if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth) { /* @@ -226,7 +262,8 @@ AcpiExSetupRegion ( "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", AcpiUtGetNodeName (ObjDesc->CommonField.Node), ObjDesc->CommonField.AccessByteWidth, - AcpiUtGetNodeName (RgnDesc->Region.Node), RgnDesc->Region.Length)); + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); } /* @@ -238,27 +275,9 @@ AcpiExSetupRegion ( AcpiUtGetNodeName (ObjDesc->CommonField.Node), ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, - AcpiUtGetNodeName (RgnDesc->Region.Node), RgnDesc->Region.Length)); + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); -#ifndef ACPICA_PEDANTIC - { - /* - * Allow access to the field if it is within the region size - * rounded up to a multiple of the access byte width. This - * overcomes "off-by-one" programming errors in the AML often - * found in Toshiba laptops. These errors were allowed by - * the Microsoft ASL compiler. - */ - UINT32 rounded_length = ACPI_ROUND_UP(RgnDesc->Region.Length, - ObjDesc->CommonField.AccessByteWidth); - - if (rounded_length >= (ObjDesc->CommonField.BaseByteOffset + - FieldDatumByteOffset + - ObjDesc->CommonField.AccessByteWidth)) { - return_ACPI_STATUS (AE_OK); - } - } -#endif return_ACPI_STATUS (AE_AML_REGION_LIMIT); } @@ -270,10 +289,10 @@ AcpiExSetupRegion ( * * FUNCTION: AcpiExAccessRegion * - * PARAMETERS: *ObjDesc - Field to be read + * PARAMETERS: ObjDesc - Field to be read * FieldDatumByteOffset - Byte offset of this datum within the * parent field - * *Value - Where to store value (must at least + * Value - Where to store value (must at least * the size of ACPI_INTEGER) * Function - Read or Write flag plus other region- * dependent flags @@ -317,9 +336,9 @@ AcpiExAccessRegion ( * 3) The current offset into the field */ RgnDesc = ObjDesc->CommonField.RegionObj; - Address = RgnDesc->Region.Address - + ObjDesc->CommonField.BaseByteOffset - + FieldDatumByteOffset; + Address = RgnDesc->Region.Address + + ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset; if ((Function & ACPI_IO_MASK) == ACPI_READ) { @@ -342,7 +361,8 @@ AcpiExAccessRegion ( /* Invoke the appropriate AddressSpace/OpRegion handler */ Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function, - Address, ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); + Address, + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); if (ACPI_FAILURE (Status)) { @@ -355,7 +375,7 @@ AcpiExAccessRegion ( } else if (Status == AE_NOT_EXIST) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + ACPI_REPORT_ERROR (( "Region %s(%X) has no handler\n", AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId)); @@ -370,7 +390,7 @@ AcpiExAccessRegion ( * * FUNCTION: AcpiExRegisterOverflow * - * PARAMETERS: *ObjDesc - Register(Field) to be written + * PARAMETERS: ObjDesc - Register(Field) to be written * Value - Value to be stored * * RETURN: TRUE if value overflows the field, FALSE otherwise @@ -383,7 +403,7 @@ AcpiExAccessRegion ( * ******************************************************************************/ -BOOLEAN +static BOOLEAN AcpiExRegisterOverflow ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_INTEGER Value) @@ -417,10 +437,10 @@ AcpiExRegisterOverflow ( * * FUNCTION: AcpiExFieldDatumIo * - * PARAMETERS: *ObjDesc - Field to be read + * PARAMETERS: ObjDesc - Field to be read * FieldDatumByteOffset - Byte offset of this datum within the * parent field - * *Value - Where to store value (must be 64 bits) + * Value - Where to store value (must be 64 bits) * ReadWrite - Read or Write flag * * RETURN: Status @@ -431,7 +451,7 @@ AcpiExRegisterOverflow ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExFieldDatumIo ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, @@ -450,7 +470,9 @@ AcpiExFieldDatumIo ( if (!Value) { LocalValue = 0; - Value = &LocalValue; /* To support reads without saving return value */ + + /* To support reads without saving return value */ + Value = &LocalValue; } /* Clear the entire return buffer first, [Very Important!] */ @@ -463,8 +485,10 @@ AcpiExFieldDatumIo ( * * BufferField - Read/write from/to a Buffer * RegionField - Read/write from/to a Operation Region. - * BankField - Write to a Bank Register, then read/write from/to an OpRegion - * IndexField - Write to an Index Register, then read/write from/to a Data Register + * BankField - Write to a Bank Register, then read/write from/to an + * OperationRegion + * IndexField - Write to an Index Register, then read/write from/to a + * Data Register */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -488,10 +512,11 @@ AcpiExFieldDatumIo ( * Copy the data from the source buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY (Value, (ObjDesc->BufferField.BufferObj)->Buffer.Pointer - + ObjDesc->BufferField.BaseByteOffset - + FieldDatumByteOffset, - ObjDesc->CommonField.AccessByteWidth); + ACPI_MEMCPY (Value, + (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, + ObjDesc->CommonField.AccessByteWidth); } else { @@ -499,9 +524,9 @@ AcpiExFieldDatumIo ( * Copy the data to the target buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer - + ObjDesc->BufferField.BaseByteOffset - + FieldDatumByteOffset, + ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, Value, ObjDesc->CommonField.AccessByteWidth); } @@ -511,8 +536,10 @@ AcpiExFieldDatumIo ( case ACPI_TYPE_LOCAL_BANK_FIELD: - /* Ensure that the BankValue is not beyond the capacity of the register */ - + /* + * Ensure that the BankValue is not beyond the capacity of + * the register + */ if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj, (ACPI_INTEGER) ObjDesc->BankField.Value)) { @@ -552,8 +579,10 @@ AcpiExFieldDatumIo ( case ACPI_TYPE_LOCAL_INDEX_FIELD: - /* Ensure that the IndexValue is not beyond the capacity of the register */ - + /* + * Ensure that the IndexValue is not beyond the capacity of + * the register + */ if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj, (ACPI_INTEGER) ObjDesc->IndexField.Value)) { @@ -609,15 +638,17 @@ AcpiExFieldDatumIo ( { if (ReadWrite == ACPI_READ) { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read %8.8X%8.8X, Width %d\n", - ACPI_FORMAT_UINT64 (*Value), - ObjDesc->CommonField.AccessByteWidth)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Read %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); } else { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written %8.8X%8.8X, Width %d\n", - ACPI_FORMAT_UINT64 (*Value), - ObjDesc->CommonField.AccessByteWidth)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Written %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); } } @@ -629,8 +660,10 @@ AcpiExFieldDatumIo ( * * FUNCTION: AcpiExWriteWithUpdateRule * - * PARAMETERS: *ObjDesc - Field to be set - * Value - Value to store + * PARAMETERS: ObjDesc - Field to be written + * Mask - bitmask within field datum + * FieldValue - Value to write + * FieldDatumByteOffset - Offset of datum within field * * RETURN: Status * @@ -730,152 +763,15 @@ AcpiExWriteWithUpdateRule ( /******************************************************************************* * - * FUNCTION: AcpiExGetBufferDatum - * - * PARAMETERS: Datum - Where the Datum is returned - * Buffer - Raw field buffer - * BufferLength - Entire length (used for big-endian only) - * ByteGranularity - 1/2/4/8 Granularity of the field - * (aka Datum Size) - * BufferOffset - Datum offset into the buffer - * - * RETURN: none - * - * DESCRIPTION: Get a datum from the buffer according to the buffer field - * byte granularity - * - ******************************************************************************/ - -void -AcpiExGetBufferDatum ( - ACPI_INTEGER *Datum, - void *Buffer, - UINT32 BufferLength, - UINT32 ByteGranularity, - UINT32 BufferOffset) -{ - UINT32 Index; - - - ACPI_FUNCTION_TRACE_U32 ("ExGetBufferDatum", ByteGranularity); - - - /* Get proper index into buffer (handles big/little endian) */ - - Index = ACPI_BUFFER_INDEX (BufferLength, BufferOffset, ByteGranularity); - - /* Move the requested number of bytes */ - - switch (ByteGranularity) - { - case ACPI_FIELD_BYTE_GRANULARITY: - - *Datum = ((UINT8 *) Buffer) [Index]; - break; - - case ACPI_FIELD_WORD_GRANULARITY: - - ACPI_MOVE_16_TO_64 (Datum, &(((UINT16 *) Buffer) [Index])); - break; - - case ACPI_FIELD_DWORD_GRANULARITY: - - ACPI_MOVE_32_TO_64 (Datum, &(((UINT32 *) Buffer) [Index])); - break; - - case ACPI_FIELD_QWORD_GRANULARITY: - - ACPI_MOVE_64_TO_64 (Datum, &(((UINT64 *) Buffer) [Index])); - break; - - default: - /* Should not get here */ - break; - } - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSetBufferDatum - * - * PARAMETERS: MergedDatum - Value to store - * Buffer - Receiving buffer - * BufferLength - Entire length (used for big-endian only) - * ByteGranularity - 1/2/4/8 Granularity of the field - * (aka Datum Size) - * BufferOffset - Datum offset into the buffer - * - * RETURN: none - * - * DESCRIPTION: Store the merged datum to the buffer according to the - * byte granularity - * - ******************************************************************************/ - -void -AcpiExSetBufferDatum ( - ACPI_INTEGER MergedDatum, - void *Buffer, - UINT32 BufferLength, - UINT32 ByteGranularity, - UINT32 BufferOffset) -{ - UINT32 Index; - - - ACPI_FUNCTION_TRACE_U32 ("ExSetBufferDatum", ByteGranularity); - - - /* Get proper index into buffer (handles big/little endian) */ - - Index = ACPI_BUFFER_INDEX (BufferLength, BufferOffset, ByteGranularity); - - /* Move the requested number of bytes */ - - switch (ByteGranularity) - { - case ACPI_FIELD_BYTE_GRANULARITY: - - ((UINT8 *) Buffer) [Index] = (UINT8) MergedDatum; - break; - - case ACPI_FIELD_WORD_GRANULARITY: - - ACPI_MOVE_64_TO_16 (&(((UINT16 *) Buffer)[Index]), &MergedDatum); - break; - - case ACPI_FIELD_DWORD_GRANULARITY: - - ACPI_MOVE_64_TO_32 (&(((UINT32 *) Buffer)[Index]), &MergedDatum); - break; - - case ACPI_FIELD_QWORD_GRANULARITY: - - ACPI_MOVE_64_TO_64 (&(((UINT64 *) Buffer)[Index]), &MergedDatum); - break; - - default: - /* Should not get here */ - break; - } - - return_VOID; -} - - -/******************************************************************************* - * * FUNCTION: AcpiExExtractFromField * - * PARAMETERS: *ObjDesc - Field to be read - * *Value - Where to store value + * PARAMETERS: ObjDesc - Field to be read + * Buffer - Where to store the field data + * BufferLength - Length of Buffer * * RETURN: Status * - * DESCRIPTION: Retrieve the value of the given field + * DESCRIPTION: Retrieve the current value of the given field * ******************************************************************************/ @@ -886,167 +782,101 @@ AcpiExExtractFromField ( UINT32 BufferLength) { ACPI_STATUS Status; - UINT32 FieldDatumByteOffset; - UINT32 BufferDatumOffset; - ACPI_INTEGER PreviousRawDatum = 0; - ACPI_INTEGER ThisRawDatum = 0; - ACPI_INTEGER MergedDatum = 0; - UINT32 ByteFieldLength; + ACPI_INTEGER RawDatum; + ACPI_INTEGER MergedDatum; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; UINT32 DatumCount; + UINT32 FieldDatumCount; UINT32 i; ACPI_FUNCTION_TRACE ("ExExtractFromField"); - /* - * The field must fit within the caller's buffer - */ - ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); - if (ByteFieldLength > BufferLength) + /* Validate target buffer and clear it */ + + if (BufferLength < ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength)) { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Field size %X (bytes) too large for buffer (%X)\n", - ByteFieldLength, BufferLength)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Field size %X (bits) is too large for buffer (%X)\n", + ObjDesc->CommonField.BitLength, BufferLength)); return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } + ACPI_MEMSET (Buffer, 0, BufferLength); - /* Convert field byte count to datum count, round up if necessary */ + /* Compute the number of datums (access width data items) */ - DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength, - ObjDesc->CommonField.AccessByteWidth); + DatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + FieldDatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); - /* - * If the field is not aligned on a datum boundary and does not - * fit within a single datum, we must read an extra datum. - * - * We could just split the aligned and non-aligned cases since the - * aligned case is so very simple, but this would require more code. - */ - if ((ObjDesc->CommonField.EndFieldValidBits != 0) && - (!(ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM))) + /* Priming read from the field */ + + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ); + if (ACPI_FAILURE (Status)) { - DatumCount++; + return_ACPI_STATUS (Status); } + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "ByteLen %X, DatumLen %X, ByteGran %X\n", - ByteFieldLength, DatumCount,ObjDesc->CommonField.AccessByteWidth)); - - /* - * Clear the caller's buffer (the whole buffer length as given) - * This is very important, especially in the cases where the buffer - * is longer than the size of the field. - */ - ACPI_MEMSET (Buffer, 0, BufferLength); - - FieldDatumByteOffset = 0; - BufferDatumOffset= 0; + /* Read the rest of the field */ - /* Read the entire field */ - - for (i = 0; i < DatumCount; i++) + for (i = 1; i < FieldDatumCount; i++) { - Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, - &ThisRawDatum, ACPI_READ); + /* Get next input datum from the field */ + + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, + &RawDatum, ACPI_READ); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* We might actually be done if the request fits in one datum */ - - if ((DatumCount == 1) && - (ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM)) - { - /* 1) Shift the valid data bits down to start at bit 0 */ - - MergedDatum = (ThisRawDatum >> ObjDesc->CommonField.StartFieldBitOffset); - - /* 2) Mask off any upper unused bits (bits not part of the field) */ + /* Merge with previous datum if necessary */ - if (ObjDesc->CommonField.EndBufferValidBits) - { - MergedDatum &= ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits); - } + MergedDatum |= RawDatum << + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); - /* Store the datum to the caller buffer */ - - AcpiExSetBufferDatum (MergedDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, BufferDatumOffset); - - return_ACPI_STATUS (AE_OK); - } - - /* Special handling for the last datum to ignore extra bits */ - - if ((i >= (DatumCount -1)) && - (ObjDesc->CommonField.EndFieldValidBits)) + if (i == DatumCount) { - /* - * This is the last iteration of the loop. We need to clear - * any unused bits (bits that are not part of this field) before - * we store the final merged datum into the caller buffer. - */ - ThisRawDatum &= - ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); - } - - /* - * Create the (possibly) merged datum to be stored to the caller buffer - */ - if (ObjDesc->CommonField.StartFieldBitOffset == 0) - { - /* Field is not skewed and we can just copy the datum */ - - AcpiExSetBufferDatum (ThisRawDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, BufferDatumOffset); - BufferDatumOffset++; + break; } - else - { - /* Not aligned -- on the first iteration, just save the datum */ - - if (i != 0) - { - /* - * Put together the appropriate bits of the two raw data to make a - * single complete field datum - * - * 1) Normalize the first datum down to bit 0 - */ - MergedDatum = (PreviousRawDatum >> ObjDesc->CommonField.StartFieldBitOffset); - - /* 2) Insert the second datum "above" the first datum */ - MergedDatum |= (ThisRawDatum << ObjDesc->CommonField.DatumValidBits); - - AcpiExSetBufferDatum (MergedDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, BufferDatumOffset); - BufferDatumOffset++; - } + /* Write merged datum to target buffer */ - /* - * Save the raw datum that was just acquired since it may contain bits - * of the *next* field datum - */ - PreviousRawDatum = ThisRawDatum; - } + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); - FieldDatumByteOffset += ObjDesc->CommonField.AccessByteWidth; + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; } - /* For non-aligned case, there is one last datum to insert */ + /* Mask off any extra bits in the last datum */ - if (ObjDesc->CommonField.StartFieldBitOffset != 0) + BufferTailBits = ObjDesc->CommonField.BitLength % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) { - MergedDatum = (ThisRawDatum >> ObjDesc->CommonField.StartFieldBitOffset); - - AcpiExSetBufferDatum (MergedDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, BufferDatumOffset); + MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits); } + /* Write the last datum to the buffer */ + + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + return_ACPI_STATUS (AE_OK); } @@ -1055,12 +885,13 @@ AcpiExExtractFromField ( * * FUNCTION: AcpiExInsertIntoField * - * PARAMETERS: *ObjDesc - Field to be set - * Buffer - Value to store + * PARAMETERS: ObjDesc - Field to be written + * Buffer - Data to be written + * BufferLength - Length of Buffer * * RETURN: Status * - * DESCRIPTION: Store the value into the given field + * DESCRIPTION: Store the Buffer contents into the given field * ******************************************************************************/ @@ -1071,203 +902,100 @@ AcpiExInsertIntoField ( UINT32 BufferLength) { ACPI_STATUS Status; - UINT32 FieldDatumByteOffset; - UINT32 DatumOffset; ACPI_INTEGER Mask; ACPI_INTEGER MergedDatum; - ACPI_INTEGER PreviousRawDatum; - ACPI_INTEGER ThisRawDatum; - UINT32 ByteFieldLength; + ACPI_INTEGER RawDatum = 0; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; UINT32 DatumCount; + UINT32 FieldDatumCount; + UINT32 i; ACPI_FUNCTION_TRACE ("ExInsertIntoField"); - /* - * Incoming buffer must be at least as long as the field, we do not - * allow "partial" field writes. We do not care if the buffer is - * larger than the field, this typically happens when an integer is - * written to a field that is actually smaller than an integer. - */ - ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.BitLength); - if (BufferLength < ByteFieldLength) + /* Validate input buffer */ + + if (BufferLength < ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength)) { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Buffer length %X too small for field %X\n", - BufferLength, ByteFieldLength)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Field size %X (bits) is too large for buffer (%X)\n", + ObjDesc->CommonField.BitLength, BufferLength)); return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } - ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.StartFieldBitOffset + - ObjDesc->CommonField.BitLength); - - /* Convert byte count to datum count, round up if necessary */ - - DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength, - ObjDesc->CommonField.AccessByteWidth); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Bytes %X, Datums %X, ByteGran %X\n", - ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessByteWidth)); + /* Compute the number of datums (access width data items) */ - /* - * Break the request into up to three parts (similar to an I/O request): - * 1) non-aligned part at start - * 2) aligned part in middle - * 3) non-aligned part at the end - */ - FieldDatumByteOffset = 0; - DatumOffset= 0; - - /* Get a single datum from the caller's buffer */ - - AcpiExGetBufferDatum (&PreviousRawDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, DatumOffset); - - /* - * Part1: - * Write a partial field datum if field does not begin on a datum boundary - * Note: The code in this section also handles the aligned case - * - * Construct Mask with 1 bits where the field is, 0 bits elsewhere - * (Only the bottom 5 bits of BitLength are valid for a shift operation) - * - * Mask off bits that are "below" the field (if any) - */ Mask = ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); + DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); - /* If the field fits in one datum, may need to mask upper bits */ - - if ((ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM) && - ObjDesc->CommonField.EndFieldValidBits) - { - /* There are bits above the field, mask them off also */ - - Mask &= ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); - } + /* Get initial Datum from the input buffer */ - /* Shift and mask the value into the field position */ + ACPI_MEMCPY (&RawDatum, Buffer, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); - MergedDatum = (PreviousRawDatum << ObjDesc->CommonField.StartFieldBitOffset); - MergedDatum &= Mask; + MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset; - /* Apply the update rule (if necessary) and write the datum to the field */ + /* Write the entire field */ - Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum, - FieldDatumByteOffset); - if (ACPI_FAILURE (Status)) + for (i = 1; i < FieldDatumCount; i++) { - return_ACPI_STATUS (Status); - } - - /* We just wrote the first datum */ - - DatumOffset++; + /* Write merged datum to the target field */ - /* If the entire field fits within one datum, we are done. */ - - if ((DatumCount == 1) && - (ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM)) - { - return_ACPI_STATUS (AE_OK); - } - - /* - * Part2: - * Write the aligned data. - * - * We don't need to worry about the update rule for these data, because - * all of the bits in each datum are part of the field. - * - * The last datum must be special cased because it might contain bits - * that are not part of the field -- therefore the "update rule" must be - * applied in Part3 below. - */ - while (DatumOffset < DatumCount) - { - FieldDatumByteOffset += ObjDesc->CommonField.AccessByteWidth; + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, + MergedDatum, FieldOffset); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - /* - * Get the next raw buffer datum. It may contain bits of the previous - * field datum - */ - AcpiExGetBufferDatum (&ThisRawDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, DatumOffset); + /* Start new output datum by merging with previous input datum */ - /* Create the field datum based on the field alignment */ + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + MergedDatum = RawDatum >> + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + Mask = ACPI_INTEGER_MAX; - if (ObjDesc->CommonField.StartFieldBitOffset != 0) + if (i == DatumCount) { - /* - * Put together appropriate bits of the two raw buffer data to make - * a single complete field datum - */ - MergedDatum = - (PreviousRawDatum >> ObjDesc->CommonField.DatumValidBits) | - (ThisRawDatum << ObjDesc->CommonField.StartFieldBitOffset); - } - else - { - /* Field began aligned on datum boundary */ - - MergedDatum = ThisRawDatum; + break; } - /* - * Special handling for the last datum if the field does NOT end on - * a datum boundary. Update Rule must be applied to the bits outside - * the field. - */ - DatumOffset++; - if ((DatumOffset == DatumCount) && - (ObjDesc->CommonField.EndFieldValidBits)) - { - /* - * If there are dangling non-aligned bits, perform one more merged write - * Else - field is aligned at the end, no need for any more writes - */ + /* Get the next input datum from the buffer */ - /* - * Part3: - * This is the last datum and the field does not end on a datum boundary. - * Build the partial datum and write with the update rule. - * - * Mask off the unused bits above (after) the end-of-field - */ - Mask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); - MergedDatum &= Mask; + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset; + } - /* Write the last datum with the update rule */ + /* Mask off any extra bits in the last datum */ - Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum, - FieldDatumByteOffset); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - else - { - /* Normal (aligned) case -- write the completed datum */ + BufferTailBits = (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset) % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) + { + Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits); + } - Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, - &MergedDatum, ACPI_WRITE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } + /* Write the last datum to the field */ - /* - * Save the most recent datum since it may contain bits of the *next* - * field datum. Update current byte offset. - */ - PreviousRawDatum = ThisRawDatum; - } + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, + Mask, MergedDatum, FieldOffset); return_ACPI_STATUS (Status); } diff --git a/sys/dev/acpi/acpica/Subsystem/exmisc.c b/sys/dev/acpi/acpica/Subsystem/exmisc.c index 09c82926cc2..e8201471b7a 100644 --- a/sys/dev/acpi/acpica/Subsystem/exmisc.c +++ b/sys/dev/acpi/acpica/Subsystem/exmisc.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes - * xRevision: 118 $ + * xRevision: 130 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exmisc.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exmisc.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXMISC_C__ @@ -176,6 +176,7 @@ AcpiExGetObjectReference ( { case AML_LOCAL_OP: case AML_ARG_OP: + case AML_DEBUG_OP: /* The referenced object is the pseudo-node for the local/arg */ @@ -184,7 +185,7 @@ AcpiExGetObjectReference ( default: - ACPI_REPORT_ERROR (("Unknown Reference subtype in get ref %X\n", + ACPI_REPORT_ERROR (("Unknown Reference opcode in GetReference %X\n", ObjDesc->Reference.Opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -202,7 +203,7 @@ AcpiExGetObjectReference ( default: - ACPI_REPORT_ERROR (("Invalid descriptor type in get ref: %X\n", + ACPI_REPORT_ERROR (("Invalid descriptor type in GetReference: %X\n", ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))); return_ACPI_STATUS (AE_TYPE); } @@ -220,8 +221,9 @@ AcpiExGetObjectReference ( ReferenceObj->Reference.Object = ReferencedObj; *ReturnDesc = ReferenceObj; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p Type [%s], returning Reference %p\n", - ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p Type [%s], returning Reference %p\n", + ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc)); return_ACPI_STATUS (AE_OK); } @@ -231,8 +233,9 @@ AcpiExGetObjectReference ( * * FUNCTION: AcpiExConcatTemplate * - * PARAMETERS: *ObjDesc - Object to be converted. Must be an - * Integer, Buffer, or String + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object * WalkState - Current walk state * * RETURN: Status @@ -243,8 +246,8 @@ AcpiExGetObjectReference ( ACPI_STATUS AcpiExConcatTemplate ( - ACPI_OPERAND_OBJECT *ObjDesc1, - ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState) { @@ -261,8 +264,8 @@ AcpiExConcatTemplate ( /* Find the EndTags in each resource template */ - EndTag1 = AcpiUtGetResourceEndTag (ObjDesc1); - EndTag2 = AcpiUtGetResourceEndTag (ObjDesc2); + EndTag1 = AcpiUtGetResourceEndTag (Operand0); + EndTag2 = AcpiUtGetResourceEndTag (Operand1); if (!EndTag1 || !EndTag2) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -270,8 +273,8 @@ AcpiExConcatTemplate ( /* Compute the length of each part */ - Length1 = ACPI_PTR_DIFF (EndTag1, ObjDesc1->Buffer.Pointer); - Length2 = ACPI_PTR_DIFF (EndTag2, ObjDesc2->Buffer.Pointer) + + Length1 = ACPI_PTR_DIFF (EndTag1, Operand0->Buffer.Pointer); + Length2 = ACPI_PTR_DIFF (EndTag2, Operand1->Buffer.Pointer) + 2; /* Size of END_TAG */ /* Create a new buffer object for the result */ @@ -285,8 +288,8 @@ AcpiExConcatTemplate ( /* Copy the templates to the new descriptor */ NewBuf = ReturnDesc->Buffer.Pointer; - ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, Length1); - ACPI_MEMCPY (NewBuf + Length1, ObjDesc2->Buffer.Pointer, Length2); + ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length1); + ACPI_MEMCPY (NewBuf + Length1, Operand1->Buffer.Pointer, Length2); /* Compute the new checksum */ @@ -305,8 +308,8 @@ AcpiExConcatTemplate ( * * FUNCTION: AcpiExDoConcatenate * - * PARAMETERS: ObjDesc1 - First source object - * ObjDesc2 - Second source object + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object * ActualReturnDesc - Where to place the return object * WalkState - Current walk state * @@ -318,20 +321,59 @@ AcpiExConcatTemplate ( ACPI_STATUS AcpiExDoConcatenate ( - ACPI_OPERAND_OBJECT *ObjDesc1, - ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status; - UINT32 i; - ACPI_INTEGER ThisInteger; + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; ACPI_OPERAND_OBJECT *ReturnDesc; char *NewBuf; + ACPI_STATUS Status; + ACPI_SIZE NewLength; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_TRACE ("ExDoConcatenate"); + + + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (ACPI_GET_OBJECT_TYPE (Operand0)) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); + break; + + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; + + default: + ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", + ACPI_GET_OBJECT_TYPE (Operand0))); + Status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + /* + * Both operands are now known to be the same object type + * (Both are Integer, String, or Buffer), and we can now perform the + * concatenation. + */ /* * There are three cases to handle: @@ -340,120 +382,108 @@ AcpiExDoConcatenate ( * 2) Two Strings concatenated to produce a new String * 3) Two Buffers concatenated to produce a new Buffer */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc1)) + switch (ACPI_GET_OBJECT_TYPE (Operand0)) { case ACPI_TYPE_INTEGER: /* Result of two Integers is a Buffer */ /* Need enough buffer space for two integers */ - ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth * 2); + ReturnDesc = AcpiUtCreateBufferObject ( + ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); if (!ReturnDesc) { - return (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup; } NewBuf = (char *) ReturnDesc->Buffer.Pointer; - /* Convert the first integer */ + /* Copy the first integer, LSB first */ - ThisInteger = ObjDesc1->Integer.Value; - for (i = 0; i < AcpiGbl_IntegerByteWidth; i++) - { - NewBuf[i] = (char) ThisInteger; - ThisInteger >>= 8; - } + ACPI_MEMCPY (NewBuf, + &Operand0->Integer.Value, + AcpiGbl_IntegerByteWidth); - /* Convert the second integer */ - - ThisInteger = ObjDesc2->Integer.Value; - for (; i < (ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); i++) - { - NewBuf[i] = (char) ThisInteger; - ThisInteger >>= 8; - } + /* Copy the second integer (LSB first) after the first */ + ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth, + &LocalOperand1->Integer.Value, + AcpiGbl_IntegerByteWidth); break; - case ACPI_TYPE_STRING: /* Result of two Strings is a String */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); - if (!ReturnDesc) + NewLength = (ACPI_SIZE) Operand0->String.Length + + (ACPI_SIZE) LocalOperand1->String.Length; + if (NewLength > ACPI_MAX_STRING_CONVERSION) { - return (AE_NO_MEMORY); + Status = AE_AML_STRING_LIMIT; + goto Cleanup; } - /* Operand0 is string */ - - NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) ObjDesc1->String.Length + - (ACPI_SIZE) ObjDesc2->String.Length + 1); - if (!NewBuf) + ReturnDesc = AcpiUtCreateStringObject (NewLength); + if (!ReturnDesc) { - ACPI_REPORT_ERROR - (("ExDoConcatenate: String allocation failure\n")); Status = AE_NO_MEMORY; goto Cleanup; } - /* Concatenate the strings */ - - ACPI_STRCPY (NewBuf, ObjDesc1->String.Pointer); - ACPI_STRCPY (NewBuf + ObjDesc1->String.Length, - ObjDesc2->String.Pointer); + NewBuf = ReturnDesc->String.Pointer; - /* Complete the String object initialization */ + /* Concatenate the strings */ - ReturnDesc->String.Pointer = NewBuf; - ReturnDesc->String.Length = ObjDesc1->String.Length + - ObjDesc2->String.Length; + ACPI_STRCPY (NewBuf, + Operand0->String.Pointer); + ACPI_STRCPY (NewBuf + Operand0->String.Length, + LocalOperand1->String.Pointer); break; - case ACPI_TYPE_BUFFER: /* Result of two Buffers is a Buffer */ ReturnDesc = AcpiUtCreateBufferObject ( - (ACPI_SIZE) ObjDesc1->Buffer.Length + - (ACPI_SIZE) ObjDesc2->Buffer.Length); + (ACPI_SIZE) Operand0->Buffer.Length + + (ACPI_SIZE) LocalOperand1->Buffer.Length); if (!ReturnDesc) { - return (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup; } NewBuf = (char *) ReturnDesc->Buffer.Pointer; /* Concatenate the buffers */ - ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, - ObjDesc1->Buffer.Length); - ACPI_MEMCPY (NewBuf + ObjDesc1->Buffer.Length, ObjDesc2->Buffer.Pointer, - ObjDesc2->Buffer.Length); - + ACPI_MEMCPY (NewBuf, + Operand0->Buffer.Pointer, + Operand0->Buffer.Length); + ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length, + LocalOperand1->Buffer.Pointer, + LocalOperand1->Buffer.Length); break; - default: /* Invalid object type, should not happen here */ - ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", - ACPI_GET_OBJECT_TYPE (ObjDesc1))); - Status = AE_AML_INTERNAL; - ReturnDesc = NULL; + ACPI_REPORT_ERROR (("Concatenate - Invalid object type: %X\n", + ACPI_GET_OBJECT_TYPE (Operand0))); + Status =AE_AML_INTERNAL; + goto Cleanup; } *ActualReturnDesc = ReturnDesc; - return (AE_OK); - Cleanup: - - AcpiUtRemoveReference (ReturnDesc); - return (Status); + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + return_ACPI_STATUS (Status); } @@ -462,8 +492,8 @@ Cleanup: * FUNCTION: AcpiExDoMathOp * * PARAMETERS: Opcode - AML opcode - * Operand0 - Integer operand #0 - * Operand1 - Integer operand #1 + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 * * RETURN: Integer result of the operation * @@ -476,61 +506,63 @@ Cleanup: ACPI_INTEGER AcpiExDoMathOp ( UINT16 Opcode, - ACPI_INTEGER Operand0, - ACPI_INTEGER Operand1) + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1) { + ACPI_FUNCTION_ENTRY (); + switch (Opcode) { - case AML_ADD_OP: /* Add (Operand0, Operand1, Result) */ + case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ - return (Operand0 + Operand1); + return (Integer0 + Integer1); - case AML_BIT_AND_OP: /* And (Operand0, Operand1, Result) */ + case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */ - return (Operand0 & Operand1); + return (Integer0 & Integer1); - case AML_BIT_NAND_OP: /* NAnd (Operand0, Operand1, Result) */ + case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */ - return (~(Operand0 & Operand1)); + return (~(Integer0 & Integer1)); - case AML_BIT_OR_OP: /* Or (Operand0, Operand1, Result) */ + case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */ - return (Operand0 | Operand1); + return (Integer0 | Integer1); - case AML_BIT_NOR_OP: /* NOr (Operand0, Operand1, Result) */ + case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */ - return (~(Operand0 | Operand1)); + return (~(Integer0 | Integer1)); - case AML_BIT_XOR_OP: /* XOr (Operand0, Operand1, Result) */ + case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */ - return (Operand0 ^ Operand1); + return (Integer0 ^ Integer1); - case AML_MULTIPLY_OP: /* Multiply (Operand0, Operand1, Result) */ + case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */ - return (Operand0 * Operand1); + return (Integer0 * Integer1); - case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result) */ + case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/ - return (Operand0 << Operand1); + return (Integer0 << Integer1); case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ - return (Operand0 >> Operand1); + return (Integer0 >> Integer1); - case AML_SUBTRACT_OP: /* Subtract (Operand0, Operand1, Result) */ + case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */ - return (Operand0 - Operand1); + return (Integer0 - Integer1); default: @@ -541,18 +573,87 @@ AcpiExDoMathOp ( /******************************************************************************* * + * FUNCTION: AcpiExDoLogicalNumericOp + * + * PARAMETERS: Opcode - AML opcode + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 + * LogicalResult - TRUE/FALSE result of the operation + * + * RETURN: Status + * + * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric + * operators (LAnd and LOr), both operands must be integers. + * + * Note: cleanest machine code seems to be produced by the code + * below, rather than using statements of the form: + * Result = (Integer0 && Integer1); + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + + + ACPI_FUNCTION_TRACE ("ExDoLogicalNumericOp"); + + + switch (Opcode) + { + case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ + + if (Integer0 && Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LOR_OP: /* LOr (Integer0, Integer1) */ + + if (Integer0 || Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * * FUNCTION: AcpiExDoLogicalOp * * PARAMETERS: Opcode - AML opcode - * Operand0 - Integer operand #0 - * Operand1 - Integer operand #1 + * Operand0 - operand #0 + * Operand1 - operand #1 + * LogicalResult - TRUE/FALSE result of the operation * - * RETURN: TRUE/FALSE result of the operation + * RETURN: Status * * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the * functions here is to prevent a lot of pointer dereferencing * to obtain the operands and to simplify the generation of the - * logical value. + * logical value. For the Numeric operators (LAnd and LOr), both + * operands must be integers. For the other logical operators, + * operands can be any combination of Integer/String/Buffer. The + * first operand determines the type to which the second operand + * will be converted. * * Note: cleanest machine code seems to be produced by the code * below, rather than using statements of the form: @@ -560,66 +661,192 @@ AcpiExDoMathOp ( * ******************************************************************************/ -BOOLEAN +ACPI_STATUS AcpiExDoLogicalOp ( UINT16 Opcode, - ACPI_INTEGER Operand0, - ACPI_INTEGER Operand1) + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult) { + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_INTEGER Integer0; + ACPI_INTEGER Integer1; + UINT32 Length0; + UINT32 Length1; + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + int Compare; - switch (Opcode) - { + ACPI_FUNCTION_TRACE ("ExDoLogicalOp"); - case AML_LAND_OP: /* LAnd (Operand0, Operand1) */ - if (Operand0 && Operand1) - { - return (TRUE); - } + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI 3.0+ specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (ACPI_GET_OBJECT_TYPE (Operand0)) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); break; + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; - case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; - if (Operand0 == Operand1) - { - return (TRUE); - } + default: + Status = AE_AML_INTERNAL; break; + } + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } - case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + /* + * Two cases: 1) Both Integers, 2) Both Strings or Buffers + */ + if (ACPI_GET_OBJECT_TYPE (Operand0) == ACPI_TYPE_INTEGER) + { + /* + * 1) Both operands are of type integer + * Note: LocalOperand1 may have changed above + */ + Integer0 = Operand0->Integer.Value; + Integer1 = LocalOperand1->Integer.Value; - if (Operand0 > Operand1) + switch (Opcode) { - return (TRUE); - } - break; + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + if (Integer0 == Integer1) + { + LocalResult = TRUE; + } + break; - case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ - if (Operand0 < Operand1) - { - return (TRUE); + if (Integer0 > Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Integer0 < Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; } - break; + } + else + { + /* + * 2) Both operands are Strings or both are Buffers + * Note: Code below takes advantage of common Buffer/String + * object fields. LocalOperand1 may have changed above. Use + * memcmp to handle nulls in buffers. + */ + Length0 = Operand0->Buffer.Length; + Length1 = LocalOperand1->Buffer.Length; + /* Lexicographic compare: compare the data bytes */ - case AML_LOR_OP: /* LOr (Operand0, Operand1) */ + Compare = ACPI_MEMCMP ((const char * ) Operand0->Buffer.Pointer, + (const char * ) LocalOperand1->Buffer.Pointer, + (Length0 > Length1) ? Length1 : Length0); - if (Operand0 || Operand1) + switch (Opcode) { - return (TRUE); + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + + /* Length and all bytes must be equal */ + + if ((Length0 == Length1) && + (Compare == 0)) + { + /* Length and all bytes match ==> TRUE */ + + LocalResult = TRUE; + } + break; + + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + + if (Compare > 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + if (Compare < 0) + { + goto Cleanup; /* FALSE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 > Length1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Compare > 0) + { + goto Cleanup; /* FALSE */ + } + if (Compare < 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 < Length1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; } - break; + } - default: - break; +Cleanup: + + /* New object was created if implicit conversion performed - delete */ + + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); } - return (FALSE); + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); } diff --git a/sys/dev/acpi/acpica/Subsystem/exmutex.c b/sys/dev/acpi/acpica/Subsystem/exmutex.c index 726513fc505..ffa71993741 100644 --- a/sys/dev/acpi/acpica/Subsystem/exmutex.c +++ b/sys/dev/acpi/acpica/Subsystem/exmutex.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmutex - ASL Mutex Acquire/Release functions - * xRevision: 20 $ + * xRevision: 28 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exmutex.c,v 1.13 2004/04/07 18:19:34 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exmutex.c,v 1.14 2005/05/02 14:52:09 kochi Exp $"); #define __EXMUTEX_C__ @@ -126,14 +126,21 @@ __KERNEL_RCSID(0, "$NetBSD: exmutex.c,v 1.13 2004/04/07 18:19:34 kochi Exp $"); #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exmutex") +/* Local prototypes */ + +static void +AcpiExLinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_STATE *Thread); + /******************************************************************************* * * FUNCTION: AcpiExUnlinkMutex * - * PARAMETERS: *ObjDesc - The mutex to be unlinked + * PARAMETERS: ObjDesc - The mutex to be unlinked * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list * @@ -151,6 +158,8 @@ AcpiExUnlinkMutex ( return; } + /* Doubly linked list */ + if (ObjDesc->Mutex.Next) { (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; @@ -171,16 +180,16 @@ AcpiExUnlinkMutex ( * * FUNCTION: AcpiExLinkMutex * - * PARAMETERS: *ObjDesc - The mutex to be linked - * *ListHead - head of the "AcquiredMutex" list + * PARAMETERS: ObjDesc - The mutex to be linked + * Thread - Current executing thread object * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk * ******************************************************************************/ -void +static void AcpiExLinkMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_THREAD_STATE *Thread) @@ -212,8 +221,9 @@ AcpiExLinkMutex ( * * FUNCTION: AcpiExAcquireMutex * - * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor - * *ObjDesc - The object descriptor for this op + * PARAMETERS: TimeDesc - Timeout integer + * ObjDesc - Mutex object + * WalkState - Current method execution state * * RETURN: Status * @@ -243,7 +253,7 @@ AcpiExAcquireMutex ( if (!WalkState->Thread) { ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -253,24 +263,30 @@ AcpiExAcquireMutex ( */ if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) { - ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], incorrect SyncLevel\n", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + ACPI_REPORT_ERROR (( + "Cannot acquire Mutex [%4.4s], incorrect SyncLevel\n", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } - /* - * Support for multiple acquires by the owning thread - */ + /* Support for multiple acquires by the owning thread */ - if ((ObjDesc->Mutex.OwnerThread) && - (ObjDesc->Mutex.OwnerThread->ThreadId == WalkState->Thread->ThreadId)) + if (ObjDesc->Mutex.OwnerThread) { - /* - * The mutex is already owned by this thread, - * just increment the acquisition depth - */ - ObjDesc->Mutex.AcquisitionDepth++; - return_ACPI_STATUS (AE_OK); + /* Special case for Global Lock, allow all threads */ + + if ((ObjDesc->Mutex.OwnerThread->ThreadId == + WalkState->Thread->ThreadId) || + (ObjDesc->Mutex.Semaphore == + AcpiGbl_GlobalLockSemaphore)) + { + /* + * The mutex is already owned by this thread, + * just increment the acquisition depth + */ + ObjDesc->Mutex.AcquisitionDepth++; + return_ACPI_STATUS (AE_OK); + } } /* Acquire the mutex, wait if necessary */ @@ -283,12 +299,12 @@ AcpiExAcquireMutex ( return_ACPI_STATUS (Status); } - /* Have the mutex, update mutex and walk info */ + /* Have the mutex: update mutex and walk info and save the SyncLevel */ - ObjDesc->Mutex.OwnerThread = WalkState->Thread; - ObjDesc->Mutex.AcquisitionDepth = 1; + ObjDesc->Mutex.OwnerThread = WalkState->Thread; + ObjDesc->Mutex.AcquisitionDepth = 1; + ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; - ObjDesc->Mutex.PreviousSyncLevel = WalkState->Thread->CurrentSyncLevel; WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; /* Link the mutex to the current thread for force-unlock at method exit */ @@ -303,7 +319,8 @@ AcpiExAcquireMutex ( * * FUNCTION: AcpiExReleaseMutex * - * PARAMETERS: *ObjDesc - The object descriptor for this op + * PARAMETERS: ObjDesc - The object descriptor for this op + * WalkState - Current method execution state * * RETURN: Status * @@ -345,9 +362,12 @@ AcpiExReleaseMutex ( return_ACPI_STATUS (AE_AML_INTERNAL); } - /* The Mutex is owned, but this thread must be the owner */ - - if (ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) + /* + * The Mutex is owned, but this thread must be the owner. + * Special case for Global Lock, any thread can release + */ + if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) && + (ObjDesc->Mutex.Semaphore != AcpiGbl_GlobalLockSemaphore)) { ACPI_REPORT_ERROR (( "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", @@ -363,14 +383,14 @@ AcpiExReleaseMutex ( */ if (ObjDesc->Mutex.SyncLevel > WalkState->Thread->CurrentSyncLevel) { - ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], incorrect SyncLevel\n", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + ACPI_REPORT_ERROR (( + "Cannot release Mutex [%4.4s], incorrect SyncLevel\n", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } - /* - * Match multiple Acquires with multiple Releases - */ + /* Match multiple Acquires with multiple Releases */ + ObjDesc->Mutex.AcquisitionDepth--; if (ObjDesc->Mutex.AcquisitionDepth != 0) { @@ -387,10 +407,10 @@ AcpiExReleaseMutex ( Status = AcpiExSystemReleaseMutex (ObjDesc); - /* Update the mutex and walk state */ + /* Update the mutex and walk state, restore SyncLevel before acquire */ ObjDesc->Mutex.OwnerThread = NULL; - WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.PreviousSyncLevel; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; return_ACPI_STATUS (Status); } @@ -400,11 +420,11 @@ AcpiExReleaseMutex ( * * FUNCTION: AcpiExReleaseAllMutexes * - * PARAMETERS: *MutexList - Head of the mutex list + * PARAMETERS: Thread - Current executing thread object * * RETURN: Status * - * DESCRIPTION: Release all mutexes in the list + * DESCRIPTION: Release all mutexes held by this thread * ******************************************************************************/ @@ -420,9 +440,8 @@ AcpiExReleaseAllMutexes ( ACPI_FUNCTION_ENTRY (); - /* - * Traverse the list of owned mutexes, releasing each one. - */ + /* Traverse the list of owned mutexes, releasing each one */ + while (Next) { This = Next; @@ -442,7 +461,11 @@ AcpiExReleaseAllMutexes ( /* Mark mutex unowned */ - This->Mutex.OwnerThread = NULL; + This->Mutex.OwnerThread = NULL; + + /* Update Thread SyncLevel (Last mutex is the important one) */ + + Thread->CurrentSyncLevel = This->Mutex.OriginalSyncLevel; } } diff --git a/sys/dev/acpi/acpica/Subsystem/exnames.c b/sys/dev/acpi/acpica/Subsystem/exnames.c index 44a0dfcbbef..d4e895816e4 100644 --- a/sys/dev/acpi/acpica/Subsystem/exnames.c +++ b/sys/dev/acpi/acpica/Subsystem/exnames.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exnames - interpreter/scanner name load/execute - * xRevision: 95 $ + * xRevision: 100 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exnames.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exnames.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXNAMES_C__ @@ -127,13 +127,17 @@ __KERNEL_RCSID(0, "$NetBSD: exnames.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exnames") +/* Local prototypes */ -/* AML Package Length encodings */ +static char * +AcpiExAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs); -#define ACPI_AML_PACKAGE_TYPE1 0x40 -#define ACPI_AML_PACKAGE_TYPE2 0x4000 -#define ACPI_AML_PACKAGE_TYPE3 0x400000 -#define ACPI_AML_PACKAGE_TYPE4 0x40000000 +static ACPI_STATUS +AcpiExNameSegment ( + UINT8 **InAmlAddress, + char *NameString); /******************************************************************************* @@ -141,7 +145,7 @@ __KERNEL_RCSID(0, "$NetBSD: exnames.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * FUNCTION: AcpiExAllocateNameString * * PARAMETERS: PrefixCount - Count of parent levels. Special cases: - * (-1) = root, 0 = none + * (-1)==root, 0==none * NumNameSegs - count of 4-character name segments * * RETURN: A pointer to the allocated string segment. This segment must @@ -152,7 +156,7 @@ __KERNEL_RCSID(0, "$NetBSD: exnames.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * ******************************************************************************/ -char * +static char * AcpiExAllocateNameString ( UINT32 PrefixCount, UINT32 NumNameSegs) @@ -165,7 +169,7 @@ AcpiExAllocateNameString ( /* - * Allow room for all \ and ^ prefixes, all segments, and a MultiNamePrefix. + * Allow room for all \ and ^ prefixes, all segments and a MultiNamePrefix. * Also, one byte for the null terminator. * This may actually be somewhat longer than needed. */ @@ -187,7 +191,8 @@ AcpiExAllocateNameString ( NameString = ACPI_MEM_ALLOCATE (SizeNeeded); if (!NameString) { - ACPI_REPORT_ERROR (("ExAllocateNameString: Could not allocate size %d\n", SizeNeeded)); + ACPI_REPORT_ERROR (( + "ExAllocateNameString: Could not allocate size %d\n", SizeNeeded)); return_PTR (NULL); } @@ -237,15 +242,17 @@ AcpiExAllocateNameString ( * * FUNCTION: AcpiExNameSegment * - * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) + * PARAMETERS: InAmlAddress - Pointer to the name in the AML code + * NameString - Where to return the name. The name is appended + * to any existing string to form a namepath * * RETURN: Status * - * DESCRIPTION: Execute a name segment (4 bytes) + * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExNameSegment ( UINT8 **InAmlAddress, char *NameString) @@ -315,10 +322,13 @@ AcpiExNameSegment ( } else { - /* Segment started with one or more valid characters, but fewer than 4 */ - + /* + * Segment started with one or more valid characters, but fewer than + * the required 4 + */ Status = AE_AML_BAD_NAME; - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad character %02x in name, at %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Bad character %02x in name, at %p\n", *AmlAddress, AmlAddress)); } @@ -331,11 +341,16 @@ AcpiExNameSegment ( * * FUNCTION: AcpiExGetNameString * - * PARAMETERS: DataType - Data type to be associated with this name + * PARAMETERS: DataType - Object type to be associated with this + * name + * InAmlAddress - Pointer to the namestring in the AML code + * OutNameString - Where the namestring is returned + * OutNameLength - Length of the returned string * - * RETURN: Status + * RETURN: Status, namestring and length * - * DESCRIPTION: Get a name, including any prefixes. + * DESCRIPTION: Extract a full namepath from the AML byte stream, + * including any prefixes. * ******************************************************************************/ @@ -383,7 +398,8 @@ AcpiExGetNameString ( { case AML_ROOT_PREFIX: - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", AmlAddress)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", + AmlAddress)); /* * Remember that we have a RootPrefix -- @@ -401,7 +417,8 @@ AcpiExGetNameString ( do { - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", AmlAddress)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", + AmlAddress)); AmlAddress++; PrefixCount++; @@ -419,14 +436,14 @@ AcpiExGetNameString ( break; } - /* Examine first character of name for name segment prefix operator */ switch (*AmlAddress) { case AML_DUAL_NAME_PREFIX: - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", AmlAddress)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", + AmlAddress)); AmlAddress++; NameString = AcpiExAllocateNameString (PrefixCount, 2); @@ -450,7 +467,8 @@ AcpiExGetNameString ( case AML_MULTI_NAME_PREFIX_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", AmlAddress)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", + AmlAddress)); /* Fetch count of segments remaining in name path */ @@ -470,7 +488,8 @@ AcpiExGetNameString ( HasPrefix = TRUE; while (NumSegments && - (Status = AcpiExNameSegment (&AmlAddress, NameString)) == AE_OK) + (Status = AcpiExNameSegment (&AmlAddress, NameString)) == + AE_OK) { NumSegments--; } @@ -484,7 +503,8 @@ AcpiExGetNameString ( if (PrefixCount == ACPI_UINT32_MAX) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "NameSeg is \"\\\" followed by NULL\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "NameSeg is \"\\\" followed by NULL\n")); } /* Consume the NULL byte */ diff --git a/sys/dev/acpi/acpica/Subsystem/exoparg1.c b/sys/dev/acpi/acpica/Subsystem/exoparg1.c index e8d6ee735e4..b4da0c07546 100644 --- a/sys/dev/acpi/acpica/Subsystem/exoparg1.c +++ b/sys/dev/acpi/acpica/Subsystem/exoparg1.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg1 - AML execution - opcodes with 1 argument - * xRevision: 152 $ + * xRevision: 167 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exoparg1.c,v 1.9 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exoparg1.c,v 1.10 2005/05/02 14:52:09 kochi Exp $"); #define __EXOPARG1_C__ @@ -144,7 +144,7 @@ __KERNEL_RCSID(0, "$NetBSD: exoparg1.c,v 1.9 2004/02/14 16:57:24 kochi Exp $"); * Where: * * xA - ARGUMENTS: The number of arguments (input operands) that are - * required for this opcode type (1 through 6 args). + * required for this opcode type (0 through 6 args). * yT - TARGETS: The number of targets (output operands) that are required * for this opcode type (0, 1, or 2 targets). * zR - RETURN VALUE: Indicates whether this opcode type returns a value @@ -156,6 +156,74 @@ __KERNEL_RCSID(0, "$NetBSD: exoparg1.c,v 1.9 2004/02/14 16:57:24 kochi Exp $"); /******************************************************************************* * + * FUNCTION: AcpiExOpcode_0A_0T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute operator with no operands, one return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + + + ACPI_FUNCTION_TRACE_STR ("ExOpcode_0A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_TIMER_OP: /* Timer () */ + + /* Create a return object of type Integer */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc->Integer.Value = AcpiOsGetTimer (); + break; + + default: /* Unknown opcode */ + + ACPI_REPORT_ERROR (("AcpiExOpcode_0A_0T_1R: Unknown opcode %X\n", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + +Cleanup: + + if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * * FUNCTION: AcpiExOpcode_1A_0T_0R * * PARAMETERS: WalkState - Current state (contains AML opcode) @@ -175,7 +243,8 @@ AcpiExOpcode_1A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -202,7 +271,7 @@ AcpiExOpcode_1A_0T_0R ( case AML_SLEEP_OP: /* Sleep (MsecTime) */ - Status = AcpiExSystemDoSuspend ((UINT32) Operand[0]->Integer.Value); + Status = AcpiExSystemDoSuspend (Operand[0]->Integer.Value); break; @@ -251,7 +320,8 @@ AcpiExOpcode_1A_1T_0R ( ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -301,11 +371,12 @@ AcpiExOpcode_1A_1T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; UINT32 Temp32; UINT32 i; - UINT32 PowerOfTen; + ACPI_INTEGER PowerOfTen; ACPI_INTEGER Digit; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -344,7 +415,8 @@ AcpiExOpcode_1A_1T_1R ( * Acpi specification describes Integer type as a little * endian unsigned value, so this boundary condition is valid. */ - for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value >>= 1; } @@ -353,7 +425,7 @@ AcpiExOpcode_1A_1T_1R ( break; - case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ + case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ ReturnDesc->Integer.Value = Operand[0]->Integer.Value; @@ -361,14 +433,16 @@ AcpiExOpcode_1A_1T_1R ( * The Acpi specification describes Integer type as a little * endian unsigned value, so this boundary condition is valid. */ - for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value <<= 1; } /* Since the bit position is one-based, subtract from 33 (65) */ - ReturnDesc->Integer.Value = Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; + ReturnDesc->Integer.Value = Temp32 == 0 ? 0 : + (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; break; @@ -405,7 +479,8 @@ AcpiExOpcode_1A_1T_1R ( /* Sum the digit into the result with the current power of 10 */ - ReturnDesc->Integer.Value += (((ACPI_INTEGER) Temp32) * PowerOfTen); + ReturnDesc->Integer.Value += (((ACPI_INTEGER) Temp32) * + PowerOfTen); /* Shift to next BCD digit */ @@ -427,19 +502,23 @@ AcpiExOpcode_1A_1T_1R ( for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) { - (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Temp32); + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32); - /* Insert the BCD digit that resides in the remainder from above */ - - ReturnDesc->Integer.Value |= (((ACPI_INTEGER) Temp32) << (i * 4)); + /* + * Insert the BCD digit that resides in the + * remainder from above + */ + ReturnDesc->Integer.Value |= (((ACPI_INTEGER) Temp32) << + ACPI_MUL_4 (i)); } /* Overflow if there is any data left in Digit */ if (Digit > 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Integer too large to convert to BCD: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Integer too large to convert to BCD: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value))); Status = AE_AML_NUMERIC_OVERFLOW; goto Cleanup; } @@ -465,7 +544,8 @@ AcpiExOpcode_1A_1T_1R ( /* Get the object reference, store it, and remove our reference */ - Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc2, WalkState); + Status = AcpiExGetObjectReference (Operand[0], + &ReturnDesc2, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -505,10 +585,10 @@ AcpiExOpcode_1A_1T_1R ( if (!WalkState->ResultObj) { /* - * Normally, we would remove a reference on the Operand[0] parameter; - * But since it is being used as the internal return object - * (meaning we would normally increment it), the two cancel out, - * and we simply don't do anything. + * Normally, we would remove a reference on the Operand[0] + * parameter; But since it is being used as the internal return + * object (meaning we would normally increment it), the two + * cancel out, and we simply don't do anything. */ WalkState->ResultObj = Operand[0]; WalkState->Operands[0] = NULL; /* Prevent deletion */ @@ -521,42 +601,66 @@ AcpiExOpcode_1A_1T_1R ( */ case AML_COPY_OP: /* Copy (Source, Target) */ - Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, WalkState); + Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, + WalkState); break; case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */ - Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 10, ACPI_UINT32_MAX, WalkState); + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_DECIMAL); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */ - Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 16, ACPI_UINT32_MAX, WalkState); + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_HEX); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ - Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc, WalkState); + Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ - Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, WalkState); + Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, + ACPI_ANY_BASE); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; - case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ - case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ + case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ + case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ - /* - * These are two obsolete opcodes - */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n", - AcpiPsGetOpcodeName (WalkState->Opcode))); + /* These are two obsolete opcodes */ + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "%s is obsolete and not implemented\n", + AcpiPsGetOpcodeName (WalkState->Opcode))); Status = AE_SUPPORT; goto Cleanup; @@ -569,10 +673,12 @@ AcpiExOpcode_1A_1T_1R ( goto Cleanup; } - /* - * Store the return value computed above into the target object - */ - Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + if (ACPI_SUCCESS (Status)) + { + /* Store the return value computed above into the target object */ + + Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + } Cleanup: @@ -617,7 +723,8 @@ AcpiExOpcode_1A_0T_1R ( ACPI_INTEGER Value; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -633,7 +740,14 @@ AcpiExOpcode_1A_0T_1R ( goto Cleanup; } - ReturnDesc->Integer.Value = !Operand[0]->Integer.Value; + /* + * Set result to ONES (TRUE) if Value == 0. Note: + * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above. + */ + if (!Operand[0]->Integer.Value) + { + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + } break; @@ -641,51 +755,79 @@ AcpiExOpcode_1A_0T_1R ( case AML_INCREMENT_OP: /* Increment (Operand) */ /* - * Since we are expecting a Reference operand, it - * can be either a NS Node or an internal object. + * Create a new integer. Can't just get the base integer and + * increment it because it may be an Arg or Field. + */ + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Since we are expecting a Reference operand, it can be either a + * NS Node or an internal object. */ - ReturnDesc = Operand[0]; - if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_OPERAND) + TempDesc = Operand[0]; + if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND) { /* Internal reference object - prevent deletion */ - AcpiUtAddReference (ReturnDesc); + AcpiUtAddReference (TempDesc); } /* - * Convert the ReturnDesc Reference to a Number - * (This removes a reference on the ReturnDesc object) + * Convert the Reference operand to an Integer (This removes a + * reference on the Operand[0] object) + * + * NOTE: We use LNOT_OP here in order to force resolution of the + * reference operand to an actual integer. */ - Status = AcpiExResolveOperands (AML_LNOT_OP, &ReturnDesc, WalkState); + Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n", - AcpiPsGetOpcodeName (WalkState->Opcode), AcpiFormatException(Status))); + AcpiPsGetOpcodeName (WalkState->Opcode), + AcpiFormatException(Status))); goto Cleanup; } /* - * ReturnDesc is now guaranteed to be an Integer object - * Do the actual increment or decrement + * TempDesc is now guaranteed to be an Integer object -- + * Perform the actual increment or decrement */ - if (AML_INCREMENT_OP == WalkState->Opcode) + if (WalkState->Opcode == AML_INCREMENT_OP) { - ReturnDesc->Integer.Value++; + ReturnDesc->Integer.Value = TempDesc->Integer.Value +1; } else { - ReturnDesc->Integer.Value--; + ReturnDesc->Integer.Value = TempDesc->Integer.Value -1; } - /* Store the result back in the original descriptor */ + /* Finished with this Integer object */ + AcpiUtRemoveReference (TempDesc); + + /* + * Store the result back (indirectly) through the original + * Reference object + */ Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); break; case AML_TYPE_OP: /* ObjectType (SourceObject) */ + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. For example, we don't + * want to resolve a FieldUnit to its value, we want the actual + * FieldUnit object. + */ + /* Get the type of the base object */ Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL); @@ -693,7 +835,6 @@ AcpiExOpcode_1A_0T_1R ( { goto Cleanup; } - /* Allocate a descriptor to hold the type. */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); @@ -709,21 +850,35 @@ AcpiExOpcode_1A_0T_1R ( case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */ + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. + */ + /* Get the base object */ - Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, &TempDesc); + Status = AcpiExResolveMultiple (WalkState, + Operand[0], &Type, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* - * Type is guaranteed to be a buffer, string, or package at this - * point (even if the original operand was an object reference, it - * will be resolved and typechecked during operand resolution.) + * The type of the base object must be integer, buffer, string, or + * package. All others are not supported. + * + * NOTE: Integer is not specifically supported by the ACPI spec, + * but is supported implicitly via implicit operand conversion. + * rather than bother with conversion, we just use the byte width + * global (4 or 8 bytes). */ switch (Type) { + case ACPI_TYPE_INTEGER: + Value = AcpiGbl_IntegerByteWidth; + break; + case ACPI_TYPE_BUFFER: Value = TempDesc->Buffer.Length; break; @@ -737,7 +892,8 @@ AcpiExOpcode_1A_0T_1R ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "SizeOf, Not Buf/Str/Pkg - found type %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "SizeOf - Operand is not Buf/Int/Str/Pkg - found type %s\n", AcpiUtGetTypeName (Type))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -789,8 +945,10 @@ AcpiExOpcode_1A_0T_1R ( /* Set Operand[0] to the value of the local/arg */ - Status = AcpiDsMethodDataGetValue (Operand[0]->Reference.Opcode, - Operand[0]->Reference.Offset, WalkState, &TempDesc); + Status = AcpiDsMethodDataGetValue ( + Operand[0]->Reference.Opcode, + Operand[0]->Reference.Offset, + WalkState, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -824,22 +982,27 @@ AcpiExOpcode_1A_0T_1R ( case ACPI_TYPE_STRING: /* - * This is a DerefOf (String). The string is a reference to a named ACPI object. + * This is a DerefOf (String). The string is a reference + * to a named ACPI object. * * 1) Find the owning Node - * 2) Dereference the node to an actual object. Could be a Field, so we nee - * to resolve the node to a value. + * 2) Dereference the node to an actual object. Could be a + * Field, so we need to resolve the node to a value. */ Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer, - WalkState->ScopeInfo->Scope.Node, ACPI_NS_SEARCH_PARENT, - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc)); + WalkState->ScopeInfo->Scope.Node, + ACPI_NS_SEARCH_PARENT, + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc)); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiExResolveNodeToValue ( - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc), WalkState); + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc), + WalkState); goto Cleanup; @@ -857,15 +1020,17 @@ AcpiExOpcode_1A_0T_1R ( /* * This is a DerefOf (ObjectReference) * Get the actual object from the Node (This is the dereference). - * -- This case may only happen when a LocalX or ArgX is dereferenced above. + * This case may only happen when a LocalX or ArgX is + * dereferenced above. */ - ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) Operand[0]); + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) Operand[0]); } else { /* - * This must be a reference object produced by either the Index() or - * RefOf() operator + * This must be a reference object produced by either the + * Index() or RefOf() operator */ switch (Operand[0]->Reference.Opcode) { @@ -909,8 +1074,8 @@ AcpiExOpcode_1A_0T_1R ( case ACPI_TYPE_PACKAGE: /* - * Return the referenced element of the package. We must add - * another reference to the referenced object, however. + * Return the referenced element of the package. We must + * add another reference to the referenced object, however. */ ReturnDesc = *(Operand[0]->Reference.Where); if (!ReturnDesc) @@ -920,7 +1085,8 @@ AcpiExOpcode_1A_0T_1R ( * an uninitialized package element and is thus a * severe error. */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "NULL package element obj %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "NULL package element obj %p\n", Operand[0])); Status = AE_AML_UNINITIALIZED_ELEMENT; goto Cleanup; @@ -932,7 +1098,8 @@ AcpiExOpcode_1A_0T_1R ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Index TargetType %X in obj %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown Index TargetType %X in obj %p\n", Operand[0]->Reference.TargetType, Operand[0])); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -944,10 +1111,12 @@ AcpiExOpcode_1A_0T_1R ( ReturnDesc = Operand[0]->Reference.Object; - if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == ACPI_DESC_TYPE_NAMED) + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == + ACPI_DESC_TYPE_NAMED) { - ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ReturnDesc); + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ReturnDesc); } /* Add another reference to the object! */ @@ -957,7 +1126,8 @@ AcpiExOpcode_1A_0T_1R ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown opcode in ref(%p) - %X\n", Operand[0], Operand[0]->Reference.Opcode)); Status = AE_TYPE; diff --git a/sys/dev/acpi/acpica/Subsystem/exoparg2.c b/sys/dev/acpi/acpica/Subsystem/exoparg2.c index e9c16d3d022..a895d713355 100644 --- a/sys/dev/acpi/acpica/Subsystem/exoparg2.c +++ b/sys/dev/acpi/acpica/Subsystem/exoparg2.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exoparg2 - AML execution - opcodes with 2 arguments - * xRevision: 119 $ + * xRevision: 134 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exoparg2.c,v 1.9 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exoparg2.c,v 1.10 2005/05/02 14:52:09 kochi Exp $"); #define __EXOPARG2_C__ @@ -175,6 +175,7 @@ AcpiExOpcode_2A_0T_0R ( { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_NAMESPACE_NODE *Node; + UINT32 Value; ACPI_STATUS Status = AE_OK; @@ -192,17 +193,49 @@ AcpiExOpcode_2A_0T_0R ( Node = (ACPI_NAMESPACE_NODE *) Operand[0]; - /* Notifies allowed on this object? */ + /* Second value is the notify value */ + + Value = (UINT32) Operand[1]->Integer.Value; + + /* Are notifies allowed on this object? */ if (!AcpiEvIsNotifyObject (Node)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type [%s]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unexpected notify object type [%s]\n", AcpiUtGetTypeName (Node->Type))); Status = AE_AML_OPERAND_TYPE; break; } +#ifdef ACPI_GPE_NOTIFY_CHECK + /* + * GPE method wake/notify check. Here, we want to ensure that we + * don't receive any "DeviceWake" Notifies from a GPE _Lxx or _Exx + * GPE method during system runtime. If we do, the GPE is marked + * as "wake-only" and disabled. + * + * 1) Is the Notify() value == DeviceWake? + * 2) Is this a GPE deferred method? (An _Lxx or _Exx method) + * 3) Did the original GPE happen at system runtime? + * (versus during wake) + * + * If all three cases are true, this is a wake-only GPE that should + * be disabled at runtime. + */ + if (Value == 2) /* DeviceWake */ + { + Status = AcpiEvCheckForWakeOnlyGpe (WalkState->GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + /* AE_WAKE_ONLY_GPE only error, means ignore this notify */ + + return_ACPI_STATUS (AE_OK) + } + } +#endif + /* * Dispatch the notify to the appropriate handler * NOTE: the request is queued for execution after this method @@ -210,8 +243,7 @@ AcpiExOpcode_2A_0T_0R ( * from this thread -- because handlers may in turn run other * control methods. */ - Status = AcpiEvQueueNotifyRequest (Node, - (UINT32) Operand[1]->Integer.Value); + Status = AcpiEvQueueNotifyRequest (Node, Value); break; @@ -249,15 +281,17 @@ AcpiExOpcode_2A_2T_1R ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_2T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_2T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); - /* - * Execute the opcode - */ + /* Execute the opcode */ + switch (WalkState->Opcode) { - case AML_DIVIDE_OP: /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */ + case AML_DIVIDE_OP: + + /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */ ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc1) @@ -275,8 +309,10 @@ AcpiExOpcode_2A_2T_1R ( /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */ - Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value, - &ReturnDesc1->Integer.Value, &ReturnDesc2->Integer.Value); + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + &ReturnDesc1->Integer.Value, + &ReturnDesc2->Integer.Value); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -292,7 +328,6 @@ AcpiExOpcode_2A_2T_1R ( goto Cleanup; } - /* Store the results to the target reference operands */ Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState); @@ -349,18 +384,17 @@ AcpiExOpcode_2A_1T_1R ( { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_OPERAND_OBJECT *TempDesc = NULL; - UINT32 Index; + ACPI_INTEGER Index; ACPI_STATUS Status = AE_OK; ACPI_SIZE Length; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_1T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); - /* - * Execute the opcode - */ + /* Execute the opcode */ + if (WalkState->OpInfo->Flags & AML_MATH) { /* All simple math opcodes (add, etc.) */ @@ -378,10 +412,9 @@ AcpiExOpcode_2A_1T_1R ( goto StoreResultToTarget; } - switch (WalkState->Opcode) { - case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ + case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) @@ -392,119 +425,72 @@ AcpiExOpcode_2A_1T_1R ( /* ReturnDesc will contain the remainder */ - Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value, - NULL, &ReturnDesc->Integer.Value); + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + NULL, + &ReturnDesc->Integer.Value); break; - case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ + case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ - /* - * Convert the second operand if necessary. The first operand - * determines the type of the second operand, (See the Data Types - * section of the ACPI specification.) Both object types are - * guaranteed to be either Integer/String/Buffer by the operand - * resolution mechanism above. - */ - switch (ACPI_GET_OBJECT_TYPE (Operand[0])) - { - case ACPI_TYPE_INTEGER: - Status = AcpiExConvertToInteger (Operand[1], &TempDesc, WalkState); - break; - - case ACPI_TYPE_STRING: - Status = AcpiExConvertToString (Operand[1], &TempDesc, 16, ACPI_UINT32_MAX, WalkState); - break; - - case ACPI_TYPE_BUFFER: - Status = AcpiExConvertToBuffer (Operand[1], &TempDesc, WalkState); - break; - - default: - ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", - ACPI_GET_OBJECT_TYPE (Operand[0]))); - Status = AE_AML_INTERNAL; - } - - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* - * Both operands are now known to be the same object type - * (Both are Integer, String, or Buffer), and we can now perform the - * concatenation. - */ - Status = AcpiExDoConcatenate (Operand[0], TempDesc, &ReturnDesc, WalkState); - if (TempDesc != Operand[1]) - { - AcpiUtRemoveReference (TempDesc); - } + Status = AcpiExDoConcatenate (Operand[0], Operand[1], + &ReturnDesc, WalkState); break; - case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ + case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ /* * Input object is guaranteed to be a buffer at this point (it may have - * been converted.) Copy the raw buffer data to a new object of type String. + * been converted.) Copy the raw buffer data to a new object of + * type String. */ - /* Get the length of the new string */ - + /* + * Get the length of the new string. It is the smallest of: + * 1) Length of the input buffer + * 2) Max length as specified in the ToString operator + * 3) Length of input buffer up to a zero byte (null terminator) + * + * NOTE: A length of zero is ok, and will create a zero-length, null + * terminated string. + */ Length = 0; - if (Operand[1]->Integer.Value == 0) - { - /* Handle optional length value */ - - Operand[1]->Integer.Value = ACPI_INTEGER_MAX; - } - while ((Length < Operand[0]->Buffer.Length) && (Length < Operand[1]->Integer.Value) && (Operand[0]->Buffer.Pointer[Length])) { Length++; + if (Length > ACPI_MAX_STRING_CONVERSION) + { + Status = AE_AML_STRING_LIMIT; + goto Cleanup; + } } - if (Length > ACPI_MAX_STRING_CONVERSION) - { - Status = AE_AML_STRING_LIMIT; - goto Cleanup; - } - - /* Create the internal return object */ + /* Allocate a new string object */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); + ReturnDesc = AcpiUtCreateStringObject (Length); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - /* Allocate a new string buffer (Length + 1 for null terminator) */ - - ReturnDesc->String.Pointer = ACPI_MEM_CALLOCATE (Length + 1); - if (!ReturnDesc->String.Pointer) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Copy the raw buffer data with no transform */ - - ACPI_MEMCPY (ReturnDesc->String.Pointer, Operand[0]->Buffer.Pointer, Length); - - /* Set the string length */ + /* Copy the raw buffer data with no transform. NULL terminated already*/ - ReturnDesc->String.Length = (UINT32) Length; + ACPI_MEMCPY (ReturnDesc->String.Pointer, + Operand[0]->Buffer.Pointer, Length); break; - case AML_CONCAT_RES_OP: /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ + case AML_CONCAT_RES_OP: - Status = AcpiExConcatTemplate (Operand[0], Operand[1], &ReturnDesc, WalkState); + /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ + + Status = AcpiExConcatTemplate (Operand[0], Operand[1], + &ReturnDesc, WalkState); break; @@ -519,35 +505,37 @@ AcpiExOpcode_2A_1T_1R ( goto Cleanup; } - Index = (UINT32) Operand[1]->Integer.Value; + Index = Operand[1]->Integer.Value; + + /* At this point, the Source operand is a Package, Buffer, or String */ - /* - * At this point, the Source operand is either a Package or a Buffer - */ if (ACPI_GET_OBJECT_TYPE (Operand[0]) == ACPI_TYPE_PACKAGE) { /* Object to be indexed is a Package */ if (Index >= Operand[0]->Package.Count) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value (%X) beyond package end (%X)\n", - Index, Operand[0]->Package.Count)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Index value (%X%8.8X) beyond package end (%X)\n", + ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); Status = AE_AML_PACKAGE_LIMIT; goto Cleanup; } ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; ReturnDesc->Reference.Object = Operand[0]; - ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index]; + ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [ + Index]; } else { - /* Object to be indexed is a Buffer */ + /* Object to be indexed is a Buffer/String */ if (Index >= Operand[0]->Buffer.Length) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value (%X) beyond end of buffer (%X)\n", - Index, Operand[0]->Buffer.Length)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Index value (%X%8.8X) beyond end of buffer (%X)\n", + ACPI_FORMAT_UINT64 (Index), Operand[0]->Buffer.Length)); Status = AE_AML_BUFFER_LIMIT; goto Cleanup; } @@ -556,10 +544,16 @@ AcpiExOpcode_2A_1T_1R ( ReturnDesc->Reference.Object = Operand[0]; } + /* + * Add a reference to the target package/buffer/string for the life + * of the index. + */ + AcpiUtAddReference (Operand[0]); + /* Complete the Index reference object */ ReturnDesc->Reference.Opcode = AML_INDEX_OP; - ReturnDesc->Reference.Offset = Index; + ReturnDesc->Reference.Offset = (UINT32) Index; /* Store the reference to the Target */ @@ -636,7 +630,8 @@ AcpiExOpcode_2A_0T_1R ( BOOLEAN LogicalResult = FALSE; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Create the internal return object */ @@ -648,17 +643,25 @@ AcpiExOpcode_2A_0T_1R ( goto Cleanup; } - /* - * Execute the Opcode - */ - if (WalkState->OpInfo->Flags & AML_LOGICAL) /* LogicalOp (Operand0, Operand1) */ + /* Execute the Opcode */ + + if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC) { - LogicalResult = AcpiExDoLogicalOp (WalkState->Opcode, - Operand[0]->Integer.Value, - Operand[1]->Integer.Value); + /* LogicalOp (Operand0, Operand1) */ + + Status = AcpiExDoLogicalNumericOp (WalkState->Opcode, + Operand[0]->Integer.Value, Operand[1]->Integer.Value, + &LogicalResult); goto StoreLogicalResult; } + else if (WalkState->OpInfo->Flags & AML_LOGICAL) + { + /* LogicalOp (Operand0, Operand1) */ + Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0], + Operand[1], &LogicalResult); + goto StoreLogicalResult; + } switch (WalkState->Opcode) { diff --git a/sys/dev/acpi/acpica/Subsystem/exoparg3.c b/sys/dev/acpi/acpica/Subsystem/exoparg3.c index 4dcbf4de83e..ede2973ff26 100644 --- a/sys/dev/acpi/acpica/Subsystem/exoparg3.c +++ b/sys/dev/acpi/acpica/Subsystem/exoparg3.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg3 - AML execution - opcodes with 3 arguments - * xRevision: 19 $ + * xRevision: 24 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exoparg3.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exoparg3.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXOPARG3_C__ @@ -175,12 +175,13 @@ AcpiExOpcode_3A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_0T_0R", + AcpiPsGetOpcodeName (WalkState->Opcode)); switch (WalkState->Opcode) { - case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ + case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", @@ -196,9 +197,8 @@ AcpiExOpcode_3A_0T_0R ( Fatal->Argument = (UINT32) Operand[2]->Integer.Value; } - /* - * Always signal the OS! - */ + /* Always signal the OS! */ + Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); /* Might return while OS is shutting down, just continue */ @@ -242,22 +242,24 @@ AcpiExOpcode_3A_1T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc = NULL; char *Buffer; ACPI_STATUS Status = AE_OK; - ACPI_NATIVE_UINT Index; + ACPI_INTEGER Index; ACPI_SIZE Length; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_1T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); switch (WalkState->Opcode) { - case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ + case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ /* * Create the return object. The Source operand is guaranteed to be * either a String or a Buffer, so just use its type. */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_GET_OBJECT_TYPE (Operand[0])); + ReturnDesc = AcpiUtCreateInternalObject ( + ACPI_GET_OBJECT_TYPE (Operand[0])); if (!ReturnDesc) { Status = AE_NO_MEMORY; @@ -266,7 +268,7 @@ AcpiExOpcode_3A_1T_1R ( /* Get the Integer values from the objects */ - Index = (ACPI_NATIVE_UINT) Operand[1]->Integer.Value; + Index = Operand[1]->Integer.Value; Length = (ACPI_SIZE) Operand[2]->Integer.Value; /* @@ -281,7 +283,8 @@ AcpiExOpcode_3A_1T_1R ( if ((Index + Length) > Operand[0]->String.Length) { - Length = (ACPI_SIZE) Operand[0]->String.Length - Index; + Length = (ACPI_SIZE) Operand[0]->String.Length - + (ACPI_SIZE) Index; } /* Allocate a new buffer for the String/Buffer */ @@ -303,6 +306,10 @@ AcpiExOpcode_3A_1T_1R ( ReturnDesc->String.Pointer = Buffer; ReturnDesc->String.Length = (UINT32) Length; } + + /* Mark buffer initialized */ + + ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; break; diff --git a/sys/dev/acpi/acpica/Subsystem/exoparg6.c b/sys/dev/acpi/acpica/Subsystem/exoparg6.c index 068f462e49b..1bbfc46baa4 100644 --- a/sys/dev/acpi/acpica/Subsystem/exoparg6.c +++ b/sys/dev/acpi/acpica/Subsystem/exoparg6.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg6 - AML execution - opcodes with 6 arguments - * xRevision: 13 $ + * xRevision: 23 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exoparg6.c,v 1.9 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exoparg6.c,v 1.10 2005/05/02 14:52:09 kochi Exp $"); #define __EXOPARG6_C__ @@ -153,87 +153,139 @@ __KERNEL_RCSID(0, "$NetBSD: exoparg6.c,v 1.9 2004/02/14 16:57:24 kochi Exp $"); * fully resolved operands. !*/ +/* Local prototypes */ + +static BOOLEAN +AcpiExDoMatch ( + UINT32 MatchOp, + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj); + /******************************************************************************* * * FUNCTION: AcpiExDoMatch * * PARAMETERS: MatchOp - The AML match operand - * PackageValue - Value from the target package - * MatchValue - Value to be matched + * PackageObj - Object from the target package + * MatchObj - Object to be matched * * RETURN: TRUE if the match is successful, FALSE otherwise * - * DESCRIPTION: Implements the low-level match for the ASL Match operator + * DESCRIPTION: Implements the low-level match for the ASL Match operator. + * Package elements will be implicitly converted to the type of + * the match object (Integer/Buffer/String). * ******************************************************************************/ -BOOLEAN +static BOOLEAN AcpiExDoMatch ( UINT32 MatchOp, - ACPI_INTEGER PackageValue, - ACPI_INTEGER MatchValue) + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj) { - + BOOLEAN LogicalResult = TRUE; + ACPI_STATUS Status; + + + /* + * Note: Since the PackageObj/MatchObj ordering is opposite to that of + * the standard logical operators, we have to reverse them when we call + * DoLogicalOp in order to make the implicit conversion rules work + * correctly. However, this means we have to flip the entire equation + * also. A bit ugly perhaps, but overall, better than fussing the + * parameters around at runtime, over and over again. + * + * Below, P[i] refers to the package element, M refers to the Match object. + */ switch (MatchOp) { - case MATCH_MTR: /* always true */ + case MATCH_MTR: - break; + /* Always true */ + break; - case MATCH_MEQ: /* true if equal */ + case MATCH_MEQ: - if (PackageValue != MatchValue) + /* + * True if equal: (P[i] == M) + * Change to: (M == P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } break; + case MATCH_MLE: - case MATCH_MLE: /* true if less than or equal */ - - if (PackageValue > MatchValue) + /* + * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M) + * Change to: (M >= P[i]) (M NotLess than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } + LogicalResult = (BOOLEAN) !LogicalResult; break; + case MATCH_MLT: - case MATCH_MLT: /* true if less than */ - - if (PackageValue >= MatchValue) + /* + * True if less than: (P[i] < M) + * Change to: (M > P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } break; + case MATCH_MGE: - case MATCH_MGE: /* true if greater than or equal */ - - if (PackageValue < MatchValue) + /* + * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M) + * Change to: (M <= P[i]) (M NotGreater than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } + LogicalResult = (BOOLEAN)!LogicalResult; break; + case MATCH_MGT: - case MATCH_MGT: /* true if greater than */ - - if (PackageValue <= MatchValue) + /* + * True if greater than: (P[i] > M) + * Change to: (M < P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } break; + default: - default: /* undefined */ + /* Undefined */ return (FALSE); } - - return TRUE; + return LogicalResult; } @@ -256,39 +308,46 @@ AcpiExOpcode_6A_0T_1R ( ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; ACPI_STATUS Status = AE_OK; - UINT32 Index; + ACPI_INTEGER Index; ACPI_OPERAND_OBJECT *ThisElement; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_6A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_6A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); switch (WalkState->Opcode) { case AML_MATCH_OP: /* - * Match (SearchPackage[0], MatchOp1[1], MatchObject1[2], - * MatchOp2[3], MatchObject2[4], StartIndex[5]) + * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2], + * MatchOp2[3], MatchObj2[4], StartIndex[5]) */ - /* Validate match comparison sub-opcodes */ + /* Validate both Match Term Operators (MTR, MEQ, etc.) */ if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) || (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "operation encoding out of range\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Match operator out of range\n")); Status = AE_AML_OPERAND_VALUE; goto Cleanup; } - Index = (UINT32) Operand[5]->Integer.Value; - if (Index >= (UINT32) Operand[0]->Package.Count) + /* Get the package StartIndex, validate against the package length */ + + Index = Operand[5]->Integer.Value; + if (Index >= Operand[0]->Package.Count) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index beyond package end\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Index (%X%8.8X) beyond package end (%X)\n", + ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); Status = AE_AML_PACKAGE_LIMIT; goto Cleanup; } + /* Create an integer for the return value */ + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { @@ -302,40 +361,42 @@ AcpiExOpcode_6A_0T_1R ( ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; /* - * Examine each element until a match is found. Within the loop, + * Examine each element until a match is found. Both match conditions + * must be satisfied for a match to occur. Within the loop, * "continue" signifies that the current element does not match * and the next should be examined. * * Upon finding a match, the loop will terminate via "break" at - * the bottom. If it terminates "normally", MatchValue will be -1 - * (its initial value) indicating that no match was found. When - * returned as a Number, this will produce the Ones value as specified. + * the bottom. If it terminates "normally", MatchValue will be + * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no + * match was found. */ for ( ; Index < Operand[0]->Package.Count; Index++) { + /* Get the current package element */ + ThisElement = Operand[0]->Package.Elements[Index]; - /* - * Treat any NULL or non-numeric elements as non-matching. - */ - if (!ThisElement || - ACPI_GET_OBJECT_TYPE (ThisElement) != ACPI_TYPE_INTEGER) + /* Treat any uninitialized (NULL) elements as non-matching */ + + if (!ThisElement) { continue; } /* - * "continue" (proceed to next iteration of enclosing - * "for" loop) signifies a non-match. + * Both match conditions must be satisfied. Execution of a continue + * (proceed to next iteration of enclosing for loop) signifies a + * non-match. */ if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, - ThisElement->Integer.Value, Operand[2]->Integer.Value)) + ThisElement, Operand[2])) { continue; } if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, - ThisElement->Integer.Value, Operand[4]->Integer.Value)) + ThisElement, Operand[4])) { continue; } @@ -345,7 +406,6 @@ AcpiExOpcode_6A_0T_1R ( ReturnDesc->Integer.Value = Index; break; } - break; @@ -357,13 +417,12 @@ AcpiExOpcode_6A_0T_1R ( default: - ACPI_REPORT_ERROR (("AcpiExOpcode_3A_0T_0R: Unknown opcode %X\n", + ACPI_REPORT_ERROR (("AcpiExOpcode_6A_0T_1R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } - WalkState->ResultObj = ReturnDesc; diff --git a/sys/dev/acpi/acpica/Subsystem/exprep.c b/sys/dev/acpi/acpica/Subsystem/exprep.c index dbf3c449814..ddd56a91a95 100644 --- a/sys/dev/acpi/acpica/Subsystem/exprep.c +++ b/sys/dev/acpi/acpica/Subsystem/exprep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities - * xRevision: 127 $ + * xRevision: 134 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exprep.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exprep.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXPREP_C__ @@ -129,8 +129,23 @@ __KERNEL_RCSID(0, "$NetBSD: exprep.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exprep") +/* Local prototypes */ + +static UINT32 +AcpiExDecodeFieldAccess ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT32 *ReturnByteAlignment); + #ifdef ACPI_UNDER_DEVELOPMENT + +static UINT32 +AcpiExGenerateAccess ( + UINT32 FieldBitOffset, + UINT32 FieldBitLength, + UINT32 RegionLength); + /******************************************************************************* * * FUNCTION: AcpiExGenerateAccess @@ -176,12 +191,14 @@ AcpiExGenerateAccess ( /* Round Field start offset and length to "minimal" byte boundaries */ FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8)); - FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + FieldBitOffset, 8)); + FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + + FieldBitOffset, 8)); FieldByteLength = FieldByteEndOffset - FieldByteOffset; ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Bit length %d, Bit offset %d\n", FieldBitLength, FieldBitOffset)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Byte Length %d, Byte Offset %d, End Offset %d\n", FieldByteLength, FieldByteOffset, FieldByteEndOffset)); @@ -195,21 +212,27 @@ AcpiExGenerateAccess ( for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1) { /* - * 1) Round end offset up to next access boundary and make sure that this - * does not go beyond the end of the parent region. - * 2) When the Access width is greater than the FieldByteLength, we are done. - * (This does not optimize for the perfectly aligned case yet). + * 1) Round end offset up to next access boundary and make sure that + * this does not go beyond the end of the parent region. + * 2) When the Access width is greater than the FieldByteLength, we + * are done. (This does not optimize for the perfectly aligned + * case yet). */ if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength) { - FieldStartOffset = ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / - AccessByteWidth; - FieldEndOffset = ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), - AccessByteWidth) / AccessByteWidth; - Accesses = FieldEndOffset - FieldStartOffset; + FieldStartOffset = + ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / + AccessByteWidth; + + FieldEndOffset = + ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), + AccessByteWidth) / AccessByteWidth; + + Accesses = FieldEndOffset - FieldStartOffset; ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "AccessWidth %d end is within region\n", AccessByteWidth)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Field Start %d, Field End %d -- requires %d accesses\n", FieldStartOffset, FieldEndOffset, Accesses)); @@ -219,8 +242,8 @@ AcpiExGenerateAccess ( if (Accesses <= 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Entire field can be accessed with one operation of size %d\n", - AccessByteWidth)); + "Entire field can be accessed with one operation of size %d\n", + AccessByteWidth)); return_VALUE (AccessByteWidth); } @@ -237,16 +260,21 @@ AcpiExGenerateAccess ( else { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "AccessWidth %d end is NOT within region\n", AccessByteWidth)); + "AccessWidth %d end is NOT within region\n", AccessByteWidth)); if (AccessByteWidth == 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Field goes beyond end-of-region!\n")); - return_VALUE (0); /* Field does not fit in the region at all */ - } - /* This width goes beyond the end-of-region, back off to previous access */ + /* Field does not fit in the region at all */ + return_VALUE (0); + } + + /* + * This width goes beyond the end-of-region, back off to + * previous access + */ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Backing off to previous optimal access width of %d\n", MinimumAccessWidth)); @@ -254,8 +282,10 @@ AcpiExGenerateAccess ( } } - /* Could not read/write field with one operation, just use max access width */ - + /* + * Could not read/write field with one operation, + * just use max access width + */ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Cannot access field in one operation, using width 8\n")); return_VALUE (8); @@ -267,8 +297,9 @@ AcpiExGenerateAccess ( * * FUNCTION: AcpiExDecodeFieldAccess * - * PARAMETERS: Access - Encoded field access bits - * Length - Field length. + * PARAMETERS: ObjDesc - Field object + * FieldFlags - Encoded fieldflags (contains access bits) + * ReturnByteAlignment - Where the byte alignment is returned * * RETURN: Field granularity (8, 16, 32 or 64) and * ByteAlignment (1, 2, 3, or 4) @@ -298,9 +329,10 @@ AcpiExDecodeFieldAccess ( case AML_FIELD_ACCESS_ANY: #ifdef ACPI_UNDER_DEVELOPMENT - ByteAlignment = AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.BitLength, - 0xFFFFFFFF /* Temp until we pass RegionLength as param */); + ByteAlignment = + AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */); BitLength = ByteAlignment * 8; #endif @@ -361,6 +393,7 @@ AcpiExDecodeFieldAccess ( * FieldFlags - Access, LockRule, and UpdateRule. * The format of a FieldFlag is described * in the ACPI specification + * FieldAttribute - Special attributes (not used) * FieldBitPosition - Field start position * FieldBitLength - Field length in number of bits * @@ -423,7 +456,9 @@ AcpiExPrepCommonFieldObject ( /* Setup width (access granularity) fields */ ObjDesc->CommonField.AccessByteWidth = (UINT8) - ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */ + ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */ + + ObjDesc->CommonField.AccessBitWidth = (UINT8) AccessBitWidth; /* * BaseByteOffset is the address of the start of the field within the @@ -448,28 +483,6 @@ AcpiExPrepCommonFieldObject ( (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset)); /* - * Valid bits -- the number of bits that compose a partial datum, - * 1) At the end of the field within the region (arbitrary starting bit - * offset) - * 2) At the end of a buffer used to contain the field (starting offset - * always zero) - */ - ObjDesc->CommonField.EndFieldValidBits = (UINT8) - ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) % - AccessBitWidth); - /* StartBufferBitOffset always = 0 */ - - ObjDesc->CommonField.EndBufferValidBits = (UINT8) - (FieldBitLength % AccessBitWidth); - - /* - * DatumValidBits is the number of valid field bits in the first - * field datum. - */ - ObjDesc->CommonField.DatumValidBits = (UINT8) - (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset); - - /* * Does the entire field fit within a single field access element? (datum) * (i.e., without crossing a datum boundary) */ @@ -487,11 +500,7 @@ AcpiExPrepCommonFieldObject ( * * FUNCTION: AcpiExPrepFieldValue * - * PARAMETERS: Node - Owning Node - * RegionNode - Region in which field is being defined - * FieldFlags - Access, LockRule, and UpdateRule. - * FieldBitPosition - Field start position - * FieldBitLength - Field length in number of bits + * PARAMETERS: Info - Contains all field creation info * * RETURN: Status * @@ -558,7 +567,7 @@ AcpiExPrepFieldValue ( { case ACPI_TYPE_LOCAL_REGION_FIELD: - ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); + ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); /* An additional reference for the container */ @@ -574,8 +583,10 @@ AcpiExPrepFieldValue ( case ACPI_TYPE_LOCAL_BANK_FIELD: ObjDesc->BankField.Value = Info->BankValue; - ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); - ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject (Info->RegisterNode); + ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject ( + Info->RegionNode); + ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); /* An additional reference for the attached objects */ @@ -594,14 +605,18 @@ AcpiExPrepFieldValue ( case ACPI_TYPE_LOCAL_INDEX_FIELD: - ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject (Info->RegisterNode); - ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject (Info->DataRegisterNode); + ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); + ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject ( + Info->DataRegisterNode); ObjDesc->IndexField.Value = (UINT32) - (Info->FieldBitPosition / ACPI_MUL_8 (ObjDesc->Field.AccessByteWidth)); + (Info->FieldBitPosition / ACPI_MUL_8 ( + ObjDesc->Field.AccessByteWidth)); if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) { ACPI_REPORT_ERROR (("Null Index Object during field prep\n")); + AcpiUtDeleteObjectDesc (ObjDesc); return_ACPI_STATUS (AE_AML_INTERNAL); } diff --git a/sys/dev/acpi/acpica/Subsystem/exregion.c b/sys/dev/acpi/acpica/Subsystem/exregion.c index 66cdf9933cf..3e5a1ca2dee 100644 --- a/sys/dev/acpi/acpica/Subsystem/exregion.c +++ b/sys/dev/acpi/acpica/Subsystem/exregion.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exregion - ACPI default OpRegion (address space) handlers - * xRevision: 86 $ + * xRevision: 90 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exregion.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exregion.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXREGION_C__ @@ -194,13 +194,12 @@ AcpiExSystemMemorySpaceHandler ( return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } - #ifndef ACPI_MISALIGNED_TRANSFERS /* * Hardware does not support non-aligned data transfers, we must verify * the request. */ - (void) AcpiUtShortDivide ((ACPI_INTEGER *) &Address, Length, NULL, &Remainder); + (void) AcpiUtShortDivide ((ACPI_INTEGER) Address, Length, NULL, &Remainder); if (Remainder != 0) { return_ACPI_STATUS (AE_AML_ALIGNMENT); @@ -214,7 +213,8 @@ AcpiExSystemMemorySpaceHandler ( */ if ((Address < MemInfo->MappedPhysicalAddress) || (((ACPI_INTEGER) Address + Length) > - ((ACPI_INTEGER) MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) + ((ACPI_INTEGER) + MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) { /* * The request cannot be resolved by the current memory mapping; @@ -232,7 +232,9 @@ AcpiExSystemMemorySpaceHandler ( * Don't attempt to map memory beyond the end of the region, and * constrain the maximum mapping size to something reasonable. */ - WindowSize = (ACPI_SIZE) ((MemInfo->Address + MemInfo->Length) - Address); + WindowSize = (ACPI_SIZE) + ((MemInfo->Address + MemInfo->Length) - Address); + if (WindowSize > ACPI_SYSMEM_REGION_WINDOW_SIZE) { WindowSize = ACPI_SYSMEM_REGION_WINDOW_SIZE; @@ -244,8 +246,9 @@ AcpiExSystemMemorySpaceHandler ( (void **) &MemInfo->MappedLogicalAddress); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X%8.8X, size %X\n", - ACPI_FORMAT_UINT64 (Address), (UINT32) WindowSize)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not map memory at %8.8X%8.8X, size %X\n", + ACPI_FORMAT_UINT64 (Address), (UINT32) WindowSize)); MemInfo->MappedLength = 0; return_ACPI_STATUS (Status); } @@ -261,10 +264,12 @@ AcpiExSystemMemorySpaceHandler ( * access */ LogicalAddrPtr = MemInfo->MappedLogicalAddress + - ((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); + ((ACPI_INTEGER) Address - + (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "SystemMemory %d (%d width) Address=%8.8X%8.8X\n", Function, BitWidth, + "SystemMemory %d (%d width) Address=%8.8X%8.8X\n", + Function, BitWidth, ACPI_FORMAT_UINT64 (Address))); /* @@ -386,13 +391,15 @@ AcpiExSystemIoSpaceHandler ( { case ACPI_READ: - Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) Address, &Value32, BitWidth); + Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) Address, + &Value32, BitWidth); *Value = Value32; break; case ACPI_WRITE: - Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) Address, (UINT32) *Value, BitWidth); + Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) Address, + (UINT32) *Value, BitWidth); break; default: @@ -464,12 +471,14 @@ AcpiExPciConfigSpaceHandler ( case ACPI_READ: *Value = 0; - Status = AcpiOsReadPciConfiguration (PciId, PciRegister, Value, BitWidth); + Status = AcpiOsReadPciConfiguration (PciId, PciRegister, + Value, BitWidth); break; case ACPI_WRITE: - Status = AcpiOsWritePciConfiguration (PciId, PciRegister, *Value, BitWidth); + Status = AcpiOsWritePciConfiguration (PciId, PciRegister, + *Value, BitWidth); break; default: @@ -594,8 +603,7 @@ AcpiExDataTableSpaceHandler ( LogicalAddrPtr = ACPI_PHYSADDR_TO_PTR (Address); - - /* Perform the memory read or write */ + /* Perform the memory read or write */ switch (Function) { diff --git a/sys/dev/acpi/acpica/Subsystem/exresnte.c b/sys/dev/acpi/acpica/Subsystem/exresnte.c index 66b7654f5a3..a2e6d4e1b43 100644 --- a/sys/dev/acpi/acpica/Subsystem/exresnte.c +++ b/sys/dev/acpi/acpica/Subsystem/exresnte.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresnte - AML Interpreter object resolution - * xRevision: 64 $ + * xRevision: 68 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exresnte.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exresnte.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXRESNTE_C__ @@ -185,11 +185,12 @@ AcpiExResolveNodeToValue ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n", Node, SourceDesc, AcpiUtGetTypeName (EntryType))); - if (EntryType == ACPI_TYPE_LOCAL_ALIAS) + if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) || + (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { /* There is always exactly one level of indirection */ - Node = (ACPI_NAMESPACE_NODE *) Node->Object; + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); SourceDesc = AcpiNsGetAttachedObject (Node); EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); *ObjectPtr = Node; @@ -296,15 +297,15 @@ AcpiExResolveNodeToValue ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead Node=%p SourceDesc=%p Type=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "FieldRead Node=%p SourceDesc=%p Type=%X\n", Node, SourceDesc, EntryType)); Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc); break; - /* - * For these objects, just return the object attached to the Node - */ + /* For these objects, just return the object attached to the Node */ + case ACPI_TYPE_MUTEX: case ACPI_TYPE_METHOD: case ACPI_TYPE_POWER: @@ -319,12 +320,12 @@ AcpiExResolveNodeToValue ( AcpiUtAddReference (ObjDesc); break; - /* TYPE_ANY is untyped, and thus there is no object associated with it */ case ACPI_TYPE_ANY: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Untyped entry %p, no attached object!\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Untyped entry %p, no attached object!\n", Node)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ @@ -346,7 +347,8 @@ AcpiExResolveNodeToValue ( default: /* No named references are allowed here */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported Reference opcode %X (%s)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unsupported Reference opcode %X (%s)\n", SourceDesc->Reference.Opcode, AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode))); @@ -355,11 +357,12 @@ AcpiExResolveNodeToValue ( break; - /* Default case is for unknown types */ - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Node %p - Unknown object type %X\n", + /* Default case is for unknown types */ + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Node %p - Unknown object type %X\n", Node, EntryType)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -367,7 +370,7 @@ AcpiExResolveNodeToValue ( } /* switch (EntryType) */ - /* Put the object descriptor on the stack */ + /* Return the object descriptor */ *ObjectPtr = (void *) ObjDesc; return_ACPI_STATUS (Status); diff --git a/sys/dev/acpi/acpica/Subsystem/exresolv.c b/sys/dev/acpi/acpica/Subsystem/exresolv.c index cdeefea04db..249a95a756b 100644 --- a/sys/dev/acpi/acpica/Subsystem/exresolv.c +++ b/sys/dev/acpi/acpica/Subsystem/exresolv.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresolv - AML Interpreter object resolution - * xRevision: 123 $ + * xRevision: 132 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exresolv.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exresolv.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXRESOLV_C__ @@ -131,6 +131,13 @@ __KERNEL_RCSID(0, "$NetBSD: exresolv.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exresolv") +/* Local prototypes */ + +static ACPI_STATUS +AcpiExResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + /******************************************************************************* * @@ -176,6 +183,12 @@ AcpiExResolveToValue ( { return_ACPI_STATUS (Status); } + + if (!*StackPtr) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } } /* @@ -202,18 +215,17 @@ AcpiExResolveToValue ( * * FUNCTION: AcpiExResolveObjectToValue * - * PARAMETERS: StackPtr - Pointer to a stack location that contains a - * ptr to an internal object. + * PARAMETERS: StackPtr - Pointer to an internal object * WalkState - Current method state * * RETURN: Status * - * DESCRIPTION: Retrieve the value from an internal object. The Reference type + * DESCRIPTION: Retrieve the value from an internal object. The Reference type * uses the associated AML opcode to determine the value. * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExResolveObjectToValue ( ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState) @@ -243,7 +255,7 @@ AcpiExResolveObjectToValue ( case AML_NAME_OP: /* - * Convert indirect name ptr to a direct name ptr. + * Convert name reference to a namespace node * Then, AcpiExResolveNodeToValue can be used to get the value */ TempNode = StackDesc->Reference.Object; @@ -252,7 +264,7 @@ AcpiExResolveObjectToValue ( AcpiUtRemoveReference (StackDesc); - /* Put direct name pointer onto stack and exit */ + /* Return the namespace node */ (*StackPtr) = TempNode; break; @@ -272,15 +284,15 @@ AcpiExResolveObjectToValue ( return_ACPI_STATUS (Status); } + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", + StackDesc->Reference.Offset, ObjDesc)); + /* * Now we can delete the original Reference Object and - * replace it with the resolve value + * replace it with the resolved value */ AcpiUtRemoveReference (StackDesc); *StackPtr = ObjDesc; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %d] ValueObj is %p\n", - StackDesc->Reference.Offset, ObjDesc)); break; @@ -343,10 +355,19 @@ AcpiExResolveObjectToValue ( break; + case AML_INT_NAMEPATH_OP: /* Reference to a named object */ + + /* Get the object pointed to by the namespace node */ + + *StackPtr = (StackDesc->Reference.Node)->Object; + AcpiUtAddReference (*StackPtr); + AcpiUtRemoveReference (StackDesc); + break; default: - ACPI_REPORT_ERROR (("During resolve, Unknown Reference opcode %X (%s) in %p\n", + ACPI_REPORT_ERROR (( + "During resolve, Unknown Reference opcode %X (%s) in %p\n", Opcode, AcpiPsGetOpcodeName (Opcode), StackDesc)); Status = AE_AML_INTERNAL; break; @@ -366,9 +387,8 @@ AcpiExResolveObjectToValue ( break; - /* - * These cases may never happen here, but just in case.. - */ + /* These cases may never happen here, but just in case.. */ + case ACPI_TYPE_BUFFER_FIELD: case ACPI_TYPE_LOCAL_REGION_FIELD: case ACPI_TYPE_LOCAL_BANK_FIELD: @@ -415,11 +435,44 @@ AcpiExResolveMultiple ( ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; ACPI_NAMESPACE_NODE *Node; ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiExResolveMultiple"); + /* Operand can be either a namespace node or an operand descriptor */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_OPERAND: + Type = ObjDesc->Common.Type; + break; + + case ACPI_DESC_TYPE_NAMED: + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + + /* If we had an Alias node, use the attached object for type info */ + + if (Type == ACPI_TYPE_LOCAL_ALIAS) + { + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + } + break; + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* If type is anything other than a reference, we are done */ + + if (Type != ACPI_TYPE_LOCAL_REFERENCE) + { + goto Exit; + } + /* * For reference objects created via the RefOf or Index operators, * we need to get to the base object (as per the ACPI specification @@ -440,8 +493,9 @@ AcpiExResolveMultiple ( if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR (("AcpiExResolveMultiple: Not a NS node %p [%s]\n", - Node, AcpiUtGetDescriptorName (Node))); + ACPI_REPORT_ERROR (( + "AcpiExResolveMultiple: Not a NS node %p [%s]\n", + Node, AcpiUtGetDescriptorName (Node))); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -483,6 +537,13 @@ AcpiExResolveMultiple ( * This could of course in turn be another reference object. */ ObjDesc = *(ObjDesc->Reference.Where); + if (!ObjDesc) + { + /* NULL package elements are allowed */ + + Type = 0; /* Uninitialized */ + goto Exit; + } break; @@ -496,8 +557,9 @@ AcpiExResolveMultiple ( if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR (("AcpiExResolveMultiple: Not a NS node %p [%s]\n", - Node, AcpiUtGetDescriptorName (Node))); + ACPI_REPORT_ERROR (( + "AcpiExResolveMultiple: Not a NS node %p [%s]\n", + Node, AcpiUtGetDescriptorName (Node))); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -521,6 +583,38 @@ AcpiExResolveMultiple ( break; + case AML_LOCAL_OP: + case AML_ARG_OP: + + if (ReturnDesc) + { + Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Opcode, + ObjDesc->Reference.Offset, WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiUtRemoveReference (ObjDesc); + } + else + { + Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Opcode, + ObjDesc->Reference.Offset, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Type = ACPI_TYPE_ANY; + goto Exit; + } + } + break; + + case AML_DEBUG_OP: /* The Debug Object is of type "DebugObject" */ @@ -531,7 +625,8 @@ AcpiExResolveMultiple ( default: - ACPI_REPORT_ERROR (("AcpiExResolveMultiple: Unknown Reference subtype %X\n", + ACPI_REPORT_ERROR (( + "AcpiExResolveMultiple: Unknown Reference subtype %X\n", ObjDesc->Reference.Opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); } diff --git a/sys/dev/acpi/acpica/Subsystem/exresop.c b/sys/dev/acpi/acpica/Subsystem/exresop.c index 7b7ec6af944..24fb46e13c5 100644 --- a/sys/dev/acpi/acpica/Subsystem/exresop.c +++ b/sys/dev/acpi/acpica/Subsystem/exresop.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresop - AML Interpreter operand/object resolution - * xRevision: 67 $ + * xRevision: 82 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exresop.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exresop.c,v 1.13 2005/05/02 14:52:09 kochi Exp $"); #define __EXRESOP_C__ @@ -129,6 +129,14 @@ __KERNEL_RCSID(0, "$NetBSD: exresop.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exresop") +/* Local prototypes */ + +static ACPI_STATUS +AcpiExCheckObjectType ( + ACPI_OBJECT_TYPE TypeNeeded, + ACPI_OBJECT_TYPE ThisType, + void *Object); + /******************************************************************************* * @@ -144,7 +152,7 @@ __KERNEL_RCSID(0, "$NetBSD: exresop.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExCheckObjectType ( ACPI_OBJECT_TYPE TypeNeeded, ACPI_OBJECT_TYPE ThisType, @@ -223,6 +231,7 @@ AcpiExResolveOperands ( const ACPI_OPCODE_INFO *OpInfo; UINT32 ThisArgType; ACPI_OBJECT_TYPE TypeNeeded; + UINT16 TargetOp = 0; ACPI_FUNCTION_TRACE_U32 ("ExResolveOperands", Opcode); @@ -243,7 +252,8 @@ AcpiExResolveOperands ( return_ACPI_STATUS (AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] OperandTypes=%X \n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Opcode %X [%s] RequiredOperandTypes=%8.8X \n", Opcode, OpInfo->Name, ArgTypes)); /* @@ -273,7 +283,7 @@ AcpiExResolveOperands ( { case ACPI_DESC_TYPE_NAMED: - /* Node */ + /* Namespace Node */ ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; break; @@ -289,7 +299,8 @@ AcpiExResolveOperands ( if (!AcpiUtValidObjectType (ObjectType)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad operand object type [%X]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Bad operand object type [%X]\n", ObjectType)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -297,9 +308,8 @@ AcpiExResolveOperands ( if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) { - /* - * Decode the Reference - */ + /* Decode the Reference */ + OpInfo = AcpiPsGetOpcodeInfo (Opcode); if (OpInfo->Class == AML_CLASS_UNKNOWN) { @@ -309,20 +319,26 @@ AcpiExResolveOperands ( switch (ObjDesc->Reference.Opcode) { case AML_DEBUG_OP: + TargetOp = AML_DEBUG_OP; + + /*lint -fallthrough */ + case AML_NAME_OP: case AML_INDEX_OP: case AML_REF_OF_OP: case AML_ARG_OP: case AML_LOCAL_OP: - case AML_LOAD_OP: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ + case AML_LOAD_OP: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ + case AML_INT_NAMEPATH_OP: /* Reference to a named object */ ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Reference Opcode: %s\n", OpInfo->Name))); + "Operand is a Reference, RefOpcode [%s]\n", + (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name))); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown Reference Opcode %X [%s]\n", + "Operand is a Reference, Unknown Reference Opcode %X [%s]\n", ObjDesc->Reference.Opcode, (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name)); @@ -343,10 +359,8 @@ AcpiExResolveOperands ( return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } + /* Get one argument type, point to the next */ - /* - * Get one argument type, point to the next - */ ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); INCREMENT_ARG_LIST (ArgTypes); @@ -362,26 +376,31 @@ AcpiExResolveOperands ( (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_STRING)) { /* - * String found - the string references a named object and must be - * resolved to a node + * String found - the string references a named object and + * must be resolved to a node */ goto NextOperand; } - /* Else not a string - fall through to the normal Reference case below */ + /* + * Else not a string - fall through to the normal Reference + * case below + */ /*lint -fallthrough */ case ARGI_REFERENCE: /* References: */ case ARGI_INTEGER_REF: case ARGI_OBJECT_REF: case ARGI_DEVICE_REF: - case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ - case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ - case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ + case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ + case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ + case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ - /* Need an operand of type ACPI_TYPE_LOCAL_REFERENCE */ - - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */ + /* + * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE + * A Namespace Node is OK as-is + */ + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) { goto NextOperand; } @@ -393,12 +412,10 @@ AcpiExResolveOperands ( return_ACPI_STATUS (Status); } - if (AML_NAME_OP == ObjDesc->Reference.Opcode) + if (ObjDesc->Reference.Opcode == AML_NAME_OP) { - /* - * Convert an indirect name ptr to direct name ptr and put - * it on the stack - */ + /* Convert a named reference to the actual named object */ + TempNode = ObjDesc->Reference.Object; AcpiUtRemoveReference (ObjDesc); (*StackPtr) = TempNode; @@ -406,7 +423,7 @@ AcpiExResolveOperands ( goto NextOperand; - case ARGI_ANYTYPE: + case ARGI_DATAREFOBJ: /* Store operator only */ /* * We don't want to resolve IndexOp reference objects during @@ -427,7 +444,6 @@ AcpiExResolveOperands ( break; } - /* * Resolve this object to a value */ @@ -489,14 +505,14 @@ AcpiExResolveOperands ( /* * The more complex cases allow multiple resolved object types */ - case ARGI_INTEGER: /* Number */ + case ARGI_INTEGER: /* * Need an operand of type ACPI_TYPE_INTEGER, * But we can implicitly convert from a STRING or BUFFER * Aka - "Implicit Source Operand Conversion" */ - Status = AcpiExConvertToInteger (ObjDesc, StackPtr, WalkState); + Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) @@ -520,7 +536,7 @@ AcpiExResolveOperands ( * But we can implicitly convert from a STRING or INTEGER * Aka - "Implicit Source Operand Conversion" */ - Status = AcpiExConvertToBuffer (ObjDesc, StackPtr, WalkState); + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) @@ -544,7 +560,8 @@ AcpiExResolveOperands ( * But we can implicitly convert from a BUFFER or INTEGER * Aka - "Implicit Source Operand Conversion" */ - Status = AcpiExConvertToString (ObjDesc, StackPtr, 16, ACPI_UINT32_MAX, WalkState); + Status = AcpiExConvertToString (ObjDesc, StackPtr, + ACPI_IMPLICIT_CONVERT_HEX); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) @@ -600,7 +617,7 @@ AcpiExResolveOperands ( /* Highest priority conversion is to type Buffer */ - Status = AcpiExConvertToBuffer (ObjDesc, StackPtr, WalkState); + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -670,7 +687,7 @@ AcpiExResolveOperands ( case ARGI_REGION_OR_FIELD: - /* Need an operand of type ACPI_TYPE_REGION or a FIELD in a region */ + /* Need an operand of type REGION or a FIELD in a region */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -692,6 +709,54 @@ AcpiExResolveOperands ( goto NextOperand; + case ARGI_DATAREFOBJ: + + /* Used by the Store() operator only */ + + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REFERENCE: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + case ACPI_TYPE_DDB_HANDLE: + + /* Valid operand */ + break; + + default: + + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Enable original behavior of Store(), allowing any and all + * objects as the source operand. The ACPI spec does not + * allow this, however. + */ + break; + } + + if (TargetOp == AML_DEBUG_OP) + { + /* Allow store of any object to the Debug object */ + + break; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + default: /* Unknown type */ @@ -723,8 +788,7 @@ NextOperand: { StackPtr--; } - - } /* while (*Types) */ + } return_ACPI_STATUS (Status); } diff --git a/sys/dev/acpi/acpica/Subsystem/exstore.c b/sys/dev/acpi/acpica/Subsystem/exstore.c index 8710683f4a9..a7a5dd3518e 100644 --- a/sys/dev/acpi/acpica/Subsystem/exstore.c +++ b/sys/dev/acpi/acpica/Subsystem/exstore.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exstore - AML Interpreter object store support - * xRevision: 180 $ + * xRevision: 194 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exstore.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exstore.c,v 1.12 2005/05/02 14:52:09 kochi Exp $"); #define __EXSTORE_C__ @@ -125,11 +125,187 @@ __KERNEL_RCSID(0, "$NetBSD: exstore.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" +#include "acparser.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exstore") +/* Local prototypes */ + +static void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index); + +static ACPI_STATUS +AcpiExStoreObjectToIndex ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoDebugObject + * + * PARAMETERS: SourceDesc - Value to be stored + * Level - Indentation level (used for packages) + * Index - Current package element, zero if not pkg + * + * RETURN: None + * + * DESCRIPTION: Handles stores to the Debug Object. + * + ******************************************************************************/ + +static void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR ("ExDoDebugObject", SourceDesc); + + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", + Level, " ")); + + /* Display index for package output only */ + + if (Index > 0) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + "(%.2u) ", Index -1)); + } + + if (!SourceDesc) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "<Null Object>\n")); + return_VOID; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: ", + AcpiUtGetObjectTypeName (SourceDesc))); + + if (!AcpiUtValidInternalObject (SourceDesc)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + "%p, Invalid Internal Object!\n", SourceDesc)); + return_VOID; + } + } + else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", + AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), + SourceDesc)); + return_VOID; + } + else + { + return_VOID; + } + + switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) + { + case ACPI_TYPE_INTEGER: + + /* Output correct integer width */ + + if (AcpiGbl_IntegerByteWidth == 4) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", + (UINT32) SourceDesc->Integer.Value)); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value))); + } + break; + + case ACPI_TYPE_BUFFER: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]", + (UINT32) SourceDesc->Buffer.Length)); + ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, + (SourceDesc->Buffer.Length < 32) ? SourceDesc->Buffer.Length : 32); + break; + + case ACPI_TYPE_STRING: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", + SourceDesc->String.Length, SourceDesc->String.Pointer)); + break; + + case ACPI_TYPE_PACKAGE: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X Elements]\n", + SourceDesc->Package.Count)); + + /* Output the entire contents of the package */ + + for (i = 0; i < SourceDesc->Package.Count; i++) + { + AcpiExDoDebugObject (SourceDesc->Package.Elements[i], + Level+4, i+1); + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + + if (SourceDesc->Reference.Opcode == AML_INDEX_OP) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s, 0x%X]\n", + AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode), + SourceDesc->Reference.Offset)); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s]\n", + AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode))); + } + + + if (SourceDesc->Reference.Object) + { + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == + ACPI_DESC_TYPE_NAMED) + { + AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) + SourceDesc->Reference.Object)->Object, + Level+4, 0); + } + else + { + AcpiExDoDebugObject (SourceDesc->Reference.Object, Level+4, 0); + } + } + else if (SourceDesc->Reference.Node) + { + AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, + Level+4, 0); + } + break; + + default: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p %s\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); + break; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); + return_VOID; +} + /******************************************************************************* * @@ -181,7 +357,8 @@ AcpiExStore ( * Storing an object into a Named node. */ Status = AcpiExStoreObjectToNode (SourceDesc, - (ACPI_NAMESPACE_NODE *) DestDesc, WalkState); + (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, + ACPI_IMPLICIT_CONVERSION); return_ACPI_STATUS (Status); } @@ -209,7 +386,8 @@ AcpiExStore ( /* Destination is not a Reference object */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Destination is not a Reference or Constant object [%p]\n", DestDesc)); + "Target is not a Reference or Constant object - %s [%p]\n", + AcpiUtGetObjectTypeName (DestDesc), DestDesc)); ACPI_DUMP_STACK_ENTRY (SourceDesc); ACPI_DUMP_STACK_ENTRY (DestDesc); @@ -234,8 +412,9 @@ AcpiExStore ( /* Storing an object into a Name "container" */ - Status = AcpiExStoreObjectToNode (SourceDesc, RefDesc->Reference.Object, - WalkState); + Status = AcpiExStoreObjectToNode (SourceDesc, + RefDesc->Reference.Object, + WalkState, ACPI_IMPLICIT_CONVERSION); break; @@ -253,7 +432,7 @@ AcpiExStore ( /* Store to a method local/arg */ Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode, - RefDesc->Reference.Offset, SourceDesc, WalkState); + RefDesc->Reference.Offset, SourceDesc, WalkState); break; @@ -263,51 +442,11 @@ AcpiExStore ( * Storing to the Debug object causes the value stored to be * displayed and otherwise has no effect -- see ACPI Specification */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Write to Debug Object: ****:\n\n")); - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ", - AcpiUtGetObjectTypeName (SourceDesc))); - - switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) - { - case ACPI_TYPE_INTEGER: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value))); - break; - - - case ACPI_TYPE_BUFFER: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X", - (UINT32) SourceDesc->Buffer.Length)); - ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, - (SourceDesc->Buffer.Length < 32) ? SourceDesc->Buffer.Length : 32); - break; - - - case ACPI_TYPE_STRING: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X, \"%s\"\n", - SourceDesc->String.Length, SourceDesc->String.Pointer)); - break; - - - case ACPI_TYPE_PACKAGE: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Size 0x%.2X Elements Ptr - %p\n", - SourceDesc->Package.Count, SourceDesc->Package.Elements)); - break; - - - default: - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n", - SourceDesc)); - break; - } + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** Write to Debug Object: Object %p %s ****:\n\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); + AcpiExDoDebugObject (SourceDesc, 0, 0); break; @@ -339,7 +478,7 @@ AcpiExStore ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExStoreObjectToIndex ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *IndexDesc, @@ -363,60 +502,55 @@ AcpiExStoreObjectToIndex ( { case ACPI_TYPE_PACKAGE: /* - * Storing to a package element is not simple. The source must be - * evaluated and converted to the type of the destination and then the - * source is copied into the destination - we can't just point to the - * source object. - */ - /* + * Storing to a package element. Copy the object and replace + * any existing object with the new object. No implicit + * conversion is performed. + * * The object at *(IndexDesc->Reference.Where) is the * element within the package that is to be modified. * The parent package object is at IndexDesc->Reference.Object */ ObjDesc = *(IndexDesc->Reference.Where); - /* Do the conversion/store */ - - Status = AcpiExStoreObjectToObject (SourceDesc, ObjDesc, &NewDesc, - WalkState); + Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not store object to indexed package element\n")); return_ACPI_STATUS (Status); } - /* - * If a new object was created, we must install it as the new - * package element - */ - if (NewDesc != ObjDesc) + if (ObjDesc) { - AcpiUtRemoveReference (ObjDesc); - *(IndexDesc->Reference.Where) = NewDesc; - - /* If same as the original source, add a reference */ + /* Decrement reference count by the ref count of the parent package */ - if (NewDesc == SourceDesc) + for (i = 0; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) { - AcpiUtAddReference (NewDesc); + AcpiUtRemoveReference (ObjDesc); } + } - /* Increment reference count by the ref count of the parent package -1 */ + *(IndexDesc->Reference.Where) = NewDesc; - for (i = 1; i < ((ACPI_OPERAND_OBJECT *) IndexDesc->Reference.Object)->Common.ReferenceCount; i++) - { - AcpiUtAddReference (NewDesc); - } + /* Increment ref count by the ref count of the parent package-1 */ + + for (i = 1; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) + { + AcpiUtAddReference (NewDesc); } + break; case ACPI_TYPE_BUFFER_FIELD: /* - * Store into a Buffer (not actually a real BufferField) at a - * location defined by an Index. + * Store into a Buffer or String (not actually a real BufferField) + * at a location defined by an Index. * * The first 8-bit element of the source object is written to the * 8-bit Buffer location defined by the Index destination object, @@ -424,10 +558,13 @@ AcpiExStoreObjectToIndex ( */ /* - * Make sure the target is a Buffer + * Make sure the target is a Buffer or String. An error should + * not happen here, since the ReferenceObject was constructed + * by the INDEX_OP code. */ ObjDesc = IndexDesc->Reference.Object; - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) + if ((ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) && + (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_STRING)) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -446,13 +583,11 @@ AcpiExStoreObjectToIndex ( break; case ACPI_TYPE_BUFFER: - - Value = SourceDesc->Buffer.Pointer[0]; - break; - case ACPI_TYPE_STRING: - Value = (UINT8) SourceDesc->String.Pointer[0]; + /* Note: Takes advantage of common string/buffer fields */ + + Value = SourceDesc->Buffer.Pointer[0]; break; default: @@ -489,6 +624,7 @@ AcpiExStoreObjectToIndex ( * PARAMETERS: SourceDesc - Value to be stored * Node - Named object to receive the value * WalkState - Current walk state + * ImplicitConversion - Perform implicit conversion (yes/no) * * RETURN: Status * @@ -511,7 +647,8 @@ ACPI_STATUS AcpiExStoreObjectToNode ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node, - ACPI_WALK_STATE *WalkState) + ACPI_WALK_STATE *WalkState, + UINT8 ImplicitConversion) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *TargetDesc; @@ -522,9 +659,8 @@ AcpiExStoreObjectToNode ( ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc); - /* - * Get current type of the node, and object attached to Node - */ + /* Get current type of the node, and object attached to Node */ + TargetType = AcpiNsGetType (Node); TargetDesc = AcpiNsGetAttachedObject (Node); @@ -542,9 +678,17 @@ AcpiExStoreObjectToNode ( return_ACPI_STATUS (Status); } - /* - * Do the actual store operation - */ + /* If no implicit conversion, drop into the default case below */ + + if (!ImplicitConversion) + { + /* Force execution of default (no implicit conversion) */ + + TargetType = ACPI_TYPE_ANY; + } + + /* Do the actual store operation */ + switch (TargetType) { case ACPI_TYPE_BUFFER_FIELD: @@ -552,10 +696,10 @@ AcpiExStoreObjectToNode ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - /* - * For fields, copy the source data to the target field. - */ - Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, &WalkState->ResultObj); + /* For fields, copy the source data to the target field. */ + + Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, + &WalkState->ResultObj); break; @@ -569,7 +713,8 @@ AcpiExStoreObjectToNode ( * * Copy and/or convert the source object to a new target object */ - Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, &NewDesc, WalkState); + Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, + &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -604,7 +749,8 @@ AcpiExStoreObjectToNode ( /* No conversions for all other types. Just attach the source object */ - Status = AcpiNsAttachObject (Node, SourceDesc, ACPI_GET_OBJECT_TYPE (SourceDesc)); + Status = AcpiNsAttachObject (Node, SourceDesc, + ACPI_GET_OBJECT_TYPE (SourceDesc)); break; } diff --git a/sys/dev/acpi/acpica/Subsystem/exstoren.c b/sys/dev/acpi/acpica/Subsystem/exstoren.c index a989587aac8..44d6faab348 100644 --- a/sys/dev/acpi/acpica/Subsystem/exstoren.c +++ b/sys/dev/acpi/acpica/Subsystem/exstoren.c @@ -3,7 +3,7 @@ * * Module Name: exstoren - AML Interpreter object store support, * Store to Node (namespace object) - * xRevision: 58 $ + * xRevision: 63 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exstoren.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exstoren.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXSTOREN_C__ @@ -158,9 +158,8 @@ AcpiExResolveObject ( ACPI_FUNCTION_TRACE ("ExResolveObject"); - /* - * Ensure we have a Target that can be stored to - */ + /* Ensure we have a Target that can be stored to */ + switch (TargetType) { case ACPI_TYPE_BUFFER_FIELD: @@ -199,17 +198,15 @@ AcpiExResolveObject ( break; } - /* - * Must have a Integer, Buffer, or String - */ + /* Must have a Integer, Buffer, or String */ + if ((ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_INTEGER) && (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER) && (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_STRING) && !((ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_LOCAL_REFERENCE) && (SourceDesc->Reference.Opcode == AML_LOAD_OP))) { - /* - * Conversion successful but still not a valid type - */ + /* Conversion successful but still not a valid type */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", AcpiUtGetObjectTypeName (SourceDesc), @@ -220,10 +217,10 @@ AcpiExResolveObject ( case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_METHOD_ALIAS: + + /* Aliases are resolved by AcpiExPrepOperands */ - /* - * Aliases are resolved by AcpiExPrepOperands - */ ACPI_REPORT_ERROR (("Store into Alias - should never happen\n")); Status = AE_AML_INTERNAL; break; @@ -315,8 +312,8 @@ AcpiExStoreObjectToObject ( * Otherwise, ActualSrcDesc is a temporary object to hold the * converted object. */ - Status = AcpiExConvertToTargetType (ACPI_GET_OBJECT_TYPE (DestDesc), SourceDesc, - &ActualSrcDesc, WalkState); + Status = AcpiExConvertToTargetType (ACPI_GET_OBJECT_TYPE (DestDesc), + SourceDesc, &ActualSrcDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -325,7 +322,7 @@ AcpiExStoreObjectToObject ( if (SourceDesc == ActualSrcDesc) { /* - * No conversion was performed. Return the SourceDesc as the + * No conversion was performed. Return the SourceDesc as the * new object. */ *NewDesc = SourceDesc; @@ -355,12 +352,17 @@ AcpiExStoreObjectToObject ( case ACPI_TYPE_BUFFER: + /* + * Note: There is different store behavior depending on the original + * source type + */ Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc); break; case ACPI_TYPE_PACKAGE: - Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, WalkState); + Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, + WalkState); break; default: diff --git a/sys/dev/acpi/acpica/Subsystem/exstorob.c b/sys/dev/acpi/acpica/Subsystem/exstorob.c index bc92022f7a4..d2e445ccd7c 100644 --- a/sys/dev/acpi/acpica/Subsystem/exstorob.c +++ b/sys/dev/acpi/acpica/Subsystem/exstorob.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exstorob - AML Interpreter object store support, store to object - * xRevision: 51 $ + * xRevision: 57 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exstorob.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exstorob.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXSTOROB_C__ @@ -153,9 +153,8 @@ AcpiExStoreBufferToBuffer ( ACPI_FUNCTION_TRACE_PTR ("ExStoreBufferToBuffer", SourceDesc); - /* - * We know that SourceDesc is a buffer by now - */ + /* We know that SourceDesc is a buffer by now */ + Buffer = (UINT8 *) SourceDesc->Buffer.Pointer; Length = SourceDesc->Buffer.Length; @@ -172,36 +171,57 @@ AcpiExStoreBufferToBuffer ( return_ACPI_STATUS (AE_NO_MEMORY); } - TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; TargetDesc->Buffer.Length = Length; } - /* - * Buffer is a static allocation, - * only place what will fit in the buffer. - */ + /* Copy source buffer to target buffer */ + if (Length <= TargetDesc->Buffer.Length) { /* Clear existing buffer and copy in the new one */ ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length); + +#ifdef ACPI_OBSOLETE_BEHAVIOR + /* + * NOTE: ACPI versions up to 3.0 specified that the buffer must be + * truncated if the string is smaller than the buffer. However, "other" + * implementations of ACPI never did this and thus became the defacto + * standard. ACPI 3.0A changes this behavior such that the buffer + * is no longer truncated. + */ + + /* + * OBSOLETE BEHAVIOR: + * If the original source was a string, we must truncate the buffer, + * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer + * copy must not truncate the original buffer. + */ + if (OriginalSrcType == ACPI_TYPE_STRING) + { + /* Set the new length of the target */ + + TargetDesc->Buffer.Length = Length; + } +#endif } else { - /* - * Truncate the source, copy only what will fit - */ - ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, TargetDesc->Buffer.Length); + /* Truncate the source, copy only what will fit */ + + ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, + TargetDesc->Buffer.Length); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Truncating src buffer from %X to %X\n", + "Truncating source buffer from %X to %X\n", Length, TargetDesc->Buffer.Length)); } /* Copy flags */ TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags; + TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; return_ACPI_STATUS (AE_OK); } @@ -231,9 +251,8 @@ AcpiExStoreStringToString ( ACPI_FUNCTION_TRACE_PTR ("ExStoreStringToString", SourceDesc); - /* - * We know that SourceDesc is a string by now. - */ + /* We know that SourceDesc is a string by now */ + Buffer = (UINT8 *) SourceDesc->String.Pointer; Length = SourceDesc->String.Length; @@ -248,7 +267,8 @@ AcpiExStoreStringToString ( * String will fit in existing non-static buffer. * Clear old string and copy in the new one */ - ACPI_MEMSET (TargetDesc->String.Pointer, 0, (ACPI_SIZE) TargetDesc->String.Length + 1); + ACPI_MEMSET (TargetDesc->String.Pointer, 0, + (ACPI_SIZE) TargetDesc->String.Length + 1); ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); } else @@ -260,13 +280,13 @@ AcpiExStoreStringToString ( if (TargetDesc->String.Pointer && (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) { - /* - * Only free if not a pointer into the DSDT - */ + /* Only free if not a pointer into the DSDT */ + ACPI_MEM_FREE (TargetDesc->String.Pointer); } - TargetDesc->String.Pointer = ACPI_MEM_CALLOCATE ((ACPI_SIZE) Length + 1); + TargetDesc->String.Pointer = ACPI_MEM_CALLOCATE ( + (ACPI_SIZE) Length + 1); if (!TargetDesc->String.Pointer) { return_ACPI_STATUS (AE_NO_MEMORY); diff --git a/sys/dev/acpi/acpica/Subsystem/exsystem.c b/sys/dev/acpi/acpica/Subsystem/exsystem.c index 96316bedd96..1c6f69a7963 100644 --- a/sys/dev/acpi/acpica/Subsystem/exsystem.c +++ b/sys/dev/acpi/acpica/Subsystem/exsystem.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exsystem - Interface to OS services - * xRevision: 80 $ + * xRevision: 84 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exsystem.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exsystem.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXSYSTEM_C__ @@ -132,8 +132,8 @@ __KERNEL_RCSID(0, "$NetBSD: exsystem.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * * FUNCTION: AcpiExSystemWaitSemaphore * - * PARAMETERS: Semaphore - OSD semaphore to wait on - * Timeout - Max time to wait + * PARAMETERS: Semaphore - Semaphore to wait on + * Timeout - Max time to wait * * RETURN: Status * @@ -169,7 +169,8 @@ AcpiExSystemWaitSemaphore ( Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*** Thread awake after blocking, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", AcpiFormatException (Status))); /* Reacquire the interpreter */ @@ -191,8 +192,8 @@ AcpiExSystemWaitSemaphore ( * * FUNCTION: AcpiExSystemDoStall * - * PARAMETERS: HowLong - The amount of time to stall, - * in microseconds + * PARAMETERS: HowLong - The amount of time to stall, + * in microseconds * * RETURN: Status * @@ -222,7 +223,8 @@ AcpiExSystemDoStall ( * (ACPI specifies 100 usec as max, but this gives some slack in * order to support existing BIOSs) */ - ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n", HowLong)); + ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n", + HowLong)); Status = AE_AML_OPERAND_VALUE; } else @@ -238,8 +240,8 @@ AcpiExSystemDoStall ( * * FUNCTION: AcpiExSystemDoSuspend * - * PARAMETERS: HowLong - The amount of time to suspend, - * in milliseconds + * PARAMETERS: HowLong - The amount of time to suspend, + * in milliseconds * * RETURN: None * @@ -249,7 +251,7 @@ AcpiExSystemDoStall ( ACPI_STATUS AcpiExSystemDoSuspend ( - UINT32 HowLong) + ACPI_INTEGER HowLong) { ACPI_STATUS Status; @@ -261,8 +263,7 @@ AcpiExSystemDoSuspend ( AcpiExExitInterpreter (); - AcpiOsSleep ((UINT16) (HowLong / (UINT32) 1000), - (UINT16) (HowLong % (UINT32) 1000)); + AcpiOsSleep (HowLong); /* And now we must get the interpreter again */ @@ -275,8 +276,8 @@ AcpiExSystemDoSuspend ( * * FUNCTION: AcpiExSystemAcquireMutex * - * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor - * *ObjDesc - The object descriptor for this op + * PARAMETERS: TimeDesc - The 'time to delay' object descriptor + * ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -302,9 +303,8 @@ AcpiExSystemAcquireMutex ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Support for the _GL_ Mutex object -- go get the global lock - */ + /* Support for the _GL_ Mutex object -- go get the global lock */ + if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) { Status = AcpiEvAcquireGlobalLock ((UINT16) TimeDesc->Integer.Value); @@ -312,7 +312,7 @@ AcpiExSystemAcquireMutex ( } Status = AcpiExSystemWaitSemaphore (ObjDesc->Mutex.Semaphore, - (UINT16) TimeDesc->Integer.Value); + (UINT16) TimeDesc->Integer.Value); return_ACPI_STATUS (Status); } @@ -321,7 +321,7 @@ AcpiExSystemAcquireMutex ( * * FUNCTION: AcpiExSystemReleaseMutex * - * PARAMETERS: *ObjDesc - The object descriptor for this op + * PARAMETERS: ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -347,9 +347,8 @@ AcpiExSystemReleaseMutex ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Support for the _GL_ Mutex object -- release the global lock - */ + /* Support for the _GL_ Mutex object -- release the global lock */ + if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) { Status = AcpiEvReleaseGlobalLock (); @@ -365,9 +364,9 @@ AcpiExSystemReleaseMutex ( * * FUNCTION: AcpiExSystemSignalEvent * - * PARAMETERS: *ObjDesc - The object descriptor for this op + * PARAMETERS: ObjDesc - The object descriptor for this op * - * RETURN: AE_OK + * RETURN: Status * * DESCRIPTION: Provides an access point to perform synchronization operations * within the AML. @@ -397,8 +396,8 @@ AcpiExSystemSignalEvent ( * * FUNCTION: AcpiExSystemWaitEvent * - * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor - * *ObjDesc - The object descriptor for this op + * PARAMETERS: TimeDesc - The 'time to delay' object descriptor + * ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -422,7 +421,7 @@ AcpiExSystemWaitEvent ( if (ObjDesc) { Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.Semaphore, - (UINT16) TimeDesc->Integer.Value); + (UINT16) TimeDesc->Integer.Value); } return_ACPI_STATUS (Status); @@ -433,7 +432,7 @@ AcpiExSystemWaitEvent ( * * FUNCTION: AcpiExSystemResetEvent * - * PARAMETERS: *ObjDesc - The object descriptor for this op + * PARAMETERS: ObjDesc - The object descriptor for this op * * RETURN: Status * diff --git a/sys/dev/acpi/acpica/Subsystem/exutils.c b/sys/dev/acpi/acpica/Subsystem/exutils.c index bfb9b470c1c..7bc1fbd891f 100644 --- a/sys/dev/acpi/acpica/Subsystem/exutils.c +++ b/sys/dev/acpi/acpica/Subsystem/exutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exutils - interpreter/scanner utilities - * xRevision: 111 $ + * xRevision: 116 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exutils.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exutils.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __EXUTILS_C__ @@ -144,22 +144,31 @@ __KERNEL_RCSID(0, "$NetBSD: exutils.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exutils") +/* Local prototypes */ + +static UINT32 +AcpiExDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base); -#ifndef ACPI_NO_METHOD_EXECUTION +#ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* * * FUNCTION: AcpiExEnterInterpreter * * PARAMETERS: None * + * RETURN: Status + * * DESCRIPTION: Enter the interpreter execution region. Failure to enter * the interpreter region is a fatal system error * ******************************************************************************/ ACPI_STATUS -AcpiExEnterInterpreter (void) +AcpiExEnterInterpreter ( + void) { ACPI_STATUS Status; @@ -182,6 +191,8 @@ AcpiExEnterInterpreter (void) * * PARAMETERS: None * + * RETURN: None + * * DESCRIPTION: Exit the interpreter execution region * * Cases where the interpreter is unlocked: @@ -197,7 +208,8 @@ AcpiExEnterInterpreter (void) ******************************************************************************/ void -AcpiExExitInterpreter (void) +AcpiExExitInterpreter ( + void) { ACPI_STATUS Status; @@ -296,7 +308,8 @@ AcpiExAcquireGlobalLock ( } else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not acquire Global Lock, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not acquire Global Lock, %s\n", AcpiFormatException (Status))); } } @@ -312,7 +325,7 @@ AcpiExAcquireGlobalLock ( * PARAMETERS: LockedByMe - Return value from corresponding call to * AcquireGlobalLock. * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Release the global lock if it is locked. * @@ -355,38 +368,41 @@ AcpiExReleaseGlobalLock ( * PARAMETERS: Value - Value to be represented * Base - Base of representation * - * RETURN: the number of digits needed to represent Value in Base + * RETURN: The number of digits. + * + * DESCRIPTION: Calculate the number of digits needed to represent the Value + * in the given Base (Radix) * ******************************************************************************/ -UINT32 +static UINT32 AcpiExDigitsNeeded ( ACPI_INTEGER Value, UINT32 Base) { UINT32 NumDigits; ACPI_INTEGER CurrentValue; - ACPI_INTEGER Quotient; ACPI_FUNCTION_TRACE ("ExDigitsNeeded"); - /* - * ACPI_INTEGER is unsigned, so we don't worry about a '-' - */ - if ((CurrentValue = Value) == 0) + /* ACPI_INTEGER is unsigned, so we don't worry about a '-' prefix */ + + if (Value == 0) { return_VALUE (1); } + CurrentValue = Value; NumDigits = 0; + /* Count the digits in the requested base */ + while (CurrentValue) { - (void) AcpiUtShortDivide (&CurrentValue, Base, &Quotient, NULL); + (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL); NumDigits++; - CurrentValue = Quotient; } return_VALUE (NumDigits); @@ -400,6 +416,8 @@ AcpiExDigitsNeeded ( * PARAMETERS: NumericId - EISA ID to be converted * OutString - Where to put the converted string (8 bytes) * + * RETURN: None + * * DESCRIPTION: Convert a numeric EISA ID to string representation * ******************************************************************************/ @@ -437,7 +455,10 @@ AcpiExEisaIdToString ( * PARAMETERS: Value - Value to be converted * OutString - Where to put the converted string (8 bytes) * - * RETURN: Convert a number to string representation + * RETURN: None, string + * + * DESCRIPTOIN: Convert a number to string representation. Assumes string + * buffer is large enough to hold the string. * ******************************************************************************/ @@ -449,7 +470,6 @@ AcpiExUnsignedIntegerToString ( UINT32 Count; UINT32 DigitsNeeded; UINT32 Remainder; - ACPI_INTEGER Quotient; ACPI_FUNCTION_ENTRY (); @@ -460,9 +480,8 @@ AcpiExUnsignedIntegerToString ( for (Count = DigitsNeeded; Count > 0; Count--) { - (void) AcpiUtShortDivide (&Value, 10, &Quotient, &Remainder); + (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder); OutString[Count-1] = (char) ('0' + Remainder);\ - Value = Quotient; } } diff --git a/sys/dev/acpi/acpica/Subsystem/hwacpi.c b/sys/dev/acpi/acpica/Subsystem/hwacpi.c index efb56cb4259..9f5bfe0d4b0 100644 --- a/sys/dev/acpi/acpica/Subsystem/hwacpi.c +++ b/sys/dev/acpi/acpica/Subsystem/hwacpi.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface - * xRevision: 66 $ + * xRevision: 69 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwacpi.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hwacpi.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __HWACPI_C__ @@ -135,7 +135,8 @@ __KERNEL_RCSID(0, "$NetBSD: hwacpi.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * * RETURN: Status * - * DESCRIPTION: Initialize and validate various ACPI registers + * DESCRIPTION: Initialize and validate the various ACPI registers defined in + * the FADT. * ******************************************************************************/ @@ -153,7 +154,7 @@ AcpiHwInitialize ( if (!AcpiGbl_FADT) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "A FADT is not loaded\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT is present\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } @@ -212,7 +213,8 @@ AcpiHwSetMode ( */ if (!AcpiGbl_FADT->AcpiEnable && !AcpiGbl_FADT->AcpiDisable) { - ACPI_REPORT_ERROR (("No ACPI mode transition supported in this system (enable/disable both zero)\n")); + ACPI_REPORT_ERROR (( + "No ACPI mode transition supported in this system (enable/disable both zero)\n")); return_ACPI_STATUS (AE_OK); } @@ -245,7 +247,8 @@ AcpiHwSetMode ( if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not write mode change, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Could not write mode change, %s\n", + AcpiFormatException (Status))); return_ACPI_STATUS (Status); } @@ -258,7 +261,8 @@ AcpiHwSetMode ( { if (AcpiHwGetMode() == Mode) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", Mode)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", + Mode)); return_ACPI_STATUS (AE_OK); } AcpiOsStall(1000); @@ -270,7 +274,7 @@ AcpiHwSetMode ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiHwGetMode * @@ -284,7 +288,8 @@ AcpiHwSetMode ( ******************************************************************************/ UINT32 -AcpiHwGetMode (void) +AcpiHwGetMode ( + void) { ACPI_STATUS Status; UINT32 Value; diff --git a/sys/dev/acpi/acpica/Subsystem/hwgpe.c b/sys/dev/acpi/acpica/Subsystem/hwgpe.c index 787337d8f1a..8a0bb35377f 100644 --- a/sys/dev/acpi/acpica/Subsystem/hwgpe.c +++ b/sys/dev/acpi/acpica/Subsystem/hwgpe.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: hwgpe - Low level GPE enable/disable/clear functions - * xRevision: 55 $ + * xRevision: 69 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwgpe.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hwgpe.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acevents.h" @@ -124,107 +124,34 @@ __KERNEL_RCSID(0, "$NetBSD: hwgpe.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME ("hwgpe") +/* Local prototypes */ -/****************************************************************************** - * - * FUNCTION: AcpiHwEnableGpe - * - * PARAMETERS: GpeNumber - The GPE - * - * RETURN: None - * - * DESCRIPTION: Enable a single GPE. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiHwEnableGpe ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - UINT32 InByte; - ACPI_STATUS Status; - - - ACPI_FUNCTION_ENTRY (); - - - /* - * Read the current value of the register, set the appropriate bit - * to enable the GPE, and write out the new register. - */ - Status = AcpiHwLowLevelRead (8, &InByte, - &GpeEventInfo->RegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Write with the new GPE bit enabled */ - - Status = AcpiHwLowLevelWrite (8, (InByte | GpeEventInfo->BitMask), - &GpeEventInfo->RegisterInfo->EnableAddress); - - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiHwEnableGpeForWakeup - * - * PARAMETERS: GpeNumber - The GPE - * - * RETURN: None - * - * DESCRIPTION: Keep track of which GPEs the OS has requested not be - * disabled when going to sleep. - * - ******************************************************************************/ - -void -AcpiHwEnableGpeForWakeup ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - - - ACPI_FUNCTION_ENTRY (); - - - /* Get the info block for the entire GPE register */ - - GpeRegisterInfo = GpeEventInfo->RegisterInfo; - if (!GpeRegisterInfo) - { - return; - } - - /* - * Set the bit so we will not disable this when sleeping - */ - GpeRegisterInfo->WakeEnable |= GpeEventInfo->BitMask; -} +static ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock); /****************************************************************************** * - * FUNCTION: AcpiHwDisableGpe + * FUNCTION: AcpiHwWriteGpeEnableReg * - * PARAMETERS: GpeNumber - The GPE + * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Disable a single GPE. + * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must + * already be cleared or set in the parent register + * EnableForRun mask. * ******************************************************************************/ ACPI_STATUS -AcpiHwDisableGpe ( +AcpiHwWriteGpeEnableReg ( ACPI_GPE_EVENT_INFO *GpeEventInfo) { - UINT32 InByte; - ACPI_STATUS Status; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_STATUS Status; ACPI_FUNCTION_ENTRY (); @@ -235,69 +162,15 @@ AcpiHwDisableGpe ( GpeRegisterInfo = GpeEventInfo->RegisterInfo; if (!GpeRegisterInfo) { - return (AE_BAD_PARAMETER); - } - - /* - * Read the current value of the register, clear the appropriate bit, - * and write out the new register value to disable the GPE. - */ - Status = AcpiHwLowLevelRead (8, &InByte, - &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - return (Status); + return (AE_NOT_EXIST); } - /* Write the byte with this GPE bit cleared */ + /* Write the entire GPE (runtime) enable register */ - Status = AcpiHwLowLevelWrite (8, (InByte & ~(GpeEventInfo->BitMask)), + Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->EnableForRun, &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - AcpiHwDisableGpeForWakeup (GpeEventInfo); - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiHwDisableGpeForWakeup - * - * PARAMETERS: GpeNumber - The GPE - * - * RETURN: None - * - * DESCRIPTION: Keep track of which GPEs the OS has requested not be - * disabled when going to sleep. - * - ******************************************************************************/ - -void -AcpiHwDisableGpeForWakeup ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - - ACPI_FUNCTION_ENTRY (); - - - /* Get the info block for the entire GPE register */ - - GpeRegisterInfo = GpeEventInfo->RegisterInfo; - if (!GpeRegisterInfo) - { - return; - } - - /* - * Clear the bit so we will disable this when sleeping - */ - GpeRegisterInfo->WakeEnable &= ~(GpeEventInfo->BitMask); + return (Status); } @@ -305,11 +178,11 @@ AcpiHwDisableGpeForWakeup ( * * FUNCTION: AcpiHwClearGpe * - * PARAMETERS: GpeNumber - The GPE + * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Clear a single GPE. + * DESCRIPTION: Clear the status bit for a single GPE. * ******************************************************************************/ @@ -327,7 +200,7 @@ AcpiHwClearGpe ( * Write a one to the appropriate bit in the status register to * clear this GPE. */ - Status = AcpiHwLowLevelWrite (8, GpeEventInfo->BitMask, + Status = AcpiHwLowLevelWrite (8, GpeEventInfo->RegisterBit, &GpeEventInfo->RegisterInfo->StatusAddress); return (Status); @@ -338,9 +211,10 @@ AcpiHwClearGpe ( * * FUNCTION: AcpiHwGetGpeStatus * - * PARAMETERS: GpeNumber - The GPE + * PARAMETERS: GpeEventInfo - Info block for the GPE to queried + * EventStatus - Where the GPE status is returned * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Return the status of a single GPE. * @@ -352,7 +226,7 @@ AcpiHwGetGpeStatus ( ACPI_EVENT_STATUS *EventStatus) { UINT32 InByte; - UINT8 BitMask; + UINT8 RegisterBit; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_STATUS Status; ACPI_EVENT_STATUS LocalEventStatus = 0; @@ -372,29 +246,23 @@ AcpiHwGetGpeStatus ( /* Get the register bitmask for this GPE */ - BitMask = GpeEventInfo->BitMask; + RegisterBit = GpeEventInfo->RegisterBit; - /* GPE Enabled? */ + /* GPE currently enabled? (enabled for runtime?) */ - Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - - if (BitMask & InByte) + if (RegisterBit & GpeRegisterInfo->EnableForRun) { LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; } - /* GPE Enabled for wake? */ + /* GPE enabled for wake? */ - if (BitMask & GpeRegisterInfo->WakeEnable) + if (RegisterBit & GpeRegisterInfo->EnableForWake) { LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED; } - /* GPE active (set)? */ + /* GPE currently active (status bit == 1)? */ Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress); if (ACPI_FAILURE (Status)) @@ -402,7 +270,7 @@ AcpiHwGetGpeStatus ( goto UnlockAndExit; } - if (BitMask & InByte) + if (RegisterBit & InByte) { LocalEventStatus |= ACPI_EVENT_FLAG_SET; } @@ -426,7 +294,7 @@ UnlockAndExit: * * RETURN: Status * - * DESCRIPTION: Disable all GPEs within a GPE block + * DESCRIPTION: Disable all GPEs within a single GPE block * ******************************************************************************/ @@ -466,7 +334,7 @@ AcpiHwDisableGpeBlock ( * * RETURN: Status * - * DESCRIPTION: Clear all GPEs within a GPE block + * DESCRIPTION: Clear status bits for all GPEs within a single GPE block * ******************************************************************************/ @@ -483,7 +351,7 @@ AcpiHwClearGpeBlock ( for (i = 0; i < GpeBlock->RegisterCount; i++) { - /* Clear all GPEs in this register */ + /* Clear status on all GPEs in this register */ Status = AcpiHwLowLevelWrite (8, 0xFF, &GpeBlock->RegisterInfo[i].StatusAddress); @@ -499,60 +367,46 @@ AcpiHwClearGpeBlock ( /****************************************************************************** * - * FUNCTION: AcpiHwDisableNonWakeupGpeBlock + * FUNCTION: AcpiHwEnableRuntimeGpeBlock * * PARAMETERS: GpeXruptInfo - GPE Interrupt info * GpeBlock - Gpe Block info * * RETURN: Status * - * DESCRIPTION: Disable all GPEs except wakeup GPEs in a GPE block + * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes + * combination wake/run GPEs. * ******************************************************************************/ -static ACPI_STATUS -AcpiHwDisableNonWakeupGpeBlock ( +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock) { UINT32 i; - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; - UINT32 InValue; ACPI_STATUS Status; - /* Get the register info for the entire GPE block */ - - GpeRegisterInfo = GpeBlock->RegisterInfo; + /* NOTE: assumes that all GPEs are currently disabled */ /* Examine each GPE Register within the block */ for (i = 0; i < GpeBlock->RegisterCount; i++) { - /* - * Read the enabled status of all GPEs. We - * will be using it to restore all the GPEs later. - */ - Status = AcpiHwLowLevelRead (8, &InValue, - &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) + if (!GpeBlock->RegisterInfo[i].EnableForRun) { - return (Status); + continue; } - GpeRegisterInfo->Enable = (UINT8) InValue; + /* Enable all "runtime" GPEs in this register */ - /* - * Disable all GPEs except wakeup GPEs. - */ - Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->WakeEnable, - &GpeRegisterInfo->EnableAddress); + Status = AcpiHwLowLevelWrite (8, GpeBlock->RegisterInfo[i].EnableForRun, + &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { return (Status); } - - GpeRegisterInfo++; } return (AE_OK); @@ -561,111 +415,129 @@ AcpiHwDisableNonWakeupGpeBlock ( /****************************************************************************** * - * FUNCTION: AcpiHwDisableNonWakeupGpes + * FUNCTION: AcpiHwEnableWakeupGpeBlock * - * PARAMETERS: None + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Disable all non-wakeup GPEs - * Called with interrupts disabled. The interrupt handler also - * modifies GpeRegisterInfo->Enable, so it should not be - * given the chance to run until after non-wake GPEs are - * re-enabled. + * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes + * combination wake/run GPEs. * ******************************************************************************/ -ACPI_STATUS -AcpiHwDisableNonWakeupGpes ( - void) +static ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock) { + UINT32 i; ACPI_STATUS Status; - ACPI_FUNCTION_ENTRY (); + /* Examine each GPE Register within the block */ + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + if (!GpeBlock->RegisterInfo[i].EnableForWake) + { + continue; + } - Status = AcpiEvWalkGpeList (AcpiHwDisableNonWakeupGpeBlock); + /* Enable all "wake" GPEs in this register */ - return (Status); + Status = AcpiHwLowLevelWrite (8, + GpeBlock->RegisterInfo[i].EnableForWake, + &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); } /****************************************************************************** * - * FUNCTION: AcpiHwEnableNonWakeupGpeBlock + * FUNCTION: AcpiHwDisableAllGpes * - * PARAMETERS: GpeXruptInfo - GPE Interrupt info - * GpeBlock - Gpe Block info + * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR * * RETURN: Status * - * DESCRIPTION: Enable a single GPE. + * DESCRIPTION: Disable and clear all GPEs in all GPE blocks * ******************************************************************************/ -static ACPI_STATUS -AcpiHwEnableNonWakeupGpeBlock ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock) +ACPI_STATUS +AcpiHwDisableAllGpes ( + UINT32 Flags) { - UINT32 i; - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_STATUS Status; - /* This callback processes one entire GPE block */ + ACPI_FUNCTION_TRACE ("HwDisableAllGpes"); - /* Get the register info for the entire GPE block */ - GpeRegisterInfo = GpeBlock->RegisterInfo; + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, Flags); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, Flags); + return_ACPI_STATUS (Status); +} - /* Examine each GPE register within the block */ - for (i = 0; i < GpeBlock->RegisterCount; i++) - { - /* - * We previously stored the enabled status of all GPEs. - * Blast them back in. - */ - Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->Enable, - &GpeRegisterInfo->EnableAddress); - if (ACPI_FAILURE (Status)) - { - return (Status); - } +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableAllRuntimeGpes + * + * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks + * + ******************************************************************************/ - GpeRegisterInfo++; - } +ACPI_STATUS +AcpiHwEnableAllRuntimeGpes ( + UINT32 Flags) +{ + ACPI_STATUS Status; - return (AE_OK); + ACPI_FUNCTION_TRACE ("HwEnableAllRuntimeGpes"); + + + Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, Flags); + return_ACPI_STATUS (Status); } /****************************************************************************** * - * FUNCTION: AcpiHwEnableNonWakeupGpes + * FUNCTION: AcpiHwEnableAllWakeupGpes * - * PARAMETERS: None + * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Enable all non-wakeup GPEs we previously enabled. + * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks * ******************************************************************************/ ACPI_STATUS -AcpiHwEnableNonWakeupGpes ( - void) +AcpiHwEnableAllWakeupGpes ( + UINT32 Flags) { ACPI_STATUS Status; - ACPI_FUNCTION_ENTRY (); - + ACPI_FUNCTION_TRACE ("HwEnableAllWakeupGpes"); - Status = AcpiEvWalkGpeList (AcpiHwEnableNonWakeupGpeBlock); - return (Status); + Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, Flags); + return_ACPI_STATUS (Status); } + diff --git a/sys/dev/acpi/acpica/Subsystem/hwregs.c b/sys/dev/acpi/acpica/Subsystem/hwregs.c index 953ab353aeb..1ebb650aa31 100644 --- a/sys/dev/acpi/acpica/Subsystem/hwregs.c +++ b/sys/dev/acpi/acpica/Subsystem/hwregs.c @@ -3,7 +3,7 @@ * * Module Name: hwregs - Read/write access functions for the various ACPI * control and status registers. - * xRevision: 153 $ + * xRevision: 169 $ * ******************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwregs.c,v 1.13 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hwregs.c,v 1.14 2005/05/02 14:52:09 kochi Exp $"); #define __HWREGS_C__ @@ -138,6 +138,7 @@ __KERNEL_RCSID(0, "$NetBSD: hwregs.c,v 1.13 2004/02/14 16:57:24 kochi Exp $"); * RETURN: none * * DESCRIPTION: Clears all fixed and general purpose status bits + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ @@ -164,8 +165,9 @@ AcpiHwClearAcpiStatus ( } } - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, - ACPI_BITMASK_ALL_FIXED_STATUS); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_STATUS, + ACPI_BITMASK_ALL_FIXED_STATUS); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -185,7 +187,7 @@ AcpiHwClearAcpiStatus ( /* Clear the GPE Bits in all GPE registers in all GPE blocks */ - Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, ACPI_ISR); UnlockAndExit: if (Flags & ACPI_MTX_LOCK) @@ -218,84 +220,101 @@ AcpiGetSleepTypeData ( UINT8 *SleepTypeB) { ACPI_STATUS Status = AE_OK; - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARAMETER_INFO Info; + char *SleepStateName; ACPI_FUNCTION_TRACE ("AcpiGetSleepTypeData"); - /* - * Validate parameters - */ + /* Validate parameters */ + if ((SleepState > ACPI_S_STATES_MAX) || !SleepTypeA || !SleepTypeB) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Evaluate the namespace object containing the values for this state - */ - Status = AcpiNsEvaluateByName ((char *) AcpiGbl_DbSleepStates[SleepState], - NULL, &ObjDesc); + /* Evaluate the namespace object containing the values for this state */ + + Info.Parameters = NULL; + Info.ReturnObject = NULL; + SleepStateName = (char *) AcpiGbl_SleepStateNames[SleepState]; + + Status = AcpiNsEvaluateByName (SleepStateName, &Info); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating SleepState [%s]\n", - AcpiFormatException (Status), AcpiGbl_DbSleepStates[SleepState])); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%s while evaluating SleepState [%s]\n", + AcpiFormatException (Status), SleepStateName)); return_ACPI_STATUS (Status); } /* Must have a return object */ - if (!ObjDesc) + if (!Info.ReturnObject) { - ACPI_REPORT_ERROR (("Missing Sleep State object\n")); + ACPI_REPORT_ERROR (("No Sleep State object returned from [%s]\n", + SleepStateName)); Status = AE_NOT_EXIST; } /* It must be of type Package */ - else if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_PACKAGE) + else if (ACPI_GET_OBJECT_TYPE (Info.ReturnObject) != ACPI_TYPE_PACKAGE) { - ACPI_REPORT_ERROR (("Sleep State object not a Package\n")); + ACPI_REPORT_ERROR (("Sleep State return object is not a Package\n")); Status = AE_AML_OPERAND_TYPE; } - /* The package must have at least two elements */ - - else if (ObjDesc->Package.Count < 2) + /* + * The package must have at least two elements. NOTE (March 2005): This + * goes against the current ACPI spec which defines this object as a + * package with one encoded DWORD element. However, existing practice + * by BIOS vendors seems to be to have 2 or more elements, at least + * one per sleep type (A/B). + */ + else if (Info.ReturnObject->Package.Count < 2) { - ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n")); + ACPI_REPORT_ERROR (( + "Sleep State return package does not have at least two elements\n")); Status = AE_AML_NO_OPERAND; } /* The first two elements must both be of type Integer */ - else if ((ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[0]) != ACPI_TYPE_INTEGER) || - (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[1]) != ACPI_TYPE_INTEGER)) + else if ((ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[0]) + != ACPI_TYPE_INTEGER) || + (ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[1]) + != ACPI_TYPE_INTEGER)) { - ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n", - AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[0]), - AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[1]))); + ACPI_REPORT_ERROR (( + "Sleep State return package elements are not both Integers (%s, %s)\n", + AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[0]), + AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[1]))); Status = AE_AML_OPERAND_TYPE; } else { - /* - * Valid _Sx_ package size, type, and value - */ - *SleepTypeA = (UINT8) (ObjDesc->Package.Elements[0])->Integer.Value; - *SleepTypeB = (UINT8) (ObjDesc->Package.Elements[1])->Integer.Value; + /* Valid _Sx_ package size, type, and value */ + + *SleepTypeA = (UINT8) + (Info.ReturnObject->Package.Elements[0])->Integer.Value; + *SleepTypeB = (UINT8) + (Info.ReturnObject->Package.Elements[1])->Integer.Value; } if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While evaluating SleepState [%s], bad Sleep object %p type %s\n", - AcpiGbl_DbSleepStates[SleepState], ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "%s While evaluating SleepState [%s], bad Sleep object %p type %s\n", + AcpiFormatException (Status), + SleepStateName, Info.ReturnObject, + AcpiUtGetObjectTypeName (Info.ReturnObject))); } - AcpiUtRemoveReference (ObjDesc); + AcpiUtRemoveReference (Info.ReturnObject); return_ACPI_STATUS (Status); } @@ -306,9 +325,9 @@ AcpiGetSleepTypeData ( * * PARAMETERS: RegisterId - Index of ACPI Register to access * - * RETURN: The bit mask to be used when accessing the register + * RETURN: The bitmask to be used when accessing the register * - * DESCRIPTION: Map RegisterId into a register bit mask. + * DESCRIPTION: Map RegisterId into a register bitmask. * ******************************************************************************/ @@ -337,8 +356,8 @@ AcpiHwGetBitRegisterInfo ( * ReturnValue - Value that was read from the register * Flags - Lock the hardware or not * - * RETURN: Value is read from specified Register. Value returned is - * normalized to bit0 (is shifted all the way right) + * RETURN: Status and the value read from specified Register. Value + * returned is normalized to bit0 (is shifted all the way right) * * DESCRIPTION: ACPI BitRegister read function. * @@ -375,6 +394,8 @@ AcpiGetRegister ( } } + /* Read from the register */ + Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, BitRegInfo->ParentRegister, &RegisterValue); @@ -406,10 +427,10 @@ AcpiGetRegister ( * * PARAMETERS: RegisterId - ID of ACPI BitRegister to access * Value - (only used on write) value to write to the - * Register, NOT pre-normalized to the bit pos. + * Register, NOT pre-normalized to the bit pos * Flags - Lock the hardware or not * - * RETURN: None + * RETURN: Status * * DESCRIPTION: ACPI Bit Register write function. * @@ -450,7 +471,7 @@ AcpiSetRegister ( /* Always do a register read first so we can insert the new bits */ Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, - BitRegInfo->ParentRegister, &RegisterValue); + BitRegInfo->ParentRegister, &RegisterValue); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -490,7 +511,7 @@ AcpiSetRegister ( BitRegInfo->AccessBitMask, Value); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_ENABLE, (UINT16) RegisterValue); + ACPI_REGISTER_PM1_ENABLE, (UINT16) RegisterValue); break; @@ -507,7 +528,7 @@ AcpiSetRegister ( BitRegInfo->AccessBitMask, Value); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_CONTROL, (UINT16) RegisterValue); + ACPI_REGISTER_PM1_CONTROL, (UINT16) RegisterValue); break; @@ -522,17 +543,19 @@ AcpiSetRegister ( ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n", RegisterValue, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)))); + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( + AcpiGbl_FADT->XPm2CntBlk.Address)))); ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, BitRegInfo->AccessBitMask, Value); ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", RegisterValue, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)))); + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( + AcpiGbl_FADT->XPm2CntBlk.Address)))); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue)); + ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue)); break; @@ -550,7 +573,9 @@ UnlockAndExit: /* Normalize the value that was read */ - ACPI_DEBUG_EXEC (RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask) >> BitRegInfo->BitPosition)); + ACPI_DEBUG_EXEC (RegisterValue = + ((RegisterValue & BitRegInfo->AccessBitMask) >> + BitRegInfo->BitPosition)); ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", Value, RegisterValue, BitRegInfo->ParentRegister)); @@ -562,10 +587,11 @@ UnlockAndExit: * * FUNCTION: AcpiHwRegisterRead * - * PARAMETERS: UseLock - Mutex hw access. - * RegisterId - RegisterID + Offset. + * PARAMETERS: UseLock - Mutex hw access + * RegisterId - RegisterID + Offset + * ReturnValue - Where the register value is returned * - * RETURN: Value read or written. + * RETURN: Status and the value read. * * DESCRIPTION: Acpi register read function. Registers are read at the * given offset. @@ -657,7 +683,8 @@ AcpiHwRegisterRead ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", RegisterId)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", + RegisterId)); Status = AE_BAD_PARAMETER; break; } @@ -681,10 +708,11 @@ UnlockAndExit: * * FUNCTION: AcpiHwRegisterWrite * - * PARAMETERS: UseLock - Mutex hw access. - * RegisterId - RegisterID + Offset. + * PARAMETERS: UseLock - Mutex hw access + * RegisterId - RegisterID + Offset + * Value - The value to write * - * RETURN: Value read or written. + * RETURN: Status * * DESCRIPTION: Acpi register Write function. Registers are written at the * given offset. @@ -807,11 +835,11 @@ UnlockAndExit: * * PARAMETERS: Width - 8, 16, or 32 * Value - Where the value is returned - * Register - GAS register structure + * Reg - GAS register structure * * RETURN: Status * - * DESCRIPTION: Read from either memory, IO, or PCI config space. + * DESCRIPTION: Read from either memory or IO space. * ******************************************************************************/ @@ -821,8 +849,7 @@ AcpiHwLowLevelRead ( UINT32 *Value, ACPI_GENERIC_ADDRESS *Reg) { - ACPI_PCI_ID PciId; - UINT16 PciRegister; + UINT64 Address; ACPI_STATUS Status; @@ -834,43 +861,37 @@ AcpiHwLowLevelRead ( * a non-zero address within. However, don't return an error * because the PM1A/B code must not fail if B isn't present. */ - if ((!Reg) || - (!ACPI_VALID_ADDRESS (Reg->Address))) + if (!Reg) + { + return (AE_OK); + } + + /* Get a local copy of the address. Handles possible alignment issues */ + + ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); + if (!ACPI_VALID_ADDRESS (Address)) { return (AE_OK); } *Value = 0; /* - * Three address spaces supported: - * Memory, IO, or PCI_Config. + * Two address spaces supported: Memory or IO. + * PCI_Config is not supported here because the GAS struct is insufficient */ switch (Reg->AddressSpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: Status = AcpiOsReadMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), + (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Address), Value, Width); break; case ACPI_ADR_SPACE_SYSTEM_IO: - Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), - Value, Width); - break; - - - case ACPI_ADR_SPACE_PCI_CONFIG: - - PciId.Segment = 0; - PciId.Bus = 0; - PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address)); - PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address)); - PciRegister = (UINT16) ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address)); - - Status = AcpiOsReadPciConfiguration (&PciId, PciRegister, + Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Address), Value, Width); break; @@ -881,10 +902,11 @@ AcpiHwLowLevelRead ( return (AE_BAD_PARAMETER); } - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, Width, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Reg->Address)), - AcpiUtGetRegionName (Reg->AddressSpaceId))); + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", + *Value, Width, + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Address)), + AcpiUtGetRegionName (Reg->AddressSpaceId))); return (Status); } @@ -896,11 +918,11 @@ AcpiHwLowLevelRead ( * * PARAMETERS: Width - 8, 16, or 32 * Value - To be written - * Register - GAS register structure + * Reg - GAS register structure * * RETURN: Status * - * DESCRIPTION: Write to either memory, IO, or PCI config space. + * DESCRIPTION: Write to either memory or IO space. * ******************************************************************************/ @@ -910,8 +932,7 @@ AcpiHwLowLevelWrite ( UINT32 Value, ACPI_GENERIC_ADDRESS *Reg) { - ACPI_PCI_ID PciId; - UINT16 PciRegister; + UINT64 Address; ACPI_STATUS Status; @@ -923,56 +944,51 @@ AcpiHwLowLevelWrite ( * a non-zero address within. However, don't return an error * because the PM1A/B code must not fail if B isn't present. */ - if ((!Reg) || - (!ACPI_VALID_ADDRESS (Reg->Address))) + if (!Reg) + { + return (AE_OK); + } + + /* Get a local copy of the address. Handles possible alignment issues */ + + ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); + if (!ACPI_VALID_ADDRESS (Address)) { return (AE_OK); } /* - * Three address spaces supported: - * Memory, IO, or PCI_Config. + * Two address spaces supported: Memory or IO. + * PCI_Config is not supported here because the GAS struct is insufficient */ switch (Reg->AddressSpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: Status = AcpiOsWriteMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), + (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Address), Value, Width); break; case ACPI_ADR_SPACE_SYSTEM_IO: - Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), + Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Address), Value, Width); break; - case ACPI_ADR_SPACE_PCI_CONFIG: - - PciId.Segment = 0; - PciId.Bus = 0; - PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address)); - PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address)); - PciRegister = (UINT16) ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address)); - - Status = AcpiOsWritePciConfiguration (&PciId, PciRegister, - (ACPI_INTEGER) Value, Width); - break; - - default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported address space: %X\n", Reg->AddressSpaceId)); return (AE_BAD_PARAMETER); } - ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, Width, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Reg->Address)), - AcpiUtGetRegionName (Reg->AddressSpaceId))); + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", + Value, Width, + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Address)), + AcpiUtGetRegionName (Reg->AddressSpaceId))); return (Status); } diff --git a/sys/dev/acpi/acpica/Subsystem/hwsleep.c b/sys/dev/acpi/acpica/Subsystem/hwsleep.c index d82e912bc09..3dbea32416b 100644 --- a/sys/dev/acpi/acpica/Subsystem/hwsleep.c +++ b/sys/dev/acpi/acpica/Subsystem/hwsleep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface - * xRevision: 62 $ + * xRevision: 74 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwsleep.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hwsleep.c,v 1.13 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" @@ -124,7 +124,7 @@ __KERNEL_RCSID(0, "$NetBSD: hwsleep.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); ACPI_MODULE_NAME ("hwsleep") -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiSetFirmwareWakingVector * @@ -133,7 +133,7 @@ __KERNEL_RCSID(0, "$NetBSD: hwsleep.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); * * RETURN: Status * - * DESCRIPTION: Access function for dFirmwareWakingVector field in FACS + * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS * ******************************************************************************/ @@ -162,17 +162,17 @@ AcpiSetFirmwareWakingVector ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiGetFirmwareWakingVector * - * PARAMETERS: *PhysicalAddress - Output buffer where contents of + * PARAMETERS: *PhysicalAddress - Where the contents of * the FirmwareWakingVector field of - * the FACS will be stored. + * the FACS will be returned. * - * RETURN: Status + * RETURN: Status, vector * - * DESCRIPTION: Access function for FirmwareWakingVector field in FACS + * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS * ******************************************************************************/ @@ -206,7 +206,7 @@ AcpiGetFirmwareWakingVector ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEnterSleepStatePrep * @@ -253,53 +253,55 @@ AcpiEnterSleepStatePrep ( /* Run the _PTS and _GTS methods */ - Status = AcpiEvaluateObject (NULL, "\\_PTS", &ArgList, NULL); + Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { return_ACPI_STATUS (Status); } - Status = AcpiEvaluateObject (NULL, "\\_GTS", &ArgList, NULL); + Status = AcpiEvaluateObject (NULL, METHOD_NAME__GTS, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { return_ACPI_STATUS (Status); } - /* Set the system indicators to show the desired sleep state. */ + /* Setup the argument to _SST */ switch (SleepState) { case ACPI_STATE_S0: - /* _SST 1: Working */ - Arg.Integer.Value = 1; + Arg.Integer.Value = ACPI_SST_WORKING; break; + case ACPI_STATE_S1: case ACPI_STATE_S2: case ACPI_STATE_S3: - /* _SST 3: Sleeping. Used to indicate system state S1, S2 or S3. */ - Arg.Integer.Value = 3; + Arg.Integer.Value = ACPI_SST_SLEEPING; break; + case ACPI_STATE_S4: - /* _SST 4: Sleeping with context saved to non-volatile storage. */ - Arg.Integer.Value = 4; + Arg.Integer.Value = ACPI_SST_SLEEP_CONTEXT; break; - case ACPI_STATE_S5: - /* _SST 0: No system state indication. Indicator off. */ - Arg.Integer.Value = 0; + + default: + Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */ break; } - Status = AcpiEvaluateObject (NULL, "\\_SI._SST", &ArgList, NULL); + /* Set the system indicators to show the desired sleep state. */ + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _SST failed, %s\n", + AcpiFormatException (Status))); } return_ACPI_STATUS (AE_OK); } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEnterSleepState * @@ -321,7 +323,6 @@ AcpiEnterSleepState ( ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; UINT32 InValue; - UINT32 Retry; ACPI_STATUS Status; @@ -339,32 +340,46 @@ AcpiEnterSleepState ( SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE_A); SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); - if (SleepState != ACPI_STATE_S5) + /* Clear wake status */ + + Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE (Status)) { - /* Clear wake status */ + return_ACPI_STATUS (Status); + } - Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Clear all fixed and general purpose status bits */ - Status = AcpiHwClearAcpiStatus (ACPI_MTX_DO_NOT_LOCK); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + Status = AcpiHwClearAcpiStatus (ACPI_MTX_DO_NOT_LOCK); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + if (SleepState != ACPI_STATE_S5) + { /* Disable BM arbitration */ - Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, + 1, ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } - Status = AcpiHwDisableNonWakeupGpes (); + /* + * 1) Disable/Clear all GPEs + * 2) Enable all wakeup GPEs + */ + Status = AcpiHwDisableAllGpes (ACPI_ISR); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (ACPI_ISR); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -372,16 +387,19 @@ AcpiEnterSleepState ( /* Get current value of PM1A control */ - Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, &PM1AControl); + Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, &PM1AControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%d]\n", SleepState)); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Entering sleep state [S%d]\n", SleepState)); /* Clear SLP_EN and SLP_TYP fields */ - PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | SleepEnableRegInfo->AccessBitMask); + PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); PM1BControl = PM1AControl; /* Insert SLP_TYP bits */ @@ -396,13 +414,15 @@ AcpiEnterSleepState ( /* Write #1: fill in SLP_TYP data */ - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, PM1AControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, PM1BControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -417,13 +437,15 @@ AcpiEnterSleepState ( ACPI_FLUSH_CPU_CACHE (); - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, PM1AControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, PM1BControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -432,10 +454,11 @@ AcpiEnterSleepState ( if (SleepState > ACPI_STATE_S3) { /* - * We wanted to sleep > S3, but it didn't happen (by virtue of the fact that - * we are still executing!) + * We wanted to sleep > S3, but it didn't happen (by virtue of the + * fact that we are still executing!) * - * Wait ten seconds, then try again. This is to get S4/S5 to work on all machines. + * Wait ten seconds, then try again. This is to get S4/S5 to work on + * all machines. * * We wait so long to allow chipsets that poll this reg very slowly to * still read the right value. Ideally, this block would go @@ -443,7 +466,8 @@ AcpiEnterSleepState ( */ AcpiOsStall (10000000); - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, SleepEnableRegInfo->AccessBitMask); if (ACPI_FAILURE (Status)) { @@ -453,24 +477,15 @@ AcpiEnterSleepState ( /* Wait until we enter sleep state */ - Retry = 1000; do { - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, + ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* - * Some BIOSs don't set WAK_STS at all. Give up waiting after - * 1000 retries if it still isn't set. - */ - if (Retry-- == 0) - { - break; - } - /* Spin until we wake */ } while (!InValue); @@ -479,7 +494,7 @@ AcpiEnterSleepState ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEnterSleepStateS4bios * @@ -515,7 +530,18 @@ AcpiEnterSleepStateS4bios ( return_ACPI_STATUS (Status); } - Status = AcpiHwDisableNonWakeupGpes (); + /* + * 1) Disable/Clear all GPEs + * 2) Enable all wakeup GPEs + */ + Status = AcpiHwDisableAllGpes (ACPI_ISR); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (ACPI_ISR); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -523,11 +549,13 @@ AcpiEnterSleepStateS4bios ( ACPI_FLUSH_CPU_CACHE (); - Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, (UINT32) AcpiGbl_FADT->S4BiosReq, 8); + Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, + (UINT32) AcpiGbl_FADT->S4BiosReq, 8); do { AcpiOsStall(1000); - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, + ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -538,7 +566,7 @@ AcpiEnterSleepStateS4bios ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiLeaveSleepState * @@ -547,6 +575,7 @@ AcpiEnterSleepStateS4bios ( * RETURN: Status * * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep + * Called with interrupts ENABLED. * ******************************************************************************/ @@ -616,45 +645,72 @@ AcpiLeaveSleepState ( /* Ignore any errors from these methods */ - /* _SST 2: Waking */ - Arg.Integer.Value = 2; - Status = AcpiEvaluateObject (NULL, "\\_SI._SST", &ArgList, NULL); + Arg.Integer.Value = ACPI_SST_WAKING; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _SST failed, %s\n", + AcpiFormatException (Status))); } Arg.Integer.Value = SleepState; - Status = AcpiEvaluateObject (NULL, "\\_BFS", &ArgList, NULL); + Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", + AcpiFormatException (Status))); } - Status = AcpiEvaluateObject (NULL, "\\_WAK", &ArgList, NULL); + Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", + AcpiFormatException (Status))); } + /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ - /* _WAK returns stuff - do we want to look at it? */ + /* + * Restore the GPEs: + * 1) Disable/Clear all GPEs + * 2) Enable all runtime GPEs + */ + Status = AcpiHwDisableAllGpes (ACPI_NOT_ISR); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = TRUE; - Status = AcpiHwEnableNonWakeupGpes (); + Status = AcpiHwEnableAllRuntimeGpes (ACPI_NOT_ISR); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } + /* Enable power button */ + + (void) AcpiSetRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, + 1, ACPI_MTX_DO_NOT_LOCK); + + (void) AcpiSetRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, + 1, ACPI_MTX_DO_NOT_LOCK); + /* Enable BM arbitration */ Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_LOCK); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - /* _SST 1: Working */ - Arg.Integer.Value = 1; - Status = AcpiEvaluateObject (NULL, "\\_SI._SST", &ArgList, NULL); + Arg.Integer.Value = ACPI_SST_WORKING; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _SST failed, %s\n", + AcpiFormatException (Status))); } return_ACPI_STATUS (Status); diff --git a/sys/dev/acpi/acpica/Subsystem/hwtimer.c b/sys/dev/acpi/acpica/Subsystem/hwtimer.c index eb13c984625..fd323354d0e 100644 --- a/sys/dev/acpi/acpica/Subsystem/hwtimer.c +++ b/sys/dev/acpi/acpica/Subsystem/hwtimer.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwtimer.c - ACPI Power Management Timer Interface - * xRevision: 26 $ + * xRevision: 30 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hwtimer.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hwtimer.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" @@ -128,11 +128,11 @@ __KERNEL_RCSID(0, "$NetBSD: hwtimer.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * * FUNCTION: AcpiGetTimerResolution * - * PARAMETERS: none + * PARAMETERS: Resolution - Where the resolution is returned * - * RETURN: Number of bits of resolution in the PM Timer (24 or 32). + * RETURN: Status and timer resolution * - * DESCRIPTION: Obtains resolution of the ACPI PM Timer. + * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits). * ******************************************************************************/ @@ -165,11 +165,11 @@ AcpiGetTimerResolution ( * * FUNCTION: AcpiGetTimer * - * PARAMETERS: none + * PARAMETERS: Ticks - Where the timer value is returned * - * RETURN: Current value of the ACPI PM Timer (in ticks). + * RETURN: Status and current timer value (ticks) * - * DESCRIPTION: Obtains current value of ACPI PM Timer. + * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks). * ******************************************************************************/ @@ -198,11 +198,11 @@ AcpiGetTimer ( * * FUNCTION: AcpiGetTimerDuration * - * PARAMETERS: StartTicks - * EndTicks - * TimeElapsed + * PARAMETERS: StartTicks - Starting timestamp + * EndTicks - End timestamp + * TimeElapsed - Where the elapsed time is returned * - * RETURN: TimeElapsed + * RETURN: Status and TimeElapsed * * DESCRIPTION: Computes the time elapsed (in microseconds) between two * PM Timer time stamps, taking into account the possibility of @@ -216,7 +216,7 @@ AcpiGetTimer ( * Note that this function accommodates only a single timer * rollover. Thus for 24-bit timers, this function should only * be used for calculating durations less than ~4.6 seconds - * (~20 minutes for 32-bit timers) -- calculations below + * (~20 minutes for 32-bit timers) -- calculations below: * * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes @@ -229,10 +229,9 @@ AcpiGetTimerDuration ( UINT32 EndTicks, UINT32 *TimeElapsed) { - UINT32 DeltaTicks = 0; - UINT64_OVERLAY NormalizedTicks; ACPI_STATUS Status; - ACPI_INTEGER OutQuotient; + UINT32 DeltaTicks; + ACPI_INTEGER Quotient; ACPI_FUNCTION_TRACE ("AcpiGetTimerDuration"); @@ -245,8 +244,7 @@ AcpiGetTimerDuration ( /* * Compute Tick Delta: - * ------------------- - * Handle (max one) timer rollovers on 24- versus 32-bit timers. + * Handle (max one) timer rollovers on 24-bit versus 32-bit timers. */ if (StartTicks < EndTicks) { @@ -267,26 +265,21 @@ AcpiGetTimerDuration ( DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks; } } - else + else /* StartTicks == EndTicks */ { *TimeElapsed = 0; return_ACPI_STATUS (AE_OK); } /* - * Compute Duration: - * ----------------- - * - * Requires a 64-bit divide: + * Compute Duration (Requires a 64-bit multiply and divide): * * TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY; */ - NormalizedTicks.Full = ((UINT64) DeltaTicks) * 1000000; - - Status = AcpiUtShortDivide (&NormalizedTicks.Full, PM_TIMER_FREQUENCY, - &OutQuotient, NULL); + Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * 1000000, + PM_TIMER_FREQUENCY, &Quotient, NULL); - *TimeElapsed = (UINT32) OutQuotient; + *TimeElapsed = (UINT32) Quotient; return_ACPI_STATUS (Status); } diff --git a/sys/dev/acpi/acpica/Subsystem/nsaccess.c b/sys/dev/acpi/acpica/Subsystem/nsaccess.c index ee26a154c94..d8bfe44de44 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsaccess.c +++ b/sys/dev/acpi/acpica/Subsystem/nsaccess.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsaccess - Top-level functions for accessing ACPI namespace - * xRevision: 177 $ + * xRevision: 188 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsaccess.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsaccess.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __NSACCESS_C__ @@ -144,7 +144,8 @@ __KERNEL_RCSID(0, "$NetBSD: nsaccess.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); ******************************************************************************/ ACPI_STATUS -AcpiNsRootInitialize (void) +AcpiNsRootInitialize ( + void) { ACPI_STATUS Status; const ACPI_PREDEFINED_NAMES *InitVal = NULL; @@ -185,8 +186,16 @@ AcpiNsRootInitialize (void) for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) { + /* _OSI is optional for now, will be permanent later */ + + if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) + { + continue; + } + Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, - ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, NULL, &NewNode); + ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, + NULL, &NewNode); if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ { @@ -205,7 +214,8 @@ AcpiNsRootInitialize (void) Status = AcpiOsPredefinedOverride (InitVal, &Val); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not override predefined %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not override predefined %s\n", InitVal->Name)); } @@ -233,22 +243,27 @@ AcpiNsRootInitialize (void) switch (InitVal->Type) { case ACPI_TYPE_METHOD: - ObjDesc->Method.ParamCount = - (UINT8) ACPI_STRTOUL (Val, NULL, 10); + ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val); ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; -#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) - - /* Compiler cheats by putting parameter count in the OwnerID */ +#if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_APP) + /* + * iASL Compiler cheats by putting parameter count + * in the OwnerID + */ NewNode->OwnerId = ObjDesc->Method.ParamCount; +#else + /* Mark this as a very SPECIAL method */ + + ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY; + ObjDesc->Method.Implementation = AcpiUtOsiImplementation; #endif break; case ACPI_TYPE_INTEGER: - ObjDesc->Integer.Value = - (ACPI_INTEGER) ACPI_STRTOUL (Val, NULL, 10); + ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val); break; @@ -266,8 +281,7 @@ AcpiNsRootInitialize (void) case ACPI_TYPE_MUTEX: ObjDesc->Mutex.Node = NewNode; - ObjDesc->Mutex.SyncLevel = - (UINT16) ACPI_STRTOUL (Val, NULL, 10); + ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1); if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) { @@ -279,6 +293,7 @@ AcpiNsRootInitialize (void) 1, &ObjDesc->Mutex.Semaphore); if (ACPI_FAILURE (Status)) { + AcpiUtRemoveReference (ObjDesc); goto UnlockAndExit; } @@ -296,6 +311,7 @@ AcpiNsRootInitialize (void) &ObjDesc->Mutex.Semaphore); if (ACPI_FAILURE (Status)) { + AcpiUtRemoveReference (ObjDesc); goto UnlockAndExit; } } @@ -303,6 +319,7 @@ AcpiNsRootInitialize (void) default: + ACPI_REPORT_ERROR (("Unsupported initial type value %X\n", InitVal->Type)); AcpiUtRemoveReference (ObjDesc); @@ -312,7 +329,8 @@ AcpiNsRootInitialize (void) /* Store pointer to value descriptor in the Node */ - Status = AcpiNsAttachObject (NewNode, ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc)); + Status = AcpiNsAttachObject (NewNode, ObjDesc, + ACPI_GET_OBJECT_TYPE (ObjDesc)); /* Remove local reference to the object */ @@ -323,6 +341,15 @@ AcpiNsRootInitialize (void) UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Save a handle to "_GPE", it is always present */ + + if (ACPI_SUCCESS (Status)) + { + Status = AcpiNsGetNodeByPath ("\\_GPE", NULL, ACPI_NS_NO_UPSEARCH, + &AcpiGbl_FadtGpeDevice); + } + return_ACPI_STATUS (Status); } @@ -331,7 +358,7 @@ UnlockAndExit: * * FUNCTION: AcpiNsLookup * - * PARAMETERS: PrefixNode - Search scope if name is not fully qualified + * PARAMETERS: ScopeInfo - Current scope info block * Pathname - Search pathname, in internal format * (as represented in the AML stream) * Type - Type associated with name @@ -544,7 +571,8 @@ AcpiNsLookup ( Type = ThisNode->Type; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Prefix-only Pathname (Zero name segments), Flags=%X\n", Flags)); + "Prefix-only Pathname (Zero name segments), Flags=%X\n", + Flags)); break; case AML_DUAL_NAME_PREFIX: @@ -640,7 +668,7 @@ AcpiNsLookup ( /* Try to find the single (4 character) ACPI name */ Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, - InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); + InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -673,6 +701,7 @@ AcpiNsLookup ( if ((NumSegments == 0) && (TypeToCheckFor != ACPI_TYPE_ANY) && (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) && (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) && (ThisNode->Type != ACPI_TYPE_ANY) && (ThisNode->Type != TypeToCheckFor)) diff --git a/sys/dev/acpi/acpica/Subsystem/nsalloc.c b/sys/dev/acpi/acpica/Subsystem/nsalloc.c index 823e3f627ee..1360ee6ab43 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsalloc.c +++ b/sys/dev/acpi/acpica/Subsystem/nsalloc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsalloc - Namespace allocation and deletion utilities - * xRevision: 84 $ + * xRevision: 92 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsalloc.c,v 1.14 2004/04/23 02:58:29 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsalloc.c,v 1.15 2005/05/02 14:52:09 kochi Exp $"); #define __NSALLOC_C__ @@ -127,14 +127,20 @@ __KERNEL_RCSID(0, "$NetBSD: nsalloc.c,v 1.14 2004/04/23 02:58:29 simonb Exp $"); #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsalloc") +/* Local prototypes */ + +static void +AcpiNsRemoveReference ( + ACPI_NAMESPACE_NODE *Node); + /******************************************************************************* * * FUNCTION: AcpiNsCreateNode * - * PARAMETERS: AcpiName - Name of the new node + * PARAMETERS: Name - Name of the new node (4 char ACPI name) * - * RETURN: None + * RETURN: New namespace node (Null on failure) * * DESCRIPTION: Create a namespace node * @@ -230,7 +236,6 @@ AcpiNsDeleteNode ( } } - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].TotalFreed++); /* @@ -242,60 +247,6 @@ AcpiNsDeleteNode ( } -#ifdef ACPI_ALPHABETIC_NAMESPACE -/******************************************************************************* - * - * FUNCTION: AcpiNsCompareNames - * - * PARAMETERS: Name1 - First name to compare - * Name2 - Second name to compare - * - * RETURN: value from strncmp - * - * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an - * underscore are forced to be alphabetically first. - * - ******************************************************************************/ - -int -AcpiNsCompareNames ( - char *Name1, - char *Name2) -{ - char ReversedName1[ACPI_NAME_SIZE]; - char ReversedName2[ACPI_NAME_SIZE]; - UINT32 i; - UINT32 j; - - - /* - * Replace all instances of "underscore" with a value that is smaller so - * that all names that are prefixed with underscore(s) are alphabetically - * first. - * - * Reverse the name bytewise so we can just do a 32-bit compare instead - * of a strncmp. - */ - for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) - { - ReversedName1[j] = Name1[i]; - if (Name1[i] == '_') - { - ReversedName1[j] = '*'; - } - - ReversedName2[j] = Name2[i]; - if (Name2[i] == '_') - { - ReversedName2[j] = '*'; - } - } - - return (*(int *) ReversedName1 - *(int *) ReversedName2); -} -#endif - - /******************************************************************************* * * FUNCTION: AcpiNsInstallNode @@ -362,7 +313,8 @@ AcpiNsInstallNode ( * alphabetic placement. */ PreviousChildNode = NULL; - while (AcpiNsCompareNames (AcpiUtGetNodeName (ChildNode), AcpiUtGetNodeName (Node)) < 0) + while (AcpiNsCompareNames (AcpiUtGetNodeName (ChildNode), + AcpiUtGetNodeName (Node)) < 0) { if (ChildNode->Flags & ANOBJ_END_OF_PEER_LIST) { @@ -431,10 +383,11 @@ AcpiNsInstallNode ( Node->OwnerId = OwnerId; Node->Type = (UINT8) Type; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s (%s) added to %4.4s (%s) %p at %p\n", - AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId, AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type), - ParentNode, Node)); + ParentNode)); /* * Increment the reference count(s) of all parents up to @@ -532,7 +485,8 @@ AcpiNsDeleteChildren ( if (ChildNode->ReferenceCount != 1) { - ACPI_REPORT_WARNING (("Existing references (%d) on node being deleted (%p)\n", + ACPI_REPORT_WARNING (( + "Existing references (%d) on node being deleted (%p)\n", ChildNode->ReferenceCount, ChildNode)); } @@ -602,15 +556,15 @@ AcpiNsDeleteNamespaceSubtree ( /* Check if this node has any children */ - if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, 0)) + if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) { /* * There is at least one child of this node, * visit the node */ Level++; - ParentNode = ChildNode; - ChildNode = 0; + ParentNode = ChildNode; + ChildNode = NULL; } } else @@ -656,7 +610,7 @@ AcpiNsDeleteNamespaceSubtree ( * ******************************************************************************/ -void +static void AcpiNsRemoveReference ( ACPI_NAMESPACE_NODE *Node) { @@ -765,8 +719,8 @@ AcpiNsDeleteNamespaceByOwner ( * visit the node */ Level++; - ParentNode = ChildNode; - ChildNode = NULL; + ParentNode = ChildNode; + ChildNode = NULL; } else if (ChildNode->OwnerId == OwnerId) { @@ -802,3 +756,57 @@ AcpiNsDeleteNamespaceByOwner ( } +#ifdef ACPI_ALPHABETIC_NAMESPACE +/******************************************************************************* + * + * FUNCTION: AcpiNsCompareNames + * + * PARAMETERS: Name1 - First name to compare + * Name2 - Second name to compare + * + * RETURN: value from strncmp + * + * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an + * underscore are forced to be alphabetically first. + * + ******************************************************************************/ + +int +AcpiNsCompareNames ( + char *Name1, + char *Name2) +{ + char ReversedName1[ACPI_NAME_SIZE]; + char ReversedName2[ACPI_NAME_SIZE]; + UINT32 i; + UINT32 j; + + + /* + * Replace all instances of "underscore" with a value that is smaller so + * that all names that are prefixed with underscore(s) are alphabetically + * first. + * + * Reverse the name bytewise so we can just do a 32-bit compare instead + * of a strncmp. + */ + for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) + { + ReversedName1[j] = Name1[i]; + if (Name1[i] == '_') + { + ReversedName1[j] = '*'; + } + + ReversedName2[j] = Name2[i]; + if (Name2[i] == '_') + { + ReversedName2[j] = '*'; + } + } + + return (*(int *) ReversedName1 - *(int *) ReversedName2); +} +#endif + + diff --git a/sys/dev/acpi/acpica/Subsystem/nsdump.c b/sys/dev/acpi/acpica/Subsystem/nsdump.c index 94348efb18a..c6d82478ad5 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsdump.c +++ b/sys/dev/acpi/acpica/Subsystem/nsdump.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsdump - table dumping routines for debug - * xRevision: 157 $ + * xRevision: 164 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsdump.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsdump.c,v 1.13 2005/05/02 14:52:09 kochi Exp $"); #define __NSDUMP_C__ @@ -128,16 +128,32 @@ __KERNEL_RCSID(0, "$NetBSD: nsdump.c,v 1.12 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsdump") +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +void +AcpiNsDumpRootDevices ( + void); + +static ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); +#endif -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /******************************************************************************* * * FUNCTION: AcpiNsPrintPathname * - * PARAMETERS: NumSegment - Number of ACPI name segments + * PARAMETERS: NumSegments - Number of ACPI name segments * Pathname - The compressed (internal) path * + * RETURN: None + * * DESCRIPTION: Print an object's full namespace pathname * ******************************************************************************/ @@ -184,6 +200,8 @@ AcpiNsPrintPathname ( * Level - Desired debug level * Component - Caller's component ID * + * RETURN: None + * * DESCRIPTION: Print an object's full namespace pathname * Manages allocation/freeing of a pathname buffer * @@ -219,9 +237,12 @@ AcpiNsDumpPathname ( * * FUNCTION: AcpiNsDumpOneObject * - * PARAMETERS: Handle - Node to be dumped + * PARAMETERS: ObjHandle - Node to be dumped * Level - Nesting level of the handle * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status * * DESCRIPTION: Dump a single Node * This procedure is a UserFunction called by AcpiNsWalkNamespace. @@ -285,7 +306,8 @@ AcpiNsDumpOneObject ( if (!AcpiUtValidAcpiName (ThisNode->Name.Integer)) { - ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name.Integer)); + ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", + ThisNode->Name.Integer)); } /* @@ -316,9 +338,8 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_PROCESSOR: AcpiOsPrintf ("ID %X Len %.4X Addr %p\n", - ObjDesc->Processor.ProcId, - ObjDesc->Processor.Length, - (char *) ObjDesc->Processor.Address); + ObjDesc->Processor.ProcId, ObjDesc->Processor.Length, + (char *) ObjDesc->Processor.Address); break; @@ -331,16 +352,15 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_METHOD: AcpiOsPrintf ("Args %X Len %.4X Aml %p\n", - (UINT32) ObjDesc->Method.ParamCount, - ObjDesc->Method.AmlLength, - ObjDesc->Method.AmlStart); + (UINT32) ObjDesc->Method.ParamCount, + ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart); break; case ACPI_TYPE_INTEGER: AcpiOsPrintf ("= %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; @@ -349,7 +369,7 @@ AcpiNsDumpOneObject ( if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { AcpiOsPrintf ("Elements %.2X\n", - ObjDesc->Package.Count); + ObjDesc->Package.Count); } else { @@ -394,12 +414,13 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_REGION: - AcpiOsPrintf ("[%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); + AcpiOsPrintf ("[%s]", + AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) { AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), - ObjDesc->Region.Length); + ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), + ObjDesc->Region.Length); } else { @@ -411,7 +432,7 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_LOCAL_REFERENCE: AcpiOsPrintf ("[%s]\n", - AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode)); + AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode)); break; @@ -421,7 +442,7 @@ AcpiNsDumpOneObject ( ObjDesc->BufferField.BufferObj->Buffer.Node) { AcpiOsPrintf ("Buf [%4.4s]", - AcpiUtGetNodeName (ObjDesc->BufferField.BufferObj->Buffer.Node)); + AcpiUtGetNodeName (ObjDesc->BufferField.BufferObj->Buffer.Node)); } break; @@ -429,29 +450,31 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_LOCAL_REGION_FIELD: AcpiOsPrintf ("Rgn [%4.4s]", - AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node)); + AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node)); break; case ACPI_TYPE_LOCAL_BANK_FIELD: AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]", - AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node), - AcpiUtGetNodeName (ObjDesc->BankField.BankObj->CommonField.Node)); + AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node), + AcpiUtGetNodeName (ObjDesc->BankField.BankObj->CommonField.Node)); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]", - AcpiUtGetNodeName (ObjDesc->IndexField.IndexObj->CommonField.Node), - AcpiUtGetNodeName (ObjDesc->IndexField.DataObj->CommonField.Node)); + AcpiUtGetNodeName (ObjDesc->IndexField.IndexObj->CommonField.Node), + AcpiUtGetNodeName (ObjDesc->IndexField.DataObj->CommonField.Node)); break; case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_METHOD_ALIAS: - AcpiOsPrintf ("Target %4.4s (%p)\n", AcpiUtGetNodeName (ObjDesc), ObjDesc); + AcpiOsPrintf ("Target %4.4s (%p)\n", + AcpiUtGetNodeName (ObjDesc), ObjDesc); break; default: @@ -470,10 +493,10 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_LOCAL_INDEX_FIELD: AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n", - (ObjDesc->CommonField.BaseByteOffset * 8) - + ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.BitLength, - ObjDesc->CommonField.AccessByteWidth); + (ObjDesc->CommonField.BaseByteOffset * 8) + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessByteWidth); break; default: @@ -493,8 +516,7 @@ AcpiNsDumpOneObject ( return (AE_OK); } - AcpiOsPrintf ("(R%d)", - ObjDesc->Common.ReferenceCount); + AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount); switch (Type) { @@ -576,13 +598,14 @@ AcpiNsDumpOneObject ( if (ObjType > ACPI_TYPE_LOCAL_MAX) { - AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType); + AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", + ObjType); BytesToDump = 32; } else { AcpiOsPrintf ("(Ptr to ACPI Object type %s, %X)\n", - AcpiUtGetTypeName (ObjType), ObjType); + AcpiUtGetTypeName (ObjType), ObjType); BytesToDump = sizeof (ACPI_OPERAND_OBJECT); } break; @@ -590,8 +613,9 @@ AcpiNsDumpOneObject ( default: - AcpiOsPrintf ("(String or Buffer ptr - not an object descriptor) [%s]\n", - AcpiUtGetDescriptorName (ObjDesc)); + AcpiOsPrintf ( + "(String or Buffer ptr - not an object descriptor) [%s]\n", + AcpiUtGetDescriptorName (ObjDesc)); BytesToDump = 16; break; } @@ -660,12 +684,15 @@ Cleanup: * FUNCTION: AcpiNsDumpObjects * * PARAMETERS: Type - Object type to be dumped - * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX + * DisplayType - 0 or ACPI_DISPLAY_SUMMARY + * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX * for an effectively unlimited depth. * OwnerId - Dump only objects owned by this ID. Use * ACPI_UINT32_MAX to match all owners. * StartHandle - Where in namespace to start/end search * + * RETURN: None + * * DESCRIPTION: Dump typed objects within the loaded namespace. * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. * @@ -697,6 +724,39 @@ AcpiNsDumpObjects ( /******************************************************************************* * + * FUNCTION: AcpiNsDumpEntry + * + * PARAMETERS: Handle - Node to be dumped + * DebugLevel - Output level + * + * RETURN: None + * + * DESCRIPTION: Dump a single Node + * + ******************************************************************************/ + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel) +{ + ACPI_WALK_INFO Info; + + + ACPI_FUNCTION_ENTRY (); + + + Info.DebugLevel = DebugLevel; + Info.OwnerId = ACPI_UINT32_MAX; + Info.DisplayType = ACPI_DISPLAY_SUMMARY; + + (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL); +} + + +#ifdef _ACPI_ASL_COMPILER +/******************************************************************************* + * * FUNCTION: AcpiNsDumpTables * * PARAMETERS: SearchBase - Root of subtree to be dumped, or @@ -704,6 +764,8 @@ AcpiNsDumpObjects ( * MaxDepth - Maximum depth of dump. Use INT_MAX * for an effectively unlimited depth. * + * RETURN: None + * * DESCRIPTION: Dump the name space, or a portion of it. * ******************************************************************************/ @@ -731,7 +793,7 @@ AcpiNsDumpTables ( if (ACPI_NS_ALL == SearchBase) { - /* entire namespace */ + /* Entire namespace */ SearchHandle = AcpiGbl_RootNode; ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); @@ -741,36 +803,6 @@ AcpiNsDumpTables ( ACPI_UINT32_MAX, SearchHandle); return_VOID; } - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpEntry - * - * PARAMETERS: Handle - Node to be dumped - * DebugLevel - Output level - * - * DESCRIPTION: Dump a single Node - * - ******************************************************************************/ - -void -AcpiNsDumpEntry ( - ACPI_HANDLE Handle, - UINT32 DebugLevel) -{ - ACPI_WALK_INFO Info; - - - ACPI_FUNCTION_ENTRY (); - - - Info.DebugLevel = DebugLevel; - Info.OwnerId = ACPI_UINT32_MAX; - Info.DisplayType = ACPI_DISPLAY_SUMMARY; - - (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL); -} - +#endif #endif diff --git a/sys/dev/acpi/acpica/Subsystem/nsdumpdv.c b/sys/dev/acpi/acpica/Subsystem/nsdumpdv.c index 3317785f36f..814914162ae 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsdumpdv.c +++ b/sys/dev/acpi/acpica/Subsystem/nsdumpdv.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsdump - table dumping routines for debug - * xRevision: 10 $ + * xRevision: 16 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,20 +116,23 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsdumpdv.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsdumpdv.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #define __NSDUMPDV_C__ #include "acpi.h" -#include "acnamesp.h" +/* TBD: This entire module is apparently obsolete and should be removed */ + #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsdumpdv") - +#ifdef ACPI_OBSOLETE_FUNCTIONS #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +#include "acnamesp.h" + /******************************************************************************* * * FUNCTION: AcpiNsDumpOneDevice @@ -137,13 +140,16 @@ __KERNEL_RCSID(0, "$NetBSD: nsdumpdv.c,v 1.5 2004/02/14 16:57:24 kochi Exp $"); * PARAMETERS: Handle - Node to be dumped * Level - Nesting level of the handle * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status * * DESCRIPTION: Dump a single Node that represents a device * This procedure is a UserFunction called by AcpiNsWalkNamespace. * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsDumpOneDevice ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -171,10 +177,10 @@ AcpiNsDumpOneDevice ( ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ")); } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", - Info->HardwareId.Value, - ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, + " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", + Info->HardwareId.Value, ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus)); ACPI_MEM_FREE (Info); } @@ -188,12 +194,15 @@ AcpiNsDumpOneDevice ( * * PARAMETERS: None * + * RETURN: None + * * DESCRIPTION: Dump all objects of type "device" * ******************************************************************************/ void -AcpiNsDumpRootDevices (void) +AcpiNsDumpRootDevices ( + void) { ACPI_HANDLE SysBusHandle; ACPI_STATUS Status; @@ -209,13 +218,14 @@ AcpiNsDumpRootDevices (void) return; } - Status = AcpiGetHandle (0, ACPI_NS_SYSTEM_BUS, &SysBusHandle); + Status = AcpiGetHandle (NULL, ACPI_NS_SYSTEM_BUS, &SysBusHandle); if (ACPI_FAILURE (Status)) { return; } - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Display of all devices in the namespace:\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "Display of all devices in the namespace:\n")); Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, @@ -223,5 +233,6 @@ AcpiNsDumpRootDevices (void) } #endif +#endif diff --git a/sys/dev/acpi/acpica/Subsystem/nseval.c b/sys/dev/acpi/acpica/Subsystem/nseval.c index ca75918cd7d..c84bc0cf0d1 100644 --- a/sys/dev/acpi/acpica/Subsystem/nseval.c +++ b/sys/dev/acpi/acpica/Subsystem/nseval.c @@ -2,7 +2,7 @@ * * Module Name: nseval - Object evaluation interfaces -- includes control * method lookup and execution. - * xRevision: 122 $ + * xRevision: 133 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nseval.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nseval.c,v 1.12 2005/05/02 14:52:09 kochi Exp $"); #define __NSEVAL_C__ @@ -130,24 +130,33 @@ __KERNEL_RCSID(0, "$NetBSD: nseval.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nseval") +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsExecuteControlMethod ( + ACPI_PARAMETER_INFO *Info); + +static ACPI_STATUS +AcpiNsGetObjectValue ( + ACPI_PARAMETER_INFO *Info); + /******************************************************************************* * * FUNCTION: AcpiNsEvaluateRelative * - * PARAMETERS: Handle - The relative containing object - * Pathname - Name of method to execute, If NULL, the - * handle is the object to execute - * Params - List of parameters to pass to the method, + * PARAMETERS: Pathname - Name of method to execute, If NULL, the + * handle is the object to execute + * Info - Method info block, contains: + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * Params - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. * * RETURN: Status * - * DESCRIPTION: Find and execute the requested method using the handle as a - * scope + * DESCRIPTION: Evaluate the object or find and execute the requested method * * MUTEX: Locks Namespace * @@ -155,16 +164,13 @@ __KERNEL_RCSID(0, "$NetBSD: nseval.c,v 1.11 2004/02/14 16:57:24 kochi Exp $"); ACPI_STATUS AcpiNsEvaluateRelative ( - ACPI_NAMESPACE_NODE *Handle, char *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject) + ACPI_PARAMETER_INFO *Info) { - ACPI_NAMESPACE_NODE *PrefixNode; ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node = NULL; + ACPI_GENERIC_STATE *ScopeInfo; char *InternalPath = NULL; - ACPI_GENERIC_STATE ScopeInfo; ACPI_FUNCTION_TRACE ("NsEvaluateRelative"); @@ -173,7 +179,7 @@ AcpiNsEvaluateRelative ( /* * Must have a valid object handle */ - if (!Handle) + if (!Info || !Info->Node) { return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -186,6 +192,12 @@ AcpiNsEvaluateRelative ( return_ACPI_STATUS (Status); } + ScopeInfo = AcpiUtCreateGenericState (); + if (!ScopeInfo) + { + goto Cleanup1; + } + /* Get the prefix handle and Node */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); @@ -194,8 +206,8 @@ AcpiNsEvaluateRelative ( goto Cleanup; } - PrefixNode = AcpiNsMapHandleToNode (Handle); - if (!PrefixNode) + Info->Node = AcpiNsMapHandleToNode (Info->Node); + if (!Info->Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Status = AE_BAD_PARAMETER; @@ -204,8 +216,8 @@ AcpiNsEvaluateRelative ( /* Lookup the name in the namespace */ - ScopeInfo.Scope.Node = PrefixNode; - Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, + ScopeInfo->Scope.Node = Info->Node; + Status = AcpiNsLookup (ScopeInfo, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, &Node); @@ -219,19 +231,21 @@ AcpiNsEvaluateRelative ( } /* - * Now that we have a handle to the object, we can attempt - * to evaluate it. + * Now that we have a handle to the object, we can attempt to evaluate it. */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Pathname, Node, AcpiNsGetAttachedObject (Node))); - Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); + Info->Node = Node; + Status = AcpiNsEvaluateByHandle (Info); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", Pathname)); Cleanup: + AcpiUtDeleteGenericState (ScopeInfo); +Cleanup1: ACPI_MEM_FREE (InternalPath); return_ACPI_STATUS (Status); } @@ -241,17 +255,18 @@ Cleanup: * * FUNCTION: AcpiNsEvaluateByName * - * PARAMETERS: Pathname - Fully qualified pathname to the object - * ReturnObject - Where to put method's return value (if + * PARAMETERS: Pathname - Fully qualified pathname to the object + * Info - Method info block, contains: + * ReturnObject - Where to put method's return value (if * any). If NULL, no value is returned. - * Params - List of parameters to pass to the method, + * Params - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. * * RETURN: Status * - * DESCRIPTION: Find and execute the requested method passing the given - * parameters + * DESCRIPTION: Evaluate the object or rind and execute the requested method + * passing the given parameters * * MUTEX: Locks Namespace * @@ -260,11 +275,9 @@ Cleanup: ACPI_STATUS AcpiNsEvaluateByName ( char *Pathname, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject) + ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node = NULL; char *InternalPath = NULL; @@ -289,25 +302,25 @@ AcpiNsEvaluateByName ( Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, - &Node); + &Info->Node); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object at [%s] was not found, status=%.4X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Object at [%s] was not found, status=%.4X\n", Pathname, Status)); goto Cleanup; } /* - * Now that we have a handle to the object, we can attempt - * to evaluate it. + * Now that we have a handle to the object, we can attempt to evaluate it. */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", - Pathname, Node, AcpiNsGetAttachedObject (Node))); + Pathname, Info->Node, AcpiNsGetAttachedObject (Info->Node))); - Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); + Status = AcpiNsEvaluateByHandle (Info); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", Pathname)); @@ -330,16 +343,21 @@ Cleanup: * * FUNCTION: AcpiNsEvaluateByHandle * - * PARAMETERS: Handle - Method Node to execute - * Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be + * PARAMETERS: Info - Method info block, contains: + * Node - Method/Object Node to execute + * Parameters - List of parameters to pass to the method, + * terminated by NULL. Params itself may be * NULL if no parameters are being passed. - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. * * RETURN: Status * - * DESCRIPTION: Execute the requested method passing the given parameters + * DESCRIPTION: Evaluate object or execute the requested method passing the + * given parameters * * MUTEX: Locks Namespace * @@ -347,13 +365,9 @@ Cleanup: ACPI_STATUS AcpiNsEvaluateByHandle ( - ACPI_NAMESPACE_NODE *Handle, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObject) + ACPI_PARAMETER_INFO *Info) { - ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *LocalReturnObject; ACPI_FUNCTION_TRACE ("NsEvaluateByHandle"); @@ -368,17 +382,14 @@ AcpiNsEvaluateByHandle ( /* Parameter Validation */ - if (!Handle) + if (!Info) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - if (ReturnObject) - { - /* Initialize the return value to an invalid object */ + /* Initialize the return value to an invalid object */ - *ReturnObject = NULL; - } + Info->ReturnObject = NULL; /* Get the prefix handle and Node */ @@ -388,68 +399,57 @@ AcpiNsEvaluateByHandle ( return_ACPI_STATUS (Status); } - Node = AcpiNsMapHandleToNode (Handle); - if (!Node) + Info->Node = AcpiNsMapHandleToNode (Info->Node); + if (!Info->Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* + * For a method alias, we must grab the actual method node so that proper + * scoping context will be established before execution. + */ + if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + { + Info->Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->Node->Object); + } + + /* * Two major cases here: * 1) The object is an actual control method -- execute it. - * 2) The object is not a method -- just return it's current - * value + * 2) The object is not a method -- just return it's current value * - * In both cases, the namespace is unlocked by the - * AcpiNs* procedure + * In both cases, the namespace is unlocked by the AcpiNs* procedure */ - if (AcpiNsGetType (Node) == ACPI_TYPE_METHOD) + if (AcpiNsGetType (Info->Node) == ACPI_TYPE_METHOD) { /* * Case 1) We have an actual control method to execute */ - Status = AcpiNsExecuteControlMethod (Node, Params, - &LocalReturnObject); + Status = AcpiNsExecuteControlMethod (Info); } else { /* - * Case 2) Object is NOT a method, just return its - * current value + * Case 2) Object is NOT a method, just return its current value */ - Status = AcpiNsGetObjectValue (Node, &LocalReturnObject); + Status = AcpiNsGetObjectValue (Info); } /* - * Check if there is a return value on the stack that must - * be dealt with + * Check if there is a return value on the stack that must be dealt with */ if (Status == AE_CTRL_RETURN_VALUE) { - /* - * If the Method returned a value and the caller - * provided a place to store a returned value, Copy - * the returned value to the object descriptor provided - * by the caller. - */ - if (ReturnObject) - { - /* - * Valid return object, copy the pointer to - * the returned object - */ - *ReturnObject = LocalReturnObject; - } - /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ Status = AE_OK; } /* - * Namespace was unlocked by the handling AcpiNs* function, - * so we just return + * Namespace was unlocked by the handling AcpiNs* function, so we + * just return */ return_ACPI_STATUS (Status); } @@ -459,12 +459,16 @@ AcpiNsEvaluateByHandle ( * * FUNCTION: AcpiNsExecuteControlMethod * - * PARAMETERS: MethodNode - The method to execute - * Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be + * PARAMETERS: Info - Method info block, contains: + * Node - Method Node to execute + * Parameters - List of parameters to pass to the method, + * terminated by NULL. Params itself may be * NULL if no parameters are being passed. - * ReturnObjDesc - List of result objects to be returned - * from the method. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. * * RETURN: Status * @@ -474,11 +478,9 @@ AcpiNsEvaluateByHandle ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsExecuteControlMethod ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc) + ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; @@ -489,7 +491,7 @@ AcpiNsExecuteControlMethod ( /* Verify that there is a method associated with this object */ - ObjDesc = AcpiNsGetAttachedObject (MethodNode); + ObjDesc = AcpiNsGetAttachedObject (Info->Node); if (!ObjDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); @@ -498,7 +500,7 @@ AcpiNsExecuteControlMethod ( return_ACPI_STATUS (AE_NULL_OBJECT); } - ACPI_DUMP_PATHNAME (MethodNode, "Execute Method:", + ACPI_DUMP_PATHNAME (Info->Node, "Execute Method:", ACPI_LV_INFO, _COMPONENT); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", @@ -527,7 +529,7 @@ AcpiNsExecuteControlMethod ( return_ACPI_STATUS (Status); } - Status = AcpiPsxExecute (MethodNode, Params, ReturnObjDesc); + Status = AcpiPsxExecute (Info); AcpiExExitInterpreter (); return_ACPI_STATUS (Status); @@ -538,8 +540,10 @@ AcpiNsExecuteControlMethod ( * * FUNCTION: AcpiNsGetObjectValue * - * PARAMETERS: Node - The object - * ReturnObjDesc - Where the objects value is returned + * PARAMETERS: Info - Method info block, contains: + * Node - Object's NS node + * ReturnObject - Where to put object value (if + * any). If NULL, no value is returned. * * RETURN: Status * @@ -549,41 +553,37 @@ AcpiNsExecuteControlMethod ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsGetObjectValue ( - ACPI_NAMESPACE_NODE *Node, - ACPI_OPERAND_OBJECT **ReturnObjDesc) + ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status = AE_OK; - ACPI_NAMESPACE_NODE *ResolvedNode = Node; + ACPI_NAMESPACE_NODE *ResolvedNode = Info->Node; ACPI_FUNCTION_TRACE ("NsGetObjectValue"); /* - * Objects require additional resolution steps (e.g., the - * Node may be a field that must be read, etc.) -- we can't just grab - * the object out of the node. + * Objects require additional resolution steps (e.g., the Node may be a + * field that must be read, etc.) -- we can't just grab the object out of + * the node. */ /* - * Use ResolveNodeToValue() to get the associated value. This call - * always deletes ObjDesc (allocated above). + * Use ResolveNodeToValue() to get the associated value. This call always + * deletes ObjDesc (allocated above). * - * NOTE: we can get away with passing in NULL for a walk state - * because ObjDesc is guaranteed to not be a reference to either - * a method local or a method argument (because this interface can only be - * called from the AcpiEvaluate external interface, never called from - * a running control method.) + * NOTE: we can get away with passing in NULL for a walk state because + * ObjDesc is guaranteed to not be a reference to either a method local or + * a method argument (because this interface can only be called from the + * AcpiEvaluate external interface, never called from a running method.) * - * Even though we do not directly invoke the interpreter - * for this, we must enter it because we could access an opregion. - * The opregion access code assumes that the interpreter - * is locked. + * Even though we do not directly invoke the interpreter for this, we must + * enter it because we could access an opregion. The opregion access code + * assumes that the interpreter is locked. * - * We must release the namespace lock before entering the - * intepreter. + * We must release the namespace lock before entering the intepreter. */ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) @@ -596,17 +596,19 @@ AcpiNsGetObjectValue ( { Status = AcpiExResolveNodeToValue (&ResolvedNode, NULL); /* - * If AcpiExResolveNodeToValue() succeeded, the return value was - * placed in ResolvedNode. + * If AcpiExResolveNodeToValue() succeeded, the return value was placed + * in ResolvedNode. */ AcpiExExitInterpreter (); if (ACPI_SUCCESS (Status)) { Status = AE_CTRL_RETURN_VALUE; - *ReturnObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ResolvedNode); + Info->ReturnObject = ACPI_CAST_PTR + (ACPI_OPERAND_OBJECT, ResolvedNode); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", - *ReturnObjDesc, AcpiUtGetObjectTypeName (*ReturnObjDesc))); + Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); } } diff --git a/sys/dev/acpi/acpica/Subsystem/nsinit.c b/sys/dev/acpi/acpica/Subsystem/nsinit.c index 221c7e81e55..479f74d0962 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsinit.c +++ b/sys/dev/acpi/acpica/Subsystem/nsinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsinit - namespace initialization - * xRevision: 58 $ + * xRevision: 68 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsinit.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsinit.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __NSXFINIT_C__ @@ -128,6 +128,22 @@ __KERNEL_RCSID(0, "$NetBSD: nsinit.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsinit") +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + /******************************************************************************* * @@ -155,7 +171,8 @@ AcpiNsInitializeObjects ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Completing Region/Field/Buffer/Package initialization:")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Completing Region/Field/Buffer/Package initialization:")); /* Set all init info to zero */ @@ -221,7 +238,8 @@ AcpiNsInitializeDevices ( Info.Num_STA = 0; Info.Num_INI = 0; - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Executing all Device _STA and_INI methods:")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Executing all Device _STA and_INI methods:")); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) @@ -229,7 +247,7 @@ AcpiNsInitializeDevices ( return_ACPI_STATUS (Status); } - /* Walk namespace for all objects of type Device or Processor */ + /* Walk namespace for all objects */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, TRUE, AcpiNsInitOneDevice, &Info, NULL); @@ -270,7 +288,7 @@ AcpiNsInitializeDevices ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsInitOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -342,8 +360,8 @@ AcpiNsInitOneObject ( } /* - * Each of these types can contain executable AML code within - * the declaration. + * Each of these types can contain executable AML code within the + * declaration. */ switch (Type) { @@ -353,21 +371,18 @@ AcpiNsInitOneObject ( Status = AcpiDsGetRegionArguments (ObjDesc); break; - case ACPI_TYPE_BUFFER_FIELD: Info->FieldInit++; Status = AcpiDsGetBufferFieldArguments (ObjDesc); break; - case ACPI_TYPE_BUFFER: Info->BufferInit++; Status = AcpiDsGetBufferArguments (ObjDesc); break; - case ACPI_TYPE_PACKAGE: Info->PackageInit++; @@ -388,16 +403,18 @@ AcpiNsInitOneObject ( AcpiFormatException (Status))); } - /* Print a dot for each object unless we are going to print the entire pathname */ - + /* + * Print a dot for each object unless we are going to print the entire + * pathname + */ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); } /* - * We ignore errors from above, and always return OK, since - * we don't want to abort the walk on any single error. + * We ignore errors from above, and always return OK, since we don't want + * to abort the walk on any single error. */ AcpiExExitInterpreter (); return (AE_OK); @@ -418,38 +435,43 @@ AcpiNsInitOneObject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsInitOneDevice ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue) { - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - UINT32 Flags; ACPI_DEVICE_WALK_INFO *Info = (ACPI_DEVICE_WALK_INFO *) Context; + ACPI_PARAMETER_INFO Pinfo; + UINT32 Flags; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("NsInitOneDevice"); - Node = AcpiNsMapHandleToNode (ObjHandle); - if (!Node) + Pinfo.Parameters = NULL; + Pinfo.ParameterType = ACPI_PARAM_ARGS; + + Pinfo.Node = AcpiNsMapHandleToNode (ObjHandle); + if (!Pinfo.Node) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* - * We will run _STA/_INI on Devices and Processors only + * We will run _STA/_INI on Devices, Processors and ThermalZones only */ - if ((Node->Type != ACPI_TYPE_DEVICE) && - (Node->Type != ACPI_TYPE_PROCESSOR)) + if ((Pinfo.Node->Type != ACPI_TYPE_DEVICE) && + (Pinfo.Node->Type != ACPI_TYPE_PROCESSOR) && + (Pinfo.Node->Type != ACPI_TYPE_THERMAL)) { return_ACPI_STATUS (AE_OK); } - if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && (!(AcpiDbgLevel & ACPI_LV_INFO))) + if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && + (!(AcpiDbgLevel & ACPI_LV_INFO))) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); } @@ -459,19 +481,20 @@ AcpiNsInitOneDevice ( /* * Run _STA to determine if we can run _INI on the device. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Node, "_STA")); - Status = AcpiUtExecute_STA (Node, &Flags); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, + Pinfo.Node, METHOD_NAME__STA)); + Status = AcpiUtExecute_STA (Pinfo.Node, &Flags); if (ACPI_FAILURE (Status)) { - if (Node->Type == ACPI_TYPE_DEVICE) + if (Pinfo.Node->Type == ACPI_TYPE_DEVICE) { /* Ignore error and move on to next device */ return_ACPI_STATUS (AE_OK); } - /* _STA is not required for Processor objects */ + /* _STA is not required for Processor or ThermalZone objects */ } else { @@ -488,8 +511,9 @@ AcpiNsInitOneDevice ( /* * The device is present. Run _INI. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, ObjHandle, "_INI")); - Status = AcpiNsEvaluateRelative (ObjHandle, "_INI", NULL, NULL); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, + Pinfo.Node, METHOD_NAME__INI)); + Status = AcpiNsEvaluateRelative (METHOD_NAME__INI, &Pinfo); if (ACPI_FAILURE (Status)) { /* No _INI (AE_NOT_FOUND) means device requires no initialization */ @@ -498,20 +522,27 @@ AcpiNsInitOneDevice ( { /* Ignore error and move on to next device */ - #ifdef ACPI_DEBUG_OUTPUT - char *ScopeName = AcpiNsGetExternalPathname (ObjHandle); +#ifdef ACPI_DEBUG_OUTPUT + char *ScopeName = AcpiNsGetExternalPathname (Pinfo.Node); ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n", ScopeName, AcpiFormatException (Status))); ACPI_MEM_FREE (ScopeName); - #endif +#endif } Status = AE_OK; } else { + /* Delete any return object (especially if ImplicitReturn is enabled) */ + + if (Pinfo.ReturnObject) + { + AcpiUtRemoveReference (Pinfo.ReturnObject); + } + /* Count of successful INIs */ Info->Num_INI++; @@ -521,9 +552,8 @@ AcpiNsInitOneDevice ( { /* External initialization handler is present, call it */ - Status = AcpiGbl_InitHandler (ObjHandle, ACPI_INIT_DEVICE_INI); + Status = AcpiGbl_InitHandler (Pinfo.Node, ACPI_INIT_DEVICE_INI); } - return_ACPI_STATUS (Status); } diff --git a/sys/dev/acpi/acpica/Subsystem/nsload.c b/sys/dev/acpi/acpica/Subsystem/nsload.c index e94c7d78d2f..a1569ba8510 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsload.c +++ b/sys/dev/acpi/acpica/Subsystem/nsload.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsload - namespace loading/expanding/contracting procedures - * xRevision: 67 $ + * xRevision: 72 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsload.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsload.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __NSLOAD_C__ @@ -127,9 +127,24 @@ __KERNEL_RCSID(0, "$NetBSD: nsload.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsload") +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsLoadTableByType ( + ACPI_TABLE_TYPE TableType); + +#ifdef ACPI_FUTURE_IMPLEMENTATION +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle); + +static ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle); +#endif -#ifndef ACPI_NO_METHOD_EXECUTION +#ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* * * FUNCTION: AcpiNsLoadTable @@ -171,13 +186,15 @@ AcpiNsLoadTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", TableDesc->AmlStart)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", + TableDesc->AmlStart)); /* Ignore table if there is no AML contained within */ if (!TableDesc->AmlLength) { - ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", TableDesc->Pointer->Signature)); + ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", + TableDesc->Pointer->Signature)); return_ACPI_STATUS (AE_OK); } @@ -190,7 +207,8 @@ AcpiNsLoadTable ( * to another control method, we can't continue parsing * because we don't know how many arguments to parse next! */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Loading table into namespace ****\n")); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) @@ -238,7 +256,7 @@ AcpiNsLoadTable ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsLoadTableByType ( ACPI_TABLE_TYPE TableType) { @@ -282,7 +300,6 @@ AcpiNsLoadTableByType ( { TableDesc->LoadedIntoNamespace = TRUE; } - break; @@ -344,7 +361,6 @@ AcpiNsLoadTableByType ( TableDesc = TableDesc->Next; } - break; @@ -414,6 +430,7 @@ AcpiNsLoadNamespace ( } +#ifdef ACPI_FUTURE_IMPLEMENTATION /******************************************************************************* * * FUNCTION: AcpiNsDeleteSubtree @@ -430,7 +447,7 @@ AcpiNsLoadNamespace ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsDeleteSubtree ( ACPI_HANDLE StartHandle) { @@ -446,7 +463,7 @@ AcpiNsDeleteSubtree ( ParentHandle = StartHandle; - ChildHandle = 0; + ChildHandle = NULL; Level = 1; /* @@ -469,7 +486,7 @@ AcpiNsDeleteSubtree ( /* Check if this object has any children */ if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle, - 0, &Dummy))) + NULL, &Dummy))) { /* * There is at least one child of this object, @@ -477,7 +494,7 @@ AcpiNsDeleteSubtree ( */ Level++; ParentHandle = ChildHandle; - ChildHandle = 0; + ChildHandle = NULL; } } else @@ -551,6 +568,6 @@ AcpiNsUnloadNamespace ( return_ACPI_STATUS (Status); } - +#endif #endif diff --git a/sys/dev/acpi/acpica/Subsystem/nsnames.c b/sys/dev/acpi/acpica/Subsystem/nsnames.c index dc4e6195761..b91f3db77aa 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsnames.c +++ b/sys/dev/acpi/acpica/Subsystem/nsnames.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsnames - Name manipulation and search - * xRevision: 84 $ + * xRevision: 90 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsnames.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsnames.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __NSNAMES_C__ @@ -127,6 +127,14 @@ __KERNEL_RCSID(0, "$NetBSD: nsnames.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsnames") +/* Local prototypes */ + +static void +AcpiNsBuildExternalPath ( + ACPI_NAMESPACE_NODE *Node, + ACPI_SIZE Size, + char *NameBuffer); + /******************************************************************************* * @@ -143,7 +151,7 @@ __KERNEL_RCSID(0, "$NetBSD: nsnames.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * ******************************************************************************/ -void +static void AcpiNsBuildExternalPath ( ACPI_NAMESPACE_NODE *Node, ACPI_SIZE Size, @@ -206,7 +214,7 @@ AcpiNsBuildExternalPath ( * * FUNCTION: AcpiNsGetExternalPathname * - * PARAMETERS: Node - NS node whose pathname is needed + * PARAMETERS: Node - Namespace node whose pathname is needed * * RETURN: Pointer to storage containing the fully qualified name of * the node, In external format (name segments separated by path @@ -284,7 +292,12 @@ AcpiNsGetPathnameLength ( NextNode = AcpiNsGetParentNode (NextNode); } - return (Size + 1); + if (!Size) + { + Size = 1; /* Root node case */ + } + + return (Size + 1); /* +1 for null string terminator */ } @@ -337,7 +350,8 @@ AcpiNsHandleToPathname ( AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", (char *) Buffer->Pointer, (UINT32) RequiredSize)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", + (char *) Buffer->Pointer, (UINT32) RequiredSize)); return_ACPI_STATUS (AE_OK); } diff --git a/sys/dev/acpi/acpica/Subsystem/nsobject.c b/sys/dev/acpi/acpica/Subsystem/nsobject.c index 435b84f4f17..05b96ecc3e0 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsobject.c +++ b/sys/dev/acpi/acpica/Subsystem/nsobject.c @@ -2,7 +2,7 @@ * * Module Name: nsobject - Utilities for objects attached to namespace * table entries - * xRevision: 90 $ + * xRevision: 93 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsobject.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsobject.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __NSOBJECT_C__ @@ -138,6 +138,8 @@ __KERNEL_RCSID(0, "$NetBSD: nsobject.c,v 1.10 2004/02/14 16:57:24 kochi Exp $"); * Type - Type of object, or ACPI_TYPE_ANY if not * known * + * RETURN: Status + * * DESCRIPTION: Record the given object as the value associated with the * name whose ACPI_HANDLE is passed. If Object is NULL * and Type is ACPI_TYPE_ANY, set the name as having no value. @@ -177,7 +179,8 @@ AcpiNsAttachObject ( { /* Null object */ - ACPI_REPORT_ERROR (("NsAttachObject: Null object, but type not ACPI_TYPE_ANY\n")); + ACPI_REPORT_ERROR (( + "NsAttachObject: Null object, but type not ACPI_TYPE_ANY\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -194,7 +197,8 @@ AcpiNsAttachObject ( if (Node->Object == Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj %p already installed in NameObj %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj %p already installed in NameObj %p\n", Object, Node)); return_ACPI_STATUS (AE_OK); @@ -280,7 +284,7 @@ AcpiNsAttachObject ( * * FUNCTION: AcpiNsDetachObject * - * PARAMETERS: Node - An node whose object will be detached + * PARAMETERS: Node - A Namespace node whose object will be detached * * RETURN: None. * @@ -339,7 +343,7 @@ AcpiNsDetachObject ( * * FUNCTION: AcpiNsGetAttachedObject * - * PARAMETERS: Node - Parent Node to be examined + * PARAMETERS: Node - Namespace node * * RETURN: Current value of the object field from the Node whose * handle is passed @@ -377,7 +381,7 @@ AcpiNsGetAttachedObject ( * * FUNCTION: AcpiNsGetSecondaryObject * - * PARAMETERS: Node - Parent Node to be examined + * PARAMETERS: Node - Namespace node * * RETURN: Current value of the object field from the Node whose * handle is passed. diff --git a/sys/dev/acpi/acpica/Subsystem/nsparse.c b/sys/dev/acpi/acpica/Subsystem/nsparse.c index 0880cff5931..a045a7e7bad 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsparse.c +++ b/sys/dev/acpi/acpica/Subsystem/nsparse.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsparse - namespace interface to AML parser - * xRevision: 5 $ + * xRevision: 7 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsparse.c,v 1.5 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsparse.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #define __NSPARSE_C__ @@ -173,8 +173,9 @@ AcpiNsOneCompleteParse ( return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, TableDesc->AmlStart, - TableDesc->AmlLength, NULL, NULL, PassNumber); + Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, + TableDesc->AmlStart, TableDesc->AmlLength, + NULL, PassNumber); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); diff --git a/sys/dev/acpi/acpica/Subsystem/nssearch.c b/sys/dev/acpi/acpica/Subsystem/nssearch.c index 56684c4845e..f32bb812fe4 100644 --- a/sys/dev/acpi/acpica/Subsystem/nssearch.c +++ b/sys/dev/acpi/acpica/Subsystem/nssearch.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nssearch - Namespace search - * xRevision: 100 $ + * xRevision: 106 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nssearch.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nssearch.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __NSSEARCH_C__ @@ -126,15 +126,24 @@ __KERNEL_RCSID(0, "$NetBSD: nssearch.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nssearch") +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode); + /******************************************************************************* * * FUNCTION: AcpiNsSearchNode * - * PARAMETERS: *TargetName - Ascii ACPI name to search for - * *Node - Starting node where search will begin - * Type - Object type to match - * **ReturnNode - Where the matched Named obj is returned + * PARAMETERS: TargetName - Ascii ACPI name to search for + * Node - Starting node where search will begin + * Type - Object type to match + * ReturnNode - Where the matched Named obj is returned * * RETURN: Status * @@ -175,8 +184,10 @@ AcpiNsSearchNode ( ScopeName = AcpiNsGetExternalPathname (Node); if (ScopeName) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s (%p) For [%4.4s] (%s)\n", - ScopeName, Node, (char *) &TargetName, AcpiUtGetTypeName (Type))); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching %s (%p) For [%4.4s] (%s)\n", + ScopeName, Node, (char *) &TargetName, + AcpiUtGetTypeName (Type))); ACPI_MEM_FREE (ScopeName); } @@ -194,6 +205,13 @@ AcpiNsSearchNode ( if (NextNode->Name.Integer == TargetName) { + /* Resolve a control method alias if any */ + + if (AcpiNsGetType (NextNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + { + NextNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, NextNode->Object); + } + /* * Found matching entry. */ @@ -237,10 +255,10 @@ AcpiNsSearchNode ( * * FUNCTION: AcpiNsSearchParentTree * - * PARAMETERS: *TargetName - Ascii ACPI name to search for - * *Node - Starting node where search will begin - * Type - Object type to match - * **ReturnNode - Where the matched Named Obj is returned + * PARAMETERS: TargetName - Ascii ACPI name to search for + * Node - Starting node where search will begin + * Type - Object type to match + * ReturnNode - Where the matched Node is returned * * RETURN: Status * @@ -275,14 +293,14 @@ AcpiNsSearchParentTree ( ParentNode = AcpiNsGetParentNode (Node); /* - * If there is no parent (i.e., we are at the root) or - * type is "local", we won't be searching the parent tree. + * If there is no parent (i.e., we are at the root) or type is "local", + * we won't be searching the parent tree. */ if (!ParentNode) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", (char *) &TargetName)); - return_ACPI_STATUS (AE_NOT_FOUND); + return_ACPI_STATUS (AE_NOT_FOUND); } if (AcpiNsLocal (Type)) @@ -295,11 +313,12 @@ AcpiNsSearchParentTree ( /* Search the parent tree */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching parent for %4.4s\n", (char *) &TargetName)); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching parent [%4.4s] for [%4.4s]\n", + AcpiUtGetNodeName (ParentNode), (char *) &TargetName)); /* - * Search parents until found the target or we have backed up to - * the root + * Search parents until target is found or we have backed up to the root */ while (ParentNode) { @@ -309,7 +328,7 @@ AcpiNsSearchParentTree ( * the actual name we are searching for. Typechecking comes later. */ Status = AcpiNsSearchNode (TargetName, ParentNode, - ACPI_TYPE_ANY, ReturnNode); + ACPI_TYPE_ANY, ReturnNode); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); @@ -334,12 +353,12 @@ AcpiNsSearchParentTree ( * * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) * WalkState - Current state of the walk - * *Node - Starting node where search will begin + * Node - Starting node where search will begin * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x. * Otherwise,search only. * Type - Object type to match * Flags - Flags describing the search restrictions - * **ReturnNode - Where the Node is returned + * ReturnNode - Where the Node is returned * * RETURN: Status * @@ -374,7 +393,8 @@ AcpiNsSearchAndEnter ( if (!Node || !TargetName || !ReturnNode) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null param: Node %p Name %X ReturnNode %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null param: Node %p Name %X ReturnNode %p\n", Node, TargetName, ReturnNode)); ACPI_REPORT_ERROR (("NsSearchAndEnter: Null parameter\n")); @@ -414,23 +434,21 @@ AcpiNsSearchAndEnter ( } /* - * The name was not found. If we are NOT performing the - * first pass (name entry) of loading the namespace, search - * the parent tree (all the way to the root if necessary.) - * We don't want to perform the parent search when the - * namespace is actually being loaded. We want to perform - * the search when namespace references are being resolved - * (load pass 2) and during the execution phase. + * The name was not found. If we are NOT performing the first pass + * (name entry) of loading the namespace, search the parent tree (all the + * way to the root if necessary.) We don't want to perform the parent + * search when the namespace is actually being loaded. We want to perform + * the search when namespace references are being resolved (load pass 2) + * and during the execution phase. */ if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) && (Flags & ACPI_NS_SEARCH_PARENT)) { /* - * Not found at this level - search parent tree according - * to ACPI specification + * Not found at this level - search parent tree according to the + * ACPI specification */ - Status = AcpiNsSearchParentTree (TargetName, Node, - Type, ReturnNode); + Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); @@ -442,7 +460,8 @@ AcpiNsSearchAndEnter ( */ if (InterpreterMode == ACPI_IMODE_EXECUTE) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s Not found in %p [Not adding]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%4.4s Not found in %p [Not adding]\n", (char *) &TargetName, Node)); return_ACPI_STATUS (AE_NOT_FOUND); diff --git a/sys/dev/acpi/acpica/Subsystem/nsutils.c b/sys/dev/acpi/acpica/Subsystem/nsutils.c index 7c1529663f5..a670b086e0d 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsutils.c +++ b/sys/dev/acpi/acpica/Subsystem/nsutils.c @@ -2,7 +2,7 @@ * * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing * parents and siblings and Scope manipulation - * xRevision: 132 $ + * xRevision: 140 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsutils.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsutils.c,v 1.12 2005/05/02 14:52:09 kochi Exp $"); #define __NSUTILS_C__ @@ -128,6 +128,18 @@ __KERNEL_RCSID(0, "$NetBSD: nsutils.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsutils") +/* Local prototypes */ + +static BOOLEAN +AcpiNsValidPathSeparator ( + char Sep); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *NodeToSearch); +#endif + /******************************************************************************* * @@ -136,7 +148,8 @@ __KERNEL_RCSID(0, "$NetBSD: nsutils.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) - * Message - Error message to use on failure + * InternalName - Name or path of the namespace node + * LookupStatus - Exception code from NS lookup * * RETURN: None * @@ -163,13 +176,15 @@ AcpiNsReportError ( { /* There is a non-ascii character in the name */ - AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)\n", *(ACPI_CAST_PTR (UINT32, InternalName))); + AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)\n", + *(ACPI_CAST_PTR (UINT32, InternalName))); } else { /* Convert path to external format */ - Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalName, NULL, &Name); + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, + InternalName, NULL, &Name); /* Print target name */ @@ -201,6 +216,9 @@ AcpiNsReportError ( * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) * Message - Error message to use on failure + * PrefixNode - Prefix relative to the path + * Path - Path to the node + * MethodStatus - Execution status * * RETURN: None * @@ -224,7 +242,8 @@ AcpiNsReportMethodError ( if (Path) { - Status = AcpiNsGetNodeByPath (Path, PrefixNode, ACPI_NS_NO_UPSEARCH, &Node); + Status = AcpiNsGetNodeByPath (Path, PrefixNode, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("ReportMethodError: Could not get node\n"); @@ -242,8 +261,8 @@ AcpiNsReportMethodError ( * * FUNCTION: AcpiNsPrintNodePathname * - * PARAMETERS: Node - Object - * Msg - Prefix message + * PARAMETERS: Node - Object + * Message - Prefix message * * DESCRIPTION: Print an object's full namespace pathname * Manages allocation/freeing of a pathname buffer @@ -253,7 +272,7 @@ AcpiNsReportMethodError ( void AcpiNsPrintNodePathname ( ACPI_NAMESPACE_NODE *Node, - char *Msg) + char *Message) { ACPI_BUFFER Buffer; ACPI_STATUS Status; @@ -265,16 +284,16 @@ AcpiNsPrintNodePathname ( return; } - /* Convert handle to a full pathname and print it (with supplied message) */ + /* Convert handle to full pathname and print it (with supplied message) */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (Node, &Buffer); if (ACPI_SUCCESS (Status)) { - if (Msg) + if (Message) { - AcpiOsPrintf ("%s ", Msg); + AcpiOsPrintf ("%s ", Message); } AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node); @@ -308,7 +327,7 @@ AcpiNsValidRootPrefix ( * * FUNCTION: AcpiNsValidPathSeparator * - * PARAMETERS: Sep - Character to be checked + * PARAMETERS: Sep - Character to be checked * * RETURN: TRUE if a valid path separator * @@ -316,7 +335,7 @@ AcpiNsValidRootPrefix ( * ******************************************************************************/ -BOOLEAN +static BOOLEAN AcpiNsValidPathSeparator ( char Sep) { @@ -329,10 +348,12 @@ AcpiNsValidPathSeparator ( * * FUNCTION: AcpiNsGetType * - * PARAMETERS: Handle - Parent Node to be examined + * PARAMETERS: Node - Parent Node to be examined * * RETURN: Type field from Node whose handle is passed * + * DESCRIPTION: Return the type of a Namespace node + * ******************************************************************************/ ACPI_OBJECT_TYPE @@ -344,7 +365,7 @@ AcpiNsGetType ( if (!Node) { - ACPI_REPORT_WARNING (("NsGetType: Null Node ptr")); + ACPI_REPORT_WARNING (("NsGetType: Null Node input pointer\n")); return_VALUE (ACPI_TYPE_ANY); } @@ -356,11 +377,13 @@ AcpiNsGetType ( * * FUNCTION: AcpiNsLocal * - * PARAMETERS: Type - A namespace object type + * PARAMETERS: Type - A namespace object type * * RETURN: LOCAL if names must be found locally in objects of the * passed type, 0 if enclosing scopes should be searched * + * DESCRIPTION: Returns scope rule for the given object type. + * ******************************************************************************/ UINT32 @@ -389,7 +412,7 @@ AcpiNsLocal ( * PARAMETERS: Info - Info struct initialized with the * external name pointer. * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Calculate the length of the internal (AML) namestring * corresponding to the external (ASL) namestring. @@ -413,13 +436,11 @@ AcpiNsGetInternalNameLength ( Info->FullyQualified = FALSE; /* - * For the internal name, the required length is 4 bytes - * per segment, plus 1 each for RootPrefix, MultiNamePrefixOp, - * segment count, trailing null (which is not really needed, - * but no there's harm in putting it there) + * For the internal name, the required length is 4 bytes per segment, plus + * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null + * (which is not really needed, but no there's harm in putting it there) * - * strlen() + 1 covers the first NameSeg, which has no - * path separator + * strlen() + 1 covers the first NameSeg, which has no path separator */ if (AcpiNsValidRootPrefix (NextExternalChar[0])) { @@ -439,10 +460,9 @@ AcpiNsGetInternalNameLength ( } /* - * Determine the number of ACPI name "segments" by counting - * the number of path separators within the string. Start - * with one segment since the segment count is (# separators) - * + 1, and zero separators is ok. + * Determine the number of ACPI name "segments" by counting the number of + * path separators within the string. Start with one segment since the + * segment count is [(# separators) + 1], and zero separators is ok. */ if (*NextExternalChar) { @@ -666,14 +686,16 @@ AcpiNsInternalizeName ( * * FUNCTION: AcpiNsExternalizeName * - * PARAMETERS: *InternalName - Internal representation of name - * **ConvertedName - Where to return the resulting - * external representation of name + * PARAMETERS: InternalNameLength - Lenth of the internal name below + * InternalName - Internal representation of name + * ConvertedNameLength - Where the length is returned + * ConvertedName - Where the resulting external name + * is returned * * RETURN: Status * * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) - * to its external form (e.g. "\_PR_.CPU0") + * to its external (printable) form (e.g. "\_PR_.CPU0") * ******************************************************************************/ @@ -748,7 +770,8 @@ AcpiNsExternalizeName ( /* <count> 4-byte names */ NamesIndex = PrefixLength + 2; - NumSegments = (ACPI_NATIVE_UINT) (UINT8) InternalName[(ACPI_NATIVE_UINT) (PrefixLength + 1)]; + NumSegments = (ACPI_NATIVE_UINT) (UINT8) + InternalName[(ACPI_NATIVE_UINT) (PrefixLength + 1)]; break; case AML_DUAL_NAME_PREFIX: @@ -796,7 +819,7 @@ AcpiNsExternalizeName ( } /* - * Build ConvertedName... + * Build ConvertedName */ *ConvertedName = ACPI_MEM_CALLOCATE (RequiredLength); if (!(*ConvertedName)) @@ -846,8 +869,9 @@ AcpiNsExternalizeName ( * * DESCRIPTION: Convert a namespace handle to a real Node * - * Note: Real integer handles allow for more verification - * and keep all pointers within this subsystem. + * Note: Real integer handles would allow for more verification + * and keep all pointers within this subsystem - however this introduces + * more (and perhaps unnecessary) overhead. * ******************************************************************************/ @@ -889,7 +913,7 @@ AcpiNsMapHandleToNode ( * * PARAMETERS: Node - Node to be converted to a Handle * - * RETURN: An USER ACPI_HANDLE + * RETURN: A user handle * * DESCRIPTION: Convert a real Node to a namespace handle * @@ -907,7 +931,7 @@ AcpiNsConvertEntryToHandle ( return ((ACPI_HANDLE) Node); -/* --------------------------------------------------- +/* Example future implementation --------------------- if (!Node) { @@ -933,12 +957,13 @@ AcpiNsConvertEntryToHandle ( * * RETURN: none * - * DESCRIPTION: free memory allocated for table storage. + * DESCRIPTION: free memory allocated for namespace and ACPI table storage. * ******************************************************************************/ void -AcpiNsTerminate (void) +AcpiNsTerminate ( + void) { ACPI_OPERAND_OBJECT *ObjDesc; @@ -1078,9 +1103,6 @@ AcpiNsGetNodeByPath ( (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Cleanup: - - /* Cleanup */ - if (InternalPath) { ACPI_MEM_FREE (InternalPath); @@ -1091,55 +1113,6 @@ Cleanup: /******************************************************************************* * - * FUNCTION: AcpiNsFindParentName - * - * PARAMETERS: *ChildNode - Named Obj whose name is to be found - * - * RETURN: The ACPI name - * - * DESCRIPTION: Search for the given obj in its parent scope and return the - * name segment, or "????" if the parent name can't be found - * (which "should not happen"). - * - ******************************************************************************/ - -ACPI_NAME -AcpiNsFindParentName ( - ACPI_NAMESPACE_NODE *ChildNode) -{ - ACPI_NAMESPACE_NODE *ParentNode; - - - ACPI_FUNCTION_TRACE ("NsFindParentName"); - - - if (ChildNode) - { - /* Valid entry. Get the parent Node */ - - ParentNode = AcpiNsGetParentNode (ChildNode); - if (ParentNode) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Parent of %p [%4.4s] is %p [%4.4s]\n", - ChildNode, AcpiUtGetNodeName (ChildNode), - ParentNode, AcpiUtGetNodeName (ParentNode))); - - if (ParentNode->Name.Integer) - { - return_VALUE ((ACPI_NAME) ParentNode->Name.Integer); - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "unable to find parent of %p (%4.4s)\n", - ChildNode, AcpiUtGetNodeName (ChildNode))); - } - - return_VALUE (ACPI_UNKNOWN_NAME); -} - - -/******************************************************************************* - * * FUNCTION: AcpiNsGetParentNode * * PARAMETERS: Node - Current table entry @@ -1150,7 +1123,6 @@ AcpiNsFindParentName ( * ******************************************************************************/ - ACPI_NAMESPACE_NODE * AcpiNsGetParentNode ( ACPI_NAMESPACE_NODE *Node) @@ -1164,18 +1136,15 @@ AcpiNsGetParentNode ( } /* - * Walk to the end of this peer list. - * The last entry is marked with a flag and the peer - * pointer is really a pointer back to the parent. - * This saves putting a parent back pointer in each and - * every named object! + * Walk to the end of this peer list. The last entry is marked with a flag + * and the peer pointer is really a pointer back to the parent. This saves + * putting a parent back pointer in each and every named object! */ while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) { Node = Node->Peer; } - return (Node->Peer); } @@ -1186,15 +1155,14 @@ AcpiNsGetParentNode ( * * PARAMETERS: Node - Current table entry * - * RETURN: Next valid Node in the linked node list. NULL if no more valid - * nodess + * RETURN: Next valid Node in the linked node list. NULL if no more valid + * nodes. * * DESCRIPTION: Find the next valid node within a name table. * Useful for implementing NULL-end-of-list loops. * ******************************************************************************/ - ACPI_NAMESPACE_NODE * AcpiNsGetNextValidNode ( ACPI_NAMESPACE_NODE *Node) @@ -1213,3 +1181,56 @@ AcpiNsGetNextValidNode ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiNsFindParentName + * + * PARAMETERS: *ChildNode - Named Obj whose name is to be found + * + * RETURN: The ACPI name + * + * DESCRIPTION: Search for the given obj in its parent scope and return the + * name segment, or "????" if the parent name can't be found + * (which "should not happen"). + * + ******************************************************************************/ + +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_TRACE ("NsFindParentName"); + + + if (ChildNode) + { + /* Valid entry. Get the parent Node */ + + ParentNode = AcpiNsGetParentNode (ChildNode); + if (ParentNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Parent of %p [%4.4s] is %p [%4.4s]\n", + ChildNode, AcpiUtGetNodeName (ChildNode), + ParentNode, AcpiUtGetNodeName (ParentNode))); + + if (ParentNode->Name.Integer) + { + return_VALUE ((ACPI_NAME) ParentNode->Name.Integer); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Unable to find parent of %p (%4.4s)\n", + ChildNode, AcpiUtGetNodeName (ChildNode))); + } + + return_VALUE (ACPI_UNKNOWN_NAME); +} +#endif + + diff --git a/sys/dev/acpi/acpica/Subsystem/nswalk.c b/sys/dev/acpi/acpica/Subsystem/nswalk.c index c56e8fdef3e..bcd7e1a25a2 100644 --- a/sys/dev/acpi/acpica/Subsystem/nswalk.c +++ b/sys/dev/acpi/acpica/Subsystem/nswalk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nswalk - Functions for walking the ACPI namespace - * xRevision: 36 $ + * xRevision: 39 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nswalk.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nswalk.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __NSWALK_C__ @@ -134,7 +134,7 @@ __KERNEL_RCSID(0, "$NetBSD: nswalk.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * * PARAMETERS: Type - Type of node to be searched for * ParentNode - Parent node whose children we are - * getting + * getting * ChildNode - Previous child that was found. * The NEXT child will be returned * @@ -268,7 +268,7 @@ AcpiNsWalkNamespace ( /* Null child means "get first node" */ ParentNode = StartNode; - ChildNode = 0; + ChildNode = NULL; ChildType = ACPI_TYPE_ANY; Level = 1; @@ -353,15 +353,15 @@ AcpiNsWalkNamespace ( */ if ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH)) { - if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, 0)) + if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) { /* * There is at least one child of this * node, visit the onde */ Level++; - ParentNode = ChildNode; - ChildNode = 0; + ParentNode = ChildNode; + ChildNode = NULL; } } } diff --git a/sys/dev/acpi/acpica/Subsystem/nsxfeval.c b/sys/dev/acpi/acpica/Subsystem/nsxfeval.c index bb615cb365b..d5761d38666 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsxfeval.c +++ b/sys/dev/acpi/acpica/Subsystem/nsxfeval.c @@ -2,7 +2,7 @@ * * Module Name: nsxfeval - Public interfaces to the ACPI subsystem * ACPI Object evaluation interfaces - * xRevision: 11 $ + * xRevision: 17 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,12 +117,13 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsxfeval.c,v 1.5 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsxfeval.c,v 1.6 2005/05/02 14:52:09 kochi Exp $"); #define __NSXFEVAL_C__ #include "acpi.h" #include "acnamesp.h" +#include "acinterp.h" #define _COMPONENT ACPI_NAMESPACE @@ -134,11 +135,11 @@ __KERNEL_RCSID(0, "$NetBSD: nsxfeval.c,v 1.5 2004/02/14 16:57:25 kochi Exp $"); * FUNCTION: AcpiEvaluateObjectTyped * * PARAMETERS: Handle - Object handle (optional) - * *Pathname - Object pathname (optional) - * **ExternalParams - List of parameters to pass to method, + * Pathname - Object pathname (optional) + * ExternalParams - List of parameters to pass to method, * terminated by NULL. May be NULL * if no parameters are being passed. - * *ReturnBuffer - Where to put method's return value (if + * ReturnBuffer - Where to put method's return value (if * any). If NULL, no value is returned. * ReturnType - Expected type of return object * @@ -234,11 +235,11 @@ AcpiEvaluateObjectTyped ( * FUNCTION: AcpiEvaluateObject * * PARAMETERS: Handle - Object handle (optional) - * *Pathname - Object pathname (optional) - * **ExternalParams - List of parameters to pass to method, + * Pathname - Object pathname (optional) + * ExternalParams - List of parameters to pass to method, * terminated by NULL. May be NULL * if no parameters are being passed. - * *ReturnBuffer - Where to put method's return value (if + * ReturnBuffer - Where to put method's return value (if * any). If NULL, no value is returned. * * RETURN: Status @@ -257,8 +258,8 @@ AcpiEvaluateObject ( ACPI_BUFFER *ReturnBuffer) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT **InternalParams = NULL; - ACPI_OPERAND_OBJECT *InternalReturnObj = NULL; + ACPI_STATUS Status2; + ACPI_PARAMETER_INFO Info; ACPI_SIZE BufferSpaceNeeded; UINT32 i; @@ -266,6 +267,11 @@ AcpiEvaluateObject ( ACPI_FUNCTION_TRACE ("AcpiEvaluateObject"); + Info.Node = Handle; + Info.Parameters = NULL; + Info.ReturnObject = NULL; + Info.ParameterType = ACPI_PARAM_ARGS; + /* * If there are parameters to be passed to the object * (which must be a control method), the external objects @@ -277,9 +283,10 @@ AcpiEvaluateObject ( * Allocate a new parameter block for the internal objects * Add 1 to count to allow for null terminated internal list */ - InternalParams = ACPI_MEM_CALLOCATE (((ACPI_SIZE) ExternalParams->Count + 1) * - sizeof (void *)); - if (!InternalParams) + Info.Parameters = ACPI_MEM_CALLOCATE ( + ((ACPI_SIZE) ExternalParams->Count + 1) * + sizeof (void *)); + if (!Info.Parameters) { return_ACPI_STATUS (AE_NO_MEMORY); } @@ -291,16 +298,17 @@ AcpiEvaluateObject ( for (i = 0; i < ExternalParams->Count; i++) { Status = AcpiUtCopyEobjectToIobject (&ExternalParams->Pointer[i], - &InternalParams[i]); + &Info.Parameters[i]); if (ACPI_FAILURE (Status)) { - AcpiUtDeleteInternalObjectList (InternalParams); + AcpiUtDeleteInternalObjectList (Info.Parameters); return_ACPI_STATUS (Status); } } - InternalParams[ExternalParams->Count] = NULL; + Info.Parameters[ExternalParams->Count] = NULL; } + /* * Three major cases: * 1) Fully qualified pathname @@ -313,8 +321,7 @@ AcpiEvaluateObject ( /* * The path is fully qualified, just evaluate by name */ - Status = AcpiNsEvaluateByName (Pathname, InternalParams, - &InternalReturnObj); + Status = AcpiNsEvaluateByName (Pathname, &Info); } else if (!Handle) { @@ -349,16 +356,14 @@ AcpiEvaluateObject ( * The null pathname case means the handle is for * the actual object to be evaluated */ - Status = AcpiNsEvaluateByHandle (Handle, InternalParams, - &InternalReturnObj); + Status = AcpiNsEvaluateByHandle (&Info); } else { /* * Both a Handle and a relative Pathname */ - Status = AcpiNsEvaluateRelative (Handle, Pathname, InternalParams, - &InternalReturnObj); + Status = AcpiNsEvaluateRelative (Pathname, &Info); } } @@ -369,13 +374,13 @@ AcpiEvaluateObject ( */ if (ReturnBuffer) { - if (!InternalReturnObj) + if (!Info.ReturnObject) { ReturnBuffer->Length = 0; } else { - if (ACPI_GET_DESCRIPTOR_TYPE (InternalReturnObj) == ACPI_DESC_TYPE_NAMED) + if (ACPI_GET_DESCRIPTOR_TYPE (Info.ReturnObject) == ACPI_DESC_TYPE_NAMED) { /* * If we received a NS Node as a return object, this means that @@ -386,7 +391,7 @@ AcpiEvaluateObject ( * support for various types at a later date if necessary. */ Status = AE_TYPE; - InternalReturnObj = NULL; /* No need to delete a NS Node */ + Info.ReturnObject = NULL; /* No need to delete a NS Node */ ReturnBuffer->Length = 0; } @@ -396,13 +401,14 @@ AcpiEvaluateObject ( * Find out how large a buffer is needed * to contain the returned object */ - Status = AcpiUtGetObjectSize (InternalReturnObj, + Status = AcpiUtGetObjectSize (Info.ReturnObject, &BufferSpaceNeeded); if (ACPI_SUCCESS (Status)) { /* Validate/Allocate/Clear caller buffer */ - Status = AcpiUtInitializeBuffer (ReturnBuffer, BufferSpaceNeeded); + Status = AcpiUtInitializeBuffer (ReturnBuffer, + BufferSpaceNeeded); if (ACPI_FAILURE (Status)) { /* @@ -410,14 +416,15 @@ AcpiEvaluateObject ( */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Needed buffer size %X, %s\n", - (UINT32) BufferSpaceNeeded, AcpiFormatException (Status))); + (UINT32) BufferSpaceNeeded, + AcpiFormatException (Status))); } else { /* * We have enough space for the object, build it */ - Status = AcpiUtCopyIobjectToEobject (InternalReturnObj, + Status = AcpiUtCopyIobjectToEobject (Info.ReturnObject, ReturnBuffer); } } @@ -425,25 +432,32 @@ AcpiEvaluateObject ( } } - /* Delete the return and parameter objects */ - - if (InternalReturnObj) + if (Info.ReturnObject) { /* - * Delete the internal return object. (Or at least - * decrement the reference count by one) + * Delete the internal return object. NOTE: Interpreter + * must be locked to avoid race condition. */ - AcpiUtRemoveReference (InternalReturnObj); + Status2 = AcpiExEnterInterpreter (); + if (ACPI_SUCCESS (Status2)) + { + /* + * Delete the internal return object. (Or at least + * decrement the reference count by one) + */ + AcpiUtRemoveReference (Info.ReturnObject); + AcpiExExitInterpreter (); + } } /* * Free the input parameter list (if we created one), */ - if (InternalParams) + if (Info.Parameters) { /* Free the allocated parameter block */ - AcpiUtDeleteInternalObjectList (InternalParams); + AcpiUtDeleteInternalObjectList (Info.Parameters); } return_ACPI_STATUS (Status); @@ -516,7 +530,8 @@ AcpiWalkNamespace ( return_ACPI_STATUS (Status); } - Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, ACPI_NS_WALK_UNLOCK, + Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, + ACPI_NS_WALK_UNLOCK, UserFunction, Context, ReturnValue); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -630,7 +645,8 @@ AcpiNsGetDeviceCallback ( } } - Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, ReturnValue); + Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, + ReturnValue); return (Status); } diff --git a/sys/dev/acpi/acpica/Subsystem/nsxfname.c b/sys/dev/acpi/acpica/Subsystem/nsxfname.c index b61c24a7a64..80a7fde23ed 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsxfname.c +++ b/sys/dev/acpi/acpica/Subsystem/nsxfname.c @@ -2,7 +2,7 @@ * * Module Name: nsxfname - Public interfaces to the ACPI subsystem * ACPI Namespace oriented interfaces - * xRevision: 99 $ + * xRevision: 104 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsxfname.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsxfname.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __NSXFNAME_C__ @@ -133,9 +133,9 @@ __KERNEL_RCSID(0, "$NetBSD: nsxfname.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * FUNCTION: AcpiGetHandle * * PARAMETERS: Parent - Object to search under (search scope). - * PathName - Pointer to an asciiz string containing the - * name - * RetHandle - Where the return handle is placed + * Pathname - Pointer to an asciiz string containing the + * name + * RetHandle - Where the return handle is returned * * RETURN: Status * @@ -307,7 +307,7 @@ UnlockAndExit: * FUNCTION: AcpiGetObjectInfo * * PARAMETERS: Handle - Object Handle - * Info - Where the info is returned + * Buffer - Where the info is returned * * RETURN: Status * @@ -324,7 +324,7 @@ AcpiGetObjectInfo ( { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; - ACPI_DEVICE_INFO Info; + ACPI_DEVICE_INFO *Info; ACPI_DEVICE_INFO *ReturnInfo; ACPI_COMPATIBLE_ID_LIST *CidList = NULL; ACPI_SIZE Size; @@ -343,61 +343,66 @@ AcpiGetObjectInfo ( return (Status); } + Info = ACPI_MEM_CALLOCATE (sizeof (ACPI_DEVICE_INFO)); + if (!Info) + { + return (AE_NO_MEMORY); + } + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - return (Status); + goto Cleanup; } Node = AcpiNsMapHandleToNode (Handle); if (!Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); + goto Cleanup; } /* Init return structure */ Size = sizeof (ACPI_DEVICE_INFO); - ACPI_MEMSET (&Info, 0, Size); - Info.Type = Node->Type; - Info.Name = Node->Name.Integer; - Info.Valid = 0; + Info->Type = Node->Type; + Info->Name = Node->Name.Integer; + Info->Valid = 0; Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - return (Status); + goto Cleanup; } /* If not a device, we are all done */ - if (Info.Type == ACPI_TYPE_DEVICE) + if (Info->Type == ACPI_TYPE_DEVICE) { /* * Get extra info for ACPI Devices objects only: - * Run the Device _HID, _UID, _CID, _STA, and _ADR methods. + * Run the Device _HID, _UID, _CID, _STA, _ADR and _SxD methods. * * Note: none of these methods are required, so they may or may - * not be present for this device. The Info.Valid bitfield is used + * not be present for this device. The Info->Valid bitfield is used * to indicate which methods were found and ran successfully. */ /* Execute the Device._HID method */ - Status = AcpiUtExecute_HID (Node, &Info.HardwareId); + Status = AcpiUtExecute_HID (Node, &Info->HardwareId); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_HID; + Info->Valid |= ACPI_VALID_HID; } /* Execute the Device._UID method */ - Status = AcpiUtExecute_UID (Node, &Info.UniqueId); + Status = AcpiUtExecute_UID (Node, &Info->UniqueId); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_UID; + Info->Valid |= ACPI_VALID_UID; } /* Execute the Device._CID method */ @@ -407,27 +412,33 @@ AcpiGetObjectInfo ( { Size += ((ACPI_SIZE) CidList->Count - 1) * sizeof (ACPI_COMPATIBLE_ID); - Info.Valid |= ACPI_VALID_CID; + Info->Valid |= ACPI_VALID_CID; } /* Execute the Device._STA method */ - Status = AcpiUtExecute_STA (Node, &Info.CurrentStatus); + Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_STA; + Info->Valid |= ACPI_VALID_STA; } /* Execute the Device._ADR method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, - &Info.Address); + &Info->Address); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_ADR; + Info->Valid |= ACPI_VALID_ADR; } - Status = AE_OK; + /* Execute the Device._SxD methods */ + + Status = AcpiUtExecute_Sxds (Node, Info->HighestDstates); + if (ACPI_SUCCESS (Status)) + { + Info->Valid |= ACPI_VALID_SXDS; + } } /* Validate/Allocate/Clear caller buffer */ @@ -441,7 +452,7 @@ AcpiGetObjectInfo ( /* Populate the return buffer */ ReturnInfo = Buffer->Pointer; - ACPI_MEMCPY (ReturnInfo, &Info, sizeof (ACPI_DEVICE_INFO)); + ACPI_MEMCPY (ReturnInfo, Info, sizeof (ACPI_DEVICE_INFO)); if (CidList) { @@ -450,6 +461,7 @@ AcpiGetObjectInfo ( Cleanup: + ACPI_MEM_FREE (Info); if (CidList) { ACPI_MEM_FREE (CidList); diff --git a/sys/dev/acpi/acpica/Subsystem/nsxfobj.c b/sys/dev/acpi/acpica/Subsystem/nsxfobj.c index 676ae0705c4..bb7714d3986 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsxfobj.c +++ b/sys/dev/acpi/acpica/Subsystem/nsxfobj.c @@ -2,7 +2,7 @@ * * Module Name: nsxfobj - Public interfaces to the ACPI subsystem * ACPI Object oriented interfaces - * xRevision: 117 $ + * xRevision: 119 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsxfobj.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsxfobj.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __NSXFOBJ_C__ @@ -133,7 +133,7 @@ __KERNEL_RCSID(0, "$NetBSD: nsxfobj.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * FUNCTION: AcpiGetType * * PARAMETERS: Handle - Handle of object whose type is desired - * *RetType - Where the type will be placed + * RetType - Where the type will be placed * * RETURN: Status * diff --git a/sys/dev/acpi/acpica/Subsystem/psargs.c b/sys/dev/acpi/acpica/Subsystem/psargs.c index 3eaefc3cc40..74457d554b2 100644 --- a/sys/dev/acpi/acpica/Subsystem/psargs.c +++ b/sys/dev/acpi/acpica/Subsystem/psargs.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psargs - Parse AML opcode arguments - * xRevision: 76 $ + * xRevision: 80 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psargs.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psargs.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __PSARGS_C__ @@ -127,6 +127,16 @@ __KERNEL_RCSID(0, "$NetBSD: psargs.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psargs") +/* Local prototypes */ + +static UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState); + +static ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState); + /******************************************************************************* * @@ -141,7 +151,7 @@ __KERNEL_RCSID(0, "$NetBSD: psargs.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * ******************************************************************************/ -UINT32 +static UINT32 AcpiPsGetNextPackageLength ( ACPI_PARSE_STATE *ParserState) { @@ -155,7 +165,6 @@ AcpiPsGetNextPackageLength ( EncodedLength = (UINT32) ACPI_GET8 (ParserState->Aml); ParserState->Aml++; - switch (EncodedLength >> 6) /* bits 6-7 contain encoding scheme */ { case 0: /* 1-byte encoding (bits 0-5) */ @@ -370,15 +379,16 @@ AcpiPsGetNextNamepath ( * parent tree, but don't open a new scope -- we just want to lookup the * object (MUST BE mode EXECUTE to perform upsearch) */ - Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &Node); if (ACPI_SUCCESS (Status) && MethodCall) { if (Node->Type == ACPI_TYPE_METHOD) { - /* - * This name is actually a control method invocation - */ + /* This name is actually a control method invocation */ + MethodDesc = AcpiNsGetAttachedObject (Node); ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p Desc %p Path=%p\n", @@ -450,7 +460,7 @@ AcpiPsGetNextNamepath ( /* * We got a NOT_FOUND during table load or we encountered * a CondRefOf(x) where the target does not exist. - * -- either case is ok + * Either case is ok */ Status = AE_OK; } @@ -578,12 +588,13 @@ AcpiPsGetNextSimpleArg ( * ******************************************************************************/ -ACPI_PARSE_OBJECT * +static ACPI_PARSE_OBJECT * AcpiPsGetNextField ( ACPI_PARSE_STATE *ParserState) { - UINT32 AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, - ParserState->AmlStart); + UINT32 AmlOffset = (UINT32) + ACPI_PTR_DIFF (ParserState->Aml, + ParserState->AmlStart); ACPI_PARSE_OBJECT *Field; UINT16 Opcode; UINT32 Name; @@ -592,7 +603,7 @@ AcpiPsGetNextField ( ACPI_FUNCTION_TRACE ("PsGetNextField"); - /* determine field type */ + /* Determine field type */ switch (ACPI_GET8 (ParserState->Aml)) { @@ -614,7 +625,6 @@ AcpiPsGetNextField ( break; } - /* Allocate a new field op */ Field = AcpiPsAllocOp (Opcode); @@ -677,10 +687,10 @@ AcpiPsGetNextField ( * * FUNCTION: AcpiPsGetNextArg * - * PARAMETERS: ParserState - Current parser state object + * PARAMETERS: WalkState - Current state + * ParserState - Current parser state object * ArgType - The argument type (AML_*_ARG) - * ArgCount - If the argument points to a control method - * the method's argument is returned here. + * ReturnArg - Where the next arg is returned * * RETURN: Status, and an op object containing the next argument. * @@ -715,7 +725,7 @@ AcpiPsGetNextArg ( case ARGP_NAME: case ARGP_NAMESTRING: - /* constants, strings, and namestrings are all the same size */ + /* Constants, strings, and namestrings are all the same size */ Arg = AcpiPsAllocOp (AML_BYTE_OP); if (!Arg) @@ -756,7 +766,6 @@ AcpiPsGetNextArg ( { Arg = Field; } - Prev = Field; } @@ -781,8 +790,8 @@ AcpiPsGetNextArg ( /* Fill in bytelist data */ - Arg->Common.Value.Size = (UINT32) ACPI_PTR_DIFF (ParserState->PkgEnd, - ParserState->Aml); + Arg->Common.Value.Size = (UINT32) + ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); Arg->Named.Data = ParserState->Aml; /* Skip to End of byte data */ @@ -813,7 +822,7 @@ AcpiPsGetNextArg ( } else { - /* single complex argument, nothing returned */ + /* Single complex argument, nothing returned */ WalkState->ArgCount = 1; } @@ -823,7 +832,7 @@ AcpiPsGetNextArg ( case ARGP_DATAOBJ: case ARGP_TERMARG: - /* single complex argument, nothing returned */ + /* Single complex argument, nothing returned */ WalkState->ArgCount = 1; break; @@ -835,7 +844,7 @@ AcpiPsGetNextArg ( if (ParserState->Aml < ParserState->PkgEnd) { - /* non-empty list of variable arguments, nothing returned */ + /* Non-empty list of variable arguments, nothing returned */ WalkState->ArgCount = ACPI_VAR_ARGS; } diff --git a/sys/dev/acpi/acpica/Subsystem/psopcode.c b/sys/dev/acpi/acpica/Subsystem/psopcode.c index bff49c9e2de..220782c0d42 100644 --- a/sys/dev/acpi/acpica/Subsystem/psopcode.c +++ b/sys/dev/acpi/acpica/Subsystem/psopcode.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psopcode - Parser/Interpreter opcode information table - * xRevision: 78 $ + * xRevision: 91 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,10 +116,11 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psopcode.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psopcode.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acparser.h" +#include "acopcode.h" #include "amlcode.h" @@ -127,23 +128,6 @@ __KERNEL_RCSID(0, "$NetBSD: psopcode.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); ACPI_MODULE_NAME ("psopcode") -#define _UNK 0x6B -/* - * Reserved ASCII characters. Do not use any of these for - * internal opcodes, since they are used to differentiate - * name strings from AML opcodes - */ -#define _ASC 0x6C -#define _NAM 0x6C -#define _PFX 0x6D -#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */ - -#define MAX_EXTENDED_OPCODE 0x88 -#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1) -#define MAX_INTERNAL_OPCODE -#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1) - - /******************************************************************************* * * NAME: AcpiGbl_AmlOpInfo @@ -155,272 +139,9 @@ __KERNEL_RCSID(0, "$NetBSD: psopcode.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * ******************************************************************************/ - -/* - * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed - * into a 32-bit number and stored in the master opcode table at the end of this file. - */ - - -#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) -#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) -#define ARGP_ARG0 ARG_NONE -#define ARGP_ARG1 ARG_NONE -#define ARGP_ARG2 ARG_NONE -#define ARGP_ARG3 ARG_NONE -#define ARGP_ARG4 ARG_NONE -#define ARGP_ARG5 ARG_NONE -#define ARGP_ARG6 ARG_NONE -#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) -#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BREAK_OP ARG_NONE -#define ARGP_BREAK_POINT_OP ARG_NONE -#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) -#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) -#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) -#define ARGP_CONTINUE_OP ARG_NONE -#define ARGP_COPY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SIMPLENAME) -#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_DEBUG_OP ARG_NONE -#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) -#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) -#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) -#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) -#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) -#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) -#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) -#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) -#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) -#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) -#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LOCAL0 ARG_NONE -#define ARGP_LOCAL1 ARG_NONE -#define ARGP_LOCAL2 ARG_NONE -#define ARGP_LOCAL3 ARG_NONE -#define ARGP_LOCAL4 ARG_NONE -#define ARGP_LOCAL5 ARG_NONE -#define ARGP_LOCAL6 ARG_NONE -#define ARGP_LOCAL7 ARG_NONE -#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) -#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) -#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) -#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_NOOP_OP ARG_NONE -#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) -#define ARGP_ONE_OP ARG_NONE -#define ARGP_ONES_OP ARG_NONE -#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) -#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) -#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) -#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) -#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_REVISION_OP ARG_NONE -#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) -#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) -#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST) -#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) -#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST) -#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) -#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) -#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) -#define ARGP_ZERO_OP ARG_NONE - - -/* - * All AML opcodes and the runtime arguments for each. Used by the AML interpreter Each list is compressed - * into a 32-bit number and stored in the master opcode table at the end of this file. - * - * (Used by PrepOperands procedure and the ASL Compiler) - */ - - -#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE -#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER) -#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE -#define ARGI_ARG0 ARG_NONE -#define ARGI_ARG1 ARG_NONE -#define ARGI_ARG2 ARG_NONE -#define ARGI_ARG3 ARG_NONE -#define ARGI_ARG4 ARG_NONE -#define ARGI_ARG5 ARG_NONE -#define ARGI_ARG6 ARG_NONE -#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE -#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BREAK_OP ARG_NONE -#define ARGI_BREAK_POINT_OP ARG_NONE -#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_BYTE_OP ARGI_INVALID_OPCODE -#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE -#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF) -#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF) -#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF) -#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE -#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET) -#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING) -#define ARGI_DEBUG_OP ARG_NONE -#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) -#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING) -#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE -#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF) -#define ARGI_DWORD_OP ARGI_INVALID_OPCODE -#define ARGI_ELSE_OP ARGI_INVALID_OPCODE -#define ARGI_EVENT_OP ARGI_INVALID_OPCODE -#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_FIELD_OP ARGI_INVALID_OPCODE -#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_IF_OP ARGI_INVALID_OPCODE -#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) -#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE -#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE -#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE -#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE -#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_FIELD,ARGI_TARGETREF) -#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE) -#define ARGI_LOCAL0 ARG_NONE -#define ARGI_LOCAL1 ARG_NONE -#define ARGI_LOCAL2 ARG_NONE -#define ARGI_LOCAL3 ARG_NONE -#define ARGI_LOCAL4 ARG_NONE -#define ARGI_LOCAL5 ARG_NONE -#define ARGI_LOCAL6 ARG_NONE -#define ARGI_LOCAL7 ARG_NONE -#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_METHOD_OP ARGI_INVALID_OPCODE -#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE -#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE -#define ARGI_NAME_OP ARGI_INVALID_OPCODE -#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE -#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE -#define ARGI_NOOP_OP ARG_NONE -#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER) -#define ARGI_ONE_OP ARG_NONE -#define ARGI_ONES_OP ARG_NONE -#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE -#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE -#define ARGI_QWORD_OP ARGI_INVALID_OPCODE -#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF) -#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) -#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE -#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) -#define ARGI_RETURN_OP ARGI_INVALID_OPCODE -#define ARGI_REVISION_OP ARG_NONE -#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE -#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) -#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT) -#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE -#define ARGI_STORE_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_TARGETREF) -#define ARGI_STRING_OP ARGI_INVALID_OPCODE -#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE -#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) -#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) -#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET) -#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) -#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) -#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER) -#define ARGI_WHILE_OP ARGI_INVALID_OPCODE -#define ARGI_WORD_OP ARGI_INVALID_OPCODE -#define ARGI_ZERO_OP ARG_NONE - - /* * Summary of opcode types/flags - */ - -/****************************************************************************** + * Opcodes that have associated namespace objects (AML_NSOBJECT flag) @@ -534,14 +255,13 @@ __KERNEL_RCSID(0, "$NetBSD: psopcode.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); AML_CREATE_DWORD_FIELD_OP AML_CREATE_QWORD_FIELD_OP -******************************************************************************/ + ******************************************************************************/ /* - * Master Opcode information table. A summary of everything we know about each opcode, all in one place. + * Master Opcode information table. A summary of everything we know about each + * opcode, all in one place. */ - - const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = { /*! [Begin] no source code translation */ @@ -595,16 +315,16 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = /* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), /* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), /* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), -/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), -/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R), /* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), /* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), /* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), /* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), /* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), -/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), -/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), +/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), /* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), /* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), /* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), @@ -664,7 +384,6 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = /* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), /* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), - /* ACPI 2.0 opcodes */ /* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), @@ -682,7 +401,11 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = /* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), /* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), /* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE) +/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), + +/* ACPI 3.0 opcodes */ + +/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R) /*! [End] no source code translation !*/ }; @@ -691,7 +414,6 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = * This table is directly indexed by the opcodes, and returns an * index into the table above */ - static const UINT8 AcpiGbl_ShortOpIndex[256] = { /* 0 1 2 3 4 5 6 7 */ @@ -730,7 +452,10 @@ static const UINT8 AcpiGbl_ShortOpIndex[256] = /* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, }; - +/* + * This table is indexed by the second opcode of the extended opcode + * pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo) + */ static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = { /* 0 1 2 3 4 5 6 7 */ @@ -741,7 +466,7 @@ static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, /* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, /* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x30 */ 0x55, 0x56, 0x57, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, /* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, @@ -762,8 +487,7 @@ static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = * * PARAMETERS: Opcode - The AML opcode * - * RETURN: A pointer to the info about the opcode. NULL if the opcode was - * not found in the table. + * RETURN: A pointer to the info about the opcode. * * DESCRIPTION: Find AML opcode description based on the opcode. * NOTE: This procedure must ALWAYS return a valid pointer! @@ -802,7 +526,8 @@ AcpiPsGetOpcodeInfo ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown extended opcode [%X]\n", Opcode)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown AML opcode [%4.4X]\n", Opcode)); break; } diff --git a/sys/dev/acpi/acpica/Subsystem/psparse.c b/sys/dev/acpi/acpica/Subsystem/psparse.c index 491da6c08fe..11834898d30 100644 --- a/sys/dev/acpi/acpica/Subsystem/psparse.c +++ b/sys/dev/acpi/acpica/Subsystem/psparse.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psparse - Parser top level AML parse routines - * xRevision: 143 $ + * xRevision: 152 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,7 +125,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psparse.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psparse.c,v 1.12 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acparser.h" @@ -140,6 +140,23 @@ __KERNEL_RCSID(0, "$NetBSD: psparse.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); static UINT32 AcpiGbl_Depth = 0; +/* Local prototypes */ + +static void +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +static ACPI_STATUS +AcpiPsNextParseState ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS CallbackStatus); + +static ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState); + /******************************************************************************* * @@ -177,7 +194,7 @@ AcpiPsGetOpcodeSize ( * * PARAMETERS: ParserState - A parser state object * - * RETURN: Status + * RETURN: Next AML opcode * * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) * @@ -194,7 +211,6 @@ AcpiPsPeekOpcode ( Aml = ParserState->Aml; Opcode = (UINT16) ACPI_GET8 (Aml); - if (Opcode == AML_EXTOP) { /* Extended opcode */ @@ -220,7 +236,7 @@ AcpiPsPeekOpcode ( * ******************************************************************************/ -void +static void AcpiPsCompleteThisOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) @@ -243,141 +259,142 @@ AcpiPsCompleteThisOp ( /* Delete this op and the subtree below it if asked to */ - if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) && - (WalkState->OpInfo->Class != AML_CLASS_ARGUMENT)) + if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || + (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT)) + { + return_VOID; + } + + /* Make sure that we only delete this subtree */ + + if (Op->Common.Parent) { - /* Make sure that we only delete this subtree */ + /* + * Check if we need to replace the operator and its subtree + * with a return value op (placeholder op) + */ + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); - if (Op->Common.Parent) + switch (ParentInfo->Class) { + case AML_CLASS_CONTROL: + break; + + case AML_CLASS_CREATE: + /* - * Check if we need to replace the operator and its subtree - * with a return value op (placeholder op) + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op */ - ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); - - switch (ParentInfo->Class) + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) { - case AML_CLASS_CONTROL: - break; + goto Cleanup; + } + break; - case AML_CLASS_CREATE: + case AML_CLASS_NAMED_OBJECT: - /* - * These opcodes contain TermArg operands. The current - * op must be replaced by a placeholder return op - */ + /* + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op + */ + if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); if (!ReplacementOp) { - return_VOID; + goto Cleanup; } - break; + } - case AML_CLASS_NAMED_OBJECT: + if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->DescendingCallback != AcpiDsExecBeginOp)) - /* - * These opcodes contain TermArg operands. The current - * op must be replaced by a placeholder return op - */ - if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || - (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || - (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || - (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || - (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + if ((Op->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) { - ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); if (!ReplacementOp) { - return_VOID; + goto Cleanup; } + + ReplacementOp->Named.Data = Op->Named.Data; + ReplacementOp->Named.Length = Op->Named.Length; } + } + break; - if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && - (WalkState->DescendingCallback != AcpiDsExecBeginOp)) + default: + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + goto Cleanup; + } + } - { - if ((Op->Common.AmlOpcode == AML_BUFFER_OP) || - (Op->Common.AmlOpcode == AML_PACKAGE_OP) || - (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) - { - ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); - if (!ReplacementOp) - { - return_VOID; - } + /* We must unlink this op from the parent tree */ - ReplacementOp->Named.Data = Op->Named.Data; - ReplacementOp->Named.Length = Op->Named.Length; - } - } - break; + Prev = Op->Common.Parent->Common.Value.Arg; + if (Prev == Op) + { + /* This op is the first in the list */ - default: - ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); - if (!ReplacementOp) - { - return_VOID; - } + if (ReplacementOp) + { + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Op->Common.Parent->Common.Value.Arg = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; + } + else + { + Op->Common.Parent->Common.Value.Arg = Op->Common.Next; } + } - /* We must unlink this op from the parent tree */ + /* Search the parent list */ - Prev = Op->Common.Parent->Common.Value.Arg; - if (Prev == Op) - { - /* This op is the first in the list */ + else while (Prev) + { + /* Traverse all siblings in the parent's argument list */ + Next = Prev->Common.Next; + if (Next == Op) + { if (ReplacementOp) { - ReplacementOp->Common.Parent = Op->Common.Parent; - ReplacementOp->Common.Value.Arg = NULL; - ReplacementOp->Common.Node = Op->Common.Node; - Op->Common.Parent->Common.Value.Arg = ReplacementOp; - ReplacementOp->Common.Next = Op->Common.Next; + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Prev->Common.Next = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; + Next = NULL; } else { - Op->Common.Parent->Common.Value.Arg = Op->Common.Next; + Prev->Common.Next = Op->Common.Next; + Next = NULL; } } - - /* Search the parent list */ - - else while (Prev) - { - /* Traverse all siblings in the parent's argument list */ - - Next = Prev->Common.Next; - if (Next == Op) - { - if (ReplacementOp) - { - ReplacementOp->Common.Parent = Op->Common.Parent; - ReplacementOp->Common.Value.Arg = NULL; - ReplacementOp->Common.Node = Op->Common.Node; - Prev->Common.Next = ReplacementOp; - ReplacementOp->Common.Next = Op->Common.Next; - Next = NULL; - } - else - { - Prev->Common.Next = Op->Common.Next; - Next = NULL; - } - } - - Prev = Next; - } + Prev = Next; } + } - /* Now we can actually delete the subtree rooted at op */ - AcpiPsDeleteParseTree (Op); +Cleanup: - return_VOID; - } + /* Now we can actually delete the subtree rooted at Op */ + AcpiPsDeleteParseTree (Op); return_VOID; } @@ -386,7 +403,9 @@ AcpiPsCompleteThisOp ( * * FUNCTION: AcpiPsNextParseState * - * PARAMETERS: ParserState - Current parser state object + * PARAMETERS: WalkState - Current state + * Op - Current parse op + * CallbackStatus - Status from previous operation * * RETURN: Status * @@ -395,7 +414,7 @@ AcpiPsCompleteThisOp ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiPsNextParseState ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, @@ -478,9 +497,8 @@ AcpiPsNextParseState ( case AE_CTRL_TRANSFER: - /* - * A method call (invocation) -- transfer control - */ + /* A method call (invocation) -- transfer control */ + Status = AE_CTRL_TRANSFER; WalkState->PrevOp = Op; WalkState->MethodCallOp = Op; @@ -493,6 +511,7 @@ AcpiPsNextParseState ( default: + Status = CallbackStatus; if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL) { @@ -509,7 +528,7 @@ AcpiPsNextParseState ( * * FUNCTION: AcpiPsParseLoop * - * PARAMETERS: ParserState - Current parser state object + * PARAMETERS: WalkState - Current state * * RETURN: Status * @@ -518,14 +537,14 @@ AcpiPsNextParseState ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiPsParseLoop ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *Op = NULL; /* current op */ ACPI_PARSE_OBJECT *Arg = NULL; - ACPI_PARSE_OBJECT PreOp; + ACPI_PARSE_OBJECT *PreOp = NULL; ACPI_PARSE_STATE *ParserState; UINT8 *AmlOpStart = NULL; @@ -541,6 +560,7 @@ AcpiPsParseLoop ( WalkState->ArgTypes = 0; #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) { /* We are restarting a preempted control method */ @@ -574,7 +594,8 @@ AcpiPsParseLoop ( AcpiFormatException (Status))); } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "GetPredicate Failed, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "GetPredicate Failed, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } @@ -596,9 +617,8 @@ AcpiPsParseLoop ( } #endif - /* - * Iterative parsing loop, while there is more aml to process: - */ + /* Iterative parsing loop, while there is more AML to process: */ + while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) { AmlOpStart = ParserState->Aml; @@ -607,7 +627,7 @@ AcpiPsParseLoop ( /* Get the next opcode from the AML stream */ WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, - ParserState->AmlStart); + ParserState->AmlStart); WalkState->Opcode = AcpiPsPeekOpcode (ParserState); /* @@ -657,8 +677,20 @@ AcpiPsParseLoop ( if (WalkState->OpInfo->Flags & AML_NAMED) { - PreOp.Common.Value.Arg = NULL; - PreOp.Common.AmlOpcode = WalkState->Opcode; + /* Allocate a new PreOp if necessary */ + + if (!PreOp) + { + PreOp = AcpiPsAllocOp (WalkState->Opcode); + if (!PreOp) + { + Status = AE_NO_MEMORY; + goto CloseThisOp; + } + } + + PreOp->Common.Value.Arg = NULL; + PreOp->Common.AmlOpcode = WalkState->Opcode; /* * Get and append arguments until we find the node that contains @@ -674,15 +706,18 @@ AcpiPsParseLoop ( goto CloseThisOp; } - AcpiPsAppendArg (&PreOp, Arg); + AcpiPsAppendArg (PreOp, Arg); INCREMENT_ARG_LIST (WalkState->ArgTypes); } - /* Make sure that we found a NAME and didn't run out of arguments */ - + /* + * Make sure that we found a NAME and didn't run out of + * arguments + */ if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes)) { - return_ACPI_STATUS (AE_AML_NO_OPERAND); + Status = AE_AML_NO_OPERAND; + goto CloseThisOp; } /* We know that this arg is a name, move to next arg */ @@ -698,12 +733,13 @@ AcpiPsParseLoop ( Status = WalkState->DescendingCallback (WalkState, &Op); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n", - AcpiFormatException (Status))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "During name lookup/catalog, %s\n", + AcpiFormatException (Status))); goto CloseThisOp; } - if (Op == NULL) + if (!Op) { continue; } @@ -720,7 +756,7 @@ AcpiPsParseLoop ( goto CloseThisOp; } - AcpiPsAppendArg (Op, PreOp.Common.Value.Arg); + AcpiPsAppendArg (Op, PreOp->Common.Value.Arg); AcpiGbl_Depth++; if (Op->Common.AmlOpcode == AML_REGION_OP) @@ -749,7 +785,8 @@ AcpiPsParseLoop ( Op = AcpiPsAllocOp (WalkState->Opcode); if (!Op) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto CloseThisOp; } if (WalkState->OpInfo->Flags & AML_CREATE) @@ -767,7 +804,7 @@ AcpiPsParseLoop ( if ((WalkState->DescendingCallback != NULL)) { /* - * Find the object. This will either insert the object into + * Find the object. This will either insert the object into * the namespace or simply look it up */ WalkState->Op = Op; @@ -799,11 +836,15 @@ AcpiPsParseLoop ( } - /* Start ArgCount at zero because we don't know if there are any args yet */ - + /* + * Start ArgCount at zero because we don't know if there are + * any args yet + */ WalkState->ArgCount = 0; - if (WalkState->ArgTypes) /* Are there any arguments that must be processed? */ + /* Are there any arguments that must be processed? */ + + if (WalkState->ArgTypes) { /* Get arguments */ @@ -834,15 +875,19 @@ AcpiPsParseLoop ( default: - /* Op is not a constant or string, append each argument to the Op */ - + /* + * Op is not a constant or string, append each argument + * to the Op + */ while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount) { - WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, - ParserState->AmlStart); + WalkState->AmlOffset = (UINT32) + ACPI_PTR_DIFF (ParserState->Aml, ParserState->AmlStart); + Status = AcpiPsGetNextArg (WalkState, ParserState, - GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), + &Arg); if (ACPI_FAILURE (Status)) { goto CloseThisOp; @@ -870,7 +915,8 @@ AcpiPsParseLoop ( * Save the length and address of the body */ Op->Named.Data = ParserState->Aml; - Op->Named.Length = (UINT32) (ParserState->PkgEnd - ParserState->Aml); + Op->Named.Length = (UINT32) (ParserState->PkgEnd - + ParserState->Aml); /* Skip body of method */ @@ -892,7 +938,8 @@ AcpiPsParseLoop ( * to parse them correctly. */ Op->Named.Data = AmlOpStart; - Op->Named.Length = (UINT32) (ParserState->PkgEnd - AmlOpStart); + Op->Named.Length = (UINT32) (ParserState->PkgEnd - + AmlOpStart); /* Skip body */ @@ -905,7 +952,8 @@ AcpiPsParseLoop ( if (WalkState->ControlState) { - WalkState->ControlState->Control.PackageEnd = ParserState->PkgEnd; + WalkState->ControlState->Control.PackageEnd = + ParserState->PkgEnd; } break; @@ -922,20 +970,24 @@ AcpiPsParseLoop ( if (WalkState->ArgCount) { - /* There are arguments (complex ones), push Op and prepare for argument */ - + /* + * There are arguments (complex ones), push Op and + * prepare for argument + */ Status = AcpiPsPushScope (ParserState, Op, WalkState->ArgTypes, WalkState->ArgCount); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto CloseThisOp; } Op = NULL; continue; } - /* All arguments have been processed -- Op is complete, prepare for next */ - + /* + * All arguments have been processed -- Op is complete, + * prepare for next + */ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); if (WalkState->OpInfo->Flags & AML_NAMED) { @@ -996,6 +1048,11 @@ CloseThisOp: AcpiPsCompleteThisOp (WalkState, Op); Op = NULL; + if (PreOp) + { + AcpiPsFreeOp (PreOp); + PreOp = NULL; + } switch (Status) { @@ -1005,9 +1062,8 @@ CloseThisOp: case AE_CTRL_TRANSFER: - /* - * We are about to transfer to a called method. - */ + /* We are about to transfer to a called method. */ + WalkState->PrevOp = Op; WalkState->PrevArgTypes = WalkState->ArgTypes; return_ACPI_STATUS (Status); @@ -1193,10 +1249,7 @@ CloseThisOp: * * FUNCTION: AcpiPsParseAml * - * PARAMETERS: StartScope - The starting point of the parse. Becomes the - * root of the parsed op tree. - * Aml - Pointer to the raw AML code to parse - * AmlSize - Length of the AML to parse + * PARAMETERS: WalkState - Current state * * * RETURN: Status @@ -1214,16 +1267,14 @@ AcpiPsParseAml ( ACPI_THREAD_STATE *Thread; ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList; ACPI_WALK_STATE *PreviousWalkState; -#ifndef ACPICA_PEDANTIC - ACPI_OPERAND_OBJECT **CallerReturnDesc = WalkState->CallerReturnDesc; - ACPI_OPERAND_OBJECT *EffectiveReturnDesc = NULL; -#endif ACPI_FUNCTION_TRACE ("PsParseAml"); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with WalkState=%p Aml=%p size=%X\n", - WalkState, WalkState->ParserState.Aml, WalkState->ParserState.AmlSize)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Entered with WalkState=%p Aml=%p size=%X\n", + WalkState, WalkState->ParserState.Aml, + WalkState->ParserState.AmlSize)); /* Create and initialize a new thread state */ @@ -1284,26 +1335,40 @@ AcpiPsParseAml ( { Status = AE_OK; } - else if (Status != AE_OK) + else if ((Status != AE_OK) && (WalkState->MethodDesc)) { ACPI_REPORT_METHOD_ERROR ("Method execution failed", WalkState->MethodNode, NULL, Status); - } - - /* We are done with this walk, move on to the parent if any */ - WalkState = AcpiDsPopWalkState (Thread); + /* Check for possible multi-thread reentrancy problem */ -#ifndef ACPICA_PEDANTIC - /* Save the last effective return value */ + if ((Status == AE_ALREADY_EXISTS) && + (!WalkState->MethodDesc->Method.Semaphore)) + { + /* + * This method is marked NotSerialized, but it tried to create + * a named object, causing the second thread entrance to fail. + * We will workaround this by marking the method permanently + * as Serialized. + */ + WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED; + WalkState->MethodDesc->Method.Concurrency = 1; + } + } - if (CallerReturnDesc && WalkState->ReturnDesc) + if (WalkState->MethodDesc) { - AcpiUtRemoveReference (EffectiveReturnDesc); - EffectiveReturnDesc = WalkState->ReturnDesc; - AcpiUtAddReference (EffectiveReturnDesc); + /* Decrement the thread count on the method parse tree */ + + if (WalkState->MethodDesc->Method.ThreadCount) + { + WalkState->MethodDesc->Method.ThreadCount--; + } } -#endif + + /* We are done with this walk, move on to the parent if any */ + + WalkState = AcpiDsPopWalkState (Thread); /* Reset the current scope to the beginning of scope stack */ @@ -1331,8 +1396,9 @@ AcpiPsParseAml ( PreviousWalkState = WalkState; - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "ReturnValue=%p, State=%p\n", - WalkState->ReturnDesc, WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "ReturnValue=%p, ImplicitValue=%p State=%p\n", + WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState)); /* Check if we have restarted a preempted walk */ @@ -1346,8 +1412,22 @@ AcpiPsParseAml ( * If the method return value is not used by the parent, * The object is deleted */ - Status = AcpiDsRestartControlMethod (WalkState, - PreviousWalkState->ReturnDesc); + if (!PreviousWalkState->ReturnDesc) + { + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ImplicitReturnObj); + } + else + { + /* + * We have a valid return value, delete any implicit + * return value. + */ + AcpiDsClearImplicitReturn (PreviousWalkState); + + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ReturnDesc); + } if (ACPI_SUCCESS (Status)) { WalkState->WalkType |= ACPI_WALK_METHOD_RESTART; @@ -1367,26 +1447,33 @@ AcpiPsParseAml ( */ else if (PreviousWalkState->CallerReturnDesc) { -#ifndef ACPICA_PEDANTIC - /* - * Some AML code expects a return value without a ReturnOp. - * Return the saved effective return value instead. - */ - - if (PreviousWalkState->ReturnDesc == NULL && EffectiveReturnDesc != NULL) + if (PreviousWalkState->ImplicitReturnObj) { - PreviousWalkState->ReturnDesc = EffectiveReturnDesc; - AcpiUtAddReference (PreviousWalkState->ReturnDesc); + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ImplicitReturnObj; } -#endif + else + { + /* NULL if no return value */ - *(PreviousWalkState->CallerReturnDesc) = PreviousWalkState->ReturnDesc; /* NULL if no return value */ + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ReturnDesc; + } } - else if (PreviousWalkState->ReturnDesc) + else { - /* Caller doesn't want it, must delete it */ + if (PreviousWalkState->ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + } + if (PreviousWalkState->ImplicitReturnObj) + { + /* Caller doesn't want it, must delete it */ - AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj); + } } AcpiDsDeleteWalkState (PreviousWalkState); @@ -1394,9 +1481,6 @@ AcpiPsParseAml ( /* Normal exit */ -#ifndef ACPICA_PEDANTIC - AcpiUtRemoveReference (EffectiveReturnDesc); -#endif AcpiExReleaseAllMutexes (Thread); AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread)); AcpiGbl_CurrentWalkList = PrevWalkList; diff --git a/sys/dev/acpi/acpica/Subsystem/psscope.c b/sys/dev/acpi/acpica/Subsystem/psscope.c index d129ff64b06..2c88ac1c787 100644 --- a/sys/dev/acpi/acpica/Subsystem/psscope.c +++ b/sys/dev/acpi/acpica/Subsystem/psscope.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psscope - Parser scope stack management routines - * xRevision: 37 $ + * xRevision: 42 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psscope.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psscope.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acparser.h" @@ -141,6 +141,7 @@ ACPI_PARSE_OBJECT * AcpiPsGetParentScope ( ACPI_PARSE_STATE *ParserState) { + return (ParserState->Scope->ParseScope.Op); } @@ -163,8 +164,10 @@ BOOLEAN AcpiPsHasCompletedScope ( ACPI_PARSE_STATE *ParserState) { - return ((BOOLEAN) ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || - !ParserState->Scope->ParseScope.ArgCount))); + + return ((BOOLEAN) + ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || + !ParserState->Scope->ParseScope.ArgCount))); } @@ -245,28 +248,25 @@ AcpiPsPushScope ( return_ACPI_STATUS (AE_NO_MEMORY); } - - Scope->Common.DataType = ACPI_DESC_TYPE_STATE_PSCOPE; - Scope->ParseScope.Op = Op; - Scope->ParseScope.ArgList = RemainingArgs; - Scope->ParseScope.ArgCount = ArgCount; - Scope->ParseScope.PkgEnd = ParserState->PkgEnd; + Scope->Common.DataType = ACPI_DESC_TYPE_STATE_PSCOPE; + Scope->ParseScope.Op = Op; + Scope->ParseScope.ArgList = RemainingArgs; + Scope->ParseScope.ArgCount = ArgCount; + Scope->ParseScope.PkgEnd = ParserState->PkgEnd; /* Push onto scope stack */ AcpiUtPushGenericState (&ParserState->Scope, Scope); - if (ArgCount == ACPI_VAR_ARGS) { - /* multiple arguments */ + /* Multiple arguments */ Scope->ParseScope.ArgEnd = ParserState->PkgEnd; } - else { - /* single argument */ + /* Single argument */ Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR); } @@ -304,36 +304,34 @@ AcpiPsPopScope ( ACPI_FUNCTION_TRACE ("PsPopScope"); - /* - * Only pop the scope if there is in fact a next scope - */ + /* Only pop the scope if there is in fact a next scope */ + if (Scope->Common.Next) { Scope = AcpiUtPopGenericState (&ParserState->Scope); /* return to parsing previous op */ - *Op = Scope->ParseScope.Op; - *ArgList = Scope->ParseScope.ArgList; - *ArgCount = Scope->ParseScope.ArgCount; - ParserState->PkgEnd = Scope->ParseScope.PkgEnd; + *Op = Scope->ParseScope.Op; + *ArgList = Scope->ParseScope.ArgList; + *ArgCount = Scope->ParseScope.ArgCount; + ParserState->PkgEnd = Scope->ParseScope.PkgEnd; /* All done with this scope state structure */ AcpiUtDeleteGenericState (Scope); } - else { /* empty parse stack, prepare to fetch next opcode */ - *Op = NULL; - *ArgList = 0; - *ArgCount = 0; + *Op = NULL; + *ArgList = 0; + *ArgCount = 0; } - - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped Op %p Args %X\n", *Op, *ArgCount)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Popped Op %p Args %X\n", *Op, *ArgCount)); return_VOID; } @@ -344,7 +342,7 @@ AcpiPsPopScope ( * * PARAMETERS: ParserState - Current parser state object * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Destroy available list, remaining stack levels, and return * root scope @@ -357,15 +355,15 @@ AcpiPsCleanupScope ( { ACPI_GENERIC_STATE *Scope; + ACPI_FUNCTION_TRACE_PTR ("PsCleanupScope", ParserState); if (!ParserState) { - return; + return_VOID; } - /* Delete anything on the scope stack */ while (ParserState->Scope) diff --git a/sys/dev/acpi/acpica/Subsystem/pstree.c b/sys/dev/acpi/acpica/Subsystem/pstree.c index 9ea71da4c6c..7d53b175e1e 100644 --- a/sys/dev/acpi/acpica/Subsystem/pstree.c +++ b/sys/dev/acpi/acpica/Subsystem/pstree.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: pstree - Parser op tree manipulation/traversal/search - * xRevision: 42 $ + * xRevision: 46 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pstree.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pstree.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __PSTREE_C__ @@ -127,6 +127,14 @@ __KERNEL_RCSID(0, "$NetBSD: pstree.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("pstree") +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *op); +#endif + /******************************************************************************* * @@ -135,7 +143,7 @@ __KERNEL_RCSID(0, "$NetBSD: pstree.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * PARAMETERS: Op - Get an argument for this op * Argn - Nth argument to get * - * RETURN: The argument (as an Op object). NULL if argument does not exist + * RETURN: The argument (as an Op object). NULL if argument does not exist * * DESCRIPTION: Get the specified op's argument. * @@ -236,7 +244,6 @@ AcpiPsAppendArg ( return; } - /* Append the argument to the linked argument list */ if (Op->Common.Value.Arg) @@ -250,7 +257,6 @@ AcpiPsAppendArg ( } PrevArg->Common.Next = Arg; } - else { /* No argument list, this will be the first argument */ @@ -258,7 +264,6 @@ AcpiPsAppendArg ( Op->Common.Value.Arg = Arg; } - /* Set the parent in this arg and any args linked after it */ while (Arg) @@ -271,74 +276,6 @@ AcpiPsAppendArg ( /******************************************************************************* * - * FUNCTION: AcpiPsGetChild - * - * PARAMETERS: Op - Get the child of this Op - * - * RETURN: Child Op, Null if none is found. - * - * DESCRIPTION: Get op's children or NULL if none - * - ******************************************************************************/ - -ACPI_PARSE_OBJECT * -AcpiPsGetChild ( - ACPI_PARSE_OBJECT *Op) -{ - ACPI_PARSE_OBJECT *Child = NULL; - - - ACPI_FUNCTION_ENTRY (); - - - switch (Op->Common.AmlOpcode) - { - case AML_SCOPE_OP: - case AML_ELSE_OP: - case AML_DEVICE_OP: - case AML_THERMAL_ZONE_OP: - case AML_INT_METHODCALL_OP: - - Child = AcpiPsGetArg (Op, 0); - break; - - - case AML_BUFFER_OP: - case AML_PACKAGE_OP: - case AML_METHOD_OP: - case AML_IF_OP: - case AML_WHILE_OP: - case AML_FIELD_OP: - - Child = AcpiPsGetArg (Op, 1); - break; - - - case AML_POWER_RES_OP: - case AML_INDEX_FIELD_OP: - - Child = AcpiPsGetArg (Op, 2); - break; - - - case AML_PROCESSOR_OP: - case AML_BANK_FIELD_OP: - - Child = AcpiPsGetArg (Op, 3); - break; - - - default: - /* All others have no children */ - break; - } - - return (Child); -} - - -/******************************************************************************* - * * FUNCTION: AcpiPsGetDepthNext * * PARAMETERS: Origin - Root of subtree to search @@ -369,7 +306,7 @@ AcpiPsGetDepthNext ( return (NULL); } - /* look for an argument or child */ + /* Look for an argument or child */ Next = AcpiPsGetArg (Op, 0); if (Next) @@ -377,7 +314,7 @@ AcpiPsGetDepthNext ( return (Next); } - /* look for a sibling */ + /* Look for a sibling */ Next = Op->Common.Next; if (Next) @@ -385,7 +322,7 @@ AcpiPsGetDepthNext ( return (Next); } - /* look for a sibling of parent */ + /* Look for a sibling of parent */ Parent = Op->Common.Parent; @@ -399,14 +336,14 @@ AcpiPsGetDepthNext ( if (Arg == Origin) { - /* reached parent of origin, end search */ + /* Reached parent of origin, end search */ return (NULL); } if (Parent->Common.Next) { - /* found sibling of parent */ + /* Found sibling of parent */ return (Parent->Common.Next); } @@ -419,3 +356,73 @@ AcpiPsGetDepthNext ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiPsGetChild + * + * PARAMETERS: Op - Get the child of this Op + * + * RETURN: Child Op, Null if none is found. + * + * DESCRIPTION: Get op's children or NULL if none + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Child = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + switch (Op->Common.AmlOpcode) + { + case AML_SCOPE_OP: + case AML_ELSE_OP: + case AML_DEVICE_OP: + case AML_THERMAL_ZONE_OP: + case AML_INT_METHODCALL_OP: + + Child = AcpiPsGetArg (Op, 0); + break; + + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_IF_OP: + case AML_WHILE_OP: + case AML_FIELD_OP: + + Child = AcpiPsGetArg (Op, 1); + break; + + + case AML_POWER_RES_OP: + case AML_INDEX_FIELD_OP: + + Child = AcpiPsGetArg (Op, 2); + break; + + + case AML_PROCESSOR_OP: + case AML_BANK_FIELD_OP: + + Child = AcpiPsGetArg (Op, 3); + break; + + + default: + /* All others have no children */ + break; + } + + return (Child); +} +#endif + + diff --git a/sys/dev/acpi/acpica/Subsystem/psutils.c b/sys/dev/acpi/acpica/Subsystem/psutils.c index 25b2408728f..d73fbcda2ca 100644 --- a/sys/dev/acpi/acpica/Subsystem/psutils.c +++ b/sys/dev/acpi/acpica/Subsystem/psutils.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psutils - Parser miscellaneous utilities (Parser only) - * xRevision: 56 $ + * xRevision: 63 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,12 +116,11 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psutils.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psutils.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acparser.h" #include "amlcode.h" -#include "acnamesp.h" #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psutils") @@ -133,7 +132,7 @@ __KERNEL_RCSID(0, "$NetBSD: psutils.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * * PARAMETERS: None * - * RETURN: ScopeOp + * RETURN: A new Scope object, null on failure * * DESCRIPTION: Create a Scope and associated namepath op with the root name * @@ -152,7 +151,6 @@ AcpiPsCreateScopeOp ( return (NULL); } - ScopeOp->Named.Name = ACPI_ROOT_NAME; return (ScopeOp); } @@ -165,10 +163,9 @@ AcpiPsCreateScopeOp ( * PARAMETERS: Op - A newly allocated Op object * Opcode - Opcode to store in the Op * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on - * opcode + * DESCRIPTION: Initialize a parse (Op) object * ******************************************************************************/ @@ -184,7 +181,8 @@ AcpiPsInitOp ( Op->Common.AmlOpcode = Opcode; ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName, - (AcpiPsGetOpcodeInfo (Opcode))->Name, sizeof (Op->Common.AmlOpName))); + (AcpiPsGetOpcodeInfo (Opcode))->Name, + sizeof (Op->Common.AmlOpName))); } @@ -194,7 +192,7 @@ AcpiPsInitOp ( * * PARAMETERS: Opcode - Opcode that will be stored in the new Op * - * RETURN: Pointer to the new Op. + * RETURN: Pointer to the new Op, null on failure * * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on * opcode. A cache of opcodes is available for the pure @@ -206,10 +204,9 @@ ACPI_PARSE_OBJECT* AcpiPsAllocOp ( UINT16 Opcode) { - ACPI_PARSE_OBJECT *Op = NULL; - UINT32 Size; - UINT8 Flags; + ACPI_PARSE_OBJECT *Op; const ACPI_OPCODE_INFO *OpInfo; + UINT8 Flags = ACPI_PARSEOP_GENERIC; ACPI_FUNCTION_ENTRY (); @@ -217,38 +214,33 @@ AcpiPsAllocOp ( OpInfo = AcpiPsGetOpcodeInfo (Opcode); - /* Allocate the minimum required size object */ + /* Determine type of ParseOp required */ if (OpInfo->Flags & AML_DEFER) { - Size = sizeof (ACPI_PARSE_OBJ_NAMED); Flags = ACPI_PARSEOP_DEFERRED; } else if (OpInfo->Flags & AML_NAMED) { - Size = sizeof (ACPI_PARSE_OBJ_NAMED); Flags = ACPI_PARSEOP_NAMED; } else if (Opcode == AML_INT_BYTELIST_OP) { - Size = sizeof (ACPI_PARSE_OBJ_NAMED); Flags = ACPI_PARSEOP_BYTELIST; } - else - { - Size = sizeof (ACPI_PARSE_OBJ_COMMON); - Flags = ACPI_PARSEOP_GENERIC; - } - if (Size == sizeof (ACPI_PARSE_OBJ_COMMON)) + /* Allocate the minimum required size object */ + + if (Flags == ACPI_PARSEOP_GENERIC) { - /* - * The generic op is by far the most common (16 to 1) - */ + /* The generic op (default) is by far the most common (16 to 1) */ + Op = AcpiUtAcquireFromCache (ACPI_MEM_LIST_PSNODE); } else { + /* Extended parseop */ + Op = AcpiUtAcquireFromCache (ACPI_MEM_LIST_PSNODE_EXT); } @@ -300,6 +292,7 @@ AcpiPsFreeOp ( } +#ifdef ACPI_ENABLE_OBJECT_CACHE /******************************************************************************* * * FUNCTION: AcpiPsDeleteParseCache @@ -323,6 +316,7 @@ AcpiPsDeleteParseCache ( AcpiUtDeleteGenericCache (ACPI_MEM_LIST_PSNODE_EXT); return_VOID; } +#endif /******************************************************************************* @@ -364,7 +358,6 @@ AcpiPsGetName ( ACPI_PARSE_OBJECT *Op) { - /* The "generic" object has no name associated with it */ if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) diff --git a/sys/dev/acpi/acpica/Subsystem/pswalk.c b/sys/dev/acpi/acpica/Subsystem/pswalk.c index c1784a5a0e8..e24d75b0580 100644 --- a/sys/dev/acpi/acpica/Subsystem/pswalk.c +++ b/sys/dev/acpi/acpica/Subsystem/pswalk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: pswalk - Parser routines to walk parsed op tree(s) - * xRevision: 70 $ + * xRevision: 75 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,11 +116,10 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pswalk.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pswalk.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #include "acpi.h" #include "acparser.h" -#include "acdispat.h" #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("pswalk") @@ -128,199 +127,6 @@ __KERNEL_RCSID(0, "$NetBSD: pswalk.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); /******************************************************************************* * - * FUNCTION: AcpiPsGetNextWalkOp - * - * PARAMETERS: WalkState - Current state of the walk - * Op - Current Op to be walked - * AscendingCallback - Procedure called when Op is complete - * - * RETURN: Status - * - * DESCRIPTION: Get the next Op in a walk of the parse tree. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiPsGetNextWalkOp ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op, - ACPI_PARSE_UPWARDS AscendingCallback) -{ - ACPI_PARSE_OBJECT *Next; - ACPI_PARSE_OBJECT *Parent; - ACPI_PARSE_OBJECT *GrandParent; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR ("PsGetNextWalkOp", Op); - - - /* Check for a argument only if we are descending in the tree */ - - if (WalkState->NextOpInfo != ACPI_NEXT_OP_UPWARD) - { - /* Look for an argument or child of the current op */ - - Next = AcpiPsGetArg (Op, 0); - if (Next) - { - /* Still going downward in tree (Op is not completed yet) */ - - WalkState->PrevOp = Op; - WalkState->NextOp = Next; - WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD; - - return_ACPI_STATUS (AE_OK); - } - - /* - * No more children, this Op is complete. Save Next and Parent - * in case the Op object gets deleted by the callback routine - */ - Next = Op->Common.Next; - Parent = Op->Common.Parent; - - WalkState->Op = Op; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - WalkState->Opcode = Op->Common.AmlOpcode; - - Status = AscendingCallback (WalkState); - - /* - * If we are back to the starting point, the walk is complete. - */ - if (Op == WalkState->Origin) - { - /* Reached the point of origin, the walk is complete */ - - WalkState->PrevOp = Op; - WalkState->NextOp = NULL; - - return_ACPI_STATUS (Status); - } - - /* - * Check for a sibling to the current op. A sibling means - * we are still going "downward" in the tree. - */ - if (Next) - { - /* There is a sibling, it will be next */ - - WalkState->PrevOp = Op; - WalkState->NextOp = Next; - WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD; - - /* Continue downward */ - - return_ACPI_STATUS (Status); - } - - /* - * Drop into the loop below because we are moving upwards in - * the tree - */ - } - else - { - /* - * We are resuming a walk, and we were (are) going upward in the tree. - * So, we want to drop into the parent loop below. - */ - Parent = Op; - } - - /* - * Look for a sibling of the current Op's parent - * Continue moving up the tree until we find a node that has not been - * visited, or we get back to where we started. - */ - while (Parent) - { - /* We are moving up the tree, therefore this parent Op is complete */ - - GrandParent = Parent->Common.Parent; - Next = Parent->Common.Next; - - WalkState->Op = Parent; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Parent->Common.AmlOpcode); - WalkState->Opcode = Parent->Common.AmlOpcode; - - Status = AscendingCallback (WalkState); - - /* - * If we are back to the starting point, the walk is complete. - */ - if (Parent == WalkState->Origin) - { - /* Reached the point of origin, the walk is complete */ - - WalkState->PrevOp = Parent; - WalkState->NextOp = NULL; - - return_ACPI_STATUS (Status); - } - - /* - * If there is a sibling to this parent (it is not the starting point - * Op), then we will visit it. - */ - if (Next) - { - /* found sibling of parent */ - - WalkState->PrevOp = Parent; - WalkState->NextOp = Next; - WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD; - - return_ACPI_STATUS (Status); - } - - /* No siblings, no errors, just move up one more level in the tree */ - - Op = Parent; - Parent = GrandParent; - WalkState->PrevOp = Op; - } - - - /* - * Got all the way to the top of the tree, we must be done! - * However, the code should have terminated in the loop above - */ - WalkState->NextOp = NULL; - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiPsDeleteCompletedOp - * - * PARAMETERS: State - Walk state - * Op - Completed op - * - * RETURN: AE_OK - * - * DESCRIPTION: Callback function for AcpiPsGetNextWalkOp(). Used during - * AcpiPsDeleteParse tree to delete Op objects when all sub-objects - * have been visited (and deleted.) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiPsDeleteCompletedOp ( - ACPI_WALK_STATE *WalkState) -{ - - AcpiPsFreeOp (WalkState->Op); - return (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: AcpiPsDeleteParseTree * * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete @@ -335,62 +141,56 @@ void AcpiPsDeleteParseTree ( ACPI_PARSE_OBJECT *SubtreeRoot) { - ACPI_WALK_STATE *WalkState; - ACPI_THREAD_STATE *Thread; - ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op = SubtreeRoot; + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent = NULL; ACPI_FUNCTION_TRACE_PTR ("PsDeleteParseTree", SubtreeRoot); - if (!SubtreeRoot) - { - return_VOID; - } - - /* Create and initialize a new walk list */ + /* Visit all nodes in the subtree */ - Thread = AcpiUtCreateThreadState (); - if (!Thread) + while (Op) { - return_VOID; - } + /* Check if we are not ascending */ - WalkState = AcpiDsCreateWalkState (0, NULL, NULL, Thread); - if (!WalkState) - { - return_VOID; - } + if (Op != Parent) + { + /* Look for an argument or child of the current op */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + /* Still going downward in tree (Op is not completed yet) */ - WalkState->ParseFlags = 0; - WalkState->DescendingCallback = NULL; - WalkState->AscendingCallback = NULL; + Op = Next; + continue; + } + } - WalkState->Origin = SubtreeRoot; - WalkState->NextOp = SubtreeRoot; + /* No more children, this Op is complete. */ - /* Head downward in the tree */ + Next = Op->Common.Next; + Parent = Op->Common.Parent; - WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD; + AcpiPsFreeOp (Op); - /* Visit all nodes in the subtree */ + /* If we are back to the starting point, the walk is complete. */ - while (WalkState->NextOp) - { - Status = AcpiPsGetNextWalkOp (WalkState, WalkState->NextOp, - AcpiPsDeleteCompletedOp); - if (ACPI_FAILURE (Status)) + if (Op == SubtreeRoot) + { + return_VOID; + } + if (Next) { - break; + Op = Next; + } + else + { + Op = Parent; } } - /* We are done with this walk */ - - AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread)); - AcpiDsDeleteWalkState (WalkState); - return_VOID; } - - diff --git a/sys/dev/acpi/acpica/Subsystem/psxface.c b/sys/dev/acpi/acpica/Subsystem/psxface.c index 817495df2c7..d7a6cbaff01 100644 --- a/sys/dev/acpi/acpica/Subsystem/psxface.c +++ b/sys/dev/acpi/acpica/Subsystem/psxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psxface - Parser external interfaces - * xRevision: 71 $ + * xRevision: 78 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: psxface.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psxface.c,v 1.11 2005/05/02 14:52:09 kochi Exp $"); #define __PSXFACE_C__ @@ -134,13 +134,16 @@ __KERNEL_RCSID(0, "$NetBSD: psxface.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * * FUNCTION: AcpiPsxExecute * - * PARAMETERS: MethodNode - A method object containing both the AML - * address and length. - * **Params - List of parameters to pass to method, + * PARAMETERS: Info - Method info block, contains: + * Node - Method Node to execute + * Parameters - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. - * **ReturnObjDesc - Return object from execution of the - * method. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. * * RETURN: Status * @@ -150,9 +153,7 @@ __KERNEL_RCSID(0, "$NetBSD: psxface.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); ACPI_STATUS AcpiPsxExecute ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc) + ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; @@ -166,12 +167,12 @@ AcpiPsxExecute ( /* Validate the Node and get the attached object */ - if (!MethodNode) + if (!Info || !Info->Node) { return_ACPI_STATUS (AE_NULL_ENTRY); } - ObjDesc = AcpiNsGetAttachedObject (MethodNode); + ObjDesc = AcpiNsGetAttachedObject (Info->Node); if (!ObjDesc) { return_ACPI_STATUS (AE_NULL_OBJECT); @@ -179,21 +180,22 @@ AcpiPsxExecute ( /* Init for new method, wait on concurrency semaphore */ - Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, NULL); + Status = AcpiDsBeginMethodExecution (Info->Node, ObjDesc, NULL); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - if (Params) + if ((Info->ParameterType == ACPI_PARAM_ARGS) && + (Info->Parameters)) { /* * The caller "owns" the parameters, so give each one an extra * reference */ - for (i = 0; Params[i]; i++) + for (i = 0; Info->Parameters[i]; i++) { - AcpiUtAddReference (Params[i]); + AcpiUtAddReference (Info->Parameters[i]); } } @@ -203,7 +205,7 @@ AcpiPsxExecute ( */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Begin Method Parse **** Entry=%p obj=%p\n", - MethodNode, ObjDesc)); + Info->Node, ObjDesc)); /* Create and init a Root Node */ @@ -231,8 +233,9 @@ AcpiPsxExecute ( goto Cleanup2; } - Status = AcpiDsInitAmlWalk (WalkState, Op, MethodNode, ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, NULL, NULL, 1); + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, NULL, 1); if (ACPI_FAILURE (Status)) { goto Cleanup3; @@ -245,7 +248,6 @@ AcpiPsxExecute ( if (ACPI_FAILURE (Status)) { goto Cleanup1; /* Walk state is already deleted */ - } /* @@ -253,7 +255,7 @@ AcpiPsxExecute ( */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Begin Method Execution **** Entry=%p obj=%p\n", - MethodNode, ObjDesc)); + Info->Node, ObjDesc)); /* Create and init a Root Node */ @@ -266,8 +268,8 @@ AcpiPsxExecute ( /* Init new op with the method name and pointer back to the NS node */ - AcpiPsSetName (Op, MethodNode->Name.Integer); - Op->Common.Node = MethodNode; + AcpiPsSetName (Op, Info->Node->Name.Integer); + Op->Common.Node = Info->Node; /* Create and initialize a new walk state */ @@ -278,16 +280,16 @@ AcpiPsxExecute ( goto Cleanup2; } - Status = AcpiDsInitAmlWalk (WalkState, Op, MethodNode, ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, Params, ReturnObjDesc, 3); + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, Info, 3); if (ACPI_FAILURE (Status)) { goto Cleanup3; } - /* - * The walk of the parse tree is where we actually execute the method - */ + /* The walk of the parse tree is where we actually execute the method */ + Status = AcpiPsParseAml (WalkState); goto Cleanup2; /* Walk state already deleted */ @@ -299,15 +301,17 @@ Cleanup2: AcpiPsDeleteParseTree (Op); Cleanup1: - if (Params) + if ((Info->ParameterType == ACPI_PARAM_ARGS) && + (Info->Parameters)) { /* Take away the extra reference that we gave the parameters above */ - for (i = 0; Params[i]; i++) + for (i = 0; Info->Parameters[i]; i++) { /* Ignore errors, just do them all */ - (void) AcpiUtUpdateObjectReference (Params[i], REF_DECREMENT); + (void) AcpiUtUpdateObjectReference ( + Info->Parameters[i], REF_DECREMENT); } } @@ -320,11 +324,11 @@ Cleanup1: * If the method has returned an object, signal this to the caller with * a control exception code */ - if (*ReturnObjDesc) + if (Info->ReturnObject) { ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n", - *ReturnObjDesc)); - ACPI_DUMP_STACK_ENTRY (*ReturnObjDesc); + Info->ReturnObject)); + ACPI_DUMP_STACK_ENTRY (Info->ReturnObject); Status = AE_CTRL_RETURN_VALUE; } diff --git a/sys/dev/acpi/acpica/Subsystem/rsaddr.c b/sys/dev/acpi/acpica/Subsystem/rsaddr.c index 39c8807c67e..07bac298210 100644 --- a/sys/dev/acpi/acpica/Subsystem/rsaddr.c +++ b/sys/dev/acpi/acpica/Subsystem/rsaddr.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsaddr - Address resource descriptors (16/32/64) - * xRevision: 34 $ + * xRevision: 40 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsaddr.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rsaddr.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __RSADDR_C__ @@ -154,20 +154,21 @@ AcpiRsAddress16Resource ( UINT8 **OutputBuffer, ACPI_SIZE *StructureSize) { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT8 *TempPtr; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16); UINT32 Index; UINT16 Temp16; UINT8 Temp8; + UINT8 *TempPtr; + UINT8 *Buffer = ByteStreamBuffer; + ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_ADDRESS16); ACPI_FUNCTION_TRACE ("RsAddress16Resource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + + /* Point past the Descriptor to get the number of bytes consumed */ + Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); @@ -181,24 +182,22 @@ AcpiRsAddress16Resource ( *BytesConsumed = Temp16 + 3; OutputStruct->Id = ACPI_RSTYPE_ADDRESS16; - /* - * Get the Resource Type (Byte3) - */ + /* Get the Resource Type (Byte3) */ + Buffer += 2; Temp8 = *Buffer; - /* Values 0-2 are valid */ + /* Values 0-2 and 0xC0-0xFF are valid */ - if (Temp8 > 2) + if ((Temp8 > 2) && (Temp8 < 0xC0)) { return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } - OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03; + OutputStruct->Data.Address16.ResourceType = Temp8; + + /* Get the General Flags (Byte4) */ - /* - * Get the General Flags (Byte4) - */ Buffer += 1; Temp8 = *Buffer; @@ -218,9 +217,8 @@ AcpiRsAddress16Resource ( OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01; - /* - * Get the Type Specific Flags (Byte5) - */ + /* Get the Type Specific Flags (Byte5) */ + Buffer += 1; Temp8 = *Buffer; @@ -229,7 +227,7 @@ AcpiRsAddress16Resource ( OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute = (UINT16) (Temp8 & 0x01); OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute = - (UINT16) ((Temp8 >> 1) & 0x0F); + (UINT16) ((Temp8 >> 1) & 0x03); } else { @@ -247,39 +245,34 @@ AcpiRsAddress16Resource ( } } - /* - * Get Granularity (Bytes 6-7) - */ + /* Get Granularity (Bytes 6-7) */ + Buffer += 1; ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.Granularity, Buffer); - /* - * Get MinAddressRange (Bytes 8-9) - */ + /* Get MinAddressRange (Bytes 8-9) */ + Buffer += 2; ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MinAddressRange, Buffer); - /* - * Get MaxAddressRange (Bytes 10-11) - */ + /* Get MaxAddressRange (Bytes 10-11) */ + Buffer += 2; ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MaxAddressRange, Buffer); - /* - * Get AddressTranslationOffset (Bytes 12-13) - */ + /* Get AddressTranslationOffset (Bytes 12-13) */ + Buffer += 2; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressTranslationOffset, Buffer); + ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressTranslationOffset, + Buffer); + + /* Get AddressLength (Bytes 14-15) */ - /* - * Get AddressLength (Bytes 14-15) - */ Buffer += 2; ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressLength, Buffer); - /* - * Resource Source Index (if present) - */ + /* Resource Source Index (if present) */ + Buffer += 2; /* @@ -308,7 +301,8 @@ AcpiRsAddress16Resource ( OutputStruct->Data.Address16.ResourceSource.StringPtr = (char *)((UINT8 * )OutputStruct + StructSize); - TempPtr = (UINT8 *) OutputStruct->Data.Address16.ResourceSource.StringPtr; + TempPtr = (UINT8 *) + OutputStruct->Data.Address16.ResourceSource.StringPtr; /* Copy the string into the buffer */ @@ -323,9 +317,8 @@ AcpiRsAddress16Resource ( Index += 1; } - /* - * Add the terminating null - */ + /* Add the terminating null */ + *TempPtr = 0x00; OutputStruct->Data.Address16.ResourceSource.StringLength = Index + 1; @@ -345,14 +338,12 @@ AcpiRsAddress16Resource ( OutputStruct->Data.Address16.ResourceSource.StringPtr = NULL; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -390,28 +381,24 @@ AcpiRsAddress16Stream ( ACPI_FUNCTION_TRACE ("RsAddress16Stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x88; Buffer += 1; - /* - * Save a pointer to the Length field - to be filled in later - */ + /* Save a pointer to the Length field - to be filled in later */ + LengthField = Buffer; Buffer += 2; - /* - * Set the Resource Type (Memory, Io, BusNumber) - */ + /* Set the Resource Type (Memory, Io, BusNumber) */ + Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03); *Buffer = Temp8; Buffer += 1; - /* - * Set the general flags - */ + /* Set the general flags */ + Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01); Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1; @@ -421,9 +408,8 @@ AcpiRsAddress16Stream ( *Buffer = Temp8; Buffer += 1; - /* - * Set the type specific flags - */ + /* Set the type specific flags */ + Temp8 = 0; if (ACPI_MEMORY_RANGE == LinkedList->Data.Address16.ResourceType) @@ -434,7 +420,7 @@ AcpiRsAddress16Stream ( Temp8 |= (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute & - 0x0F) << 1; + 0x03) << 1; } else if (ACPI_IO_RANGE == LinkedList->Data.Address16.ResourceType) { @@ -449,39 +435,34 @@ AcpiRsAddress16Stream ( *Buffer = Temp8; Buffer += 1; - /* - * Set the address space granularity - */ + /* Set the address space granularity */ + ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.Granularity); Buffer += 2; - /* - * Set the address range minimum - */ + /* Set the address range minimum */ + ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MinAddressRange); Buffer += 2; - /* - * Set the address range maximum - */ + /* Set the address range maximum */ + ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MaxAddressRange); Buffer += 2; - /* - * Set the address translation offset - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressTranslationOffset); + /* Set the address translation offset */ + + ACPI_MOVE_32_TO_16 (Buffer, + &LinkedList->Data.Address16.AddressTranslationOffset); Buffer += 2; - /* - * Set the address length - */ + /* Set the address length */ + ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressLength); Buffer += 2; - /* - * Resource Source Index and Resource Source are optional - */ + /* Resource Source Index and Resource Source are optional */ + if (0 != LinkedList->Data.Address16.ResourceSource.StringLength) { Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSource.Index; @@ -491,9 +472,8 @@ AcpiRsAddress16Stream ( TempPointer = (char *) Buffer; - /* - * Copy the string - */ + /* Copy the string */ + ACPI_STRCPY (TempPointer, LinkedList->Data.Address16.ResourceSource.StringPtr); @@ -501,12 +481,12 @@ AcpiRsAddress16Stream ( * Buffer needs to be set to the length of the sting + one for the * terminating null */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address16.ResourceSource.StringPtr) + 1); + Buffer += (ACPI_SIZE)(ACPI_STRLEN ( + LinkedList->Data.Address16.ResourceSource.StringPtr) + 1); } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + ActualBytes = ACPI_PTR_DIFF (Buffer, *OutputBuffer); *BytesConsumed = ActualBytes; @@ -563,9 +543,8 @@ AcpiRsAddress32Resource ( Buffer = ByteStreamBuffer; StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS32); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); @@ -579,49 +558,43 @@ AcpiRsAddress32Resource ( *BytesConsumed = Temp16 + 3; OutputStruct->Id = ACPI_RSTYPE_ADDRESS32; - /* - * Get the Resource Type (Byte3) - */ + /* Get the Resource Type (Byte3) */ + Buffer += 2; Temp8 = *Buffer; - /* Values 0-2 are valid */ - if(Temp8 > 2) + /* Values 0-2 and 0xC0-0xFF are valid */ + + if ((Temp8 > 2) && (Temp8 < 0xC0)) { return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } - OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03; + OutputStruct->Data.Address32.ResourceType = Temp8; + + /* Get the General Flags (Byte4) */ - /* - * Get the General Flags (Byte4) - */ Buffer += 1; Temp8 = *Buffer; - /* - * Producer / Consumer - */ + /* Producer / Consumer */ + OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01; - /* - * Decode - */ + /* Decode */ + OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01; - /* - * Min Address Fixed - */ + /* Min Address Fixed */ + OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01; - /* - * Max Address Fixed - */ + /* Max Address Fixed */ + OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01; - /* - * Get the Type Specific Flags (Byte5) - */ + /* Get the Type Specific Flags (Byte5) */ + Buffer += 1; Temp8 = *Buffer; @@ -631,7 +604,7 @@ AcpiRsAddress32Resource ( (UINT16) (Temp8 & 0x01); OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute = - (UINT16) ((Temp8 >> 1) & 0x0F); + (UINT16) ((Temp8 >> 1) & 0x03); } else { @@ -649,39 +622,34 @@ AcpiRsAddress32Resource ( } } - /* - * Get Granularity (Bytes 6-9) - */ + /* Get Granularity (Bytes 6-9) */ + Buffer += 1; ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.Granularity, Buffer); - /* - * Get MinAddressRange (Bytes 10-13) - */ + /* Get MinAddressRange (Bytes 10-13) */ + Buffer += 4; ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange, Buffer); - /* - * Get MaxAddressRange (Bytes 14-17) - */ + /* Get MaxAddressRange (Bytes 14-17) */ + Buffer += 4; ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange, Buffer); - /* - * Get AddressTranslationOffset (Bytes 18-21) - */ + /* Get AddressTranslationOffset (Bytes 18-21) */ + Buffer += 4; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressTranslationOffset, Buffer); + ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressTranslationOffset, + Buffer); + + /* Get AddressLength (Bytes 22-25) */ - /* - * Get AddressLength (Bytes 22-25) - */ Buffer += 4; ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressLength, Buffer); - /* - * Resource Source Index (if present) - */ + /* Resource Source Index (if present) */ + Buffer += 4; /* @@ -709,7 +677,8 @@ AcpiRsAddress32Resource ( OutputStruct->Data.Address32.ResourceSource.StringPtr = (char *)((UINT8 *)OutputStruct + StructSize); - TempPtr = (UINT8 *) OutputStruct->Data.Address32.ResourceSource.StringPtr; + TempPtr = (UINT8 *) + OutputStruct->Data.Address32.ResourceSource.StringPtr; /* Copy the string into the buffer */ @@ -723,9 +692,8 @@ AcpiRsAddress32Resource ( Index += 1; } - /* - * Add the terminating null - */ + /* Add the terminating null */ + *TempPtr = 0x00; OutputStruct->Data.Address32.ResourceSource.StringLength = Index + 1; @@ -744,14 +712,12 @@ AcpiRsAddress32Resource ( OutputStruct->Data.Address32.ResourceSource.StringPtr = NULL; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -790,29 +756,25 @@ AcpiRsAddress32Stream ( Buffer = *OutputBuffer; - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x87; Buffer += 1; - /* - * Set a pointer to the Length field - to be filled in later - */ + /* Set a pointer to the Length field - to be filled in later */ + LengthField = ACPI_CAST_PTR (UINT16, Buffer); Buffer += 2; - /* - * Set the Resource Type (Memory, Io, BusNumber) - */ + /* Set the Resource Type (Memory, Io, BusNumber) */ + Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03); *Buffer = Temp8; Buffer += 1; - /* - * Set the general flags - */ + /* Set the general flags */ + Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01); Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1; Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2; @@ -821,9 +783,8 @@ AcpiRsAddress32Stream ( *Buffer = Temp8; Buffer += 1; - /* - * Set the type specific flags - */ + /* Set the type specific flags */ + Temp8 = 0; if (ACPI_MEMORY_RANGE == LinkedList->Data.Address32.ResourceType) @@ -834,7 +795,7 @@ AcpiRsAddress32Stream ( Temp8 |= (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute & - 0x0F) << 1; + 0x03) << 1; } else if (ACPI_IO_RANGE == LinkedList->Data.Address32.ResourceType) { @@ -849,39 +810,34 @@ AcpiRsAddress32Stream ( *Buffer = Temp8; Buffer += 1; - /* - * Set the address space granularity - */ + /* Set the address space granularity */ + ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.Granularity); Buffer += 4; - /* - * Set the address range minimum - */ + /* Set the address range minimum */ + ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MinAddressRange); Buffer += 4; - /* - * Set the address range maximum - */ + /* Set the address range maximum */ + ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MaxAddressRange); Buffer += 4; - /* - * Set the address translation offset - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressTranslationOffset); + /* Set the address translation offset */ + + ACPI_MOVE_32_TO_32 (Buffer, + &LinkedList->Data.Address32.AddressTranslationOffset); Buffer += 4; - /* - * Set the address length - */ + /* Set the address length */ + ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressLength); Buffer += 4; - /* - * Resource Source Index and Resource Source are optional - */ + /* Resource Source Index and Resource Source are optional */ + if (0 != LinkedList->Data.Address32.ResourceSource.StringLength) { Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSource.Index; @@ -891,9 +847,8 @@ AcpiRsAddress32Stream ( TempPointer = (char *) Buffer; - /* - * Copy the string - */ + /* Copy the string */ + ACPI_STRCPY (TempPointer, LinkedList->Data.Address32.ResourceSource.StringPtr); @@ -901,12 +856,12 @@ AcpiRsAddress32Stream ( * Buffer needs to be set to the length of the sting + one for the * terminating null */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address32.ResourceSource.StringPtr) + 1); + Buffer += (ACPI_SIZE)(ACPI_STRLEN ( + LinkedList->Data.Address32.ResourceSource.StringPtr) + 1); } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); /* @@ -950,6 +905,7 @@ AcpiRsAddress64Resource ( ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; UINT16 Temp16; UINT8 Temp8; + UINT8 ResourceType; UINT8 *TempPtr; ACPI_SIZE StructSize; UINT32 Index; @@ -960,10 +916,10 @@ AcpiRsAddress64Resource ( Buffer = ByteStreamBuffer; StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64); + ResourceType = *Buffer; + + /* Point past the Descriptor to get the number of bytes consumed */ - /* - * Point past the Descriptor to get the number of bytes consumed - */ Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); @@ -977,50 +933,43 @@ AcpiRsAddress64Resource ( *BytesConsumed = Temp16 + 3; OutputStruct->Id = ACPI_RSTYPE_ADDRESS64; - /* - * Get the Resource Type (Byte3) - */ + /* Get the Resource Type (Byte3) */ + Buffer += 2; Temp8 = *Buffer; - /* Values 0-2 are valid */ + /* Values 0-2 and 0xC0-0xFF are valid */ - if(Temp8 > 2) + if ((Temp8 > 2) && (Temp8 < 0xC0)) { return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } - OutputStruct->Data.Address64.ResourceType = Temp8 & 0x03; + OutputStruct->Data.Address64.ResourceType = Temp8; + + /* Get the General Flags (Byte4) */ - /* - * Get the General Flags (Byte4) - */ Buffer += 1; Temp8 = *Buffer; - /* - * Producer / Consumer - */ + /* Producer / Consumer */ + OutputStruct->Data.Address64.ProducerConsumer = Temp8 & 0x01; - /* - * Decode - */ + /* Decode */ + OutputStruct->Data.Address64.Decode = (Temp8 >> 1) & 0x01; - /* - * Min Address Fixed - */ + /* Min Address Fixed */ + OutputStruct->Data.Address64.MinAddressFixed = (Temp8 >> 2) & 0x01; - /* - * Max Address Fixed - */ + /* Max Address Fixed */ + OutputStruct->Data.Address64.MaxAddressFixed = (Temp8 >> 3) & 0x01; - /* - * Get the Type Specific Flags (Byte5) - */ + /* Get the Type Specific Flags (Byte5) */ + Buffer += 1; Temp8 = *Buffer; @@ -1030,7 +979,7 @@ AcpiRsAddress64Resource ( (UINT16) (Temp8 & 0x01); OutputStruct->Data.Address64.Attribute.Memory.CacheAttribute = - (UINT16) ((Temp8 >> 1) & 0x0F); + (UINT16) ((Temp8 >> 1) & 0x03); } else { @@ -1048,111 +997,125 @@ AcpiRsAddress64Resource ( } } - /* - * Get Granularity (Bytes 6-13) - */ + if (ResourceType == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) + { + /* Move past RevisionId and Reserved byte */ + + Buffer += 2; + } + + /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ + Buffer += 1; ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.Granularity, Buffer); - /* - * Get MinAddressRange (Bytes 14-21) - */ + /* Get MinAddressRange (Bytes 14-21) or (Bytes 16-23) */ + Buffer += 8; ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MinAddressRange, Buffer); - /* - * Get MaxAddressRange (Bytes 22-29) - */ + /* Get MaxAddressRange (Bytes 22-29) or (Bytes 24-31) */ + Buffer += 8; ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MaxAddressRange, Buffer); - /* - * Get AddressTranslationOffset (Bytes 30-37) - */ + /* Get AddressTranslationOffset (Bytes 30-37) or (Bytes 32-39) */ + Buffer += 8; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressTranslationOffset, Buffer); + ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressTranslationOffset, + Buffer); + + /* Get AddressLength (Bytes 38-45) or (Bytes 40-47) */ - /* - * Get AddressLength (Bytes 38-45) - */ Buffer += 8; ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressLength, Buffer); - /* - * Resource Source Index (if present) - */ - Buffer += 8; + OutputStruct->Data.Address64.ResourceSource.Index = 0x00; + OutputStruct->Data.Address64.ResourceSource.StringLength = 0; + OutputStruct->Data.Address64.ResourceSource.StringPtr = NULL; - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*BytesConsumed > (46 + 1)) + if (ResourceType == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { - /* Dereference the Index */ + /* Get TypeSpecificAttribute (Bytes 48-55) */ - Temp8 = *Buffer; - OutputStruct->Data.Address64.ResourceSource.Index = - (UINT32) Temp8; + Buffer += 8; + ACPI_MOVE_64_TO_64 ( + &OutputStruct->Data.Address64.TypeSpecificAttributes, + Buffer); + } + else + { + OutputStruct->Data.Address64.TypeSpecificAttributes = 0; - /* Point to the String */ + /* Resource Source Index (if present) */ - Buffer += 1; + Buffer += 8; - /* Point the String pointer to the end of this structure */ + /* + * This will leave us pointing to the Resource Source Index + * If it is present, then save it off and calculate the + * pointer to where the null terminated string goes: + * Each Interrupt takes 32-bits + the 5 bytes of the + * stream that are default. + * + * Note: Some resource descriptors will have an additional null, so + * we add 1 to the length. + */ + if (*BytesConsumed > (46 + 1)) + { + /* Dereference the Index */ - OutputStruct->Data.Address64.ResourceSource.StringPtr = - (char *)((UINT8 *)OutputStruct + StructSize); + Temp8 = *Buffer; + OutputStruct->Data.Address64.ResourceSource.Index = + (UINT32) Temp8; - TempPtr = (UINT8 *) OutputStruct->Data.Address64.ResourceSource.StringPtr; + /* Point to the String */ - /* Copy the string into the buffer */ + Buffer += 1; - Index = 0; - while (0x00 != *Buffer) - { - *TempPtr = *Buffer; + /* Point the String pointer to the end of this structure */ - TempPtr += 1; - Buffer += 1; - Index += 1; - } + OutputStruct->Data.Address64.ResourceSource.StringPtr = + (char *)((UINT8 *)OutputStruct + StructSize); - /* - * Add the terminating null - */ - *TempPtr = 0x00; - OutputStruct->Data.Address64.ResourceSource.StringLength = Index + 1; + TempPtr = (UINT8 *) + OutputStruct->Data.Address64.ResourceSource.StringPtr; - /* - * In order for the StructSize to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * StructSize to the next 32-bit boundary. - */ - Temp8 = (UINT8) (Index + 1); - StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8); - } - else - { - OutputStruct->Data.Address64.ResourceSource.Index = 0x00; - OutputStruct->Data.Address64.ResourceSource.StringLength = 0; - OutputStruct->Data.Address64.ResourceSource.StringPtr = NULL; + /* Copy the string into the buffer */ + + Index = 0; + while (0x00 != *Buffer) + { + *TempPtr = *Buffer; + + TempPtr += 1; + Buffer += 1; + Index += 1; + } + + /* + * Add the terminating null + */ + *TempPtr = 0x00; + OutputStruct->Data.Address64.ResourceSource.StringLength = + Index + 1; + + /* + * In order for the StructSize to fall on a 32-bit boundary, + * calculate the length of the string and expand the + * StructSize to the next 32-bit boundary. + */ + Temp8 = (UINT8) (Index + 1); + StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8); + } } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -1191,29 +1154,25 @@ AcpiRsAddress64Stream ( Buffer = *OutputBuffer; - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x8A; Buffer += 1; - /* - * Set a pointer to the Length field - to be filled in later - */ + /* Set a pointer to the Length field - to be filled in later */ + LengthField = ACPI_CAST_PTR (UINT16, Buffer); Buffer += 2; - /* - * Set the Resource Type (Memory, Io, BusNumber) - */ + /* Set the Resource Type (Memory, Io, BusNumber) */ + Temp8 = (UINT8) (LinkedList->Data.Address64.ResourceType & 0x03); *Buffer = Temp8; Buffer += 1; - /* - * Set the general flags - */ + /* Set the general flags */ + Temp8 = (UINT8) (LinkedList->Data.Address64.ProducerConsumer & 0x01); Temp8 |= (LinkedList->Data.Address64.Decode & 0x01) << 1; Temp8 |= (LinkedList->Data.Address64.MinAddressFixed & 0x01) << 2; @@ -1222,9 +1181,8 @@ AcpiRsAddress64Stream ( *Buffer = Temp8; Buffer += 1; - /* - * Set the type specific flags - */ + /* Set the type specific flags */ + Temp8 = 0; if (ACPI_MEMORY_RANGE == LinkedList->Data.Address64.ResourceType) @@ -1235,7 +1193,7 @@ AcpiRsAddress64Stream ( Temp8 |= (LinkedList->Data.Address64.Attribute.Memory.CacheAttribute & - 0x0F) << 1; + 0x03) << 1; } else if (ACPI_IO_RANGE == LinkedList->Data.Address64.ResourceType) { @@ -1250,39 +1208,34 @@ AcpiRsAddress64Stream ( *Buffer = Temp8; Buffer += 1; - /* - * Set the address space granularity - */ + /* Set the address space granularity */ + ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.Granularity); Buffer += 8; - /* - * Set the address range minimum - */ + /* Set the address range minimum */ + ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MinAddressRange); Buffer += 8; - /* - * Set the address range maximum - */ + /* Set the address range maximum */ + ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MaxAddressRange); Buffer += 8; - /* - * Set the address translation offset - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressTranslationOffset); + /* Set the address translation offset */ + + ACPI_MOVE_64_TO_64 (Buffer, + &LinkedList->Data.Address64.AddressTranslationOffset); Buffer += 8; - /* - * Set the address length - */ + /* Set the address length */ + ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressLength); Buffer += 8; - /* - * Resource Source Index and Resource Source are optional - */ + /* Resource Source Index and Resource Source are optional */ + if (0 != LinkedList->Data.Address64.ResourceSource.StringLength) { Temp8 = (UINT8) LinkedList->Data.Address64.ResourceSource.Index; @@ -1292,21 +1245,21 @@ AcpiRsAddress64Stream ( TempPointer = (char *) Buffer; - /* - * Copy the string - */ - ACPI_STRCPY (TempPointer, LinkedList->Data.Address64.ResourceSource.StringPtr); + /* Copy the string */ + + ACPI_STRCPY (TempPointer, + LinkedList->Data.Address64.ResourceSource.StringPtr); /* * Buffer needs to be set to the length of the sting + one for the * terminating null */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address64.ResourceSource.StringPtr) + 1); + Buffer += (ACPI_SIZE)(ACPI_STRLEN ( + LinkedList->Data.Address64.ResourceSource.StringPtr) + 1); } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); /* diff --git a/sys/dev/acpi/acpica/Subsystem/rscalc.c b/sys/dev/acpi/acpica/Subsystem/rscalc.c index 4e3bff60122..f064b941811 100644 --- a/sys/dev/acpi/acpica/Subsystem/rscalc.c +++ b/sys/dev/acpi/acpica/Subsystem/rscalc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rscalc - Calculate stream and list lengths - * xRevision: 50 $ + * xRevision: 57 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rscalc.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rscalc.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __RSCALC_C__ @@ -151,7 +151,6 @@ AcpiRsGetByteStreamLength ( { ACPI_SIZE ByteStreamSizeNeeded = 0; ACPI_SIZE SegmentSize; - ACPI_RESOURCE_EXT_IRQ *ExIrq = NULL; BOOLEAN Done = FALSE; @@ -160,9 +159,8 @@ AcpiRsGetByteStreamLength ( while (!Done) { - /* - * Init the variable that will hold the size to add to the total. - */ + /* Init the variable that will hold the size to add to the total. */ + SegmentSize = 0; switch (LinkedList->Id) @@ -170,8 +168,8 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_IRQ: /* * IRQ Resource - * For an IRQ Resource, Byte 3, although optional, will - * always be created - it holds IRQ information. + * For an IRQ Resource, Byte 3, although optional, will always be + * created - it holds IRQ information. */ SegmentSize = 4; break; @@ -187,8 +185,8 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_START_DPF: /* * Start Dependent Functions Resource - * For a StartDependentFunctions Resource, Byte 1, - * although optional, will always be created. + * For a StartDependentFunctions Resource, Byte 1, although + * optional, will always be created. */ SegmentSize = 2; break; @@ -220,10 +218,9 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_VENDOR: /* * Vendor Defined Resource - * For a Vendor Specific resource, if the Length is - * between 1 and 7 it will be created as a Small - * Resource data type, otherwise it is a Large - * Resource data type. + * For a Vendor Specific resource, if the Length is between 1 and 7 + * it will be created as a Small Resource data type, otherwise it + * is a Large Resource data type. */ if (LinkedList->Data.VendorSpecific.Length > 7) { @@ -272,16 +269,16 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_ADDRESS16: /* * 16-Bit Address Resource - * The base size of this byte stream is 16. If a - * Resource Source string is not NULL, add 1 for - * the Index + the length of the null terminated - * string Resource Source + 1 for the null. + * The base size of this byte stream is 16. If a Resource Source + * string is not NULL, add 1 for the Index + the length of the null + * terminated string Resource Source + 1 for the null. */ SegmentSize = 16; if (LinkedList->Data.Address16.ResourceSource.StringPtr) { - SegmentSize += LinkedList->Data.Address16.ResourceSource.StringLength; + SegmentSize += + LinkedList->Data.Address16.ResourceSource.StringLength; SegmentSize++; } break; @@ -298,7 +295,8 @@ AcpiRsGetByteStreamLength ( if (LinkedList->Data.Address32.ResourceSource.StringPtr) { - SegmentSize += LinkedList->Data.Address32.ResourceSource.StringLength; + SegmentSize += + LinkedList->Data.Address32.ResourceSource.StringLength; SegmentSize++; } break; @@ -306,16 +304,16 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_ADDRESS64: /* * 64-Bit Address Resource - * The base size of this byte stream is 46. If a Resource - * Source string is not NULL, add 1 for the Index + the - * length of the null terminated string Resource Source + - * 1 for the null. + * The base size of this byte stream is 46. If a ResourceSource + * string is not NULL, add 1 for the Index + the length of the null + * terminated string Resource Source + 1 for the null. */ SegmentSize = 46; if (LinkedList->Data.Address64.ResourceSource.StringPtr) { - SegmentSize += LinkedList->Data.Address64.ResourceSource.StringLength; + SegmentSize += + LinkedList->Data.Address64.ResourceSource.StringLength; SegmentSize++; } break; @@ -323,47 +321,43 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_EXT_IRQ: /* * Extended IRQ Resource - * The base size of this byte stream is 9. This is for an - * Interrupt table length of 1. For each additional - * interrupt, add 4. + * The base size of this byte stream is 9. This is for an Interrupt + * table length of 1. For each additional interrupt, add 4. * If a Resource Source string is not NULL, add 1 for the * Index + the length of the null terminated string * Resource Source + 1 for the null. */ - SegmentSize = 9 + - (((ACPI_SIZE) LinkedList->Data.ExtendedIrq.NumberOfInterrupts - 1) * 4); + SegmentSize = 9 + (((ACPI_SIZE) + LinkedList->Data.ExtendedIrq.NumberOfInterrupts - 1) * 4); - if (ExIrq && ExIrq->ResourceSource.StringPtr) + if (LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr) { - SegmentSize += LinkedList->Data.ExtendedIrq.ResourceSource.StringLength; + SegmentSize += + LinkedList->Data.ExtendedIrq.ResourceSource.StringLength; SegmentSize++; } break; default: - /* - * If we get here, everything is out of sync, - * so exit with an error - */ + + /* If we get here, everything is out of sync, exit with error */ + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } /* switch (LinkedList->Id) */ - /* - * Update the total - */ + /* Update the total */ + ByteStreamSizeNeeded += SegmentSize; - /* - * Point to the next object - */ + /* Point to the next object */ + LinkedList = ACPI_PTR_ADD (ACPI_RESOURCE, LinkedList, LinkedList->Length); } - /* - * This is the data the caller needs - */ + /* This is the data the caller needs */ + *SizeNeeded = ByteStreamSizeNeeded; return_ACPI_STATUS (AE_OK); } @@ -412,9 +406,8 @@ AcpiRsGetListLength ( while (BytesParsed < ByteStreamBufferLength) { - /* - * The next byte in the stream is the resource type - */ + /* The next byte in the stream is the resource type */ + ResourceType = AcpiRsGetResourceType (*ByteStreamBuffer); switch (ResourceType) @@ -439,9 +432,8 @@ AcpiRsGetListLength ( ACPI_MOVE_16_TO_16 (&Temp16, Buffer); BytesConsumed = Temp16 + 3; - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + Temp16 = (UINT16) ACPI_ROUND_UP_TO_32BITS (Temp16); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR) + @@ -453,7 +445,6 @@ AcpiRsGetListLength ( /* * 32-Bit Memory Range Resource */ - BytesConsumed = 20; StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM32); @@ -470,6 +461,20 @@ AcpiRsGetListLength ( break; + case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: + /* + * 64-Bit Address Resource + */ + Buffer = ByteStreamBuffer; + + ++Buffer; + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + + BytesConsumed = Temp16 + 3; + StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64); + break; + + case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: /* * 64-Bit Address Resource @@ -482,14 +487,12 @@ AcpiRsGetListLength ( BytesConsumed = Temp16 + 3; /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 43, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. + * Resource Source Index and Resource Source are optional elements. + * Check the length of the Bytestream. If it is greater than 43, + * that means that an Index exists and is followed by a null + * terminated string. Therefore, set the temp variable to the + * length minus the minimum byte stream length plus the byte for + * the Index to determine the size of the NULL terminated string. */ if (43 < Temp16) { @@ -500,9 +503,8 @@ AcpiRsGetListLength ( Temp8 = 0; } - /* - * Ensure a 64-bit boundary for the structure - */ + /* Ensure a 64-bit boundary for the structure */ + Temp8 = (UINT8) ACPI_ROUND_UP_TO_64BITS (Temp8); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64) + @@ -522,14 +524,12 @@ AcpiRsGetListLength ( BytesConsumed = Temp16 + 3; /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 23, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. + * Resource Source Index and Resource Source are optional elements. + * Check the length of the Bytestream. If it is greater than 23, + * that means that an Index exists and is followed by a null + * terminated string. Therefore, set the temp variable to the + * length minus the minimum byte stream length plus the byte for + * the Index to determine the size of the NULL terminated string. */ if (23 < Temp16) { @@ -540,9 +540,8 @@ AcpiRsGetListLength ( Temp8 = 0; } - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS32) + @@ -562,14 +561,12 @@ AcpiRsGetListLength ( BytesConsumed = Temp16 + 3; /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 13, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. + * Resource Source Index and Resource Source are optional elements. + * Check the length of the Bytestream. If it is greater than 13, + * that means that an Index exists and is followed by a null + * terminated string. Therefore, set the temp variable to the + * length minus the minimum byte stream length plus the byte for + * the Index to determine the size of the NULL terminated string. */ if (13 < Temp16) { @@ -580,9 +577,8 @@ AcpiRsGetListLength ( Temp8 = 0; } - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16) + @@ -602,9 +598,8 @@ AcpiRsGetListLength ( BytesConsumed = Temp16 + 3; /* - * Point past the length field and the - * Interrupt vector flags to save off the - * Interrupt table length to the Temp8 variable. + * Point past the length field and the Interrupt vector flags to + * save off the Interrupt table length to the Temp8 variable. */ Buffer += 3; Temp8 = *Buffer; @@ -616,14 +611,12 @@ AcpiRsGetListLength ( AdditionalBytes = (UINT8) ((Temp8 - 1) * 4); /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 9, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. + * Resource Source Index and Resource Source are optional elements. + * Check the length of the Bytestream. If it is greater than 9, + * that means that an Index exists and is followed by a null + * terminated string. Therefore, set the temp variable to the + * length minus the minimum byte stream length plus the byte for + * the Index to determine the size of the NULL terminated string. */ if (9 + AdditionalBytes < Temp16) { @@ -634,9 +627,8 @@ AcpiRsGetListLength ( Temp8 = 0; } - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_EXT_IRQ) + @@ -662,14 +654,12 @@ AcpiRsGetListLength ( BytesConsumed = 3; } - /* - * Point past the descriptor - */ + /* Point past the descriptor */ + ++Buffer; - /* - * Look at the number of bits set - */ + /* Look at the number of bits set */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); for (Index = 0; Index < 16; Index++) @@ -694,14 +684,12 @@ AcpiRsGetListLength ( Buffer = ByteStreamBuffer; BytesConsumed = 3; - /* - * Point past the descriptor - */ + /* Point past the descriptor */ + ++Buffer; - /* - * Look at the number of bits set - */ + /* Look at the number of bits set */ + Temp8 = *Buffer; for(Index = 0; Index < 8; Index++) @@ -777,9 +765,8 @@ AcpiRsGetListLength ( Temp8 = (UINT8) (Temp8 & 0x7); BytesConsumed = Temp8 + 1; - /* - * Ensure a 32-bit boundary for the structure - */ + /* Ensure a 32-bit boundary for the structure */ + Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR) + (Temp8 * sizeof (UINT8)); @@ -804,21 +791,18 @@ AcpiRsGetListLength ( return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } - /* - * Update the return value and counter - */ + /* Update the return value and counter */ + BufferSize += (UINT32) ACPI_ALIGN_RESOURCE_SIZE (StructureSize); BytesParsed += BytesConsumed; - /* - * Set the byte stream to point to the next resource - */ + /* Set the byte stream to point to the next resource */ + ByteStreamBuffer += BytesConsumed; } - /* - * This is the data the caller needs - */ + /* This is the data the caller needs */ + *SizeNeeded = BufferSize; return_ACPI_STATUS (AE_OK); } @@ -875,9 +859,8 @@ AcpiRsGetPciRoutingTableLength ( for (Index = 0; Index < NumberOfElements; Index++) { - /* - * Dereference the sub-package - */ + /* Dereference the sub-package */ + PackageElement = *TopObjectList; /* @@ -886,33 +869,35 @@ AcpiRsGetPciRoutingTableLength ( */ SubObjectList = PackageElement->Package.Elements; - /* - * Scan the IrqTableElements for the Source Name String - */ + /* Scan the IrqTableElements for the Source Name String */ + NameFound = FALSE; for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) { - if ((ACPI_TYPE_STRING == ACPI_GET_OBJECT_TYPE (*SubObjectList)) || - ((ACPI_TYPE_LOCAL_REFERENCE == ACPI_GET_OBJECT_TYPE (*SubObjectList)) && - ((*SubObjectList)->Reference.Opcode == AML_INT_NAMEPATH_OP))) + if ((ACPI_TYPE_STRING == + ACPI_GET_OBJECT_TYPE (*SubObjectList)) || + + ((ACPI_TYPE_LOCAL_REFERENCE == + ACPI_GET_OBJECT_TYPE (*SubObjectList)) && + + ((*SubObjectList)->Reference.Opcode == + AML_INT_NAMEPATH_OP))) { NameFound = TRUE; } else { - /* - * Look at the next element - */ + /* Look at the next element */ + SubObjectList++; } } TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); - /* - * Was a String type found? - */ + /* Was a String type found? */ + if (NameFound) { if (ACPI_GET_OBJECT_TYPE (*SubObjectList) == ACPI_TYPE_STRING) @@ -921,7 +906,8 @@ AcpiRsGetPciRoutingTableLength ( * The length String.Length field does not include the * terminating NULL, add 1 */ - TempSizeNeeded += ((ACPI_SIZE) (*SubObjectList)->String.Length + 1); + TempSizeNeeded += ((ACPI_SIZE) + (*SubObjectList)->String.Length + 1); } else { @@ -942,14 +928,14 @@ AcpiRsGetPciRoutingTableLength ( TempSizeNeeded = ACPI_ROUND_UP_TO_64BITS (TempSizeNeeded); - /* - * Point to the next ACPI_OPERAND_OBJECT - */ + /* Point to the next ACPI_OPERAND_OBJECT */ + TopObjectList++; } /* - * Adding an extra element to the end of the list, essentially a NULL terminator + * Adding an extra element to the end of the list, essentially a + * NULL terminator */ *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE); return_ACPI_STATUS (AE_OK); diff --git a/sys/dev/acpi/acpica/Subsystem/rscreate.c b/sys/dev/acpi/acpica/Subsystem/rscreate.c index 52be4e72559..260defba0ff 100644 --- a/sys/dev/acpi/acpica/Subsystem/rscreate.c +++ b/sys/dev/acpi/acpica/Subsystem/rscreate.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rscreate - Create resource lists/tables - * xRevision: 66 $ + * xRevision: 70 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rscreate.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rscreate.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __RSCREATE_C__ @@ -165,9 +165,8 @@ AcpiRsCreateResourceList ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteStreamBuffer = %p\n", ByteStreamBuffer)); - /* - * Params already validated, so we don't re-validate here - */ + /* Params already validated, so we don't re-validate here */ + ByteStreamBufferLength = ByteStreamBuffer->Buffer.Length; ByteStreamStart = ByteStreamBuffer->Buffer.Pointer; @@ -252,9 +251,8 @@ AcpiRsCreatePciRoutingTable ( /* Params already validated, so we don't re-validate here */ - /* - * Get the required buffer length - */ + /* Get the required buffer length */ + Status = AcpiRsGetPciRoutingTableLength (PackageObject, &BufferSizeNeeded); if (ACPI_FAILURE (Status)) @@ -301,9 +299,8 @@ AcpiRsCreatePciRoutingTable ( */ UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); - /* - * Each element of the top-level package must also be a package - */ + /* Each element of the top-level package must also be a package */ + if (ACPI_GET_OBJECT_TYPE (*TopObjectList) != ACPI_TYPE_PACKAGE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, @@ -329,9 +326,8 @@ AcpiRsCreatePciRoutingTable ( */ SubObjectList = (*TopObjectList)->Package.Elements; - /* - * 1) First subobject: Dereference the PRT.Address - */ + /* 1) First subobject: Dereference the PRT.Address */ + ObjDesc = SubObjectList[0]; if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { @@ -345,9 +341,8 @@ AcpiRsCreatePciRoutingTable ( return_ACPI_STATUS (AE_BAD_DATA); } - /* - * 2) Second subobject: Dereference the PRT.Pin - */ + /* 2) Second subobject: Dereference the PRT.Pin */ + ObjDesc = SubObjectList[1]; if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { @@ -361,9 +356,8 @@ AcpiRsCreatePciRoutingTable ( return_ACPI_STATUS (AE_BAD_DATA); } - /* - * 3) Third subobject: Dereference the PRT.SourceName - */ + /* 3) Third subobject: Dereference the PRT.SourceName */ + ObjDesc = SubObjectList[2]; switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -388,7 +382,9 @@ AcpiRsCreatePciRoutingTable ( Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); - UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; /* include null terminator */ + /* +1 to include null terminator */ + + UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; break; @@ -396,8 +392,10 @@ AcpiRsCreatePciRoutingTable ( ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); - /* Add to the Length field the length of the string (add 1 for terminator) */ - + /* + * Add to the Length field the length of the string + * (add 1 for terminator) + */ UserPrt->Length += ObjDesc->String.Length + 1; break; @@ -425,9 +423,8 @@ AcpiRsCreatePciRoutingTable ( UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BITS (UserPrt->Length); - /* - * 4) Fourth subobject: Dereference the PRT.SourceIndex - */ + /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ + ObjDesc = SubObjectList[3]; if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { diff --git a/sys/dev/acpi/acpica/Subsystem/rsdump.c b/sys/dev/acpi/acpica/Subsystem/rsdump.c index 50799abb53e..543ecb6ade0 100644 --- a/sys/dev/acpi/acpica/Subsystem/rsdump.c +++ b/sys/dev/acpi/acpica/Subsystem/rsdump.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsdump - Functions to display the resource structures. - * xRevision: 38 $ + * xRevision: 44 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsdump.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rsdump.c,v 1.13 2005/05/02 14:52:10 kochi Exp $"); #define __RSDUMP_C__ @@ -126,9 +126,63 @@ __KERNEL_RCSID(0, "$NetBSD: rsdump.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsdump") - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/* Local prototypes */ + +static void +AcpiRsDumpIrq ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpAddress16 ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpAddress32 ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpAddress64 ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpDma ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpIo ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpExtendedIrq ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpFixedIo ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpFixedMemory32 ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpMemory24 ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpMemory32 ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpStartDependFns ( + ACPI_RESOURCE_DATA *Data); + +static void +AcpiRsDumpVendorSpecific ( + ACPI_RESOURCE_DATA *Data); + + /******************************************************************************* * * FUNCTION: AcpiRsDumpIrq @@ -141,7 +195,7 @@ __KERNEL_RCSID(0, "$NetBSD: rsdump.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); * ******************************************************************************/ -void +static void AcpiRsDumpIrq ( ACPI_RESOURCE_DATA *Data) { @@ -155,13 +209,13 @@ AcpiRsDumpIrq ( AcpiOsPrintf ("IRQ Resource\n"); AcpiOsPrintf (" %s Triggered\n", - ACPI_LEVEL_SENSITIVE == IrqData->EdgeLevel ? "Level" : "Edge"); + ACPI_LEVEL_SENSITIVE == IrqData->EdgeLevel ? "Level" : "Edge"); AcpiOsPrintf (" Active %s\n", - ACPI_ACTIVE_LOW == IrqData->ActiveHighLow ? "Low" : "High"); + ACPI_ACTIVE_LOW == IrqData->ActiveHighLow ? "Low" : "High"); AcpiOsPrintf (" %s\n", - ACPI_SHARED == IrqData->SharedExclusive ? "Shared" : "Exclusive"); + ACPI_SHARED == IrqData->SharedExclusive ? "Shared" : "Exclusive"); AcpiOsPrintf (" %X Interrupts ( ", IrqData->NumberOfInterrupts); @@ -187,7 +241,7 @@ AcpiRsDumpIrq ( * ******************************************************************************/ -void +static void AcpiRsDumpDma ( ACPI_RESOURCE_DATA *Data) { @@ -224,7 +278,7 @@ AcpiRsDumpDma ( } AcpiOsPrintf (" %sBus Master\n", - ACPI_BUS_MASTER == DmaData->BusMaster ? "" : "Not a "); + ACPI_BUS_MASTER == DmaData->BusMaster ? "" : "Not a "); switch (DmaData->Transfer) @@ -246,7 +300,8 @@ AcpiRsDumpDma ( break; } - AcpiOsPrintf (" Number of Channels: %X ( ", DmaData->NumberOfChannels); + AcpiOsPrintf (" Number of Channels: %X ( ", + DmaData->NumberOfChannels); for (Index = 0; Index < DmaData->NumberOfChannels; Index++) { @@ -270,7 +325,7 @@ AcpiRsDumpDma ( * ******************************************************************************/ -void +static void AcpiRsDumpStartDependFns ( ACPI_RESOURCE_DATA *Data) { @@ -316,8 +371,7 @@ AcpiRsDumpStartDependFns ( break; default: - AcpiOsPrintf (" Invalid performance " - "robustness preference\n"); + AcpiOsPrintf (" Invalid performance robustness preference\n"); break; } @@ -337,7 +391,7 @@ AcpiRsDumpStartDependFns ( * ******************************************************************************/ -void +static void AcpiRsDumpIo ( ACPI_RESOURCE_DATA *Data) { @@ -350,19 +404,15 @@ AcpiRsDumpIo ( AcpiOsPrintf ("Io Resource\n"); AcpiOsPrintf (" %d bit decode\n", - ACPI_DECODE_16 == IoData->IoDecode ? 16 : 10); + ACPI_DECODE_16 == IoData->IoDecode ? 16 : 10); - AcpiOsPrintf (" Range minimum base: %08X\n", - IoData->MinBaseAddress); + AcpiOsPrintf (" Range minimum base: %08X\n", IoData->MinBaseAddress); - AcpiOsPrintf (" Range maximum base: %08X\n", - IoData->MaxBaseAddress); + AcpiOsPrintf (" Range maximum base: %08X\n", IoData->MaxBaseAddress); - AcpiOsPrintf (" Alignment: %08X\n", - IoData->Alignment); + AcpiOsPrintf (" Alignment: %08X\n", IoData->Alignment); - AcpiOsPrintf (" Range Length: %08X\n", - IoData->RangeLength); + AcpiOsPrintf (" Range Length: %08X\n", IoData->RangeLength); return; } @@ -380,7 +430,7 @@ AcpiRsDumpIo ( * ******************************************************************************/ -void +static void AcpiRsDumpFixedIo ( ACPI_RESOURCE_DATA *Data) { @@ -391,11 +441,9 @@ AcpiRsDumpFixedIo ( AcpiOsPrintf ("Fixed Io Resource\n"); - AcpiOsPrintf (" Range base address: %08X", - FixedIoData->BaseAddress); + AcpiOsPrintf (" Range base address: %08X", FixedIoData->BaseAddress); - AcpiOsPrintf (" Range length: %08X", - FixedIoData->RangeLength); + AcpiOsPrintf (" Range length: %08X", FixedIoData->RangeLength); return; } @@ -413,7 +461,7 @@ AcpiRsDumpFixedIo ( * ******************************************************************************/ -void +static void AcpiRsDumpVendorSpecific ( ACPI_RESOURCE_DATA *Data) { @@ -431,7 +479,7 @@ AcpiRsDumpVendorSpecific ( for (Index = 0; Index < VendorData->Length; Index++) { AcpiOsPrintf (" Byte %X: %08X\n", - Index, VendorData->Reserved[Index]); + Index, VendorData->Reserved[Index]); } return; @@ -450,7 +498,7 @@ AcpiRsDumpVendorSpecific ( * ******************************************************************************/ -void +static void AcpiRsDumpMemory24 ( ACPI_RESOURCE_DATA *Data) { @@ -463,21 +511,19 @@ AcpiRsDumpMemory24 ( AcpiOsPrintf ("24-Bit Memory Range Resource\n"); AcpiOsPrintf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - Memory24Data->ReadWriteAttribute ? - "/Write" : " only"); + ACPI_READ_WRITE_MEMORY == + Memory24Data->ReadWriteAttribute ? + "/Write" : " only"); AcpiOsPrintf (" Range minimum base: %08X\n", - Memory24Data->MinBaseAddress); + Memory24Data->MinBaseAddress); AcpiOsPrintf (" Range maximum base: %08X\n", - Memory24Data->MaxBaseAddress); + Memory24Data->MaxBaseAddress); - AcpiOsPrintf (" Alignment: %08X\n", - Memory24Data->Alignment); + AcpiOsPrintf (" Alignment: %08X\n", Memory24Data->Alignment); - AcpiOsPrintf (" Range length: %08X\n", - Memory24Data->RangeLength); + AcpiOsPrintf (" Range length: %08X\n", Memory24Data->RangeLength); return; } @@ -495,7 +541,7 @@ AcpiRsDumpMemory24 ( * ******************************************************************************/ -void +static void AcpiRsDumpMemory32 ( ACPI_RESOURCE_DATA *Data) { @@ -508,21 +554,19 @@ AcpiRsDumpMemory32 ( AcpiOsPrintf ("32-Bit Memory Range Resource\n"); AcpiOsPrintf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - Memory32Data->ReadWriteAttribute ? - "/Write" : " only"); + ACPI_READ_WRITE_MEMORY == + Memory32Data->ReadWriteAttribute ? + "/Write" : " only"); AcpiOsPrintf (" Range minimum base: %08X\n", - Memory32Data->MinBaseAddress); + Memory32Data->MinBaseAddress); AcpiOsPrintf (" Range maximum base: %08X\n", - Memory32Data->MaxBaseAddress); + Memory32Data->MaxBaseAddress); - AcpiOsPrintf (" Alignment: %08X\n", - Memory32Data->Alignment); + AcpiOsPrintf (" Alignment: %08X\n", Memory32Data->Alignment); - AcpiOsPrintf (" Range length: %08X\n", - Memory32Data->RangeLength); + AcpiOsPrintf (" Range length: %08X\n", Memory32Data->RangeLength); return; } @@ -540,11 +584,12 @@ AcpiRsDumpMemory32 ( * ******************************************************************************/ -void +static void AcpiRsDumpFixedMemory32 ( ACPI_RESOURCE_DATA *Data) { - ACPI_RESOURCE_FIXED_MEM32 *FixedMemory32Data = (ACPI_RESOURCE_FIXED_MEM32 *) Data; + ACPI_RESOURCE_FIXED_MEM32 *FixedMemory32Data = + (ACPI_RESOURCE_FIXED_MEM32 *) Data; ACPI_FUNCTION_ENTRY (); @@ -553,15 +598,14 @@ AcpiRsDumpFixedMemory32 ( AcpiOsPrintf ("32-Bit Fixed Location Memory Range Resource\n"); AcpiOsPrintf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - FixedMemory32Data->ReadWriteAttribute ? - "/Write" : " Only"); + ACPI_READ_WRITE_MEMORY == + FixedMemory32Data->ReadWriteAttribute ? "/Write" : " Only"); AcpiOsPrintf (" Range base address: %08X\n", - FixedMemory32Data->RangeBaseAddress); + FixedMemory32Data->RangeBaseAddress); AcpiOsPrintf (" Range length: %08X\n", - FixedMemory32Data->RangeLength); + FixedMemory32Data->RangeLength); return; } @@ -579,7 +623,7 @@ AcpiRsDumpFixedMemory32 ( * ******************************************************************************/ -void +static void AcpiRsDumpAddress16 ( ACPI_RESOURCE_DATA *Data) { @@ -601,35 +645,30 @@ AcpiRsDumpAddress16 ( switch (Address16Data->Attribute.Memory.CacheAttribute) { case ACPI_NON_CACHEABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Noncacheable memory\n"); + AcpiOsPrintf (" Type Specific: Noncacheable memory\n"); break; case ACPI_CACHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Cacheable memory\n"); + AcpiOsPrintf (" Type Specific: Cacheable memory\n"); break; case ACPI_WRITE_COMBINING_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Write-combining memory\n"); + AcpiOsPrintf (" Type Specific: Write-combining memory\n"); break; case ACPI_PREFETCHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Prefetchable memory\n"); + AcpiOsPrintf (" Type Specific: Prefetchable memory\n"); break; default: - AcpiOsPrintf (" Type Specific: " - "Invalid cache attribute\n"); + AcpiOsPrintf (" Type Specific: Invalid cache attribute\n"); break; } AcpiOsPrintf (" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == - Address16Data->Attribute.Memory.ReadWriteAttribute ? - "/Write" : " Only"); + Address16Data->Attribute.Memory.ReadWriteAttribute ? + "/Write" : " Only"); break; case ACPI_IO_RANGE: @@ -639,30 +678,26 @@ AcpiRsDumpAddress16 ( switch (Address16Data->Attribute.Io.RangeAttribute) { case ACPI_NON_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "Non-ISA Io Addresses\n"); + AcpiOsPrintf (" Type Specific: Non-ISA Io Addresses\n"); break; case ACPI_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "ISA Io Addresses\n"); + AcpiOsPrintf (" Type Specific: ISA Io Addresses\n"); break; case ACPI_ENTIRE_RANGE: - AcpiOsPrintf (" Type Specific: " - "ISA and non-ISA Io Addresses\n"); + AcpiOsPrintf (" Type Specific: ISA and non-ISA Io Addresses\n"); break; default: - AcpiOsPrintf (" Type Specific: " - "Invalid range attribute\n"); + AcpiOsPrintf (" Type Specific: Invalid range attribute\n"); break; } - AcpiOsPrintf (" Type Specific: %s Translation\n", + AcpiOsPrintf (" Type Specific: %s Translation\n", ACPI_SPARSE_TRANSLATION == - Address16Data->Attribute.Io.TranslationAttribute ? - "Sparse" : "Dense"); + Address16Data->Attribute.Io.TranslationAttribute ? + "Sparse" : "Dense"); break; case ACPI_BUS_NUMBER_RANGE: @@ -672,47 +707,48 @@ AcpiRsDumpAddress16 ( default: - AcpiOsPrintf ("Invalid resource type. Exiting.\n"); - return; + AcpiOsPrintf ("0x%2.2X\n", Address16Data->ResourceType); + break; } AcpiOsPrintf (" Resource %s\n", - ACPI_CONSUMER == Address16Data->ProducerConsumer ? + ACPI_CONSUMER == Address16Data->ProducerConsumer ? "Consumer" : "Producer"); AcpiOsPrintf (" %s decode\n", - ACPI_SUB_DECODE == Address16Data->Decode ? - "Subtractive" : "Positive"); + ACPI_SUB_DECODE == Address16Data->Decode ? + "Subtractive" : "Positive"); AcpiOsPrintf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address16Data->MinAddressFixed ? - "" : "not"); + ACPI_ADDRESS_FIXED == Address16Data->MinAddressFixed ? + "" : "not"); AcpiOsPrintf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address16Data->MaxAddressFixed ? - "" : "not"); + ACPI_ADDRESS_FIXED == Address16Data->MaxAddressFixed ? + "" : "not"); AcpiOsPrintf (" Granularity: %08X\n", - Address16Data->Granularity); + Address16Data->Granularity); AcpiOsPrintf (" Address range min: %08X\n", - Address16Data->MinAddressRange); + Address16Data->MinAddressRange); AcpiOsPrintf (" Address range max: %08X\n", - Address16Data->MaxAddressRange); + Address16Data->MaxAddressRange); AcpiOsPrintf (" Address translation offset: %08X\n", - Address16Data->AddressTranslationOffset); + Address16Data->AddressTranslationOffset); AcpiOsPrintf (" Address Length: %08X\n", - Address16Data->AddressLength); + Address16Data->AddressLength); if (0xFF != Address16Data->ResourceSource.Index) { AcpiOsPrintf (" Resource Source Index: %X\n", - Address16Data->ResourceSource.Index); + Address16Data->ResourceSource.Index); + AcpiOsPrintf (" Resource Source: %s\n", - Address16Data->ResourceSource.StringPtr); + Address16Data->ResourceSource.StringPtr); } return; @@ -731,7 +767,7 @@ AcpiRsDumpAddress16 ( * ******************************************************************************/ -void +static void AcpiRsDumpAddress32 ( ACPI_RESOURCE_DATA *Data) { @@ -752,35 +788,30 @@ AcpiRsDumpAddress32 ( switch (Address32Data->Attribute.Memory.CacheAttribute) { case ACPI_NON_CACHEABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Noncacheable memory\n"); + AcpiOsPrintf (" Type Specific: Noncacheable memory\n"); break; case ACPI_CACHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Cacheable memory\n"); + AcpiOsPrintf (" Type Specific: Cacheable memory\n"); break; case ACPI_WRITE_COMBINING_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Write-combining memory\n"); + AcpiOsPrintf (" Type Specific: Write-combining memory\n"); break; case ACPI_PREFETCHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Prefetchable memory\n"); + AcpiOsPrintf (" Type Specific: Prefetchable memory\n"); break; default: - AcpiOsPrintf (" Type Specific: " - "Invalid cache attribute\n"); + AcpiOsPrintf (" Type Specific: Invalid cache attribute\n"); break; } AcpiOsPrintf (" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == - Address32Data->Attribute.Memory.ReadWriteAttribute ? - "/Write" : " Only"); + Address32Data->Attribute.Memory.ReadWriteAttribute ? + "/Write" : " Only"); break; case ACPI_IO_RANGE: @@ -790,30 +821,26 @@ AcpiRsDumpAddress32 ( switch (Address32Data->Attribute.Io.RangeAttribute) { case ACPI_NON_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "Non-ISA Io Addresses\n"); + AcpiOsPrintf (" Type Specific: Non-ISA Io Addresses\n"); break; case ACPI_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "ISA Io Addresses\n"); + AcpiOsPrintf (" Type Specific: ISA Io Addresses\n"); break; case ACPI_ENTIRE_RANGE: - AcpiOsPrintf (" Type Specific: " - "ISA and non-ISA Io Addresses\n"); + AcpiOsPrintf (" Type Specific: ISA and non-ISA Io Addresses\n"); break; default: - AcpiOsPrintf (" Type Specific: " - "Invalid Range attribute"); + AcpiOsPrintf (" Type Specific: Invalid Range attribute"); break; } - AcpiOsPrintf (" Type Specific: %s Translation\n", + AcpiOsPrintf (" Type Specific: %s Translation\n", ACPI_SPARSE_TRANSLATION == - Address32Data->Attribute.Io.TranslationAttribute ? - "Sparse" : "Dense"); + Address32Data->Attribute.Io.TranslationAttribute ? + "Sparse" : "Dense"); break; case ACPI_BUS_NUMBER_RANGE: @@ -823,47 +850,49 @@ AcpiRsDumpAddress32 ( default: - AcpiOsPrintf (" Invalid Resource Type..exiting.\n"); - return; + AcpiOsPrintf (" Resource Type: 0x%2.2X\n", + Address32Data->ResourceType); + break; } AcpiOsPrintf (" Resource %s\n", - ACPI_CONSUMER == Address32Data->ProducerConsumer ? - "Consumer" : "Producer"); + ACPI_CONSUMER == Address32Data->ProducerConsumer ? + "Consumer" : "Producer"); AcpiOsPrintf (" %s decode\n", - ACPI_SUB_DECODE == Address32Data->Decode ? - "Subtractive" : "Positive"); + ACPI_SUB_DECODE == Address32Data->Decode ? + "Subtractive" : "Positive"); AcpiOsPrintf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address32Data->MinAddressFixed ? - "" : "not "); + ACPI_ADDRESS_FIXED == Address32Data->MinAddressFixed ? + "" : "not "); AcpiOsPrintf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address32Data->MaxAddressFixed ? - "" : "not "); + ACPI_ADDRESS_FIXED == Address32Data->MaxAddressFixed ? + "" : "not "); AcpiOsPrintf (" Granularity: %08X\n", - Address32Data->Granularity); + Address32Data->Granularity); AcpiOsPrintf (" Address range min: %08X\n", - Address32Data->MinAddressRange); + Address32Data->MinAddressRange); AcpiOsPrintf (" Address range max: %08X\n", - Address32Data->MaxAddressRange); + Address32Data->MaxAddressRange); AcpiOsPrintf (" Address translation offset: %08X\n", - Address32Data->AddressTranslationOffset); + Address32Data->AddressTranslationOffset); AcpiOsPrintf (" Address Length: %08X\n", - Address32Data->AddressLength); + Address32Data->AddressLength); if(0xFF != Address32Data->ResourceSource.Index) { AcpiOsPrintf (" Resource Source Index: %X\n", - Address32Data->ResourceSource.Index); + Address32Data->ResourceSource.Index); + AcpiOsPrintf (" Resource Source: %s\n", - Address32Data->ResourceSource.StringPtr); + Address32Data->ResourceSource.StringPtr); } return; @@ -882,7 +911,7 @@ AcpiRsDumpAddress32 ( * ******************************************************************************/ -void +static void AcpiRsDumpAddress64 ( ACPI_RESOURCE_DATA *Data) { @@ -903,35 +932,30 @@ AcpiRsDumpAddress64 ( switch (Address64Data->Attribute.Memory.CacheAttribute) { case ACPI_NON_CACHEABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Noncacheable memory\n"); + AcpiOsPrintf (" Type Specific: Noncacheable memory\n"); break; case ACPI_CACHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Cacheable memory\n"); + AcpiOsPrintf (" Type Specific: Cacheable memory\n"); break; case ACPI_WRITE_COMBINING_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Write-combining memory\n"); + AcpiOsPrintf (" Type Specific: Write-combining memory\n"); break; case ACPI_PREFETCHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Prefetchable memory\n"); + AcpiOsPrintf (" Type Specific: Prefetchable memory\n"); break; default: - AcpiOsPrintf (" Type Specific: " - "Invalid cache attribute\n"); + AcpiOsPrintf (" Type Specific: Invalid cache attribute\n"); break; } AcpiOsPrintf (" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == - Address64Data->Attribute.Memory.ReadWriteAttribute ? - "/Write" : " Only"); + Address64Data->Attribute.Memory.ReadWriteAttribute ? + "/Write" : " Only"); break; case ACPI_IO_RANGE: @@ -941,30 +965,26 @@ AcpiRsDumpAddress64 ( switch (Address64Data->Attribute.Io.RangeAttribute) { case ACPI_NON_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "Non-ISA Io Addresses\n"); + AcpiOsPrintf (" Type Specific: Non-ISA Io Addresses\n"); break; case ACPI_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "ISA Io Addresses\n"); + AcpiOsPrintf (" Type Specific: ISA Io Addresses\n"); break; case ACPI_ENTIRE_RANGE: - AcpiOsPrintf (" Type Specific: " - "ISA and non-ISA Io Addresses\n"); + AcpiOsPrintf (" Type Specific: ISA and non-ISA Io Addresses\n"); break; default: - AcpiOsPrintf (" Type Specific: " - "Invalid Range attribute"); + AcpiOsPrintf (" Type Specific: Invalid Range attribute"); break; } - AcpiOsPrintf (" Type Specific: %s Translation\n", + AcpiOsPrintf (" Type Specific: %s Translation\n", ACPI_SPARSE_TRANSLATION == - Address64Data->Attribute.Io.TranslationAttribute ? - "Sparse" : "Dense"); + Address64Data->Attribute.Io.TranslationAttribute ? + "Sparse" : "Dense"); break; case ACPI_BUS_NUMBER_RANGE: @@ -974,47 +994,52 @@ AcpiRsDumpAddress64 ( default: - AcpiOsPrintf (" Invalid Resource Type..exiting.\n"); - return; + AcpiOsPrintf (" Resource Type: 0x%2.2X\n", + Address64Data->ResourceType); + break; } AcpiOsPrintf (" Resource %s\n", - ACPI_CONSUMER == Address64Data->ProducerConsumer ? - "Consumer" : "Producer"); + ACPI_CONSUMER == Address64Data->ProducerConsumer ? + "Consumer" : "Producer"); AcpiOsPrintf (" %s decode\n", - ACPI_SUB_DECODE == Address64Data->Decode ? - "Subtractive" : "Positive"); + ACPI_SUB_DECODE == Address64Data->Decode ? + "Subtractive" : "Positive"); AcpiOsPrintf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address64Data->MinAddressFixed ? - "" : "not "); + ACPI_ADDRESS_FIXED == Address64Data->MinAddressFixed ? + "" : "not "); AcpiOsPrintf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address64Data->MaxAddressFixed ? - "" : "not "); + ACPI_ADDRESS_FIXED == Address64Data->MaxAddressFixed ? + "" : "not "); AcpiOsPrintf (" Granularity: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->Granularity)); + ACPI_FORMAT_UINT64 (Address64Data->Granularity)); AcpiOsPrintf (" Address range min: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->MinAddressRange)); + ACPI_FORMAT_UINT64 (Address64Data->MinAddressRange)); AcpiOsPrintf (" Address range max: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->MaxAddressRange)); + ACPI_FORMAT_UINT64 (Address64Data->MaxAddressRange)); AcpiOsPrintf (" Address translation offset: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->AddressTranslationOffset)); + ACPI_FORMAT_UINT64 (Address64Data->AddressTranslationOffset)); AcpiOsPrintf (" Address Length: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->AddressLength)); + ACPI_FORMAT_UINT64 (Address64Data->AddressLength)); - if(0xFF != Address64Data->ResourceSource.Index) + AcpiOsPrintf (" Type Specific Attributes: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Address64Data->TypeSpecificAttributes)); + + if (0xFF != Address64Data->ResourceSource.Index) { AcpiOsPrintf (" Resource Source Index: %X\n", - Address64Data->ResourceSource.Index); + Address64Data->ResourceSource.Index); + AcpiOsPrintf (" Resource Source: %s\n", - Address64Data->ResourceSource.StringPtr); + Address64Data->ResourceSource.StringPtr); } return; @@ -1033,7 +1058,7 @@ AcpiRsDumpAddress64 ( * ******************************************************************************/ -void +static void AcpiRsDumpExtendedIrq ( ACPI_RESOURCE_DATA *Data) { @@ -1047,23 +1072,22 @@ AcpiRsDumpExtendedIrq ( AcpiOsPrintf ("Extended IRQ Resource\n"); AcpiOsPrintf (" Resource %s\n", - ACPI_CONSUMER == ExtIrqData->ProducerConsumer ? - "Consumer" : "Producer"); + ACPI_CONSUMER == ExtIrqData->ProducerConsumer ? + "Consumer" : "Producer"); AcpiOsPrintf (" %s\n", - ACPI_LEVEL_SENSITIVE == ExtIrqData->EdgeLevel ? - "Level" : "Edge"); + ACPI_LEVEL_SENSITIVE == ExtIrqData->EdgeLevel ? + "Level" : "Edge"); AcpiOsPrintf (" Active %s\n", - ACPI_ACTIVE_LOW == ExtIrqData->ActiveHighLow ? - "low" : "high"); + ACPI_ACTIVE_LOW == ExtIrqData->ActiveHighLow ? + "low" : "high"); AcpiOsPrintf (" %s\n", - ACPI_SHARED == ExtIrqData->SharedExclusive ? - "Shared" : "Exclusive"); + ACPI_SHARED == ExtIrqData->SharedExclusive ? + "Shared" : "Exclusive"); - AcpiOsPrintf (" Interrupts : %X ( ", - ExtIrqData->NumberOfInterrupts); + AcpiOsPrintf (" Interrupts : %X ( ", ExtIrqData->NumberOfInterrupts); for (Index = 0; Index < ExtIrqData->NumberOfInterrupts; Index++) { @@ -1075,9 +1099,10 @@ AcpiRsDumpExtendedIrq ( if(0xFF != ExtIrqData->ResourceSource.Index) { AcpiOsPrintf (" Resource Source Index: %X", - ExtIrqData->ResourceSource.Index); + ExtIrqData->ResourceSource.Index); + AcpiOsPrintf (" Resource Source: %s", - ExtIrqData->ResourceSource.StringPtr); + ExtIrqData->ResourceSource.StringPtr); } return; @@ -1088,7 +1113,7 @@ AcpiRsDumpExtendedIrq ( * * FUNCTION: AcpiRsDumpResourceList * - * PARAMETERS: Data - pointer to the resource structure to dump. + * PARAMETERS: Resource - pointer to the resource structure to dump. * * RETURN: None * @@ -1195,7 +1220,7 @@ AcpiRsDumpResourceList ( * * FUNCTION: AcpiRsDumpIrqList * - * PARAMETERS: Data - pointer to the routing table to dump. + * PARAMETERS: RouteTable - pointer to the routing table to dump. * * RETURN: None * @@ -1225,20 +1250,17 @@ AcpiRsDumpIrqList ( AcpiOsPrintf ("PCI IRQ Routing Table structure %X.\n", Count++); AcpiOsPrintf (" Address: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (PrtElement->Address)); + ACPI_FORMAT_UINT64 (PrtElement->Address)); AcpiOsPrintf (" Pin: %X\n", PrtElement->Pin); AcpiOsPrintf (" Source: %s\n", PrtElement->Source); - AcpiOsPrintf (" SourceIndex: %X\n", - PrtElement->SourceIndex); + AcpiOsPrintf (" SourceIndex: %X\n", PrtElement->SourceIndex); Buffer += PrtElement->Length; - PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); - - if(0 == PrtElement->Length) + if (0 == PrtElement->Length) { Done = TRUE; } diff --git a/sys/dev/acpi/acpica/Subsystem/rsio.c b/sys/dev/acpi/acpica/Subsystem/rsio.c index 45e19f1e6e3..3407d3a4f3a 100644 --- a/sys/dev/acpi/acpica/Subsystem/rsio.c +++ b/sys/dev/acpi/acpica/Subsystem/rsio.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsio - IO and DMA resource descriptors - * xRevision: 25 $ + * xRevision: 28 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsio.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rsio.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __RSIO_C__ @@ -158,67 +158,60 @@ AcpiRsIoResource ( ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; UINT16 Temp16 = 0; UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IO); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_IO); ACPI_FUNCTION_TRACE ("RsIoResource"); - /* - * The number of bytes consumed are Constant - */ + /* The number of bytes consumed are Constant */ + *BytesConsumed = 8; OutputStruct->Id = ACPI_RSTYPE_IO; - /* - * Check Decode - */ + /* Check Decode */ + Buffer += 1; Temp8 = *Buffer; OutputStruct->Data.Io.IoDecode = Temp8 & 0x01; - /* - * Check MinBase Address - */ + /* Check MinBase Address */ + Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); OutputStruct->Data.Io.MinBaseAddress = Temp16; - /* - * Check MaxBase Address - */ + /* Check MaxBase Address */ + Buffer += 2; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); OutputStruct->Data.Io.MaxBaseAddress = Temp16; - /* - * Check Base alignment - */ + /* Check Base alignment */ + Buffer += 2; Temp8 = *Buffer; OutputStruct->Data.Io.Alignment = Temp8; - /* - * Check RangeLength - */ + /* Check RangeLength */ + Buffer += 1; Temp8 = *Buffer; OutputStruct->Data.Io.RangeLength = Temp8; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -256,43 +249,39 @@ AcpiRsFixedIoResource ( ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; UINT16 Temp16 = 0; UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_IO); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_FIXED_IO); ACPI_FUNCTION_TRACE ("RsFixedIoResource"); - /* - * The number of bytes consumed are Constant - */ + /* The number of bytes consumed are Constant */ + *BytesConsumed = 4; OutputStruct->Id = ACPI_RSTYPE_FIXED_IO; - /* - * Check Range Base Address - */ + /* Check Range Base Address */ + Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); OutputStruct->Data.FixedIo.BaseAddress = Temp16; - /* - * Check RangeLength - */ + /* Check RangeLength */ + Buffer += 2; Temp8 = *Buffer; OutputStruct->Data.FixedIo.RangeLength = Temp8; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -328,55 +317,48 @@ AcpiRsIoStream ( ACPI_FUNCTION_TRACE ("RsIoStream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x47; Buffer += 1; - /* - * Io Information Byte - */ + /* Io Information Byte */ + Temp8 = (UINT8) (LinkedList->Data.Io.IoDecode & 0x01); *Buffer = Temp8; Buffer += 1; - /* - * Set the Range minimum base address - */ + /* Set the Range minimum base address */ + Temp16 = (UINT16) LinkedList->Data.Io.MinBaseAddress; ACPI_MOVE_16_TO_16 (Buffer, &Temp16); Buffer += 2; - /* - * Set the Range maximum base address - */ + /* Set the Range maximum base address */ + Temp16 = (UINT16) LinkedList->Data.Io.MaxBaseAddress; ACPI_MOVE_16_TO_16 (Buffer, &Temp16); Buffer += 2; - /* - * Set the base alignment - */ + /* Set the base alignment */ + Temp8 = (UINT8) LinkedList->Data.Io.Alignment; *Buffer = Temp8; Buffer += 1; - /* - * Set the range length - */ + /* Set the range length */ + Temp8 = (UINT8) LinkedList->Data.Io.RangeLength; *Buffer = Temp8; Buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } @@ -412,32 +394,28 @@ AcpiRsFixedIoStream ( ACPI_FUNCTION_TRACE ("RsFixedIoStream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x4B; Buffer += 1; - /* - * Set the Range base address - */ + /* Set the Range base address */ + Temp16 = (UINT16) LinkedList->Data.FixedIo.BaseAddress; ACPI_MOVE_16_TO_16 (Buffer, &Temp16); Buffer += 2; - /* - * Set the range length - */ + /* Set the range length */ + Temp8 = (UINT8) LinkedList->Data.FixedIo.RangeLength; *Buffer = Temp8; Buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } @@ -476,21 +454,20 @@ AcpiRsDmaResource ( UINT8 Temp8 = 0; UINT8 Index; UINT8 i; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_DMA); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_DMA); ACPI_FUNCTION_TRACE ("RsDmaResource"); - /* - * The number of bytes consumed are Constant - */ + /* The number of bytes consumed are Constant */ + *BytesConsumed = 3; OutputStruct->Id = ACPI_RSTYPE_DMA; - /* - * Point to the 8-bits of Byte 1 - */ + /* Point to the 8-bits of Byte 1 */ + Buffer += 1; Temp8 = *Buffer; @@ -510,47 +487,41 @@ AcpiRsDmaResource ( OutputStruct->Data.Dma.NumberOfChannels = i; if (i > 0) { - /* - * Calculate the structure size based upon the number of interrupts - */ + /* Calculate the structure size based upon the number of interrupts */ + StructSize += ((ACPI_SIZE) i - 1) * 4; } - /* - * Point to Byte 2 - */ + /* Point to Byte 2 */ + Buffer += 1; Temp8 = *Buffer; - /* - * Check for transfer preference (Bits[1:0]) - */ + /* Check for transfer preference (Bits[1:0]) */ + OutputStruct->Data.Dma.Transfer = Temp8 & 0x03; if (0x03 == OutputStruct->Data.Dma.Transfer) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid DMA.Transfer preference (3)\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid DMA.Transfer preference (3)\n")); return_ACPI_STATUS (AE_BAD_DATA); } - /* - * Get bus master preference (Bit[2]) - */ + /* Get bus master preference (Bit[2]) */ + OutputStruct->Data.Dma.BusMaster = (Temp8 >> 2) & 0x01; - /* - * Get channel speed support (Bits[6:5]) - */ + /* Get channel speed support (Bits[6:5]) */ + OutputStruct->Data.Dma.Type = (Temp8 >> 5) & 0x03; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -587,16 +558,14 @@ AcpiRsDmaStream ( ACPI_FUNCTION_TRACE ("RsDmaStream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x2A; Buffer += 1; Temp8 = 0; - /* - * Loop through all of the Channels and set the mask bits - */ + /* Loop through all of the Channels and set the mask bits */ + for (Index = 0; Index < LinkedList->Data.Dma.NumberOfChannels; Index++) @@ -608,9 +577,8 @@ AcpiRsDmaStream ( *Buffer = Temp8; Buffer += 1; - /* - * Set the DMA Info - */ + /* Set the DMA Info */ + Temp8 = (UINT8) ((LinkedList->Data.Dma.Type & 0x03) << 5); Temp8 |= ((LinkedList->Data.Dma.BusMaster & 0x01) << 2); Temp8 |= (LinkedList->Data.Dma.Transfer & 0x03); @@ -618,9 +586,8 @@ AcpiRsDmaStream ( *Buffer = Temp8; Buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } diff --git a/sys/dev/acpi/acpica/Subsystem/rsirq.c b/sys/dev/acpi/acpica/Subsystem/rsirq.c index 2e245761927..53ffa79b1b9 100644 --- a/sys/dev/acpi/acpica/Subsystem/rsirq.c +++ b/sys/dev/acpi/acpica/Subsystem/rsirq.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsirq - IRQ resource descriptors - * xRevision: 38 $ + * xRevision: 42 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsirq.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rsirq.c,v 1.12 2005/05/02 14:52:10 kochi Exp $"); #define __RSIRQ_C__ @@ -160,7 +160,8 @@ AcpiRsIrqResource ( UINT8 Temp8 = 0; UINT8 Index; UINT8 i; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IRQ); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_IRQ); ACPI_FUNCTION_TRACE ("RsIrqResource"); @@ -168,15 +169,14 @@ AcpiRsIrqResource ( /* * The number of bytes consumed are contained in the descriptor - * (Bits:0-1) + * (Bits:0-1) */ Temp8 = *Buffer; *BytesConsumed = (Temp8 & 0x03) + 1; OutputStruct->Id = ACPI_RSTYPE_IRQ; - /* - * Point to the 16-bits of Bytes 1 and 2 - */ + /* Point to the 16-bits of Bytes 1 and 2 */ + Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); @@ -198,23 +198,20 @@ AcpiRsIrqResource ( OutputStruct->Data.Irq.NumberOfInterrupts = i; if (i > 0) { - /* - * Calculate the structure size based upon the number of interrupts - */ + /* Calculate the structure size based upon the number of interrupts */ + StructSize += ((ACPI_SIZE) i - 1) * 4; } - /* - * Point to Byte 3 if it is used - */ + /* Point to Byte 3 if it is used */ + if (4 == *BytesConsumed) { Buffer += 2; Temp8 = *Buffer; - /* - * Check for HE, LL interrupts - */ + /* Check for HE, LL interrupts */ + switch (Temp8 & 0x09) { case 0x01: /* HE */ @@ -234,13 +231,13 @@ AcpiRsIrqResource ( * so 0x00 and 0x09 are illegal. */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid interrupt polarity/trigger in resource list, %X\n", Temp8)); + "Invalid interrupt polarity/trigger in resource list, %X\n", + Temp8)); return_ACPI_STATUS (AE_BAD_DATA); } - /* - * Check for sharable - */ + /* Check for sharable */ + OutputStruct->Data.Irq.SharedExclusive = (Temp8 >> 3) & 0x01; } else @@ -254,14 +251,12 @@ AcpiRsIrqResource ( OutputStruct->Data.Irq.SharedExclusive = ACPI_EXCLUSIVE; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -319,9 +314,8 @@ AcpiRsIrqStream ( Buffer += 1; Temp16 = 0; - /* - * Loop through all of the interrupts and set the mask bits - */ + /* Loop through all of the interrupts and set the mask bits */ + for(Index = 0; Index < LinkedList->Data.Irq.NumberOfInterrupts; Index++) @@ -333,9 +327,8 @@ AcpiRsIrqStream ( ACPI_MOVE_16_TO_16 (Buffer, &Temp16); Buffer += 2; - /* - * Set the IRQ Info byte if needed. - */ + /* Set the IRQ Info byte if needed. */ + if (IRQInfoByteNeeded) { Temp8 = 0; @@ -356,9 +349,8 @@ AcpiRsIrqStream ( Buffer += 1; } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } @@ -398,15 +390,15 @@ AcpiRsExtendedIrqResource ( UINT8 Temp8 = 0; UINT8 *TempPtr; UINT8 Index; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_EXT_IRQ); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_EXT_IRQ); ACPI_FUNCTION_TRACE ("RsExtendedIrqResource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); @@ -420,9 +412,8 @@ AcpiRsExtendedIrqResource ( *BytesConsumed = Temp16 + 3; OutputStruct->Id = ACPI_RSTYPE_EXT_IRQ; - /* - * Point to the Byte3 - */ + /* Point to the Byte3 */ + Buffer += 2; Temp8 = *Buffer; @@ -437,21 +428,18 @@ AcpiRsExtendedIrqResource ( * - Edge/Level are defined opposite in the table vs the headers */ OutputStruct->Data.ExtendedIrq.EdgeLevel = - (Temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; + (Temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; + + /* Check Interrupt Polarity */ - /* - * Check Interrupt Polarity - */ OutputStruct->Data.ExtendedIrq.ActiveHighLow = (Temp8 >> 2) & 0x1; - /* - * Check for sharable - */ + /* Check for sharable */ + OutputStruct->Data.ExtendedIrq.SharedExclusive = (Temp8 >> 3) & 0x01; - /* - * Point to Byte4 (IRQ Table length) - */ + /* Point to Byte4 (IRQ Table length) */ + Buffer += 1; Temp8 = *Buffer; @@ -470,14 +458,12 @@ AcpiRsExtendedIrqResource ( */ StructSize += (Temp8 - 1) * 4; - /* - * Point to Byte5 (First IRQ Number) - */ + /* Point to Byte5 (First IRQ Number) */ + Buffer += 1; - /* - * Cycle through every IRQ in the table - */ + /* Cycle through every IRQ in the table */ + for (Index = 0; Index < Temp8; Index++) { ACPI_MOVE_32_TO_32 ( @@ -499,7 +485,8 @@ AcpiRsExtendedIrqResource ( * we add 1 to the length. */ if (*BytesConsumed > - ((ACPI_SIZE) OutputStruct->Data.ExtendedIrq.NumberOfInterrupts * 4) + (5 + 1)) + ((ACPI_SIZE) OutputStruct->Data.ExtendedIrq.NumberOfInterrupts * 4) + + (5 + 1)) { /* Dereference the Index */ @@ -510,13 +497,13 @@ AcpiRsExtendedIrqResource ( Buffer += 1; - /* - * Point the String pointer to the end of this structure. - */ + /* Point the String pointer to the end of this structure. */ + OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr = (char *)((char *) OutputStruct + StructSize); - TempPtr = (UINT8 *) OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr; + TempPtr = (UINT8 *) + OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr; /* Copy the string into the buffer */ @@ -530,9 +517,8 @@ AcpiRsExtendedIrqResource ( Index += 1; } - /* - * Add the terminating null - */ + /* Add the terminating null */ + *TempPtr = 0x00; OutputStruct->Data.ExtendedIrq.ResourceSource.StringLength = Index + 1; @@ -551,14 +537,12 @@ AcpiRsExtendedIrqResource ( OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr = NULL; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -596,21 +580,18 @@ AcpiRsExtendedIrqStream ( ACPI_FUNCTION_TRACE ("RsExtendedIrqStream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x89; Buffer += 1; - /* - * Set a pointer to the Length field - to be filled in later - */ + /* Set a pointer to the Length field - to be filled in later */ + LengthField = ACPI_CAST_PTR (UINT16, Buffer); Buffer += 2; - /* - * Set the Interrupt vector flags - */ + /* Set the Interrupt vector flags */ + Temp8 = (UINT8)(LinkedList->Data.ExtendedIrq.ProducerConsumer & 0x01); Temp8 |= ((LinkedList->Data.ExtendedIrq.SharedExclusive & 0x01) << 3); @@ -628,17 +609,15 @@ AcpiRsExtendedIrqStream ( Temp8 |= 0x2; } - /* - * Set the Interrupt Polarity - */ + /* Set the Interrupt Polarity */ + Temp8 |= ((LinkedList->Data.ExtendedIrq.ActiveHighLow & 0x1) << 2); *Buffer = Temp8; Buffer += 1; - /* - * Set the Interrupt table length - */ + /* Set the Interrupt table length */ + Temp8 = (UINT8) LinkedList->Data.ExtendedIrq.NumberOfInterrupts; *Buffer = Temp8; @@ -652,9 +631,8 @@ AcpiRsExtendedIrqStream ( Buffer += 4; } - /* - * Resource Source Index and Resource Source are optional - */ + /* Resource Source Index and Resource Source are optional */ + if (0 != LinkedList->Data.ExtendedIrq.ResourceSource.StringLength) { *Buffer = (UINT8) LinkedList->Data.ExtendedIrq.ResourceSource.Index; @@ -662,9 +640,8 @@ AcpiRsExtendedIrqStream ( TempPointer = (char *) Buffer; - /* - * Copy the string - */ + /* Copy the string */ + ACPI_STRCPY (TempPointer, LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr); @@ -672,12 +649,12 @@ AcpiRsExtendedIrqStream ( * Buffer needs to be set to the length of the sting + one for the * terminating null */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr) + 1); + Buffer += (ACPI_SIZE) (ACPI_STRLEN ( + LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr) + 1); } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); /* diff --git a/sys/dev/acpi/acpica/Subsystem/rslist.c b/sys/dev/acpi/acpica/Subsystem/rslist.c index adba10ed01a..58e5dc9b1e0 100644 --- a/sys/dev/acpi/acpica/Subsystem/rslist.c +++ b/sys/dev/acpi/acpica/Subsystem/rslist.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rslist - Linked list utilities - * xRevision: 34 $ + * xRevision: 39 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rslist.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rslist.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __RSLIST_C__ @@ -132,7 +132,7 @@ __KERNEL_RCSID(0, "$NetBSD: rslist.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * * PARAMETERS: ResourceStartByte - Byte 0 of a resource descriptor * - * RETURN: The Resource Type (Name) with no extraneous bits + * RETURN: The Resource Type with no extraneous bits * * DESCRIPTION: Extract the Resource Type/Name from the first byte of * a resource descriptor. @@ -147,29 +147,26 @@ AcpiRsGetResourceType ( ACPI_FUNCTION_ENTRY (); - /* - * Determine if this is a small or large resource - */ + /* Determine if this is a small or large resource */ + switch (ResourceStartByte & ACPI_RDESC_TYPE_MASK) { case ACPI_RDESC_TYPE_SMALL: - /* - * Small Resource Type -- Only bits 6:3 are valid - */ + /* Small Resource Type -- Only bits 6:3 are valid */ + return ((UINT8) (ResourceStartByte & ACPI_RDESC_SMALL_MASK)); case ACPI_RDESC_TYPE_LARGE: - /* - * Large Resource Type -- All bits are valid - */ + /* Large Resource Type -- All bits are valid */ + return (ResourceStartByte); default: - /* No other types of resource descriptor */ + /* Invalid type */ break; } @@ -214,9 +211,8 @@ AcpiRsByteStreamToList ( while (BytesParsed < ByteStreamBufferLength && !EndTagProcessed) { - /* - * The next byte in the stream is the resource type - */ + /* The next byte in the stream is the resource type */ + ResourceType = AcpiRsGetResourceType (*ByteStreamBuffer); switch (ResourceType) @@ -258,6 +254,7 @@ AcpiRsByteStreamToList ( case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: + case ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE: /* * 64-Bit Address Resource */ @@ -379,28 +376,23 @@ AcpiRsByteStreamToList ( return_ACPI_STATUS (Status); } - /* - * Update the return value and counter - */ + /* Update the return value and counter */ + BytesParsed += BytesConsumed; - /* - * Set the byte stream to point to the next resource - */ + /* Set the byte stream to point to the next resource */ + ByteStreamBuffer += BytesConsumed; - /* - * Set the Buffer to the next structure - */ + /* Set the Buffer to the next structure */ + Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer); Resource->Length = (UINT32) ACPI_ALIGN_RESOURCE_SIZE (Resource->Length); Buffer += ACPI_ALIGN_RESOURCE_SIZE (StructureSize); + } - } /* end while */ + /* Check the reason for exiting the while loop */ - /* - * Check the reason for exiting the while loop - */ if (!EndTagProcessed) { return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); @@ -507,9 +499,8 @@ AcpiRsListToByteStream ( */ Status = AcpiRsEndTagStream (LinkedList, &Buffer, &BytesConsumed); - /* - * An End Tag indicates the end of the Resource Template - */ + /* An End Tag indicates the end of the Resource Template */ + Done = TRUE; break; @@ -571,28 +562,26 @@ AcpiRsListToByteStream ( default: /* * If we get here, everything is out of sync, - * so exit with an error + * so exit with an error */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid descriptor type (%X) in resource list\n", LinkedList->Id)); Status = AE_BAD_DATA; break; - - } /* switch (LinkedList->Id) */ + } if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* - * Set the Buffer to point to the open byte - */ + /* Set the Buffer to point to the open byte */ + Buffer += BytesConsumed; - /* - * Point to the next object - */ + /* Point to the next object */ + LinkedList = ACPI_PTR_ADD (ACPI_RESOURCE, LinkedList, LinkedList->Length); } diff --git a/sys/dev/acpi/acpica/Subsystem/rsmemory.c b/sys/dev/acpi/acpica/Subsystem/rsmemory.c index 65740cbdc90..5e550ce47eb 100644 --- a/sys/dev/acpi/acpica/Subsystem/rsmemory.c +++ b/sys/dev/acpi/acpica/Subsystem/rsmemory.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsmem24 - Memory resource descriptors - * xRevision: 25 $ + * xRevision: 28 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsmemory.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rsmemory.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __RSMEMORY_C__ @@ -158,15 +158,15 @@ AcpiRsMemory24Resource ( ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; UINT16 Temp16 = 0; UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM24); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_MEM24); ACPI_FUNCTION_TRACE ("RsMemory24Resource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); @@ -174,48 +174,41 @@ AcpiRsMemory24Resource ( *BytesConsumed = (ACPI_SIZE) Temp16 + 3; OutputStruct->Id = ACPI_RSTYPE_MEM24; - /* - * Check Byte 3 the Read/Write bit - */ + /* Check Byte 3 the Read/Write bit */ + Temp8 = *Buffer; Buffer += 1; OutputStruct->Data.Memory24.ReadWriteAttribute = Temp8 & 0x01; - /* - * Get MinBaseAddress (Bytes 4-5) - */ + /* Get MinBaseAddress (Bytes 4-5) */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); Buffer += 2; OutputStruct->Data.Memory24.MinBaseAddress = Temp16; - /* - * Get MaxBaseAddress (Bytes 6-7) - */ + /* Get MaxBaseAddress (Bytes 6-7) */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); Buffer += 2; OutputStruct->Data.Memory24.MaxBaseAddress = Temp16; - /* - * Get Alignment (Bytes 8-9) - */ + /* Get Alignment (Bytes 8-9) */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); Buffer += 2; OutputStruct->Data.Memory24.Alignment = Temp16; - /* - * Get RangeLength (Bytes 10-11) - */ + /* Get RangeLength (Bytes 10-11) */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); OutputStruct->Data.Memory24.RangeLength = Temp16; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -251,53 +244,45 @@ AcpiRsMemory24Stream ( ACPI_FUNCTION_TRACE ("RsMemory24Stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x81; Buffer += 1; - /* - * The length field is static - */ + /* The length field is static */ + Temp16 = 0x09; ACPI_MOVE_16_TO_16 (Buffer, &Temp16); Buffer += 2; - /* - * Set the Information Byte - */ + /* Set the Information Byte */ + Temp8 = (UINT8) (LinkedList->Data.Memory24.ReadWriteAttribute & 0x01); *Buffer = Temp8; Buffer += 1; - /* - * Set the Range minimum base address - */ + /* Set the Range minimum base address */ + ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Memory24.MinBaseAddress); Buffer += 2; - /* - * Set the Range maximum base address - */ + /* Set the Range maximum base address */ + ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Memory24.MaxBaseAddress); Buffer += 2; - /* - * Set the base alignment - */ + /* Set the base alignment */ + ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Memory24.Alignment); Buffer += 2; - /* - * Set the range length - */ + /* Set the range length */ + ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Memory24.RangeLength); Buffer += 2; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } @@ -335,15 +320,15 @@ AcpiRsMemory32RangeResource ( ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; UINT16 Temp16 = 0; UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM32); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_MEM32); ACPI_FUNCTION_TRACE ("RsMemory32RangeResource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); @@ -362,45 +347,38 @@ AcpiRsMemory32RangeResource ( * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(UINT8) */ - /* - * Check Byte 3 the Read/Write bit - */ + /* Check Byte 3 the Read/Write bit */ + Temp8 = *Buffer; Buffer += 1; OutputStruct->Data.Memory32.ReadWriteAttribute = Temp8 & 0x01; - /* - * Get MinBaseAddress (Bytes 4-7) - */ + /* Get MinBaseAddress (Bytes 4-7) */ + ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Memory32.MinBaseAddress, Buffer); Buffer += 4; - /* - * Get MaxBaseAddress (Bytes 8-11) - */ + /* Get MaxBaseAddress (Bytes 8-11) */ + ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Memory32.MaxBaseAddress, Buffer); Buffer += 4; - /* - * Get Alignment (Bytes 12-15) - */ + /* Get Alignment (Bytes 12-15) */ + ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Memory32.Alignment, Buffer); Buffer += 4; - /* - * Get RangeLength (Bytes 16-19) - */ + /* Get RangeLength (Bytes 16-19) */ + ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Memory32.RangeLength, Buffer); - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -438,15 +416,15 @@ AcpiRsFixedMemory32Resource ( ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; UINT16 Temp16 = 0; UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_MEM32); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_FIXED_MEM32); ACPI_FUNCTION_TRACE ("RsFixedMemory32Resource"); - /* - * Point past the Descriptor to get the number of bytes consumed - */ + /* Point past the Descriptor to get the number of bytes consumed */ + Buffer += 1; ACPI_MOVE_16_TO_16 (&Temp16, Buffer); @@ -455,32 +433,28 @@ AcpiRsFixedMemory32Resource ( OutputStruct->Id = ACPI_RSTYPE_FIXED_MEM32; - /* - * Check Byte 3 the Read/Write bit - */ + /* Check Byte 3 the Read/Write bit */ + Temp8 = *Buffer; Buffer += 1; OutputStruct->Data.FixedMemory32.ReadWriteAttribute = Temp8 & 0x01; - /* - * Get RangeBaseAddress (Bytes 4-7) - */ - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeBaseAddress, Buffer); + /* Get RangeBaseAddress (Bytes 4-7) */ + + ACPI_MOVE_32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeBaseAddress, + Buffer); Buffer += 4; - /* - * Get RangeLength (Bytes 8-11) - */ + /* Get RangeLength (Bytes 8-11) */ + ACPI_MOVE_32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeLength, Buffer); - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -516,54 +490,46 @@ AcpiRsMemory32RangeStream ( ACPI_FUNCTION_TRACE ("RsMemory32RangeStream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x85; Buffer += 1; - /* - * The length field is static - */ + /* The length field is static */ + Temp16 = 0x11; ACPI_MOVE_16_TO_16 (Buffer, &Temp16); Buffer += 2; - /* - * Set the Information Byte - */ + /* Set the Information Byte */ + Temp8 = (UINT8) (LinkedList->Data.Memory32.ReadWriteAttribute & 0x01); *Buffer = Temp8; Buffer += 1; - /* - * Set the Range minimum base address - */ + /* Set the Range minimum base address */ + ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Memory32.MinBaseAddress); Buffer += 4; - /* - * Set the Range maximum base address - */ + /* Set the Range maximum base address */ + ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Memory32.MaxBaseAddress); Buffer += 4; - /* - * Set the base alignment - */ + /* Set the base alignment */ + ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Memory32.Alignment); Buffer += 4; - /* - * Set the range length - */ + /* Set the range length */ + ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Memory32.RangeLength); Buffer += 4; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } @@ -599,44 +565,38 @@ AcpiRsFixedMemory32Stream ( ACPI_FUNCTION_TRACE ("RsFixedMemory32Stream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x86; Buffer += 1; - /* - * The length field is static - */ + /* The length field is static */ + Temp16 = 0x09; ACPI_MOVE_16_TO_16 (Buffer, &Temp16); Buffer += 2; - /* - * Set the Information Byte - */ + /* Set the Information Byte */ + Temp8 = (UINT8) (LinkedList->Data.FixedMemory32.ReadWriteAttribute & 0x01); *Buffer = Temp8; Buffer += 1; - /* - * Set the Range base address - */ + /* Set the Range base address */ + ACPI_MOVE_32_TO_32 (Buffer, - &LinkedList->Data.FixedMemory32.RangeBaseAddress); + &LinkedList->Data.FixedMemory32.RangeBaseAddress); Buffer += 4; - /* - * Set the range length - */ + /* Set the range length */ + ACPI_MOVE_32_TO_32 (Buffer, - &LinkedList->Data.FixedMemory32.RangeLength); + &LinkedList->Data.FixedMemory32.RangeLength); Buffer += 4; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } diff --git a/sys/dev/acpi/acpica/Subsystem/rsmisc.c b/sys/dev/acpi/acpica/Subsystem/rsmisc.c index 89d7511ab65..5a24a747adf 100644 --- a/sys/dev/acpi/acpica/Subsystem/rsmisc.c +++ b/sys/dev/acpi/acpica/Subsystem/rsmisc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsmisc - Miscellaneous resource descriptors - * xRevision: 27 $ + * xRevision: 29 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsmisc.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rsmisc.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __RSMISC_C__ @@ -161,24 +161,20 @@ AcpiRsEndTagResource ( ACPI_FUNCTION_TRACE ("RsEndTagResource"); - /* - * The number of bytes consumed is static - */ + /* The number of bytes consumed is static */ + *BytesConsumed = 2; - /* - * Fill out the structure - */ + /* Fill out the structure */ + OutputStruct->Id = ACPI_RSTYPE_END_TAG; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = 0; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -213,9 +209,8 @@ AcpiRsEndTagStream ( ACPI_FUNCTION_TRACE ("RsEndTagStream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x79; Buffer += 1; @@ -228,9 +223,8 @@ AcpiRsEndTagStream ( *Buffer = Temp8; Buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } @@ -269,22 +263,21 @@ AcpiRsVendorResource ( UINT16 Temp16 = 0; UINT8 Temp8 = 0; UINT8 Index; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_VENDOR); ACPI_FUNCTION_TRACE ("RsVendorResource"); - /* - * Dereference the Descriptor to find if this is a large or small item. - */ + /* Dereference the Descriptor to find if this is a large or small item. */ + Temp8 = *Buffer; if (Temp8 & 0x80) { - /* - * Large Item, point to the length field - */ + /* Large Item, point to the length field */ + Buffer += 1; /* Dereference */ @@ -301,9 +294,8 @@ AcpiRsVendorResource ( } else { - /* - * Small Item, dereference the size - */ + /* Small Item, dereference the size */ + Temp16 = (UINT8)(*Buffer & 0x07); /* Calculate bytes consumed */ @@ -331,14 +323,12 @@ AcpiRsVendorResource ( */ StructSize += ACPI_ROUND_UP_TO_32BITS (Temp16); - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -375,14 +365,12 @@ AcpiRsVendorStream ( ACPI_FUNCTION_TRACE ("RsVendorStream"); - /* - * Dereference the length to find if this is a large or small item. - */ + /* Dereference the length to find if this is a large or small item. */ + if(LinkedList->Data.VendorSpecific.Length > 7) { - /* - * Large Item, Set the descriptor field and length bytes - */ + /* Large Item, Set the descriptor field and length bytes */ + *Buffer = 0x84; Buffer += 1; @@ -393,9 +381,8 @@ AcpiRsVendorStream ( } else { - /* - * Small Item, Set the descriptor field - */ + /* Small Item, Set the descriptor field */ + Temp8 = 0x70; Temp8 |= (UINT8) LinkedList->Data.VendorSpecific.Length; @@ -403,9 +390,8 @@ AcpiRsVendorStream ( Buffer += 1; } - /* - * Loop through all of the Vendor Specific fields - */ + /* Loop through all of the Vendor Specific fields */ + for (Index = 0; Index < LinkedList->Data.VendorSpecific.Length; Index++) { Temp8 = LinkedList->Data.VendorSpecific.Reserved[Index]; @@ -414,9 +400,8 @@ AcpiRsVendorStream ( Buffer += 1; } - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } @@ -453,32 +438,30 @@ AcpiRsStartDependFnsResource ( UINT8 *Buffer = ByteStreamBuffer; ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_START_DPF); + ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE ( + ACPI_RESOURCE_START_DPF); ACPI_FUNCTION_TRACE ("RsStartDependFnsResource"); - /* - * The number of bytes consumed are contained in the descriptor (Bits:0-1) - */ + /* The number of bytes consumed are found in the descriptor (Bits:0-1) */ + Temp8 = *Buffer; *BytesConsumed = (Temp8 & 0x01) + 1; OutputStruct->Id = ACPI_RSTYPE_START_DPF; - /* - * Point to Byte 1 if it is used - */ + /* Point to Byte 1 if it is used */ + if (2 == *BytesConsumed) { Buffer += 1; Temp8 = *Buffer; - /* - * Check Compatibility priority - */ + /* Check Compatibility priority */ + OutputStruct->Data.StartDpf.CompatibilityPriority = Temp8 & 0x03; if (3 == OutputStruct->Data.StartDpf.CompatibilityPriority) @@ -486,9 +469,8 @@ AcpiRsStartDependFnsResource ( return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); } - /* - * Check Performance/Robustness preference - */ + /* Check Performance/Robustness preference */ + OutputStruct->Data.StartDpf.PerformanceRobustness = (Temp8 >> 2) & 0x03; if (3 == OutputStruct->Data.StartDpf.PerformanceRobustness) @@ -499,20 +481,18 @@ AcpiRsStartDependFnsResource ( else { OutputStruct->Data.StartDpf.CompatibilityPriority = - ACPI_ACCEPTABLE_CONFIGURATION; + ACPI_ACCEPTABLE_CONFIGURATION; OutputStruct->Data.StartDpf.PerformanceRobustness = - ACPI_ACCEPTABLE_CONFIGURATION; + ACPI_ACCEPTABLE_CONFIGURATION; } - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -553,24 +533,20 @@ AcpiRsEndDependFnsResource ( ACPI_FUNCTION_TRACE ("RsEndDependFnsResource"); - /* - * The number of bytes consumed is static - */ + /* The number of bytes consumed is static */ + *BytesConsumed = 1; - /* - * Fill out the structure - */ + /* Fill out the structure */ + OutputStruct->Id = ACPI_RSTYPE_END_DPF; - /* - * Set the Length parameter - */ + /* Set the Length parameter */ + OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ + /* Return the final size of the structure */ + *StructureSize = StructSize; return_ACPI_STATUS (AE_OK); } @@ -622,9 +598,8 @@ AcpiRsStartDependFnsStream ( *Buffer = 0x31; Buffer += 1; - /* - * Set the Priority Byte Definition - */ + /* Set the Priority Byte Definition */ + Temp8 = 0; Temp8 = (UINT8) ((LinkedList->Data.StartDpf.PerformanceRobustness & 0x03) << 2); @@ -635,9 +610,8 @@ AcpiRsStartDependFnsStream ( Buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } @@ -671,15 +645,13 @@ AcpiRsEndDependFnsStream ( ACPI_FUNCTION_TRACE ("RsEndDependFnsStream"); - /* - * The descriptor field is static - */ + /* The descriptor field is static */ + *Buffer = 0x38; Buffer += 1; - /* - * Return the number of bytes consumed in this operation - */ + /* Return the number of bytes consumed in this operation */ + *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); return_ACPI_STATUS (AE_OK); } diff --git a/sys/dev/acpi/acpica/Subsystem/rsutils.c b/sys/dev/acpi/acpica/Subsystem/rsutils.c index 0ef424a2dd5..d0c05d7416f 100644 --- a/sys/dev/acpi/acpica/Subsystem/rsutils.c +++ b/sys/dev/acpi/acpica/Subsystem/rsutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsutils - Utilities for the resource manager - * xRevision: 38 $ + * xRevision: 45 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsutils.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rsutils.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __RSUTILS_C__ @@ -161,10 +161,10 @@ AcpiRsGetPrtMethodData ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ - Status = AcpiUtEvaluateObject (Handle, "_PRT", ACPI_BTYPE_PACKAGE, &ObjDesc); + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__PRT, + ACPI_BTYPE_PACKAGE, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -215,10 +215,10 @@ AcpiRsGetCrsMethodData ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ - Status = AcpiUtEvaluateObject (Handle, "_CRS", ACPI_BTYPE_BUFFER, &ObjDesc); + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__CRS, + ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -270,10 +270,10 @@ AcpiRsGetPrsMethodData ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ - Status = AcpiUtEvaluateObject (Handle, "_PRS", ACPI_BTYPE_BUFFER, &ObjDesc); + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__PRS, + ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -298,6 +298,7 @@ AcpiRsGetPrsMethodData ( * FUNCTION: AcpiRsGetMethodData * * PARAMETERS: Handle - a handle to the containing object + * Path - Path to method, relative to Handle * RetBuffer - a pointer to a buffer structure for the * results * @@ -326,9 +327,8 @@ AcpiRsGetMethodData ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ + /* Execute the method, no parameters */ + Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -370,6 +370,7 @@ AcpiRsSetSrsMethodData ( ACPI_HANDLE Handle, ACPI_BUFFER *InBuffer) { + ACPI_PARAMETER_INFO Info; ACPI_OPERAND_OBJECT *Params[2]; ACPI_STATUS Status; ACPI_BUFFER Buffer; @@ -394,9 +395,8 @@ AcpiRsSetSrsMethodData ( return_ACPI_STATUS (Status); } - /* - * Init the param object - */ + /* Init the param object */ + Params[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); if (!Params[0]) { @@ -404,22 +404,32 @@ AcpiRsSetSrsMethodData ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * Set up the parameter object - */ + /* Set up the parameter object */ + Params[0]->Buffer.Length = (UINT32) Buffer.Length; Params[0]->Buffer.Pointer = Buffer.Pointer; Params[0]->Common.Flags = AOPOBJ_DATA_VALID; Params[1] = NULL; - /* - * Execute the method, no return value - */ - Status = AcpiNsEvaluateRelative (Handle, "_SRS", Params, NULL); + Info.Node = Handle; + Info.Parameters = Params; + Info.ParameterType = ACPI_PARAM_ARGS; + + /* Execute the method, no return value */ + + Status = AcpiNsEvaluateRelative (METHOD_NAME__SRS, &Info); + if (ACPI_SUCCESS (Status)) + { + /* Delete any return object (especially if ImplicitReturn is enabled) */ + + if (Info.ReturnObject) + { + AcpiUtRemoveReference (Info.ReturnObject); + } + } + + /* Clean up and return the status from AcpiNsEvaluateRelative */ - /* - * Clean up and return the status from AcpiNsEvaluateRelative - */ AcpiUtRemoveReference (Params[0]); return_ACPI_STATUS (Status); } diff --git a/sys/dev/acpi/acpica/Subsystem/rsxface.c b/sys/dev/acpi/acpica/Subsystem/rsxface.c index d0c0facb032..34a365e1b9a 100644 --- a/sys/dev/acpi/acpica/Subsystem/rsxface.c +++ b/sys/dev/acpi/acpica/Subsystem/rsxface.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsxface - Public interfaces to the resource manager - * xRevision: 28 $ + * xRevision: 33 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rsxface.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rsxface.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __RSXFACE_C__ @@ -126,6 +126,23 @@ __KERNEL_RCSID(0, "$NetBSD: rsxface.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsxface") +/* Local macros for 16,32-bit to 64-bit conversion */ + +#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) +#define ACPI_COPY_ADDRESS(Out, In) \ + ACPI_COPY_FIELD(Out, In, ResourceType); \ + ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ + ACPI_COPY_FIELD(Out, In, Decode); \ + ACPI_COPY_FIELD(Out, In, MinAddressFixed); \ + ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \ + ACPI_COPY_FIELD(Out, In, Attribute); \ + ACPI_COPY_FIELD(Out, In, Granularity); \ + ACPI_COPY_FIELD(Out, In, MinAddressRange); \ + ACPI_COPY_FIELD(Out, In, MaxAddressRange); \ + ACPI_COPY_FIELD(Out, In, AddressTranslationOffset); \ + ACPI_COPY_FIELD(Out, In, AddressLength); \ + ACPI_COPY_FIELD(Out, In, ResourceSource); + /******************************************************************************* * @@ -323,6 +340,7 @@ AcpiWalkResources ( ACPI_STATUS Status; ACPI_BUFFER Buffer = {ACPI_ALLOCATE_BUFFER, NULL}; ACPI_RESOURCE *Resource; + ACPI_RESOURCE *BufferEnd; ACPI_FUNCTION_TRACE ("AcpiWalkResources"); @@ -341,7 +359,14 @@ AcpiWalkResources ( return_ACPI_STATUS (Status); } - Resource = (ACPI_RESOURCE *) Buffer.Pointer; + /* Setup pointers */ + + Resource = (ACPI_RESOURCE *) Buffer.Pointer; + BufferEnd = ACPI_CAST_PTR (ACPI_RESOURCE, + ((UINT8 *) Buffer.Pointer + Buffer.Length)); + + /* Walk the resource list */ + for (;;) { if (!Resource || Resource->Id == ACPI_RSTYPE_END_TAG) @@ -357,6 +382,7 @@ AcpiWalkResources ( case AE_CTRL_DEPTH: /* Just keep going */ + Status = AE_OK; break; @@ -374,7 +400,16 @@ AcpiWalkResources ( goto Cleanup; } + /* Get the next resource descriptor */ + Resource = ACPI_NEXT_RESOURCE (Resource); + + /* Check for end-of-buffer */ + + if (Resource >= BufferEnd) + { + goto Cleanup; + } } Cleanup: @@ -413,9 +448,8 @@ AcpiSetCurrentResources ( ACPI_FUNCTION_TRACE ("AcpiSetCurrentResources"); - /* - * Must have a valid handle and buffer - */ + /* Must have a valid handle and buffer */ + if ((!DeviceHandle) || (!InBuffer) || (!InBuffer->Pointer) || @@ -429,21 +463,6 @@ AcpiSetCurrentResources ( } -#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) -#define ACPI_COPY_ADDRESS(Out, In) \ - ACPI_COPY_FIELD(Out, In, ResourceType); \ - ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ - ACPI_COPY_FIELD(Out, In, Decode); \ - ACPI_COPY_FIELD(Out, In, MinAddressFixed); \ - ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \ - ACPI_COPY_FIELD(Out, In, Attribute); \ - ACPI_COPY_FIELD(Out, In, Granularity); \ - ACPI_COPY_FIELD(Out, In, MinAddressRange); \ - ACPI_COPY_FIELD(Out, In, MaxAddressRange); \ - ACPI_COPY_FIELD(Out, In, AddressTranslationOffset); \ - ACPI_COPY_FIELD(Out, In, AddressLength); \ - ACPI_COPY_FIELD(Out, In, ResourceSource); - /****************************************************************************** * * FUNCTION: AcpiResourceToAddress64 @@ -475,14 +494,14 @@ AcpiResourceToAddress64 ( case ACPI_RSTYPE_ADDRESS16: Address16 = (ACPI_RESOURCE_ADDRESS16 *) &Resource->Data; - ACPI_COPY_ADDRESS(Out, Address16); + ACPI_COPY_ADDRESS (Out, Address16); break; case ACPI_RSTYPE_ADDRESS32: Address32 = (ACPI_RESOURCE_ADDRESS32 *) &Resource->Data; - ACPI_COPY_ADDRESS(Out, Address32); + ACPI_COPY_ADDRESS (Out, Address32); break; diff --git a/sys/dev/acpi/acpica/Subsystem/tbconvrt.c b/sys/dev/acpi/acpica/Subsystem/tbconvrt.c index 5afbe35af8d..1074e8769df 100644 --- a/sys/dev/acpi/acpica/Subsystem/tbconvrt.c +++ b/sys/dev/acpi/acpica/Subsystem/tbconvrt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbconvrt - ACPI Table conversion utilities - * xRevision: 56 $ + * xRevision: 63 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbconvrt.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tbconvrt.c,v 1.12 2005/05/02 14:52:10 kochi Exp $"); #define __TBCONVRT_C__ @@ -126,6 +126,24 @@ __KERNEL_RCSID(0, "$NetBSD: tbconvrt.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbconvrt") +/* Local prototypes */ + +static void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *NewGasStruct, + UINT8 RegisterBitWidth, + ACPI_PHYSICAL_ADDRESS Address); + +static void +AcpiTbConvertFadt1 ( + FADT_DESCRIPTOR_REV2 *LocalFadt, + FADT_DESCRIPTOR_REV1 *OriginalFadt); + +static void +AcpiTbConvertFadt2 ( + FADT_DESCRIPTOR_REV2 *LocalFadt, + FADT_DESCRIPTOR_REV2 *OriginalFadt); + /******************************************************************************* * @@ -220,12 +238,14 @@ AcpiTbConvertToXsdt ( if (AcpiGbl_RSDP->Revision < 2) { ACPI_STORE_ADDRESS (NewTable->TableOffsetEntry[i], - (ACPI_CAST_PTR (RSDT_DESCRIPTOR_REV1, TableInfo->Pointer))->TableOffsetEntry[i]); + (ACPI_CAST_PTR (RSDT_DESCRIPTOR_REV1, + TableInfo->Pointer))->TableOffsetEntry[i]); } else { NewTable->TableOffsetEntry[i] = - (ACPI_CAST_PTR (XSDT_DESCRIPTOR, TableInfo->Pointer))->TableOffsetEntry[i]; + (ACPI_CAST_PTR (XSDT_DESCRIPTOR, + TableInfo->Pointer))->TableOffsetEntry[i]; } } @@ -243,7 +263,7 @@ AcpiTbConvertToXsdt ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiTbInitGenericAddress * @@ -269,7 +289,7 @@ AcpiTbInitGenericAddress ( NewGasStruct->AddressSpaceId = ACPI_ADR_SPACE_SYSTEM_IO; NewGasStruct->RegisterBitWidth = RegisterBitWidth; NewGasStruct->RegisterBitOffset = 0; - NewGasStruct->Reserved = 0; + NewGasStruct->AccessWidth = 0; } @@ -280,7 +300,7 @@ AcpiTbInitGenericAddress ( * PARAMETERS: LocalFadt - Pointer to new FADT * OriginalFadt - Pointer to old FADT * - * RETURN: Populates LocalFadt + * RETURN: None, populates LocalFadt * * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format * @@ -292,7 +312,6 @@ AcpiTbConvertFadt1 ( FADT_DESCRIPTOR_REV1 *OriginalFadt) { - /* ACPI 1.0 FACS */ /* The BIOS stored FADT should agree with Revision 1.0 */ @@ -310,7 +329,8 @@ AcpiTbConvertFadt1 ( ACPI_STORE_ADDRESS (LocalFadt->XDsdt, LocalFadt->V1_Dsdt); /* - * System Interrupt Model isn't used in ACPI 2.0 (LocalFadt->Reserved1 = 0;) + * System Interrupt Model isn't used in ACPI 2.0 + * (LocalFadt->Reserved1 = 0;) */ /* @@ -334,10 +354,29 @@ AcpiTbConvertFadt1 ( LocalFadt->CstCnt = 0; /* - * Since there isn't any equivalence in 1.0 and since it highly likely - * that a 1.0 system has legacy support. + * FADT Rev 2 was an interim FADT released between ACPI 1.0 and ACPI 2.0. + * It primarily adds the FADT reset mechanism. */ - LocalFadt->IapcBootArch = BAF_LEGACY_DEVICES; + if ((OriginalFadt->Revision == 2) && + (OriginalFadt->Length == sizeof (FADT_DESCRIPTOR_REV2_MINUS))) + { + /* + * Grab the entire generic address struct, plus the 1-byte reset value + * that immediately follows. + */ + ACPI_MEMCPY (&LocalFadt->ResetRegister, + &(ACPI_CAST_PTR (FADT_DESCRIPTOR_REV2_MINUS, + OriginalFadt))->ResetRegister, + sizeof (ACPI_GENERIC_ADDRESS) + 1); + } + else + { + /* + * Since there isn't any equivalence in 1.0 and since it is highly + * likely that a 1.0 system has legacy support. + */ + LocalFadt->IapcBootArch = BAF_LEGACY_DEVICES; + } /* * Convert the V1.0 block addresses to V2.0 GAS structures @@ -363,7 +402,8 @@ AcpiTbConvertFadt1 ( AcpiTbInitGenericAddress (&AcpiGbl_XPm1aEnable, (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + + (ACPI_PHYSICAL_ADDRESS) + (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); /* PM1B is optional; leave null if not present */ @@ -372,7 +412,8 @@ AcpiTbConvertFadt1 ( { AcpiTbInitGenericAddress (&AcpiGbl_XPm1bEnable, (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + + (ACPI_PHYSICAL_ADDRESS) + (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); } } @@ -385,7 +426,7 @@ AcpiTbConvertFadt1 ( * PARAMETERS: LocalFadt - Pointer to new FADT * OriginalFadt - Pointer to old FADT * - * RETURN: Populates LocalFadt + * RETURN: None, populates LocalFadt * * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format. * Handles optional "X" fields. @@ -409,7 +450,8 @@ AcpiTbConvertFadt2 ( */ if (!(ACPI_GET_ADDRESS (LocalFadt->XFirmwareCtrl))) { - ACPI_STORE_ADDRESS (LocalFadt->XFirmwareCtrl, LocalFadt->V1_FirmwareCtrl); + ACPI_STORE_ADDRESS (LocalFadt->XFirmwareCtrl, + LocalFadt->V1_FirmwareCtrl); } if (!(ACPI_GET_ADDRESS (LocalFadt->XDsdt))) @@ -420,37 +462,43 @@ AcpiTbConvertFadt2 ( if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm1aEvtBlk, - LocalFadt->Pm1EvtLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aEvtBlk); + LocalFadt->Pm1EvtLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aEvtBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm1bEvtBlk, - LocalFadt->Pm1EvtLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bEvtBlk); + LocalFadt->Pm1EvtLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bEvtBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1aCntBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm1aCntBlk, - LocalFadt->Pm1CntLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aCntBlk); + LocalFadt->Pm1CntLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aCntBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1bCntBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm1bCntBlk, - LocalFadt->Pm1CntLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bCntBlk); + LocalFadt->Pm1CntLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bCntBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm2CntBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm2CntBlk, - LocalFadt->Pm2CntLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm2CntBlk); + LocalFadt->Pm2CntLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm2CntBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPmTmrBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPmTmrBlk, - LocalFadt->PmTmLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_PmTmrBlk); + LocalFadt->PmTmLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_PmTmrBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XGpe0Blk.Address))) @@ -469,9 +517,12 @@ AcpiTbConvertFadt2 ( AcpiTbInitGenericAddress (&AcpiGbl_XPm1aEnable, (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + + (ACPI_PHYSICAL_ADDRESS) + (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); - AcpiGbl_XPm1aEnable.AddressSpaceId = LocalFadt->XPm1aEvtBlk.AddressSpaceId; + + AcpiGbl_XPm1aEnable.AddressSpaceId = + LocalFadt->XPm1aEvtBlk.AddressSpaceId; /* PM1B is optional; leave null if not present */ @@ -479,9 +530,12 @@ AcpiTbConvertFadt2 ( { AcpiTbInitGenericAddress (&AcpiGbl_XPm1bEnable, (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + + (ACPI_PHYSICAL_ADDRESS) + (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); - AcpiGbl_XPm1bEnable.AddressSpaceId = LocalFadt->XPm1bEvtBlk.AddressSpaceId; + + AcpiGbl_XPm1bEnable.AddressSpaceId = + LocalFadt->XPm1bEvtBlk.AddressSpaceId; } } @@ -503,7 +557,8 @@ AcpiTbConvertFadt2 ( ******************************************************************************/ ACPI_STATUS -AcpiTbConvertTableFadt (void) +AcpiTbConvertTableFadt ( + void) { FADT_DESCRIPTOR_REV2 *LocalFadt; ACPI_TABLE_DESC *TableDesc; @@ -513,23 +568,22 @@ AcpiTbConvertTableFadt (void) /* - * AcpiGbl_FADT is valid - * Allocate and zero the 2.0 FADT buffer + * AcpiGbl_FADT is valid. Validate the FADT length. The table must be + * at least as long as the version 1.0 FADT */ - LocalFadt = ACPI_MEM_CALLOCATE (sizeof (FADT_DESCRIPTOR_REV2)); - if (LocalFadt == NULL) + if (AcpiGbl_FADT->Length < sizeof (FADT_DESCRIPTOR_REV1)) { - return_ACPI_STATUS (AE_NO_MEMORY); + ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", + AcpiGbl_FADT->Length)); + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); } - /* - * FADT length and version validation. The table must be at least as - * long as the version 1.0 FADT - */ - if (AcpiGbl_FADT->Length < sizeof (FADT_DESCRIPTOR_REV1)) + /* Allocate buffer for the ACPI 2.0(+) FADT */ + + LocalFadt = ACPI_MEM_CALLOCATE (sizeof (FADT_DESCRIPTOR_REV2)); + if (!LocalFadt) { - ACPI_REPORT_ERROR (("Invalid FADT table length: 0x%X\n", AcpiGbl_FADT->Length)); - return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + return_ACPI_STATUS (AE_NO_MEMORY); } if (AcpiGbl_FADT->Revision >= FADT2_REVISION_ID) @@ -538,8 +592,9 @@ AcpiTbConvertTableFadt (void) { /* Length is too short to be a V2.0 table */ - ACPI_REPORT_WARNING (("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", - AcpiGbl_FADT->Length, AcpiGbl_FADT->Revision)); + ACPI_REPORT_WARNING (( + "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", + AcpiGbl_FADT->Length, AcpiGbl_FADT->Revision)); AcpiTbConvertFadt1 (LocalFadt, (void *) AcpiGbl_FADT); } @@ -557,9 +612,8 @@ AcpiTbConvertTableFadt (void) AcpiTbConvertFadt1 (LocalFadt, (void *) AcpiGbl_FADT); } - /* - * Global FADT pointer will point to the new common V2.0 FADT - */ + /* Global FADT pointer will point to the new common V2.0 FADT */ + AcpiGbl_FADT = LocalFadt; AcpiGbl_FADT->Length = sizeof (FADT_DESCRIPTOR); @@ -587,9 +641,9 @@ AcpiTbConvertTableFadt (void) /******************************************************************************* * - * FUNCTION: AcpiTbConvertTableFacs + * FUNCTION: AcpiTbBuildCommonFacs * - * PARAMETERS: TableInfo - Info for currently installad FACS + * PARAMETERS: TableInfo - Info for currently installed FACS * * RETURN: Status * @@ -610,13 +664,15 @@ AcpiTbBuildCommonFacs ( if (AcpiGbl_FACS->Length < 24) { - ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", AcpiGbl_FACS->Length)); + ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", + AcpiGbl_FACS->Length)); return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); } if (AcpiGbl_FACS->Length < 64) { - ACPI_REPORT_WARNING (("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", + ACPI_REPORT_WARNING (( + "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", AcpiGbl_FACS->Length)); } @@ -630,7 +686,8 @@ AcpiTbBuildCommonFacs ( { /* ACPI 1.0 FACS or short table or optional X_ field is zero */ - AcpiGbl_CommonFACS.FirmwareWakingVector = ACPI_CAST_PTR (UINT64, &(AcpiGbl_FACS->FirmwareWakingVector)); + AcpiGbl_CommonFACS.FirmwareWakingVector = ACPI_CAST_PTR (UINT64, + &(AcpiGbl_FACS->FirmwareWakingVector)); AcpiGbl_CommonFACS.VectorWidth = 32; } else diff --git a/sys/dev/acpi/acpica/Subsystem/tbget.c b/sys/dev/acpi/acpica/Subsystem/tbget.c index b637c232201..57bc40d69ee 100644 --- a/sys/dev/acpi/acpica/Subsystem/tbget.c +++ b/sys/dev/acpi/acpica/Subsystem/tbget.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbget - ACPI Table get* routines - * xRevision: 88 $ + * xRevision: 94 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbget.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tbget.c,v 1.12 2005/05/02 14:52:10 kochi Exp $"); #define __TBGET_C__ @@ -126,6 +126,19 @@ __KERNEL_RCSID(0, "$NetBSD: tbget.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbget") +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbGetThisTable ( + ACPI_POINTER *Address, + ACPI_TABLE_HEADER *Header, + ACPI_TABLE_DESC *TableInfo); + +static ACPI_STATUS +AcpiTbTableOverride ( + ACPI_TABLE_HEADER *Header, + ACPI_TABLE_DESC *TableInfo); + /******************************************************************************* * @@ -153,9 +166,8 @@ AcpiTbGetTable ( ACPI_FUNCTION_TRACE ("TbGetTable"); - /* - * Get the header in order to get signature and table size - */ + /* Get the header in order to get signature and table size */ + Status = AcpiTbGetTableHeader (Address, &Header); if (ACPI_FAILURE (Status)) { @@ -206,8 +218,8 @@ AcpiTbGetTableHeader ( /* - * Flags contains the current processor mode (Virtual or Physical addressing) - * The PointerType is either Logical or Physical + * Flags contains the current processor mode (Virtual or Physical + * addressing) The PointerType is either Logical or Physical */ switch (Address->PointerType) { @@ -216,7 +228,8 @@ AcpiTbGetTableHeader ( /* Pointer matches processor mode, copy the header */ - ACPI_MEMCPY (ReturnHeader, Address->Pointer.Logical, sizeof (ACPI_TABLE_HEADER)); + ACPI_MEMCPY (ReturnHeader, Address->Pointer.Logical, + sizeof (ACPI_TABLE_HEADER)); break; @@ -224,11 +237,12 @@ AcpiTbGetTableHeader ( /* Create a logical address for the physical pointer*/ - Status = AcpiOsMapMemory (Address->Pointer.Physical, sizeof (ACPI_TABLE_HEADER), - (void *) &Header); + Status = AcpiOsMapMemory (Address->Pointer.Physical, + sizeof (ACPI_TABLE_HEADER), (void *) &Header); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not map memory at %8.8X%8.8X for length %X\n", + ACPI_REPORT_ERROR (( + "Could not map memory at %8.8X%8.8X for length %X\n", ACPI_FORMAT_UINT64 (Address->Pointer.Physical), sizeof (ACPI_TABLE_HEADER))); return_ACPI_STATUS (Status); @@ -248,6 +262,9 @@ AcpiTbGetTableHeader ( return_ACPI_STATUS (AE_BAD_PARAMETER); } + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n", + ReturnHeader->Signature)); + return_ACPI_STATUS (AE_OK); } @@ -289,9 +306,8 @@ AcpiTbGetTableBody ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Attempt table override. - */ + /* Attempt table override. */ + Status = AcpiTbTableOverride (Header, TableInfo); if (ACPI_SUCCESS (Status)) { @@ -321,7 +337,7 @@ AcpiTbGetTableBody ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbTableOverride ( ACPI_TABLE_HEADER *Header, ACPI_TABLE_DESC *TableInfo) @@ -398,7 +414,7 @@ AcpiTbTableOverride ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbGetThisTable ( ACPI_POINTER *Address, ACPI_TABLE_HEADER *Header, @@ -413,8 +429,8 @@ AcpiTbGetThisTable ( /* - * Flags contains the current processor mode (Virtual or Physical addressing) - * The PointerType is either Logical or Physical + * Flags contains the current processor mode (Virtual or Physical + * addressing) The PointerType is either Logical or Physical */ switch (Address->PointerType) { @@ -426,7 +442,8 @@ AcpiTbGetThisTable ( FullTable = ACPI_MEM_ALLOCATE (Header->Length); if (!FullTable) { - ACPI_REPORT_ERROR (("Could not allocate table memory for [%4.4s] length %X\n", + ACPI_REPORT_ERROR (( + "Could not allocate table memory for [%4.4s] length %X\n", Header->Signature, Header->Length)); return_ACPI_STATUS (AE_NO_MEMORY); } @@ -447,13 +464,15 @@ AcpiTbGetThisTable ( * Just map the table's physical memory * into our address space. */ - Status = AcpiOsMapMemory (Address->Pointer.Physical, (ACPI_SIZE) Header->Length, - (void *) &FullTable); + Status = AcpiOsMapMemory (Address->Pointer.Physical, + (ACPI_SIZE) Header->Length, (void *) &FullTable); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", + ACPI_REPORT_ERROR (( + "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", Header->Signature, - ACPI_FORMAT_UINT64 (Address->Pointer.Physical), Header->Length)); + ACPI_FORMAT_UINT64 (Address->Pointer.Physical), + Header->Length)); return (Status); } @@ -557,9 +576,8 @@ AcpiTbGetTablePtr ( return_ACPI_STATUS (AE_OK); } - /* - * Check for instance out of range - */ + /* Check for instance out of range */ + if (Instance > AcpiGbl_TableLists[TableType].Count) { return_ACPI_STATUS (AE_NOT_EXIST); diff --git a/sys/dev/acpi/acpica/Subsystem/tbgetall.c b/sys/dev/acpi/acpica/Subsystem/tbgetall.c index 0b10418adc3..a18c04f29ae 100644 --- a/sys/dev/acpi/acpica/Subsystem/tbgetall.c +++ b/sys/dev/acpi/acpica/Subsystem/tbgetall.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbgetall - Get all required ACPI tables - * xRevision: 9 $ + * xRevision: 13 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbgetall.c,v 1.5 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tbgetall.c,v 1.6 2005/05/02 14:52:10 kochi Exp $"); #define __TBGETALL_C__ @@ -126,6 +126,19 @@ __KERNEL_RCSID(0, "$NetBSD: tbgetall.c,v 1.5 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbgetall") +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbGetPrimaryTable ( + ACPI_POINTER *Address, + ACPI_TABLE_DESC *TableInfo); + +static ACPI_STATUS +AcpiTbGetSecondaryTable ( + ACPI_POINTER *Address, + ACPI_STRING Signature, + ACPI_TABLE_DESC *TableInfo); + /******************************************************************************* * @@ -140,7 +153,7 @@ __KERNEL_RCSID(0, "$NetBSD: tbgetall.c,v 1.5 2004/02/14 16:57:25 kochi Exp $"); * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbGetPrimaryTable ( ACPI_POINTER *Address, ACPI_TABLE_DESC *TableInfo) @@ -159,9 +172,8 @@ AcpiTbGetPrimaryTable ( return_ACPI_STATUS (AE_OK); } - /* - * Get the header in order to get signature and table size - */ + /* Get the header in order to get signature and table size */ + Status = AcpiTbGetTableHeader (Address, &Header); if (ACPI_FAILURE (Status)) { @@ -211,7 +223,7 @@ AcpiTbGetPrimaryTable ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbGetSecondaryTable ( ACPI_POINTER *Address, ACPI_STRING Signature, @@ -236,7 +248,8 @@ AcpiTbGetSecondaryTable ( if (ACPI_STRNCMP (Header.Signature, Signature, ACPI_NAME_SIZE)) { - ACPI_REPORT_ERROR (("Incorrect table signature - wanted [%s] found [%4.4s]\n", + ACPI_REPORT_ERROR (( + "Incorrect table signature - wanted [%s] found [%4.4s]\n", Signature, Header.Signature)); return_ACPI_STATUS (AE_BAD_SIGNATURE); } @@ -316,7 +329,8 @@ AcpiTbGetRequiredTables ( { /* Get the table address from the common internal XSDT */ - Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[i]); + Address.Pointer.Value = ACPI_GET_ADDRESS ( + AcpiGbl_XSDT->TableOffsetEntry[i]); /* * Get the tables needed by this subsystem (FADT and any SSDTs). @@ -340,19 +354,19 @@ AcpiTbGetRequiredTables ( } /* - * Convert the FADT to a common format. This allows earlier revisions of the - * table to coexist with newer versions, using common access code. + * Convert the FADT to a common format. This allows earlier revisions of + * the table to coexist with newer versions, using common access code. */ Status = AcpiTbConvertTableFadt (); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not convert FADT to internal common format\n")); + ACPI_REPORT_ERROR (( + "Could not convert FADT to internal common format\n")); return_ACPI_STATUS (Status); } - /* - * Get the FACS (Pointed to by the FADT) - */ + /* Get the FACS (Pointed to by the FADT) */ + Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl); Status = AcpiTbGetSecondaryTable (&Address, FACS_SIG, &TableInfo); @@ -373,9 +387,8 @@ AcpiTbGetRequiredTables ( return_ACPI_STATUS (Status); } - /* - * Get/install the DSDT (Pointed to by the FADT) - */ + /* Get/install the DSDT (Pointed to by the FADT) */ + Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt); Status = AcpiTbGetSecondaryTable (&Address, DSDT_SIG, &TableInfo); diff --git a/sys/dev/acpi/acpica/Subsystem/tbinstal.c b/sys/dev/acpi/acpica/Subsystem/tbinstal.c index 1d10f35b865..834cca99b55 100644 --- a/sys/dev/acpi/acpica/Subsystem/tbinstal.c +++ b/sys/dev/acpi/acpica/Subsystem/tbinstal.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbinstal - ACPI table installation and removal - * xRevision: 73 $ + * xRevision: 78 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbinstal.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tbinstal.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __TBINSTAL_C__ @@ -127,6 +127,14 @@ __KERNEL_RCSID(0, "$NetBSD: tbinstal.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbinstal") +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbMatchSignature ( + char *Signature, + ACPI_TABLE_DESC *TableInfo, + UINT8 SearchType); + /******************************************************************************* * @@ -134,6 +142,7 @@ __KERNEL_RCSID(0, "$NetBSD: tbinstal.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * * PARAMETERS: Signature - Table signature to match * TableInfo - Return data + * SearchType - Table type to match (primary/secondary) * * RETURN: Status * @@ -142,7 +151,7 @@ __KERNEL_RCSID(0, "$NetBSD: tbinstal.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbMatchSignature ( char *Signature, ACPI_TABLE_DESC *TableInfo, @@ -154,9 +163,8 @@ AcpiTbMatchSignature ( ACPI_FUNCTION_TRACE ("TbMatchSignature"); - /* - * Search for a signature match among the known table types - */ + /* Search for a signature match among the known table types */ + for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) { if (!(AcpiGbl_TableData[i].Flags & SearchType)) @@ -245,6 +253,7 @@ AcpiTbInstallTable ( * FUNCTION: AcpiTbRecognizeTable * * PARAMETERS: TableInfo - Return value from AcpiTbGetTableBody + * SearchType - Table type to match (primary/secondary) * * RETURN: Status * @@ -288,7 +297,8 @@ AcpiTbRecognizeTable ( * This can be any one of many valid ACPI tables, it just isn't one of * the tables that is consumed by the core subsystem */ - Status = AcpiTbMatchSignature (TableHeader->Signature, TableInfo, SearchType); + Status = AcpiTbMatchSignature (TableHeader->Signature, + TableInfo, SearchType); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -341,9 +351,8 @@ AcpiTbInitTableDescriptor ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * Install the table into the global data structure - */ + /* Install the table into the global data structure */ + ListHead = &AcpiGbl_TableLists[TableType]; /* @@ -355,10 +364,11 @@ AcpiTbInitTableDescriptor ( { /* * Only one table allowed, and a table has alread been installed - * at this location, so return an error. + * at this location, so return an error. */ if (ListHead->Next) { + ACPI_MEM_FREE (TableDesc); return_ACPI_STATUS (AE_ALREADY_EXISTS); } @@ -410,7 +420,8 @@ AcpiTbInitTableDescriptor ( TableDesc->AmlStart = (UINT8 *) (TableDesc->Pointer + 1), TableDesc->AmlLength = (UINT32) (TableDesc->Length - (UINT32) sizeof (ACPI_TABLE_HEADER)); - TableDesc->TableId = AcpiUtAllocateOwnerId (ACPI_OWNER_TYPE_TABLE); + TableDesc->TableId = AcpiUtAllocateOwnerId ( + ACPI_OWNER_TYPE_TABLE); TableDesc->LoadedIntoNamespace = FALSE; /* @@ -444,7 +455,8 @@ AcpiTbInitTableDescriptor ( ******************************************************************************/ void -AcpiTbDeleteAllTables (void) +AcpiTbDeleteAllTables ( + void) { ACPI_TABLE_TYPE Type; diff --git a/sys/dev/acpi/acpica/Subsystem/tbrsdt.c b/sys/dev/acpi/acpica/Subsystem/tbrsdt.c index 093c09a05b6..d7516245d1f 100644 --- a/sys/dev/acpi/acpica/Subsystem/tbrsdt.c +++ b/sys/dev/acpi/acpica/Subsystem/tbrsdt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbrsdt - ACPI RSDT table utilities - * xRevision: 12 $ + * xRevision: 16 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbrsdt.c,v 1.6 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tbrsdt.c,v 1.7 2005/05/02 14:52:10 kochi Exp $"); #define __TBRSDT_C__ @@ -162,7 +162,8 @@ AcpiTbVerifyRsdp ( /* * Obtain access to the RSDP structure */ - Status = AcpiOsMapMemory (Address->Pointer.Physical, sizeof (RSDP_DESCRIPTOR), + Status = AcpiOsMapMemory (Address->Pointer.Physical, + sizeof (RSDP_DESCRIPTOR), (void *) &Rsdp); if (ACPI_FAILURE (Status)) { @@ -239,9 +240,9 @@ Cleanup: * * FUNCTION: AcpiTbGetRsdtAddress * - * PARAMETERS: None + * PARAMETERS: OutAddress - Where the address is returned * - * RETURN: RSDT physical address + * RETURN: None, Address * * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the * version of the RSDP @@ -268,7 +269,8 @@ AcpiTbGetRsdtAddress ( } else { - OutAddress->Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress); + OutAddress->Pointer.Value = ACPI_GET_ADDRESS ( + AcpiGbl_RSDP->XsdtPhysicalAddress); } } @@ -314,7 +316,8 @@ AcpiTbValidateRsdt ( { /* Invalid RSDT or XSDT signature */ - ACPI_REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); + ACPI_REPORT_ERROR (( + "Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); ACPI_DUMP_BUFFER (AcpiGbl_RSDP, 20); @@ -369,11 +372,13 @@ AcpiTbGetTableRsdt ( AcpiTbGetRsdtAddress (&Address); + TableInfo.Type = ACPI_TABLE_XSDT; Status = AcpiTbGetTable (&Address, &TableInfo); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n", AcpiFormatException (Status))); + return_ACPI_STATUS (Status); } @@ -392,7 +397,8 @@ AcpiTbGetTableRsdt ( /* Get the number of tables defined in the RSDT or XSDT */ - AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, TableInfo.Pointer); + AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, + TableInfo.Pointer); /* Convert and/or copy to an XSDT structure */ diff --git a/sys/dev/acpi/acpica/Subsystem/tbutils.c b/sys/dev/acpi/acpica/Subsystem/tbutils.c index 3ffa5dda392..b7175abd8da 100644 --- a/sys/dev/acpi/acpica/Subsystem/tbutils.c +++ b/sys/dev/acpi/acpica/Subsystem/tbutils.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbutils - Table manipulation utilities - * xRevision: 61 $ + * xRevision: 65 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbutils.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tbutils.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __TBUTILS_C__ @@ -126,50 +126,14 @@ __KERNEL_RCSID(0, "$NetBSD: tbutils.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbutils") +/* Local prototypes */ -/******************************************************************************* - * - * FUNCTION: AcpiTbHandleToObject - * - * PARAMETERS: TableId - Id for which the function is searching - * TableDesc - Pointer to return the matching table - * descriptor. - * - * RETURN: Search the tables to find one with a matching TableId and - * return a pointer to that table descriptor. - * - ******************************************************************************/ - +#ifdef ACPI_OBSOLETE_FUNCTIONS ACPI_STATUS AcpiTbHandleToObject ( UINT16 TableId, - ACPI_TABLE_DESC **ReturnTableDesc) -{ - UINT32 i; - ACPI_TABLE_DESC *TableDesc; - - - ACPI_FUNCTION_NAME ("TbHandleToObject"); - - - for (i = 0; i < ACPI_TABLE_MAX; i++) - { - TableDesc = AcpiGbl_TableLists[i].Next; - while (TableDesc) - { - if (TableDesc->TableId == TableId) - { - *ReturnTableDesc = TableDesc; - return (AE_OK); - } - - TableDesc = TableDesc->Next; - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "TableId=%X does not exist\n", TableId)); - return (AE_BAD_PARAMETER); -} + ACPI_TABLE_DESC **TableDesc); +#endif /******************************************************************************* @@ -208,6 +172,7 @@ AcpiTbValidateTableHeader ( { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Cannot read table header at %p\n", TableHeader)); + return (AE_BAD_ADDRESS); } @@ -222,6 +187,7 @@ AcpiTbValidateTableHeader ( ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n", (char *) &Signature)); + ACPI_DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); return (AE_BAD_SIGNATURE); } @@ -236,6 +202,7 @@ AcpiTbValidateTableHeader ( ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n", (UINT32) TableHeader->Length)); + ACPI_DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); return (AE_BAD_HEADER); } @@ -276,8 +243,10 @@ AcpiTbVerifyTableChecksum ( if (Checksum) { - ACPI_REPORT_WARNING (("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", - TableHeader->Signature, (UINT32) TableHeader->Checksum, (UINT32) Checksum)); + ACPI_REPORT_WARNING (( + "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", + TableHeader->Signature, (UINT32) TableHeader->Checksum, + (UINT32) Checksum)); Status = AE_BAD_CHECKSUM; } @@ -292,7 +261,7 @@ AcpiTbVerifyTableChecksum ( * PARAMETERS: Buffer - Buffer to checksum * Length - Size of the buffer * - * RETURNS 8 bit checksum of buffer + * RETURN: 8 bit checksum of buffer * * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. * @@ -323,3 +292,50 @@ AcpiTbChecksum ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiTbHandleToObject + * + * PARAMETERS: TableId - Id for which the function is searching + * TableDesc - Pointer to return the matching table + * descriptor. + * + * RETURN: Search the tables to find one with a matching TableId and + * return a pointer to that table descriptor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbHandleToObject ( + UINT16 TableId, + ACPI_TABLE_DESC **ReturnTableDesc) +{ + UINT32 i; + ACPI_TABLE_DESC *TableDesc; + + + ACPI_FUNCTION_NAME ("TbHandleToObject"); + + + for (i = 0; i < ACPI_TABLE_MAX; i++) + { + TableDesc = AcpiGbl_TableLists[i].Next; + while (TableDesc) + { + if (TableDesc->TableId == TableId) + { + *ReturnTableDesc = TableDesc; + return (AE_OK); + } + + TableDesc = TableDesc->Next; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "TableId=%X does not exist\n", TableId)); + return (AE_BAD_PARAMETER); +} +#endif + + diff --git a/sys/dev/acpi/acpica/Subsystem/tbxface.c b/sys/dev/acpi/acpica/Subsystem/tbxface.c index 7c8aaf944a0..8b7ee78faa8 100644 --- a/sys/dev/acpi/acpica/Subsystem/tbxface.c +++ b/sys/dev/acpi/acpica/Subsystem/tbxface.c @@ -2,7 +2,7 @@ * * Module Name: tbxface - Public interfaces to the ACPI subsystem * ACPI table oriented interfaces - * xRevision: 64 $ + * xRevision: 67 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbxface.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tbxface.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __TBXFACE_C__ @@ -143,7 +143,8 @@ __KERNEL_RCSID(0, "$NetBSD: tbxface.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); ******************************************************************************/ ACPI_STATUS -AcpiLoadTables (void) +AcpiLoadTables ( + void) { ACPI_POINTER RsdpAddress; ACPI_STATUS Status; @@ -159,7 +160,7 @@ AcpiLoadTables (void) if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiLoadTables: Could not get RSDP, %s\n", - AcpiFormatException (Status))); + AcpiFormatException (Status))); goto ErrorExit; } @@ -171,7 +172,7 @@ AcpiLoadTables (void) if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiLoadTables: RSDP Failed validation: %s\n", - AcpiFormatException (Status))); + AcpiFormatException (Status))); goto ErrorExit; } @@ -181,7 +182,7 @@ AcpiLoadTables (void) if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load RSDT: %s\n", - AcpiFormatException (Status))); + AcpiFormatException (Status))); goto ErrorExit; } @@ -190,21 +191,21 @@ AcpiLoadTables (void) Status = AcpiTbGetRequiredTables (); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("AcpiLoadTables: Error getting required tables (DSDT/FADT/FACS): %s\n", - AcpiFormatException (Status))); + ACPI_REPORT_ERROR (( + "AcpiLoadTables: Error getting required tables (DSDT/FADT/FACS): %s\n", + AcpiFormatException (Status))); goto ErrorExit; } ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); - /* Load the namespace from the tables */ Status = AcpiNsLoadNamespace (); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load namespace: %s\n", - AcpiFormatException (Status))); + AcpiFormatException (Status))); goto ErrorExit; } @@ -335,7 +336,6 @@ AcpiUnloadTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Find all tables of the requested type */ TableDesc = AcpiGbl_TableLists[TableType].Next; @@ -409,7 +409,6 @@ AcpiGetTableHeader ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get a pointer to the entire table */ Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); @@ -418,19 +417,17 @@ AcpiGetTableHeader ( return_ACPI_STATUS (Status); } - /* - * The function will return a NULL pointer if the table is not loaded - */ + /* The function will return a NULL pointer if the table is not loaded */ + if (TblPtr == NULL) { return_ACPI_STATUS (AE_NOT_EXIST); } - /* - * Copy the header to the caller's buffer - */ + /* Copy the header to the caller's buffer */ + ACPI_MEMCPY ((void *) OutTableHeader, (void *) TblPtr, - sizeof (ACPI_TABLE_HEADER)); + sizeof (ACPI_TABLE_HEADER)); return_ACPI_STATUS (Status); } @@ -495,7 +492,6 @@ AcpiGetTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get a pointer to the entire table */ Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); @@ -517,9 +513,8 @@ AcpiGetTable ( if (TableType == ACPI_TABLE_RSDP) { - /* - * RSD PTR is the only "table" without a header - */ + /* RSD PTR is the only "table" without a header */ + TableLength = sizeof (RSDP_DESCRIPTOR); } else diff --git a/sys/dev/acpi/acpica/Subsystem/tbxfroot.c b/sys/dev/acpi/acpica/Subsystem/tbxfroot.c index d49ca94ef3b..12d32f3fd41 100644 --- a/sys/dev/acpi/acpica/Subsystem/tbxfroot.c +++ b/sys/dev/acpi/acpica/Subsystem/tbxfroot.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbxfroot - Find the root ACPI table (RSDT) - * xRevision: 72 $ + * xRevision: 85 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tbxfroot.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tbxfroot.c,v 1.12 2005/05/02 14:52:10 kochi Exp $"); #define __TBXFROOT_C__ @@ -126,6 +126,18 @@ __KERNEL_RCSID(0, "$NetBSD: tbxfroot.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbxfroot") +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbFindRsdp ( + ACPI_TABLE_DESC *TableInfo, + UINT32 Flags); + +static UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length); + /******************************************************************************* * @@ -133,7 +145,8 @@ __KERNEL_RCSID(0, "$NetBSD: tbxfroot.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); * * PARAMETERS: Signature - String with ACPI table signature * OemId - String with the table OEM ID - * OemTableId - String with the OEM Table ID. + * OemTableId - String with the OEM Table ID + * TablePtr - Where the table pointer is returned * * RETURN: Status * @@ -165,23 +178,49 @@ AcpiTbFindTable ( return_ACPI_STATUS (AE_AML_STRING_LIMIT); } - /* Find the table */ - - Status = AcpiGetFirmwareTable (Signature, 1, - ACPI_LOGICAL_ADDRESSING, &Table); - if (ACPI_FAILURE (Status)) + if (!ACPI_STRNCMP (Signature, DSDT_SIG, ACPI_NAME_SIZE)) + { + /* + * The DSDT pointer is contained in the FADT, not the RSDT. + * This code should suffice, because the only code that would perform + * a "find" on the DSDT is the DataTableRegion() AML opcode -- in + * which case, the DSDT is guaranteed to be already loaded. + * If this becomes insufficient, the FADT will have to be found first. + */ + if (!AcpiGbl_DSDT) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + Table = AcpiGbl_DSDT; + } + else { - return_ACPI_STATUS (Status); + /* Find the table */ + + Status = AcpiGetFirmwareTable (Signature, 1, + ACPI_LOGICAL_ADDRESSING, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } /* Check OemId and OemTableId */ - if ((OemId[0] && ACPI_STRCMP (OemId, Table->OemId)) || - (OemTableId[0] && ACPI_STRCMP (OemTableId, Table->OemTableId))) + if ((OemId[0] && ACPI_STRNCMP ( + OemId, Table->OemId, + sizeof (Table->OemId))) || + + (OemTableId[0] && ACPI_STRNCMP ( + OemTableId, Table->OemTableId, + sizeof (Table->OemTableId)))) { return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND); } + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", + Table->Signature)); + *TablePtr = Table; return_ACPI_STATUS (AE_OK); } @@ -195,17 +234,14 @@ AcpiTbFindTable ( * Instance - the non zero instance of the table, allows * support for multiple tables of the same type * Flags - Physical/Virtual support - * RetBuffer - pointer to a structure containing a buffer to - * receive the table + * TablePointer - Where a buffer containing the table is + * returned * * RETURN: Status * - * DESCRIPTION: This function is called to get an ACPI table. The caller - * supplies an OutBuffer large enough to contain the entire ACPI - * table. Upon completion - * the OutBuffer->Length field will indicate the number of bytes - * copied into the OutBuffer->BufPtr buffer. This table will be - * a complete table including the header. + * DESCRIPTION: This function is called to get an ACPI table. A buffer is + * allocated for the table and returned in TablePointer. + * This table will be a complete table including the header. * ******************************************************************************/ @@ -216,12 +252,11 @@ AcpiGetFirmwareTable ( UINT32 Flags, ACPI_TABLE_HEADER **TablePointer) { - ACPI_POINTER RsdpAddress; - ACPI_POINTER Address; ACPI_STATUS Status; - ACPI_TABLE_HEADER Header; - ACPI_TABLE_DESC TableInfo; - ACPI_TABLE_DESC RsdtInfo; + ACPI_POINTER Address; + ACPI_TABLE_HEADER *Header = NULL; + ACPI_TABLE_DESC *TableInfo = NULL; + ACPI_TABLE_DESC *RsdtInfo; UINT32 TableCount; UINT32 i; UINT32 j; @@ -232,29 +267,26 @@ AcpiGetFirmwareTable ( /* * Ensure that at least the table manager is initialized. We don't - * require that the entire ACPI subsystem is up for this interface - */ - - /* - * If we have a buffer, we must have a length too + * require that the entire ACPI subsystem is up for this interface. + * If we have a buffer, we must have a length too */ - if ((Instance == 0) || - (!Signature) || + if ((Instance == 0) || + (!Signature) || (!TablePointer)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - RsdtInfo.Pointer = NULL; + /* Ensure that we have a RSDP */ if (!AcpiGbl_RSDP) { /* Get the RSDP */ - Status = AcpiOsGetRootPointer (Flags, &RsdpAddress); + Status = AcpiOsGetRootPointer (Flags, &Address); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } @@ -262,8 +294,8 @@ AcpiGetFirmwareTable ( if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { - Status = AcpiOsMapMemory (RsdpAddress.Pointer.Physical, sizeof (RSDP_DESCRIPTOR), - (void *) &AcpiGbl_RSDP); + Status = AcpiOsMapMemory (Address.Pointer.Physical, + sizeof (RSDP_DESCRIPTOR), (void *) &AcpiGbl_RSDP); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -271,13 +303,13 @@ AcpiGetFirmwareTable ( } else { - AcpiGbl_RSDP = RsdpAddress.Pointer.Logical; + AcpiGbl_RSDP = Address.Pointer.Logical; } - /* - * The signature and checksum must both be correct - */ - if (ACPI_STRNCMP ((char *) AcpiGbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) + /* The signature and checksum must both be correct */ + + if (ACPI_STRNCMP ((char *) AcpiGbl_RSDP, RSDP_SIG, + sizeof (RSDP_SIG)-1) != 0) { /* Nope, BAD Signature */ @@ -292,10 +324,9 @@ AcpiGetFirmwareTable ( } } - /* Get the RSDT and validate it */ + /* Get the RSDT address via the RSDP */ AcpiTbGetRsdtAddress (&Address); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", AcpiGbl_RSDP, @@ -305,22 +336,45 @@ AcpiGetFirmwareTable ( Address.PointerType |= Flags; - Status = AcpiTbGetTable (&Address, &RsdtInfo); + /* Get and validate the RSDT */ + + RsdtInfo = ACPI_MEM_CALLOCATE (sizeof (ACPI_TABLE_DESC)); + if (!RsdtInfo) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiTbGetTable (&Address, RsdtInfo); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Cleanup; } - Status = AcpiTbValidateRsdt (RsdtInfo.Pointer); + Status = AcpiTbValidateRsdt (RsdtInfo->Pointer); if (ACPI_FAILURE (Status)) { goto Cleanup; } - /* Get the number of table pointers within the RSDT */ + /* Allocate a scratch table header and table descriptor */ + + Header = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); + if (!Header) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + TableInfo = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_DESC)); + if (!TableInfo) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } - TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtInfo.Pointer); + /* Get the number of table pointers within the RSDT */ + TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtInfo->Pointer); Address.PointerType = AcpiGbl_TableFlags | Flags; /* @@ -333,17 +387,18 @@ AcpiGetFirmwareTable ( if (AcpiGbl_RSDP->Revision < 2) { - Address.Pointer.Value = (ACPI_CAST_PTR (RSDT_DESCRIPTOR, RsdtInfo.Pointer))->TableOffsetEntry[i]; + Address.Pointer.Value = (ACPI_CAST_PTR ( + RSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]; } else { - Address.Pointer.Value = ACPI_GET_ADDRESS ( - (ACPI_CAST_PTR (XSDT_DESCRIPTOR, RsdtInfo.Pointer))->TableOffsetEntry[i]); + Address.Pointer.Value = ACPI_GET_ADDRESS ((ACPI_CAST_PTR ( + XSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]); } /* Get the table header */ - Status = AcpiTbGetTableHeader (&Address, &Header); + Status = AcpiTbGetTableHeader (&Address, Header); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -351,7 +406,7 @@ AcpiGetFirmwareTable ( /* Compare table signatures and table instance */ - if (!ACPI_STRNCMP (Header.Signature, Signature, ACPI_NAME_SIZE)) + if (!ACPI_STRNCMP (Header->Signature, Signature, ACPI_NAME_SIZE)) { /* An instance of the table was found */ @@ -360,13 +415,13 @@ AcpiGetFirmwareTable ( { /* Found the correct instance, get the entire table */ - Status = AcpiTbGetTableBody (&Address, &Header, &TableInfo); + Status = AcpiTbGetTableBody (&Address, Header, TableInfo); if (ACPI_FAILURE (Status)) { goto Cleanup; } - *TablePointer = TableInfo.Pointer; + *TablePointer = TableInfo->Pointer; goto Cleanup; } } @@ -378,7 +433,18 @@ AcpiGetFirmwareTable ( Cleanup: - AcpiOsUnmapMemory (RsdtInfo.Pointer, (ACPI_SIZE) RsdtInfo.Pointer->Length); + AcpiOsUnmapMemory (RsdtInfo->Pointer, + (ACPI_SIZE) RsdtInfo->Pointer->Length); + ACPI_MEM_FREE (RsdtInfo); + + if (Header) + { + ACPI_MEM_FREE (Header); + } + if (TableInfo) + { + ACPI_MEM_FREE (TableInfo); + } return_ACPI_STATUS (Status); } @@ -391,8 +457,8 @@ Cleanup: * * FUNCTION: AcpiFindRootPointer * - * PARAMETERS: **RsdpAddress - Where to place the RSDP address - * Flags - Logical/Physical addressing + * PARAMETERS: Flags - Logical/Physical addressing + * RsdpAddress - Where to place the RSDP address * * RETURN: Status, Physical address of the RSDP * @@ -417,8 +483,10 @@ AcpiFindRootPointer ( Status = AcpiTbFindRsdp (&TableInfo, Flags); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found, %s Flags=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "RSDP structure not found, %s Flags=%X\n", AcpiFormatException (Status), Flags)); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); } @@ -441,42 +509,69 @@ AcpiFindRootPointer ( * ******************************************************************************/ -UINT8 * +static UINT8 * AcpiTbScanMemoryForRsdp ( UINT8 *StartAddress, UINT32 Length) { - UINT32 Offset; UINT8 *MemRover; + UINT8 *EndAddress; + UINT8 Checksum; ACPI_FUNCTION_TRACE ("TbScanMemoryForRsdp"); - /* Search from given start addr for the requested length */ + EndAddress = StartAddress + Length; - for (Offset = 0, MemRover = StartAddress; - Offset < Length; - Offset += ACPI_RSDP_SCAN_STEP, MemRover += ACPI_RSDP_SCAN_STEP) - { + /* Search from given start address for the requested length */ + for (MemRover = StartAddress; MemRover < EndAddress; + MemRover += ACPI_RSDP_SCAN_STEP) + { /* The signature and checksum must both be correct */ if (ACPI_STRNCMP ((char *) MemRover, - RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 && - AcpiTbChecksum (MemRover, ACPI_RSDP_CHECKSUM_LENGTH) == 0) + RSDP_SIG, sizeof (RSDP_SIG) - 1) != 0) + { + /* No signature match, keep looking */ + + continue; + } + + /* Signature matches, check the appropriate checksum */ + + if ((ACPI_CAST_PTR (RSDP_DESCRIPTOR, MemRover))->Revision < 2) + { + /* ACPI version 1.0 */ + + Checksum = AcpiTbChecksum (MemRover, ACPI_RSDP_CHECKSUM_LENGTH); + } + else + { + /* Post ACPI 1.0, use ExtendedChecksum */ + + Checksum = AcpiTbChecksum (MemRover, ACPI_RSDP_XCHECKSUM_LENGTH); + } + + if (Checksum == 0) { - /* If so, we have found the RSDP */ + /* Checksum valid, we have found a valid RSDP */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "RSDP located at physical address %p\n",MemRover)); + "RSDP located at physical address %p\n", MemRover)); return_PTR (MemRover); } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Found an RSDP at physical address %p, but it has a bad checksum\n", + MemRover)); } /* Searched entire block, no RSDP was found */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO,"Searched entire block, no RSDP was found.\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Searched entire block, no valid RSDP was found.\n")); return_PTR (NULL); } @@ -485,75 +580,113 @@ AcpiTbScanMemoryForRsdp ( * * FUNCTION: AcpiTbFindRsdp * - * PARAMETERS: *TableInfo - Where the table info is returned + * PARAMETERS: TableInfo - Where the table info is returned * Flags - Current memory mode (logical vs. * physical addressing) * - * RETURN: Status + * RETURN: Status, RSDP physical address * * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor * pointer structure. If it is found, set *RSDP to point to it. * - * NOTE: The RSDP must be either in the first 1K of the Extended - * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section - * 5.2.2; assertion #421). + * NOTE1: The RSDP must be either in the first 1K of the Extended + * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) + * Only a 32-bit physical address is necessary. + * + * NOTE2: This function is always available, regardless of the + * initialization state of the rest of ACPI. * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbFindRsdp ( ACPI_TABLE_DESC *TableInfo, UINT32 Flags) { UINT8 *TablePtr; UINT8 *MemRover; - UINT64 PhysAddr; - ACPI_STATUS Status = AE_OK; + UINT32 PhysicalAddress; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("TbFindRsdp"); /* - * Scan supports either 1) Logical addressing or 2) Physical addressing + * Scan supports either logical addressing or physical addressing */ if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { - /* - * 1) Search EBDA (low memory) paragraphs - */ - Status = AcpiOsMapMemory ((UINT64) ACPI_LO_RSDP_WINDOW_BASE, ACPI_LO_RSDP_WINDOW_SIZE, - (void *) &TablePtr); + /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ + + Status = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH, (void *) &TablePtr); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %X for length %X\n", - ACPI_LO_RSDP_WINDOW_BASE, ACPI_LO_RSDP_WINDOW_SIZE)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not map memory at %8.8X for length %X\n", + ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); + return_ACPI_STATUS (Status); } - MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_LO_RSDP_WINDOW_SIZE); - AcpiOsUnmapMemory (TablePtr, ACPI_LO_RSDP_WINDOW_SIZE); + ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr); - if (MemRover) + /* Convert segment part to physical address */ + + PhysicalAddress <<= 4; + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH); + + /* EBDA present? */ + + if (PhysicalAddress > 0x400) { - /* Found it, return the physical address */ + /* + * 1b) Search EBDA paragraphs (EBDA is required to be a + * minimum of 1K length) + */ + Status = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, + ACPI_EBDA_WINDOW_SIZE, (void *) &TablePtr); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not map memory at %8.8X for length %X\n", + PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); - PhysAddr = ACPI_LO_RSDP_WINDOW_BASE; - PhysAddr += ACPI_PTR_DIFF (MemRover,TablePtr); + return_ACPI_STATUS (Status); + } - TableInfo->PhysicalAddress = PhysAddr; - return_ACPI_STATUS (AE_OK); + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, + ACPI_EBDA_WINDOW_SIZE); + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); + + if (MemRover) + { + /* Found it, return the physical address */ + + PhysicalAddress += ACPI_PTR_DIFF (MemRover, TablePtr); + + TableInfo->PhysicalAddress = + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress; + return_ACPI_STATUS (AE_OK); + } } /* - * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h + * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ - Status = AcpiOsMapMemory ((UINT64) ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE, - (void *) &TablePtr); + Status = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE, (void *) &TablePtr); + if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %X for length %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not map memory at %8.8X for length %X\n", ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); + return_ACPI_STATUS (Status); } @@ -564,10 +697,11 @@ AcpiTbFindRsdp ( { /* Found it, return the physical address */ - PhysAddr = ACPI_HI_RSDP_WINDOW_BASE; - PhysAddr += ACPI_PTR_DIFF (MemRover, TablePtr); + PhysicalAddress = + ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr); - TableInfo->PhysicalAddress = PhysAddr; + TableInfo->PhysicalAddress = + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress; return_ACPI_STATUS (AE_OK); } } @@ -577,23 +711,35 @@ AcpiTbFindRsdp ( */ else { - /* - * 1) Search EBDA (low memory) paragraphs - */ - MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (ACPI_LO_RSDP_WINDOW_BASE), - ACPI_LO_RSDP_WINDOW_SIZE); - if (MemRover) + /* 1a) Get the location of the EBDA */ + + ACPI_MOVE_16_TO_32 (&PhysicalAddress, ACPI_EBDA_PTR_LOCATION); + PhysicalAddress <<= 4; /* Convert segment to physical address */ + + /* EBDA present? */ + + if (PhysicalAddress > 0x400) { - /* Found it, return the physical address */ + /* + * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of + * 1K length) + */ + MemRover = AcpiTbScanMemoryForRsdp ( + ACPI_PHYSADDR_TO_PTR (PhysicalAddress), + ACPI_EBDA_WINDOW_SIZE); + if (MemRover) + { + /* Found it, return the physical address */ - TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover); - return_ACPI_STATUS (AE_OK); + TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover); + return_ACPI_STATUS (AE_OK); + } } - /* - * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h - */ - MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), + /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ + + MemRover = AcpiTbScanMemoryForRsdp ( + ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), ACPI_HI_RSDP_WINDOW_SIZE); if (MemRover) { diff --git a/sys/dev/acpi/acpica/Subsystem/utalloc.c b/sys/dev/acpi/acpica/Subsystem/utalloc.c index e61703f85f4..ef740ddb7ac 100644 --- a/sys/dev/acpi/acpica/Subsystem/utalloc.c +++ b/sys/dev/acpi/acpica/Subsystem/utalloc.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utalloc - local cache and memory allocation routines - * xRevision: 135 $ + * xRevision: 144 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utalloc.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utalloc.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __UTALLOC_C__ @@ -124,8 +124,36 @@ __KERNEL_RCSID(0, "$NetBSD: utalloc.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utalloc") +#ifdef ACPI_DBG_TRACK_ALLOCATIONS -/****************************************************************************** +/* Local prototypes */ + +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + UINT32 ListId, + void *Allocation); + +static ACPI_STATUS +AcpiUtTrackAllocation ( + UINT32 ListId, + ACPI_DEBUG_MEM_BLOCK *Address, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + char *Module, + UINT32 Line); + +static ACPI_STATUS +AcpiUtRemoveAllocation ( + UINT32 ListId, + ACPI_DEBUG_MEM_BLOCK *Address, + UINT32 Component, + char *Module, + UINT32 Line); + +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + +/******************************************************************************* * * FUNCTION: AcpiUtReleaseToCache * @@ -150,9 +178,12 @@ AcpiUtReleaseToCache ( ACPI_FUNCTION_ENTRY (); + CacheInfo = &AcpiGbl_MemoryLists[ListId]; + +#ifdef ACPI_ENABLE_OBJECT_CACHE + /* If walk cache is full, just free this wallkstate object */ - CacheInfo = &AcpiGbl_MemoryLists[ListId]; if (CacheInfo->CacheDepth >= CacheInfo->MaxCacheDepth) { ACPI_MEM_FREE (Object); @@ -175,16 +206,25 @@ AcpiUtReleaseToCache ( /* Put the object at the head of the cache list */ - * (ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))) = CacheInfo->ListHead; + * (ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[CacheInfo->LinkOffset]))) = CacheInfo->ListHead; CacheInfo->ListHead = Object; CacheInfo->CacheDepth++; (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); } + +#else + + /* Object cache is disabled; just free the object */ + + ACPI_MEM_FREE (Object); + ACPI_MEM_TRACKING (CacheInfo->TotalFreed++); +#endif } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtAcquireFromCache * @@ -210,6 +250,9 @@ AcpiUtAcquireFromCache ( CacheInfo = &AcpiGbl_MemoryLists[ListId]; + +#ifdef ACPI_ENABLE_OBJECT_CACHE + if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES))) { return (NULL); @@ -224,7 +267,8 @@ AcpiUtAcquireFromCache ( /* There is an object available, use it */ Object = CacheInfo->ListHead; - CacheInfo->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))); + CacheInfo->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[CacheInfo->LinkOffset]))); ACPI_MEM_TRACKING (CacheInfo->CacheHits++); CacheInfo->CacheDepth--; @@ -259,11 +303,20 @@ AcpiUtAcquireFromCache ( ACPI_MEM_TRACKING (CacheInfo->TotalAllocated++); } +#else + + /* Object cache is disabled; just allocate the object */ + + Object = ACPI_MEM_CALLOCATE (CacheInfo->ObjectSize); + ACPI_MEM_TRACKING (CacheInfo->TotalAllocated++); +#endif + return (Object); } -/****************************************************************************** +#ifdef ACPI_ENABLE_OBJECT_CACHE +/******************************************************************************* * * FUNCTION: AcpiUtDeleteGenericCache * @@ -291,13 +344,15 @@ AcpiUtDeleteGenericCache ( { /* Delete one cached state object */ - Next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) CacheInfo->ListHead)[CacheInfo->LinkOffset]))); + Next = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) CacheInfo->ListHead)[CacheInfo->LinkOffset]))); ACPI_MEM_FREE (CacheInfo->ListHead); CacheInfo->ListHead = Next; CacheInfo->CacheDepth--; } } +#endif /******************************************************************************* @@ -348,13 +403,13 @@ AcpiUtValidateBuffer ( * * FUNCTION: AcpiUtInitializeBuffer * - * PARAMETERS: RequiredLength - Length needed - * Buffer - Buffer to be validated + * PARAMETERS: Buffer - Buffer to be validated + * RequiredLength - Length needed * * RETURN: Status * * DESCRIPTION: Validate that the buffer is of the required length or - * allocate a new buffer. + * allocate a new buffer. Returned buffer is always zeroed. * ******************************************************************************/ @@ -396,26 +451,27 @@ AcpiUtInitializeBuffer ( /* Allocate a new buffer with local interface to allow tracking */ - Buffer->Pointer = ACPI_MEM_ALLOCATE (RequiredLength); + Buffer->Pointer = ACPI_MEM_CALLOCATE (RequiredLength); if (!Buffer->Pointer) { return (AE_NO_MEMORY); } - - /* Clear the buffer */ - - ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); break; default: - /* Validate the size of the buffer */ + /* Existing buffer: Validate the size of the buffer */ if (Buffer->Length < RequiredLength) { Status = AE_BUFFER_OVERFLOW; + break; } + + /* Clear the buffer */ + + ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); break; } @@ -569,8 +625,8 @@ AcpiUtAllocateAndTrack ( ACPI_STATUS Status; - Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component, - Module, Line); + Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); if (!Allocation) { return (NULL); @@ -617,8 +673,8 @@ AcpiUtCallocateAndTrack ( ACPI_STATUS Status; - Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component, - Module, Line); + Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); if (!Allocation) { /* Report allocation error */ @@ -706,7 +762,8 @@ AcpiUtFreeAndTrack ( * * FUNCTION: AcpiUtFindAllocation * - * PARAMETERS: Allocation - Address of allocated memory + * PARAMETERS: ListId - Memory list to search + * Allocation - Address of allocated memory * * RETURN: A list element if found; NULL otherwise. * @@ -714,7 +771,7 @@ AcpiUtFreeAndTrack ( * ******************************************************************************/ -ACPI_DEBUG_MEM_BLOCK * +static ACPI_DEBUG_MEM_BLOCK * AcpiUtFindAllocation ( UINT32 ListId, void *Allocation) @@ -752,7 +809,8 @@ AcpiUtFindAllocation ( * * FUNCTION: AcpiUtTrackAllocation * - * PARAMETERS: Allocation - Address of allocated memory + * PARAMETERS: ListId - Memory list to search + * Allocation - Address of allocated memory * Size - Size of the allocation * AllocType - MEM_MALLOC or MEM_CALLOC * Component - Component type of caller @@ -765,7 +823,7 @@ AcpiUtFindAllocation ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtTrackAllocation ( UINT32 ListId, ACPI_DEBUG_MEM_BLOCK *Allocation, @@ -803,10 +861,12 @@ AcpiUtTrackAllocation ( Element = AcpiUtFindAllocation (ListId, Allocation); if (Element) { - ACPI_REPORT_ERROR (("UtTrackAllocation: Allocation already present in list! (%p)\n", + ACPI_REPORT_ERROR (( + "UtTrackAllocation: Allocation already present in list! (%p)\n", Allocation)); - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", Element, Allocation)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", + Element, Allocation)); goto UnlockAndExit; } @@ -819,6 +879,7 @@ AcpiUtTrackAllocation ( Allocation->Line = Line; ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); + Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; /* Insert at list head */ @@ -843,7 +904,8 @@ UnlockAndExit: * * FUNCTION: AcpiUtRemoveAllocation * - * PARAMETERS: Allocation - Address of allocated memory + * PARAMETERS: ListId - Memory list to search + * Allocation - Address of allocated memory * Component - Component type of caller * Module - Source file name of caller * Line - Line number of caller @@ -854,7 +916,7 @@ UnlockAndExit: * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtRemoveAllocation ( UINT32 ListId, ACPI_DEBUG_MEM_BLOCK *Allocation, @@ -880,7 +942,7 @@ AcpiUtRemoveAllocation ( /* No allocations! */ _ACPI_REPORT_ERROR (Module, Line, Component, - ("UtRemoveAllocation: Empty allocation list, nothing to free!\n")); + ("UtRemoveAllocation: Empty allocation list, nothing to free!\n")); return_ACPI_STATUS (AE_OK); } @@ -911,7 +973,8 @@ AcpiUtRemoveAllocation ( ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", Allocation->Size)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", + Allocation->Size)); Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); return_ACPI_STATUS (Status); @@ -971,7 +1034,8 @@ AcpiUtDumpAllocationInfo ( ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Max Nodes", AcpiGbl_MaxConcurrentNodeCount, - ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE))))); + ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * + sizeof (ACPI_NAMESPACE_NODE))))); */ return_VOID; } @@ -1023,8 +1087,8 @@ AcpiUtDumpAllocations ( if (Descriptor->DescriptorId != ACPI_DESC_TYPE_CACHED) { AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", - Descriptor, Element->Size, Element->Module, - Element->Line, AcpiUtGetDescriptorName (Descriptor)); + Descriptor, Element->Size, Element->Module, + Element->Line, AcpiUtGetDescriptorName (Descriptor)); /* Most of the elements will be Operand objects. */ @@ -1032,18 +1096,18 @@ AcpiUtDumpAllocations ( { case ACPI_DESC_TYPE_OPERAND: AcpiOsPrintf ("%12.12s R%hd", - AcpiUtGetTypeName (Descriptor->Object.Common.Type), - Descriptor->Object.Common.ReferenceCount); + AcpiUtGetTypeName (Descriptor->Object.Common.Type), + Descriptor->Object.Common.ReferenceCount); break; case ACPI_DESC_TYPE_PARSER: AcpiOsPrintf ("AmlOpcode %04hX", - Descriptor->Op.Asl.AmlOpcode); + Descriptor->Op.Asl.AmlOpcode); break; case ACPI_DESC_TYPE_NAMED: AcpiOsPrintf ("%4.4s", - AcpiUtGetNodeName (&Descriptor->Node)); + AcpiUtGetNodeName (&Descriptor->Node)); break; default: @@ -1076,6 +1140,5 @@ AcpiUtDumpAllocations ( return_VOID; } - #endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ diff --git a/sys/dev/acpi/acpica/Subsystem/utcopy.c b/sys/dev/acpi/acpica/Subsystem/utcopy.c index 7bad2e6e712..3fa18095b66 100644 --- a/sys/dev/acpi/acpica/Subsystem/utcopy.c +++ b/sys/dev/acpi/acpica/Subsystem/utcopy.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utcopy - Internal to external object translation utilities - * xRevision: 114 $ + * xRevision: 120 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utcopy.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utcopy.c,v 1.13 2005/05/02 14:52:10 kochi Exp $"); #define __UTCOPY_C__ @@ -126,21 +126,69 @@ __KERNEL_RCSID(0, "$NetBSD: utcopy.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utcopy") +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, + UINT8 *DataSpace, + ACPI_SIZE *BufferSpaceUsed); + +static ACPI_STATUS +AcpiUtCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT8 *Buffer, + ACPI_SIZE *SpaceUsed); + +static ACPI_STATUS +AcpiUtCopyEsimpleToIsimple( + ACPI_OBJECT *UserObj, + ACPI_OPERAND_OBJECT **ReturnObj); + +static ACPI_STATUS +AcpiUtCopySimpleObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc); + +static ACPI_STATUS +AcpiUtCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState); + /******************************************************************************* * * FUNCTION: AcpiUtCopyIsimpleToEsimple * - * PARAMETERS: *InternalObject - Pointer to the object we are examining - * *Buffer - Where the object is returned - * *SpaceUsed - Where the data length is returned + * PARAMETERS: InternalObject - Source object to be copied + * ExternalObject - Where to return the copied object + * DataSpace - Where object data is returned (such as + * buffer and string data) + * BufferSpaceUsed - Length of DataSpace that was used * * RETURN: Status * - * DESCRIPTION: This function is called to place a simple object in a user - * buffer. + * DESCRIPTION: This function is called to copy a simple internal object to + * an external object. * - * The buffer is assumed to have sufficient space for the object. + * The DataSpace buffer is assumed to have sufficient space for + * the object. * ******************************************************************************/ @@ -186,10 +234,12 @@ AcpiUtCopyIsimpleToEsimple ( ExternalObject->String.Pointer = (char *) DataSpace; ExternalObject->String.Length = InternalObject->String.Length; - *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ((ACPI_SIZE) InternalObject->String.Length + 1); + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + (ACPI_SIZE) InternalObject->String.Length + 1); - ACPI_MEMCPY ((void *) DataSpace, (void *) InternalObject->String.Pointer, - (ACPI_SIZE) InternalObject->String.Length + 1); + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->String.Pointer, + (ACPI_SIZE) InternalObject->String.Length + 1); break; @@ -197,10 +247,12 @@ AcpiUtCopyIsimpleToEsimple ( ExternalObject->Buffer.Pointer = DataSpace; ExternalObject->Buffer.Length = InternalObject->Buffer.Length; - *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (InternalObject->String.Length); + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + InternalObject->String.Length); - ACPI_MEMCPY ((void *) DataSpace, (void *) InternalObject->Buffer.Pointer, - InternalObject->Buffer.Length); + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->Buffer.Pointer, + InternalObject->Buffer.Length); break; @@ -274,7 +326,7 @@ AcpiUtCopyIsimpleToEsimple ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopyIelementToEelement ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, @@ -293,7 +345,7 @@ AcpiUtCopyIelementToEelement ( ThisIndex = State->Pkg.Index; TargetObject = (ACPI_OBJECT *) - &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; + &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; switch (ObjectType) { @@ -318,7 +370,8 @@ AcpiUtCopyIelementToEelement ( */ TargetObject->Type = ACPI_TYPE_PACKAGE; TargetObject->Package.Count = SourceObject->Package.Count; - TargetObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); + TargetObject->Package.Elements = + ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); /* * Pass the new package object back to the package walk routine @@ -330,7 +383,8 @@ AcpiUtCopyIelementToEelement ( * update the buffer length counter */ ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( - (ACPI_SIZE) TargetObject->Package.Count * sizeof (ACPI_OBJECT)); + (ACPI_SIZE) TargetObject->Package.Count * + sizeof (ACPI_OBJECT)); break; @@ -348,9 +402,9 @@ AcpiUtCopyIelementToEelement ( * * FUNCTION: AcpiUtCopyIpackageToEpackage * - * PARAMETERS: *InternalObject - Pointer to the object we are returning - * *Buffer - Where the object is returned - * *SpaceUsed - Where the object length is returned + * PARAMETERS: InternalObject - Pointer to the object we are returning + * Buffer - Where the object is returned + * SpaceUsed - Where the object length is returned * * RETURN: Status * @@ -386,13 +440,15 @@ AcpiUtCopyIpackageToEpackage ( * Free space begins right after the first package */ Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( + sizeof (ACPI_OBJECT)); Info.ObjectSpace = 0; Info.NumPackages = 1; ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject); ExternalObject->Package.Count = InternalObject->Package.Count; - ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, Info.FreeSpace); + ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, + Info.FreeSpace); /* * Leave room for an array of ACPI_OBJECTS in the buffer @@ -404,7 +460,7 @@ AcpiUtCopyIpackageToEpackage ( ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, - AcpiUtCopyIelementToEelement, &Info); + AcpiUtCopyIelementToEelement, &Info); *SpaceUsed = Info.Length; return_ACPI_STATUS (Status); @@ -415,8 +471,8 @@ AcpiUtCopyIpackageToEpackage ( * * FUNCTION: AcpiUtCopyIobjectToEobject * - * PARAMETERS: *InternalObject - The internal object to be converted - * *BufferPtr - Where the object is returned + * PARAMETERS: InternalObject - The internal object to be converted + * BufferPtr - Where the object is returned * * RETURN: Status * @@ -451,10 +507,10 @@ AcpiUtCopyIobjectToEobject ( * Build a simple object (no nested objects) */ Status = AcpiUtCopyIsimpleToEsimple (InternalObject, - (ACPI_OBJECT *) RetBuffer->Pointer, - ((UINT8 *) RetBuffer->Pointer + - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), - &RetBuffer->Length); + (ACPI_OBJECT *) RetBuffer->Pointer, + ((UINT8 *) RetBuffer->Pointer + + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), + &RetBuffer->Length); /* * build simple does not include the object size in the length * so we add it in here @@ -470,8 +526,8 @@ AcpiUtCopyIobjectToEobject ( * * FUNCTION: AcpiUtCopyEsimpleToIsimple * - * PARAMETERS: *ExternalObject - The external object to be converted - * *InternalObject - Where the internal object is returned + * PARAMETERS: ExternalObject - The external object to be converted + * RetInternalObject - Where the internal object is returned * * RETURN: Status * @@ -482,7 +538,7 @@ AcpiUtCopyIobjectToEobject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopyEsimpleToIsimple ( ACPI_OBJECT *ExternalObject, ACPI_OPERAND_OBJECT **RetInternalObject) @@ -502,7 +558,8 @@ AcpiUtCopyEsimpleToIsimple ( case ACPI_TYPE_BUFFER: case ACPI_TYPE_INTEGER: - InternalObject = AcpiUtCreateInternalObject ((UINT8) ExternalObject->Type); + InternalObject = AcpiUtCreateInternalObject ( + (UINT8) ExternalObject->Type); if (!InternalObject) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -510,25 +567,23 @@ AcpiUtCopyEsimpleToIsimple ( break; default: - /* - * Whatever other type -- it is not supported - */ + /* All other types are not supported */ + return_ACPI_STATUS (AE_SUPPORT); } - switch (ExternalObject->Type) - { - /* Must COPY string and buffer contents */ + switch (ExternalObject->Type) + { case ACPI_TYPE_STRING: InternalObject->String.Pointer = ACPI_MEM_CALLOCATE ((ACPI_SIZE) ExternalObject->String.Length + 1); if (!InternalObject->String.Pointer) { - return_ACPI_STATUS (AE_NO_MEMORY); + goto ErrorExit; } ACPI_MEMCPY (InternalObject->String.Pointer, @@ -545,7 +600,7 @@ AcpiUtCopyEsimpleToIsimple ( ACPI_MEM_CALLOCATE (ExternalObject->Buffer.Length); if (!InternalObject->Buffer.Pointer) { - return_ACPI_STATUS (AE_NO_MEMORY); + goto ErrorExit; } ACPI_MEMCPY (InternalObject->Buffer.Pointer, @@ -568,11 +623,15 @@ AcpiUtCopyEsimpleToIsimple ( *RetInternalObject = InternalObject; return_ACPI_STATUS (AE_OK); + + +ErrorExit: + AcpiUtRemoveReference (InternalObject); + return_ACPI_STATUS (AE_NO_MEMORY); } #ifdef ACPI_FUTURE_IMPLEMENTATION - /* Code to convert packages that are parameters to control methods */ /******************************************************************************* @@ -702,7 +761,7 @@ AcpiUtCopyEobjectToIobject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopySimpleObject ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc) @@ -750,7 +809,8 @@ AcpiUtCopySimpleObject ( if (SourceDesc->Buffer.Length) { - DestDesc->Buffer.Pointer = ACPI_MEM_ALLOCATE (SourceDesc->Buffer.Length); + DestDesc->Buffer.Pointer = + ACPI_MEM_ALLOCATE (SourceDesc->Buffer.Length); if (!DestDesc->Buffer.Pointer) { return (AE_NO_MEMORY); @@ -758,8 +818,9 @@ AcpiUtCopySimpleObject ( /* Copy the actual buffer data */ - ACPI_MEMCPY (DestDesc->Buffer.Pointer, SourceDesc->Buffer.Pointer, - SourceDesc->Buffer.Length); + ACPI_MEMCPY (DestDesc->Buffer.Pointer, + SourceDesc->Buffer.Pointer, + SourceDesc->Buffer.Length); } } break; @@ -775,7 +836,8 @@ AcpiUtCopySimpleObject ( if ((SourceDesc->String.Pointer) && (!(SourceDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) { - DestDesc->String.Pointer = ACPI_MEM_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); + DestDesc->String.Pointer = + ACPI_MEM_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); if (!DestDesc->String.Pointer) { return (AE_NO_MEMORY); @@ -786,6 +848,14 @@ AcpiUtCopySimpleObject ( } break; + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * We copied the reference object, so we now must add a reference + * to the object pointed to by the reference + */ + AcpiUtAddReference (SourceDesc->Reference.Object); + break; + default: /* Nothing to do for other simple objects */ break; @@ -807,7 +877,7 @@ AcpiUtCopySimpleObject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopyIelementToIelement ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, @@ -848,7 +918,7 @@ AcpiUtCopyIelementToIelement ( Status = AcpiUtCopySimpleObject (SourceObject, TargetObject); if (ACPI_FAILURE (Status)) { - return (Status); + goto ErrorExit; } *ThisTargetPtr = TargetObject; @@ -885,8 +955,8 @@ AcpiUtCopyIelementToIelement ( sizeof (void *)); if (!TargetObject->Package.Elements) { - ACPI_MEM_FREE (TargetObject); - return (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto ErrorExit; } /* @@ -906,6 +976,10 @@ AcpiUtCopyIelementToIelement ( } return (Status); + +ErrorExit: + AcpiUtRemoveReference (TargetObject); + return (Status); } @@ -923,7 +997,7 @@ AcpiUtCopyIelementToIelement ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopyIpackageToIpackage ( ACPI_OPERAND_OBJECT *SourceObj, ACPI_OPERAND_OBJECT *DestObj, diff --git a/sys/dev/acpi/acpica/Subsystem/utdebug.c b/sys/dev/acpi/acpica/Subsystem/utdebug.c index 63573fb85c3..aa5a0a7cb61 100644 --- a/sys/dev/acpi/acpica/Subsystem/utdebug.c +++ b/sys/dev/acpi/acpica/Subsystem/utdebug.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utdebug - Debug print routines - * xRevision: 111 $ + * xRevision: 115 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utdebug.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utdebug.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __UTDEBUG_C__ @@ -132,7 +132,7 @@ static char *AcpiGbl_FnEntryStr = "----Entry"; static char *AcpiGbl_FnExitStr = "----Exit-"; -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtInitStackPtrTrace * @@ -140,9 +140,9 @@ static char *AcpiGbl_FnExitStr = "----Exit-"; * * RETURN: None * - * DESCRIPTION: Save the current stack pointer + * DESCRIPTION: Save the current CPU stack pointer at subsystem startup * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtInitStackPtrTrace ( @@ -155,7 +155,7 @@ AcpiUtInitStackPtrTrace ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTrackStackPtr * @@ -163,9 +163,9 @@ AcpiUtInitStackPtrTrace ( * * RETURN: None * - * DESCRIPTION: Save the current stack pointer + * DESCRIPTION: Save the current CPU stack pointer * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTrackStackPtr ( @@ -188,16 +188,16 @@ AcpiUtTrackStackPtr ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtDebugPrint * - * PARAMETERS: DebugLevel - Requested debug print level - * ProcName - Caller's procedure name - * ModuleName - Caller's module name (for error output) + * PARAMETERS: RequestedDebugLevel - Requested debug print level * LineNumber - Caller's line number (for error output) - * ComponentId - Caller's component ID (for error output) - * + * DbgInfo - Contains: + * ProcName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * Format - Printf format field * ... - Optional printf arguments * @@ -206,7 +206,7 @@ AcpiUtTrackStackPtr ( * DESCRIPTION: Print error message with prefix consisting of the module name, * line number, and component ID. * - ****************************************************************************/ + ******************************************************************************/ void ACPI_INTERNAL_VAR_XFACE AcpiUtDebugPrint ( @@ -238,7 +238,8 @@ AcpiUtDebugPrint ( { if (ACPI_LV_THREADS & AcpiDbgLevel) { - AcpiOsPrintf ("\n**** Context Switch from TID %X to TID %X ****\n\n", + AcpiOsPrintf ( + "\n**** Context Switch from TID %X to TID %X ****\n\n", AcpiGbl_PrevThreadId, ThreadId); } @@ -256,14 +257,15 @@ AcpiUtDebugPrint ( AcpiOsPrintf ("[%04lX] ", ThreadId); } - AcpiOsPrintf ("[%02ld] %-22.22s: ", AcpiGbl_NestingLevel, DbgInfo->ProcName); + AcpiOsPrintf ("[%02ld] %-22.22s: ", + AcpiGbl_NestingLevel, DbgInfo->ProcName); va_start (args, Format); AcpiOsVprintf (Format, args); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtDebugPrintRaw * @@ -281,7 +283,7 @@ AcpiUtDebugPrint ( * DESCRIPTION: Print message with no headers. Has same interface as * DebugPrint so that the same macros can be used. * - ****************************************************************************/ + ******************************************************************************/ void ACPI_INTERNAL_VAR_XFACE AcpiUtDebugPrintRaw ( @@ -305,7 +307,7 @@ AcpiUtDebugPrintRaw ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTrace * @@ -320,7 +322,7 @@ AcpiUtDebugPrintRaw ( * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTrace ( @@ -336,7 +338,7 @@ AcpiUtTrace ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTracePtr * @@ -352,7 +354,7 @@ AcpiUtTrace ( * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTracePtr ( @@ -368,7 +370,7 @@ AcpiUtTracePtr ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTraceStr * @@ -384,7 +386,7 @@ AcpiUtTracePtr ( * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTraceStr ( @@ -401,7 +403,7 @@ AcpiUtTraceStr ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTraceU32 * @@ -417,7 +419,7 @@ AcpiUtTraceStr ( * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTraceU32 ( @@ -434,7 +436,7 @@ AcpiUtTraceU32 ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtExit * @@ -449,7 +451,7 @@ AcpiUtTraceU32 ( * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtExit ( @@ -464,7 +466,7 @@ AcpiUtExit ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtStatusExit * @@ -480,7 +482,7 @@ AcpiUtExit ( * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel. Prints exit status also. * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtStatusExit ( @@ -506,7 +508,7 @@ AcpiUtStatusExit ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtValueExit * @@ -522,7 +524,7 @@ AcpiUtStatusExit ( * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel. Prints exit value also. * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtValueExit ( @@ -539,7 +541,7 @@ AcpiUtValueExit ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtPtrExit * @@ -548,14 +550,14 @@ AcpiUtValueExit ( * ProcName - Caller's procedure name * ModuleName - Caller's module name * ComponentId - Caller's component ID - * Value - Value to be printed with exit msg + * Ptr - Pointer to display * * RETURN: None * * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel. Prints exit value also. * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtPtrExit ( @@ -573,7 +575,7 @@ AcpiUtPtrExit ( #endif -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtDumpBuffer * @@ -586,7 +588,7 @@ AcpiUtPtrExit ( * * DESCRIPTION: Generic dump buffer in both hex and ascii. * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtDumpBuffer ( @@ -614,16 +616,13 @@ AcpiUtDumpBuffer ( Display = DB_BYTE_DISPLAY; } - AcpiOsPrintf ("\nOffset Value\n"); + /* Nasty little dump buffer routine! */ - /* - * Nasty little dump buffer routine! - */ while (i < Count) { /* Print current offset */ - AcpiOsPrintf ("%05X ", (UINT32) i); + AcpiOsPrintf ("%6.4X: ", (UINT32) i); /* Print 16 hex chars */ @@ -631,21 +630,18 @@ AcpiUtDumpBuffer ( { if (i + j >= Count) { - AcpiOsPrintf ("\n"); - return; - } + /* Dump fill spaces */ - /* Make sure that the INT8 doesn't get sign-extended! */ + AcpiOsPrintf ("%*s", ((Display * 2) + 1), " "); + j += Display; + continue; + } switch (Display) { - /* Default is BYTE display */ - - default: + default: /* Default is BYTE display */ - AcpiOsPrintf ("%02X ", - *((UINT8 *) &Buffer[i + j])); - j += 1; + AcpiOsPrintf ("%02X ", Buffer[i + j]); break; @@ -653,7 +649,6 @@ AcpiUtDumpBuffer ( ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[i + j]); AcpiOsPrintf ("%04X ", Temp32); - j += 2; break; @@ -661,7 +656,6 @@ AcpiUtDumpBuffer ( ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j]); AcpiOsPrintf ("%08X ", Temp32); - j += 4; break; @@ -672,15 +666,17 @@ AcpiUtDumpBuffer ( ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j + 4]); AcpiOsPrintf ("%08X ", Temp32); - j += 8; break; } + + j += Display; } /* * Print the ASCII equivalent characters * But watch out for the bad unprintable ones... */ + AcpiOsPrintf (" "); for (j = 0; j < 16; j++) { if (i + j >= Count) diff --git a/sys/dev/acpi/acpica/Subsystem/utdelete.c b/sys/dev/acpi/acpica/Subsystem/utdelete.c index dca4a30a597..791a457454f 100644 --- a/sys/dev/acpi/acpica/Subsystem/utdelete.c +++ b/sys/dev/acpi/acpica/Subsystem/utdelete.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utdelete - object deletion and reference count utilities - * xRevision: 99 $ + * xRevision: 105 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utdelete.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utdelete.c,v 1.13 2005/05/02 14:52:10 kochi Exp $"); #define __UTDELETE_C__ @@ -123,16 +123,28 @@ __KERNEL_RCSID(0, "$NetBSD: utdelete.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); #include "acinterp.h" #include "acnamesp.h" #include "acevents.h" +#include "amlcode.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdelete") +/* Local prototypes */ + +static void +AcpiUtDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object); + +static void +AcpiUtUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action); + /******************************************************************************* * * FUNCTION: AcpiUtDeleteInternalObj * - * PARAMETERS: *Object - Pointer to the list to be deleted + * PARAMETERS: Object - Object to be deleted * * RETURN: None * @@ -141,7 +153,7 @@ __KERNEL_RCSID(0, "$NetBSD: utdelete.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); * ******************************************************************************/ -void +static void AcpiUtDeleteInternalObj ( ACPI_OPERAND_OBJECT *Object) { @@ -234,7 +246,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_MUTEX: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Mutex %p, Semaphore %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Mutex %p, Semaphore %p\n", Object, Object->Mutex.Semaphore)); AcpiExUnlinkMutex (Object); @@ -244,7 +257,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_EVENT: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Event %p, Semaphore %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Event %p, Semaphore %p\n", Object, Object->Event.Semaphore)); (void) AcpiOsDeleteSemaphore (Object->Event.Semaphore); @@ -254,7 +268,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_METHOD: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Method %p\n", Object)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Method %p\n", Object)); /* Delete the method semaphore if it exists */ @@ -268,7 +283,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_REGION: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Region %p\n", Object)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Region %p\n", Object)); SecondDesc = AcpiNsGetSecondaryObject (Object); if (SecondDesc) @@ -298,7 +314,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_BUFFER_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Buffer Field %p\n", Object)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Buffer Field %p\n", Object)); SecondDesc = AcpiNsGetSecondaryObject (Object); if (SecondDesc) @@ -335,7 +352,7 @@ AcpiUtDeleteInternalObj ( * * FUNCTION: AcpiUtDeleteInternalObjectList * - * PARAMETERS: *ObjList - Pointer to the list to be deleted + * PARAMETERS: ObjList - Pointer to the list to be deleted * * RETURN: None * @@ -372,7 +389,7 @@ AcpiUtDeleteInternalObjectList ( * * FUNCTION: AcpiUtUpdateRefCount * - * PARAMETERS: *Object - Object whose ref count is to be updated + * PARAMETERS: Object - Object whose ref count is to be updated * Action - What to do * * RETURN: New ref count @@ -402,7 +419,8 @@ AcpiUtUpdateRefCount ( NewCount = Count; /* - * Perform the reference count action (increment, decrement, or force delete) + * Perform the reference count action + * (increment, decrement, or force delete) */ switch (Action) { @@ -412,7 +430,8 @@ AcpiUtUpdateRefCount ( NewCount++; Object->Common.ReferenceCount = NewCount; - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Incremented]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Incremented]\n", Object, NewCount)); break; @@ -421,7 +440,8 @@ AcpiUtUpdateRefCount ( if (Count < 1) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, can't decrement! (Set to 0)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, can't decrement! (Set to 0)\n", Object, NewCount)); NewCount = 0; @@ -430,13 +450,15 @@ AcpiUtUpdateRefCount ( { NewCount--; - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Decremented]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); } if (ACPI_GET_OBJECT_TYPE (Object) == ACPI_TYPE_METHOD) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Method Obj %p Refs=%X, [Decremented]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); } @@ -451,7 +473,8 @@ AcpiUtUpdateRefCount ( case REF_FORCE_DELETE: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, Force delete! (Set to 0)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count)); NewCount = 0; @@ -486,7 +509,7 @@ AcpiUtUpdateRefCount ( * * FUNCTION: AcpiUtUpdateObjectReference * - * PARAMETERS: *Object - Increment ref count for this object + * PARAMETERS: Object - Increment ref count for this object * and all sub-objects * Action - Either REF_INCREMENT or REF_DECREMENT or * REF_FORCE_DELETE @@ -529,7 +552,8 @@ AcpiUtUpdateObjectReference ( if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p is NS handle\n", Object)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Object %p is NS handle\n", Object)); return_ACPI_STATUS (AE_OK); } @@ -635,8 +659,25 @@ AcpiUtUpdateObjectReference ( break; - case ACPI_TYPE_REGION: case ACPI_TYPE_LOCAL_REFERENCE: + + /* + * The target of an Index (a package, string, or buffer) must track + * changes to the ref count of the index. + */ + if (Object->Reference.Opcode == AML_INDEX_OP) + { + Status = AcpiUtCreateUpdateStateAndPush ( + Object->Reference.Object, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + } + break; + + + case ACPI_TYPE_REGION: default: /* No subobjects */ @@ -671,8 +712,8 @@ ErrorExit: * * FUNCTION: AcpiUtAddReference * - * PARAMETERS: *Object - Object whose reference count is to be - * incremented + * PARAMETERS: Object - Object whose reference count is to be + * incremented * * RETURN: None * @@ -695,6 +736,10 @@ AcpiUtAddReference ( return_VOID; } + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Incremented]\n", + Object, Object->Common.ReferenceCount)); + /* Increment the reference count */ (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); @@ -706,7 +751,7 @@ AcpiUtAddReference ( * * FUNCTION: AcpiUtRemoveReference * - * PARAMETERS: *Object - Object whose ref count will be decremented + * PARAMETERS: Object - Object whose ref count will be decremented * * RETURN: None * @@ -741,8 +786,9 @@ AcpiUtRemoveReference ( return_VOID; } - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X\n", - Object, Object->Common.ReferenceCount)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Decremented]\n", + Object, Object->Common.ReferenceCount)); /* * Decrement the reference count, and only actually delete the object diff --git a/sys/dev/acpi/acpica/Subsystem/uteval.c b/sys/dev/acpi/acpica/Subsystem/uteval.c index 606060de073..835c9df3067 100644 --- a/sys/dev/acpi/acpica/Subsystem/uteval.c +++ b/sys/dev/acpi/acpica/Subsystem/uteval.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: uteval - Object evaluation - * xRevision: 50 $ + * xRevision: 59 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uteval.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uteval.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __UTEVAL_C__ @@ -127,6 +127,79 @@ __KERNEL_RCSID(0, "$NetBSD: uteval.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("uteval") +/* Local prototypes */ + +static void +AcpiUtCopyIdString ( + char *Destination, + char *Source, + ACPI_SIZE MaxLength); + +static ACPI_STATUS +AcpiUtTranslateOneCid ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_COMPATIBLE_ID *OneCid); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtOsiImplementation + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Implementation of _OSI predefined control method + * Supported = _OSI (String) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtOsiImplementation ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *StringDesc; + ACPI_OPERAND_OBJECT *ReturnDesc; + ACPI_NATIVE_UINT i; + + + ACPI_FUNCTION_TRACE ("UtOsiImplementation"); + + + /* Validate the string input argument */ + + StringDesc = WalkState->Arguments[0].Object; + if (!StringDesc || (StringDesc->Common.Type != ACPI_TYPE_STRING)) + { + return_ACPI_STATUS (AE_TYPE); + } + + /* Create a return object (Default value = 0) */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Compare input string to table of supported strings */ + + for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) + { + if (!ACPI_STRCMP (StringDesc->String.Pointer, + (char *) AcpiGbl_ValidOsiStrings[i])) + { + /* This string is supported */ + + ReturnDesc->Integer.Value = 0xFFFFFFFF; + break; + } + } + + WalkState->ReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_CTRL_TERMINATE); +} + /******************************************************************************* * @@ -154,7 +227,7 @@ AcpiUtEvaluateObject ( UINT32 ExpectedReturnBtypes, ACPI_OPERAND_OBJECT **ReturnDesc) { - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARAMETER_INFO Info; ACPI_STATUS Status; UINT32 ReturnBtype; @@ -162,9 +235,13 @@ AcpiUtEvaluateObject ( ACPI_FUNCTION_TRACE ("UtEvaluateObject"); + Info.Node = PrefixNode; + Info.Parameters = NULL; + Info.ParameterType = ACPI_PARAM_ARGS; + /* Evaluate the object/method */ - Status = AcpiNsEvaluateRelative (PrefixNode, Path, NULL, &ObjDesc); + Status = AcpiNsEvaluateRelative (Path, &Info); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -183,7 +260,7 @@ AcpiUtEvaluateObject ( /* Did we get a return object? */ - if (!ObjDesc) + if (!Info.ReturnObject) { if (ExpectedReturnBtypes) { @@ -198,7 +275,7 @@ AcpiUtEvaluateObject ( /* Map the return object type to the bitmapped type */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + switch (ACPI_GET_OBJECT_TYPE (Info.ReturnObject)) { case ACPI_TYPE_INTEGER: ReturnBtype = ACPI_BTYPE_INTEGER; @@ -221,6 +298,18 @@ AcpiUtEvaluateObject ( break; } + if ((AcpiGbl_EnableInterpreterSlack) && + (!ExpectedReturnBtypes)) + { + /* + * We received a return object, but one was not expected. This can + * happen frequently if the "implicit return" feature is enabled. + * Just delete the return object and return AE_OK. + */ + AcpiUtRemoveReference (Info.ReturnObject); + return_ACPI_STATUS (AE_OK); + } + /* Is the return object one of the expected types? */ if (!(ExpectedReturnBtypes & ReturnBtype)) @@ -229,18 +318,19 @@ AcpiUtEvaluateObject ( PrefixNode, Path, AE_TYPE); ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Type returned from %s was incorrect: %X\n", - Path, ACPI_GET_OBJECT_TYPE (ObjDesc))); + "Type returned from %s was incorrect: %s, expected Btypes: %X\n", + Path, AcpiUtGetObjectTypeName (Info.ReturnObject), + ExpectedReturnBtypes)); /* On error exit, we must delete the return object */ - AcpiUtRemoveReference (ObjDesc); + AcpiUtRemoveReference (Info.ReturnObject); return_ACPI_STATUS (AE_TYPE); } /* Object type is OK, return it */ - *ReturnDesc = ObjDesc; + *ReturnDesc = Info.ReturnObject; return_ACPI_STATUS (AE_OK); } @@ -249,9 +339,9 @@ AcpiUtEvaluateObject ( * * FUNCTION: AcpiUtEvaluateNumericObject * - * PARAMETERS: *ObjectName - Object name to be evaluated + * PARAMETERS: ObjectName - Object name to be evaluated * DeviceNode - Node for the device - * *Address - Where the value is returned + * Address - Where the value is returned * * RETURN: Status * @@ -316,7 +406,6 @@ AcpiUtCopyIdString ( ACPI_SIZE MaxLength) { - /* * Workaround for ID strings that have a leading asterisk. This construct * is not allowed by the ACPI specification (ID strings must be @@ -339,7 +428,7 @@ AcpiUtCopyIdString ( * FUNCTION: AcpiUtExecute_HID * * PARAMETERS: DeviceNode - Node for the device - * *Hid - Where the HID is returned + * Hid - Where the HID is returned * * RETURN: Status * @@ -448,7 +537,7 @@ AcpiUtTranslateOneCid ( * FUNCTION: AcpiUtExecute_CID * * PARAMETERS: DeviceNode - Node for the device - * *Cid - Where the CID is returned + * ReturnCidList - Where the CID list is returned * * RETURN: Status * @@ -510,10 +599,10 @@ AcpiUtExecute_CID ( CidList->Size = Size; /* - * A _CID can return either a single compatible ID or a package of compatible - * IDs. Each compatible ID can be one of the following: - * -- Number (32 bit compressed EISA ID) or - * -- String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss"). + * A _CID can return either a single compatible ID or a package of + * compatible IDs. Each compatible ID can be one of the following: + * 1) Integer (32 bit compressed EISA ID) or + * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") */ /* The _CID object can be either a single CID or a package (list) of CIDs */ @@ -562,7 +651,7 @@ AcpiUtExecute_CID ( * FUNCTION: AcpiUtExecute_UID * * PARAMETERS: DeviceNode - Node for the device - * *Uid - Where the UID is returned + * Uid - Where the UID is returned * * RETURN: Status * @@ -618,7 +707,7 @@ AcpiUtExecute_UID ( * FUNCTION: AcpiUtExecute_STA * * PARAMETERS: DeviceNode - Node for the device - * *Flags - Where the status flags are returned + * Flags - Where the status flags are returned * * RETURN: Status * @@ -667,3 +756,67 @@ AcpiUtExecute_STA ( AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_Sxds + * + * PARAMETERS: DeviceNode - Node for the device + * Flags - Where the status flags are returned + * + * RETURN: Status + * + * DESCRIPTION: Executes _STA for selected device and stores results in + * *Flags. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_Sxds ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT8 *Highest) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE ("UtExecute_Sxds"); + + + for (i = 0; i < 4; i++) + { + Highest[i] = 0xFF; + Status = AcpiUtEvaluateObject (DeviceNode, + (char *) AcpiGbl_HighestDstateNames[i], + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (Status != AE_NOT_FOUND) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%s on Device %4.4s, %s\n", + (char *) AcpiGbl_HighestDstateNames[i], + AcpiUtGetNodeName (DeviceNode), + AcpiFormatException (Status))); + + return_ACPI_STATUS (Status); + } + } + else + { + /* Extract the Dstate value */ + + Highest[i] = (UINT8) ObjDesc->Integer.Value; + + /* Delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + } + } + + return_ACPI_STATUS (AE_OK); +} diff --git a/sys/dev/acpi/acpica/Subsystem/utglobal.c b/sys/dev/acpi/acpica/Subsystem/utglobal.c index 73eba925f00..1701f828814 100644 --- a/sys/dev/acpi/acpica/Subsystem/utglobal.c +++ b/sys/dev/acpi/acpica/Subsystem/utglobal.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utglobal - Global variables for the ACPI subsystem - * xRevision: 192 $ + * xRevision: 211 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utglobal.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utglobal.c,v 1.12 2005/05/02 14:52:10 kochi Exp $"); #define __UTGLOBAL_C__ #define DEFINE_ACPI_GLOBALS @@ -127,13 +127,14 @@ __KERNEL_RCSID(0, "$NetBSD: utglobal.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); ACPI_MODULE_NAME ("utglobal") -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiFormatException * * PARAMETERS: Status - The ACPI_STATUS code to be formatted * - * RETURN: A string containing the exception text + * RETURN: A string containing the exception text. A valid pointer is + * always returned. * * DESCRIPTION: This function translates an ACPI exception into an ASCII string. * @@ -143,8 +144,8 @@ const char * AcpiFormatException ( ACPI_STATUS Status) { - const char *Exception = "UNKNOWN_STATUS_CODE"; ACPI_STATUS SubStatus; + const char *Exception = NULL; ACPI_FUNCTION_NAME ("FormatException"); @@ -159,61 +160,60 @@ AcpiFormatException ( if (SubStatus <= AE_CODE_ENV_MAX) { Exception = AcpiGbl_ExceptionNames_Env [SubStatus]; - break; } - goto Unknown; + break; case AE_CODE_PROGRAMMER: if (SubStatus <= AE_CODE_PGM_MAX) { Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1]; - break; } - goto Unknown; + break; case AE_CODE_ACPI_TABLES: if (SubStatus <= AE_CODE_TBL_MAX) { Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1]; - break; } - goto Unknown; + break; case AE_CODE_AML: if (SubStatus <= AE_CODE_AML_MAX) { Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1]; - break; } - goto Unknown; + break; case AE_CODE_CONTROL: if (SubStatus <= AE_CODE_CTRL_MAX) { Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1]; - break; } - goto Unknown; + break; default: - goto Unknown; + break; } + if (!Exception) + { + /* Exception code was not recognized */ - return ((const char *) Exception); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown exception code: 0x%8.8X\n", Status)); -Unknown: + return ((const char *) "UNKNOWN_STATUS_CODE"); + } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", Status)); return ((const char *) Exception); } -/****************************************************************************** +/******************************************************************************* * * Static global variable initialization. * @@ -254,56 +254,87 @@ BOOLEAN AcpiGbl_Shutdown = TRUE; const UINT8 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128}; -const char *AcpiGbl_DbSleepStates[ACPI_S_STATE_COUNT] = { - "\\_S0_", - "\\_S1_", - "\\_S2_", - "\\_S3_", - "\\_S4_", - "\\_S5_"}; +const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = +{ + "\\_S0_", + "\\_S1_", + "\\_S2_", + "\\_S3_", + "\\_S4_", + "\\_S5_" +}; +const char *AcpiGbl_HighestDstateNames[4] = +{ + "_S1D", + "_S2D", + "_S3D", + "_S4D" +}; -/****************************************************************************** +/* + * Strings supported by the _OSI predefined (internal) method. + * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS. + */ +const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] = +{ + /* Operating System Vendor Strings */ + + "Linux", + "Windows 2000", + "Windows 2001", + "Windows 2001.1", + "Windows 2001 SP0", + "Windows 2001 SP1", + "Windows 2001 SP2", + "Windows 2001 SP3", + "Windows 2001 SP4", + + /* Feature Group Strings */ + + "Extended Address Space Descriptor" +}; + + +/******************************************************************************* * * Namespace globals * ******************************************************************************/ - /* * Predefined ACPI Names (Built-in to the Interpreter) * - * Initial values are currently supported only for types String and Number. - * Both are specified as strings in this table. - * * NOTES: - * 1) _SB_ is defined to be a device to allow _SB_/_INI to be run + * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run * during the initialization sequence. + * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to + * perform a Notify() operation on it. */ - const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, {"_SB_", ACPI_TYPE_DEVICE, NULL}, {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_TZ_", ACPI_TYPE_LOCAL_SCOPE, NULL}, - {"_REV", ACPI_TYPE_INTEGER, "2"}, + {"_TZ_", ACPI_TYPE_THERMAL, NULL}, + {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, - {"_GL_", ACPI_TYPE_MUTEX, "0"}, + {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, -#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) - {"_OSI", ACPI_TYPE_METHOD, "1"}, +#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) + {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, #endif - {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */ -}; + /* Table terminator */ + + {NULL, ACPI_TYPE_ANY, NULL} +}; /* * Properties of the ACPI Object Types, both internal and external. * The table is indexed by values of ACPI_OBJECT_TYPE */ - const UINT8 AcpiGbl_NsProperties[] = { ACPI_NS_NORMAL, /* 00 Any */ @@ -328,36 +359,40 @@ const UINT8 AcpiGbl_NsProperties[] = ACPI_NS_NORMAL, /* 19 IndexField */ ACPI_NS_NORMAL, /* 20 Reference */ ACPI_NS_NORMAL, /* 21 Alias */ - ACPI_NS_NORMAL, /* 22 Notify */ - ACPI_NS_NORMAL, /* 23 Address Handler */ - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 24 Resource Desc */ - ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Field */ - ACPI_NS_NEWSCOPE, /* 26 Scope */ - ACPI_NS_NORMAL, /* 27 Extra */ - ACPI_NS_NORMAL, /* 28 Data */ - ACPI_NS_NORMAL /* 29 Invalid */ + ACPI_NS_NORMAL, /* 22 MethodAlias */ + ACPI_NS_NORMAL, /* 23 Notify */ + ACPI_NS_NORMAL, /* 24 Address Handler */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ + ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ + ACPI_NS_NEWSCOPE, /* 27 Scope */ + ACPI_NS_NORMAL, /* 28 Extra */ + ACPI_NS_NORMAL, /* 29 Data */ + ACPI_NS_NORMAL /* 30 Invalid */ }; /* Hex to ASCII conversion table */ static const char AcpiGbl_HexToAscii[] = - {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; +{ + '0','1','2','3','4','5','6','7', + '8','9','A','B','C','D','E','F' +}; + -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtHexToAsciiChar * * PARAMETERS: Integer - Contains the hex digit * Position - bit position of the digit within the - * integer + * integer (multiple of 4) * - * RETURN: Ascii character + * RETURN: The converted Ascii character * - * DESCRIPTION: Convert a hex digit to an ascii character + * DESCRIPTION: Convert a hex digit to an Ascii character * - ****************************************************************************/ + ******************************************************************************/ char AcpiUtHexToAsciiChar ( @@ -369,7 +404,7 @@ AcpiUtHexToAsciiChar ( } -/****************************************************************************** +/******************************************************************************* * * Table name globals * @@ -378,14 +413,12 @@ AcpiUtHexToAsciiChar ( * that are not used by the subsystem are simply ignored. * * Do NOT add any table to this list that is not consumed directly by this - * subsystem. + * subsystem (No MADT, ECDT, SBST, etc.) * ******************************************************************************/ - ACPI_TABLE_LIST AcpiGbl_TableLists[NUM_ACPI_TABLE_TYPES]; - ACPI_TABLE_SUPPORT AcpiGbl_TableData[NUM_ACPI_TABLE_TYPES] = { /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */ @@ -417,6 +450,7 @@ ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, + /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, @@ -424,6 +458,7 @@ ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, + /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, @@ -445,7 +480,7 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, }; -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetRegionName * @@ -455,7 +490,7 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = * * DESCRIPTION: Translate a Space ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ /* Region type decoding */ @@ -483,7 +518,6 @@ AcpiUtGetRegionName ( { return ("UserDefinedRegion"); } - else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) { return ("InvalidSpaceId"); @@ -493,7 +527,7 @@ AcpiUtGetRegionName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetEventName * @@ -503,7 +537,7 @@ AcpiUtGetRegionName ( * * DESCRIPTION: Translate a Event ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ /* Event type decoding */ @@ -531,7 +565,7 @@ AcpiUtGetEventName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetTypeName * @@ -541,21 +575,21 @@ AcpiUtGetEventName ( * * DESCRIPTION: Translate a Type ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ /* * Elements of AcpiGbl_NsTypeNames below must match * one-to-one with values of ACPI_OBJECT_TYPE * - * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when - * stored in a table it really means that we have thus far seen no evidence to - * indicatewhat type is actually going to be stored for this entry. + * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; + * when stored in a table it really means that we have thus far seen no + * evidence to indicate what type is actually going to be stored for this entry. */ - static const char AcpiGbl_BadType[] = "UNDEFINED"; -#define TYPE_NAME_LENGTH 12 /* Maximum length of each string */ -static const char *AcpiGbl_NsTypeNames[] = /* printable names of ACPI types */ +/* Printable names of the ACPI object types */ + +static const char *AcpiGbl_NsTypeNames[] = { /* 00 */ "Untyped", /* 01 */ "Integer", @@ -579,14 +613,15 @@ static const char *AcpiGbl_NsTypeNames[] = /* printable names of AC /* 19 */ "IndexField", /* 20 */ "Reference", /* 21 */ "Alias", - /* 22 */ "Notify", - /* 23 */ "AddrHandler", - /* 24 */ "ResourceDesc", - /* 25 */ "ResourceFld", - /* 26 */ "Scope", - /* 27 */ "Extra", - /* 28 */ "Data", - /* 39 */ "Invalid" + /* 22 */ "MethodAlias", + /* 23 */ "Notify", + /* 24 */ "AddrHandler", + /* 25 */ "ResourceDesc", + /* 26 */ "ResourceFld", + /* 27 */ "Scope", + /* 28 */ "Extra", + /* 29 */ "Data", + /* 30 */ "Invalid" }; @@ -618,7 +653,7 @@ AcpiUtGetObjectTypeName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetNodeName * @@ -628,37 +663,51 @@ AcpiUtGetObjectTypeName ( * * DESCRIPTION: Validate the node and return the node's ACPI name. * - ****************************************************************************/ + ******************************************************************************/ char * AcpiUtGetNodeName ( void *Object) { - ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object; + + /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ if (!Object) { - return ("NULL NODE"); + return ("NULL"); + } + + /* Check for Root node */ + + if ((Object == ACPI_ROOT_OBJECT) || + (Object == AcpiGbl_RootNode)) + { + return ("\"\\\" "); } - Node = (ACPI_NAMESPACE_NODE *) Object; + /* Descriptor must be a namespace node */ if (Node->Descriptor != ACPI_DESC_TYPE_NAMED) { - return ("****"); + return ("####"); } + /* Name must be a valid ACPI name */ + if (!AcpiUtValidAcpiName (* (UINT32 *) Node->Name.Ascii)) { - return ("----"); + return ("????"); } + /* Return the name */ + return (Node->Name.Ascii); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetDescriptorName * @@ -668,9 +717,11 @@ AcpiUtGetNodeName ( * * DESCRIPTION: Validate object and return the descriptor type * - ****************************************************************************/ + ******************************************************************************/ + +/* Printable names of object descriptor types */ -static const char *AcpiGbl_DescTypeNames[] = /* printable names of descriptor types */ +static const char *AcpiGbl_DescTypeNames[] = { /* 00 */ "Invalid", /* 01 */ "Cached", @@ -716,17 +767,18 @@ AcpiUtGetDescriptorName ( * Strings and procedures used for debug only */ -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetMutexName * - * PARAMETERS: None. + * PARAMETERS: MutexId - The predefined ID for this mutex. * - * RETURN: Status + * RETURN: String containing the name of the mutex. Always returns a valid + * pointer. * * DESCRIPTION: Translate a mutex ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ char * AcpiUtGetMutexName ( @@ -740,21 +792,20 @@ AcpiUtGetMutexName ( return (AcpiGbl_MutexNames[MutexId]); } - #endif -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtValidObjectType * * PARAMETERS: Type - Object type to be validated * - * RETURN: TRUE if valid object type + * RETURN: TRUE if valid object type, FALSE otherwise * * DESCRIPTION: Validate an object type * - ****************************************************************************/ + ******************************************************************************/ BOOLEAN AcpiUtValidObjectType ( @@ -772,7 +823,7 @@ AcpiUtValidObjectType ( } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtAllocateOwnerId * @@ -780,7 +831,10 @@ AcpiUtValidObjectType ( * * DESCRIPTION: Allocate a table or method owner id * - ***************************************************************************/ + * NOTE: This algorithm has a wraparound problem at 64K method invocations, and + * should be revisited (TBD) + * + ******************************************************************************/ ACPI_OWNER_ID AcpiUtAllocateOwnerId ( @@ -836,16 +890,18 @@ AcpiUtAllocateOwnerId ( } -/**************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtInitGlobals * - * PARAMETERS: none + * PARAMETERS: None + * + * RETURN: None * * DESCRIPTION: Init library globals. All globals that require specific * initialization should be initialized here! * - ***************************************************************************/ + ******************************************************************************/ void AcpiUtInitGlobals ( @@ -856,6 +912,7 @@ AcpiUtInitGlobals ( ACPI_FUNCTION_TRACE ("UtInitGlobals"); + /* Memory allocation and cache lists */ ACPI_MEMSET (AcpiGbl_MemoryLists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS); @@ -914,6 +971,7 @@ AcpiUtInitGlobals ( AcpiGbl_SystemNotify.Handler = NULL; AcpiGbl_DeviceNotify.Handler = NULL; + AcpiGbl_ExceptionHandler = NULL; AcpiGbl_InitHandler = NULL; /* Global "typed" ACPI table pointers */ @@ -948,6 +1006,7 @@ AcpiUtInitGlobals ( /* Hardware oriented */ AcpiGbl_EventsInitialized = FALSE; + AcpiGbl_SystemAwakeAndRunning = TRUE; /* Namespace */ diff --git a/sys/dev/acpi/acpica/Subsystem/utinit.c b/sys/dev/acpi/acpica/Subsystem/utinit.c index 87c7d22e4a3..25d9b94b2b8 100644 --- a/sys/dev/acpi/acpica/Subsystem/utinit.c +++ b/sys/dev/acpi/acpica/Subsystem/utinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utinit - Common ACPI subsystem initialization - * xRevision: 118 $ + * xRevision: 122 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utinit.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utinit.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __UTINIT_C__ @@ -127,19 +127,29 @@ __KERNEL_RCSID(0, "$NetBSD: utinit.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utinit") +/* Local prototypes */ + +static void +AcpiUtFadtRegisterError ( + char *RegisterName, + UINT32 Value, + ACPI_SIZE Offset); + +static void AcpiUtTerminate ( + void); + /******************************************************************************* * * FUNCTION: AcpiUtFadtRegisterError * - * PARAMETERS: *RegisterName - Pointer to string identifying register + * PARAMETERS: RegisterName - Pointer to string identifying register * Value - Actual register contents value - * AcpiTestSpecSection - TDS section containing assertion - * AcpiAssertion - Assertion number being tested + * Offset - Byte offset in the FADT * * RETURN: AE_BAD_VALUE * - * DESCRIPTION: Display failure message and link failure to TDS assertion + * DESCRIPTION: Display failure message * ******************************************************************************/ @@ -253,12 +263,13 @@ AcpiUtValidateFadt ( * * RETURN: none * - * DESCRIPTION: free global memory + * DESCRIPTION: Free global memory * ******************************************************************************/ -void -AcpiUtTerminate (void) +static void +AcpiUtTerminate ( + void) { ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_GPE_BLOCK_INFO *NextGpeBlock; @@ -270,8 +281,6 @@ AcpiUtTerminate (void) /* Free global tables, etc. */ - - /* Free global GPE blocks and related info structures */ GpeXruptInfo = AcpiGbl_GpeXruptListHead; @@ -310,7 +319,8 @@ AcpiUtTerminate (void) ******************************************************************************/ void -AcpiUtSubsystemShutdown (void) +AcpiUtSubsystemShutdown ( + void) { ACPI_FUNCTION_TRACE ("UtSubsystemShutdown"); @@ -319,14 +329,16 @@ AcpiUtSubsystemShutdown (void) if (AcpiGbl_Shutdown) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "ACPI Subsystem is already terminated\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "ACPI Subsystem is already terminated\n")); return_VOID; } /* Subsystem appears active, go ahead and shut it down */ AcpiGbl_Shutdown = TRUE; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Shutting down ACPI Subsystem...\n")); /* Close the AcpiEvent Handling */ diff --git a/sys/dev/acpi/acpica/Subsystem/utmath.c b/sys/dev/acpi/acpica/Subsystem/utmath.c index 91f3aadd3f8..7e9938c3297 100644 --- a/sys/dev/acpi/acpica/Subsystem/utmath.c +++ b/sys/dev/acpi/acpica/Subsystem/utmath.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utmath - Integer math support routines - * xRevision: 13 $ + * xRevision: 16 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utmath.c,v 1.9 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utmath.c,v 1.10 2005/05/02 14:52:10 kochi Exp $"); #define __UTMATH_C__ @@ -137,7 +137,7 @@ __KERNEL_RCSID(0, "$NetBSD: utmath.c,v 1.9 2004/02/14 16:57:25 kochi Exp $"); * * FUNCTION: AcpiUtShortDivide * - * PARAMETERS: InDividend - Pointer to the dividend + * PARAMETERS: Dividend - 64-bit dividend * Divisor - 32-bit divisor * OutQuotient - Pointer to where the quotient is returned * OutRemainder - Pointer to where the remainder is returned @@ -152,19 +152,18 @@ __KERNEL_RCSID(0, "$NetBSD: utmath.c,v 1.9 2004/02/14 16:57:25 kochi Exp $"); ACPI_STATUS AcpiUtShortDivide ( - ACPI_INTEGER *InDividend, + ACPI_INTEGER Dividend, UINT32 Divisor, ACPI_INTEGER *OutQuotient, UINT32 *OutRemainder) { - UINT64_OVERLAY Dividend; + UINT64_OVERLAY DividendOvl; UINT64_OVERLAY Quotient; UINT32 Remainder32; ACPI_FUNCTION_TRACE ("UtShortDivide"); - Dividend.Full = *InDividend; /* Always check for a zero divisor */ @@ -174,13 +173,15 @@ AcpiUtShortDivide ( return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); } + DividendOvl.Full = Dividend; + /* * The quotient is 64 bits, the remainder is always 32 bits, * and is generated by the second divide. */ - ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor, + ACPI_DIV_64_BY_32 (0, DividendOvl.Part.Hi, Divisor, Quotient.Part.Hi, Remainder32); - ACPI_DIV_64_BY_32 (Remainder32, Dividend.Part.Lo, Divisor, + ACPI_DIV_64_BY_32 (Remainder32, DividendOvl.Part.Lo, Divisor, Quotient.Part.Lo, Remainder32); /* Return only what was requested */ @@ -202,8 +203,8 @@ AcpiUtShortDivide ( * * FUNCTION: AcpiUtDivide * - * PARAMETERS: InDividend - Pointer to the dividend - * InDivisor - Pointer to the divisor + * PARAMETERS: InDividend - Dividend + * InDivisor - Divisor * OutQuotient - Pointer to where the quotient is returned * OutRemainder - Pointer to where the remainder is returned * @@ -215,8 +216,8 @@ AcpiUtShortDivide ( ACPI_STATUS AcpiUtDivide ( - ACPI_INTEGER *InDividend, - ACPI_INTEGER *InDivisor, + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, ACPI_INTEGER *OutQuotient, ACPI_INTEGER *OutRemainder) { @@ -236,14 +237,14 @@ AcpiUtDivide ( /* Always check for a zero divisor */ - if (*InDivisor == 0) + if (InDivisor == 0) { ACPI_REPORT_ERROR (("AcpiUtDivide: Divide by zero\n")); return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); } - Divisor.Full = *InDivisor; - Dividend.Full = *InDividend; + Divisor.Full = InDivisor; + Dividend.Full = InDividend; if (Divisor.Part.Hi == 0) { /* @@ -351,6 +352,8 @@ AcpiUtDivide ( * * FUNCTION: AcpiUtShortDivide, AcpiUtDivide * + * PARAMETERS: See function headers above + * * DESCRIPTION: Native versions of the UtDivide functions. Use these if either * 1) The target is a 64-bit platform and therefore 64-bit * integer math is supported directly by the machine. @@ -362,7 +365,7 @@ AcpiUtDivide ( ACPI_STATUS AcpiUtShortDivide ( - ACPI_INTEGER *InDividend, + ACPI_INTEGER InDividend, UINT32 Divisor, ACPI_INTEGER *OutQuotient, UINT32 *OutRemainder) @@ -383,11 +386,11 @@ AcpiUtShortDivide ( if (OutQuotient) { - *OutQuotient = *InDividend / Divisor; + *OutQuotient = InDividend / Divisor; } if (OutRemainder) { - *OutRemainder = (UINT32) *InDividend % Divisor; + *OutRemainder = (UINT32) InDividend % Divisor; } return_ACPI_STATUS (AE_OK); @@ -395,8 +398,8 @@ AcpiUtShortDivide ( ACPI_STATUS AcpiUtDivide ( - ACPI_INTEGER *InDividend, - ACPI_INTEGER *InDivisor, + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, ACPI_INTEGER *OutQuotient, ACPI_INTEGER *OutRemainder) { @@ -405,7 +408,7 @@ AcpiUtDivide ( /* Always check for a zero divisor */ - if (*InDivisor == 0) + if (InDivisor == 0) { ACPI_REPORT_ERROR (("AcpiUtDivide: Divide by zero\n")); return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); @@ -416,11 +419,11 @@ AcpiUtDivide ( if (OutQuotient) { - *OutQuotient = *InDividend / *InDivisor; + *OutQuotient = InDividend / InDivisor; } if (OutRemainder) { - *OutRemainder = *InDividend % *InDivisor; + *OutRemainder = InDividend % InDivisor; } return_ACPI_STATUS (AE_OK); diff --git a/sys/dev/acpi/acpica/Subsystem/utmisc.c b/sys/dev/acpi/acpica/Subsystem/utmisc.c index fe380b21de4..e9ed757af60 100644 --- a/sys/dev/acpi/acpica/Subsystem/utmisc.c +++ b/sys/dev/acpi/acpica/Subsystem/utmisc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utmisc - common utility procedures - * xRevision: 99 $ + * xRevision: 112 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utmisc.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utmisc.c,v 1.11 2005/05/02 14:52:10 kochi Exp $"); #define __UTMISC_C__ @@ -127,12 +127,58 @@ __KERNEL_RCSID(0, "$NetBSD: utmisc.c,v 1.10 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utmisc") +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCreateMutex ( + ACPI_MUTEX_HANDLE MutexId); + +static ACPI_STATUS +AcpiUtDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrupr (strupr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: Converted SrcString (same as input pointer) + * + * DESCRIPTION: Convert string to uppercase + * + * NOTE: This is not a POSIX function, so it appears here, not in utclib.c + * + ******************************************************************************/ + +char * +AcpiUtStrupr ( + char *SrcString) +{ + char *String; + + + ACPI_FUNCTION_ENTRY (); + + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) ACPI_TOUPPER (*String); + } + + return (SrcString); +} + /******************************************************************************* * * FUNCTION: AcpiUtPrintString * * PARAMETERS: String - Null terminated ASCII string + * MaxLength - Maximum output length * * RETURN: None * @@ -230,6 +276,8 @@ AcpiUtPrintString ( * * PARAMETERS: Value - Value to be converted * + * RETURN: UINT32 integer with bytes swapped + * * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) * ******************************************************************************/ @@ -243,7 +291,6 @@ AcpiUtDwordByteSwap ( UINT32 Value; UINT8 Bytes[4]; } Out; - union { UINT32 Value; @@ -305,7 +352,8 @@ AcpiUtSetIntegerWidth ( * * FUNCTION: AcpiUtDisplayInitPathname * - * PARAMETERS: ObjHandle - Handle whose pathname will be displayed + * PARAMETERS: Type - Object type of the node + * ObjHandle - Handle whose pathname will be displayed * Path - Additional path string to be appended. * (NULL if no extra path) * @@ -359,7 +407,8 @@ AcpiUtDisplayInitPathname ( /* Print the object type and pathname */ - AcpiOsPrintf ("%-12s %s", AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); + AcpiOsPrintf ("%-12s %s", + AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); /* Extra path is used to append names like _STA, _INI, etc. */ @@ -378,9 +427,9 @@ AcpiUtDisplayInitPathname ( * * FUNCTION: AcpiUtValidAcpiName * - * PARAMETERS: Character - The character to be examined + * PARAMETERS: Name - The name to be examined * - * RETURN: 1 if Character may appear in a name, else 0 + * RETURN: TRUE if the name is valid, FALSE otherwise * * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: * 1) Upper case alpha @@ -448,16 +497,15 @@ AcpiUtValidAcpiCharacter ( * FUNCTION: AcpiUtStrtoul64 * * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte is returned - * Base - Radix of the string + * Base - Radix of the string: 10, 16, or ACPI_ANY_BASE + * RetInteger - Where the converted integer is returned * - * RETURN: Converted value + * RETURN: Status and Converted value * * DESCRIPTION: Convert a string into an unsigned value. + * NOTE: Does not support Octal strings, not needed. * ******************************************************************************/ -#define NEGATIVE 1 -#define POSITIVE 0 ACPI_STATUS AcpiUtStrtoul64 ( @@ -465,56 +513,49 @@ AcpiUtStrtoul64 ( UINT32 Base, ACPI_INTEGER *RetInteger) { - UINT32 Index; + UINT32 ThisDigit = 0; ACPI_INTEGER ReturnValue = 0; - ACPI_STATUS Status = AE_OK; - ACPI_INTEGER Dividend; ACPI_INTEGER Quotient; - *RetInteger = 0; + ACPI_FUNCTION_TRACE ("UtStroul64"); + + + if ((!String) || !(*String)) + { + goto ErrorExit; + } switch (Base) { - case 0: - case 8: + case ACPI_ANY_BASE: case 10: case 16: break; default: - /* - * The specified Base parameter is not in the domain of - * this function: - */ - return (AE_BAD_PARAMETER); + /* Invalid Base */ + return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * skip over any white space in the buffer: - */ + /* Skip over any white space in the buffer */ + while (ACPI_IS_SPACE (*String) || *String == '\t') { - ++String; + String++; } /* * If the input parameter Base is zero, then we need to - * determine if it is octal, decimal, or hexadecimal: + * determine if it is decimal or hexadecimal: */ if (Base == 0) { - if (*String == '0') + if ((*String == '0') && + (ACPI_TOLOWER (*(String + 1)) == 'x')) { - if (ACPI_TOLOWER (*(++String)) == 'x') - { - Base = 16; - ++String; - } - else - { - Base = 8; - } + Base = 16; + String += 2; } else { @@ -523,122 +564,93 @@ AcpiUtStrtoul64 ( } /* - * For octal and hexadecimal bases, skip over the leading + * For hexadecimal base, skip over the leading * 0 or 0x, if they are present. */ - if (Base == 8 && *String == '0') + if ((Base == 16) && + (*String == '0') && + (ACPI_TOLOWER (*(String + 1)) == 'x')) { - String++; + String += 2; } - if (Base == 16 && - *String == '0' && - ACPI_TOLOWER (*(++String)) == 'x') + /* Any string left? */ + + if (!(*String)) { - String++; + goto ErrorExit; } - /* Main loop: convert the string to an unsigned long */ + /* Main loop: convert the string to a 64-bit integer */ while (*String) { if (ACPI_IS_DIGIT (*String)) { - Index = ((UINT8) *String) - '0'; + /* Convert ASCII 0-9 to Decimal value */ + + ThisDigit = ((UINT8) *String) - '0'; } else { - Index = (UINT8) ACPI_TOUPPER (*String); - if (ACPI_IS_UPPER ((char) Index)) + if (Base == 10) { - Index = Index - 'A' + 10; + /* Digit is out of range */ + + goto ErrorExit; + } + + ThisDigit = (UINT8) ACPI_TOUPPER (*String); + if (ACPI_IS_XDIGIT ((char) ThisDigit)) + { + /* Convert ASCII Hex char to value */ + + ThisDigit = ThisDigit - 'A' + 10; } else { - goto ErrorExit; + /* + * We allow non-hex chars, just stop now, same as end-of-string. + * See ACPI spec, string-to-integer conversion. + */ + break; } } - if (Index >= Base) - { - goto ErrorExit; - } - - /* Check to see if value is out of range: */ + /* Divide the digit into the correct position */ - Dividend = ACPI_INTEGER_MAX - (ACPI_INTEGER) Index; - (void) AcpiUtShortDivide (&Dividend, Base, &Quotient, NULL); + (void) AcpiUtShortDivide ((ACPI_INTEGER_MAX - (ACPI_INTEGER) ThisDigit), + Base, &Quotient, NULL); if (ReturnValue > Quotient) { goto ErrorExit; } ReturnValue *= Base; - ReturnValue += Index; - ++String; + ReturnValue += ThisDigit; + String++; } + /* All done, normal exit */ + *RetInteger = ReturnValue; - return (Status); + return_ACPI_STATUS (AE_OK); ErrorExit: - switch (Base) - { - case 8: - Status = AE_BAD_OCTAL_CONSTANT; - break; - - case 10: - Status = AE_BAD_DECIMAL_CONSTANT; - break; - - case 16: - Status = AE_BAD_HEX_CONSTANT; - break; + /* Base was set/validated above */ - default: - /* Base validated above */ - break; + if (Base == 10) + { + return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); } - - return (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtStrupr - * - * PARAMETERS: SrcString - The source string to convert to - * - * RETURN: SrcString - * - * DESCRIPTION: Convert string to uppercase - * - ******************************************************************************/ - -char * -AcpiUtStrupr ( - char *SrcString) -{ - char *String; - - - ACPI_FUNCTION_ENTRY (); - - - /* Walk entire string, uppercasing the letters */ - - for (String = SrcString; *String; ) + else { - *String = (char) ACPI_TOUPPER (*String); - String++; + return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); } - - return (SrcString); } + /******************************************************************************* * * FUNCTION: AcpiUtMutexInitialize @@ -674,10 +686,8 @@ AcpiUtMutexInitialize ( } } - Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); - - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } @@ -728,7 +738,7 @@ AcpiUtMutexTerminate ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCreateMutex ( ACPI_MUTEX_HANDLE MutexId) { @@ -767,7 +777,7 @@ AcpiUtCreateMutex ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtDeleteMutex ( ACPI_MUTEX_HANDLE MutexId) { @@ -808,7 +818,6 @@ AcpiUtAcquireMutex ( ACPI_MUTEX_HANDLE MutexId) { ACPI_STATUS Status; - UINT32 i; UINT32 ThisThreadId; @@ -822,53 +831,61 @@ AcpiUtAcquireMutex ( ThisThreadId = AcpiOsGetThreadId (); - /* - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than or equal to this one. If so, the thread has violated - * the mutex ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = MutexId; i < MAX_MUTEX; i++) +#ifdef ACPI_MUTEX_DEBUG { - if (AcpiGbl_MutexInfo[i].OwnerId == ThisThreadId) + UINT32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than or equal to this one. If so, the thread has violated + * the mutex ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = MutexId; i < MAX_MUTEX; i++) { - if (i == MutexId) + if (AcpiGbl_MutexInfo[i].OwnerId == ThisThreadId) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + if (i == MutexId) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Mutex [%s] already acquired by this thread [%X]\n", AcpiUtGetMutexName (MutexId), ThisThreadId)); - return (AE_ALREADY_ACQUIRED); - } + return (AE_ALREADY_ACQUIRED); + } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", ThisThreadId, AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); - return (AE_ACQUIRE_DEADLOCK); + return (AE_ACQUIRE_DEADLOCK); + } } } +#endif ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X attempting to acquire Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); + "Thread %X attempting to acquire Mutex [%s]\n", + ThisThreadId, AcpiUtGetMutexName (MutexId))); Status = AcpiOsWaitSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex, 1, ACPI_WAIT_FOREVER); if (ACPI_SUCCESS (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); + ThisThreadId, AcpiUtGetMutexName (MutexId))); AcpiGbl_MutexInfo[MutexId].UseCount++; AcpiGbl_MutexInfo[MutexId].OwnerId = ThisThreadId; } else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not acquire Mutex [%s] %s\n", - ThisThreadId, AcpiUtGetMutexName (MutexId), - AcpiFormatException (Status))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Thread %X could not acquire Mutex [%s] %s\n", + ThisThreadId, AcpiUtGetMutexName (MutexId), + AcpiFormatException (Status))); } return (Status); @@ -915,8 +932,8 @@ AcpiUtReleaseMutex ( if (AcpiGbl_MutexInfo[MutexId].OwnerId == ACPI_MUTEX_NOT_ACQUIRED) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Mutex [%s] is not acquired, cannot release\n", - AcpiUtGetMutexName (MutexId))); + "Mutex [%s] is not acquired, cannot release\n", + AcpiUtGetMutexName (MutexId))); return (AE_NOT_ACQUIRED); } @@ -937,8 +954,8 @@ AcpiUtReleaseMutex ( } ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid release order: owns [%s], releasing [%s]\n", - AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); + "Invalid release order: owns [%s], releasing [%s]\n", + AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); return (AE_RELEASE_DEADLOCK); } @@ -952,14 +969,15 @@ AcpiUtReleaseMutex ( if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not release Mutex [%s] %s\n", - ThisThreadId, AcpiUtGetMutexName (MutexId), - AcpiFormatException (Status))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Thread %X could not release Mutex [%s] %s\n", + ThisThreadId, AcpiUtGetMutexName (MutexId), + AcpiFormatException (Status))); } else { ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); + ThisThreadId, AcpiUtGetMutexName (MutexId))); } return (Status); @@ -970,11 +988,11 @@ AcpiUtReleaseMutex ( * * FUNCTION: AcpiUtCreateUpdateStateAndPush * - * PARAMETERS: *Object - Object to be added to the new state + * PARAMETERS: Object - Object to be added to the new state * Action - Increment/Decrement * StateList - List the state will be added to * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Create a new state and push it * @@ -1014,11 +1032,11 @@ AcpiUtCreateUpdateStateAndPush ( * * FUNCTION: AcpiUtCreatePkgStateAndPush * - * PARAMETERS: *Object - Object to be added to the new state + * PARAMETERS: Object - Object to be added to the new state * Action - Increment/Decrement * StateList - List the state will be added to * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Create a new state and push it * @@ -1055,7 +1073,7 @@ AcpiUtCreatePkgStateAndPush ( * PARAMETERS: ListHead - Head of the state stack * State - State object to push * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Push a state object onto a state stack * @@ -1084,7 +1102,7 @@ AcpiUtPushGenericState ( * * PARAMETERS: ListHead - Head of the state stack * - * RETURN: Status + * RETURN: The popped state object * * DESCRIPTION: Pop a state object from a state stack * @@ -1120,7 +1138,7 @@ AcpiUtPopGenericState ( * * PARAMETERS: None * - * RETURN: Status + * RETURN: The new state object. NULL on failure. * * DESCRIPTION: Create a generic state object. Attempt to obtain one from * the global state cache; If none available, create a new one. @@ -1128,7 +1146,8 @@ AcpiUtPopGenericState ( ******************************************************************************/ ACPI_GENERIC_STATE * -AcpiUtCreateGenericState (void) +AcpiUtCreateGenericState ( + void) { ACPI_GENERIC_STATE *State; @@ -1155,7 +1174,7 @@ AcpiUtCreateGenericState (void) * * PARAMETERS: None * - * RETURN: Thread State + * RETURN: New Thread State. NULL on failure * * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used * to track per-thread info during method execution @@ -1193,11 +1212,10 @@ AcpiUtCreateThreadState ( * * FUNCTION: AcpiUtCreateUpdateState * - * PARAMETERS: Object - Initial Object to be installed in the - * state - * Action - Update action to be performed + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed * - * RETURN: Status + * RETURN: New state object, null on failure * * DESCRIPTION: Create an "Update State" - a flavor of the generic state used * to update reference counts and delete complex objects such @@ -1238,11 +1256,10 @@ AcpiUtCreateUpdateState ( * * FUNCTION: AcpiUtCreatePkgState * - * PARAMETERS: Object - Initial Object to be installed in the - * state - * Action - Update action to be performed + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed * - * RETURN: Status + * RETURN: New state object, null on failure * * DESCRIPTION: Create a "Package State" * @@ -1286,7 +1303,7 @@ AcpiUtCreatePkgState ( * * PARAMETERS: None * - * RETURN: Status + * RETURN: New state object, null on failure * * DESCRIPTION: Create a "Control State" - a flavor of the generic state used * to support nested IF/WHILE constructs in the AML. @@ -1326,7 +1343,7 @@ AcpiUtCreateControlState ( * * PARAMETERS: State - The state object to be deleted * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Put a state object back into the global state cache. The object * is not actually freed at this time. @@ -1345,13 +1362,14 @@ AcpiUtDeleteGenericState ( } +#ifdef ACPI_ENABLE_OBJECT_CACHE /******************************************************************************* * * FUNCTION: AcpiUtDeleteGenericStateCache * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Purge the global state object cache. Used during subsystem * termination. @@ -1368,13 +1386,17 @@ AcpiUtDeleteGenericStateCache ( AcpiUtDeleteGenericCache (ACPI_MEM_LIST_STATE); return_VOID; } +#endif /******************************************************************************* * * FUNCTION: AcpiUtWalkPackageTree * - * PARAMETERS: ObjDesc - The Package object on which to resolve refs + * PARAMETERS: SourceObject - The package to walk + * TargetObject - Target object (if package is being copied) + * WalkCallback - Called once for each package element + * Context - Passed to the callback function * * RETURN: Status * @@ -1502,7 +1524,7 @@ AcpiUtWalkPackageTree ( * PARAMETERS: Buffer - Buffer to be scanned * Length - number of bytes to examine * - * RETURN: checksum + * RETURN: The generated checksum * * DESCRIPTION: Generate a checksum on a raw buffer * @@ -1590,7 +1612,6 @@ AcpiUtGetResourceEndTag ( * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) - * Message - Error message to use on failure * * RETURN: None * @@ -1605,7 +1626,6 @@ AcpiUtReportError ( UINT32 ComponentId) { - AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber); } @@ -1617,7 +1637,6 @@ AcpiUtReportError ( * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) - * Message - Error message to use on failure * * RETURN: None * @@ -1643,7 +1662,6 @@ AcpiUtReportWarning ( * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) - * Message - Error message to use on failure * * RETURN: None * diff --git a/sys/dev/acpi/acpica/Subsystem/utobject.c b/sys/dev/acpi/acpica/Subsystem/utobject.c index a9a640bce05..7eac38ef980 100644 --- a/sys/dev/acpi/acpica/Subsystem/utobject.c +++ b/sys/dev/acpi/acpica/Subsystem/utobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utobject - ACPI object create/delete/size/cache routines - * xRevision: 86 $ + * xRevision: 95 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utobject.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utobject.c,v 1.13 2005/05/02 14:52:10 kochi Exp $"); #define __UTOBJECT_C__ @@ -127,6 +127,25 @@ __KERNEL_RCSID(0, "$NetBSD: utobject.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utobject") +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + /******************************************************************************* * @@ -137,7 +156,7 @@ __KERNEL_RCSID(0, "$NetBSD: utobject.c,v 1.12 2004/02/14 16:57:25 kochi Exp $"); * ComponentId - Component type of caller * Type - ACPI Type of the new object * - * RETURN: Object - The new object. Null on failure + * RETURN: A new internal object, null on failure * * DESCRIPTION: Create and initialize a new internal object. * @@ -160,7 +179,8 @@ AcpiUtCreateInternalObjectDbg ( ACPI_OPERAND_OBJECT *SecondObject; - ACPI_FUNCTION_TRACE_STR ("UtCreateInternalObjectDbg", AcpiUtGetTypeName (Type)); + ACPI_FUNCTION_TRACE_STR ("UtCreateInternalObjectDbg", + AcpiUtGetTypeName (Type)); /* Allocate the raw object descriptor */ @@ -178,7 +198,8 @@ AcpiUtCreateInternalObjectDbg ( /* These types require a secondary object */ - SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId); + SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, + LineNumber, ComponentId); if (!SecondObject) { AcpiUtDeleteObjectDesc (Object); @@ -218,7 +239,7 @@ AcpiUtCreateInternalObjectDbg ( * * PARAMETERS: BufferSize - Size of buffer to be created * - * RETURN: Pointer to a new Buffer object + * RETURN: Pointer to a new Buffer object, null on failure * * DESCRIPTION: Create a fully initialized buffer object * @@ -235,9 +256,8 @@ AcpiUtCreateBufferObject ( ACPI_FUNCTION_TRACE_U32 ("UtCreateBufferObject", BufferSize); - /* - * Create a new Buffer object - */ + /* Create a new Buffer object */ + BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); if (!BufferDesc) { @@ -274,11 +294,70 @@ AcpiUtCreateBufferObject ( /******************************************************************************* * + * FUNCTION: AcpiUtCreateStringObject + * + * PARAMETERS: StringSize - Size of string to be created. Does not + * include NULL terminator, this is added + * automatically. + * + * RETURN: Pointer to a new String object + * + * DESCRIPTION: Create a fully initialized string object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize) +{ + ACPI_OPERAND_OBJECT *StringDesc; + char *String; + + + ACPI_FUNCTION_TRACE_U32 ("UtCreateStringObject", StringSize); + + + /* Create a new String object */ + + StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); + if (!StringDesc) + { + return_PTR (NULL); + } + + /* + * Allocate the actual string buffer -- (Size + 1) for NULL terminator. + * NOTE: Zero-length strings are NULL terminated + */ + String = ACPI_MEM_CALLOCATE (StringSize + 1); + if (!String) + { + ACPI_REPORT_ERROR (("CreateString: could not allocate size %X\n", + (UINT32) StringSize)); + AcpiUtRemoveReference (StringDesc); + return_PTR (NULL); + } + + /* Complete string object initialization */ + + StringDesc->String.Pointer = String; + StringDesc->String.Length = (UINT32) StringSize; + + /* Return the new string descriptor */ + + return_PTR (StringDesc); +} + + +/******************************************************************************* + * * FUNCTION: AcpiUtValidInternalObject * * PARAMETERS: Object - Object to be validated * - * RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT + * RETURN: TRUE if object is valid, FALSE otherwise + * + * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT * ******************************************************************************/ @@ -401,6 +480,7 @@ AcpiUtDeleteObjectDesc ( } +#ifdef ACPI_ENABLE_OBJECT_CACHE /******************************************************************************* * * FUNCTION: AcpiUtDeleteObjectCache @@ -424,14 +504,15 @@ AcpiUtDeleteObjectCache ( AcpiUtDeleteGenericCache (ACPI_MEM_LIST_OPERAND); return_VOID; } +#endif /******************************************************************************* * * FUNCTION: AcpiUtGetSimpleObjectSize * - * PARAMETERS: *InternalObject - Pointer to the object we are examining - * *ObjLength - Where the length is returned + * PARAMETERS: InternalObject - An ACPI operand object + * ObjLength - Where the length is returned * * RETURN: Status * @@ -443,7 +524,7 @@ AcpiUtDeleteObjectCache ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtGetSimpleObjectSize ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_SIZE *ObjLength) @@ -455,8 +536,10 @@ AcpiUtGetSimpleObjectSize ( ACPI_FUNCTION_TRACE_PTR ("UtGetSimpleObjectSize", InternalObject); - /* Handle a null object (Could be a uninitialized package element -- which is legal) */ - + /* + * Handle a null object (Could be a uninitialized package + * element -- which is legal) + */ if (!InternalObject) { *ObjLength = 0; @@ -515,7 +598,8 @@ AcpiUtGetSimpleObjectSize ( * Get the actual length of the full pathname to this object. * The reference will be converted to the pathname to the object */ - Length += ACPI_ROUND_UP_TO_NATIVE_WORD (AcpiNsGetPathnameLength (InternalObject->Reference.Node)); + Length += ACPI_ROUND_UP_TO_NATIVE_WORD ( + AcpiNsGetPathnameLength (InternalObject->Reference.Node)); break; default: @@ -565,7 +649,7 @@ AcpiUtGetSimpleObjectSize ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtGetElementLength ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, @@ -619,8 +703,8 @@ AcpiUtGetElementLength ( * * FUNCTION: AcpiUtGetPackageObjectSize * - * PARAMETERS: *InternalObject - Pointer to the object we are examining - * *ObjLength - Where the length is returned + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length is returned * * RETURN: Status * @@ -632,7 +716,7 @@ AcpiUtGetElementLength ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtGetPackageObjectSize ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_SIZE *ObjLength) @@ -674,8 +758,8 @@ AcpiUtGetPackageObjectSize ( * * FUNCTION: AcpiUtGetObjectSize * - * PARAMETERS: *InternalObject - Pointer to the object we are examining - * *ObjLength - Where the length will be returned + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length will be returned * * RETURN: Status * @@ -685,7 +769,7 @@ AcpiUtGetPackageObjectSize ( ******************************************************************************/ ACPI_STATUS -AcpiUtGetObjectSize( +AcpiUtGetObjectSize ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_SIZE *ObjLength) { diff --git a/sys/dev/acpi/acpica/Subsystem/utxface.c b/sys/dev/acpi/acpica/Subsystem/utxface.c index 5f9002e3ea5..17bb42f59e6 100644 --- a/sys/dev/acpi/acpica/Subsystem/utxface.c +++ b/sys/dev/acpi/acpica/Subsystem/utxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utxface - External interfaces for "global" ACPI functions - * xRevision: 105 $ + * xRevision: 110 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: utxface.c,v 1.11 2004/02/14 16:57:25 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: utxface.c,v 1.12 2005/05/02 14:52:10 kochi Exp $"); #define __UTXFACE_C__ @@ -150,6 +150,7 @@ AcpiInitializeSubsystem ( { ACPI_STATUS Status; + ACPI_FUNCTION_TRACE ("AcpiInitializeSubsystem"); @@ -184,7 +185,6 @@ AcpiInitializeSubsystem ( * Initialize the namespace manager and * the root of the namespace tree */ - Status = AcpiNsRootInitialize (); if (ACPI_FAILURE (Status)) { @@ -193,7 +193,6 @@ AcpiInitializeSubsystem ( return_ACPI_STATUS (Status); } - /* If configured, initialize the AML debugger */ ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ()); @@ -231,7 +230,8 @@ AcpiEnableSubsystem ( */ if (!(Flags & ACPI_NO_HARDWARE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI hardware\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI hardware\n")); Status = AcpiHwInitialize (); if (ACPI_FAILURE (Status)) @@ -240,9 +240,8 @@ AcpiEnableSubsystem ( } } - /* - * Enable ACPI mode - */ + /* Enable ACPI mode */ + if (!(Flags & ACPI_NO_ACPI_ENABLE)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); @@ -258,30 +257,50 @@ AcpiEnableSubsystem ( } /* - * Initialize ACPI Event handling + * Install the default OpRegion handlers. These are installed unless + * other handlers have already been installed via the + * InstallAddressSpaceHandler interface. + */ + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing default address space handlers\n")); + + Status = AcpiEvInstallRegionHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize ACPI Event handling (Fixed and General Purpose) * - * NOTE: We must have the hardware AND events initialized before we can execute - * ANY control methods SAFELY. Any control method can require ACPI hardware - * support, so the hardware MUST be initialized before execution! + * NOTE: We must have the hardware AND events initialized before we can + * execute ANY control methods SAFELY. Any control method can require + * ACPI hardware support, so the hardware MUST be initialized before + * execution! */ if (!(Flags & ACPI_NO_EVENT_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI events\n")); - Status = AcpiEvInitialize (); + Status = AcpiEvInitializeEvents (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } - /* Install the SCI handler, Global Lock handler, and GPE handlers */ + /* Install the SCI handler and Global Lock handler */ if (!(Flags & ACPI_NO_HANDLER_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL/GPE handlers\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing SCI/GL handlers\n")); - Status = AcpiEvHandlerInitialize (); + Status = AcpiEvInstallXruptHandlers (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -315,19 +334,18 @@ AcpiInitializeObjects ( /* - * Install the default OpRegion handlers. These are installed unless - * other handlers have already been installed via the - * InstallAddressSpaceHandler interface. + * Run all _REG methods * - * NOTE: This will cause _REG methods to be run. Any objects accessed + * NOTE: Any objects accessed * by the _REG methods will be automatically initialized, even if they * contain executable AML (see call to AcpiNsInitializeObjects below). */ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Executing _REG OpRegion methods\n")); - Status = AcpiEvInitAddressSpaces (); + Status = AcpiEvInitializeOpRegions (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -341,7 +359,8 @@ AcpiInitializeObjects ( */ if (!(Flags & ACPI_NO_OBJECT_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Objects\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); Status = AcpiNsInitializeObjects (); if (ACPI_FAILURE (Status)) @@ -356,7 +375,8 @@ AcpiInitializeObjects ( */ if (!(Flags & ACPI_NO_DEVICE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Devices\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI Devices\n")); Status = AcpiNsInitializeDevices (); if (ACPI_FAILURE (Status)) @@ -390,7 +410,8 @@ AcpiInitializeObjects ( ******************************************************************************/ ACPI_STATUS -AcpiTerminate (void) +AcpiTerminate ( + void) { ACPI_STATUS Status; @@ -426,7 +447,7 @@ AcpiTerminate (void) } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiSubsystemStatus * @@ -435,14 +456,16 @@ AcpiTerminate (void) * RETURN: Status of the ACPI subsystem * * DESCRIPTION: Other drivers that use the ACPI subsystem should call this - * before making any other calls, to ensure the subsystem initial- - * ized successfully. + * before making any other calls, to ensure the subsystem + * initialized successfully. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS -AcpiSubsystemStatus (void) +AcpiSubsystemStatus ( + void) { + if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK) { return (AE_OK); @@ -454,13 +477,12 @@ AcpiSubsystemStatus (void) } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiGetSystemInfo * - * PARAMETERS: OutBuffer - a pointer to a buffer to receive the - * resources for the device - * BufferLength - the number of bytes available in the buffer + * PARAMETERS: OutBuffer - A buffer to receive the resources for the + * device * * RETURN: Status - the status of the call * @@ -478,8 +500,8 @@ AcpiGetSystemInfo ( ACPI_BUFFER *OutBuffer) { ACPI_SYSTEM_INFO *InfoPtr; - UINT32 i; ACPI_STATUS Status; + UINT32 i; ACPI_FUNCTION_TRACE ("AcpiGetSystemInfo"); @@ -554,6 +576,7 @@ AcpiGetSystemInfo ( * FUNCTION: AcpiInstallInitializationHandler * * PARAMETERS: Handler - Callback procedure + * Function - Not (currently) used, see below * * RETURN: Status * @@ -597,15 +620,18 @@ AcpiInstallInitializationHandler ( ****************************************************************************/ ACPI_STATUS -AcpiPurgeCachedObjects (void) +AcpiPurgeCachedObjects ( + void) { ACPI_FUNCTION_TRACE ("AcpiPurgeCachedObjects"); +#ifdef ACPI_ENABLE_OBJECT_CACHE AcpiUtDeleteGenericStateCache (); AcpiUtDeleteObjectCache (); AcpiDsDeleteWalkStateCache (); AcpiPsDeleteParseCache (); +#endif return_ACPI_STATUS (AE_OK); } |
