diff --git a/sys/conf/files b/sys/conf/files index 6bb1355b9199..f4bb06211029 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -174,6 +174,8 @@ contrib/dev/acpica/dispatcher/dswstate.c optional acpi contrib/dev/acpica/events/evevent.c optional acpi contrib/dev/acpica/events/evgpe.c optional acpi contrib/dev/acpica/events/evgpeblk.c optional acpi +contrib/dev/acpica/events/evgpeinit.c optional acpi +contrib/dev/acpica/events/evgpeutil.c optional acpi contrib/dev/acpica/events/evmisc.c optional acpi contrib/dev/acpica/events/evregion.c optional acpi contrib/dev/acpica/events/evrgnini.c optional acpi diff --git a/sys/contrib/dev/acpica/acpica_prep.sh b/sys/contrib/dev/acpica/acpica_prep.sh index 3a17041846f8..ebbf8cff1480 100755 --- a/sys/contrib/dev/acpica/acpica_prep.sh +++ b/sys/contrib/dev/acpica/acpica_prep.sh @@ -19,7 +19,7 @@ fulldirs="common compiler debugger disassembler dispatcher events \ tools utilities" # files to remove -stripdirs="acpisrc acpixtract examples generate os_specific" +stripdirs="acpisrc acpixtract examples generate os_specific tests" stripfiles="Makefile README acintel.h aclinux.h acmsvc.h acnetbsd.h \ acos2.h accygwin.h acefi.h acwin.h acwin64.h aeexec.c \ aehandlers.c aemain.c aetables.c osunixdir.c readme.txt \ diff --git a/sys/contrib/dev/acpica/changes.txt b/sys/contrib/dev/acpica/changes.txt index d2c8c0e41edf..fed0395e61ae 100644 --- a/sys/contrib/dev/acpica/changes.txt +++ b/sys/contrib/dev/acpica/changes.txt @@ -1,3 +1,69 @@ +---------------------------------------- +28 April 2010. Summary of changes for version 20100428: + +1) ACPI CA Core Subsystem: + +Implemented GPE support for dynamically loaded ACPI tables. For all GPEs, +including FADT-based and GPE Block Devices, execute any _PRW methods in the +new table, and process any _Lxx/_Exx GPE methods in the new table. Any +runtime GPE that is referenced by an _Lxx/_Exx method in the new table is +immediately enabled. Handles the FADT-defined GPEs as well as GPE Block +Devices. Provides compatibility with other ACPI implementations. Two new +files added, evgpeinit.c and evgpeutil.c. ACPICA BZ 833. Lin Ming, Bob Moore. + +Fixed a regression introduced in version 20100331 within the table manager +where initial table loading could fail. This was introduced in the fix for +AcpiReallocateRootTable. Also, renamed some of fields in the table manager +data structures to clarify their meaning and use. + +Fixed a possible allocation overrun during internal object copy in +AcpiUtCopySimpleObject. The original code did not correctly handle the case +where the object to be copied was a namespace node. Lin Ming. ACPICA BZ 847. + +Updated the allocation dump routine, AcpiUtDumpAllocation and fixed a +possible access beyond end-of-allocation. Also, now fully validate descriptor +(size and type) before output. Lin Ming, Bob Moore. ACPICA BZ 847 + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and has a +much larger code and data size. + + Previous Release: + Non-Debug Version: 87.9K Code, 18.6K Data, 106.5K Total + Debug Version: 163.5K Code, 51.3K Data, 214.8K Total + Current Release: + Non-Debug Version: 88.4K Code, 18.8K Data, 107.2K Total + Debug Version: 164.2K Code, 51.5K Data, 215.7K Total + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented Min/Max/Len/Gran validation for address resource +descriptors. This change implements validation for the address fields that +are common to all address-type resource descriptors. These checks are +implemented: Checks for valid Min/Max, length within the Min/Max window, +valid granularity, Min/Max a multiple of granularity, and _MIF/_MAF as per +table 6-40 in the ACPI 4.0a specification. Also split the large aslrestype1.c +and aslrestype2.c files into five new files. ACPICA BZ 840. + +iASL: Added support for the _Wxx predefined names. This support was missing +and these names were not recognized by the compiler as valid predefined +names. ACPICA BZ 851. + +iASL: Added an error for all predefined names that are defined to return no +value and thus must be implemented as Control Methods. These include all of +the _Lxx, _Exx, _Wxx, and _Qxx names, as well as some other miscellaneous +names such as _DIS, _INI, _IRC, _OFF, _ON, and _PSx. ACPICA BZ 850, 856. + +iASL: Implemented the -ts option to emit hex AML data in ASL format, as an +ASL Buffer. Allows ACPI tables to be easily included within ASL files, to be +dynamically loaded via the Load() operator. Also cleaned up output for the - +ta and -tc options. ACPICA BZ 853. + +Tests: Added a new file with examples of extended iASL error checking. +Demonstrates the advanced error checking ability of the iASL compiler. +Available at tests/misc/badcode.asl. + ---------------------------------------- 31 March 2010. Summary of changes for version 20100331: diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c index fe5ae35731de..91559c2cf2d8 100644 --- a/sys/contrib/dev/acpica/common/adisasm.c +++ b/sys/contrib/dev/acpica/common/adisasm.c @@ -282,8 +282,8 @@ AdInitialize ( /* Setup the Table Manager (cheat - there is no RSDT) */ - AcpiGbl_RootTableList.Size = 1; - AcpiGbl_RootTableList.Count = 0; + AcpiGbl_RootTableList.MaxTableCount = 1; + AcpiGbl_RootTableList.CurrentTableCount = 0; AcpiGbl_RootTableList.Tables = LocalTables; return (Status); @@ -1156,7 +1156,7 @@ AdParseTable ( /* If LoadTable is FALSE, we are parsing the last loaded table */ - TableIndex = AcpiGbl_RootTableList.Count - 1; + TableIndex = AcpiGbl_RootTableList.CurrentTableCount - 1; /* Pass 2 */ diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c index 443273c62c77..439c21af4380 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompile.c +++ b/sys/contrib/dev/acpica/compiler/aslcompile.c @@ -177,7 +177,8 @@ AslCompilerSignon ( { Prefix = "; "; } - else if (Gbl_HexOutputFlag == HEX_OUTPUT_C) + else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || + (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) { FlPrintFile (ASL_FILE_HEX_OUTPUT, "/*\n"); Prefix = " * "; @@ -265,7 +266,8 @@ AslCompilerFileHeader ( { Prefix = "; "; } - else if (Gbl_HexOutputFlag == HEX_OUTPUT_C) + else if ((Gbl_HexOutputFlag == HEX_OUTPUT_C) || + (Gbl_HexOutputFlag == HEX_OUTPUT_ASL)) { Prefix = " * "; } diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h index dbc2709725b5..a277c67c8853 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h @@ -592,6 +592,10 @@ FlFileError ( UINT32 FileId, UINT8 ErrorId); +UINT32 +FlGetFileSize ( + UINT32 FileId); + ACPI_STATUS FlReadFile ( UINT32 FileId, @@ -750,6 +754,34 @@ UtDoConstant ( /* * aslresource - Resource template generation utilities */ +void +RsSmallAddressCheck ( + UINT8 Type, + UINT32 Minimum, + UINT32 Maximum, + UINT32 Length, + UINT32 Alignment, + ACPI_PARSE_OBJECT *MinOp, + ACPI_PARSE_OBJECT *MaxOp, + ACPI_PARSE_OBJECT *LengthOp, + ACPI_PARSE_OBJECT *AlignOp); + +void +RsLargeAddressCheck ( + UINT64 Minimum, + UINT64 Maximum, + UINT64 Length, + UINT64 Granularity, + UINT8 Flags, + ACPI_PARSE_OBJECT *MinOp, + ACPI_PARSE_OBJECT *MaxOp, + ACPI_PARSE_OBJECT *LengthOp, + ACPI_PARSE_OBJECT *GranOp); + +UINT16 +RsGetStringDataLength ( + ACPI_PARSE_OBJECT *InitializerOp); + ASL_RESOURCE_NODE * RsAllocateResourceNode ( UINT32 Size); @@ -805,43 +837,18 @@ RsDoResourceTemplate ( /* - * aslrestype1 - generate Small descriptors + * aslrestype1 - Miscellaneous Small descriptors */ ASL_RESOURCE_NODE * RsDoEndTagDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); -ASL_RESOURCE_NODE * -RsDoDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); - ASL_RESOURCE_NODE * RsDoEndDependentDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); -ASL_RESOURCE_NODE * -RsDoFixedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); - -ASL_RESOURCE_NODE * -RsDoIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); - -ASL_RESOURCE_NODE * -RsDoIrqDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); - -ASL_RESOURCE_NODE * -RsDoIrqNoFlagsDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); - ASL_RESOURCE_NODE * RsDoMemory24Descriptor ( ACPI_PARSE_OBJECT *Op, @@ -874,7 +881,36 @@ RsDoVendorSmallDescriptor ( /* - * aslrestype2 - generate Large descriptors + * aslrestype1i - I/O-related Small descriptors + */ +ASL_RESOURCE_NODE * +RsDoDmaDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * +RsDoFixedIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * +RsDoIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * +RsDoIrqDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * +RsDoIrqNoFlagsDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + + +/* + * aslrestype2 - Large resource descriptors */ ASL_RESOURCE_NODE * RsDoInterruptDescriptor ( @@ -882,6 +918,20 @@ RsDoInterruptDescriptor ( UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * +RsDoVendorLargeDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * +RsDoGeneralRegisterDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + + +/* + * aslrestype2d - DWord address descriptors + */ +ASL_RESOURCE_NODE * RsDoDwordIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); @@ -896,6 +946,10 @@ RsDoDwordSpaceDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); + +/* + * aslrestype2e - Extended address descriptors + */ ASL_RESOURCE_NODE * RsDoExtendedIoDescriptor ( ACPI_PARSE_OBJECT *Op, @@ -911,6 +965,10 @@ RsDoExtendedSpaceDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); + +/* + * aslrestype2q - QWord address descriptors + */ ASL_RESOURCE_NODE * RsDoQwordIoDescriptor ( ACPI_PARSE_OBJECT *Op, @@ -926,6 +984,10 @@ RsDoQwordSpaceDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); + +/* + * aslrestype2w - Word address descriptors + */ ASL_RESOURCE_NODE * RsDoWordIoDescriptor ( ACPI_PARSE_OBJECT *Op, @@ -941,15 +1003,5 @@ RsDoWordBusNumberDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); -ASL_RESOURCE_NODE * -RsDoVendorLargeDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); - -ASL_RESOURCE_NODE * -RsDoGeneralRegisterDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); - #endif /* __ASLCOMPILER_H */ diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h index 75345a5d7f4b..cff4ecf410e4 100644 --- a/sys/contrib/dev/acpica/compiler/asldefine.h +++ b/sys/contrib/dev/acpica/compiler/asldefine.h @@ -128,7 +128,7 @@ #define CompilerId "ASL Optimizing Compiler" #define DisassemblerId "AML Disassembler" #define CompilerCopyright "Copyright (c) 2000 - 2010 Intel Corporation" -#define CompilerCompliance "Supports ACPI Specification Revision 4.0" +#define CompilerCompliance "Supports ACPI Specification Revision 4.0a" #define CompilerName "iasl" #define CompilerCreatorId "INTL" diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c index f2e2dca3fc39..ca23834c0c91 100644 --- a/sys/contrib/dev/acpica/compiler/aslfiles.c +++ b/sys/contrib/dev/acpica/compiler/aslfiles.c @@ -234,6 +234,36 @@ FlOpenFile ( } +/******************************************************************************* + * + * FUNCTION: FlGetFileSize + * + * PARAMETERS: FileId - Index into file info array + * + * RETURN: File Size + * + * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. + * + ******************************************************************************/ + +UINT32 +FlGetFileSize ( + UINT32 FileId) +{ + FILE *fp; + UINT32 FileSize; + + + fp = Gbl_Files[FileId].Handle; + + fseek (fp, 0, SEEK_END); + FileSize = (UINT32) ftell (fp); + fseek (fp, 0, SEEK_SET); + + return (FileSize); +} + + /******************************************************************************* * * FUNCTION: FlReadFile diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h index 01ab931e0d0d..85bb3e2d9e6b 100644 --- a/sys/contrib/dev/acpica/compiler/aslglobal.h +++ b/sys/contrib/dev/acpica/compiler/aslglobal.h @@ -188,6 +188,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CompileTimesFlag, FALSE ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_FoldConstants, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_VerboseErrors, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NoErrors, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NoResourceChecking, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DisasmFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_GetAllTables, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_IntegerOptimizationFlag, TRUE); @@ -200,6 +201,8 @@ ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_WarningLevel, ASL_WARNI #define HEX_OUTPUT_NONE 0 #define HEX_OUTPUT_C 1 #define HEX_OUTPUT_ASM 2 +#define HEX_OUTPUT_ASL 3 + ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HexOutputFlag, HEX_OUTPUT_NONE); diff --git a/sys/contrib/dev/acpica/compiler/asllisting.c b/sys/contrib/dev/acpica/compiler/asllisting.c index ebac9ca4996d..9458b929215b 100644 --- a/sys/contrib/dev/acpica/compiler/asllisting.c +++ b/sys/contrib/dev/acpica/compiler/asllisting.c @@ -198,6 +198,10 @@ static void LsDoHexOutputAsm ( void); +static void +LsDoHexOutputAsl ( + void); + ACPI_STATUS LsTreeWriteWalk ( ACPI_PARSE_OBJECT *Op, @@ -1337,6 +1341,11 @@ LsDoHexOutput ( LsDoHexOutputAsm (); break; + case HEX_OUTPUT_ASL: + + LsDoHexOutputAsl (); + break; + default: /* No other output types supported */ break; @@ -1362,60 +1371,160 @@ static void LsDoHexOutputC ( void) { - UINT32 j; - UINT8 FileByte[HEX_TABLE_LINE_SIZE]; - UINT8 Buffer[4]; + UINT8 FileData[HEX_TABLE_LINE_SIZE]; + UINT32 LineLength; UINT32 Offset = 0; + UINT32 AmlFileSize; + UINT32 i; - FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n *\n */\n"); + /* Get AML size, seek back to start */ + + AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n"); + FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", + AmlFileSize); FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] =\n{\n"); - /* Start at the beginning of the AML file */ - - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - - /* Process all AML bytes in the AML file */ - - j = 0; - while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK) + while (Offset < AmlFileSize) { - if (j == 0) + /* Read enough bytes needed for one output line */ + + LineLength = fread (FileData, 1, HEX_TABLE_LINE_SIZE, + Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + if (!LineLength) { - FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + break; } - /* Convert each AML byte to hex */ + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); - UtConvertByteToHex (FileByte[j], Buffer); - FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4); - FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); - - /* An occasional linefeed improves readability */ - - Offset++; - j++; - - if (j >= HEX_TABLE_LINE_SIZE) + for (i = 0; i < LineLength; i++) { - /* End of line, emit the ascii dump of the entire line */ - - FlPrintFile (ASL_FILE_HEX_OUTPUT, - " /* %8.8X", Offset - HEX_TABLE_LINE_SIZE); - - /* Write the ASCII character associated with each of the bytes */ - - LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, - HEX_TABLE_LINE_SIZE, FileByte); - FlPrintFile (ASL_FILE_HEX_OUTPUT, " */\n"); - - /* Start new line */ - - j = 0; + /* + * Print each hex byte. + * Add a comma until the very last byte of the AML file + * (Some C compilers complain about a trailing comma) + */ + FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); + if ((Offset + i + 1) < AmlFileSize) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); + } + else + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + } } + + /* Add fill spaces if needed for last line */ + + if (LineLength < HEX_TABLE_LINE_SIZE) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", + 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); + } + + /* Emit the offset and ascii dump for the entire line */ + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset); + LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", + HEX_TABLE_LINE_SIZE - LineLength + 1, " "); + + Offset += LineLength; } - FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n};\n"); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "};\n"); + FlCloseFile (ASL_FILE_HEX_OUTPUT); +} + + +/******************************************************************************* + * + * FUNCTION: LsDoHexOutputAsl + * + * PARAMETERS: None + * + * RETURN: None. + * + * DESCRIPTION: Create the hex output file. This is the same data as the AML + * output file, but formatted into hex/ascii bytes suitable for + * inclusion into a C source file. + * + ******************************************************************************/ + +static void +LsDoHexOutputAsl ( + void) +{ + UINT8 FileData[HEX_TABLE_LINE_SIZE]; + UINT32 LineLength; + UINT32 Offset = 0; + UINT32 AmlFileSize; + UINT32 i; + + + /* Get AML size, seek back to start */ + + AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " * ASL source code output\n"); + FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", + AmlFileSize); + FlPrintFile (ASL_FILE_HEX_OUTPUT, " Name (BUF1, Buffer()\n {\n"); + + while (Offset < AmlFileSize) + { + /* Read enough bytes needed for one output line */ + + LineLength = fread (FileData, 1, HEX_TABLE_LINE_SIZE, + Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + if (!LineLength) + { + break; + } + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + + for (i = 0; i < LineLength; i++) + { + /* + * Print each hex byte. + * Add a comma until the very last byte of the AML file + * (Some C compilers complain about a trailing comma) + */ + FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); + if ((Offset + i + 1) < AmlFileSize) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); + } + else + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + } + } + + /* Add fill spaces if needed for last line */ + + if (LineLength < HEX_TABLE_LINE_SIZE) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", + 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); + } + + /* Emit the offset and ascii dump for the entire line */ + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset); + LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", + HEX_TABLE_LINE_SIZE - LineLength + 1, " "); + + Offset += LineLength; + } + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " })\n"); FlCloseFile (ASL_FILE_HEX_OUTPUT); } @@ -1438,58 +1547,64 @@ static void LsDoHexOutputAsm ( void) { - UINT32 j; - UINT8 FileByte[HEX_TABLE_LINE_SIZE]; - UINT8 Buffer[4]; + UINT8 FileData[HEX_TABLE_LINE_SIZE]; + UINT32 LineLength; UINT32 Offset = 0; - BOOLEAN DoComma = FALSE; + UINT32 AmlFileSize; + UINT32 i; - FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n;\n"); + /* Get AML size, seek back to start */ - /* Start at the beginning of the AML file */ + AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n"); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "; AML code block contains 0x%X bytes\n;\n", + AmlFileSize); - /* Process all AML bytes in the AML file */ - - j = 0; - while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK) + while (Offset < AmlFileSize) { - if (j == 0) + /* Read enough bytes needed for one output line */ + + LineLength = fread (FileData, 1, HEX_TABLE_LINE_SIZE, + Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + if (!LineLength) { - FlPrintFile (ASL_FILE_HEX_OUTPUT, " db "); - } - else if (DoComma) - { - FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); - DoComma = FALSE; + break; } - /* Convert each AML byte to hex */ + FlPrintFile (ASL_FILE_HEX_OUTPUT, " db "); - UtConvertByteToAsmHex (FileByte[j], Buffer); - FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4); - - /* An occasional linefeed improves readability */ - - Offset++; - j++; - if (j >= HEX_TABLE_LINE_SIZE) + for (i = 0; i < LineLength; i++) { - FlPrintFile (ASL_FILE_HEX_OUTPUT, - " ;%8.8X", Offset - HEX_TABLE_LINE_SIZE); - - /* Write the ASCII character associated with each of the bytes */ - - LsDumpAscii (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte); - FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); - j = 0; + /* + * Print each hex byte. + * Add a comma until the last byte of the line + */ + FlPrintFile (ASL_FILE_HEX_OUTPUT, "0%2.2Xh", FileData[i]); + if ((i + 1) < LineLength) + { + FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); + } } - else + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + + /* Add fill spaces if needed for last line */ + + if (LineLength < HEX_TABLE_LINE_SIZE) { - DoComma = TRUE; + FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", + 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); } + + /* Emit the offset and ascii dump for the entire line */ + + FlPrintFile (ASL_FILE_HEX_OUTPUT, " ; %8.8X", Offset); + LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); + + Offset += LineLength; } FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c index e8b0c457ce57..76be1af0ecd5 100644 --- a/sys/contrib/dev/acpica/compiler/aslmain.c +++ b/sys/contrib/dev/acpica/compiler/aslmain.c @@ -167,7 +167,7 @@ AslDoResponseFile ( #define ASL_TOKEN_SEPARATORS " \t\n" -#define ASL_SUPPORTED_OPTIONS "@:2b:cd^e:fgh^i^I:l^o:p:r:s:t:v:w:x:" +#define ASL_SUPPORTED_OPTIONS "@:2b:c:d^e:fgh^i^I:l^no:p:r:s:t:v:w:x:" /******************************************************************************* @@ -203,13 +203,14 @@ Options ( printf ("\nAML Output Files:\n"); printf (" -s Create AML in assembler or C source file (*.asm or *.c)\n"); printf (" -i Create assembler or C include file (*.inc or *.h)\n"); - printf (" -t Create AML in assembler or C hex table (*.hex)\n"); + printf (" -t Create AML in assembler, C, or ASL hex table (*.hex)\n"); printf ("\nAML Code Generation:\n"); printf (" -oa Disable all optimizations (compatibility mode)\n"); printf (" -of Disable constant folding\n"); printf (" -oi Disable integer optimization to Zero/One/Ones\n"); printf (" -on Disable named reference string optimization\n"); + printf (" -cr Disable Resource Descriptor error checking\n"); printf (" -r Override table header Revision (1-255)\n"); printf ("\nListings:\n"); @@ -264,7 +265,7 @@ HelpMessage ( printf (" -b Create compiler debug/trace file (*.txt)\n"); printf (" Types: Parse/Tree/Both\n"); printf (" -f Ignore errors, force creation of AML output file(s)\n"); - printf (" -c Parse only, no output generation\n"); + printf (" -n Parse only, no output generation\n"); printf (" -ot Display compile times\n"); printf (" -x Set debug level for trace output\n"); } @@ -507,10 +508,16 @@ AslDoOptions ( case 'c': + switch (AcpiGbl_Optarg[0]) + { + case 'r': + Gbl_NoResourceChecking = TRUE; + break; - /* Parse only */ - - Gbl_ParseOnlyFlag = TRUE; + default: + printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); + return (-1); + } break; @@ -688,6 +695,14 @@ AslDoOptions ( break; + case 'n': + + /* Parse only */ + + Gbl_ParseOnlyFlag = TRUE; + break; + + case 'p': /* Override default AML output filename */ @@ -741,6 +756,10 @@ AslDoOptions ( Gbl_HexOutputFlag = HEX_OUTPUT_C; break; + case 's': + Gbl_HexOutputFlag = HEX_OUTPUT_ASL; + break; + default: printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); return (-1); diff --git a/sys/contrib/dev/acpica/compiler/aslpredef.c b/sys/contrib/dev/acpica/compiler/aslpredef.c index b9632f9c6e19..c3e49cd05b05 100644 --- a/sys/contrib/dev/acpica/compiler/aslpredef.c +++ b/sys/contrib/dev/acpica/compiler/aslpredef.c @@ -243,11 +243,11 @@ ApCheckForPredefinedMethod ( break; - case ACPI_EVENT_RESERVED_NAME: /* _Lxx, _Exx, and _Qxx methods */ + case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ Gbl_ReservedMethods++; - /* NumArguments must be zero for all _Lxx, _Exx, and _Qxx methods */ + /* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */ if (MethodInfo->NumArguments != 0) { @@ -346,12 +346,12 @@ ApCheckPredefinedReturnValue ( case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ - case ACPI_EVENT_RESERVED_NAME: /* _Lxx, _Exx, and _Qxx methods */ + case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ /* Just return, nothing to do */ return; - default: /* a real predefined ACPI name */ + default: /* A standard predefined ACPI name */ /* Exit if no return value expected */ @@ -425,29 +425,59 @@ ApCheckForPredefinedObject ( * or a predefined scope name */ Index = ApCheckForPredefinedName (Op, Name); - if (Index > ACPI_VALID_RESERVED_NAME_MAX) - { - return; - } - /* - * We found a matching predefind name. - * Check if this predefined name requires input arguments - */ - if (PredefinedNames[Index].Info.ParamCount > 0) + switch (Index) { + case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ + case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ + case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ + + /* Nothing to do */ + return; + + case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ + /* - * This predefined name must always be defined as a control - * method because it is required to have input arguments. + * These names must be control methods, by definition in ACPI spec. + * Also because they are defined to return no value. None of them + * require any arguments. */ AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, - "with arguments"); + "with zero arguments"); + return; + + default: /* A standard predefined ACPI name */ + + /* + * If this predefined name requires input arguments, then + * it must be implemented as a control method + */ + if (PredefinedNames[Index].Info.ParamCount > 0) + { + AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, + "with arguments"); + return; + } + + /* + * If no return value is expected from this predefined name, then + * it follows that it must be implemented as a control method + * (with zero args, because the args > 0 case was handled above) + * Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx + */ + if (!PredefinedNames[Index].Info.ExpectedBtypes) + { + AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, + "with zero arguments"); + return; + } + + /* Typecheck the actual object, it is the next argument */ + + ApCheckObjectType (Op->Asl.Child->Asl.Next, + PredefinedNames[Index].Info.ExpectedBtypes); + return; } - - /* Typecheck the actual object, it is the next argument */ - - ApCheckObjectType (Op->Asl.Child->Asl.Next, - PredefinedNames[Index].Info.ExpectedBtypes); } @@ -514,7 +544,7 @@ ApCheckForPredefinedName ( } } - /* Check for _Lxx, _Exx, _Qxx, _T_x. Warning if unknown predefined name */ + /* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */ return (ApCheckForSpecialName (Op, Name)); } @@ -530,7 +560,7 @@ ApCheckForPredefinedName ( * RETURN: None * * DESCRIPTION: Check for the "special" predefined names - - * _Lxx, _Exx, _Qxx, and _T_x + * _Lxx, _Exx, _Qxx, _Wxx, and _T_x * ******************************************************************************/ @@ -541,14 +571,16 @@ ApCheckForSpecialName ( { /* - * Check for the "special" predefined names. We know the first char is an - * underscore already. + * Check for the "special" predefined names. We already know that the + * first character is an underscore. * GPE: _Lxx * GPE: _Exx + * GPE: _Wxx * EC: _Qxx */ if ((Name[1] == 'L') || (Name[1] == 'E') || + (Name[1] == 'W') || (Name[1] == 'Q')) { /* The next two characters must be hex digits */ diff --git a/sys/contrib/dev/acpica/compiler/aslresource.c b/sys/contrib/dev/acpica/compiler/aslresource.c index 3242ba700d68..25289f54a21e 100644 --- a/sys/contrib/dev/acpica/compiler/aslresource.c +++ b/sys/contrib/dev/acpica/compiler/aslresource.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: aslresource - Resource templates and descriptors + * Module Name: aslresource - Resource template/descriptor utilities * *****************************************************************************/ @@ -124,6 +124,298 @@ ACPI_MODULE_NAME ("aslresource") +/******************************************************************************* + * + * FUNCTION: RsSmallAddressCheck + * + * PARAMETERS: Minimum - Address Min value + * Maximum - Address Max value + * Length - Address range value + * Alignment - Address alignment value + * MinOp - Original Op for Address Min + * MaxOp - Original Op for Address Max + * LengthOp - Original Op for address range + * AlignOp - Original Op for address alignment. If + * NULL, means "zero value for alignment is + * OK, and means 64K alignment" (for + * Memory24 descriptor) + * + * RETURN: None. Adds error messages to error log if necessary + * + * DESCRIPTION: Perform common value checks for "small" address descriptors. + * Currently: + * Io, Memory24, Memory32 + * + ******************************************************************************/ + +void +RsSmallAddressCheck ( + UINT8 Type, + UINT32 Minimum, + UINT32 Maximum, + UINT32 Length, + UINT32 Alignment, + ACPI_PARSE_OBJECT *MinOp, + ACPI_PARSE_OBJECT *MaxOp, + ACPI_PARSE_OBJECT *LengthOp, + ACPI_PARSE_OBJECT *AlignOp) +{ + + if (Gbl_NoResourceChecking) + { + return; + } + + /* Special case for Memory24, values are compressed */ + + if (Type == ACPI_RESOURCE_NAME_MEMORY24) + { + if (!Alignment) /* Alignment==0 means 64K - no invalid alignment */ + { + Alignment = ACPI_UINT16_MAX + 1; + } + + Minimum <<= 8; + Maximum <<= 8; + Length *= 256; + } + + /* IO descriptor has different definition of min/max, don't check */ + + if (Type != ACPI_RESOURCE_NAME_IO) + { + /* Basic checks on Min/Max/Length */ + + if (Minimum > Maximum) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL); + } + else if (Length > (Maximum - Minimum + 1)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL); + } + } + + /* Alignment of zero is not in ACPI spec, but is used to mean byte acc */ + + if (!Alignment) + { + Alignment = 1; + } + + /* Addresses must be an exact multiple of the alignment value */ + + if (Minimum % Alignment) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL); + } + if (Maximum % Alignment) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, NULL); + } +} + + +/******************************************************************************* + * + * FUNCTION: RsLargeAddressCheck + * + * PARAMETERS: Minimum - Address Min value + * Maximum - Address Max value + * Length - Address range value + * Granularity - Address granularity value + * Flags - General flags for address descriptors: + * _MIF, _MAF, _DEC + * MinOp - Original Op for Address Min + * MaxOp - Original Op for Address Max + * LengthOp - Original Op for address range + * GranOp - Original Op for address granularity + * + * RETURN: None. Adds error messages to error log if necessary + * + * DESCRIPTION: Perform common value checks for "large" address descriptors. + * Currently: + * WordIo, WordBusNumber, WordSpace + * DWordIo, DWordMemory, DWordSpace + * QWordIo, QWordMemory, QWordSpace + * ExtendedIo, ExtendedMemory, ExtendedSpace + * + * _MIF flag set means that the minimum address is fixed and is not relocatable + * _MAF flag set means that the maximum address is fixed and is not relocatable + * Length of zero means that the record size is variable + * + * This function implements the LEN/MIF/MAF/MIN/MAX/GRA rules within Table 6-40 + * of the ACPI 4.0a specification. Added 04/2010. + * + ******************************************************************************/ + +void +RsLargeAddressCheck ( + UINT64 Minimum, + UINT64 Maximum, + UINT64 Length, + UINT64 Granularity, + UINT8 Flags, + ACPI_PARSE_OBJECT *MinOp, + ACPI_PARSE_OBJECT *MaxOp, + ACPI_PARSE_OBJECT *LengthOp, + ACPI_PARSE_OBJECT *GranOp) +{ + + if (Gbl_NoResourceChecking) + { + return; + } + + /* Basic checks on Min/Max/Length */ + + if (Minimum > Maximum) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL); + return; + } + else if (Length > (Maximum - Minimum + 1)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL); + return; + } + + /* If specified (non-zero), ensure granularity is a power-of-two minus one */ + + if (Granularity) + { + if ((Granularity + 1) & + Granularity) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_GRANULARITY, GranOp, NULL); + return; + } + } + + /* + * Check the various combinations of Length, MinFixed, and MaxFixed + */ + if (Length) + { + /* Fixed non-zero length */ + + switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF)) + { + case 0: + /* + * Fixed length, variable locations (both _MIN and _MAX). + * Length must be a multiple of granularity + */ + if (Granularity & Length) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, LengthOp, NULL); + } + break; + + case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF): + + /* Fixed length, fixed location. Granularity must be zero */ + + if (Granularity != 0) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_GRAN_FIXED, GranOp, NULL); + } + + /* Length must be exactly the size of the min/max window */ + + if (Length != (Maximum - Minimum + 1)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH_FIXED, LengthOp, NULL); + } + break; + + /* All other combinations are invalid */ + + case ACPI_RESOURCE_FLAG_MIF: + case ACPI_RESOURCE_FLAG_MAF: + default: + AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL); + } + } + else + { + /* Variable length (length==0) */ + + switch (Flags & (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF)) + { + case 0: + /* + * Both _MIN and _MAX are variable. + * No additional requirements, just exit + */ + break; + + case ACPI_RESOURCE_FLAG_MIF: + + /* _MIN is fixed. _MIN must be multiple of _GRA */ + + /* + * The granularity is defined by the ACPI specification to be a + * power-of-two minus one, therefore the granularity is a + * bitmask which can be used to easily validate the addresses. + */ + if (Granularity & Minimum) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL); + } + break; + + case ACPI_RESOURCE_FLAG_MAF: + + /* _MAX is fixed. (_MAX + 1) must be multiple of _GRA */ + + if (Granularity & (Maximum + 1)) + { + AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, "-1"); + } + break; + + /* Both MIF/MAF set is invalid if length is zero */ + + case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF): + default: + AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: RsGetStringDataLength + * + * PARAMETERS: InitializerOp - Start of a subtree of init nodes + * + * RETURN: Valid string length if a string node is found (otherwise 0) + * + * DESCRIPTION: In a list of peer nodes, find the first one that contains a + * string and return the length of the string. + * + ******************************************************************************/ + +UINT16 +RsGetStringDataLength ( + ACPI_PARSE_OBJECT *InitializerOp) +{ + + while (InitializerOp) + { + if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) + { + return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1)); + } + InitializerOp = ASL_GET_PEER_NODE (InitializerOp); + } + + return 0; +} + + /******************************************************************************* * * FUNCTION: RsAllocateResourceNode diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1.c b/sys/contrib/dev/acpica/compiler/aslrestype1.c index 036abdf116fc..32f2cfc14580 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: aslrestype1 - Short (type1) resource templates and descriptors + * Module Name: aslrestype1 - Miscellaneous small resource descriptors * *****************************************************************************/ @@ -121,6 +121,18 @@ #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslrestype1") +/* + * This module contains miscellaneous small resource descriptors: + * + * EndTag + * EndDependentFn + * Memory24 + * Memory32 + * Memory32Fixed + * StartDependentFn + * StartDependentFnNoPri + * VendorShort + */ /******************************************************************************* * @@ -156,127 +168,6 @@ RsDoEndTagDescriptor ( } -/******************************************************************************* - * - * FUNCTION: RsDoDmaDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "DMA" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoDmaDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - UINT8 DmaChannelMask = 0; - UINT8 DmaChannels = 0; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA)); - - Descriptor = Rnode->Buffer; - Descriptor->Dma.DescriptorType = ACPI_RESOURCE_NAME_DMA | - ASL_RDESC_DMA_SIZE; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* DMA type */ - - RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DMATYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5); - break; - - case 1: /* Bus Master */ - - RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_BUSMASTER, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2); - break; - - case 2: /* Xfer Type (transfer width) */ - - RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_XFERTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0); - break; - - case 3: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - /* All DMA channel bytes are handled here, after flags and name */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - /* Up to 8 channels can be specified in the list */ - - DmaChannels++; - if (DmaChannels > 8) - { - AslError (ASL_ERROR, ASL_MSG_DMA_LIST, - InitializerOp, NULL); - return (Rnode); - } - - /* Only DMA channels 0-7 are allowed (mask is 8 bits) */ - - if (InitializerOp->Asl.Value.Integer > 7) - { - AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL, - InitializerOp, NULL); - } - - /* Build the mask */ - - DmaChannelMask |= - (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); - } - - if (i == 4) /* case 4: First DMA byte */ - { - /* Check now for duplicates in list */ - - RsCheckListForDuplicates (InitializerOp); - - /* Create a named field at the start of the list */ - - RsCreateByteField (InitializerOp, ACPI_RESTAG_DMA, - CurrentByteOffset + - ASL_RESDESC_OFFSET (Dma.DmaChannelMask)); - } - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - /* Now we can set the channel mask */ - - Descriptor->Dma.DmaChannelMask = DmaChannelMask; - return (Rnode); -} - - /******************************************************************************* * * FUNCTION: RsDoEndDependentDescriptor @@ -309,396 +200,6 @@ RsDoEndDependentDescriptor ( } -/******************************************************************************* - * - * FUNCTION: RsDoFixedIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "FixedIO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoFixedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO)); - - Descriptor = Rnode->Buffer; - Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_FIXED_IO | - ASL_RDESC_FIXED_IO_SIZE; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Base Address */ - - Descriptor->FixedIo.Address = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS, - CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address)); - break; - - case 1: /* Length */ - - Descriptor->FixedIo.AddressLength = - (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength)); - break; - - case 2: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "IO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO)); - - Descriptor = Rnode->Buffer; - Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_IO | - ASL_RDESC_IO_SIZE; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Decode size */ - - RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0); - break; - - case 1: /* Min Address */ - - Descriptor->Io.Minimum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum)); - break; - - case 2: /* Max Address */ - - Descriptor->Io.Maximum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum)); - break; - - case 3: /* Alignment */ - - Descriptor->Io.Alignment = - (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment)); - break; - - case 4: /* Length */ - - Descriptor->Io.AddressLength = - (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength)); - break; - - case 5: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoIrqDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "IRQ" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoIrqDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 Interrupts = 0; - UINT16 IrqMask = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ)); - - /* Length = 3 (with flag byte) */ - - Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | - (ASL_RDESC_IRQ_SIZE + 0x01); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Interrupt Type (or Mode - edge/level) */ - - RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0); - break; - - case 1: /* Interrupt Level (or Polarity - Active high/low) */ - - RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3); - break; - - case 2: /* Share Type - Default: exclusive (0) */ - - RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4); - break; - - case 3: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - /* All IRQ bytes are handled here, after the flags and name */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - /* Up to 16 interrupts can be specified in the list */ - - Interrupts++; - if (Interrupts > 16) - { - AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, - InitializerOp, NULL); - return (Rnode); - } - - /* Only interrupts 0-15 are allowed (mask is 16 bits) */ - - if (InitializerOp->Asl.Value.Integer > 15) - { - AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, - InitializerOp, NULL); - } - else - { - IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer); - } - } - - /* Case 4: First IRQ value in list */ - - if (i == 4) - { - /* Check now for duplicates in list */ - - RsCheckListForDuplicates (InitializerOp); - - /* Create a named field at the start of the list */ - - RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); - } - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - /* Now we can set the channel mask */ - - Descriptor->Irq.IrqMask = IrqMask; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoIrqNoFlagsDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a short "IRQNoFlags" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoIrqNoFlagsDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT16 IrqMask = 0; - UINT32 Interrupts = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS)); - - Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | - ASL_RDESC_IRQ_SIZE; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Name */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - /* IRQ bytes are handled here, after the flags and name */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - /* Up to 16 interrupts can be specified in the list */ - - Interrupts++; - if (Interrupts > 16) - { - AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, - InitializerOp, NULL); - return (Rnode); - } - - /* Only interrupts 0-15 are allowed (mask is 16 bits) */ - - if (InitializerOp->Asl.Value.Integer > 15) - { - AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, - InitializerOp, NULL); - } - else - { - IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); - } - } - - /* Case 1: First IRQ value in list */ - - if (i == 1) - { - /* Check now for duplicates in list */ - - RsCheckListForDuplicates (InitializerOp); - - /* Create a named field at the start of the list */ - - RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); - } - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - /* Now we can set the interrupt mask */ - - Descriptor->Irq.IrqMask = IrqMask; - return (Rnode); -} - - /******************************************************************************* * * FUNCTION: RsDoMemory24Descriptor @@ -720,6 +221,10 @@ RsDoMemory24Descriptor ( { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *AlignOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT32 i; @@ -749,6 +254,7 @@ RsDoMemory24Descriptor ( Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum)); + MinOp = InitializerOp; break; case 2: /* Max Address */ @@ -756,6 +262,7 @@ RsDoMemory24Descriptor ( Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum)); + MaxOp = InitializerOp; break; case 3: /* Alignment */ @@ -763,6 +270,7 @@ RsDoMemory24Descriptor ( Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment)); + AlignOp = InitializerOp; break; case 4: /* Length */ @@ -770,6 +278,7 @@ RsDoMemory24Descriptor ( Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength)); + LengthOp = InitializerOp; break; case 5: /* Name */ @@ -786,6 +295,15 @@ RsDoMemory24Descriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */ + + RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24, + Descriptor->Memory24.Minimum, + Descriptor->Memory24.Maximum, + Descriptor->Memory24.AddressLength, + Descriptor->Memory24.Alignment, + MinOp, MaxOp, LengthOp, NULL); + return (Rnode); } @@ -811,6 +329,10 @@ RsDoMemory32Descriptor ( { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *AlignOp = NULL; ASL_RESOURCE_NODE *Rnode; UINT32 i; @@ -840,6 +362,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum)); + MinOp = InitializerOp; break; case 2: /* Max Address */ @@ -847,6 +370,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum)); + MaxOp = InitializerOp; break; case 3: /* Alignment */ @@ -854,6 +378,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment)); + AlignOp = InitializerOp; break; case 4: /* Length */ @@ -861,6 +386,7 @@ RsDoMemory32Descriptor ( Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength)); + LengthOp = InitializerOp; break; case 5: /* Name */ @@ -877,6 +403,15 @@ RsDoMemory32Descriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } + /* Validate the Min/Max/Len/Align values */ + + RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32, + Descriptor->Memory32.Minimum, + Descriptor->Memory32.Maximum, + Descriptor->Memory32.AddressLength, + Descriptor->Memory32.Alignment, + MinOp, MaxOp, LengthOp, AlignOp); + return (Rnode); } @@ -1027,6 +562,7 @@ RsDoStartDependentDescriptor ( break; default: + NextRnode = RsDoOneResourceDescriptor (InitializerOp, CurrentByteOffset, &State); @@ -1036,7 +572,6 @@ RsDoStartDependentDescriptor ( * must keep track of the offset of not only each descriptor, but each * element (field) within each descriptor as well. */ - CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode); break; @@ -1182,4 +717,3 @@ RsDoVendorSmallDescriptor ( return (Rnode); } - diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1i.c b/sys/contrib/dev/acpica/compiler/aslrestype1i.c new file mode 100644 index 000000000000..a2b80cbc5f32 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslrestype1i.c @@ -0,0 +1,668 @@ + +/****************************************************************************** + * + * Module Name: aslrestype1i - Small I/O-related resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include +#include "aslcompiler.y.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype1i") + +/* + * This module contains the I/O-related small resource descriptors: + * + * DMA + * FixedIO + * IO + * IRQ + * IRQNoFlags + */ + +/******************************************************************************* + * + * FUNCTION: RsDoDmaDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a short "DMA" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoDmaDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + UINT32 i; + UINT8 DmaChannelMask = 0; + UINT8 DmaChannels = 0; + + + InitializerOp = Op->Asl.Child; + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA)); + + Descriptor = Rnode->Buffer; + Descriptor->Dma.DescriptorType = ACPI_RESOURCE_NAME_DMA | + ASL_RDESC_DMA_SIZE; + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* DMA type */ + + RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DMATYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5); + break; + + case 1: /* Bus Master */ + + RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_BUSMASTER, + CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2); + break; + + case 2: /* Xfer Type (transfer width) */ + + RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_XFERTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0); + break; + + case 3: /* Name */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + /* All DMA channel bytes are handled here, after flags and name */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + /* Up to 8 channels can be specified in the list */ + + DmaChannels++; + if (DmaChannels > 8) + { + AslError (ASL_ERROR, ASL_MSG_DMA_LIST, + InitializerOp, NULL); + return (Rnode); + } + + /* Only DMA channels 0-7 are allowed (mask is 8 bits) */ + + if (InitializerOp->Asl.Value.Integer > 7) + { + AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL, + InitializerOp, NULL); + } + + /* Build the mask */ + + DmaChannelMask |= + (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); + } + + if (i == 4) /* case 4: First DMA byte */ + { + /* Check now for duplicates in list */ + + RsCheckListForDuplicates (InitializerOp); + + /* Create a named field at the start of the list */ + + RsCreateByteField (InitializerOp, ACPI_RESTAG_DMA, + CurrentByteOffset + + ASL_RESDESC_OFFSET (Dma.DmaChannelMask)); + } + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Now we can set the channel mask */ + + Descriptor->Dma.DmaChannelMask = DmaChannelMask; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoFixedIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a short "FixedIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoFixedIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *AddressOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO)); + + Descriptor = Rnode->Buffer; + Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_FIXED_IO | + ASL_RDESC_FIXED_IO_SIZE; + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Base Address */ + + Descriptor->FixedIo.Address = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS, + CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address)); + AddressOp = InitializerOp; + break; + + case 1: /* Length */ + + Descriptor->FixedIo.AddressLength = + (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength)); + break; + + case 2: /* Name */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Error checks */ + + if (Descriptor->FixedIo.Address > 0x03FF) + { + AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL); + } + + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a short "IO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *AlignOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO)); + + Descriptor = Rnode->Buffer; + Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_IO | + ASL_RDESC_IO_SIZE; + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Decode size */ + + RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0); + break; + + case 1: /* Min Address */ + + Descriptor->Io.Minimum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum)); + MinOp = InitializerOp; + break; + + case 2: /* Max Address */ + + Descriptor->Io.Maximum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum)); + MaxOp = InitializerOp; + break; + + case 3: /* Alignment */ + + Descriptor->Io.Alignment = + (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT, + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment)); + AlignOp = InitializerOp; + break; + + case 4: /* Length */ + + Descriptor->Io.AddressLength = + (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength)); + LengthOp = InitializerOp; + break; + + case 5: /* Name */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Align values */ + + RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO, + Descriptor->Io.Minimum, + Descriptor->Io.Maximum, + Descriptor->Io.AddressLength, + Descriptor->Io.Alignment, + MinOp, MaxOp, LengthOp, AlignOp); + + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoIrqDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a short "IRQ" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoIrqDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + UINT32 Interrupts = 0; + UINT16 IrqMask = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ)); + + /* Length = 3 (with flag byte) */ + + Descriptor = Rnode->Buffer; + Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | + (ASL_RDESC_IRQ_SIZE + 0x01); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Interrupt Type (or Mode - edge/level) */ + + RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0); + break; + + case 1: /* Interrupt Level (or Polarity - Active high/low) */ + + RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL, + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3); + break; + + case 2: /* Share Type - Default: exclusive (0) */ + + RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4); + break; + + case 3: /* Name */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + /* All IRQ bytes are handled here, after the flags and name */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + /* Up to 16 interrupts can be specified in the list */ + + Interrupts++; + if (Interrupts > 16) + { + AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, + InitializerOp, NULL); + return (Rnode); + } + + /* Only interrupts 0-15 are allowed (mask is 16 bits) */ + + if (InitializerOp->Asl.Value.Integer > 15) + { + AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, + InitializerOp, NULL); + } + else + { + IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer); + } + } + + /* Case 4: First IRQ value in list */ + + if (i == 4) + { + /* Check now for duplicates in list */ + + RsCheckListForDuplicates (InitializerOp); + + /* Create a named field at the start of the list */ + + RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT, + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); + } + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Now we can set the channel mask */ + + Descriptor->Irq.IrqMask = IrqMask; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoIrqNoFlagsDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a short "IRQNoFlags" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoIrqNoFlagsDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + UINT16 IrqMask = 0; + UINT32 Interrupts = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS)); + + Descriptor = Rnode->Buffer; + Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | + ASL_RDESC_IRQ_SIZE; + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Name */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + /* IRQ bytes are handled here, after the flags and name */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + /* Up to 16 interrupts can be specified in the list */ + + Interrupts++; + if (Interrupts > 16) + { + AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, + InitializerOp, NULL); + return (Rnode); + } + + /* Only interrupts 0-15 are allowed (mask is 16 bits) */ + + if (InitializerOp->Asl.Value.Integer > 15) + { + AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, + InitializerOp, NULL); + } + else + { + IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); + } + } + + /* Case 1: First IRQ value in list */ + + if (i == 1) + { + /* Check now for duplicates in list */ + + RsCheckListForDuplicates (InitializerOp); + + /* Create a named field at the start of the list */ + + RsCreateByteField (InitializerOp, ACPI_RESTAG_INTERRUPT, + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); + } + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Now we can set the interrupt mask */ + + Descriptor->Irq.IrqMask = IrqMask; + return (Rnode); +} diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2.c b/sys/contrib/dev/acpica/compiler/aslrestype2.c index 48be8536600f..e1537018f747 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2.c @@ -1,7 +1,7 @@ /****************************************************************************** * - * Module Name: aslrestype2 - Long (type2) resource templates and descriptors + * Module Name: aslrestype2 - Miscellaneous Large resource descriptors * *****************************************************************************/ @@ -117,51 +117,22 @@ #include #include "aslcompiler.y.h" +#include #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslrestype2") -/* Local prototypes */ - -static UINT16 -RsGetStringDataLength ( - ACPI_PARSE_OBJECT *InitializerOp); - +/* + * This module contains miscellaneous large resource descriptors: + * + * Register + * Interrupt + * VendorLong + */ /******************************************************************************* * - * FUNCTION: RsGetStringDataLength - * - * PARAMETERS: InitializerOp - Start of a subtree of init nodes - * - * RETURN: Valid string length if a string node is found (otherwise 0) - * - * DESCRIPTION: In a list of peer nodes, find the first one that contains a - * string and return the length of the string. - * - ******************************************************************************/ - -static UINT16 -RsGetStringDataLength ( - ACPI_PARSE_OBJECT *InitializerOp) -{ - - while (InitializerOp) - { - if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) - { - return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1)); - } - InitializerOp = ASL_GET_PEER_NODE (InitializerOp); - } - - return 0; -} - - -/******************************************************************************* - * - * FUNCTION: RsDoDwordIoDescriptor + * FUNCTION: RsDoGeneralRegisterDescriptor * * PARAMETERS: Op - Parent resource descriptor parse node * CurrentByteOffset - Offset into the resource template AML @@ -169,43 +140,27 @@ RsGetStringDataLength ( * * RETURN: Completed resource node * - * DESCRIPTION: Construct a long "DwordIO" descriptor + * DESCRIPTION: Construct a long "Register" descriptor * ******************************************************************************/ ASL_RESOURCE_NODE * -RsDoDwordIoDescriptor ( +RsDoGeneralRegisterDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT8 *OptionalFields; UINT32 i; - BOOLEAN ResSourceIndex = FALSE; InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER)); Descriptor = Rnode->Buffer; - Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); - Descriptor->Address32.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS32) - - sizeof (AML_RESOURCE_LARGE_HEADER)); + Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER; + Descriptor->GenericReg.ResourceLength = 12; /* Process all child initialization nodes */ @@ -213,1637 +168,48 @@ RsDoDwordIoDescriptor ( { switch (i) { - case 0: /* Resource Usage */ + case 0: /* Address space */ - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); - break; - - case 4: /* Range Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 3); - RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); - break; - - case 5: /* Address Granularity */ - - Descriptor->Address32.Granularity = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); - break; - - case 6: /* Address Min */ - - Descriptor->Address32.Minimum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); - break; - - case 7: /* Address Max */ - - Descriptor->Address32.Maximum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); - break; - - case 8: /* Translation Offset */ - - Descriptor->Address32.TranslationOffset = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); - break; - - case 9: /* Address Length */ - - Descriptor->Address32.AddressLength = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); - break; - - case 10: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - /* Found a valid ResourceSourceIndex */ - - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address32.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 11: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - /* Found a valid ResourceSource */ - - Descriptor->Address32.ResourceLength = (UINT16) - (Descriptor->Address32.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - case 13: /* Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 4); - break; - - case 14: /* Translation Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoDwordMemoryDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "DwordMemory" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoDwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); - Descriptor->Address32.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS32) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); - break; - - case 1: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); - break; - - case 2: /* MinType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); - break; - - case 3: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); - break; - - case 4: /* Memory Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 1); - break; - - case 5: /* Read/Write Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); - break; - - case 6: /* Address Granularity */ - - Descriptor->Address32.Granularity = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address32.Minimum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->Address32.Maximum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->Address32.TranslationOffset = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->Address32.AddressLength = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); - break; - - case 11: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address32.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address32.ResourceLength = (UINT16) - (Descriptor->Address32.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 13: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - - case 14: /* Address Range */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 3); - break; - - case 15: /* Type */ - - RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoDwordSpaceDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "DwordSpace" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoDwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); - Descriptor->Address32.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS32) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Type */ - - Descriptor->Address32.ResourceType = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 1: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); - break; - - case 2: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); - break; - - case 3: /* MinType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); - break; - - case 4: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); - break; - - case 5: /* Type-Specific flags */ - - Descriptor->Address32.SpecificFlags = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 6: /* Address Granularity */ - - Descriptor->Address32.Granularity = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address32.Minimum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->Address32.Maximum = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->Address32.TranslationOffset = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->Address32.AddressLength = - (UINT32) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); - break; - - case 11: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address32.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address32.ResourceLength = (UINT16) - (Descriptor->Address32.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 13: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, - InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoExtendedIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "ExtendedIO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoExtendedIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT16 StringLength = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - - Descriptor->ExtAddress64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); - break; - - case 4: /* Range Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 3); - RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); - break; - - case 5: /* Address Granularity */ - - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + Descriptor->GenericReg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESSSPACE, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AddressSpaceId)); break; - case 6: /* Address Min */ + case 1: /* Register Bit Width */ - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + Descriptor->GenericReg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITWIDTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitWidth)); break; - case 7: /* Address Max */ + case 2: /* Register Bit Offset */ - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + Descriptor->GenericReg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITOFFSET, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitOffset)); break; - case 8: /* Translation Offset */ + case 3: /* Register Address */ - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESS, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address)); break; - case 9: /* Address Length */ + case 4: /* Access Size (ACPI 3.0) */ - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); - break; + Descriptor->GenericReg.AccessSize = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_ACCESSSIZE, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize)); - case 10: /* Type-Specific Attributes */ - - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); - break; - - case 11: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - case 12: /* Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 4); - break; - - case 13: /* Translation Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoExtendedMemoryDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "ExtendedMemory" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoExtendedMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT16 StringLength = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - - Descriptor->ExtAddress64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); - break; - - case 1: /* DecodeType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); - break; - - case 2: /* MinType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); - break; - - case 3: /* MaxType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); - break; - - case 4: /* Memory Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 1); - break; - - case 5: /* Read/Write Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); - break; - - case 6: /* Address Granularity */ - - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); - break; - - case 11: /* Type-Specific Attributes */ - - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); - break; - - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - - case 13: /* Address Range */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 3); - break; - - case 14: /* Type */ - - RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoExtendedSpaceDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "ExtendedSpace" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoExtendedSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT16 StringLength = 0; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; - Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; - - Descriptor->ExtAddress64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Type */ - - Descriptor->ExtAddress64.ResourceType = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 1: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); - break; - - case 2: /* DecodeType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); - break; - - case 3: /* MinType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); - break; - - case 4: /* MaxType */ - - RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); - break; - - case 5: /* Type-Specific flags */ - - Descriptor->ExtAddress64.SpecificFlags = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 6: /* Address Granularity */ - - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); - break; - - case 11: /* Type-Specific Attributes */ - - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); - break; - - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoQwordIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "QwordIO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoQwordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); - Descriptor->Address64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); - break; - - case 4: /* Range Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 3); - RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); - break; - - case 5: /* Address Granularity */ - - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); - break; - - case 6: /* Address Min */ - - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); - break; - - case 7: /* Address Max */ - - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); - break; - - case 8: /* Translation Offset */ - - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); - break; - - case 9: /* Address Length */ - - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); - break; - - case 10: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + if (Descriptor->GenericReg.AccessSize > AML_FIELD_ACCESS_QWORD) { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address64.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 11: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address64.ResourceLength = (UINT16) - (Descriptor->Address64.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + AslError (ASL_ERROR, ASL_MSG_INVALID_ACCESS_SIZE, InitializerOp, NULL); } -#endif break; - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - case 13: /* Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 4); - break; - - case 14: /* Translation Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoQwordMemoryDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "QwordMemory" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoQwordMemoryDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); - Descriptor->Address64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); - break; - - case 1: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); - break; - - case 2: /* MinType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); - break; - - case 3: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); - break; - - case 4: /* Memory Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 1); - break; - - case 5: /* Read/Write Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 1); - RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); - break; - - case 6: /* Address Granularity */ - - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); - break; - - case 11: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address64.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address64.ResourceLength = (UINT16) - (Descriptor->Address64.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 13: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - - case 14: /* Address Range */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 3); - break; - - case 15: /* Type */ - - RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoQwordSpaceDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "QwordSpace" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoQwordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); - Descriptor->Address64.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS64) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Type */ - - Descriptor->Address64.ResourceType = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 1: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); - break; - - case 2: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); - break; - - case 3: /* MinType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); - break; - - case 4: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); - break; - - case 5: /* Type-Specific flags */ - - Descriptor->Address64.SpecificFlags = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 6: /* Address Granularity */ - - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); - break; - - case 11: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address64.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address64.ResourceLength = (UINT16) - (Descriptor->Address64.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 13: /* ResourceTag */ + case 5: /* ResourceTag (ACPI 3.0b) */ UtAttachNamepathToOwner (Op, InitializerOp); break; @@ -1856,600 +222,6 @@ RsDoQwordSpaceDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoWordIoDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "WordIO" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoWordIoDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); - Descriptor->Address16.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS16) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); - break; - - case 4: /* Range Type */ - - RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 0, 3); - RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 0); - break; - - case 5: /* Address Granularity */ - - Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); - break; - - case 6: /* Address Min */ - - Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); - break; - - case 7: /* Address Max */ - - Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); - break; - - case 8: /* Translation Offset */ - - Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); - break; - - case 9: /* Address Length */ - - Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); - break; - - case 10: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address16.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 11: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address16.ResourceLength = (UINT16) - (Descriptor->Address16.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 12: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - case 13: /* Type */ - - RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 4, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 4); - break; - - case 14: /* Translation Type */ - - RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 5, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 5); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoWordBusNumberDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "WordBusNumber" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoWordBusNumberDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); - Descriptor->Address16.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS16) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); - break; - - case 1: /* MinType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); - break; - - case 2: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); - break; - - case 3: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); - break; - - case 4: /* Address Granularity */ - - Descriptor->Address16.Granularity = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); - break; - - case 5: /* Min Address */ - - Descriptor->Address16.Minimum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); - break; - - case 6: /* Max Address */ - - Descriptor->Address16.Maximum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); - break; - - case 7: /* Translation Offset */ - - Descriptor->Address16.TranslationOffset = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); - break; - - case 8: /* Address Length */ - - Descriptor->Address16.AddressLength = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); - break; - - case 9: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address16.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 10: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address16.ResourceLength = (UINT16) - (Descriptor->Address16.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 11: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; - return (Rnode); -} - - -/******************************************************************************* - * - * FUNCTION: RsDoWordSpaceDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "WordSpace" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoWordSpaceDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT8 *OptionalFields; - UINT16 StringLength = 0; - UINT32 OptionIndex = 0; - UINT32 i; - BOOLEAN ResSourceIndex = FALSE; - - - InitializerOp = Op->Asl.Child; - StringLength = RsGetStringDataLength (InitializerOp); - - Rnode = RsAllocateResourceNode ( - sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); - - Descriptor = Rnode->Buffer; - Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; - - /* - * Initial descriptor length -- may be enlarged if there are - * optional fields present - */ - OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); - Descriptor->Address16.ResourceLength = (UINT16) - (sizeof (AML_RESOURCE_ADDRESS16) - - sizeof (AML_RESOURCE_LARGE_HEADER)); - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Resource Type */ - - Descriptor->Address16.ResourceType = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 1: /* Resource Usage */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); - break; - - case 2: /* DecodeType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); - break; - - case 3: /* MinType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); - break; - - case 4: /* MaxType */ - - RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); - RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); - break; - - case 5: /* Type-Specific flags */ - - Descriptor->Address16.SpecificFlags = - (UINT8) InitializerOp->Asl.Value.Integer; - break; - - case 6: /* Address Granularity */ - - Descriptor->Address16.Granularity = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); - break; - - case 7: /* Min Address */ - - Descriptor->Address16.Minimum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); - break; - - case 8: /* Max Address */ - - Descriptor->Address16.Maximum = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); - break; - - case 9: /* Translation Offset */ - - Descriptor->Address16.TranslationOffset = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); - break; - - case 10: /* Address Length */ - - Descriptor->Address16.AddressLength = - (UINT16) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); - break; - - case 11: /* ResSourceIndex [Optional Field - BYTE] */ - - if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) - { - OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; - OptionIndex++; - Descriptor->Address16.ResourceLength++; - ResSourceIndex = TRUE; - } - break; - - case 12: /* ResSource [Optional Field - STRING] */ - - if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (InitializerOp->Asl.Value.String)) - { - if (StringLength) - { - Descriptor->Address16.ResourceLength = (UINT16) - (Descriptor->Address16.ResourceLength + StringLength); - - strcpy ((char *) - &OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); - - /* ResourceSourceIndex must also be valid */ - - if (!ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, - InitializerOp, NULL); - } - } - } - -#if 0 - /* - * Not a valid ResourceSource, ResourceSourceIndex must also - * be invalid - */ - else if (ResSourceIndex) - { - AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, - InitializerOp, NULL); - } -#endif - break; - - case 13: /* ResourceTag */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - - Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + - OptionIndex + StringLength; return (Rnode); } @@ -2760,95 +532,3 @@ RsDoVendorLargeDescriptor ( return (Rnode); } - - -/******************************************************************************* - * - * FUNCTION: RsDoGeneralRegisterDescriptor - * - * PARAMETERS: Op - Parent resource descriptor parse node - * CurrentByteOffset - Offset into the resource template AML - * buffer (to track references to the desc) - * - * RETURN: Completed resource node - * - * DESCRIPTION: Construct a long "Register" descriptor - * - ******************************************************************************/ - -ASL_RESOURCE_NODE * -RsDoGeneralRegisterDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset) -{ - AML_RESOURCE *Descriptor; - ACPI_PARSE_OBJECT *InitializerOp; - ASL_RESOURCE_NODE *Rnode; - UINT32 i; - - - InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER)); - - Descriptor = Rnode->Buffer; - Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER; - Descriptor->GenericReg.ResourceLength = 12; - - /* Process all child initialization nodes */ - - for (i = 0; InitializerOp; i++) - { - switch (i) - { - case 0: /* Address space */ - - Descriptor->GenericReg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESSSPACE, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AddressSpaceId)); - break; - - case 1: /* Register Bit Width */ - - Descriptor->GenericReg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITWIDTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitWidth)); - break; - - case 2: /* Register Bit Offset */ - - Descriptor->GenericReg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITOFFSET, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitOffset)); - break; - - case 3: /* Register Address */ - - Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESS, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address)); - break; - - case 4: /* Access Size (ACPI 3.0) */ - - Descriptor->GenericReg.AccessSize = (UINT8) InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ACPI_RESTAG_ACCESSSIZE, - CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize)); - break; - - case 5: /* ResourceTag (ACPI 3.0b) */ - - UtAttachNamepathToOwner (Op, InitializerOp); - break; - - default: - - AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); - break; - } - - InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - } - return (Rnode); -} - - diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2d.c b/sys/contrib/dev/acpica/compiler/aslrestype2d.c new file mode 100644 index 000000000000..db0a2a7b85d5 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslrestype2d.c @@ -0,0 +1,814 @@ + +/****************************************************************************** + * + * Module Name: aslrestype2d - Large DWord address resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include +#include "aslcompiler.y.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype2d") + +/* + * This module contains the Dword (32-bit) address space descriptors: + * + * DwordIO + * DwordMemory + * DwordSpace + */ + +/******************************************************************************* + * + * FUNCTION: RsDoDwordIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "DwordIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoDwordIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT8 *OptionalFields; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); + Descriptor->Address32.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS32) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); + break; + + case 4: /* Range Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 3); + RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); + break; + + case 5: /* Address Granularity */ + + Descriptor->Address32.Granularity = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); + GranOp = InitializerOp; + break; + + case 6: /* Address Min */ + + Descriptor->Address32.Minimum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); + MinOp = InitializerOp; + break; + + case 7: /* Address Max */ + + Descriptor->Address32.Maximum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); + MaxOp = InitializerOp; + break; + + case 8: /* Translation Offset */ + + Descriptor->Address32.TranslationOffset = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); + break; + + case 9: /* Address Length */ + + Descriptor->Address32.AddressLength = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); + LengthOp = InitializerOp; + break; + + case 10: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + /* Found a valid ResourceSourceIndex */ + + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address32.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 11: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + /* Found a valid ResourceSource */ + + Descriptor->Address32.ResourceLength = (UINT16) + (Descriptor->Address32.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 13: /* Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 4); + break; + + case 14: /* Translation Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address32.Minimum, + Descriptor->Address32.Maximum, + Descriptor->Address32.AddressLength, + Descriptor->Address32.Granularity, + Descriptor->Address32.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoDwordMemoryDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "DwordMemory" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoDwordMemoryDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); + Descriptor->Address32.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS32) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); + break; + + case 1: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); + break; + + case 2: /* MinType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); + break; + + case 3: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); + break; + + case 4: /* Memory Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 1); + break; + + case 5: /* Read/Write Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 1); + RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); + break; + + case 6: /* Address Granularity */ + + Descriptor->Address32.Granularity = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address32.Minimum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address32.Maximum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address32.TranslationOffset = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address32.AddressLength = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address32.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address32.ResourceLength = (UINT16) + (Descriptor->Address32.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + + case 14: /* Address Range */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 3); + break; + + case 15: /* Type */ + + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address32.Minimum, + Descriptor->Address32.Maximum, + Descriptor->Address32.AddressLength, + Descriptor->Address32.Granularity, + Descriptor->Address32.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoDwordSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "DwordSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoDwordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); + Descriptor->Address32.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS32) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->Address32.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->Address32.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->Address32.Granularity = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address32.Minimum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address32.Maximum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address32.TranslationOffset = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address32.AddressLength = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address32.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address32.ResourceLength = (UINT16) + (Descriptor->Address32.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, + InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address32.Minimum, + Descriptor->Address32.Maximum, + Descriptor->Address32.AddressLength, + Descriptor->Address32.Granularity, + Descriptor->Address32.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + + OptionIndex + StringLength; + return (Rnode); +} diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2e.c b/sys/contrib/dev/acpica/compiler/aslrestype2e.c new file mode 100644 index 000000000000..b75d174fac1c --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslrestype2e.c @@ -0,0 +1,646 @@ + +/****************************************************************************** + * + * Module Name: aslrestype2e - Large Extended address resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include +#include "aslcompiler.y.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype2e") + +/* + * This module contains the Extended (64-bit) address space descriptors: + * + * ExtendedIO + * ExtendedMemory + * ExtendedSpace + */ + +/******************************************************************************* + * + * FUNCTION: RsDoExtendedIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ExtendedIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoExtendedIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + + Descriptor->ExtAddress64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); + break; + + case 4: /* Range Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 3); + RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); + break; + + case 5: /* Address Granularity */ + + Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + GranOp = InitializerOp; + break; + + case 6: /* Address Min */ + + Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + MinOp = InitializerOp; + break; + + case 7: /* Address Max */ + + Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + MaxOp = InitializerOp; + break; + + case 8: /* Translation Offset */ + + Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + break; + + case 9: /* Address Length */ + + Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 10: /* Type-Specific Attributes */ + + Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); + break; + + case 11: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 12: /* Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 4); + break; + + case 13: /* Translation Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->ExtAddress64.Minimum, + Descriptor->ExtAddress64.Maximum, + Descriptor->ExtAddress64.AddressLength, + Descriptor->ExtAddress64.Granularity, + Descriptor->ExtAddress64.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoExtendedMemoryDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ExtendedMemory" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoExtendedMemoryDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + + Descriptor->ExtAddress64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* DecodeType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); + break; + + case 2: /* MinType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); + break; + + case 3: /* MaxType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); + break; + + case 4: /* Memory Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 1); + break; + + case 5: /* Read/Write Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 1); + RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); + break; + + case 6: /* Address Granularity */ + + Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* Type-Specific Attributes */ + + Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + + case 13: /* Address Range */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 3); + break; + + case 14: /* Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->ExtAddress64.Minimum, + Descriptor->ExtAddress64.Maximum, + Descriptor->ExtAddress64.AddressLength, + Descriptor->ExtAddress64.Granularity, + Descriptor->ExtAddress64.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoExtendedSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ExtendedSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoExtendedSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + + Descriptor->ExtAddress64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->ExtAddress64.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->ExtAddress64.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* Type-Specific Attributes */ + + Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->ExtAddress64.Minimum, + Descriptor->ExtAddress64.Maximum, + Descriptor->ExtAddress64.AddressLength, + Descriptor->ExtAddress64.Granularity, + Descriptor->ExtAddress64.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + return (Rnode); +} diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2q.c b/sys/contrib/dev/acpica/compiler/aslrestype2q.c new file mode 100644 index 000000000000..cea12aa49128 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslrestype2q.c @@ -0,0 +1,793 @@ + +/****************************************************************************** + * + * Module Name: aslrestype2q - Large QWord address resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include +#include "aslcompiler.y.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype2q") + +/* + * This module contains the QWord (64-bit) address space descriptors: + * + * QWordIO + * QWordMemory + * QWordSpace + */ + +/******************************************************************************* + * + * FUNCTION: RsDoQwordIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "QwordIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoQwordIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); + Descriptor->Address64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); + break; + + case 4: /* Range Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 3); + RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); + break; + + case 5: /* Address Granularity */ + + Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); + GranOp = InitializerOp; + break; + + case 6: /* Address Min */ + + Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); + MinOp = InitializerOp; + break; + + case 7: /* Address Max */ + + Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); + MaxOp = InitializerOp; + break; + + case 8: /* Translation Offset */ + + Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); + break; + + case 9: /* Address Length */ + + Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 10: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address64.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 11: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address64.ResourceLength = (UINT16) + (Descriptor->Address64.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 13: /* Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 4); + break; + + case 14: /* Translation Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address64.Minimum, + Descriptor->Address64.Maximum, + Descriptor->Address64.AddressLength, + Descriptor->Address64.Granularity, + Descriptor->Address64.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoQwordMemoryDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "QwordMemory" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoQwordMemoryDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); + Descriptor->Address64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); + break; + + case 2: /* MinType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); + break; + + case 3: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); + break; + + case 4: /* Memory Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 1); + break; + + case 5: /* Read/Write Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 1); + RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); + break; + + case 6: /* Address Granularity */ + + Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address64.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address64.ResourceLength = (UINT16) + (Descriptor->Address64.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + + case 14: /* Address Range */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 3); + break; + + case 15: /* Type */ + + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address64.Minimum, + Descriptor->Address64.Maximum, + Descriptor->Address64.AddressLength, + Descriptor->Address64.Granularity, + Descriptor->Address64.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoQwordSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "QwordSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoQwordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); + Descriptor->Address64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->Address64.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->Address64.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address64.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address64.ResourceLength = (UINT16) + (Descriptor->Address64.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address64.Minimum, + Descriptor->Address64.Maximum, + Descriptor->Address64.AddressLength, + Descriptor->Address64.Granularity, + Descriptor->Address64.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + + OptionIndex + StringLength; + return (Rnode); +} diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2w.c b/sys/contrib/dev/acpica/compiler/aslrestype2w.c new file mode 100644 index 000000000000..fa0bb2226a1a --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/aslrestype2w.c @@ -0,0 +1,774 @@ + +/****************************************************************************** + * + * Module Name: aslrestype2w - Large Word address resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include +#include "aslcompiler.y.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype2w") + +/* + * This module contains the Word (16-bit) address space descriptors: + * + * WordIO + * WordMemory + * WordSpace + */ + +/******************************************************************************* + * + * FUNCTION: RsDoWordIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "WordIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoWordIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); + Descriptor->Address16.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS16) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); + break; + + case 4: /* Range Type */ + + RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 0, 3); + RsCreateBitField (InitializerOp, ACPI_RESTAG_RANGETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 0); + break; + + case 5: /* Address Granularity */ + + Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); + GranOp = InitializerOp; + break; + + case 6: /* Address Min */ + + Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); + MinOp = InitializerOp; + break; + + case 7: /* Address Max */ + + Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); + MaxOp = InitializerOp; + break; + + case 8: /* Translation Offset */ + + Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); + break; + + case 9: /* Address Length */ + + Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); + LengthOp = InitializerOp; + break; + + case 10: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address16.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 11: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address16.ResourceLength = (UINT16) + (Descriptor->Address16.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 13: /* Type */ + + RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 4); + break; + + case 14: /* Translation Type */ + + RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address16.Minimum, + Descriptor->Address16.Maximum, + Descriptor->Address16.AddressLength, + Descriptor->Address16.Granularity, + Descriptor->Address16.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoWordBusNumberDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "WordBusNumber" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoWordBusNumberDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); + Descriptor->Address16.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS16) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); + break; + + case 4: /* Address Granularity */ + + Descriptor->Address16.Granularity = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); + GranOp = InitializerOp; + break; + + case 5: /* Min Address */ + + Descriptor->Address16.Minimum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); + MinOp = InitializerOp; + break; + + case 6: /* Max Address */ + + Descriptor->Address16.Maximum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); + MaxOp = InitializerOp; + break; + + case 7: /* Translation Offset */ + + Descriptor->Address16.TranslationOffset = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); + break; + + case 8: /* Address Length */ + + Descriptor->Address16.AddressLength = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); + LengthOp = InitializerOp; + break; + + case 9: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address16.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 10: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address16.ResourceLength = (UINT16) + (Descriptor->Address16.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 11: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address16.Minimum, + Descriptor->Address16.Maximum, + Descriptor->Address16.AddressLength, + Descriptor->Address16.Granularity, + Descriptor->Address16.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoWordSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "WordSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoWordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ACPI_PARSE_OBJECT *MinOp = NULL; + ACPI_PARSE_OBJECT *MaxOp = NULL; + ACPI_PARSE_OBJECT *LengthOp = NULL; + ACPI_PARSE_OBJECT *GranOp = NULL; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); + Descriptor->Address16.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS16) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->Address16.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->Address16.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->Address16.Granularity = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); + GranOp = InitializerOp; + break; + + case 7: /* Min Address */ + + Descriptor->Address16.Minimum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); + MinOp = InitializerOp; + break; + + case 8: /* Max Address */ + + Descriptor->Address16.Maximum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); + MaxOp = InitializerOp; + break; + + case 9: /* Translation Offset */ + + Descriptor->Address16.TranslationOffset = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address16.AddressLength = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); + LengthOp = InitializerOp; + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address16.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address16.ResourceLength = (UINT16) + (Descriptor->Address16.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + /* Validate the Min/Max/Len/Gran values */ + + RsLargeAddressCheck ( + Descriptor->Address16.Minimum, + Descriptor->Address16.Maximum, + Descriptor->Address16.AddressLength, + Descriptor->Address16.Granularity, + Descriptor->Address16.Flags, + MinOp, MaxOp, LengthOp, GranOp); + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + + OptionIndex + StringLength; + return (Rnode); +} diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h index 30b8fdfe7d04..815763499d51 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.h +++ b/sys/contrib/dev/acpica/compiler/asltypes.h @@ -420,7 +420,16 @@ typedef enum ASL_MSG_SERIALIZED, ASL_MSG_COMPILER_RESERVED, ASL_MSG_NAMED_OBJECT_IN_WHILE, - ASL_MSG_LOCAL_OUTSIDE_METHOD + ASL_MSG_LOCAL_OUTSIDE_METHOD, + ASL_MSG_ALIGNMENT, + ASL_MSG_ISA_ADDRESS, + ASL_MSG_INVALID_MIN_MAX, + ASL_MSG_INVALID_LENGTH, + ASL_MSG_INVALID_LENGTH_FIXED, + ASL_MSG_INVALID_GRANULARITY, + ASL_MSG_INVALID_GRAN_FIXED, + ASL_MSG_INVALID_ACCESS_SIZE, + ASL_MSG_INVALID_ADDR_FLAGS } ASL_MESSAGE_IDS; @@ -540,7 +549,16 @@ char *AslMessages [] = { /* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", /* ASL_MSG_COMPILER_RESERVED */ "Use of compiler reserved name", /* ASL_MSG_NAMED_OBJECT_IN_WHILE */ "Creating a named object in a While loop", -/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method" +/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method", +/* ASL_MSG_ALIGNMENT */ "Must be a multiple of alignment/granularity value", +/* ASL_MSG_ISA_ADDRESS */ "Maximum 10-bit ISA address (0x3FF)", +/* ASL_MSG_INVALID_MIN_MAX */ "Address Min is greater than Address Max", +/* ASL_MSG_INVALID_LENGTH */ "Length is larger than Min/Max window", +/* ASL_MSG_INVALID_LENGTH_FIXED */ "Length is not equal to fixed Min/Max window", +/* ASL_MSG_INVALID_GRANULARITY */ "Granularity must be zero or a power of two minus one", +/* ASL_MSG_INVALID_GRAN_FIXED */ "Granularity must be zero for fixed Min/Max", +/* ASL_MSG_INVALID_ACCESS_SIZE */ "Invalid AccessSize (Maximum is 4 - QWord access)", +/* ASL_MSG_INVALID_ADDR_FLAGS */ "Invalid combination of Length and Min/Max fixed flags" }; diff --git a/sys/contrib/dev/acpica/debugger/dbcmds.c b/sys/contrib/dev/acpica/debugger/dbcmds.c index 0c704e7e386a..a5f594145eac 100644 --- a/sys/contrib/dev/acpica/debugger/dbcmds.c +++ b/sys/contrib/dev/acpica/debugger/dbcmds.c @@ -675,7 +675,7 @@ AcpiDbDisplayTableInfo ( /* Walk the entire root table list */ - for (i = 0; i < AcpiGbl_RootTableList.Count; i++) + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { TableDesc = &AcpiGbl_RootTableList.Tables[i]; AcpiOsPrintf ("%d ", i); diff --git a/sys/contrib/dev/acpica/debugger/dbdisply.c b/sys/contrib/dev/acpica/debugger/dbdisply.c index 41094891ad7d..9c85200b31db 100644 --- a/sys/contrib/dev/acpica/debugger/dbdisply.c +++ b/sys/contrib/dev/acpica/debugger/dbdisply.c @@ -816,6 +816,7 @@ AcpiDbDisplayGpes ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo; ACPI_GPE_EVENT_INFO *GpeEventInfo; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + char *GpeType; UINT32 GpeIndex; UINT32 Block = 0; UINT32 i; @@ -844,8 +845,17 @@ AcpiDbDisplayGpes ( AcpiOsPrintf ("Could not convert name to pathname\n"); } - AcpiOsPrintf ("\nBlock %d - Info %p DeviceNode %p [%s]\n", - Block, GpeBlock, GpeBlock->Node, Buffer); + if (GpeBlock->Node == AcpiGbl_FadtGpeDevice) + { + GpeType = "FADT-defined GPE block"; + } + else + { + GpeType = "GPE Block Device"; + } + + AcpiOsPrintf ("\nBlock %d - Info %p DeviceNode %p [%s] - %s\n", + Block, GpeBlock, GpeBlock->Node, Buffer, GpeType); AcpiOsPrintf (" Registers: %u (%u GPEs)\n", GpeBlock->RegisterCount, GpeBlock->GpeCount); diff --git a/sys/contrib/dev/acpica/events/evgpe.c b/sys/contrib/dev/acpica/events/evgpe.c index 0ece12ca78c4..892b2c37f527 100644 --- a/sys/contrib/dev/acpica/events/evgpe.c +++ b/sys/contrib/dev/acpica/events/evgpe.c @@ -370,7 +370,7 @@ AcpiEvGetGpeEventInfo ( ACPI_FUNCTION_ENTRY (); - /* A NULL GpeBlock means use the FADT-defined GPE block(s) */ + /* A NULL GpeDevice means use the FADT-defined GPE block(s) */ if (!GpeDevice) { diff --git a/sys/contrib/dev/acpica/events/evgpeblk.c b/sys/contrib/dev/acpica/events/evgpeblk.c index 29b0e711e5f5..4c115fbebe51 100644 --- a/sys/contrib/dev/acpica/events/evgpeblk.c +++ b/sys/contrib/dev/acpica/events/evgpeblk.c @@ -123,28 +123,6 @@ /* Local prototypes */ -static ACPI_STATUS -AcpiEvMatchGpeMethod ( - 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 InterruptNumber); - -static ACPI_STATUS -AcpiEvDeleteGpeXrupt ( - ACPI_GPE_XRUPT_INFO *GpeXrupt); - static ACPI_STATUS AcpiEvInstallGpeBlock ( ACPI_GPE_BLOCK_INFO *GpeBlock, @@ -155,581 +133,6 @@ AcpiEvCreateGpeInfoBlocks ( ACPI_GPE_BLOCK_INFO *GpeBlock); -/******************************************************************************* - * - * FUNCTION: AcpiEvValidGpeEvent - * - * PARAMETERS: GpeEventInfo - Info for this GPE - * - * RETURN: TRUE if the GpeEvent is valid - * - * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. - * Should be called only when the GPE lists are semaphore locked - * and not subject to change. - * - ******************************************************************************/ - -BOOLEAN -AcpiEvValidGpeEvent ( - ACPI_GPE_EVENT_INFO *GpeEventInfo) -{ - ACPI_GPE_XRUPT_INFO *GpeXruptBlock; - ACPI_GPE_BLOCK_INFO *GpeBlock; - - - ACPI_FUNCTION_ENTRY (); - - - /* No need for spin lock since we are not changing any list elements */ - - /* Walk the GPE interrupt levels */ - - GpeXruptBlock = AcpiGbl_GpeXruptListHead; - while (GpeXruptBlock) - { - GpeBlock = GpeXruptBlock->GpeBlockListHead; - - /* Walk the GPE blocks on this interrupt level */ - - while (GpeBlock) - { - if ((&GpeBlock->EventInfo[0] <= GpeEventInfo) && - (&GpeBlock->EventInfo[GpeBlock->GpeCount] > GpeEventInfo)) - { - return (TRUE); - } - - GpeBlock = GpeBlock->Next; - } - - GpeXruptBlock = GpeXruptBlock->Next; - } - - return (FALSE); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvWalkGpeList - * - * PARAMETERS: GpeWalkCallback - Routine called for each GPE block - * Context - Value passed to callback - * - * RETURN: Status - * - * DESCRIPTION: Walk the GPE lists. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback, - void *Context) -{ - ACPI_GPE_BLOCK_INFO *GpeBlock; - ACPI_GPE_XRUPT_INFO *GpeXruptInfo; - ACPI_STATUS Status = AE_OK; - ACPI_CPU_FLAGS Flags; - - - ACPI_FUNCTION_TRACE (EvWalkGpeList); - - - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - - /* Walk the interrupt level descriptor list */ - - GpeXruptInfo = AcpiGbl_GpeXruptListHead; - while (GpeXruptInfo) - { - /* Walk all Gpe Blocks attached to this interrupt level */ - - GpeBlock = GpeXruptInfo->GpeBlockListHead; - while (GpeBlock) - { - /* One callback per GPE block */ - - Status = GpeWalkCallback (GpeXruptInfo, GpeBlock, Context); - if (ACPI_FAILURE (Status)) - { - if (Status == AE_CTRL_END) /* Callback abort */ - { - Status = AE_OK; - } - goto UnlockAndExit; - } - - GpeBlock = GpeBlock->Next; - } - - GpeXruptInfo = GpeXruptInfo->Next; - } - -UnlockAndExit: - 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, - void *Context) -{ - ACPI_GPE_EVENT_INFO *GpeEventInfo; - UINT32 i; - UINT32 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[((ACPI_SIZE) i * - ACPI_GPE_REGISTER_WIDTH) + j]; - - if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == - ACPI_GPE_DISPATCH_HANDLER) - { - ACPI_FREE (GpeEventInfo->Dispatch.Handler); - GpeEventInfo->Dispatch.Handler = NULL; - GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; - } - } - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvMatchGpeMethod - * - * PARAMETERS: Callback from WalkNamespace - * - * RETURN: Status - * - * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a - * control method under the _GPE portion of the namespace. - * Extract the name and GPE type from the object, saving this - * information for quick lookup during GPE dispatch - * - * The name of each GPE control method is of the form: - * "_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] - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiEvMatchGpeMethod ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *ObjDesc, - void **ReturnValue) -{ - ACPI_NAMESPACE_NODE *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); - ACPI_GPE_BLOCK_INFO *GpeBlock = (void *) ObjDesc; - ACPI_GPE_EVENT_INFO *GpeEventInfo; - UINT32 GpeNumber; - char Name[ACPI_NAME_SIZE + 1]; - UINT8 Type; - - - ACPI_FUNCTION_TRACE (EvMatchGpeMethod); - - - /* - * Match and decode the _Lxx and _Exx GPE method names - * - * 1) Extract the method name and null terminate it - */ - ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer); - Name[ACPI_NAME_SIZE] = 0; - - /* 2) Name must begin with an underscore */ - - if (Name[0] != '_') - { - return_ACPI_STATUS (AE_OK); /* Ignore this method */ - } - - /* - * 3) Edge/Level determination is based on the 2nd character - * of the method name - * - * NOTE: Default GPE type is RUNTIME only. Later, if a _PRW object is - * found that points to this GPE, the ACPI_GPE_CAN_WAKE flag is set. - */ - switch (Name[1]) - { - case 'L': - Type = ACPI_GPE_LEVEL_TRIGGERED; - break; - - case 'E': - Type = ACPI_GPE_EDGE_TRIGGERED; - break; - - default: - /* Unknown method type, just ignore it */ - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, - "Ignoring unknown GPE method type: %s " - "(name not of form _Lxx or _Exx)", Name)); - return_ACPI_STATUS (AE_OK); - } - - /* 4) The last two characters of the name are the hex GPE Number */ - - GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); - if (GpeNumber == ACPI_UINT32_MAX) - { - /* Conversion failed; invalid method, just ignore it */ - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, - "Could not extract GPE number from name: %s " - "(name is not of form _Lxx or _Exx)", Name)); - return_ACPI_STATUS (AE_OK); - } - - /* Ensure that we have a valid GPE number for this GPE block */ - - GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, GpeBlock); - if (!GpeEventInfo) - { - /* - * This GpeNumber is not valid for this GPE block, just ignore it. - * However, it may be valid for a different GPE block, since GPE0 - * and GPE1 methods both appear under \_GPE. - */ - return_ACPI_STATUS (AE_OK); - } - - /* - * Add the GPE information from above to the GpeEventInfo block for - * use during dispatch of this GPE. - */ - GpeEventInfo->Flags = (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD); - GpeEventInfo->Dispatch.MethodNode = MethodNode; - - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, - "Registered GPE method %s as GPE number 0x%.2X\n", - Name, GpeNumber)); - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * 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 CAN_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 walk */ - - 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 (ObjDesc->Common.Type == 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 (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) - { - /* Package contains a GPE reference and GPE number within a GPE block */ - - if ((ObjDesc->Package.Count < 2) || - ((ObjDesc->Package.Elements[0])->Common.Type != - ACPI_TYPE_LOCAL_REFERENCE) || - ((ObjDesc->Package.Elements[1])->Common.Type != - 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 if and only if 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) - { - goto Cleanup; - } - - GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, GpeBlock); - if (GpeEventInfo) - { - /* This GPE can wake the system */ - - GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE; - } - -Cleanup: - AcpiUtRemoveReference (PkgDesc); - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvGetGpeXruptBlock - * - * PARAMETERS: InterruptNumber - Interrupt for a GPE block - * - * RETURN: A GPE interrupt block - * - * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt - * block per unique interrupt level used for GPEs. Should be - * called only when the GPE lists are semaphore locked and not - * subject to change. - * - ******************************************************************************/ - -static ACPI_GPE_XRUPT_INFO * -AcpiEvGetGpeXruptBlock ( - UINT32 InterruptNumber) -{ - ACPI_GPE_XRUPT_INFO *NextGpeXrupt; - ACPI_GPE_XRUPT_INFO *GpeXrupt; - ACPI_STATUS Status; - ACPI_CPU_FLAGS Flags; - - - ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock); - - - /* No need for lock since we are not changing any list elements here */ - - NextGpeXrupt = AcpiGbl_GpeXruptListHead; - while (NextGpeXrupt) - { - if (NextGpeXrupt->InterruptNumber == InterruptNumber) - { - return_PTR (NextGpeXrupt); - } - - NextGpeXrupt = NextGpeXrupt->Next; - } - - /* Not found, must allocate a new xrupt descriptor */ - - GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO)); - if (!GpeXrupt) - { - return_PTR (NULL); - } - - GpeXrupt->InterruptNumber = InterruptNumber; - - /* Install new interrupt descriptor with spin lock */ - - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - if (AcpiGbl_GpeXruptListHead) - { - NextGpeXrupt = AcpiGbl_GpeXruptListHead; - while (NextGpeXrupt->Next) - { - NextGpeXrupt = NextGpeXrupt->Next; - } - - NextGpeXrupt->Next = GpeXrupt; - GpeXrupt->Previous = NextGpeXrupt; - } - else - { - AcpiGbl_GpeXruptListHead = GpeXrupt; - } - AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); - - /* Install new interrupt handler if not SCI_INT */ - - if (InterruptNumber != AcpiGbl_FADT.SciInterrupt) - { - Status = AcpiOsInstallInterruptHandler (InterruptNumber, - AcpiEvGpeXruptHandler, GpeXrupt); - if (ACPI_FAILURE (Status)) - { - ACPI_ERROR ((AE_INFO, - "Could not install GPE interrupt handler at level 0x%X", - InterruptNumber)); - return_PTR (NULL); - } - } - - return_PTR (GpeXrupt); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvDeleteGpeXrupt - * - * PARAMETERS: GpeXrupt - A GPE interrupt info block - * - * RETURN: Status - * - * DESCRIPTION: Remove and free a GpeXrupt block. Remove an associated - * interrupt handler if not the SCI interrupt. - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiEvDeleteGpeXrupt ( - ACPI_GPE_XRUPT_INFO *GpeXrupt) -{ - ACPI_STATUS Status; - ACPI_CPU_FLAGS Flags; - - - ACPI_FUNCTION_TRACE (EvDeleteGpeXrupt); - - - /* We never want to remove the SCI interrupt handler */ - - if (GpeXrupt->InterruptNumber == AcpiGbl_FADT.SciInterrupt) - { - GpeXrupt->GpeBlockListHead = NULL; - return_ACPI_STATUS (AE_OK); - } - - /* Disable this interrupt */ - - Status = AcpiOsRemoveInterruptHandler ( - GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Unlink the interrupt block with lock */ - - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); - if (GpeXrupt->Previous) - { - GpeXrupt->Previous->Next = GpeXrupt->Next; - } - else - { - /* No previous, update list head */ - - AcpiGbl_GpeXruptListHead = GpeXrupt->Next; - } - - if (GpeXrupt->Next) - { - GpeXrupt->Next->Previous = GpeXrupt->Previous; - } - AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); - - /* Free the block */ - - ACPI_FREE (GpeXrupt); - return_ACPI_STATUS (AE_OK); -} - - /******************************************************************************* * * FUNCTION: AcpiEvInstallGpeBlock @@ -1041,6 +444,7 @@ AcpiEvCreateGpeBlock ( { ACPI_STATUS Status; ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_WALK_INFO WalkInfo; ACPI_FUNCTION_TRACE (EvCreateGpeBlock); @@ -1089,11 +493,16 @@ AcpiEvCreateGpeBlock ( return_ACPI_STATUS (Status); } - /* Find all GPE methods (_Lxx, _Exx) for this block */ + /* Find all GPE methods (_Lxx or_Exx) for this block */ + + WalkInfo.GpeBlock = GpeBlock; + WalkInfo.GpeDevice = GpeDevice; + WalkInfo.EnableThisGpe = FALSE; + WalkInfo.ExecuteByOwnerId = FALSE; Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, - AcpiEvMatchGpeMethod, NULL, GpeBlock, NULL); + AcpiEvMatchGpeMethod, NULL, &WalkInfo, NULL); /* Return the new block */ @@ -1139,7 +548,7 @@ AcpiEvInitializeGpeBlock ( { ACPI_STATUS Status; ACPI_GPE_EVENT_INFO *GpeEventInfo; - ACPI_GPE_WALK_INFO GpeInfo; + ACPI_GPE_WALK_INFO WalkInfo; UINT32 WakeGpeCount; UINT32 GpeEnabledCount; UINT32 GpeIndex; @@ -1170,12 +579,13 @@ AcpiEvInitializeGpeBlock ( * definition a wake GPE and will not be enabled while the machine * is running. */ - GpeInfo.GpeBlock = GpeBlock; - GpeInfo.GpeDevice = GpeDevice; + WalkInfo.GpeBlock = GpeBlock; + WalkInfo.GpeDevice = GpeDevice; + WalkInfo.ExecuteByOwnerId = FALSE; Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, - AcpiEvMatchPrwAndGpe, NULL, &GpeInfo, NULL); + AcpiEvMatchPrwAndGpe, NULL, &WalkInfo, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "While executing _PRW methods")); @@ -1238,165 +648,13 @@ AcpiEvInitializeGpeBlock ( } } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "Found %u Wake, Enabled %u Runtime GPEs in this block\n", - WakeGpeCount, GpeEnabledCount)); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvGpeInitialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize the GPE data structures - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvGpeInitialize ( - void) -{ - UINT32 RegisterCount0 = 0; - UINT32 RegisterCount1 = 0; - UINT32 GpeNumberMax = 0; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (EvGpeInitialize); - - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) + if (GpeEnabledCount || WakeGpeCount) { - return_ACPI_STATUS (Status); - } - - /* - * 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: - * - * "Each register block contains two registers of equal length - * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the - * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN - * The length of the GPE1_STS and GPE1_EN registers is equal to - * half the GPE1_LEN. If a generic register block is not supported - * then its respective block pointer and block length values in the - * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need - * to be the same size." - */ - - /* - * Determine the maximum GPE number for this machine. - * - * Note: both GPE0 and GPE1 are optional, and either can exist without - * the other. - * - * If EITHER the register length OR the block address are zero, then that - * particular block is not supported. - */ - if (AcpiGbl_FADT.Gpe0BlockLength && - AcpiGbl_FADT.XGpe0Block.Address) - { - /* GPE block 0 exists (has both length and address > 0) */ - - RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2); - - GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1; - - /* Install GPE Block 0 */ - - Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0, - AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); - - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not create GPE Block 0")); - } - } - - if (AcpiGbl_FADT.Gpe1BlockLength && - AcpiGbl_FADT.XGpe1Block.Address) - { - /* GPE block 1 exists (has both length and address > 0) */ - - RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2); - - /* Check for GPE0/GPE1 overlap (if both banks exist) */ - - if ((RegisterCount0) && - (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base)) - { - ACPI_ERROR ((AE_INFO, - "GPE0 block (GPE 0 to %u) overlaps the GPE1 block " - "(GPE %u to %u) - Ignoring GPE1", - GpeNumberMax, AcpiGbl_FADT.Gpe1Base, - AcpiGbl_FADT.Gpe1Base + - ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1))); - - /* Ignore GPE1 block by setting the register count to zero */ - - RegisterCount1 = 0; - } - else - { - /* Install GPE Block 1 */ - - Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, - &AcpiGbl_FADT.XGpe1Block, RegisterCount1, - AcpiGbl_FADT.Gpe1Base, - AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); - - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "Could not create GPE Block 1")); - } - - /* - * GPE0 and GPE1 do not have to be contiguous in the GPE number - * space. However, GPE0 always starts at GPE number zero. - */ - GpeNumberMax = AcpiGbl_FADT.Gpe1Base + - ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); - } - } - - /* Exit if there are no GPE registers */ - - if ((RegisterCount0 + RegisterCount1) == 0) - { - /* GPEs are not required by ACPI, this is OK */ - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "There are no GPE blocks defined in the FADT\n")); - Status = AE_OK; - goto Cleanup; + "Enabled %u Runtime GPEs, added %u Wake GPEs in this block\n", + GpeEnabledCount, WakeGpeCount)); } - /* Check for Max GPE number out-of-range */ - - if (GpeNumberMax > ACPI_GPE_MAX) - { - ACPI_ERROR ((AE_INFO, - "Maximum GPE number from FADT is too large: 0x%X", - GpeNumberMax)); - Status = AE_BAD_VALUE; - goto Cleanup; - } - -Cleanup: - (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_OK); } - diff --git a/sys/contrib/dev/acpica/events/evgpeinit.c b/sys/contrib/dev/acpica/events/evgpeinit.c new file mode 100644 index 000000000000..7f41eb7ecc72 --- /dev/null +++ b/sys/contrib/dev/acpica/events/evgpeinit.c @@ -0,0 +1,763 @@ +/****************************************************************************** + * + * Module Name: evgpeinit - System GPE initialization and update + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include +#include +#include +#include +#include + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpeinit") + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize the GPE data structures and the FADT GPE 0/1 blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvGpeInitialize ( + void) +{ + UINT32 RegisterCount0 = 0; + UINT32 RegisterCount1 = 0; + UINT32 GpeNumberMax = 0; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvGpeInitialize); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * 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: + * + * "Each register block contains two registers of equal length + * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the + * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN + * The length of the GPE1_STS and GPE1_EN registers is equal to + * half the GPE1_LEN. If a generic register block is not supported + * then its respective block pointer and block length values in the + * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need + * to be the same size." + */ + + /* + * Determine the maximum GPE number for this machine. + * + * Note: both GPE0 and GPE1 are optional, and either can exist without + * the other. + * + * If EITHER the register length OR the block address are zero, then that + * particular block is not supported. + */ + if (AcpiGbl_FADT.Gpe0BlockLength && + AcpiGbl_FADT.XGpe0Block.Address) + { + /* GPE block 0 exists (has both length and address > 0) */ + + RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2); + + GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1; + + /* Install GPE Block 0 */ + + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create GPE Block 0")); + } + } + + if (AcpiGbl_FADT.Gpe1BlockLength && + AcpiGbl_FADT.XGpe1Block.Address) + { + /* GPE block 1 exists (has both length and address > 0) */ + + RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2); + + /* Check for GPE0/GPE1 overlap (if both banks exist) */ + + if ((RegisterCount0) && + (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base)) + { + ACPI_ERROR ((AE_INFO, + "GPE0 block (GPE 0 to %u) overlaps the GPE1 block " + "(GPE %u to %u) - Ignoring GPE1", + GpeNumberMax, AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.Gpe1Base + + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1))); + + /* Ignore GPE1 block by setting the register count to zero */ + + RegisterCount1 = 0; + } + else + { + /* Install GPE Block 1 */ + + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT.XGpe1Block, RegisterCount1, + AcpiGbl_FADT.Gpe1Base, + AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create GPE Block 1")); + } + + /* + * GPE0 and GPE1 do not have to be contiguous in the GPE number + * space. However, GPE0 always starts at GPE number zero. + */ + GpeNumberMax = AcpiGbl_FADT.Gpe1Base + + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); + } + } + + /* Exit if there are no GPE registers */ + + if ((RegisterCount0 + RegisterCount1) == 0) + { + /* GPEs are not required by ACPI, this is 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 */ + + if (GpeNumberMax > ACPI_GPE_MAX) + { + ACPI_ERROR ((AE_INFO, + "Maximum GPE number from FADT is too large: 0x%X", + GpeNumberMax)); + Status = AE_BAD_VALUE; + goto Cleanup; + } + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvUpdateGpes + * + * PARAMETERS: TableOwnerId - ID of the newly-loaded ACPI table + * + * RETURN: None + * + * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a + * result of a Load() or LoadTable() operation. If new GPE + * methods have been installed, register the new methods and + * enable and runtime GPEs that are associated with them. Also, + * run any newly loaded _PRW methods in order to discover any + * new CAN_WAKE GPEs. + * + ******************************************************************************/ + +void +AcpiEvUpdateGpes ( + ACPI_OWNER_ID TableOwnerId) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptInfo; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_WALK_INFO WalkInfo; + ACPI_STATUS Status = AE_OK; + UINT32 NewWakeGpeCount = 0; + + + /* We will examine only _PRW/_Lxx/_Exx methods owned by this table */ + + WalkInfo.OwnerId = TableOwnerId; + WalkInfo.ExecuteByOwnerId = TRUE; + WalkInfo.Count = 0; + + if (AcpiGbl_LeaveWakeGpesDisabled) + { + /* + * 1) Run any newly-loaded _PRW methods to find any GPEs that + * can now be marked as CAN_WAKE GPEs. Note: We must run the + * _PRW methods before we process the _Lxx/_Exx methods because + * we will enable all runtime GPEs associated with the new + * _Lxx/_Exx methods at the time we process those methods. + * + * Unlock interpreter so that we can run the _PRW methods. + */ + WalkInfo.GpeBlock = NULL; + WalkInfo.GpeDevice = NULL; + + AcpiExExitInterpreter (); + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiEvMatchPrwAndGpe, NULL, &WalkInfo, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While executing _PRW methods")); + } + + AcpiExEnterInterpreter (); + NewWakeGpeCount = WalkInfo.Count; + } + + /* + * 2) Find any _Lxx/_Exx GPE methods that have just been loaded. + * + * Any GPEs that correspond to new _Lxx/_Exx methods and are not + * marked as CAN_WAKE are immediately enabled. + * + * Examine the namespace underneath each GpeDevice within the + * GpeBlock lists. + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return; + } + + WalkInfo.Count = 0; + WalkInfo.EnableThisGpe = TRUE; + + /* Walk the interrupt level descriptor list */ + + GpeXruptInfo = AcpiGbl_GpeXruptListHead; + while (GpeXruptInfo) + { + /* Walk all Gpe Blocks attached to this interrupt level */ + + GpeBlock = GpeXruptInfo->GpeBlockListHead; + while (GpeBlock) + { + WalkInfo.GpeBlock = GpeBlock; + WalkInfo.GpeDevice = GpeBlock->Node; + + Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, + WalkInfo.GpeDevice, ACPI_UINT32_MAX, + ACPI_NS_WALK_NO_UNLOCK, AcpiEvMatchGpeMethod, + NULL, &WalkInfo, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While decoding _Lxx/_Exx methods")); + } + + GpeBlock = GpeBlock->Next; + } + + GpeXruptInfo = GpeXruptInfo->Next; + } + + if (WalkInfo.Count || NewWakeGpeCount) + { + ACPI_INFO ((AE_INFO, + "Enabled %u new runtime GPEs, added %u new wakeup GPEs", + WalkInfo.Count, NewWakeGpeCount)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvMatchGpeMethod + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a + * control method under the _GPE portion of the namespace. + * Extract the name and GPE type from the object, saving this + * information for quick lookup during GPE dispatch. Allows a + * per-OwnerId evaluation if ExecuteByOwnerId is TRUE in the + * WalkInfo parameter block. + * + * The name of each GPE control method is of the form: + * "_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] + * + * If WalkInfo->ExecuteByOwnerId is TRUE, we only execute examine GPE methods + * with that owner. + * If WalkInfo->EnableThisGpe is TRUE, the GPE that is referred to by a GPE + * method is immediately enabled (Used for Load/LoadTable operators) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvMatchGpeMethod ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context); + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_NAMESPACE_NODE *GpeDevice; + ACPI_STATUS Status; + UINT32 GpeNumber; + char Name[ACPI_NAME_SIZE + 1]; + UINT8 Type; + + + ACPI_FUNCTION_TRACE (EvMatchGpeMethod); + + + /* Check if requested OwnerId matches this OwnerId */ + + if ((WalkInfo->ExecuteByOwnerId) && + (MethodNode->OwnerId != WalkInfo->OwnerId)) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Match and decode the _Lxx and _Exx GPE method names + * + * 1) Extract the method name and null terminate it + */ + ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer); + Name[ACPI_NAME_SIZE] = 0; + + /* 2) Name must begin with an underscore */ + + if (Name[0] != '_') + { + return_ACPI_STATUS (AE_OK); /* Ignore this method */ + } + + /* + * 3) Edge/Level determination is based on the 2nd character + * of the method name + * + * NOTE: Default GPE type is RUNTIME only. Later, if a _PRW object is + * found that points to this GPE, the ACPI_GPE_CAN_WAKE flag is set. + */ + switch (Name[1]) + { + case 'L': + Type = ACPI_GPE_LEVEL_TRIGGERED; + break; + + case 'E': + Type = ACPI_GPE_EDGE_TRIGGERED; + break; + + default: + /* Unknown method type, just ignore it */ + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Ignoring unknown GPE method type: %s " + "(name not of form _Lxx or _Exx)", Name)); + return_ACPI_STATUS (AE_OK); + } + + /* 4) The last two characters of the name are the hex GPE Number */ + + GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); + if (GpeNumber == ACPI_UINT32_MAX) + { + /* Conversion failed; invalid method, just ignore it */ + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Could not extract GPE number from name: %s " + "(name is not of form _Lxx or _Exx)", Name)); + return_ACPI_STATUS (AE_OK); + } + + /* Ensure that we have a valid GPE number for this GPE block */ + + GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, WalkInfo->GpeBlock); + if (!GpeEventInfo) + { + /* + * This GpeNumber is not valid for this GPE block, just ignore it. + * However, it may be valid for a different GPE block, since GPE0 + * and GPE1 methods both appear under \_GPE. + */ + return_ACPI_STATUS (AE_OK); + } + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + /* If there is already a handler, ignore this GPE method */ + + return_ACPI_STATUS (AE_OK); + } + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) + { + /* + * If there is already a method, ignore this method. But check + * for a type mismatch (if both the _Lxx AND _Exx exist) + */ + if (Type != (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK)) + { + ACPI_ERROR ((AE_INFO, + "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods", + GpeNumber, GpeNumber, GpeNumber)); + } + return_ACPI_STATUS (AE_OK); + } + + /* + * Add the GPE information from above to the GpeEventInfo block for + * use during dispatch of this GPE. + */ + GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD); + GpeEventInfo->Dispatch.MethodNode = MethodNode; + + /* + * Enable this GPE if requested. This only happens when during the + * execution of a Load or LoadTable operator. We have found a new + * GPE method and want to immediately enable the GPE if it is a + * runtime GPE. + */ + if (WalkInfo->EnableThisGpe) + { + /* Ignore GPEs that can wake the system */ + + if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE) || + !AcpiGbl_LeaveWakeGpesDisabled) + { + WalkInfo->Count++; + GpeDevice = WalkInfo->GpeDevice; + + if (GpeDevice == AcpiGbl_FadtGpeDevice) + { + GpeDevice = NULL; + } + + Status = AcpiEnableGpe (GpeDevice, GpeNumber, + ACPI_GPE_TYPE_RUNTIME); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not enable GPE 0x%02X", GpeNumber)); + } + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, + "Registered GPE method %s as GPE number 0x%.2X\n", + Name, GpeNumber)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * 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 CAN_WAKE GPE. Allows a + * per-OwnerId execution if ExecuteByOwnerId is TRUE in the + * WalkInfo parameter block. + * + * If WalkInfo->ExecuteByOwnerId is TRUE, we only execute _PRWs with that + * owner. + * If WalkInfo->GpeDevice is NULL, we execute every _PRW found. Otherwise, + * we only execute _PRWs that refer to the input GpeDevice. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvMatchPrwAndGpe ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context); + ACPI_NAMESPACE_NODE *GpeDevice; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_NAMESPACE_NODE *TargetGpeDevice; + ACPI_NAMESPACE_NODE *PrwNode; + 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 = AcpiNsGetNode (ObjHandle, METHOD_NAME__PRW, + ACPI_NS_NO_UPSEARCH, &PrwNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (AE_OK); + } + + /* Check if requested OwnerId matches this OwnerId */ + + if ((WalkInfo->ExecuteByOwnerId) && + (PrwNode->OwnerId != WalkInfo->OwnerId)) + { + return_ACPI_STATUS (AE_OK); + } + + /* Execute the _PRW */ + + Status = AcpiUtEvaluateObject (PrwNode, NULL, + ACPI_BTYPE_PACKAGE, &PkgDesc); + if (ACPI_FAILURE (Status)) + { + 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 = WalkInfo->GpeDevice; + GpeBlock = WalkInfo->GpeBlock; + + /* + * The _PRW object must return a package, we are only interested + * in the first element + */ + ObjDesc = PkgDesc->Package.Elements[0]; + + if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) + { + /* Use FADT-defined GPE device (from definition of _PRW) */ + + TargetGpeDevice = NULL; + if (GpeDevice) + { + TargetGpeDevice = AcpiGbl_FadtGpeDevice; + } + + /* Integer is the GPE number in the FADT described GPE blocks */ + + GpeNumber = (UINT32) ObjDesc->Integer.Value; + } + else if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + /* Package contains a GPE reference and GPE number within a GPE block */ + + if ((ObjDesc->Package.Count < 2) || + ((ObjDesc->Package.Elements[0])->Common.Type != + ACPI_TYPE_LOCAL_REFERENCE) || + ((ObjDesc->Package.Elements[1])->Common.Type != + 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; + } + + /* Get the GpeEventInfo for this GPE */ + + if (GpeDevice) + { + /* + * Is this GPE within this block? + * + * TRUE if and only if 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) + { + goto Cleanup; + } + + GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, GpeBlock); + } + else + { + /* GpeDevice is NULL, just match the TargetDevice and GpeNumber */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (TargetGpeDevice, GpeNumber); + } + + if (GpeEventInfo) + { + if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)) + { + /* This GPE can wake the system */ + + GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE; + WalkInfo->Count++; + } + } + +Cleanup: + AcpiUtRemoveReference (PkgDesc); + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/events/evgpeutil.c b/sys/contrib/dev/acpica/events/evgpeutil.c new file mode 100644 index 000000000000..d67f77e7778d --- /dev/null +++ b/sys/contrib/dev/acpica/events/evgpeutil.c @@ -0,0 +1,452 @@ +/****************************************************************************** + * + * Module Name: evgpeutil - GPE utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + + +#include +#include +#include + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpeutil") + + +/******************************************************************************* + * + * FUNCTION: AcpiEvWalkGpeList + * + * PARAMETERS: GpeWalkCallback - Routine called for each GPE block + * Context - Value passed to callback + * + * RETURN: Status + * + * DESCRIPTION: Walk the GPE lists. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context) +{ + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptInfo; + ACPI_STATUS Status = AE_OK; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvWalkGpeList); + + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Walk the interrupt level descriptor list */ + + GpeXruptInfo = AcpiGbl_GpeXruptListHead; + while (GpeXruptInfo) + { + /* Walk all Gpe Blocks attached to this interrupt level */ + + GpeBlock = GpeXruptInfo->GpeBlockListHead; + while (GpeBlock) + { + /* One callback per GPE block */ + + Status = GpeWalkCallback (GpeXruptInfo, GpeBlock, Context); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_END) /* Callback abort */ + { + Status = AE_OK; + } + goto UnlockAndExit; + } + + GpeBlock = GpeBlock->Next; + } + + GpeXruptInfo = GpeXruptInfo->Next; + } + +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvValidGpeEvent + * + * PARAMETERS: GpeEventInfo - Info for this GPE + * + * RETURN: TRUE if the GpeEvent is valid + * + * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. + * Should be called only when the GPE lists are semaphore locked + * and not subject to change. + * + ******************************************************************************/ + +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptBlock; + ACPI_GPE_BLOCK_INFO *GpeBlock; + + + ACPI_FUNCTION_ENTRY (); + + + /* No need for spin lock since we are not changing any list elements */ + + /* Walk the GPE interrupt levels */ + + GpeXruptBlock = AcpiGbl_GpeXruptListHead; + while (GpeXruptBlock) + { + GpeBlock = GpeXruptBlock->GpeBlockListHead; + + /* Walk the GPE blocks on this interrupt level */ + + while (GpeBlock) + { + if ((&GpeBlock->EventInfo[0] <= GpeEventInfo) && + (&GpeBlock->EventInfo[GpeBlock->GpeCount] > GpeEventInfo)) + { + return (TRUE); + } + + GpeBlock = GpeBlock->Next; + } + + GpeXruptBlock = GpeXruptBlock->Next; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeXruptBlock + * + * PARAMETERS: InterruptNumber - Interrupt for a GPE block + * + * RETURN: A GPE interrupt block + * + * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt + * block per unique interrupt level used for GPEs. Should be + * called only when the GPE lists are semaphore locked and not + * subject to change. + * + ******************************************************************************/ + +ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptNumber) +{ + ACPI_GPE_XRUPT_INFO *NextGpeXrupt; + ACPI_GPE_XRUPT_INFO *GpeXrupt; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock); + + + /* No need for lock since we are not changing any list elements here */ + + NextGpeXrupt = AcpiGbl_GpeXruptListHead; + while (NextGpeXrupt) + { + if (NextGpeXrupt->InterruptNumber == InterruptNumber) + { + return_PTR (NextGpeXrupt); + } + + NextGpeXrupt = NextGpeXrupt->Next; + } + + /* Not found, must allocate a new xrupt descriptor */ + + GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO)); + if (!GpeXrupt) + { + return_PTR (NULL); + } + + GpeXrupt->InterruptNumber = InterruptNumber; + + /* Install new interrupt descriptor with spin lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (AcpiGbl_GpeXruptListHead) + { + NextGpeXrupt = AcpiGbl_GpeXruptListHead; + while (NextGpeXrupt->Next) + { + NextGpeXrupt = NextGpeXrupt->Next; + } + + NextGpeXrupt->Next = GpeXrupt; + GpeXrupt->Previous = NextGpeXrupt; + } + else + { + AcpiGbl_GpeXruptListHead = GpeXrupt; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Install new interrupt handler if not SCI_INT */ + + if (InterruptNumber != AcpiGbl_FADT.SciInterrupt) + { + Status = AcpiOsInstallInterruptHandler (InterruptNumber, + AcpiEvGpeXruptHandler, GpeXrupt); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not install GPE interrupt handler at level 0x%X", + InterruptNumber)); + return_PTR (NULL); + } + } + + return_PTR (GpeXrupt); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDeleteGpeXrupt + * + * PARAMETERS: GpeXrupt - A GPE interrupt info block + * + * RETURN: Status + * + * DESCRIPTION: Remove and free a GpeXrupt block. Remove an associated + * interrupt handler if not the SCI interrupt. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt) +{ + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvDeleteGpeXrupt); + + + /* We never want to remove the SCI interrupt handler */ + + if (GpeXrupt->InterruptNumber == AcpiGbl_FADT.SciInterrupt) + { + GpeXrupt->GpeBlockListHead = NULL; + return_ACPI_STATUS (AE_OK); + } + + /* Disable this interrupt */ + + Status = AcpiOsRemoveInterruptHandler ( + GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Unlink the interrupt block with lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeXrupt->Previous) + { + GpeXrupt->Previous->Next = GpeXrupt->Next; + } + else + { + /* No previous, update list head */ + + AcpiGbl_GpeXruptListHead = GpeXrupt->Next; + } + + if (GpeXrupt->Next) + { + GpeXrupt->Next->Previous = GpeXrupt->Previous; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Free the block */ + + ACPI_FREE (GpeXrupt); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * 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, + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + UINT32 i; + UINT32 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[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j]; + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + ACPI_FREE (GpeEventInfo->Dispatch.Handler); + GpeEventInfo->Dispatch.Handler = NULL; + GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK; + } + } + } + + return_ACPI_STATUS (AE_OK); +} + diff --git a/sys/contrib/dev/acpica/executer/exconfig.c b/sys/contrib/dev/acpica/executer/exconfig.c index 95b78eda3b84..918fc1cf9969 100644 --- a/sys/contrib/dev/acpica/executer/exconfig.c +++ b/sys/contrib/dev/acpica/executer/exconfig.c @@ -164,8 +164,9 @@ AcpiExAddTable ( ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle) { - ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_OWNER_ID OwnerId; ACPI_FUNCTION_TRACE (ExAddTable); @@ -205,7 +206,15 @@ AcpiExAddTable ( AcpiNsExecModuleCodeList (); AcpiExEnterInterpreter (); - return_ACPI_STATUS (Status); + /* Update GPEs for any new _PRW or _Lxx/_Exx methods. Ignore errors */ + + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_SUCCESS (Status)) + { + AcpiEvUpdateGpes (OwnerId); + } + + return_ACPI_STATUS (AE_OK); } @@ -347,9 +356,8 @@ AcpiExLoadTableOp ( Status = AcpiGetTableByIndex (TableIndex, &Table); if (ACPI_SUCCESS (Status)) { - ACPI_INFO ((AE_INFO, - "Dynamic OEM Table Load - [%.4s] OemId [%.6s] OemTableId [%.8s]", - Table->Signature, Table->OemId, Table->OemTableId)); + ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + AcpiTbPrintTableHeader (0, Table); } /* Invoke table handler if present */ @@ -644,6 +652,9 @@ AcpiExLoadOp ( return_ACPI_STATUS (Status); } + ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + AcpiTbPrintTableHeader (0, TableDesc.Pointer); + /* Remove the reference by added by AcpiExStore above */ AcpiUtRemoveReference (DdbHandle); diff --git a/sys/contrib/dev/acpica/executer/exoparg1.c b/sys/contrib/dev/acpica/executer/exoparg1.c index 550980f9f3b4..f12b14f97b75 100644 --- a/sys/contrib/dev/acpica/executer/exoparg1.c +++ b/sys/contrib/dev/acpica/executer/exoparg1.c @@ -268,7 +268,7 @@ AcpiExOpcode_1A_0T_0R ( case AML_SLEEP_OP: /* Sleep (MsecTime) */ - Status = AcpiExSystemDoSuspend (Operand[0]->Integer.Value); + Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value); break; diff --git a/sys/contrib/dev/acpica/executer/exsystem.c b/sys/contrib/dev/acpica/executer/exsystem.c index 96e3063903ef..2bc96fcc7bb0 100644 --- a/sys/contrib/dev/acpica/executer/exsystem.c +++ b/sys/contrib/dev/acpica/executer/exsystem.c @@ -280,19 +280,19 @@ AcpiExSystemDoStall ( /******************************************************************************* * - * FUNCTION: AcpiExSystemDoSuspend + * FUNCTION: AcpiExSystemDoSleep * - * PARAMETERS: HowLong - The amount of time to suspend, + * PARAMETERS: HowLong - The amount of time to sleep, * in milliseconds * * RETURN: None * - * DESCRIPTION: Suspend running thread for specified amount of time. + * DESCRIPTION: Sleep the running thread for specified amount of time. * ******************************************************************************/ ACPI_STATUS -AcpiExSystemDoSuspend ( +AcpiExSystemDoSleep ( UINT64 HowLong) { ACPI_FUNCTION_ENTRY (); diff --git a/sys/contrib/dev/acpica/include/acevents.h b/sys/contrib/dev/acpica/include/acevents.h index 4d945eff8aad..40515579e5e0 100644 --- a/sys/contrib/dev/acpica/include/acevents.h +++ b/sys/contrib/dev/acpica/include/acevents.h @@ -167,8 +167,12 @@ AcpiEvQueueNotifyRequest ( /* - * evgpe - GPE handling and dispatch + * evgpe - Low-level GPE support */ +UINT32 +AcpiEvGpeDetect ( + ACPI_GPE_XRUPT_INFO *GpeXruptList); + ACPI_STATUS AcpiEvUpdateGpeEnableMasks ( ACPI_GPE_EVENT_INFO *GpeEventInfo); @@ -193,23 +197,8 @@ AcpiEvLowGetGpeInfo ( /* - * evgpeblk + * evgpeblk - Upper-level GPE block support */ -BOOLEAN -AcpiEvValidGpeEvent ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); - -ACPI_STATUS -AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback, - void *Context); - -ACPI_STATUS -AcpiEvDeleteGpeHandlers ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock, - void *Context); - ACPI_STATUS AcpiEvCreateGpeBlock ( ACPI_NAMESPACE_NODE *GpeDevice, @@ -233,14 +222,57 @@ AcpiEvGpeDispatch ( ACPI_GPE_EVENT_INFO *GpeEventInfo, UINT32 GpeNumber); -UINT32 -AcpiEvGpeDetect ( - ACPI_GPE_XRUPT_INFO *GpeXruptList); - +/* + * evgpeinit - GPE initialization and update + */ ACPI_STATUS AcpiEvGpeInitialize ( void); +void +AcpiEvUpdateGpes ( + ACPI_OWNER_ID TableOwnerId); + +ACPI_STATUS +AcpiEvMatchGpeMethod ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiEvMatchPrwAndGpe ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +/* + * evgpeutil - GPE utilities + */ +ACPI_STATUS +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context); + +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptNumber); + +ACPI_STATUS +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt); + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + /* * evregion - Address Space handling diff --git a/sys/contrib/dev/acpica/include/acglobal.h b/sys/contrib/dev/acpica/include/acglobal.h index 4f0769e6f676..e0f8871fcd09 100644 --- a/sys/contrib/dev/acpica/include/acglobal.h +++ b/sys/contrib/dev/acpica/include/acglobal.h @@ -216,11 +216,10 @@ ACPI_NAME AcpiGbl_TraceMethodName; ****************************************************************************/ /* - * AcpiGbl_RootTableList is the master list of ACPI tables found in the - * RSDT/XSDT. - * + * AcpiGbl_RootTableList is the master list of ACPI tables that were + * found in the RSDT/XSDT. */ -ACPI_EXTERN ACPI_INTERNAL_RSDT AcpiGbl_RootTableList; +ACPI_EXTERN ACPI_TABLE_LIST AcpiGbl_RootTableList; ACPI_EXTERN ACPI_TABLE_FACS *AcpiGbl_FACS; /* These addresses are calculated from the FADT Event Block addresses */ diff --git a/sys/contrib/dev/acpica/include/acinterp.h b/sys/contrib/dev/acpica/include/acinterp.h index 67142c8911b5..e3fa940a1023 100644 --- a/sys/contrib/dev/acpica/include/acinterp.h +++ b/sys/contrib/dev/acpica/include/acinterp.h @@ -434,7 +434,7 @@ AcpiExSystemDoNotifyOp ( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS -AcpiExSystemDoSuspend( +AcpiExSystemDoSleep( UINT64 Time); ACPI_STATUS diff --git a/sys/contrib/dev/acpica/include/aclocal.h b/sys/contrib/dev/acpica/include/aclocal.h index 8818a6ea9b53..1deced01136b 100644 --- a/sys/contrib/dev/acpica/include/aclocal.h +++ b/sys/contrib/dev/acpica/include/aclocal.h @@ -307,16 +307,16 @@ typedef struct acpi_namespace_node #define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */ -/* One internal RSDT for table management */ +/* Internal ACPI table management - master table list */ -typedef struct acpi_internal_rsdt +typedef struct acpi_table_list { - ACPI_TABLE_DESC *Tables; - UINT32 Count; - UINT32 Size; + ACPI_TABLE_DESC *Tables; /* Table descriptor array */ + UINT32 CurrentTableCount; /* Tables currently in the array */ + UINT32 MaxTableCount; /* Max tables array will hold */ UINT8 Flags; -} ACPI_INTERNAL_RSDT; +} ACPI_TABLE_LIST; /* Flags for above */ @@ -612,6 +612,10 @@ typedef struct acpi_gpe_walk_info { ACPI_NAMESPACE_NODE *GpeDevice; ACPI_GPE_BLOCK_INFO *GpeBlock; + UINT16 Count; + ACPI_OWNER_ID OwnerId; + BOOLEAN EnableThisGpe; + BOOLEAN ExecuteByOwnerId; } ACPI_GPE_WALK_INFO; diff --git a/sys/contrib/dev/acpica/include/acpiosxf.h b/sys/contrib/dev/acpica/include/acpiosxf.h index 13570b4f1737..9924d4d786cb 100644 --- a/sys/contrib/dev/acpica/include/acpiosxf.h +++ b/sys/contrib/dev/acpica/include/acpiosxf.h @@ -410,8 +410,8 @@ AcpiOsWritePciConfiguration ( */ void AcpiOsDerivePciId( - ACPI_HANDLE Rhandle, - ACPI_HANDLE Chandle, + ACPI_HANDLE Device, + ACPI_HANDLE Region, ACPI_PCI_ID **PciId); diff --git a/sys/contrib/dev/acpica/include/acpixf.h b/sys/contrib/dev/acpica/include/acpixf.h index 5562fa0215d5..48d824f11925 100644 --- a/sys/contrib/dev/acpica/include/acpixf.h +++ b/sys/contrib/dev/acpica/include/acpixf.h @@ -120,7 +120,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20100331 +#define ACPI_CA_VERSION 0x20100428 #include #include @@ -283,7 +283,7 @@ AcpiGetDevices ( ACPI_STATUS AcpiGetName ( - ACPI_HANDLE Handle, + ACPI_HANDLE Object, UINT32 NameType, ACPI_BUFFER *RetPathPtr); @@ -295,18 +295,18 @@ AcpiGetHandle ( ACPI_STATUS AcpiAttachData ( - ACPI_HANDLE ObjHandle, + ACPI_HANDLE Object, ACPI_OBJECT_HANDLER Handler, void *Data); ACPI_STATUS AcpiDetachData ( - ACPI_HANDLE ObjHandle, + ACPI_HANDLE Object, ACPI_OBJECT_HANDLER Handler); ACPI_STATUS AcpiGetData ( - ACPI_HANDLE ObjHandle, + ACPI_HANDLE Object, ACPI_OBJECT_HANDLER Handler, void **Data); @@ -338,7 +338,7 @@ AcpiEvaluateObjectTyped ( ACPI_STATUS AcpiGetObjectInfo ( - ACPI_HANDLE Handle, + ACPI_HANDLE Object, ACPI_DEVICE_INFO **ReturnBuffer); ACPI_STATUS @@ -527,36 +527,36 @@ ACPI_STATUS (*ACPI_WALK_RESOURCE_CALLBACK) ( ACPI_STATUS AcpiGetVendorResource ( - ACPI_HANDLE DeviceHandle, + ACPI_HANDLE Device, char *Name, ACPI_VENDOR_UUID *Uuid, ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiGetCurrentResources( - ACPI_HANDLE DeviceHandle, +AcpiGetCurrentResources ( + ACPI_HANDLE Device, ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiGetPossibleResources( - ACPI_HANDLE DeviceHandle, +AcpiGetPossibleResources ( + ACPI_HANDLE Device, ACPI_BUFFER *RetBuffer); ACPI_STATUS AcpiWalkResources ( - ACPI_HANDLE DeviceHandle, + ACPI_HANDLE Device, char *Name, ACPI_WALK_RESOURCE_CALLBACK UserFunction, void *Context); ACPI_STATUS AcpiSetCurrentResources ( - ACPI_HANDLE DeviceHandle, + ACPI_HANDLE Device, ACPI_BUFFER *InBuffer); ACPI_STATUS -AcpiGetIrqRoutingTable ( - ACPI_HANDLE BusDeviceHandle, +AcpiGetIrqRoutingTable ( + ACPI_HANDLE Device, ACPI_BUFFER *RetBuffer); ACPI_STATUS diff --git a/sys/contrib/dev/acpica/include/actypes.h b/sys/contrib/dev/acpica/include/actypes.h index 3c0626ab1e35..601e87e908d9 100644 --- a/sys/contrib/dev/acpica/include/actypes.h +++ b/sys/contrib/dev/acpica/include/actypes.h @@ -1099,7 +1099,7 @@ ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) ( typedef ACPI_STATUS (*ACPI_WALK_CALLBACK) ( - ACPI_HANDLE ObjHandle, + ACPI_HANDLE Object, UINT32 NestingLevel, void *Context, void **ReturnValue); diff --git a/sys/contrib/dev/acpica/include/amlresrc.h b/sys/contrib/dev/acpica/include/amlresrc.h index 9084e44540aa..4cd2617e22b2 100644 --- a/sys/contrib/dev/acpica/include/amlresrc.h +++ b/sys/contrib/dev/acpica/include/amlresrc.h @@ -300,6 +300,12 @@ typedef struct aml_resource_large_header } AML_RESOURCE_LARGE_HEADER; +/* General Flags for address space resource descriptors */ + +#define ACPI_RESOURCE_FLAG_DEC 2 +#define ACPI_RESOURCE_FLAG_MIF 4 +#define ACPI_RESOURCE_FLAG_MAF 8 + typedef struct aml_resource_memory24 { AML_RESOURCE_LARGE_HEADER_COMMON diff --git a/sys/contrib/dev/acpica/osunixxf.c b/sys/contrib/dev/acpica/osunixxf.c index a0e38e46c0ae..456fd19e78a9 100644 --- a/sys/contrib/dev/acpica/osunixxf.c +++ b/sys/contrib/dev/acpica/osunixxf.c @@ -986,8 +986,8 @@ AcpiOsWritePciConfiguration ( /* TEMPORARY STUB FUNCTION */ void AcpiOsDerivePciId( - ACPI_HANDLE rhandle, - ACPI_HANDLE chandle, + ACPI_HANDLE Device, + ACPI_HANDLE Region, ACPI_PCI_ID **PciId) { diff --git a/sys/contrib/dev/acpica/tables/tbfind.c b/sys/contrib/dev/acpica/tables/tbfind.c index d6cee630e13e..f9b28bafa048 100644 --- a/sys/contrib/dev/acpica/tables/tbfind.c +++ b/sys/contrib/dev/acpica/tables/tbfind.c @@ -164,7 +164,7 @@ AcpiTbFindTable ( /* Search for the table */ - for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature), Header.Signature, ACPI_NAME_SIZE)) diff --git a/sys/contrib/dev/acpica/tables/tbinstal.c b/sys/contrib/dev/acpica/tables/tbinstal.c index be5561249e91..d573eb98a3e2 100644 --- a/sys/contrib/dev/acpica/tables/tbinstal.c +++ b/sys/contrib/dev/acpica/tables/tbinstal.c @@ -227,7 +227,7 @@ AcpiTbAddTable ( /* Check if table is already registered */ - for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { if (!AcpiGbl_RootTableList.Tables[i].Pointer) { @@ -370,7 +370,7 @@ AcpiTbResizeRootTableList ( /* Increase the Table Array size */ Tables = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) AcpiGbl_RootTableList.Size + + ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) * sizeof (ACPI_TABLE_DESC)); if (!Tables) @@ -384,7 +384,7 @@ AcpiTbResizeRootTableList ( if (AcpiGbl_RootTableList.Tables) { ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, - (ACPI_SIZE) AcpiGbl_RootTableList.Size * sizeof (ACPI_TABLE_DESC)); + (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC)); if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) { @@ -393,7 +393,7 @@ AcpiTbResizeRootTableList ( } AcpiGbl_RootTableList.Tables = Tables; - AcpiGbl_RootTableList.Size += ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT; AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED; return_ACPI_STATUS (AE_OK); @@ -423,12 +423,14 @@ AcpiTbStoreTable ( UINT8 Flags, UINT32 *TableIndex) { - ACPI_STATUS Status = AE_OK; + ACPI_STATUS Status; + ACPI_TABLE_DESC *NewTable; /* Ensure that there is room for the table in the Root Table List */ - if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + if (AcpiGbl_RootTableList.CurrentTableCount >= + AcpiGbl_RootTableList.MaxTableCount) { Status = AcpiTbResizeRootTableList(); if (ACPI_FAILURE (Status)) @@ -437,21 +439,21 @@ AcpiTbStoreTable ( } } + NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount]; + /* Initialize added table */ - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = Address; - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Pointer = Table; - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Length = Length; - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].OwnerId = 0; - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Flags = Flags; + NewTable->Address = Address; + NewTable->Pointer = Table; + NewTable->Length = Length; + NewTable->OwnerId = 0; + NewTable->Flags = Flags; - ACPI_MOVE_32_TO_32 ( - &(AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Signature), - Table->Signature); + ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature); - *TableIndex = AcpiGbl_RootTableList.Count; - AcpiGbl_RootTableList.Count++; - return (Status); + *TableIndex = AcpiGbl_RootTableList.CurrentTableCount; + AcpiGbl_RootTableList.CurrentTableCount++; + return (AE_OK); } @@ -523,7 +525,7 @@ AcpiTbTerminate ( /* Delete the individual tables */ - for (i = 0; i < AcpiGbl_RootTableList.Count; i++) + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); } @@ -539,7 +541,7 @@ AcpiTbTerminate ( AcpiGbl_RootTableList.Tables = NULL; AcpiGbl_RootTableList.Flags = 0; - AcpiGbl_RootTableList.Count = 0; + AcpiGbl_RootTableList.CurrentTableCount = 0; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); @@ -575,7 +577,7 @@ AcpiTbDeleteNamespaceByOwner ( return_ACPI_STATUS (Status); } - if (TableIndex >= AcpiGbl_RootTableList.Count) + if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) { /* The table index does not exist */ @@ -634,7 +636,7 @@ AcpiTbAllocateOwnerId ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { Status = AcpiUtAllocateOwnerId (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); @@ -668,7 +670,7 @@ AcpiTbReleaseOwnerId ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { AcpiUtReleaseOwnerId ( &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); @@ -705,7 +707,7 @@ AcpiTbGetOwnerId ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; Status = AE_OK; @@ -734,7 +736,7 @@ AcpiTbIsTableLoaded ( (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { IsLoaded = (BOOLEAN) (AcpiGbl_RootTableList.Tables[TableIndex].Flags & @@ -766,7 +768,7 @@ AcpiTbSetTableLoadedFlag ( { (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.Count) + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) { if (IsLoaded) { diff --git a/sys/contrib/dev/acpica/tables/tbutils.c b/sys/contrib/dev/acpica/tables/tbutils.c index 916c04e02415..f6acc3cfb8ae 100644 --- a/sys/contrib/dev/acpica/tables/tbutils.c +++ b/sys/contrib/dev/acpica/tables/tbutils.c @@ -184,7 +184,7 @@ AcpiTbTablesLoaded ( void) { - if (AcpiGbl_RootTableList.Count >= 3) + if (AcpiGbl_RootTableList.CurrentTableCount >= 3) { return (TRUE); } @@ -780,14 +780,15 @@ AcpiTbParseRootTable ( * come from the FADT */ TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER); - AcpiGbl_RootTableList.Count = 2; + AcpiGbl_RootTableList.CurrentTableCount = 2; /* * Initialize the root table array from the RSDT/XSDT */ for (i = 0; i < TableCount; i++) { - if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + if (AcpiGbl_RootTableList.CurrentTableCount >= + AcpiGbl_RootTableList.MaxTableCount) { /* There is no more room in the root table array, attempt resize */ @@ -796,18 +797,18 @@ AcpiTbParseRootTable ( { ACPI_WARNING ((AE_INFO, "Truncating %u table entries!", (unsigned) (TableCount - - (AcpiGbl_RootTableList.Count - 2)))); + (AcpiGbl_RootTableList.CurrentTableCount - 2)))); break; } } /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount].Address = AcpiTbGetRootTableEntry (TableEntry, TableEntrySize); TableEntry += TableEntrySize; - AcpiGbl_RootTableList.Count++; + AcpiGbl_RootTableList.CurrentTableCount++; } /* @@ -820,7 +821,7 @@ AcpiTbParseRootTable ( * Complete the initialization of the root table array by examining * the header of each table */ - for (i = 2; i < AcpiGbl_RootTableList.Count; i++) + for (i = 2; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, NULL, i); diff --git a/sys/contrib/dev/acpica/tables/tbxface.c b/sys/contrib/dev/acpica/tables/tbxface.c index e2eeb2e5aed3..366a52541420 100644 --- a/sys/contrib/dev/acpica/tables/tbxface.c +++ b/sys/contrib/dev/acpica/tables/tbxface.c @@ -150,7 +150,7 @@ AcpiAllocateRootTable ( UINT32 InitialTableCount) { - AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.MaxTableCount = InitialTableCount; AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE; return (AcpiTbResizeRootTableList ()); @@ -216,7 +216,7 @@ AcpiInitializeTables ( (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC)); AcpiGbl_RootTableList.Tables = InitialTableArray; - AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.MaxTableCount = InitialTableCount; AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN; if (AllowResize) { @@ -285,7 +285,7 @@ AcpiReallocateRootTable ( * increment to create the new table size. */ CurrentSize = (ACPI_SIZE) - AcpiGbl_RootTableList.Count * sizeof (ACPI_TABLE_DESC); + AcpiGbl_RootTableList.CurrentTableCount * sizeof (ACPI_TABLE_DESC); NewSize = CurrentSize + (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC)); @@ -306,8 +306,8 @@ AcpiReallocateRootTable ( * size of the original table list. */ AcpiGbl_RootTableList.Tables = Tables; - AcpiGbl_RootTableList.Size = - AcpiGbl_RootTableList.Count + ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.MaxTableCount = + AcpiGbl_RootTableList.CurrentTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; @@ -354,7 +354,7 @@ AcpiGetTableHeader ( /* Walk the root table list */ - for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) @@ -439,7 +439,7 @@ AcpiGetTable ( /* Walk the root table list */ - for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) { if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) @@ -502,7 +502,7 @@ AcpiGetTableByIndex ( /* Validate index */ - if (TableIndex >= AcpiGbl_RootTableList.Count) + if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) { (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (AE_BAD_PARAMETER); @@ -559,7 +559,7 @@ AcpiTbLoadNamespace ( * Load the namespace. The DSDT is required, but any SSDT and * PSDT tables are optional. Verify the DSDT. */ - if (!AcpiGbl_RootTableList.Count || + if (!AcpiGbl_RootTableList.CurrentTableCount || !ACPI_COMPARE_NAME ( &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), ACPI_SIG_DSDT) || @@ -613,7 +613,7 @@ AcpiTbLoadNamespace ( /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - for (i = 2; i < AcpiGbl_RootTableList.Count; ++i) + for (i = 2; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) { if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), ACPI_SIG_SSDT) && diff --git a/sys/contrib/dev/acpica/utilities/utcopy.c b/sys/contrib/dev/acpica/utilities/utcopy.c index b16e14c1439d..f6bfba04ded0 100644 --- a/sys/contrib/dev/acpica/utilities/utcopy.c +++ b/sys/contrib/dev/acpica/utilities/utcopy.c @@ -797,6 +797,7 @@ AcpiUtCopySimpleObject ( UINT16 ReferenceCount; ACPI_OPERAND_OBJECT *NextObject; ACPI_STATUS Status; + ACPI_SIZE CopySize; /* Save fields from destination that we don't want to overwrite */ @@ -804,10 +805,18 @@ AcpiUtCopySimpleObject ( ReferenceCount = DestDesc->Common.ReferenceCount; NextObject = DestDesc->Common.NextObject; - /* Copy the entire source object over the destination object*/ + /* + * Copy the entire source object over the destination object. + * Note: Source can be either an operand object or namespace node. + */ + CopySize = sizeof (ACPI_OPERAND_OBJECT); + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) + { + CopySize = sizeof (ACPI_NAMESPACE_NODE); + } - ACPI_MEMCPY ((char *) DestDesc, (char *) SourceDesc, - sizeof (ACPI_OPERAND_OBJECT)); + ACPI_MEMCPY (ACPI_CAST_PTR (char, DestDesc), + ACPI_CAST_PTR (char, SourceDesc), CopySize); /* Restore the saved fields */ @@ -841,8 +850,7 @@ AcpiUtCopySimpleObject ( /* Copy the actual buffer data */ ACPI_MEMCPY (DestDesc->Buffer.Pointer, - SourceDesc->Buffer.Pointer, - SourceDesc->Buffer.Length); + SourceDesc->Buffer.Pointer, SourceDesc->Buffer.Length); } break; @@ -864,7 +872,7 @@ AcpiUtCopySimpleObject ( /* Copy the actual string data */ ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, - (ACPI_SIZE) SourceDesc->String.Length + 1); + (ACPI_SIZE) SourceDesc->String.Length + 1); } break; diff --git a/sys/contrib/dev/acpica/utilities/utglobal.c b/sys/contrib/dev/acpica/utilities/utglobal.c index 85a93fe77a6e..0483be9ff095 100644 --- a/sys/contrib/dev/acpica/utilities/utglobal.c +++ b/sys/contrib/dev/acpica/utilities/utglobal.c @@ -625,7 +625,7 @@ AcpiUtGetNodeName ( static const char *AcpiGbl_DescTypeNames[] = { - /* 00 */ "Invalid", + /* 00 */ "Not a Descriptor", /* 01 */ "Cached", /* 02 */ "State-Generic", /* 03 */ "State-Update", @@ -656,7 +656,7 @@ AcpiUtGetDescriptorName ( if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX) { - return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); + return ("Not a Descriptor"); } return (ACPI_CAST_PTR (char, diff --git a/sys/contrib/dev/acpica/utilities/uttrack.c b/sys/contrib/dev/acpica/utilities/uttrack.c index ddb35ef891c2..fc5a47231b0b 100644 --- a/sys/contrib/dev/acpica/utilities/uttrack.c +++ b/sys/contrib/dev/acpica/utilities/uttrack.c @@ -644,6 +644,7 @@ AcpiUtDumpAllocations ( ACPI_DEBUG_MEM_BLOCK *Element; ACPI_DESCRIPTOR *Descriptor; UINT32 NumOutstanding = 0; + UINT8 DescriptorType; ACPI_FUNCTION_TRACE (UtDumpAllocations); @@ -663,43 +664,86 @@ AcpiUtDumpAllocations ( if ((Element->Component & Component) && ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) { - /* Ignore allocated objects that are in a cache */ - Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); - if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) + + if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR)) { - AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", + AcpiOsPrintf ("%p Length 0x%04X %9.9s-%d " + "[Not a Descriptor - too small]\n", Descriptor, Element->Size, Element->Module, - Element->Line, AcpiUtGetDescriptorName (Descriptor)); - - /* Most of the elements will be Operand objects. */ - - switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) - { - case ACPI_DESC_TYPE_OPERAND: - AcpiOsPrintf ("%12.12s R%hd", - AcpiUtGetTypeName (Descriptor->Object.Common.Type), - Descriptor->Object.Common.ReferenceCount); - break; - - case ACPI_DESC_TYPE_PARSER: - AcpiOsPrintf ("AmlOpcode %04hX", - Descriptor->Op.Asl.AmlOpcode); - break; - - case ACPI_DESC_TYPE_NAMED: - AcpiOsPrintf ("%4.4s", - AcpiUtGetNodeName (&Descriptor->Node)); - break; - - default: - break; - } - - AcpiOsPrintf ( "\n"); - NumOutstanding++; + Element->Line); } + else + { + /* Ignore allocated objects that are in a cache */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) + { + AcpiOsPrintf ("%p Length 0x%04X %9.9s-%d [%s] ", + Descriptor, Element->Size, Element->Module, + Element->Line, AcpiUtGetDescriptorName (Descriptor)); + + /* Validate the descriptor type using Type field and length */ + + DescriptorType = 0; /* Not a valid descriptor type */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) + { + case ACPI_DESC_TYPE_OPERAND: + if (Element->Size == sizeof (ACPI_DESC_TYPE_OPERAND)) + { + DescriptorType = ACPI_DESC_TYPE_OPERAND; + } + break; + + case ACPI_DESC_TYPE_PARSER: + if (Element->Size == sizeof (ACPI_DESC_TYPE_PARSER)) + { + DescriptorType = ACPI_DESC_TYPE_PARSER; + } + break; + + case ACPI_DESC_TYPE_NAMED: + if (Element->Size == sizeof (ACPI_DESC_TYPE_NAMED)) + { + DescriptorType = ACPI_DESC_TYPE_NAMED; + } + break; + + default: + break; + } + + /* Display additional info for the major descriptor types */ + + switch (DescriptorType) + { + case ACPI_DESC_TYPE_OPERAND: + AcpiOsPrintf ("%12.12s RefCount 0x%04X\n", + AcpiUtGetTypeName (Descriptor->Object.Common.Type), + Descriptor->Object.Common.ReferenceCount); + break; + + case ACPI_DESC_TYPE_PARSER: + AcpiOsPrintf ("AmlOpcode 0x%04hX\n", + Descriptor->Op.Asl.AmlOpcode); + break; + + case ACPI_DESC_TYPE_NAMED: + AcpiOsPrintf ("%4.4s\n", + AcpiUtGetNodeName (&Descriptor->Node)); + break; + + default: + AcpiOsPrintf ( "\n"); + break; + } + } + } + + NumOutstanding++; } + Element = Element->Next; } @@ -709,13 +753,11 @@ AcpiUtDumpAllocations ( if (!NumOutstanding) { - ACPI_INFO ((AE_INFO, - "No outstanding allocations")); + ACPI_INFO ((AE_INFO, "No outstanding allocations")); } else { - ACPI_ERROR ((AE_INFO, - "%d(0x%X) Outstanding allocations", + ACPI_ERROR ((AE_INFO, "%d(0x%X) Outstanding allocations", NumOutstanding, NumOutstanding)); } diff --git a/sys/dev/acpica/Osd/OsdHardware.c b/sys/dev/acpica/Osd/OsdHardware.c index 822bf78545dc..06388027c60c 100644 --- a/sys/dev/acpica/Osd/OsdHardware.c +++ b/sys/dev/acpica/Osd/OsdHardware.c @@ -216,12 +216,12 @@ acpi_bus_number(ACPI_HANDLE root, ACPI_HANDLE curr, ACPI_PCI_ID *PciId) /* * Find the bus number for a device * - * rhandle: handle for the root bus - * chandle: handle for the device + * Device: handle for the PCI root bridge device + * Region: handle for the PCI configuration space operation region * PciId: pointer to device slot and function, we fill out bus */ void -AcpiOsDerivePciId(ACPI_HANDLE rhandle, ACPI_HANDLE chandle, ACPI_PCI_ID **PciId) +AcpiOsDerivePciId(ACPI_HANDLE Device, ACPI_HANDLE Region, ACPI_PCI_ID **PciId) { ACPI_HANDLE parent; ACPI_STATUS status; @@ -230,26 +230,21 @@ AcpiOsDerivePciId(ACPI_HANDLE rhandle, ACPI_HANDLE chandle, ACPI_PCI_ID **PciId) if (pci_cfgregopen() == 0) panic("AcpiOsDerivePciId unable to initialize pci bus"); - /* Try to read _BBN for bus number if we're at the root */ + /* Try to read _BBN for bus number if we're at the root. */ bus = 0; - if (rhandle == chandle) { - status = acpi_GetInteger(rhandle, "_BBN", &bus); + if (Device == Region) { + status = acpi_GetInteger(Device, "_BBN", &bus); if (ACPI_FAILURE(status) && bootverbose) printf("AcpiOsDerivePciId: root bus has no _BBN, assuming 0\n"); } - /* - * Get the parent handle and call the recursive case. It is not - * clear why we seem to be getting a chandle that points to a child - * of the desired slot/function but passing in the parent handle - * here works. - */ - if (ACPI_SUCCESS(AcpiGetParent(chandle, &parent))) - bus = acpi_bus_number(rhandle, parent, *PciId); + /* Get the parent handle and call the recursive case. */ + if (ACPI_SUCCESS(AcpiGetParent(Region, &parent))) + bus = acpi_bus_number(Device, parent, *PciId); (*PciId)->Bus = bus; if (bootverbose) { printf("AcpiOsDerivePciId: %s -> bus %d dev %d func %d\n", - acpi_name(chandle), (*PciId)->Bus, (*PciId)->Device, + acpi_name(Region), (*PciId)->Bus, (*PciId)->Device, (*PciId)->Function); } } diff --git a/sys/modules/acpi/acpi/Makefile b/sys/modules/acpi/acpi/Makefile index 6fa36ffcd707..2606023dbafb 100644 --- a/sys/modules/acpi/acpi/Makefile +++ b/sys/modules/acpi/acpi/Makefile @@ -33,8 +33,8 @@ SRCS+= dmbuffer.c dmnames.c dmopcode.c dmobject.c dmresrc.c dmresrcl.c SRCS+= dmresrcs.c dmutils.c dmwalk.c SRCS+= dsfield.c dsinit.c dsmethod.c dsmthdat.c dsobject.c dsopcode.c SRCS+= dsutils.c dswexec.c dswload.c dswscope.c dswstate.c -SRCS+= evevent.c evgpe.c evgpeblk.c evmisc.c evregion.c evrgnini.c evsci.c -SRCS+= evxface.c evxfevnt.c evxfregn.c +SRCS+= evevent.c evgpe.c evgpeblk.c evgpeinit.c evgpeutil.c evmisc.c +SRCS+= evregion.c evrgnini.c evsci.c evxface.c evxfevnt.c evxfregn.c SRCS+= exconfig.c exconvrt.c excreate.c exdebug.c exdump.c exfield.c SRCS+= exfldio.c exmisc.c exmutex.c exnames.c exoparg1.c exoparg2.c SRCS+= exoparg3.c exoparg6.c exprep.c exregion.c exresnte.c exresolv.c diff --git a/usr.sbin/acpi/acpidb/Makefile b/usr.sbin/acpi/acpidb/Makefile index c2fe844367b7..eed57f3f2a41 100644 --- a/usr.sbin/acpi/acpidb/Makefile +++ b/usr.sbin/acpi/acpidb/Makefile @@ -13,8 +13,9 @@ SRCS+= dmbuffer.c dmnames.c dmobject.c dmopcode.c dmresrc.c \ dmresrcl.c dmresrcs.c dmutils.c dmwalk.c # events -SRCS+= evevent.c evgpe.c evgpeblk.c evmisc.c evregion.c \ - evrgnini.c evsci.c evxface.c evxfevnt.c evxfregn.c +SRCS+= evevent.c evgpe.c evgpeblk.c evgpeinit.c evgpeutil.c \ + evmisc.c evregion.c evrgnini.c evsci.c evxface.c \ + evxfevnt.c evxfregn.c # hardware SRCS+= hwacpi.c hwgpe.c hwregs.c hwsleep.c hwvalid.c hwxface.c diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile index ea7a3257178a..3e17cc9b8d60 100644 --- a/usr.sbin/acpi/iasl/Makefile +++ b/usr.sbin/acpi/iasl/Makefile @@ -14,8 +14,10 @@ SRCS+= aslanalyze.c aslcodegen.c aslcompile.c aslcompiler.y.h \ aslfiles.c aslfold.c asllength.c asllisting.c \ aslload.c asllookup.c aslmain.c aslmap.c aslopcodes.c \ asloperands.c aslopt.c aslpredef.c aslresource.c \ - aslrestype1.c aslrestype2.c aslstartup.c aslstubs.c \ - asltransform.c asltree.c aslutils.c + aslrestype1.c aslrestype1i.c aslrestype2.c \ + aslrestype2d.c aslrestype2e.c aslrestype2q.c \ + aslrestype2w.c aslstartup.c aslstubs.c asltransform.c \ + asltree.c aslutils.c # debugger SRCS+= dbfileio.c