From 036a340132158b72dda75c1c1678332377d8f173 Mon Sep 17 00:00:00 2001 From: Al Stone Date: Apr 07 2014 17:36:47 +0000 Subject: Imported Upstream version 20140325 --- diff --git a/changes.txt b/changes.txt index bcd15f3..ab9cb55 100755 --- a/changes.txt +++ b/changes.txt @@ -1,4 +1,104 @@ ---------------------------------------- +25 March 2014. Summary of changes for version 20140325: + +1) ACPICA kernel-resident subsystem: + +Updated the auto-serialize feature for control methods. This feature +automatically serializes all methods that create named objects in order +to prevent runtime errors. The update adds support to ignore the +currently executing AML SyncLevel when invoking such a method, in order +to prevent disruption of any existing SyncLevel priorities that may exist +in the AML code. Although the use of SyncLevels is relatively rare, this +change fixes a regression where an AE_AML_MUTEX_ORDER exception can +appear on some machines starting with the 20140214 release. + +Added a new external interface to allow the host to install ACPI tables +very early, before the namespace is even created. AcpiInstallTable gives +the host additional flexibility for ACPI table management. Tables can be +installed directly by the host as if they had originally appeared in the +XSDT/RSDT. Installed tables can be SSDTs or other ACPI data tables +(anything except the DSDT and FACS). Adds a new file, tbdata.c, along +with additional internal restructuring and cleanup. See the ACPICA +Reference for interface details. Lv Zheng. + +Added validation of the checksum for all incoming dynamically loaded +tables (via external interfaces or via AML Load/LoadTable operators). Lv +Zheng. + +Updated the use of the AcpiOsWaitEventsComplete interface during Notify +and GPE handler removal. Restructured calls to eliminate possible race +conditions. Lv Zheng. + +Added a warning for the use/execution of the ASL/AML Unload (table) +operator. This will help detect and identify machines that use this +operator if and when it is ever used. This operator has never been seen +in the field and the usage model and possible side-effects of the drastic +runtime action of a full table removal are unknown. + +Reverted the use of #pragma push/pop which was introduced in the 20140214 +release. It appears that push and pop are not implemented by enough +compilers to make the use of this feature feasible for ACPICA at this +time. However, these operators may be deployed in a future ACPICA +release. + +Added the missing EXPORT_SYMBOL macros for the install and remove SCI +handler interfaces. + +Source code generation: +1) Disabled the use of the "strchr" macro for the gcc-specific +generation. For some versions of gcc, this macro can periodically expose +a compiler bug which in turn causes compile-time error(s). +2) Added support for PPC64 compilation. Colin Ian King. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.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. + + Current Release: + Non-Debug Version: 97.0K Code, 27.2K Data, 124.2K Total + Debug Version: 189.7K Code, 79.5K Data, 269.2K Total + Previous Release: + Non-Debug Version: 96.5K Code, 27.2K Data, 123.7K Total + Debug Version: 188.6K Code, 79.0K Data, 267.6K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Added several new features to improve the readability of +the resulting ASL code. Extra information is emitted within comment +fields in the ASL code: +1) Known _HID/_CID values are decoded to descriptive text. +2) Standard values for the Notify() operator are decoded to descriptive +text. +3) Target operands are expanded to full pathnames (in a comment) when +possible. + +Disassembler: Miscellaneous updates for extern() handling: +1) Abort compiler if file specified by -fe option does not exist. +2) Silence unnecessary warnings about argument count mismatches. +3) Update warning messages concerning unresolved method externals. +4) Emit "UnknownObj" keyword for externals whose type cannot be +determined. + +AcpiHelp utility: +1) Added the -a option to display both the ASL syntax and the AML +encoding for an input ASL operator. This effectively displays all known +information about an ASL operator with one AcpiHelp invocation. +2) Added substring match support (similar to a wildcard) for the -i +(_HID/PNP IDs) option. + +iASL/Disassembler: Since this tool does not yet support execution on big- +endian machines, added detection of endianness and an error message if +execution is attempted on big-endian. Support for big-endian within iASL +is a feature that is on the ACPICA to-be-done list. + +AcpiBin utility: +1) Remove option to extract binary files from an acpidump; this function +is made obsolete by the AcpiXtract utility. +2) General cleanup of open files and allocated buffers. + +---------------------------------------- 14 February 2014. Summary of changes for version 20140214: 1) ACPICA kernel-resident subsystem: diff --git a/generate/unix/acpibin/Makefile b/generate/unix/acpibin/Makefile index 2a5aff6..c33c085 100644 --- a/generate/unix/acpibin/Makefile +++ b/generate/unix/acpibin/Makefile @@ -29,6 +29,8 @@ HEADERS = \ OBJECTS = \ $(OBJDIR)/abcompare.o\ $(OBJDIR)/abmain.o\ + $(OBJDIR)/cmfsize.o\ + $(OBJDIR)/getopt.o\ $(OBJDIR)/utalloc.o\ $(OBJDIR)/utbuffer.o\ $(OBJDIR)/utcache.o\ @@ -42,8 +44,7 @@ OBJECTS = \ $(OBJDIR)/utstate.o\ $(OBJDIR)/utstring.o\ $(OBJDIR)/utxferror.o\ - $(OBJDIR)/osunixxf.o\ - $(OBJDIR)/getopt.o + $(OBJDIR)/osunixxf.o # # Flags specific to acpibin diff --git a/generate/unix/acpidump/Makefile b/generate/unix/acpidump/Makefile index b7d2021..8a9cda5 100644 --- a/generate/unix/acpidump/Makefile +++ b/generate/unix/acpidump/Makefile @@ -31,6 +31,8 @@ OBJECTS = \ $(OBJDIR)/apdump.o\ $(OBJDIR)/apfiles.o\ $(OBJDIR)/apmain.o\ + $(OBJDIR)/cmfsize.o\ + $(OBJDIR)/getopt.o\ $(OBJDIR)/osunixdir.o\ $(OBJDIR)/osunixmap.o\ $(OBJDIR)/tbprint.o\ @@ -39,8 +41,7 @@ OBJECTS = \ $(OBJDIR)/utexcep.o\ $(OBJDIR)/utmath.o\ $(OBJDIR)/utstring.o\ - $(OBJDIR)/utxferror.o\ - $(OBJDIR)/getopt.o + $(OBJDIR)/utxferror.o # # Per-host interfaces diff --git a/generate/unix/acpiexamples/Makefile b/generate/unix/acpiexamples/Makefile index 5f0b3b6..c2f3c73 100644 --- a/generate/unix/acpiexamples/Makefile +++ b/generate/unix/acpiexamples/Makefile @@ -103,6 +103,7 @@ OBJECTS = \ $(OBJDIR)/psutils.o\ $(OBJDIR)/pswalk.o\ $(OBJDIR)/psxface.o\ + $(OBJDIR)/tbdata.o\ $(OBJDIR)/tbfadt.o\ $(OBJDIR)/tbfind.o\ $(OBJDIR)/tbinstal.o\ diff --git a/generate/unix/acpiexec/Makefile b/generate/unix/acpiexec/Makefile index 63fa77c..84cc978 100644 --- a/generate/unix/acpiexec/Makefile +++ b/generate/unix/acpiexec/Makefile @@ -44,6 +44,8 @@ OBJECTS = \ $(OBJDIR)/aehandlers.o\ $(OBJDIR)/aemain.o\ $(OBJDIR)/aetables.o\ + $(OBJDIR)/ahids.o\ + $(OBJDIR)/cmfsize.o\ $(OBJDIR)/dbcmds.o\ $(OBJDIR)/dbconvert.o\ $(OBJDIR)/dbdisply.o\ @@ -179,6 +181,7 @@ OBJECTS = \ $(OBJDIR)/rsserial.o\ $(OBJDIR)/rsutils.o\ $(OBJDIR)/rsxface.o\ + $(OBJDIR)/tbdata.o\ $(OBJDIR)/tbfadt.o\ $(OBJDIR)/tbfind.o\ $(OBJDIR)/tbinstal.o\ diff --git a/generate/unix/acpihelp/Makefile b/generate/unix/acpihelp/Makefile index 2dbd13b..da6ee49 100644 --- a/generate/unix/acpihelp/Makefile +++ b/generate/unix/acpihelp/Makefile @@ -31,6 +31,7 @@ OBJECTS = \ $(OBJDIR)/ahaslkey.o\ $(OBJDIR)/ahaslops.o\ $(OBJDIR)/ahdecode.o\ + $(OBJDIR)/ahids.o\ $(OBJDIR)/ahpredef.o\ $(OBJDIR)/ahmain.o\ $(OBJDIR)/getopt.o\ diff --git a/generate/unix/acpinames/Makefile b/generate/unix/acpinames/Makefile index 1438200..00a0026 100644 --- a/generate/unix/acpinames/Makefile +++ b/generate/unix/acpinames/Makefile @@ -38,6 +38,7 @@ OBJECTS = \ $(OBJDIR)/anmain.o\ $(OBJDIR)/anstubs.o\ $(OBJDIR)/antables.o\ + $(OBJDIR)/cmfsize.o\ $(OBJDIR)/dbfileio.o\ $(OBJDIR)/dsfield.o\ $(OBJDIR)/dsmthdat.o\ @@ -79,6 +80,7 @@ OBJECTS = \ $(OBJDIR)/psutils.o\ $(OBJDIR)/pswalk.o\ $(OBJDIR)/psxface.o\ + $(OBJDIR)/tbdata.o\ $(OBJDIR)/tbfadt.o\ $(OBJDIR)/tbfind.o\ $(OBJDIR)/tbinstal.o\ diff --git a/generate/unix/acpisrc/Makefile b/generate/unix/acpisrc/Makefile index bf87817..50199ce 100644 --- a/generate/unix/acpisrc/Makefile +++ b/generate/unix/acpisrc/Makefile @@ -33,8 +33,9 @@ OBJECTS = \ $(OBJDIR)/asremove.o\ $(OBJDIR)/astable.o\ $(OBJDIR)/asutils.o\ - $(OBJDIR)/osunixdir.o\ - $(OBJDIR)/getopt.o + $(OBJDIR)/cmfsize.o\ + $(OBJDIR)/getopt.o \ + $(OBJDIR)/osunixdir.o # # Compile flags specific to acpisrc diff --git a/generate/unix/iasl/Makefile b/generate/unix/iasl/Makefile index fd58de9..f0662b7 100644 --- a/generate/unix/iasl/Makefile +++ b/generate/unix/iasl/Makefile @@ -46,6 +46,7 @@ OBJECTS = \ $(OBJDIR)/adfile.o\ $(OBJDIR)/adisasm.o\ $(OBJDIR)/adwalk.o\ + $(OBJDIR)/ahids.o\ $(OBJDIR)/ahpredef.o\ $(OBJDIR)/aslanalyze.o\ $(OBJDIR)/aslbtypes.o\ @@ -89,6 +90,7 @@ OBJECTS = \ $(OBJDIR)/asluuid.o\ $(OBJDIR)/aslwalks.o\ $(OBJDIR)/aslxref.o\ + $(OBJDIR)/cmfsize.o\ $(OBJDIR)/dtcompile.o\ $(OBJDIR)/dtexpress.o\ $(OBJDIR)/dtfield.o\ @@ -171,6 +173,7 @@ OBJECTS = \ $(OBJDIR)/pstree.o\ $(OBJDIR)/psutils.o\ $(OBJDIR)/pswalk.o\ + $(OBJDIR)/tbdata.o\ $(OBJDIR)/tbfadt.o\ $(OBJDIR)/tbinstal.o\ $(OBJDIR)/tbprint.o\ diff --git a/source/common/adfile.c b/source/common/adfile.c index 91b35c5..0b70d69 100644 --- a/source/common/adfile.c +++ b/source/common/adfile.c @@ -203,11 +203,16 @@ FlGenerateFilename ( /* - * Copy the original filename to a new buffer. Leave room for the worst case - * where we append the suffix, an added dot and the null terminator. + * Copy the original filename to a new buffer. Leave room for the worst + * case where we append the suffix, an added dot and the null terminator. */ NewFilename = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) strlen (InputFilename) + strlen (Suffix) + 2); + if (!NewFilename) + { + return (NULL); + } + strcpy (NewFilename, InputFilename); /* Try to find the last dot in the filename */ diff --git a/source/common/adisasm.c b/source/common/adisasm.c index 2a8fac3..7ca1623 100644 --- a/source/common/adisasm.c +++ b/source/common/adisasm.c @@ -79,10 +79,6 @@ NsSetupNamespaceListing ( /* Local prototypes */ -static UINT32 -AdGetFileSize ( - FILE *File); - static void AdCreateTableHeader ( char *Filename, @@ -157,38 +153,6 @@ static ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot; /******************************************************************************* * - * FUNCTION: AdGetFileSize - * - * PARAMETERS: File - Open file handle - * - * RETURN: File Size - * - * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. - * - ******************************************************************************/ - -static UINT32 -AdGetFileSize ( - FILE *File) -{ - UINT32 FileSize; - long Offset; - - - Offset = ftell (File); - - fseek (File, 0, SEEK_END); - FileSize = (UINT32) ftell (File); - - /* Restore file pointer */ - - fseek (File, Offset, SEEK_SET); - return (FileSize); -} - - -/******************************************************************************* - * * FUNCTION: AdInitialize * * PARAMETERS: None @@ -206,7 +170,7 @@ AdInitialize ( ACPI_STATUS Status; - /* ACPI CA subsystem initialization */ + /* ACPICA subsystem initialization */ Status = AcpiOsInitialize (); if (ACPI_FAILURE (Status)) @@ -381,7 +345,7 @@ AdAmlDisassemble ( /* Create/Open a disassembly output file */ DisasmFilename = FlGenerateFilename (Prefix, FILE_SUFFIX_DISASSEMBLY); - if (!OutFilename) + if (!DisasmFilename) { fprintf (stderr, "Could not generate output filename\n"); Status = AE_ERROR; @@ -413,7 +377,7 @@ AdAmlDisassemble ( fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n", Table->Signature); fprintf (stderr, "Formatted output: %s - %u bytes\n", - DisasmFilename, AdGetFileSize (File)); + DisasmFilename, CmGetFileSize (File)); } else { @@ -469,9 +433,10 @@ AdAmlDisassemble ( "reparsing with new information\n", AcpiDmGetExternalMethodCount ()); - /* Reparse, rebuild namespace. no need to xref namespace */ + /* Reparse, rebuild namespace */ AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot); + AcpiGbl_ParseOpRoot = NULL; AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); AcpiGbl_RootNode = NULL; @@ -485,6 +450,9 @@ AdAmlDisassemble ( AcpiGbl_RootNodeStruct.Flags = 0; Status = AcpiNsRootInitialize (); + + /* New namespace, add the external definitions first */ + AcpiDmAddExternalsToNamespace (); /* Parse the table again. No need to reload it, however */ @@ -497,6 +465,14 @@ AdAmlDisassemble ( goto Cleanup; } + /* Cross reference the namespace again */ + + AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); + + AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot, + AcpiGbl_RootNode, OwnerId); + if (AslCompilerdebug) { AcpiOsPrintf ("/**** After second load and resource conversion\n"); @@ -531,7 +507,7 @@ AdAmlDisassemble ( fprintf (stderr, "Disassembly completed\n"); fprintf (stderr, "ASL Output: %s - %u bytes\n", - DisasmFilename, AdGetFileSize (File)); + DisasmFilename, CmGetFileSize (File)); } } @@ -568,7 +544,7 @@ Cleanup: * * RETURN: None * - * DESCRIPTION: Create the disassembler header, including ACPI CA signon with + * DESCRIPTION: Create the disassembler header, including ACPICA signon with * current time and date. * *****************************************************************************/ @@ -600,7 +576,7 @@ AdDisassemblerHeader ( * * RETURN: None * - * DESCRIPTION: Create the ASL table header, including ACPI CA signon with + * DESCRIPTION: Create the ASL table header, including ACPICA signon with * current time and date. * *****************************************************************************/ @@ -678,8 +654,17 @@ AdCreateTableHeader ( else { NewFilename = ACPI_ALLOCATE_ZEROED (9); - strncat (NewFilename, Table->Signature, 4); - strcat (NewFilename, ".aml"); + if (NewFilename) + { + strncat (NewFilename, Table->Signature, 4); + strcat (NewFilename, ".aml"); + } + } + + if (!NewFilename) + { + AcpiOsPrintf (" **** Could not generate AML output filename\n"); + return; } /* Open the ASL definition block */ @@ -872,7 +857,8 @@ AdParseTable ( if (LoadTable) { Status = AcpiTbStoreTable ((ACPI_PHYSICAL_ADDRESS) Table, Table, - Table->Length, ACPI_TABLE_ORIGIN_ALLOCATED, &TableIndex); + Table->Length, ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, + &TableIndex); if (ACPI_FAILURE (Status)) { return (Status); @@ -907,9 +893,12 @@ AdParseTable ( return (AE_OK); } - /* Pass 3: Parse control methods and link their parse trees into the main parse tree */ - - fprintf (stderr, "Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n"); + /* + * Pass 3: Parse control methods and link their parse trees + * into the main parse tree + */ + fprintf (stderr, + "Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n"); Status = AcpiDmParseDeferredOps (AcpiGbl_ParseOpRoot); fprintf (stderr, "\n"); diff --git a/source/common/adwalk.c b/source/common/adwalk.c index 6bd6f50..d150f4d 100644 --- a/source/common/adwalk.c +++ b/source/common/adwalk.c @@ -760,11 +760,13 @@ AcpiDmXrefDescendingOp ( if ((!(OpInfo->Flags & AML_NAMED)) && (!(OpInfo->Flags & AML_CREATE)) && - (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP)) + (Op->Common.AmlOpcode != AML_INT_NAMEPATH_OP) && + (Op->Common.AmlOpcode != AML_NOTIFY_OP)) { goto Exit; } + /* Get the NamePath from the appropriate place */ if (OpInfo->Flags & AML_NAMED) @@ -801,6 +803,10 @@ AcpiDmXrefDescendingOp ( Path = NextOp->Common.Value.String; } } + else if (Op->Common.AmlOpcode == AML_NOTIFY_OP) + { + Path = Op->Common.Value.Arg->Asl.Value.String; + } else { Path = Op->Common.Value.String; diff --git a/source/common/ahids.c b/source/common/ahids.c new file mode 100755 index 0000000..851393b --- /dev/null +++ b/source/common/ahids.c @@ -0,0 +1,214 @@ +/****************************************************************************** + * + * Module Name: ahids - Table of ACPI/PNP _HID/_CID values + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("ahids") + + +/* + * ACPI/PNP Device IDs with description strings + */ +const AH_DEVICE_ID AslDeviceIds[] = +{ + {"10EC5640", "Realtek I2S Audio Codec"}, + {"80860F0A", "Intel Atom UART Controller"}, + {"80860F14", "Intel Baytrail SDIO/MMC Host Controller"}, + {"80860F28", "Intel SST Audio DSP"}, + {"80860F41", "Intel Baytrail I2C Host Controller"}, + {"ACPI0001", "SMBus 1.0 Host Controller"}, + {"ACPI0002", "Smart Battery Subsystem"}, + {"ACPI0003", "Power Source Device"}, + {"ACPI0004", "Module Device"}, + {"ACPI0005", "SMBus 2.0 Host Controller"}, + {"ACPI0006", "GPE Block Device"}, + {"ACPI0007", "Processor Device"}, + {"ACPI0008", "Ambient Light Sensor Device"}, + {"ACPI0009", "I/O xAPIC Device"}, + {"ACPI000A", "I/O APIC Device"}, + {"ACPI000B", "I/O SAPIC Device"}, + {"ACPI000C", "Processor Aggregator Device"}, + {"ACPI000D", "Power Meter Device"}, + {"ACPI000E", "Time and Alarm Device"}, + {"ACPI000F", "User Presence Detection Device"}, + {"ATK4001", "Asus Radio Control Button"}, + {"ATML1000", "Atmel Touchscreen Controller"}, + {"BCM2E39", "Broadcom BT Serial Bus Driver over UART Bus Enumerator"}, + {"CPLM3218", "Capella Micro CM3218x Ambient Light Sensor"}, + {"DELLABCE", "Dell Airplane Mode Switch Driver"}, + {"DLAC3002", "Qualcomm Atheros Bluetooth UART Transport"}, + {"INT0002", "Virtual GPIO Controller"}, + {"INT0800", "Intel 82802 Firmware Hub Device"}, + {"INT3394", "ACPI System Fan"}, + {"INT3396", "Standard Power Management Controller"}, + {"INT33A0", "Intel Smart Connect Technology Device"}, + {"INT33A1", "Intel Power Engine"}, + {"INT33BB", "Intel Baytrail SD Host Controller"}, + {"INT33BD", "Intel Baytrail Mailbox Device"}, + {"INT33C0", "Intel Serial I/O SPI Host Controller"}, + {"INT33C1", "Intel Serial I/O SPI Host Controller"}, + {"INT33C2", "Intel Serial I/O I2C Host Controller"}, + {"INT33C3", "Intel Serial I/O I2C Host Controller"}, + {"INT33C4", "Intel Serial I/O UART Host Controller"}, + {"INT33C5", "Intel Serial I/O UART Host Controller"}, + {"INT33C6", "Intel SD Host Controller"}, + {"INT33C7", "Intel Serial I/O GPIO Host Controller"}, + {"INT33C8", "Intel Smart Sound Technology Host Controller"}, + {"INT33C9", "Wolfson Microelectronics Audio WM5102"}, + {"INT33CA", "Intel SPB Peripheral"}, + {"INT33CB", "Intel Smart Sound Technology Audio Codec"}, + {"INT33D1", "Intel GPIO Buttons"}, + {"INT33D2", "Intel GPIO Buttons"}, + {"INT33D3", "Intel GPIO Buttons"}, + {"INT33D4", "Intel GPIO Buttons"}, + {"INT33D6", "Intel Virtual Buttons Device"}, + {"INT33F0", "Camera Sensor MT9M114"}, + {"INT33FB", "MIPI-CSI Camera Sensor OV2722"}, + {"INT33FC", "Intel Baytrail GPIO Controller"}, + {"INT33FD", "Intel Baytrail Power Management IC"}, + {"INT3400", "Intel Dynamic Power Performance Management"}, + {"INT3401", "Intel Extended Thermal Model CPU"}, + {"INT3403", "DPTF Temperature Sensor"}, + {"INT3406", "Intel Dynamic Platform & Thermal Framework Display Participant"}, + {"INT3407", "DPTF Platform Power Meter"}, + {"INT340E", "Motherboard Resources"}, + {"INT3420", "Intel Bluetooth RF Kill"}, + {"INT3F0D", "ACPI Motherboard Resources"}, + {"INTCF1A", "Sony IMX175 Camera Sensor"}, + {"INTCFD9", "Intel Baytrail SOC GPIO Controller"}, + {"INTL9C60", "Intel Baytrail SOC DMA Controller"}, + {"INVN6500", "InvenSense MPU-6500 Six Axis Gyroscope and Accelerometer"}, + {"LNXCPU", "Linux Logical CPU"}, + {"LNXPOWER", "ACPI Power Resource (power gating)"}, + {"LNXPWRBN", "System Power Button"}, + {"LNXSYBUS", "System Bus"}, + {"LNXSYSTM", "ACPI Root Node"}, + {"LNXTHERM", "ACPI Thermal Zone"}, + {"LNXVIDEO", "ACPI Video Controller"}, + {"MSFT0101", "TPM 2.0 Security Device"}, + {"NXP5442", "NXP 5442 Near Field Communications Controller"}, + {"PNP0000", "8259-compatible Programmable Interrupt Controller"}, + {"PNP0001", "EISA Interrupt Controller"}, + {"PNP0002", "MCA Interrupt Controller"}, + {"PNP0003", "IO-APIC Interrupt Controller"}, + {"PNP0100", "PC-class System Timer"}, + {"PNP0103", "HPET System Timer"}, + {"PNP0200", "PC-class DMA Controller"}, + {"PNP0300", "IBM PC/XT Keyboard Controller (83 key)"}, + {"PNP0301", "IBM PC/XT Keyboard Controller (86 key)"}, + {"PNP0302", "IBM PC/XT Keyboard Controller (84 key)"}, + {"PNP0303", "IBM Enhanced Keyboard (101/102-key, PS/2 Mouse)"}, + {"PNP0400", "Standard LPT Parallel Port"}, + {"PNP0401", "ECP Parallel Port"}, + {"PNP0500", "Standard PC COM Serial Port"}, + {"PNP0501", "16550A-compatible COM Serial Port"}, + {"PNP0510", "Generic IRDA-compatible Device"}, + {"PNP0800", "Microsoft Sound System Compatible Device"}, + {"PNP0A03", "PCI Bus"}, + {"PNP0A05", "Generic Container Device"}, + {"PNP0A06", "Generic Container Device"}, + {"PNP0A08", "PCI Express Bus"}, + {"PNP0B00", "AT Real-Time Clock"}, + {"PNP0B01", "Intel PIIX4-compatible RTC/CMOS Device"}, + {"PNP0B02", "Dallas Semiconductor-compatible RTC/CMOS Device"}, + {"PNP0C01", "System Board"}, + {"PNP0C02", "PNP Motherboard Resources"}, + {"PNP0C04", "x87-compatible Floating Point Processing Unit"}, + {"PNP0C08", "ACPI Core Hardware"}, + {"PNP0C09", "Embedded Controller Device"}, + {"PNP0C0A", "Control Method Battery"}, + {"PNP0C0B", "Fan (Thermal Solution)"}, + {"PNP0C0C", "Power Button Device"}, + {"PNP0C0D", "Lid Device"}, + {"PNP0C0E", "Sleep Button Device"}, + {"PNP0C0F", "PCI Interrupt Link Device"}, + {"PNP0C10", "System Indicator Device"}, + {"PNP0C11", "Thermal Zone"}, + {"PNP0C12", "Device Bay Controller"}, + {"PNP0C14", "Windows Management Instrumentation Device"}, + {"PNP0C15", "Docking Station"}, + {"PNP0C40", "Standard Button Controller"}, + {"PNP0C50", "HID Protocol Device (I2C bus)"}, + {"PNP0C60", "Display Sensor Device"}, + {"PNP0C70", "Dock Sensor Device"}, + {"PNP0C80", "Memory Device"}, + {"PNP0D40", "Standard Compliant SD Host Controller"}, + {"PNP0D80", "Windows-compatible System Power Management Controller"}, + {"PNP0F03", "Microsoft PS/2-style Mouse"}, + {"SMO91D0", "Sensor Hub"}, + + {NULL, NULL} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiAhMatchHardwareId + * + * PARAMETERS: HardwareId - String representation of an _HID or _CID + * + * RETURN: ID info struct. NULL if HardwareId is not found + * + * DESCRIPTION: Lookup an _HID/_CID in the device ID table + * + ******************************************************************************/ + +const AH_DEVICE_ID * +AcpiAhMatchHardwareId ( + char *HardwareId) +{ + const AH_DEVICE_ID *Info; + + + for (Info = AslDeviceIds; Info->Name; Info++) + { + if (!ACPI_STRCMP (HardwareId, Info->Name)) + { + return (Info); + } + } + + return (NULL); +} diff --git a/source/common/ahpredef.c b/source/common/ahpredef.c index 6653032..b1d393f 100644 --- a/source/common/ahpredef.c +++ b/source/common/ahpredef.c @@ -44,6 +44,9 @@ #include "acpi.h" #include "accommon.h" +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("ahpredef") + /* * iASL only needs a partial table (short descriptions only). * AcpiHelp needs the full table. @@ -321,3 +324,34 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = AH_PREDEF ("_Wxx", "Wake Event", "Method executed as a result of a wake event"), AH_PREDEF (NULL, NULL, NULL) }; + + +/******************************************************************************* + * + * FUNCTION: AcpiAhMatchPredefinedName + * + * PARAMETERS: Nameseg - Predefined name string + * + * RETURN: ID info struct. NULL if Nameseg not found + * + * DESCRIPTION: Lookup a predefined name. + * + ******************************************************************************/ + +const AH_PREDEFINED_NAME * +AcpiAhMatchPredefinedName ( + char *Nameseg) +{ + const AH_PREDEFINED_NAME *Info; + + + for (Info = AslPredefinedInfo; Info->Name; Info++) + { + if (ACPI_COMPARE_NAME (Nameseg, Info->Name)) + { + return (Info); + } + } + + return (NULL); +} diff --git a/source/common/cmfsize.c b/source/common/cmfsize.c new file mode 100755 index 0000000..c8d5a56 --- /dev/null +++ b/source/common/cmfsize.c @@ -0,0 +1,111 @@ +/****************************************************************************** + * + * Module Name: cfsize - Common get file size function + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "acpi.h" +#include "accommon.h" +#include "acapps.h" +#include + +#define _COMPONENT ACPI_TOOLS + ACPI_MODULE_NAME ("cmfsize") + + +/******************************************************************************* + * + * FUNCTION: CmGetFileSize + * + * PARAMETERS: File - Open file descriptor + * + * RETURN: File Size. On error, -1 (ACPI_UINT32_MAX) + * + * DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open. + * Does not disturb the current file pointer. Uses perror for + * error messages. + * + ******************************************************************************/ + +UINT32 +CmGetFileSize ( + FILE *File) +{ + long FileSize; + long CurrentOffset; + + + /* Save the current file pointer, seek to EOF to obtain file size */ + + CurrentOffset = ftell (File); + if (CurrentOffset < 0) + { + goto OffsetError; + } + + if (fseek (File, 0, SEEK_END)) + { + goto SeekError; + } + + FileSize = ftell (File); + if (FileSize < 0) + { + goto OffsetError; + } + + /* Restore original file pointer */ + + if (fseek (File, CurrentOffset, SEEK_SET)) + { + goto SeekError; + } + + return ((UINT32) FileSize); + + +OffsetError: + perror ("Could not get file offset"); + return (ACPI_UINT32_MAX); + +SeekError: + perror ("Could not seek file"); + return (ACPI_UINT32_MAX); +} diff --git a/source/common/dmextern.c b/source/common/dmextern.c index ba0041c..728207c 100644 --- a/source/common/dmextern.c +++ b/source/common/dmextern.c @@ -67,7 +67,7 @@ */ static const char *AcpiGbl_DmTypeNames[] = { - /* 00 */ "", /* Type ANY */ + /* 00 */ ", UnknownObj", /* Type ANY */ /* 01 */ ", IntObj", /* 02 */ ", StrObj", /* 03 */ ", BuffObj", @@ -397,6 +397,7 @@ AcpiDmGetExternalsFromFile ( { fprintf (stderr, "Could not open external reference file \"%s\"\n", Gbl_ExternalRefFilename); + AslAbort (); return; } @@ -791,7 +792,8 @@ AcpiDmCreateNewExternal ( /* Duplicate method, check that the Value (ArgCount) is the same */ if ((NextExternal->Type == ACPI_TYPE_METHOD) && - (NextExternal->Value != Value)) + (NextExternal->Value != Value) && + (Value > 0)) { ACPI_ERROR ((AE_INFO, "External method arg count mismatch %s: Current %u, attempted %u", @@ -1065,9 +1067,8 @@ AcpiDmEmitExternals ( NextExternal->Path, AcpiDmGetObjectTypeName (NextExternal->Type)); - AcpiOsPrintf ( - ") // Warning: Unresolved Method, " - "guessing %u arguments (may be incorrect, see warning above)\n", + AcpiOsPrintf (") // Warning: Unresolved method, " + "guessing %u arguments\n", NextExternal->Value); NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED; @@ -1275,8 +1276,14 @@ AcpiDmUnresolvedWarning ( " * control method external declarations with the associated method\n" " * argument counts. Each line of the file must be of the form:\n" " * External (, MethodObj, )\n" + " * Invocation:\n" + " * iasl -fe refs.txt -d dsdt.aml\n" + " *\n" + " * The following methods were unresolved and many not compile properly\n" + " * because the disassembler had to guess at the number of arguments\n" + " * required for each:\n" " */\n", - AcpiGbl_NumExternalMethods); + AcpiGbl_NumExternalMethods); } else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods) { @@ -1294,6 +1301,12 @@ AcpiDmUnresolvedWarning ( " * control method external declarations with the associated method\n" " * argument counts. Each line of the file must be of the form:\n" " * External (, MethodObj, )\n" + " * Invocation:\n" + " * iasl -fe refs.txt -d dsdt.aml\n" + " *\n" + " * The following methods were unresolved and many not compile properly\n" + " * because the disassembler had to guess at the number of arguments\n" + " * required for each:\n" " */\n", AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods, (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"), @@ -1321,7 +1334,9 @@ AcpiDmUnresolvedWarning ( "In addition, the -fe option can be used to specify a file containing\n" "control method external declarations with the associated method\n" "argument counts. Each line of the file must be of the form:\n" - " External (, MethodObj, )\n", + " External (, MethodObj, )\n" + "Invocation:\n" + " iasl -fe refs.txt -d dsdt.aml\n", AcpiGbl_NumExternalMethods); } else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods) @@ -1339,7 +1354,9 @@ AcpiDmUnresolvedWarning ( "If necessary, the -fe option can be used to specify a file containing\n" "control method external declarations with the associated method\n" "argument counts. Each line of the file must be of the form:\n" - " External (, MethodObj, )\n", + " External (, MethodObj, )\n" + "Invocation:\n" + " iasl -fe refs.txt -d dsdt.aml\n", AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods, (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"), (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods)); diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 1b077c0..cc1a0eb 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -390,7 +390,7 @@ FlCheckForAcpiTable ( /* Header length field must match the file size */ - FileSize = DtGetFileSize (Handle); + FileSize = CmGetFileSize (Handle); if (Table.Length != FileSize) { return (AE_ERROR); diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index a60f608..1fcb97e 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -874,14 +874,14 @@ AslError ( * FUNCTION: AslCoreSubsystemError * * PARAMETERS: Op - Parse node where error happened - * Status - The ACPI CA Exception + * Status - The ACPICA Exception * ExtraMessage - additional error message * Abort - TRUE -> Abort compilation * * RETURN: None * - * DESCRIPTION: Error reporting routine for exceptions returned by the ACPI - * CA core subsystem. + * DESCRIPTION: Error reporting routine for exceptions returned by the ACPICA + * core subsystem. * ******************************************************************************/ diff --git a/source/compiler/aslfileio.c b/source/compiler/aslfileio.c index 90072f1..56d006b 100644 --- a/source/compiler/aslfileio.c +++ b/source/compiler/aslfileio.c @@ -42,14 +42,11 @@ */ #include "aslcompiler.h" +#include "acapps.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslfileio") -long -UtGetFileSize ( - FILE *fp); - /******************************************************************************* * @@ -115,65 +112,6 @@ FlOpenFile ( /******************************************************************************* * - * FUNCTION: UtGetFileSize - * - * PARAMETERS: fp - Open file handle - * - * RETURN: File Size. -1 on error. - * - * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. - * TBD: This function should be used to replace other similar - * functions in ACPICA. - * - ******************************************************************************/ - -long -UtGetFileSize ( - FILE *fp) -{ - long FileSize; - long CurrentOffset; - - - CurrentOffset = ftell (fp); - if (CurrentOffset < 0) - { - goto OffsetError; - } - - if (fseek (fp, 0, SEEK_END)) - { - goto SeekError; - } - - FileSize = ftell (fp); - if (FileSize < 0) - { - goto OffsetError; - } - - /* Restore file pointer */ - - if (fseek (fp, CurrentOffset, SEEK_SET)) - { - goto SeekError; - } - - return (FileSize); - - -OffsetError: - perror ("Could not get file offset"); - return (-1); - -SeekError: - perror ("Could not seek file"); - return (-1); -} - - -/******************************************************************************* - * * FUNCTION: FlGetFileSize * * PARAMETERS: FileId - Index into file info array @@ -189,16 +127,16 @@ UINT32 FlGetFileSize ( UINT32 FileId) { - long FileSize; + UINT32 FileSize; - FileSize = UtGetFileSize (Gbl_Files[FileId].Handle); - if (FileSize == -1) + FileSize = CmGetFileSize (Gbl_Files[FileId].Handle); + if (FileSize == ACPI_UINT32_MAX) { AslAbort(); } - return ((UINT32) FileSize); + return (FileSize); } diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 6f81d21..6e92d53 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -73,6 +73,36 @@ static void AslInitialize ( void); +UINT8 +AcpiIsBigEndianMachine ( + void); + + +/******************************************************************************* + * + * FUNCTION: AcpiIsBigEndianMachine + * + * PARAMETERS: None + * + * RETURN: TRUE if machine is big endian + * FALSE if machine is little endian + * + * DESCRIPTION: Detect whether machine is little endian or big endian. + * + ******************************************************************************/ + +UINT8 +AcpiIsBigEndianMachine ( + void) +{ + union { + UINT32 Integer; + UINT8 Bytes[4]; + } Overlay = {0xFF000000}; + + return (Overlay.Bytes[0]); /* Returns 0xFF (TRUE) for big endian */ +} + /******************************************************************************* * @@ -299,6 +329,18 @@ main ( int Index2; + /* + * Big-endian machines are not currently supported. ACPI tables must + * be little-endian, and support for big-endian machines needs to + * be implemented. + */ + if (AcpiIsBigEndianMachine ()) + { + fprintf (stderr, + "iASL is not currently supported on big-endian machines.\n"); + return (-1); + } + ACPI_DEBUG_INITIALIZE (); /* For debug version only */ /* Initialize preprocessor and compiler before command line processing */ diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index a97766c..1818383 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -296,7 +296,7 @@ char *AslMessages [] = /* ASL_MSG_CONNECTION_INVALID */ "Invalid OpRegion SpaceId for use of Connection operator", /* ASL_MSG_CONSTANT_EVALUATION */ "Could not evaluate constant expression", /* ASL_MSG_CONSTANT_FOLDED */ "Constant expression evaluated and reduced", -/* ASL_MSG_CORE_EXCEPTION */ "From ACPI CA Subsystem", +/* ASL_MSG_CORE_EXCEPTION */ "From ACPICA Subsystem", /* ASL_MSG_DEBUG_FILE_OPEN */ "Could not open debug file", /* ASL_MSG_DEBUG_FILENAME */ "Could not create debug filename", /* ASL_MSG_DEPENDENT_NESTING */ "Dependent function macros cannot be nested",\ diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 7d73d20..8d52826 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -269,6 +269,7 @@ AslDoOptions ( /* Get entire list of external files */ AcpiGbl_Optind--; + argv[AcpiGbl_Optind] = AcpiGbl_Optarg; while (argv[AcpiGbl_Optind] && (argv[AcpiGbl_Optind][0] != '-')) diff --git a/source/compiler/aslstubs.c b/source/compiler/aslstubs.c index dd278d8..589edb2 100644 --- a/source/compiler/aslstubs.c +++ b/source/compiler/aslstubs.c @@ -53,7 +53,7 @@ /* - * Stubs to simplify linkage to the ACPI CA core subsystem. + * Stubs to simplify linkage to the ACPICA core subsystem. * Things like Events, Global Lock, etc. are not used * by the compiler, so they are stubbed out here. */ diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 401d473..7dc0697 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -918,7 +918,7 @@ UtDoConstant ( } -/* TBD: use version in ACPI CA main code base? */ +/* TBD: use version in ACPICA main code base? */ /******************************************************************************* * diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index 94083b5..846e9c2 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -343,10 +343,6 @@ DtStrtoul64 ( char *String, UINT64 *ReturnInteger); -UINT32 -DtGetFileSize ( - FILE *Handle); - char* DtGetFieldValue ( DT_FIELD *Field); diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c index 5c57b5f..25d84ab 100644 --- a/source/compiler/dtio.c +++ b/source/compiler/dtio.c @@ -45,6 +45,7 @@ #include "aslcompiler.h" #include "dtcompiler.h" +#include "acapps.h" #define _COMPONENT DT_COMPILER ACPI_MODULE_NAME ("dtio") @@ -737,7 +738,11 @@ DtScanFile ( /* Get the file size */ - Gbl_InputByteCount = DtGetFileSize (Handle); + Gbl_InputByteCount = CmGetFileSize (Handle); + if (Gbl_InputByteCount == ACPI_UINT32_MAX) + { + AslAbort (); + } Gbl_CurrentLineNumber = 0; Gbl_CurrentLineOffset = 0; @@ -816,7 +821,12 @@ DtOutputBinary ( /* Walk the entire parse tree, emitting the binary data */ DtWalkTableTree (RootTable, DtWriteBinary, NULL, NULL); - Gbl_TableLength = DtGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + + Gbl_TableLength = CmGetFileSize (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + if (Gbl_TableLength == ACPI_UINT32_MAX) + { + AslAbort (); + } } diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c index 7d7e430..d394aff 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -286,36 +286,6 @@ DtStrtoul64 ( /****************************************************************************** * - * FUNCTION: DtGetFileSize - * - * PARAMETERS: Handle - Open file handler - * - * RETURN: Current file size - * - * DESCRIPTION: Get the current size of a file. Seek to the EOF and get the - * offset. Seek back to the original location. - * - *****************************************************************************/ - -UINT32 -DtGetFileSize ( - FILE *Handle) -{ - int CurrentOffset; - int LastOffset; - - - CurrentOffset = ftell (Handle); - fseek (Handle, 0, SEEK_END); - LastOffset = ftell (Handle); - fseek (Handle, CurrentOffset, SEEK_SET); - - return ((UINT32) LastOffset); -} - - -/****************************************************************************** - * * FUNCTION: DtGetFieldValue * * PARAMETERS: Field - Current field list pointer diff --git a/source/components/debugger/dbcmds.c b/source/components/debugger/dbcmds.c index 8fde330..e9774cd 100644 --- a/source/components/debugger/dbcmds.c +++ b/source/components/debugger/dbcmds.c @@ -116,7 +116,7 @@ AcpiDbConvertToNode ( Node = ACPI_TO_POINTER (Address); if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) { - AcpiOsPrintf ("Address %p is invalid in this address space\n", + AcpiOsPrintf ("Address %p is invalid", Node); return (NULL); } @@ -125,7 +125,7 @@ AcpiDbConvertToNode ( if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { - AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n", + AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n", Node, AcpiUtGetDescriptorName (Node)); return (NULL); } @@ -139,6 +139,8 @@ AcpiDbConvertToNode ( Node = AcpiDbLocalNsLookup (InString); if (!Node) { + AcpiOsPrintf ("Could not find [%s] in namespace, defaulting to root node\n", + InString); Node = AcpiGbl_RootNode; } } @@ -362,24 +364,19 @@ AcpiDbDisplayTableInfo ( switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) { - case ACPI_TABLE_ORIGIN_UNKNOWN: + case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: - AcpiOsPrintf ("Unknown "); + AcpiOsPrintf ("External virtual "); break; - case ACPI_TABLE_ORIGIN_MAPPED: + case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: - AcpiOsPrintf ("Mapped "); + AcpiOsPrintf ("Internal physical "); break; - case ACPI_TABLE_ORIGIN_ALLOCATED: + case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: - AcpiOsPrintf ("Allocated "); - break; - - case ACPI_TABLE_ORIGIN_OVERRIDE: - - AcpiOsPrintf ("Override "); + AcpiOsPrintf ("Internal virtual "); break; default: @@ -390,7 +387,7 @@ AcpiDbDisplayTableInfo ( /* Make sure that the table is mapped */ - Status = AcpiTbVerifyTable (TableDesc); + Status = AcpiTbValidateTable (TableDesc); if (ACPI_FAILURE (Status)) { return; @@ -440,8 +437,6 @@ AcpiDbUnloadAcpiTable ( Node = AcpiDbConvertToNode (ObjectName); if (!Node) { - AcpiOsPrintf ("Could not find [%s] in namespace\n", - ObjectName); return; } diff --git a/source/components/debugger/dbfileio.c b/source/components/debugger/dbfileio.c index 63ecfd8..a09c1de 100644 --- a/source/components/debugger/dbfileio.c +++ b/source/components/debugger/dbfileio.c @@ -142,6 +142,8 @@ AcpiDbOpenDebugFile ( #ifdef ACPI_APPLICATION +#include "acapps.h" + /******************************************************************************* * * FUNCTION: AcpiDbCheckTextModeCorruption @@ -246,9 +248,11 @@ AcpiDbReadTable ( /* Get the file size */ - fseek (fp, 0, SEEK_END); - FileSize = (UINT32) ftell (fp); - fseek (fp, 0, SEEK_SET); + FileSize = CmGetFileSize (fp); + if (FileSize == ACPI_UINT32_MAX) + { + return (AE_ERROR); + } if (FileSize < 4) { @@ -421,7 +425,7 @@ AeLocalLoadTable ( /* Install the new table into the local data structures */ - Status = AcpiTbInstallTable (&TableInfo); + Status = AcpiTbInitTableDescriptor (&TableInfo); if (ACPI_FAILURE (Status)) { if (Status == AE_ALREADY_EXISTS) @@ -475,23 +479,23 @@ AcpiDbReadTableFromFile ( FILE *File; UINT32 FileSize; UINT32 TableLength; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_ERROR; - /* Open the file */ + /* Open the file, get current size */ File = fopen (Filename, "rb"); if (!File) { perror ("Could not open input file"); - return (AE_ERROR); + return (Status); } - /* Get the file size */ - - fseek (File, 0, SEEK_END); - FileSize = (UINT32) ftell (File); - fseek (File, 0, SEEK_SET); + FileSize = CmGetFileSize (File); + if (FileSize == ACPI_UINT32_MAX) + { + goto Exit; + } /* Get the entire file */ @@ -499,15 +503,14 @@ AcpiDbReadTableFromFile ( Filename, FileSize, FileSize); Status = AcpiDbReadTable (File, Table, &TableLength); - fclose(File); - if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get table from the file\n"); - return (Status); } - return (AE_OK); +Exit: + fclose(File); + return (Status); } #endif @@ -567,6 +570,8 @@ AcpiDbGetTableFromFile ( return (Status); } + AcpiTbPrintTableHeader (0, Table); + fprintf (stderr, "Acpi table [%4.4s] successfully installed and loaded\n", Table->Signature); diff --git a/source/components/debugger/dbmethod.c b/source/components/debugger/dbmethod.c index 6e44eaf..90d1314 100644 --- a/source/components/debugger/dbmethod.c +++ b/source/components/debugger/dbmethod.c @@ -180,6 +180,11 @@ AcpiDbSetMethodData ( if (Type == 'N') { Node = AcpiDbConvertToNode (IndexArg); + if (!Node) + { + return; + } + if (Node->Type != ACPI_TYPE_INTEGER) { AcpiOsPrintf ("Can only set Integer nodes\n"); diff --git a/source/components/disassembler/dmbuffer.c b/source/components/disassembler/dmbuffer.c index ce69459..85f0618 100644 --- a/source/components/disassembler/dmbuffer.c +++ b/source/components/disassembler/dmbuffer.c @@ -47,6 +47,7 @@ #include "acdisasm.h" #include "acparser.h" #include "amlcode.h" +#include "acinterp.h" #ifdef ACPI_DISASSEMBLER @@ -61,7 +62,7 @@ AcpiDmUnicode ( ACPI_PARSE_OBJECT *Op); static void -AcpiDmIsEisaIdElement ( +AcpiDmGetHardwareIdType ( ACPI_PARSE_OBJECT *Op); static void @@ -537,19 +538,20 @@ AcpiDmUnicode ( /******************************************************************************* * - * FUNCTION: AcpiDmIsEisaIdElement + * FUNCTION: AcpiDmGetHardwareIdType * * PARAMETERS: Op - Op to be examined * * RETURN: None * - * DESCRIPTION: Determine if an Op (argument to _HID or _CID) can be converted - * to an EISA ID. + * DESCRIPTION: Determine the type of the argument to a _HID or _CID + * 1) Strings are allowed + * 2) If Integer, determine if it is a valid EISAID * ******************************************************************************/ static void -AcpiDmIsEisaIdElement ( +AcpiDmGetHardwareIdType ( ACPI_PARSE_OBJECT *Op) { UINT32 BigEndianId; @@ -557,55 +559,66 @@ AcpiDmIsEisaIdElement ( UINT32 i; - /* The parameter must be either a word or a dword */ - - if ((Op->Common.AmlOpcode != AML_DWORD_OP) && - (Op->Common.AmlOpcode != AML_WORD_OP)) + switch (Op->Common.AmlOpcode) { - return; - } + case AML_STRING_OP: - /* Swap from little-endian to big-endian to simplify conversion */ + /* Mark this string as an _HID/_CID string */ - BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer); + Op->Common.DisasmOpcode = ACPI_DASM_HID_STRING; + break; - /* Create the 3 leading ASCII letters */ + case AML_WORD_OP: + case AML_DWORD_OP: - Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40; - Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40; - Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40; + /* Determine if a Word/Dword is a valid encoded EISAID */ - /* Verify that all 3 are ascii and alpha */ + /* Swap from little-endian to big-endian to simplify conversion */ - for (i = 0; i < 3; i++) - { - if (!ACPI_IS_ASCII (Prefix[i]) || - !ACPI_IS_ALPHA (Prefix[i])) + BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer); + + /* Create the 3 leading ASCII letters */ + + Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40; + Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40; + Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40; + + /* Verify that all 3 are ascii and alpha */ + + for (i = 0; i < 3; i++) { - return; + if (!ACPI_IS_ASCII (Prefix[i]) || + !ACPI_IS_ALPHA (Prefix[i])) + { + return; + } } - } - /* OK - mark this node as convertable to an EISA ID */ + /* Mark this node as convertable to an EISA ID string */ - Op->Common.DisasmOpcode = ACPI_DASM_EISAID; + Op->Common.DisasmOpcode = ACPI_DASM_EISAID; + break; + + default: + break; + } } /******************************************************************************* * - * FUNCTION: AcpiDmIsEisaId + * FUNCTION: AcpiDmCheckForHardwareId * * PARAMETERS: Op - Op to be examined * * RETURN: None * - * DESCRIPTION: Determine if a Name() Op can be converted to an EisaId. + * DESCRIPTION: Determine if a Name() Op is a _HID/_CID. * ******************************************************************************/ void -AcpiDmIsEisaId ( +AcpiDmCheckForHardwareId ( ACPI_PARSE_OBJECT *Op) { UINT32 Name; @@ -630,7 +643,7 @@ AcpiDmIsEisaId ( if (ACPI_COMPARE_NAME (&Name, METHOD_NAME__HID)) { - AcpiDmIsEisaIdElement (NextOp); + AcpiDmGetHardwareIdType (NextOp); return; } @@ -645,11 +658,11 @@ AcpiDmIsEisaId ( if (NextOp->Common.AmlOpcode != AML_PACKAGE_OP) { - AcpiDmIsEisaIdElement (NextOp); + AcpiDmGetHardwareIdType (NextOp); return; } - /* _CID with Package: get the package length */ + /* _CID with Package: get the package length, check all elements */ NextOp = AcpiPsGetDepthNext (NULL, NextOp); @@ -658,7 +671,7 @@ AcpiDmIsEisaId ( NextOp = NextOp->Common.Next; while (NextOp) { - AcpiDmIsEisaIdElement (NextOp); + AcpiDmGetHardwareIdType (NextOp); NextOp = NextOp->Common.Next; } } @@ -666,41 +679,38 @@ AcpiDmIsEisaId ( /******************************************************************************* * - * FUNCTION: AcpiDmEisaId + * FUNCTION: AcpiDmDecompressEisaId * * PARAMETERS: EncodedId - Raw encoded EISA ID. * * RETURN: None * - * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String. + * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String + * and emit the correct ASL statement. If the ID is known, emit + * a description of the ID as a comment. * ******************************************************************************/ void -AcpiDmEisaId ( +AcpiDmDecompressEisaId ( UINT32 EncodedId) { - UINT32 BigEndianId; - + char IdBuffer[ACPI_EISAID_STRING_SIZE]; + const AH_DEVICE_ID *Info; - /* Swap from little-endian to big-endian to simplify conversion */ - BigEndianId = AcpiUtDwordByteSwap (EncodedId); + /* Convert EISAID to a string an emit the statement */ + AcpiExEisaIdToString (IdBuffer, EncodedId); + AcpiOsPrintf ("EisaId (\"%s\")", IdBuffer); - /* Split to form "AAANNNN" string */ + /* If we know about the ID, emit the description */ - AcpiOsPrintf ("EisaId (\"%c%c%c%4.4X\")", - - /* Three Alpha characters (AAA), 5 bits each */ - - (int) ((BigEndianId >> 26) & 0x1F) + 0x40, - (int) ((BigEndianId >> 21) & 0x1F) + 0x40, - (int) ((BigEndianId >> 16) & 0x1F) + 0x40, - - /* Numeric part (NNNN) is simply the lower 16 bits */ - - (UINT32) (BigEndianId & 0xFFFF)); + Info = AcpiAhMatchHardwareId (IdBuffer); + if (Info) + { + AcpiOsPrintf (" /* %s */", Info->Description); + } } #endif diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c index 10c66b2..30f985c 100644 --- a/source/components/disassembler/dmopcode.c +++ b/source/components/disassembler/dmopcode.c @@ -46,6 +46,8 @@ #include "acparser.h" #include "amlcode.h" #include "acdisasm.h" +#include "acinterp.h" +#include "acnamesp.h" #ifdef ACPI_DISASSEMBLER @@ -61,6 +63,159 @@ AcpiDmMatchKeyword ( /******************************************************************************* * + * FUNCTION: AcpiDmDisplayTargetPathname + * + * PARAMETERS: Op - Parse object + * + * RETURN: None + * + * DESCRIPTION: For AML opcodes that have a target operand, display the full + * pathname for the target, in a comment field. Handles Return() + * statements also. + * + ******************************************************************************/ + +void +AcpiDmDisplayTargetPathname ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *PrevOp = NULL; + char *Pathname; + const ACPI_OPCODE_INFO *OpInfo; + + + if (Op->Common.AmlOpcode == AML_RETURN_OP) + { + PrevOp = Op->Asl.Value.Arg; + } + else + { + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (!(OpInfo->Flags & AML_HAS_TARGET)) + { + return; + } + + /* Target is the last Op in the arg list */ + + NextOp = Op->Asl.Value.Arg; + while (NextOp) + { + PrevOp = NextOp; + NextOp = PrevOp->Asl.Next; + } + } + + if (!PrevOp) + { + return; + } + + /* We must have a namepath AML opcode */ + + if (PrevOp->Asl.AmlOpcode != AML_INT_NAMEPATH_OP) + { + return; + } + + /* A null string is the "no target specified" case */ + + if (!PrevOp->Asl.Value.String) + { + return; + } + + /* No node means "unresolved external reference" */ + + if (!PrevOp->Asl.Node) + { + AcpiOsPrintf (" /* External reference */"); + return; + } + + /* Ignore if path is already from the root */ + + if (*PrevOp->Asl.Value.String == '\\') + { + return; + } + + /* Now: we can get the full pathname */ + + Pathname = AcpiNsGetExternalPathname (PrevOp->Asl.Node); + if (!Pathname) + { + return; + } + + AcpiOsPrintf (" /* %s */", Pathname); + ACPI_FREE (Pathname); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmNotifyDescription + * + * PARAMETERS: Op - Name() parse object + * + * RETURN: None + * + * DESCRIPTION: Emit a description comment for the value associated with a + * Notify() operator. + * + ******************************************************************************/ + +void +AcpiDmNotifyDescription ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *NextOp; + ACPI_NAMESPACE_NODE *Node; + UINT8 NotifyValue; + UINT8 Type = ACPI_TYPE_ANY; + + + /* The notify value is the second argument */ + + NextOp = Op->Asl.Value.Arg; + NextOp = NextOp->Asl.Next; + + switch (NextOp->Common.AmlOpcode) + { + case AML_ZERO_OP: + case AML_ONE_OP: + + NotifyValue = (UINT8) NextOp->Common.AmlOpcode; + break; + + case AML_BYTE_OP: + + NotifyValue = (UINT8) NextOp->Asl.Value.Integer; + break; + + default: + return; + } + + /* + * Attempt to get the namespace node so we can determine the object type. + * Some notify values are dependent on the object type (Device, Thermal, + * or Processor). + */ + Node = Op->Asl.Node; + if (Node) + { + Type = Node->Type; + } + + AcpiOsPrintf (" // %s", AcpiUtGetNotifyName (NotifyValue, Type)); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmPredefinedDescription * * PARAMETERS: Op - Name() parse object @@ -183,14 +338,11 @@ AcpiDmPredefinedDescription ( /* Match the name in the info table */ - for (Info = AslPredefinedInfo; Info->Name; Info++) + Info = AcpiAhMatchPredefinedName (NameString); + if (Info) { - if (ACPI_COMPARE_NAME (NameString, Info->Name)) - { - AcpiOsPrintf (" // %4.4s: %s", - NameString, ACPI_CAST_PTR (char, Info->Description)); - return; - } + AcpiOsPrintf (" // %4.4s: %s", + NameString, ACPI_CAST_PTR (char, Info->Description)); } #endif @@ -267,14 +419,11 @@ AcpiDmFieldPredefinedDescription ( /* Match the name in the info table */ - for (Info = AslPredefinedInfo; Info->Name; Info++) + Info = AcpiAhMatchPredefinedName (Tag); + if (Info) { - if (ACPI_COMPARE_NAME (Tag, Info->Name)) - { - AcpiOsPrintf (" // %4.4s: %s", Tag, - ACPI_CAST_PTR (char, Info->Description)); - return; - } + AcpiOsPrintf (" // %4.4s: %s", Tag, + ACPI_CAST_PTR (char, Info->Description)); } #endif @@ -527,6 +676,7 @@ AcpiDmDisassembleOneOp ( ACPI_PARSE_OBJECT *Child; ACPI_STATUS Status; UINT8 *Aml; + const AH_DEVICE_ID *IdInfo; if (!Op) @@ -605,7 +755,7 @@ AcpiDmDisassembleOneOp ( if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID) { - AcpiDmEisaId ((UINT32) Op->Common.Value.Integer); + AcpiDmDecompressEisaId ((UINT32) Op->Common.Value.Integer); } else { @@ -617,7 +767,7 @@ AcpiDmDisassembleOneOp ( if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID) { - AcpiDmEisaId ((UINT32) Op->Common.Value.Integer); + AcpiDmDecompressEisaId ((UINT32) Op->Common.Value.Integer); } else { @@ -634,6 +784,19 @@ AcpiDmDisassembleOneOp ( case AML_STRING_OP: AcpiUtPrintString (Op->Common.Value.String, ACPI_UINT16_MAX); + + /* For _HID/_CID strings, attempt to output a descriptive comment */ + + if (Op->Common.DisasmOpcode == ACPI_DASM_HID_STRING) + { + /* If we know about the ID, emit the description */ + + IdInfo = AcpiAhMatchHardwareId (Op->Common.Value.String); + if (IdInfo) + { + AcpiOsPrintf (" /* %s */", IdInfo->Description); + } + } break; case AML_BUFFER_OP: diff --git a/source/components/disassembler/dmwalk.c b/source/components/disassembler/dmwalk.c index 79242f5..3cf74b3 100644 --- a/source/components/disassembler/dmwalk.c +++ b/source/components/disassembler/dmwalk.c @@ -568,7 +568,7 @@ AcpiDmDescendingOp ( /* Check for _HID and related EISAID() */ - AcpiDmIsEisaId (Op); + AcpiDmCheckForHardwareId (Op); AcpiOsPrintf (", "); break; @@ -842,6 +842,15 @@ AcpiDmAscendingOp ( AcpiDmFieldPredefinedDescription (Op); } + /* Decode Notify() values */ + + if (Op->Common.AmlOpcode == AML_NOTIFY_OP) + { + AcpiDmNotifyDescription (Op); + } + + AcpiDmDisplayTargetPathname (Op); + /* Could be a nested operator, check if comma required */ if (!AcpiDmCommaIfListMember (Op)) diff --git a/source/components/dispatcher/dsmethod.c b/source/components/dispatcher/dsmethod.c index 5cefb4f..8d1845b 100644 --- a/source/components/dispatcher/dsmethod.c +++ b/source/components/dispatcher/dsmethod.c @@ -186,8 +186,15 @@ AcpiDsDetectNamedOpcodes ( * At this point, we know we have a Named object opcode. * Mark the method as serialized. Later code will create a mutex for * this method to enforce serialization. + * + * Note, ACPI_METHOD_IGNORE_SYNC_LEVEL flag means that we will ignore the + * Sync Level mechanism for this method, even though it is now serialized. + * Otherwise, there can be conflicts with existing ASL code that actually + * uses sync levels. */ - WalkState->MethodDesc->Method.InfoFlags |= ACPI_METHOD_SERIALIZED; + WalkState->MethodDesc->Method.SyncLevel = 0; + WalkState->MethodDesc->Method.InfoFlags |= + (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Method serialized [%4.4s] %p - [%s] (%4.4X)\n", @@ -377,11 +384,16 @@ AcpiDsBeginMethodExecution ( /* * The CurrentSyncLevel (per-thread) must be less than or equal to * the sync level of the method. This mechanism provides some - * deadlock prevention + * deadlock prevention. + * + * If the method was auto-serialized, we just ignore the sync level + * mechanism, because auto-serialization of methods can interfere + * with ASL code that actually uses sync levels. * * Top-level method invocation has no walk state at this point */ if (WalkState && + (!(ObjDesc->Method.InfoFlags & ACPI_METHOD_IGNORE_SYNC_LEVEL)) && (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel)) { ACPI_ERROR ((AE_INFO, @@ -849,7 +861,8 @@ AcpiDsTerminateControlMethod ( * thread exits here. */ MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_SERIALIZED_PENDING; - MethodDesc->Method.InfoFlags |= ACPI_METHOD_SERIALIZED; + MethodDesc->Method.InfoFlags |= + (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL); MethodDesc->Method.SyncLevel = 0; } diff --git a/source/components/events/evmisc.c b/source/components/events/evmisc.c index 3bfa81c..72f6718 100644 --- a/source/components/events/evmisc.c +++ b/source/components/events/evmisc.c @@ -181,7 +181,7 @@ AcpiEvQueueNotifyRequest ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n", AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), - NotifyValue, AcpiUtGetNotifyName (NotifyValue), Node)); + NotifyValue, AcpiUtGetNotifyName (NotifyValue, ACPI_TYPE_ANY), Node)); Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, Info); diff --git a/source/components/events/evsci.c b/source/components/events/evsci.c index 07c86d8..664b408 100644 --- a/source/components/events/evsci.c +++ b/source/components/events/evsci.c @@ -135,7 +135,7 @@ AcpiEvSciXruptHandler ( /* - * We are guaranteed by the ACPI CA initialization/shutdown code that + * We are guaranteed by the ACPICA initialization/shutdown code that * if this interrupt handler is installed, ACPI is enabled. */ diff --git a/source/components/events/evxface.c b/source/components/events/evxface.c index 3755b09..51437a9 100644 --- a/source/components/events/evxface.c +++ b/source/components/events/evxface.c @@ -266,7 +266,7 @@ AcpiRemoveNotifyHandler ( ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *HandlerObj; ACPI_OPERAND_OBJECT *PreviousHandlerObj; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; UINT32 i; @@ -281,16 +281,6 @@ AcpiRemoveNotifyHandler ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Make sure all deferred notify tasks are completed */ - - AcpiOsWaitEventsComplete (); - - Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - /* Root Object. Global handlers are removed here */ if (Device == ACPI_ROOT_OBJECT) @@ -299,6 +289,12 @@ AcpiRemoveNotifyHandler ( { if (HandlerType & (i+1)) { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + if (!AcpiGbl_GlobalNotify[i].Handler || (AcpiGbl_GlobalNotify[i].Handler != Handler)) { @@ -311,18 +307,23 @@ AcpiRemoveNotifyHandler ( AcpiGbl_GlobalNotify[i].Handler = NULL; AcpiGbl_GlobalNotify[i].Context = NULL; + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Make sure all deferred notify tasks are completed */ + + AcpiOsWaitEventsComplete (); } } - goto UnlockAndExit; + return_ACPI_STATUS (AE_OK); } /* All other objects: Are Notifies allowed on this object? */ if (!AcpiEvIsNotifyObject (Node)) { - Status = AE_TYPE; - goto UnlockAndExit; + return_ACPI_STATUS (AE_TYPE); } /* Must have an existing internal object */ @@ -330,8 +331,7 @@ AcpiRemoveNotifyHandler ( ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { - Status = AE_NOT_EXIST; - goto UnlockAndExit; + return_ACPI_STATUS (AE_NOT_EXIST); } /* Internal object exists. Find the handler and remove it */ @@ -340,6 +340,12 @@ AcpiRemoveNotifyHandler ( { if (HandlerType & (i+1)) { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + HandlerObj = ObjDesc->CommonNotify.NotifyList[i]; PreviousHandlerObj = NULL; @@ -371,10 +377,17 @@ AcpiRemoveNotifyHandler ( HandlerObj->Notify.Next[i]; } + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Make sure all deferred notify tasks are completed */ + + AcpiOsWaitEventsComplete (); AcpiUtRemoveReference (HandlerObj); } } + return_ACPI_STATUS (Status); + UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -520,6 +533,8 @@ Exit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiInstallSciHandler) + /******************************************************************************* * @@ -596,6 +611,8 @@ UnlockAndExit: return_ACPI_STATUS (Status); } +ACPI_EXPORT_SYMBOL (AcpiRemoveSciHandler) + /******************************************************************************* * @@ -970,10 +987,6 @@ AcpiRemoveGpeHandler ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Make sure all deferred GPE tasks are completed */ - - AcpiOsWaitEventsComplete (); - Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { @@ -1030,10 +1043,17 @@ AcpiRemoveGpeHandler ( (void) AcpiEvAddGpeReference (GpeEventInfo); } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + + /* Make sure all deferred GPE tasks are completed */ + + AcpiOsWaitEventsComplete (); + /* Now we can free the handler object */ ACPI_FREE (Handler); - + return_ACPI_STATUS (Status); UnlockAndExit: AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); diff --git a/source/components/executer/exconfig.c b/source/components/executer/exconfig.c index 3ed056e..b5adb96 100644 --- a/source/components/executer/exconfig.c +++ b/source/components/executer/exconfig.c @@ -380,8 +380,8 @@ AcpiExLoadOp ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *TableHeader; ACPI_TABLE_HEADER *Table; - ACPI_TABLE_DESC TableDesc; UINT32 TableIndex; ACPI_STATUS Status; UINT32 Length; @@ -390,8 +390,6 @@ AcpiExLoadOp ( ACPI_FUNCTION_TRACE (ExLoadOp); - ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC)); - /* Source Object can be either an OpRegion or a Buffer/Field */ switch (ObjDesc->Common.Type) @@ -423,16 +421,16 @@ AcpiExLoadOp ( /* Get the table header first so we can get the table length */ - Table = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); - if (!Table) + TableHeader = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); + if (!TableHeader) { return_ACPI_STATUS (AE_NO_MEMORY); } Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER), - ACPI_CAST_PTR (UINT8, Table)); - Length = Table->Length; - ACPI_FREE (Table); + ACPI_CAST_PTR (UINT8, TableHeader)); + Length = TableHeader->Length; + ACPI_FREE (TableHeader); if (ACPI_FAILURE (Status)) { @@ -464,8 +462,8 @@ AcpiExLoadOp ( /* Allocate a buffer for the table */ - TableDesc.Pointer = ACPI_ALLOCATE (Length); - if (!TableDesc.Pointer) + Table = ACPI_ALLOCATE (Length); + if (!Table) { return_ACPI_STATUS (AE_NO_MEMORY); } @@ -473,14 +471,12 @@ AcpiExLoadOp ( /* Read the entire table */ Status = AcpiExRegionRead (ObjDesc, Length, - ACPI_CAST_PTR (UINT8, TableDesc.Pointer)); + ACPI_CAST_PTR (UINT8, Table)); if (ACPI_FAILURE (Status)) { - ACPI_FREE (TableDesc.Pointer); + ACPI_FREE (Table); return_ACPI_STATUS (Status); } - - TableDesc.Address = ObjDesc->Region.Address; break; case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */ @@ -497,8 +493,8 @@ AcpiExLoadOp ( /* Get the actual table length from the table header */ - Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); - Length = Table->Length; + TableHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); + Length = TableHeader->Length; /* Table cannot extend beyond the buffer */ @@ -515,14 +511,13 @@ AcpiExLoadOp ( * Copy the table from the buffer because the buffer could be modified * or even deleted in the future */ - TableDesc.Pointer = ACPI_ALLOCATE (Length); - if (!TableDesc.Pointer) + Table = ACPI_ALLOCATE (Length); + if (!Table) { return_ACPI_STATUS (AE_NO_MEMORY); } - ACPI_MEMCPY (TableDesc.Pointer, Table, Length); - TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer); + ACPI_MEMCPY (Table, TableHeader, Length); break; default: @@ -530,28 +525,31 @@ AcpiExLoadOp ( return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - /* Validate table checksum (will not get validated in TbAddTable) */ + /* Install the new table into the local data structures */ + + ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:")); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table), + ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, TRUE, + &TableIndex); - Status = AcpiTbVerifyChecksum (TableDesc.Pointer, Length); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) { - ACPI_FREE (TableDesc.Pointer); + /* Delete allocated table buffer */ + + ACPI_FREE (Table); return_ACPI_STATUS (Status); } - /* Complete the table descriptor */ - - TableDesc.Length = Length; - TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED; - - /* Install the new table into the local data structures */ - - Status = AcpiTbAddTable (&TableDesc, &TableIndex); + /* + * Note: Now table is "INSTALLED", it must be validated before + * loading. + */ + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); if (ACPI_FAILURE (Status)) { - /* Delete allocated table buffer */ - - AcpiTbDeleteTable (&TableDesc); return_ACPI_STATUS (Status); } @@ -583,9 +581,6 @@ 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); @@ -594,7 +589,7 @@ AcpiExLoadOp ( if (AcpiGbl_TableHandler) { - (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, TableDesc.Pointer, + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, AcpiGbl_TableHandlerContext); } @@ -628,6 +623,14 @@ AcpiExUnloadTable ( /* + * Temporarily emit a warning so that the ASL for the machine can be + * hopefully obtained. This is to say that the Unload() operator is + * extremely rare if not completely unused. + */ + ACPI_WARNING ((AE_INFO, + "Received request to unload an ACPI table")); + + /* * Validate the handle * Although the handle is partially validated in AcpiExReconfiguration() * when it calls AcpiExResolveOperands(), the handle is more completely diff --git a/source/components/executer/exdump.c b/source/components/executer/exdump.c index ac92f90..815e337 100644 --- a/source/components/executer/exdump.c +++ b/source/components/executer/exdump.c @@ -155,10 +155,11 @@ static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] = {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.AmlStart), "Aml Start"} }; -static ACPI_EXDUMP_INFO AcpiExDumpMutex[5] = +static ACPI_EXDUMP_INFO AcpiExDumpMutex[6] = { {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex), NULL}, {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.OriginalSyncLevel), "Original Sync Level"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"}, {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"}, {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"} diff --git a/source/components/tables/tbdata.c b/source/components/tables/tbdata.c new file mode 100755 index 0000000..549c555 --- /dev/null +++ b/source/components/tables/tbdata.c @@ -0,0 +1,816 @@ +/****************************************************************************** + * + * Module Name: tbdata - Table manager data structure functions + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2014, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#define __TBDATA_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbdata") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitTableDescriptor + * + * PARAMETERS: TableDesc - Table descriptor + * Address - Physical address of the table + * Flags - Allocation flags of the table + * Table - Pointer to the table + * + * RETURN: None + * + * DESCRIPTION: Initialize a new table descriptor + * + ******************************************************************************/ + +void +AcpiTbInitTableDescriptor ( + ACPI_TABLE_DESC *TableDesc, + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + ACPI_TABLE_HEADER *Table) +{ + + /* + * Initialize the table descriptor. Set the pointer to NULL, since the + * table is not fully mapped at this time. + */ + ACPI_MEMSET (TableDesc, 0, sizeof (ACPI_TABLE_DESC)); + TableDesc->Address = Address; + TableDesc->Length = Table->Length; + TableDesc->Flags = Flags; + ACPI_MOVE_32_TO_32 (TableDesc->Signature.Ascii, Table->Signature); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAcquireTable + * + * PARAMETERS: TableDesc - Table descriptor + * TablePtr - Where table is returned + * TableLength - Where table length is returned + * TableFlags - Where table allocation flags are returned + * + * RETURN: Status + * + * DESCRIPTION: Acquire an ACPI table. It can be used for tables not + * maintained in the AcpiGbl_RootTableList. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAcquireTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_TABLE_HEADER **TablePtr, + UINT32 *TableLength, + UINT8 *TableFlags) +{ + ACPI_TABLE_HEADER *Table = NULL; + + + switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) + { + case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: + + Table = AcpiOsMapMemory (TableDesc->Address, TableDesc->Length); + break; + + case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: + case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: + + Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, TableDesc->Address); + break; + + default: + + break; + } + + /* Table is not valid yet */ + + if (!Table) + { + return (AE_NO_MEMORY); + } + + /* Fill the return values */ + + *TablePtr = Table; + *TableLength = TableDesc->Length; + *TableFlags = TableDesc->Flags; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbReleaseTable + * + * PARAMETERS: Table - Pointer for the table + * TableLength - Length for the table + * TableFlags - Allocation flags for the table + * + * RETURN: None + * + * DESCRIPTION: Release a table. The inverse of AcpiTbAcquireTable(). + * + ******************************************************************************/ + +void +AcpiTbReleaseTable ( + ACPI_TABLE_HEADER *Table, + UINT32 TableLength, + UINT8 TableFlags) +{ + + switch (TableFlags & ACPI_TABLE_ORIGIN_MASK) + { + case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: + + AcpiOsUnmapMemory (Table, TableLength); + break; + + case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: + case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: + default: + + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAcquireTempTable + * + * PARAMETERS: TableDesc - Table descriptor to be acquired + * Address - Address of the table + * Flags - Allocation flags of the table + * + * RETURN: Status + * + * DESCRIPTION: This function validates the table header to obtain the length + * of a table and fills the table descriptor to make its state as + * "INSTALLED". Such a table descriptor is only used for verified + * installation. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAcquireTempTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags) +{ + ACPI_TABLE_HEADER *TableHeader; + + + switch (Flags & ACPI_TABLE_ORIGIN_MASK) + { + case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: + + /* Get the length of the full table from the header */ + + TableHeader = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!TableHeader) + { + return (AE_NO_MEMORY); + } + + AcpiTbInitTableDescriptor (TableDesc, Address, Flags, TableHeader); + AcpiOsUnmapMemory (TableHeader, sizeof (ACPI_TABLE_HEADER)); + return (AE_OK); + + case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: + case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: + + TableHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Address); + if (!TableHeader) + { + return (AE_NO_MEMORY); + } + + AcpiTbInitTableDescriptor (TableDesc, Address, Flags, TableHeader); + return (AE_OK); + + default: + + break; + } + + /* Table is not valid yet */ + + return (AE_NO_MEMORY); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbReleaseTempTable + * + * PARAMETERS: TableDesc - Table descriptor to be released + * + * RETURN: Status + * + * DESCRIPTION: The inverse of AcpiTbAcquireTempTable(). + * + *****************************************************************************/ + +void +AcpiTbReleaseTempTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + /* + * Note that the .Address is maintained by the callers of + * AcpiTbAcquireTempTable(), thus do not invoke AcpiTbUninstallTable() + * where .Address will be freed. + */ + AcpiTbInvalidateTable (TableDesc); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiTbValidateTable + * + * PARAMETERS: TableDesc - Table descriptor + * + * RETURN: Status + * + * DESCRIPTION: This function is called to validate the table, the returned + * table descriptor is in "VALIDATED" state. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbValidateTable ( + ACPI_TABLE_DESC *TableDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (TbValidateTable); + + + /* Validate the table if necessary */ + + if (!TableDesc->Pointer) + { + Status = AcpiTbAcquireTable (TableDesc, &TableDesc->Pointer, + &TableDesc->Length, &TableDesc->Flags); + if (!TableDesc->Pointer) + { + Status = AE_NO_MEMORY; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInvalidateTable + * + * PARAMETERS: TableDesc - Table descriptor + * + * RETURN: None + * + * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of + * AcpiTbValidateTable(). + * + ******************************************************************************/ + +void +AcpiTbInvalidateTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + ACPI_FUNCTION_TRACE (TbInvalidateTable); + + + /* Table must be validated */ + + if (!TableDesc->Pointer) + { + return_VOID; + } + + AcpiTbReleaseTable (TableDesc->Pointer, TableDesc->Length, + TableDesc->Flags); + TableDesc->Pointer = NULL; + + return_VOID; +} + + +/****************************************************************************** + * + * FUNCTION: AcpiTbVerifyTable + * + * PARAMETERS: TableDesc - Table descriptor + * Signature - Table signature to verify + * + * RETURN: Status + * + * DESCRIPTION: This function is called to validate and verify the table, the + * returned table descriptor is in "VALIDATED" state. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc, + char *Signature) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (TbVerifyTable); + + + /* Validate the table */ + + Status = AcpiTbValidateTable (TableDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* If a particular signature is expected (DSDT/FACS), it must match */ + + if (Signature && + !ACPI_COMPARE_NAME (&TableDesc->Signature, Signature)) + { + ACPI_BIOS_ERROR ((AE_INFO, + "Invalid signature 0x%X for ACPI table, expected [%s]", + TableDesc->Signature.Integer, Signature)); + Status = AE_BAD_SIGNATURE; + goto InvalidateAndExit; + } + + /* Verify the checksum */ + + Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, + "%4.4s " ACPI_PRINTF_UINT + " Attempted table install failed", + AcpiUtValidAcpiName (TableDesc->Signature.Ascii) ? + TableDesc->Signature.Ascii : "????", + ACPI_FORMAT_TO_UINT (TableDesc->Address))); + goto InvalidateAndExit; + } + + return_ACPI_STATUS (AE_OK); + +InvalidateAndExit: + AcpiTbInvalidateTable (TableDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbResizeRootTableList + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Expand the size of global table array + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbResizeRootTableList ( + void) +{ + ACPI_TABLE_DESC *Tables; + UINT32 TableCount; + + + ACPI_FUNCTION_TRACE (TbResizeRootTableList); + + + /* AllowResize flag is a parameter to AcpiInitializeTables */ + + if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) + { + ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); + return_ACPI_STATUS (AE_SUPPORT); + } + + /* Increase the Table Array size */ + + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + TableCount = AcpiGbl_RootTableList.MaxTableCount; + } + else + { + TableCount = AcpiGbl_RootTableList.CurrentTableCount; + } + + Tables = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC)); + if (!Tables) + { + ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy and free the previous table array */ + + if (AcpiGbl_RootTableList.Tables) + { + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, + (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC)); + + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + } + + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.MaxTableCount = + TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetNextRootIndex + * + * PARAMETERS: TableIndex - Where table index is returned + * + * RETURN: Status and table index. + * + * DESCRIPTION: Allocate a new ACPI table entry to the global table list + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetNextRootIndex ( + UINT32 *TableIndex) +{ + ACPI_STATUS Status; + + + /* Ensure that there is room for the table in the Root Table List */ + + if (AcpiGbl_RootTableList.CurrentTableCount >= + AcpiGbl_RootTableList.MaxTableCount) + { + Status = AcpiTbResizeRootTableList(); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + *TableIndex = AcpiGbl_RootTableList.CurrentTableCount; + AcpiGbl_RootTableList.CurrentTableCount++; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbTerminate + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all internal ACPI tables + * + ******************************************************************************/ + +void +AcpiTbTerminate ( + void) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (TbTerminate); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Delete the individual tables */ + + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) + { + AcpiTbUninstallTable (&AcpiGbl_RootTableList.Tables[i]); + } + + /* + * Delete the root table array if allocated locally. Array cannot be + * mapped, so we don't need to check for that flag. + */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + + AcpiGbl_RootTableList.Tables = NULL; + AcpiGbl_RootTableList.Flags = 0; + AcpiGbl_RootTableList.CurrentTableCount = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteNamespaceByOwner + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Delete all namespace objects created when this table was loaded. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbDeleteNamespaceByOwner ( + UINT32 TableIndex) +{ + ACPI_OWNER_ID OwnerId; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) + { + /* The table index does not exist */ + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Get the owner ID for this table, used to delete namespace nodes */ + + OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + + /* + * Need to acquire the namespace writer lock to prevent interference + * with any concurrent namespace walks. The interpreter must be + * released during the deletion since the acquisition of the deletion + * lock may block, and also since the execution of a namespace walk + * must be allowed to use the interpreter. + */ + (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); + + AcpiNsDeleteNamespaceByOwner (OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAllocateOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Allocates OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAllocateOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbAllocateOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + Status = AcpiUtAllocateOwnerId ( + &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbReleaseOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Releases OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbReleaseOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbReleaseOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + AcpiUtReleaseOwnerId ( + &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetOwnerId + * + * PARAMETERS: TableIndex - Table index + * OwnerId - Where the table OwnerId is returned + * + * RETURN: Status + * + * DESCRIPTION: returns OwnerId for the ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetOwnerId ( + UINT32 TableIndex, + ACPI_OWNER_ID *OwnerId) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbGetOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbIsTableLoaded + * + * PARAMETERS: TableIndex - Index into the root table + * + * RETURN: Table Loaded Flag + * + ******************************************************************************/ + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex) +{ + BOOLEAN IsLoaded = FALSE; + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + IsLoaded = (BOOLEAN) + (AcpiGbl_RootTableList.Tables[TableIndex].Flags & + ACPI_TABLE_IS_LOADED); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return (IsLoaded); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSetTableLoadedFlag + * + * PARAMETERS: TableIndex - Table index + * IsLoaded - TRUE if table is loaded, FALSE otherwise + * + * RETURN: None + * + * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. + * + ******************************************************************************/ + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded) +{ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + { + if (IsLoaded) + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags |= + ACPI_TABLE_IS_LOADED; + } + else + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags &= + ~ACPI_TABLE_IS_LOADED; + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); +} diff --git a/source/components/tables/tbfadt.c b/source/components/tables/tbfadt.c index 9010825..789161d 100644 --- a/source/components/tables/tbfadt.c +++ b/source/components/tables/tbfadt.c @@ -365,14 +365,14 @@ AcpiTbParseFadt ( /* Obtain the DSDT and FACS tables via their addresses within the FADT */ - AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, + AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); /* If Hardware Reduced flag is set, there is no FACS */ if (!AcpiGbl_ReducedHardware) { - AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, + AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); } } diff --git a/source/components/tables/tbfind.c b/source/components/tables/tbfind.c index 8940437..bbd8523 100644 --- a/source/components/tables/tbfind.c +++ b/source/components/tables/tbfind.c @@ -108,7 +108,7 @@ AcpiTbFindTable ( { /* Table is not currently mapped, map it */ - Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/source/components/tables/tbinstal.c b/source/components/tables/tbinstal.c index ce4a93d..9dcaa91 100644 --- a/source/components/tables/tbinstal.c +++ b/source/components/tables/tbinstal.c @@ -41,779 +41,528 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define __TBINSTAL_C__ #include "acpi.h" #include "accommon.h" -#include "acnamesp.h" #include "actables.h" - #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbinstal") +/* Local prototypes */ -/****************************************************************************** +static BOOLEAN +AcpiTbCompareTables ( + ACPI_TABLE_DESC *TableDesc, + UINT32 TableIndex); + + +/******************************************************************************* * - * FUNCTION: AcpiTbVerifyTable + * FUNCTION: AcpiTbCompareTables * - * PARAMETERS: TableDesc - table + * PARAMETERS: TableDesc - Table 1 descriptor to be compared + * TableIndex - Index of table 2 to be compared * - * RETURN: Status + * RETURN: TRUE if both tables are identical. * - * DESCRIPTION: this function is called to verify and map table + * DESCRIPTION: This function compares a table with another table that has + * already been installed in the root table list. * - *****************************************************************************/ + ******************************************************************************/ -ACPI_STATUS -AcpiTbVerifyTable ( - ACPI_TABLE_DESC *TableDesc) +static BOOLEAN +AcpiTbCompareTables ( + ACPI_TABLE_DESC *TableDesc, + UINT32 TableIndex) { ACPI_STATUS Status = AE_OK; + BOOLEAN IsIdentical; + ACPI_TABLE_HEADER *Table; + UINT32 TableLength; + UINT8 TableFlags; - ACPI_FUNCTION_TRACE (TbVerifyTable); - - - /* Map the table if necessary */ - - if (!TableDesc->Pointer) + Status = AcpiTbAcquireTable (&AcpiGbl_RootTableList.Tables[TableIndex], + &Table, &TableLength, &TableFlags); + if (ACPI_FAILURE (Status)) { - if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == - ACPI_TABLE_ORIGIN_MAPPED) - { - TableDesc->Pointer = AcpiOsMapMemory ( - TableDesc->Address, TableDesc->Length); - } - - if (!TableDesc->Pointer) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } + return (FALSE); } - /* Always calculate checksum, ignore bad checksum if requested */ + /* + * Check for a table match on the entire table length, + * not just the header. + */ + IsIdentical = (BOOLEAN)((TableDesc->Length != TableLength || + ACPI_MEMCMP (TableDesc->Pointer, Table, TableLength)) ? + FALSE : TRUE); - Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); + /* Release the acquired table */ - return_ACPI_STATUS (Status); + AcpiTbReleaseTable (Table, TableLength, TableFlags); + return (IsIdentical); } /******************************************************************************* * - * FUNCTION: AcpiTbAddTable + * FUNCTION: AcpiTbInstallTableWithOverride * - * PARAMETERS: TableDesc - Table descriptor - * TableIndex - Where the table index is returned + * PARAMETERS: TableIndex - Index into root table array + * NewTableDesc - New table descriptor to install + * Override - Whether override should be performed * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: This function is called to add an ACPI table. It is used to - * dynamically load tables via the Load and LoadTable AML - * operators. + * DESCRIPTION: Install an ACPI table into the global data structure. The + * table override mechanism is called to allow the host + * OS to replace any table before it is installed in the root + * table array. * ******************************************************************************/ -ACPI_STATUS -AcpiTbAddTable ( - ACPI_TABLE_DESC *TableDesc, - UINT32 *TableIndex) +void +AcpiTbInstallTableWithOverride ( + UINT32 TableIndex, + ACPI_TABLE_DESC *NewTableDesc, + BOOLEAN Override) { - UINT32 i; - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE (TbAddTable); - - if (!TableDesc->Pointer) + if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) { - Status = AcpiTbVerifyTable (TableDesc); - if (ACPI_FAILURE (Status) || !TableDesc->Pointer) - { - return_ACPI_STATUS (Status); - } + return; } /* - * Validate the incoming table signature. + * ACPI Table Override: * - * 1) Originally, we checked the table signature for "SSDT" or "PSDT". - * 2) We added support for OEMx tables, signature "OEM". - * 3) Valid tables were encountered with a null signature, so we just - * gave up on validating the signature, (05/2008). - * 4) We encountered non-AML tables such as the MADT, which caused - * interpreter errors and kernel faults. So now, we once again allow - * only "SSDT", "OEMx", and now, also a null signature. (05/2011). + * Before we install the table, let the host OS override it with a new + * one if desired. Any table within the RSDT/XSDT can be replaced, + * including the DSDT which is pointed to by the FADT. */ - if ((TableDesc->Pointer->Signature[0] != 0x00) && - (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) && - (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3))) + if (Override) { - ACPI_BIOS_ERROR ((AE_INFO, - "Table has invalid signature [%4.4s] (0x%8.8X), " - "must be SSDT or OEMx", - AcpiUtValidAcpiName (TableDesc->Pointer->Signature) ? - TableDesc->Pointer->Signature : "????", - *(UINT32 *) TableDesc->Pointer->Signature)); - - return_ACPI_STATUS (AE_BAD_SIGNATURE); + AcpiTbOverrideTable (NewTableDesc); } - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - - /* Check if table is already registered */ - - for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) - { - if (!AcpiGbl_RootTableList.Tables[i].Pointer) - { - Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); - if (ACPI_FAILURE (Status) || - !AcpiGbl_RootTableList.Tables[i].Pointer) - { - continue; - } - } - - /* - * Check for a table match on the entire table length, - * not just the header. - */ - if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length) - { - continue; - } - - if (ACPI_MEMCMP (TableDesc->Pointer, - AcpiGbl_RootTableList.Tables[i].Pointer, - AcpiGbl_RootTableList.Tables[i].Length)) - { - continue; - } - - /* - * Note: the current mechanism does not unregister a table if it is - * dynamically unloaded. The related namespace entries are deleted, - * but the table remains in the root table list. - * - * The assumption here is that the number of different tables that - * will be loaded is actually small, and there is minimal overhead - * in just keeping the table in case it is needed again. - * - * If this assumption changes in the future (perhaps on large - * machines with many table load/unload operations), tables will - * need to be unregistered when they are unloaded, and slots in the - * root table list should be reused when empty. - */ - - /* - * Table is already registered. - * We can delete the table that was passed as a parameter. - */ - AcpiTbDeleteTable (TableDesc); - *TableIndex = i; - - if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED) - { - /* Table is still loaded, this is an error */ - - Status = AE_ALREADY_EXISTS; - goto Release; - } - else - { - /* Table was unloaded, allow it to be reloaded */ - - TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer; - TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address; - Status = AE_OK; - goto PrintHeader; - } - } + AcpiTbInitTableDescriptor (&AcpiGbl_RootTableList.Tables[TableIndex], + NewTableDesc->Address, NewTableDesc->Flags, NewTableDesc->Pointer); - /* - * ACPI Table Override: - * Allow the host to override dynamically loaded tables. - * NOTE: the table is fully mapped at this point, and the mapping will - * be deleted by TbTableOverride if the table is actually overridden. - */ - (void) AcpiTbTableOverride (TableDesc->Pointer, TableDesc); + AcpiTbPrintTableHeader (NewTableDesc->Address, NewTableDesc->Pointer); - /* Add the table to the global root table list */ + /* Set the global integer width (based upon revision of the DSDT) */ - Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer, - TableDesc->Length, TableDesc->Flags, TableIndex); - if (ACPI_FAILURE (Status)) + if (TableIndex == ACPI_TABLE_INDEX_DSDT) { - goto Release; + AcpiUtSetIntegerWidth (NewTableDesc->Pointer->Revision); } - -PrintHeader: - AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); - -Release: - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiTbTableOverride + * FUNCTION: AcpiTbInstallFixedTable * - * PARAMETERS: TableHeader - Header for the original table - * TableDesc - Table descriptor initialized for the - * original table. May or may not be mapped. + * PARAMETERS: Address - Physical address of DSDT or FACS + * Signature - Table signature, NULL if no need to + * match + * TableIndex - Index into root table array * - * RETURN: Pointer to the entire new table. NULL if table not overridden. - * If overridden, installs the new table within the input table - * descriptor. + * RETURN: Status * - * DESCRIPTION: Attempt table override by calling the OSL override functions. - * Note: If the table is overridden, then the entire new table - * is mapped and returned by this function. + * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data + * structure. * ******************************************************************************/ -ACPI_TABLE_HEADER * -AcpiTbTableOverride ( - ACPI_TABLE_HEADER *TableHeader, - ACPI_TABLE_DESC *TableDesc) +ACPI_STATUS +AcpiTbInstallFixedTable ( + ACPI_PHYSICAL_ADDRESS Address, + char *Signature, + UINT32 TableIndex) { + ACPI_TABLE_DESC NewTableDesc; ACPI_STATUS Status; - ACPI_TABLE_HEADER *NewTable = NULL; - ACPI_PHYSICAL_ADDRESS NewAddress = 0; - UINT32 NewTableLength = 0; - UINT8 NewFlags; - char *OverrideType; - /* (1) Attempt logical override (returns a logical address) */ + ACPI_FUNCTION_TRACE (TbInstallFixedTable); - Status = AcpiOsTableOverride (TableHeader, &NewTable); - if (ACPI_SUCCESS (Status) && NewTable) + + if (!Address) { - NewAddress = ACPI_PTR_TO_PHYSADDR (NewTable); - NewTableLength = NewTable->Length; - NewFlags = ACPI_TABLE_ORIGIN_OVERRIDE; - OverrideType = "Logical"; - goto FinishOverride; + ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]", + Signature)); + return (AE_NO_MEMORY); } - /* (2) Attempt physical override (returns a physical address) */ + /* Fill a table descriptor for validation */ - Status = AcpiOsPhysicalTableOverride (TableHeader, - &NewAddress, &NewTableLength); - if (ACPI_SUCCESS (Status) && NewAddress && NewTableLength) + Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); + if (ACPI_FAILURE (Status)) { - /* Map the entire new table */ - - NewTable = AcpiOsMapMemory (NewAddress, NewTableLength); - if (!NewTable) - { - ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, - "%4.4s " ACPI_PRINTF_UINT - " Attempted physical table override failed", - TableHeader->Signature, - ACPI_FORMAT_TO_UINT (TableDesc->Address))); - return (NULL); - } - - OverrideType = "Physical"; - NewFlags = ACPI_TABLE_ORIGIN_MAPPED; - goto FinishOverride; + ACPI_ERROR ((AE_INFO, "Could not acquire table length at %p", + ACPI_CAST_PTR (void, Address))); + return_ACPI_STATUS (Status); } - return (NULL); /* There was no override */ - - -FinishOverride: - - ACPI_INFO ((AE_INFO, "%4.4s " ACPI_PRINTF_UINT - " %s table override, new table: " ACPI_PRINTF_UINT, - TableHeader->Signature, - ACPI_FORMAT_TO_UINT (TableDesc->Address), - OverrideType, ACPI_FORMAT_TO_UINT (NewTable))); + /* Validate and verify a table before installation */ - /* We can now unmap/delete the original table (if fully mapped) */ + Status = AcpiTbVerifyTable (&NewTableDesc, Signature); + if (ACPI_FAILURE (Status)) + { + goto ReleaseAndExit; + } - AcpiTbDeleteTable (TableDesc); + AcpiTbInstallTableWithOverride (TableIndex, &NewTableDesc, TRUE); - /* Setup descriptor for the new table */ +ReleaseAndExit: - TableDesc->Address = NewAddress; - TableDesc->Pointer = NewTable; - TableDesc->Length = NewTableLength; - TableDesc->Flags = NewFlags; + /* Release the temporary table descriptor */ - return (NewTable); + AcpiTbReleaseTempTable (&NewTableDesc); + return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiTbResizeRootTableList + * FUNCTION: AcpiTbInstallStandardTable * - * PARAMETERS: None + * PARAMETERS: Address - Address of the table (might be a virtual + * address depending on the TableFlags) + * Flags - Flags for the table + * Reload - Whether reload should be performed + * Override - Whether override should be performed + * TableIndex - Where the table index is returned * * RETURN: Status * - * DESCRIPTION: Expand the size of global table array + * DESCRIPTION: This function is called to install an ACPI table that is + * neither DSDT nor FACS (a "standard" table.) + * When this function is called by "Load" or "LoadTable" opcodes, + * or by AcpiLoadTable() API, the "Reload" parameter is set. + * After sucessfully returning from this function, table is + * "INSTALLED" but not "VALIDATED". * ******************************************************************************/ ACPI_STATUS -AcpiTbResizeRootTableList ( - void) +AcpiTbInstallStandardTable ( + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + BOOLEAN Reload, + BOOLEAN Override, + UINT32 *TableIndex) { - ACPI_TABLE_DESC *Tables; - UINT32 TableCount; + UINT32 i; + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_DESC NewTableDesc; - ACPI_FUNCTION_TRACE (TbResizeRootTableList); + ACPI_FUNCTION_TRACE (TbInstallStandardTable); - /* AllowResize flag is a parameter to AcpiInitializeTables */ + /* Acquire a temporary table descriptor for validation */ - if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) + Status = AcpiTbAcquireTempTable (&NewTableDesc, Address, Flags); + if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); - return_ACPI_STATUS (AE_SUPPORT); + ACPI_ERROR ((AE_INFO, "Could not acquire table length at %p", + ACPI_CAST_PTR (void, Address))); + return_ACPI_STATUS (Status); } - /* Increase the Table Array size */ - - if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) - { - TableCount = AcpiGbl_RootTableList.MaxTableCount; - } - else + /* + * Optionally do not load any SSDTs from the RSDT/XSDT. This can + * be useful for debugging ACPI problems on some machines. + */ + if (!Reload && + AcpiGbl_DisableSsdtTableInstall && + ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) { - TableCount = AcpiGbl_RootTableList.CurrentTableCount; + ACPI_INFO ((AE_INFO, "Ignoring installation of %4.4s at %p", + NewTableDesc.Signature.Ascii, ACPI_CAST_PTR (void, Address))); + goto ReleaseAndExit; } - Tables = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) * - sizeof (ACPI_TABLE_DESC)); - if (!Tables) + /* Validate and verify a table before installation */ + + Status = AcpiTbVerifyTable (&NewTableDesc, NULL); + if (ACPI_FAILURE (Status)) { - ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); - return_ACPI_STATUS (AE_NO_MEMORY); + goto ReleaseAndExit; } - /* Copy and free the previous table array */ - - if (AcpiGbl_RootTableList.Tables) + if (Reload) { - ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, - (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC)); - - if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + /* + * Validate the incoming table signature. + * + * 1) Originally, we checked the table signature for "SSDT" or "PSDT". + * 2) We added support for OEMx tables, signature "OEM". + * 3) Valid tables were encountered with a null signature, so we just + * gave up on validating the signature, (05/2008). + * 4) We encountered non-AML tables such as the MADT, which caused + * interpreter errors and kernel faults. So now, we once again allow + * only "SSDT", "OEMx", and now, also a null signature. (05/2011). + */ + if ((NewTableDesc.Signature.Ascii[0] != 0x00) && + (!ACPI_COMPARE_NAME (&NewTableDesc.Signature, ACPI_SIG_SSDT)) && + (ACPI_STRNCMP (NewTableDesc.Signature.Ascii, "OEM", 3))) { - ACPI_FREE (AcpiGbl_RootTableList.Tables); + ACPI_BIOS_ERROR ((AE_INFO, + "Table has invalid signature [%4.4s] (0x%8.8X), " + "must be SSDT or OEMx", + AcpiUtValidAcpiName (NewTableDesc.Signature.Ascii) ? + NewTableDesc.Signature.Ascii : "????", + NewTableDesc.Signature.Integer)); + + Status = AE_BAD_SIGNATURE; + goto ReleaseAndExit; } - } - - AcpiGbl_RootTableList.Tables = Tables; - AcpiGbl_RootTableList.MaxTableCount = - TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; - AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED; - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbStoreTable - * - * PARAMETERS: Address - Table address - * Table - Table header - * Length - Table length - * Flags - flags - * - * RETURN: Status and table index. - * - * DESCRIPTION: Add an ACPI table to the global table list - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbStoreTable ( - ACPI_PHYSICAL_ADDRESS Address, - ACPI_TABLE_HEADER *Table, - UINT32 Length, - UINT8 Flags, - UINT32 *TableIndex) -{ - ACPI_STATUS Status; - ACPI_TABLE_DESC *NewTable; + /* Check if table is already registered */ + for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) + { + /* + * Check for a table match on the entire table length, + * not just the header. + */ + if (!AcpiTbCompareTables (&NewTableDesc, i)) + { + continue; + } - /* Ensure that there is room for the table in the Root Table List */ + /* + * Note: the current mechanism does not unregister a table if it is + * dynamically unloaded. The related namespace entries are deleted, + * but the table remains in the root table list. + * + * The assumption here is that the number of different tables that + * will be loaded is actually small, and there is minimal overhead + * in just keeping the table in case it is needed again. + * + * If this assumption changes in the future (perhaps on large + * machines with many table load/unload operations), tables will + * need to be unregistered when they are unloaded, and slots in the + * root table list should be reused when empty. + */ + if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED) + { + /* Table is still loaded, this is an error */ - if (AcpiGbl_RootTableList.CurrentTableCount >= - AcpiGbl_RootTableList.MaxTableCount) - { - Status = AcpiTbResizeRootTableList(); - if (ACPI_FAILURE (Status)) - { - return (Status); + Status = AE_ALREADY_EXISTS; + goto ReleaseAndExit; + } + else + { + /* + * Table was unloaded, allow it to be reloaded. + * As we are going to return AE_OK to the caller, we should + * take the responsibility of freeing the input descriptor. + * Refill the input descriptor to ensure + * AcpiTbInstallTableWithOverride() can be called again to + * indicate the re-installation. + */ + AcpiTbUninstallTable (&NewTableDesc); + *TableIndex = i; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_OK); + } } } - NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount]; - - /* Initialize added table */ - - NewTable->Address = Address; - NewTable->Pointer = Table; - NewTable->Length = Length; - NewTable->OwnerId = 0; - NewTable->Flags = Flags; - - ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature); - - *TableIndex = AcpiGbl_RootTableList.CurrentTableCount; - AcpiGbl_RootTableList.CurrentTableCount++; - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbDeleteTable - * - * PARAMETERS: TableIndex - Table index - * - * RETURN: None - * - * DESCRIPTION: Delete one internal ACPI table - * - ******************************************************************************/ - -void -AcpiTbDeleteTable ( - ACPI_TABLE_DESC *TableDesc) -{ - - /* Table must be mapped or allocated */ + /* Add the table to the global root table list */ - if (!TableDesc->Pointer) + Status = AcpiTbGetNextRootIndex (&i); + if (ACPI_FAILURE (Status)) { - return; + goto ReleaseAndExit; } - switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) - { - case ACPI_TABLE_ORIGIN_MAPPED: - - AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length); - break; - - case ACPI_TABLE_ORIGIN_ALLOCATED: + *TableIndex = i; + AcpiTbInstallTableWithOverride (i, &NewTableDesc, Override); - ACPI_FREE (TableDesc->Pointer); - break; +ReleaseAndExit: - /* Not mapped or allocated, there is nothing we can do */ + /* Release the temporary table descriptor */ - default: - - return; - } - - TableDesc->Pointer = NULL; + AcpiTbReleaseTempTable (&NewTableDesc); + return_ACPI_STATUS (Status); } /******************************************************************************* * - * FUNCTION: AcpiTbTerminate + * FUNCTION: AcpiTbOverrideTable * - * PARAMETERS: None + * PARAMETERS: OldTableDesc - Validated table descriptor to be + * overridden * * RETURN: None * - * DESCRIPTION: Delete all internal ACPI tables + * DESCRIPTION: Attempt table override by calling the OSL override functions. + * Note: If the table is overridden, then the entire new table + * is acquired and returned by this function. + * Before/after invocation, the table descriptor is in a state + * that is "VALIDATED". * ******************************************************************************/ void -AcpiTbTerminate ( - void) +AcpiTbOverrideTable ( + ACPI_TABLE_DESC *OldTableDesc) { - UINT32 i; - - - ACPI_FUNCTION_TRACE (TbTerminate); - + ACPI_STATUS Status; + char *OverrideType; + ACPI_TABLE_DESC NewTableDesc; + ACPI_TABLE_HEADER *Table; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - /* Delete the individual tables */ + /* (1) Attempt logical override (returns a logical address) */ - for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) + Status = AcpiOsTableOverride (OldTableDesc->Pointer, &Table); + if (ACPI_SUCCESS (Status) && Table) { - AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); + AcpiTbAcquireTempTable (&NewTableDesc, ACPI_PTR_TO_PHYSADDR (Table), + ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL); + OverrideType = "Logical"; + goto FinishOverride; } - /* - * Delete the root table array if allocated locally. Array cannot be - * mapped, so we don't need to check for that flag. - */ - if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + /* (2) Attempt physical override (returns a physical address) */ + + Status = AcpiOsPhysicalTableOverride (OldTableDesc->Pointer, + &Address, &Length); + if (ACPI_SUCCESS (Status) && Address && Length) { - ACPI_FREE (AcpiGbl_RootTableList.Tables); + AcpiTbAcquireTempTable (&NewTableDesc, Address, + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); + OverrideType = "Physical"; + goto FinishOverride; } - AcpiGbl_RootTableList.Tables = NULL; - AcpiGbl_RootTableList.Flags = 0; - AcpiGbl_RootTableList.CurrentTableCount = 0; - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - - return_VOID; -} - + return; /* There was no override */ -/******************************************************************************* - * - * FUNCTION: AcpiTbDeleteNamespaceByOwner - * - * PARAMETERS: TableIndex - Table index - * - * RETURN: Status - * - * DESCRIPTION: Delete all namespace objects created when this table was loaded. - * - ******************************************************************************/ -ACPI_STATUS -AcpiTbDeleteNamespaceByOwner ( - UINT32 TableIndex) -{ - ACPI_OWNER_ID OwnerId; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); +FinishOverride: + /* Validate and verify a table before overriding */ - Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); + Status = AcpiTbVerifyTable (&NewTableDesc, NULL); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + return; } - if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) - { - /* The table index does not exist */ - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (AE_NOT_EXIST); - } + ACPI_INFO ((AE_INFO, "%4.4s " ACPI_PRINTF_UINT + " %s table override, new table: " ACPI_PRINTF_UINT, + OldTableDesc->Signature.Ascii, + ACPI_FORMAT_TO_UINT (OldTableDesc->Address), + OverrideType, ACPI_FORMAT_TO_UINT (NewTableDesc.Address))); - /* Get the owner ID for this table, used to delete namespace nodes */ + /* We can now uninstall the original table */ - OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + AcpiTbUninstallTable (OldTableDesc); /* - * Need to acquire the namespace writer lock to prevent interference - * with any concurrent namespace walks. The interpreter must be - * released during the deletion since the acquisition of the deletion - * lock may block, and also since the execution of a namespace walk - * must be allowed to use the interpreter. + * Replace the original table descriptor and keep its state as + * "VALIDATED". */ - (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); - Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); - - AcpiNsDeleteNamespaceByOwner (OwnerId); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + AcpiTbInitTableDescriptor (OldTableDesc, NewTableDesc.Address, + NewTableDesc.Flags, NewTableDesc.Pointer); + AcpiTbValidateTable (OldTableDesc); - AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); + /* Release the temporary table descriptor */ - Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); - return_ACPI_STATUS (Status); + AcpiTbReleaseTempTable (&NewTableDesc); } /******************************************************************************* * - * FUNCTION: AcpiTbAllocateOwnerId + * FUNCTION: AcpiTbStoreTable * - * PARAMETERS: TableIndex - Table index + * PARAMETERS: Address - Table address + * Table - Table header + * Length - Table length + * Flags - Install flags + * TableIndex - Where the table index is returned * - * RETURN: Status + * RETURN: Status and table index. * - * DESCRIPTION: Allocates OwnerId in TableDesc + * DESCRIPTION: Add an ACPI table to the global table list * ******************************************************************************/ ACPI_STATUS -AcpiTbAllocateOwnerId ( - UINT32 TableIndex) +AcpiTbStoreTable ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Table, + UINT32 Length, + UINT8 Flags, + UINT32 *TableIndex) { - ACPI_STATUS Status = AE_BAD_PARAMETER; - - - ACPI_FUNCTION_TRACE (TbAllocateOwnerId); + ACPI_STATUS Status; + ACPI_TABLE_DESC *TableDesc; - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + Status = AcpiTbGetNextRootIndex (TableIndex); + if (ACPI_FAILURE (Status)) { - Status = AcpiUtAllocateOwnerId - (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + return (Status); } - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbReleaseOwnerId - * - * PARAMETERS: TableIndex - Table index - * - * RETURN: Status - * - * DESCRIPTION: Releases OwnerId in TableDesc - * - ******************************************************************************/ - -ACPI_STATUS -AcpiTbReleaseOwnerId ( - UINT32 TableIndex) -{ - ACPI_STATUS Status = AE_BAD_PARAMETER; - - - ACPI_FUNCTION_TRACE (TbReleaseOwnerId); - - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) - { - AcpiUtReleaseOwnerId ( - &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); - Status = AE_OK; - } + /* Initialize added table */ - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); + TableDesc = &AcpiGbl_RootTableList.Tables[*TableIndex]; + AcpiTbInitTableDescriptor (TableDesc, Address, Flags, Table); + TableDesc->Pointer = Table; + return (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiTbGetOwnerId + * FUNCTION: AcpiTbUninstallTable * - * PARAMETERS: TableIndex - Table index - * OwnerId - Where the table OwnerId is returned + * PARAMETERS: TableDesc - Table descriptor * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: returns OwnerId for the ACPI table + * DESCRIPTION: Delete one internal ACPI table * ******************************************************************************/ -ACPI_STATUS -AcpiTbGetOwnerId ( - UINT32 TableIndex, - ACPI_OWNER_ID *OwnerId) +void +AcpiTbUninstallTable ( + ACPI_TABLE_DESC *TableDesc) { - ACPI_STATUS Status = AE_BAD_PARAMETER; + ACPI_FUNCTION_TRACE (TbUninstallTable); - ACPI_FUNCTION_TRACE (TbGetOwnerId); + /* Table must be installed */ - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + if (!TableDesc->Address) { - *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; - Status = AE_OK; + return_VOID; } - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbIsTableLoaded - * - * PARAMETERS: TableIndex - Table index - * - * RETURN: Table Loaded Flag - * - ******************************************************************************/ - -BOOLEAN -AcpiTbIsTableLoaded ( - UINT32 TableIndex) -{ - BOOLEAN IsLoaded = FALSE; - + AcpiTbInvalidateTable (TableDesc); - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) + if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) { - IsLoaded = (BOOLEAN) - (AcpiGbl_RootTableList.Tables[TableIndex].Flags & - ACPI_TABLE_IS_LOADED); + ACPI_FREE (ACPI_CAST_PTR (void, TableDesc->Address)); } - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); - return (IsLoaded); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiTbSetTableLoadedFlag - * - * PARAMETERS: TableIndex - Table index - * IsLoaded - TRUE if table is loaded, FALSE otherwise - * - * RETURN: None - * - * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. - * - ******************************************************************************/ - -void -AcpiTbSetTableLoadedFlag ( - UINT32 TableIndex, - BOOLEAN IsLoaded) -{ - - (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); - if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount) - { - if (IsLoaded) - { - AcpiGbl_RootTableList.Tables[TableIndex].Flags |= - ACPI_TABLE_IS_LOADED; - } - else - { - AcpiGbl_RootTableList.Tables[TableIndex].Flags &= - ~ACPI_TABLE_IS_LOADED; - } - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + TableDesc->Address = ACPI_PTR_TO_PHYSADDR (NULL); + return_VOID; } diff --git a/source/components/tables/tbutils.c b/source/components/tables/tbutils.c index a9c2d13..fc580f6 100644 --- a/source/components/tables/tbutils.c +++ b/source/components/tables/tbutils.c @@ -197,9 +197,12 @@ AcpiTbCopyDsdt ( } ACPI_MEMCPY (NewTable, TableDesc->Pointer, TableDesc->Length); - AcpiTbDeleteTable (TableDesc); - TableDesc->Pointer = NewTable; - TableDesc->Flags = ACPI_TABLE_ORIGIN_ALLOCATED; + AcpiTbUninstallTable (TableDesc); + + AcpiTbInitTableDescriptor ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT], + ACPI_PTR_TO_PHYSADDR (NewTable), ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, + NewTable); ACPI_INFO ((AE_INFO, "Forced DSDT copy: length 0x%05X copied locally, original unmapped", @@ -211,125 +214,6 @@ AcpiTbCopyDsdt ( /******************************************************************************* * - * FUNCTION: AcpiTbInstallTable - * - * PARAMETERS: Address - Physical address of DSDT or FACS - * Signature - Table signature, NULL if no need to - * match - * TableIndex - Index into root table array - * - * RETURN: None - * - * DESCRIPTION: Install an ACPI table into the global data structure. The - * table override mechanism is called to allow the host - * OS to replace any table before it is installed in the root - * table array. - * - ******************************************************************************/ - -void -AcpiTbInstallTable ( - ACPI_PHYSICAL_ADDRESS Address, - char *Signature, - UINT32 TableIndex) -{ - ACPI_TABLE_HEADER *Table; - ACPI_TABLE_HEADER *FinalTable; - ACPI_TABLE_DESC *TableDesc; - - - if (!Address) - { - ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]", - Signature)); - return; - } - - /* Map just the table header */ - - Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); - if (!Table) - { - ACPI_ERROR ((AE_INFO, "Could not map memory for table [%s] at %p", - Signature, ACPI_CAST_PTR (void, Address))); - return; - } - - /* If a particular signature is expected (DSDT/FACS), it must match */ - - if (Signature && - !ACPI_COMPARE_NAME (Table->Signature, Signature)) - { - ACPI_BIOS_ERROR ((AE_INFO, - "Invalid signature 0x%X for ACPI table, expected [%s]", - *ACPI_CAST_PTR (UINT32, Table->Signature), Signature)); - goto UnmapAndExit; - } - - /* - * Initialize the table entry. Set the pointer to NULL, since the - * table is not fully mapped at this time. - */ - TableDesc = &AcpiGbl_RootTableList.Tables[TableIndex]; - - TableDesc->Address = Address; - TableDesc->Pointer = NULL; - TableDesc->Length = Table->Length; - TableDesc->Flags = ACPI_TABLE_ORIGIN_MAPPED; - ACPI_MOVE_32_TO_32 (TableDesc->Signature.Ascii, Table->Signature); - - /* - * ACPI Table Override: - * - * Before we install the table, let the host OS override it with a new - * one if desired. Any table within the RSDT/XSDT can be replaced, - * including the DSDT which is pointed to by the FADT. - * - * NOTE: If the table is overridden, then FinalTable will contain a - * mapped pointer to the full new table. If the table is not overridden, - * or if there has been a physical override, then the table will be - * fully mapped later (in verify table). In any case, we must - * unmap the header that was mapped above. - */ - FinalTable = AcpiTbTableOverride (Table, TableDesc); - if (!FinalTable) - { - FinalTable = Table; /* There was no override */ - } - - AcpiTbPrintTableHeader (TableDesc->Address, FinalTable); - - /* Set the global integer width (based upon revision of the DSDT) */ - - if (TableIndex == ACPI_TABLE_INDEX_DSDT) - { - AcpiUtSetIntegerWidth (FinalTable->Revision); - } - - /* - * If we have a physical override during this early loading of the ACPI - * tables, unmap the table for now. It will be mapped again later when - * it is actually used. This supports very early loading of ACPI tables, - * before virtual memory is fully initialized and running within the - * host OS. Note: A logical override has the ACPI_TABLE_ORIGIN_OVERRIDE - * flag set and will not be deleted below. - */ - if (FinalTable != Table) - { - AcpiTbDeleteTable (TableDesc); - } - - -UnmapAndExit: - - /* Always unmap the table header that we mapped above */ - - AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); -} - - -/******************************************************************************* - * * FUNCTION: AcpiTbGetRootTableEntry * * PARAMETERS: TableEntry - Pointer to the RSDT/XSDT table entry @@ -506,6 +390,7 @@ AcpiTbParseRootTable ( UINT32 Length; UINT8 *TableEntry; ACPI_STATUS Status; + UINT32 TableIndex; ACPI_FUNCTION_TRACE (TbParseRootTable); @@ -625,28 +510,20 @@ AcpiTbParseRootTable ( for (i = 0; i < TableCount; i++) { - if (AcpiGbl_RootTableList.CurrentTableCount >= - AcpiGbl_RootTableList.MaxTableCount) - { - /* There is no more room in the root table array, attempt resize */ - - Status = AcpiTbResizeRootTableList (); - if (ACPI_FAILURE (Status)) - { - ACPI_WARNING ((AE_INFO, "Truncating %u table entries!", - (unsigned) (TableCount - - (AcpiGbl_RootTableList.CurrentTableCount - 2)))); - break; - } - } - /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ - AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount].Address = - AcpiTbGetRootTableEntry (TableEntry, TableEntrySize); + Status = AcpiTbInstallStandardTable ( + AcpiTbGetRootTableEntry (TableEntry, TableEntrySize), + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE, &TableIndex); + + if (ACPI_SUCCESS (Status) && + ACPI_COMPARE_NAME (&AcpiGbl_RootTableList.Tables[TableIndex].Signature, + ACPI_SIG_FADT)) + { + AcpiTbParseFadt (TableIndex); + } TableEntry += TableEntrySize; - AcpiGbl_RootTableList.CurrentTableCount++; } /* @@ -655,23 +532,5 @@ AcpiTbParseRootTable ( */ AcpiOsUnmapMemory (Table, Length); - /* - * Complete the initialization of the root table array by examining - * the header of each table - */ - for (i = 2; i < AcpiGbl_RootTableList.CurrentTableCount; i++) - { - AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, - NULL, i); - - /* Special case for FADT - validate it then get the DSDT and FACS */ - - if (ACPI_COMPARE_NAME ( - &AcpiGbl_RootTableList.Tables[i].Signature, ACPI_SIG_FADT)) - { - AcpiTbParseFadt (i); - } - } - return_ACPI_STATUS (AE_OK); } diff --git a/source/components/tables/tbxface.c b/source/components/tables/tbxface.c index dc6374b..26ee44b 100644 --- a/source/components/tables/tbxface.c +++ b/source/components/tables/tbxface.c @@ -262,7 +262,7 @@ AcpiGetTableHeader ( { if ((AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_ORIGIN_MASK) == - ACPI_TABLE_ORIGIN_MAPPED) + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) { Header = AcpiOsMapMemory ( AcpiGbl_RootTableList.Tables[i].Address, @@ -345,7 +345,7 @@ AcpiGetTable ( continue; } - Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]); if (ACPI_SUCCESS (Status)) { *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer; @@ -406,7 +406,7 @@ AcpiGetTableByIndex ( { /* Table is not mapped, map it */ - Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); if (ACPI_FAILURE (Status)) { (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); diff --git a/source/components/tables/tbxfload.c b/source/components/tables/tbxfload.c index f39c2c6..f28aa09 100644 --- a/source/components/tables/tbxfload.c +++ b/source/components/tables/tbxfload.c @@ -131,7 +131,7 @@ AcpiTbLoadNamespace ( !ACPI_COMPARE_NAME ( &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), ACPI_SIG_DSDT) || - ACPI_FAILURE (AcpiTbVerifyTable ( + ACPI_FAILURE (AcpiTbValidateTable ( &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) { Status = AE_NO_ACPI_TABLES; @@ -142,7 +142,7 @@ AcpiTbLoadNamespace ( * Save the DSDT pointer for simple access. This is the mapped memory * address. We must take care here because the address of the .Tables * array can change dynamically as tables are loaded at run-time. Note: - * .Pointer field is not validated until after call to AcpiTbVerifyTable. + * .Pointer field is not validated until after call to AcpiTbValidateTable. */ AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer; @@ -187,24 +187,12 @@ AcpiTbLoadNamespace ( ACPI_SIG_SSDT) && !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), ACPI_SIG_PSDT)) || - ACPI_FAILURE (AcpiTbVerifyTable ( + ACPI_FAILURE (AcpiTbValidateTable ( &AcpiGbl_RootTableList.Tables[i]))) { continue; } - /* - * Optionally do not load any SSDTs from the RSDT/XSDT. This can - * be useful for debugging ACPI problems on some machines. - */ - if (AcpiGbl_DisableSsdtTableLoad) - { - ACPI_INFO ((AE_INFO, "Ignoring %4.4s at %p", - AcpiGbl_RootTableList.Tables[i].Signature.Ascii, - ACPI_CAST_PTR (void, AcpiGbl_RootTableList.Tables[i].Address))); - continue; - } - /* Ignore errors while loading tables, get as many as possible */ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); @@ -222,6 +210,53 @@ UnlockAndExit: /******************************************************************************* * + * FUNCTION: AcpiInstallTable + * + * PARAMETERS: Address - Address of the ACPI table to be installed. + * Physical - Whether the address is a physical table + * address or not + * + * RETURN: Status + * + * DESCRIPTION: Dynamically install an ACPI table. + * Note: This function should only be invoked after + * AcpiInitializeTables() and before AcpiLoadTables(). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + BOOLEAN Physical) +{ + ACPI_STATUS Status; + UINT8 Flags; + UINT32 TableIndex; + + + ACPI_FUNCTION_TRACE (AcpiInstallTable); + + + if (Physical) + { + Flags = ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL; + } + else + { + Flags = ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL; + } + + Status = AcpiTbInstallStandardTable (Address, Flags, + FALSE, FALSE, &TableIndex); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL_INIT (AcpiInstallTable) + + +/******************************************************************************* + * * FUNCTION: AcpiLoadTable * * PARAMETERS: Table - Pointer to a buffer containing the ACPI @@ -242,7 +277,6 @@ AcpiLoadTable ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - ACPI_TABLE_DESC TableDesc; UINT32 TableIndex; @@ -256,14 +290,6 @@ AcpiLoadTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Init local table descriptor */ - - ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC)); - TableDesc.Address = ACPI_PTR_TO_PHYSADDR (Table); - TableDesc.Pointer = Table; - TableDesc.Length = Table->Length; - TableDesc.Flags = ACPI_TABLE_ORIGIN_UNKNOWN; - /* Must acquire the interpreter lock during this operation */ Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); @@ -275,7 +301,23 @@ AcpiLoadTable ( /* Install the table and load it into the namespace */ ACPI_INFO ((AE_INFO, "Host-directed Dynamic ACPI Table Load:")); - Status = AcpiTbAddTable (&TableDesc, &TableIndex); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table), + ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, TRUE, FALSE, + &TableIndex); + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* + * Note: Now table is "INSTALLED", it must be validated before + * using. + */ + Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[TableIndex]); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; diff --git a/source/components/utilities/utdecode.c b/source/components/utilities/utdecode.c index 6c97c0c..28617dd 100644 --- a/source/components/utilities/utdecode.c +++ b/source/components/utilities/utdecode.c @@ -527,7 +527,7 @@ AcpiUtGetMutexName ( /* Names for Notify() values, used for debug output */ -static const char *AcpiGbl_NotifyValueNames[ACPI_NOTIFY_MAX + 1] = +static const char *AcpiGbl_GenericNotify[ACPI_NOTIFY_MAX + 1] = { /* 00 */ "Bus Check", /* 01 */ "Device Check", @@ -539,32 +539,87 @@ static const char *AcpiGbl_NotifyValueNames[ACPI_NOTIFY_MAX + 1] = /* 07 */ "Power Fault", /* 08 */ "Capabilities Check", /* 09 */ "Device PLD Check", - /* 10 */ "Reserved", - /* 11 */ "System Locality Update", - /* 12 */ "Shutdown Request" + /* 0A */ "Reserved", + /* 0B */ "System Locality Update", + /* 0C */ "Shutdown Request" }; +static const char *AcpiGbl_DeviceNotify[4] = +{ + /* 80 */ "Status Change", + /* 81 */ "Information Change", + /* 82 */ "Device-Specific Change", + /* 83 */ "Device-Specific Change" +}; + +static const char *AcpiGbl_ProcessorNotify[4] = +{ + /* 80 */ "Performance Capability Change", + /* 81 */ "C-State Change", + /* 82 */ "Throttling Capability Change", + /* 83 */ "Device-Specific Change" +}; + +static const char *AcpiGbl_ThermalNotify[4] = +{ + /* 80 */ "Thermal Status Change", + /* 81 */ "Thermal Trip Point Change", + /* 82 */ "Thermal Device List Change", + /* 83 */ "Thermal Relationship Change" +}; + + const char * AcpiUtGetNotifyName ( - UINT32 NotifyValue) + UINT32 NotifyValue, + ACPI_OBJECT_TYPE Type) { + /* 00 - 0C are common to all object types */ + if (NotifyValue <= ACPI_NOTIFY_MAX) { - return (AcpiGbl_NotifyValueNames[NotifyValue]); + return (AcpiGbl_GenericNotify[NotifyValue]); } - else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) + + /* 0D - 7F are reserved */ + + if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) { return ("Reserved"); } - else if (NotifyValue <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) + + /* 80 - 83 are per-object-type */ + + if (NotifyValue <= 0x83) { - return ("Device Specific"); + switch (Type) + { + case ACPI_TYPE_ANY: + case ACPI_TYPE_DEVICE: + return (AcpiGbl_DeviceNotify [NotifyValue - 0x80]); + + case ACPI_TYPE_PROCESSOR: + return (AcpiGbl_ProcessorNotify [NotifyValue - 0x80]); + + case ACPI_TYPE_THERMAL: + return (AcpiGbl_ThermalNotify [NotifyValue - 0x80]); + + default: + return ("Target object type does not support notifies"); + } } - else + + /* 84 - BF are device-specific */ + + if (NotifyValue <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) { - return ("Hardware Specific"); + return ("Device-Specific"); } + + /* C0 and above are hardware-specific */ + + return ("Hardware-Specific"); } #endif diff --git a/source/components/utilities/utstring.c b/source/components/utilities/utstring.c index 8a1ee92..435f698 100644 --- a/source/components/utilities/utstring.c +++ b/source/components/utilities/utstring.c @@ -420,7 +420,7 @@ AcpiUtPrintString ( } AcpiOsPrintf ("\""); - for (i = 0; String[i] && (i < MaxLength); i++) + for (i = 0; (i < MaxLength) && String[i]; i++) { /* Escape sequences */ diff --git a/source/include/acapps.h b/source/include/acapps.h index ad676cb..fa8e386 100644 --- a/source/include/acapps.h +++ b/source/include/acapps.h @@ -45,8 +45,6 @@ #define _ACAPPS -#pragma pack(push) /* Set default struct packing */ - #ifdef _MSC_VER /* disable some level-4 warnings */ #pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ #endif @@ -116,6 +114,14 @@ extern int AcpiGbl_SubOptChar; extern char *AcpiGbl_Optarg; +/* + * cmfsize - Common get file size function + */ +UINT32 +CmGetFileSize ( + FILE *File); + + #ifndef ACPI_DUMP_APP /* * adisasm @@ -221,6 +227,4 @@ AdWriteTable ( char *OemTableId); #endif -#pragma pack(pop) /* Restore original struct packing */ - #endif /* _ACAPPS */ diff --git a/source/include/acbuffer.h b/source/include/acbuffer.h index 8e3cb3d..a36a980 100644 --- a/source/include/acbuffer.h +++ b/source/include/acbuffer.h @@ -44,9 +44,6 @@ #ifndef __ACBUFFER_H__ #define __ACBUFFER_H__ - -#pragma pack(push) /* Set default struct packing */ - /* * Contains buffer structures for these predefined names: * _FDE, _GRT, _GTM, _PLD, _SRT @@ -246,6 +243,4 @@ typedef struct acpi_pld_info #define ACPI_PLD_SET_HORIZ_OFFSET(dword,value) ACPI_SET_BITS (dword, 16, ACPI_16BIT_MASK, value) /* Offset 128+16=144, Len 16 */ -#pragma pack(pop) /* Restore original struct packing */ - #endif /* ACBUFFER_H */ diff --git a/source/include/acconfig.h b/source/include/acconfig.h index 3327d19..4cad6f4 100644 --- a/source/include/acconfig.h +++ b/source/include/acconfig.h @@ -45,8 +45,6 @@ #define _ACCONFIG_H -#pragma pack(push) /* Set default struct packing */ - /****************************************************************************** * * Configuration options @@ -236,6 +234,4 @@ #define ACPI_DEBUGGER_EXECUTE_PROMPT '%' -#pragma pack(pop) /* Restore original struct packing */ - #endif /* _ACCONFIG_H */ diff --git a/source/include/acdebug.h b/source/include/acdebug.h index 59f8830..f85ec01 100644 --- a/source/include/acdebug.h +++ b/source/include/acdebug.h @@ -45,8 +45,6 @@ #define __ACDEBUG_H__ -#pragma pack(push) /* Set default struct packing */ - #define ACPI_DEBUG_BUFFER_SIZE 0x4000 /* 16K buffer for return objects */ typedef struct acpi_db_command_info @@ -468,6 +466,4 @@ AcpiDbUint32ToHexString ( UINT32 Value, char *Buffer); -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACDEBUG_H__ */ diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h index 00a4699..ae1fdf8 100644 --- a/source/include/acdisasm.h +++ b/source/include/acdisasm.h @@ -47,8 +47,6 @@ #include "amlresrc.h" -#pragma pack(push) /* Set default struct packing */ - #define BLOCK_NONE 0 #define BLOCK_PAREN 1 #define BLOCK_BRACE 2 @@ -554,6 +552,14 @@ AcpiDmMethodFlags ( ACPI_PARSE_OBJECT *Op); void +AcpiDmDisplayTargetPathname ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmNotifyDescription ( + ACPI_PARSE_OBJECT *Op); + +void AcpiDmPredefinedDescription ( ACPI_PARSE_OBJECT *Op); @@ -633,11 +639,11 @@ AcpiDmByteList ( ACPI_PARSE_OBJECT *Op); void -AcpiDmIsEisaId ( +AcpiDmCheckForHardwareId ( ACPI_PARSE_OBJECT *Op); void -AcpiDmEisaId ( +AcpiDmDecompressEisaId ( UINT32 EncodedId); BOOLEAN @@ -931,6 +937,4 @@ AdDisassemblerHeader ( char *Filename); -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACDISASM_H__ */ diff --git a/source/include/acdispat.h b/source/include/acdispat.h index d20373d..5715ab3 100644 --- a/source/include/acdispat.h +++ b/source/include/acdispat.h @@ -46,8 +46,6 @@ #define _ACDISPAT_H_ -#pragma pack(push) /* Set default struct packing */ - #define NAMEOF_LOCAL_NTE "__L0" #define NAMEOF_ARG_NTE "__A0" @@ -464,6 +462,4 @@ AcpiDsResultPush ( ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState); -#pragma pack(pop) /* Restore original struct packing */ - #endif /* _ACDISPAT_H_ */ diff --git a/source/include/acevents.h b/source/include/acevents.h index da998fb..3db6035 100644 --- a/source/include/acevents.h +++ b/source/include/acevents.h @@ -45,8 +45,6 @@ #define __ACEVENTS_H__ -#pragma pack(push) /* Set default struct packing */ - /* * evevent */ @@ -358,6 +356,4 @@ void AcpiEvTerminate ( void)) -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACEVENTS_H__ */ diff --git a/source/include/acexcep.h b/source/include/acexcep.h index 40ea039..aab6941 100644 --- a/source/include/acexcep.h +++ b/source/include/acexcep.h @@ -45,8 +45,6 @@ #define __ACEXCEP_H__ -#pragma pack(push) /* Set default struct packing */ - /* This module contains all possible exception codes for ACPI_STATUS */ /* @@ -347,6 +345,4 @@ static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Ctrl[] = #endif /* EXCEPTION_TABLE */ -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACEXCEP_H__ */ diff --git a/source/include/acglobal.h b/source/include/acglobal.h index 701955e..f33b720 100644 --- a/source/include/acglobal.h +++ b/source/include/acglobal.h @@ -45,8 +45,6 @@ #define __ACGLOBAL_H__ -#pragma pack(push) /* Set default struct packing */ - /* * Ensure that the globals are actually defined and initialized only once. * @@ -107,8 +105,8 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_AutoSerializeMethods, TRUE); /* * Create the predefined _OSI method in the namespace? Default is TRUE - * because ACPI CA is fully compatible with other ACPI implementations. - * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. + * because ACPICA is fully compatible with other ACPI implementations. + * Changing this will revert ACPICA (and machine ASL) to pre-OSI behavior. */ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_CreateOsiMethod, TRUE); @@ -164,10 +162,10 @@ ACPI_INIT_GLOBAL (UINT8, AcpiGbl_TruncateIoAddresses, FALSE); ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisableAutoRepair, FALSE); /* - * Optionally do not load any SSDTs from the RSDT/XSDT during initialization. + * Optionally do not install any SSDTs from the RSDT/XSDT during initialization. * This can be useful for debugging ACPI problems on some machines. */ -ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisableSsdtTableLoad, FALSE); +ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisableSsdtTableInstall, FALSE); /* * We keep track of the latest version of Windows that has been requested by @@ -362,7 +360,7 @@ ACPI_GLOBAL (UINT32, AcpiGbl_MaxConcurrentNodeCount); ACPI_GLOBAL (ACPI_SIZE *, AcpiGbl_EntryStackPointer); ACPI_GLOBAL (ACPI_SIZE *, AcpiGbl_LowestStackPointer); ACPI_GLOBAL (UINT32, AcpiGbl_DeepestNesting); -ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NestingLevel, 0); +ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NestingLevel, 0); #endif @@ -519,8 +517,7 @@ ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_DebugFile, NULL); ****************************************************************************/ extern const AH_PREDEFINED_NAME AslPredefinedInfo[]; +extern const AH_DEVICE_ID AslDeviceIds[]; -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACGLOBAL_H__ */ diff --git a/source/include/achware.h b/source/include/achware.h index 81d1bbf..1b13318 100644 --- a/source/include/achware.h +++ b/source/include/achware.h @@ -45,8 +45,6 @@ #define __ACHWARE_H__ -#pragma pack(push) /* Set default struct packing */ - /* Values for the _SST predefined method */ #define ACPI_SST_INDICATOR_OFF 0 @@ -226,6 +224,4 @@ AcpiHwDerivePciId ( ACPI_HANDLE PciRegion); -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACHWARE_H__ */ diff --git a/source/include/acinterp.h b/source/include/acinterp.h index bcb306c..b778640 100644 --- a/source/include/acinterp.h +++ b/source/include/acinterp.h @@ -45,8 +45,6 @@ #define __ACINTERP_H__ -#pragma pack(push) /* Set default struct packing */ - #define ACPI_WALK_OPERANDS (&(WalkState->Operands [WalkState->NumOperands -1])) /* Macros for tables used for debug output */ @@ -721,6 +719,4 @@ AcpiExDataTableSpaceHandler ( void *HandlerContext, void *RegionContext); -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __INTERP_H__ */ diff --git a/source/include/aclocal.h b/source/include/aclocal.h index 3234066..50a4a8e 100644 --- a/source/include/aclocal.h +++ b/source/include/aclocal.h @@ -45,8 +45,6 @@ #define __ACLOCAL_H__ -#pragma pack(push) /* Set default struct packing */ - /* acpisrc:StructDefs -- for acpisrc conversion */ #define ACPI_SERIALIZED 0xFF @@ -883,7 +881,8 @@ typedef union acpi_parse_value #define ACPI_DASM_MATCHOP 0x06 /* Parent opcode is a Match() operator */ #define ACPI_DASM_LNOT_PREFIX 0x07 /* Start of a LNotEqual (etc.) pair of opcodes */ #define ACPI_DASM_LNOT_SUFFIX 0x08 /* End of a LNotEqual (etc.) pair of opcodes */ -#define ACPI_DASM_IGNORE 0x09 /* Not used at this time */ +#define ACPI_DASM_HID_STRING 0x09 /* String is a _HID or _CID */ +#define ACPI_DASM_IGNORE 0x0A /* Not used at this time */ /* * Generic operation (for example: If, While, Store) @@ -1351,6 +1350,11 @@ typedef struct ah_predefined_name } AH_PREDEFINED_NAME; -#pragma pack(pop) /* Restore original struct packing */ +typedef struct ah_device_id +{ + char *Name; + char *Description; + +} AH_DEVICE_ID; #endif /* __ACLOCAL_H__ */ diff --git a/source/include/acmacros.h b/source/include/acmacros.h index 1212d05..19a3e8e 100644 --- a/source/include/acmacros.h +++ b/source/include/acmacros.h @@ -45,8 +45,6 @@ #define __ACMACROS_H__ -#pragma pack(push) /* Set default struct packing */ - /* * Extract data using a pointer. Any more than a byte and we * get into potential aligment issues -- see the STORE macros below. @@ -435,6 +433,4 @@ #define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) -#pragma pack(pop) /* Restore original struct packing */ - #endif /* ACMACROS_H */ diff --git a/source/include/acnamesp.h b/source/include/acnamesp.h index a9c7d22..9fd3841 100644 --- a/source/include/acnamesp.h +++ b/source/include/acnamesp.h @@ -45,8 +45,6 @@ #define __ACNAMESP_H__ -#pragma pack(push) /* Set default struct packing */ - /* To search the entire name space, pass this as SearchBase */ #define ACPI_NS_ALL ((ACPI_HANDLE)0) @@ -537,6 +535,4 @@ void AcpiNsTerminate ( void); -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACNAMESP_H__ */ diff --git a/source/include/acobject.h b/source/include/acobject.h index 040f5b6..3670049 100644 --- a/source/include/acobject.h +++ b/source/include/acobject.h @@ -44,8 +44,6 @@ #ifndef _ACOBJECT_H #define _ACOBJECT_H -#pragma pack(push) /* Set default struct packing */ - /* acpisrc:StructDefs -- for acpisrc conversion */ @@ -234,7 +232,8 @@ typedef struct acpi_object_method #define ACPI_METHOD_INTERNAL_ONLY 0x02 /* Method is implemented internally (_OSI) */ #define ACPI_METHOD_SERIALIZED 0x04 /* Method is serialized */ #define ACPI_METHOD_SERIALIZED_PENDING 0x08 /* Method is to be marked serialized */ -#define ACPI_METHOD_MODIFIED_NAMESPACE 0x10 /* Method modified the namespace */ +#define ACPI_METHOD_IGNORE_SYNC_LEVEL 0x10 /* Method was auto-serialized at table load time */ +#define ACPI_METHOD_MODIFIED_NAMESPACE 0x20 /* Method modified the namespace */ /****************************************************************************** @@ -583,6 +582,6 @@ typedef union acpi_descriptor } ACPI_DESCRIPTOR; -#pragma pack(pop) /* Restore original struct packing */ +#pragma pack() #endif /* _ACOBJECT_H */ diff --git a/source/include/acoutput.h b/source/include/acoutput.h index ff42023..8f054ae 100644 --- a/source/include/acoutput.h +++ b/source/include/acoutput.h @@ -44,8 +44,6 @@ #ifndef __ACOUTPUT_H__ #define __ACOUTPUT_H__ -#pragma pack(push) /* Set default struct packing */ - /* * Debug levels and component IDs. These are used to control the * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a @@ -466,6 +464,4 @@ #endif /* ACPI_DEBUG_OUTPUT */ -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACOUTPUT_H__ */ diff --git a/source/include/acparser.h b/source/include/acparser.h index 74389d2..bddd3c1 100644 --- a/source/include/acparser.h +++ b/source/include/acparser.h @@ -46,8 +46,6 @@ #define __ACPARSER_H__ -#pragma pack(push) /* Set default struct packing */ - #define OP_HAS_RETURN_VALUE 1 /* Variable number of arguments. This field must be 32 bits */ @@ -355,6 +353,4 @@ AcpiPsShow ( ACPI_PARSE_OBJECT *op); -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACPARSER_H__ */ diff --git a/source/include/acpiosxf.h b/source/include/acpiosxf.h index a97921e..ebbcb6b 100644 --- a/source/include/acpiosxf.h +++ b/source/include/acpiosxf.h @@ -50,8 +50,6 @@ #include "actypes.h" -#pragma pack(push) /* Set default struct packing */ - /* Types for AcpiOsExecute */ typedef enum @@ -553,6 +551,4 @@ AcpiOsCloseDirectory ( #endif -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACPIOSXF_H__ */ diff --git a/source/include/acpixf.h b/source/include/acpixf.h index a88491f..0b01047 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -47,15 +47,13 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20140214 +#define ACPI_CA_VERSION 0x20140325 #include "acconfig.h" #include "actypes.h" #include "actbl.h" #include "acbuffer.h" -#pragma pack(push) /* Set default struct packing */ - /* * Globals that are publically available */ @@ -76,7 +74,7 @@ extern UINT8 AcpiGbl_AutoSerializeMethods; extern UINT8 AcpiGbl_CopyDsdtLocally; extern UINT8 AcpiGbl_CreateOsiMethod; extern UINT8 AcpiGbl_DisableAutoRepair; -extern UINT8 AcpiGbl_DisableSsdtTableLoad; +extern UINT8 AcpiGbl_DisableSsdtTableInstall; extern UINT8 AcpiGbl_DoNotUseXsdt; extern UINT8 AcpiGbl_EnableAmlDebugObject; extern UINT8 AcpiGbl_EnableInterpreterSlack; @@ -204,6 +202,11 @@ AcpiDecodePldBuffer ( * ACPI table load/unload interfaces */ ACPI_STATUS +AcpiInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + BOOLEAN Physical); + +ACPI_STATUS AcpiLoadTable ( ACPI_TABLE_HEADER *Table); @@ -833,6 +836,4 @@ AcpiDebugPrintRaw ( ...); #endif -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACXFACE_H__ */ diff --git a/source/include/acpredef.h b/source/include/acpredef.h index b8b7599..e5caaf6 100644 --- a/source/include/acpredef.h +++ b/source/include/acpredef.h @@ -45,8 +45,6 @@ #define __ACPREDEF_H__ -#pragma pack(push) /* Set default struct packing */ - /****************************************************************************** * * Return Package types @@ -1069,6 +1067,4 @@ static const ACPI_PREDEFINED_INFO AcpiGbl_ScopeNames[] = { extern const ACPI_PREDEFINED_INFO AcpiGbl_ResourceNames[]; #endif -#pragma pack(pop) /* Restore original struct packing */ - #endif diff --git a/source/include/acresrc.h b/source/include/acresrc.h index 5f658a6..f761d3f 100644 --- a/source/include/acresrc.h +++ b/source/include/acresrc.h @@ -49,8 +49,6 @@ #include "amlresrc.h" -#pragma pack(push) /* Set default struct packing */ - /* * If possible, pack the following structures to byte alignment, since we * don't care about performance for debug output. Two cases where we cannot @@ -439,6 +437,4 @@ extern ACPI_RSDUMP_INFO AcpiRsDumpUartSerialBus[]; extern ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[]; #endif -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACRESRC_H__ */ diff --git a/source/include/acrestyp.h b/source/include/acrestyp.h index eaea437..b0412aa 100644 --- a/source/include/acrestyp.h +++ b/source/include/acrestyp.h @@ -45,8 +45,6 @@ #define __ACRESTYP_H__ -#pragma pack(push) /* Set default struct packing */ - /* * Definitions for Resource Attributes */ @@ -699,6 +697,4 @@ typedef struct acpi_pci_routing_table } ACPI_PCI_ROUTING_TABLE; -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACRESTYP_H__ */ diff --git a/source/include/acstruct.h b/source/include/acstruct.h index c52db8f..5a0baf4 100644 --- a/source/include/acstruct.h +++ b/source/include/acstruct.h @@ -44,9 +44,6 @@ #ifndef __ACSTRUCT_H__ #define __ACSTRUCT_H__ - -#pragma pack(push) /* Set default struct packing */ - /* acpisrc:StructDefs -- for acpisrc conversion */ /***************************************************************************** @@ -273,6 +270,4 @@ typedef struct acpi_walk_info #define ACPI_DISPLAY_SHORT (UINT8) 2 -#pragma pack(pop) /* Restore original struct packing */ - #endif diff --git a/source/include/actables.h b/source/include/actables.h index 19f4e6d..672b6b4 100644 --- a/source/include/actables.h +++ b/source/include/actables.h @@ -45,8 +45,6 @@ #define __ACTABLES_H__ -#pragma pack(push) /* Set default struct packing */ - ACPI_STATUS AcpiAllocateRootTable ( UINT32 InitialTableCount); @@ -65,6 +63,40 @@ AcpiTbScanMemoryForRsdp ( /* + * tbdata - table data structure management + */ +ACPI_STATUS +AcpiTbGetNextRootIndex ( + UINT32 *TableIndex); + +void +AcpiTbInitTableDescriptor ( + ACPI_TABLE_DESC *TableDesc, + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AcpiTbAcquireTempTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags); + +void +AcpiTbReleaseTempTable ( + ACPI_TABLE_DESC *TableDesc); + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex); + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded); + + +/* * tbfadt - FADT parse/convert/validate */ void @@ -96,17 +128,41 @@ AcpiTbResizeRootTableList ( void); ACPI_STATUS -AcpiTbVerifyTable ( +AcpiTbValidateTable ( ACPI_TABLE_DESC *TableDesc); -ACPI_TABLE_HEADER * -AcpiTbTableOverride ( - ACPI_TABLE_HEADER *TableHeader, +void +AcpiTbInvalidateTable ( ACPI_TABLE_DESC *TableDesc); ACPI_STATUS -AcpiTbAddTable ( +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc, + char *Signature); + +void +AcpiTbOverrideTable ( + ACPI_TABLE_DESC *OldTableDesc); + +ACPI_STATUS +AcpiTbAcquireTable ( ACPI_TABLE_DESC *TableDesc, + ACPI_TABLE_HEADER **TablePtr, + UINT32 *TableLength, + UINT8 *TableFlags); + +void +AcpiTbReleaseTable ( + ACPI_TABLE_HEADER *Table, + UINT32 TableLength, + UINT8 TableFlags); + +ACPI_STATUS +AcpiTbInstallStandardTable ( + ACPI_PHYSICAL_ADDRESS Address, + UINT8 Flags, + BOOLEAN Reload, + BOOLEAN Override, UINT32 *TableIndex); ACPI_STATUS @@ -118,7 +174,7 @@ AcpiTbStoreTable ( UINT32 *TableIndex); void -AcpiTbDeleteTable ( +AcpiTbUninstallTable ( ACPI_TABLE_DESC *TableDesc); void @@ -142,15 +198,6 @@ AcpiTbGetOwnerId ( UINT32 TableIndex, ACPI_OWNER_ID *OwnerId); -BOOLEAN -AcpiTbIsTableLoaded ( - UINT32 TableIndex); - -void -AcpiTbSetTableLoadedFlag ( - UINT32 TableIndex, - BOOLEAN IsLoaded); - /* * tbutils - table manager utilities @@ -187,7 +234,13 @@ AcpiTbCopyDsdt ( UINT32 TableIndex); void -AcpiTbInstallTable ( +AcpiTbInstallTableWithOverride ( + UINT32 TableIndex, + ACPI_TABLE_DESC *NewTableDesc, + BOOLEAN Override); + +ACPI_STATUS +AcpiTbInstallFixedTable ( ACPI_PHYSICAL_ADDRESS Address, char *Signature, UINT32 TableIndex); @@ -196,6 +249,4 @@ ACPI_STATUS AcpiTbParseRootTable ( ACPI_PHYSICAL_ADDRESS RsdpAddress); -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACTABLES_H__ */ diff --git a/source/include/actbl.h b/source/include/actbl.h index 980529e..a419195 100644 --- a/source/include/actbl.h +++ b/source/include/actbl.h @@ -45,8 +45,6 @@ #define __ACTBL_H__ -#pragma pack(push) /* Set default struct packing */ - /******************************************************************************* * * Fundamental ACPI tables @@ -404,12 +402,11 @@ typedef struct acpi_table_desc /* Masks for Flags field above */ -#define ACPI_TABLE_ORIGIN_UNKNOWN (0) -#define ACPI_TABLE_ORIGIN_MAPPED (1) -#define ACPI_TABLE_ORIGIN_ALLOCATED (2) -#define ACPI_TABLE_ORIGIN_OVERRIDE (4) -#define ACPI_TABLE_ORIGIN_MASK (7) -#define ACPI_TABLE_IS_LOADED (8) +#define ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL (0) /* Virtual address, external maintained */ +#define ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL (1) /* Physical address, internally mapped */ +#define ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL (2) /* Virtual address, internallly allocated */ +#define ACPI_TABLE_ORIGIN_MASK (3) +#define ACPI_TABLE_IS_LOADED (8) /* @@ -442,6 +439,4 @@ typedef struct acpi_table_desc #define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) #define ACPI_FADT_V5_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACTBL_H__ */ diff --git a/source/include/actbl1.h b/source/include/actbl1.h index bd2df95..ace4da9 100644 --- a/source/include/actbl1.h +++ b/source/include/actbl1.h @@ -45,8 +45,6 @@ #define __ACTBL1_H__ -#pragma pack(push) /* Set default struct packing */ - /******************************************************************************* * * Additional ACPI Tables (1) @@ -1143,6 +1141,8 @@ typedef struct acpi_srat_x2apic_cpu_affinity #define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ -#pragma pack(pop) /* Restore original struct packing */ +/* Reset to default packing */ + +#pragma pack() #endif /* __ACTBL1_H__ */ diff --git a/source/include/actbl2.h b/source/include/actbl2.h index 514ecb0..ae46ad8 100644 --- a/source/include/actbl2.h +++ b/source/include/actbl2.h @@ -45,8 +45,6 @@ #define __ACTBL2_H__ -#pragma pack(push) /* Set default struct packing */ - /******************************************************************************* * * Additional ACPI Tables (2) @@ -1418,6 +1416,8 @@ typedef struct acpi_table_wdrt } ACPI_TABLE_WDRT; -#pragma pack(pop) /* Restore original struct packing */ +/* Reset to default packing */ + +#pragma pack() #endif /* __ACTBL2_H__ */ diff --git a/source/include/actbl3.h b/source/include/actbl3.h index 1afc341..ce69acd 100644 --- a/source/include/actbl3.h +++ b/source/include/actbl3.h @@ -45,8 +45,6 @@ #define __ACTBL3_H__ -#pragma pack(push) /* Set default struct packing */ - /******************************************************************************* * * Additional ACPI Tables (3) @@ -734,6 +732,8 @@ typedef struct acpi_tpm2_control } ACPI_TPM2_CONTROL; -#pragma pack(pop) /* Restore original struct packing */ +/* Reset to default packing */ + +#pragma pack() #endif /* __ACTBL3_H__ */ diff --git a/source/include/actypes.h b/source/include/actypes.h index 1fa6c69..4a6e492 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -44,8 +44,6 @@ #ifndef __ACTYPES_H__ #define __ACTYPES_H__ -#pragma pack(push) /* Set default struct packing */ - /* acpisrc:StructDefs -- for acpisrc conversion */ /* @@ -1317,6 +1315,4 @@ typedef struct acpi_memory_list #define ACPI_OSI_WIN_8 0x0C -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __ACTYPES_H__ */ diff --git a/source/include/acutils.h b/source/include/acutils.h index 355e575..5c87313 100644 --- a/source/include/acutils.h +++ b/source/include/acutils.h @@ -45,8 +45,6 @@ #define _ACUTILS_H -#pragma pack(push) /* Set default struct packing */ - extern const UINT8 AcpiGbl_ResourceAmlSizes[]; extern const UINT8 AcpiGbl_ResourceAmlSerialBusSizes[]; @@ -191,8 +189,8 @@ AcpiUtGetMutexName ( const char * AcpiUtGetNotifyName ( - UINT32 NotifyValue); - + UINT32 NotifyValue, + ACPI_OBJECT_TYPE Type); #endif char * @@ -1101,7 +1099,15 @@ AcpiUtMethodError ( const char *Path, ACPI_STATUS LookupStatus); +/* + * Utility functions for ACPI names and IDs + */ +const AH_PREDEFINED_NAME * +AcpiAhMatchPredefinedName ( + char *Nameseg); -#pragma pack(pop) /* Restore original struct packing */ +const AH_DEVICE_ID * +AcpiAhMatchHardwareId ( + char *Hid); #endif /* _ACUTILS_H */ diff --git a/source/include/amlcode.h b/source/include/amlcode.h index 0695185..bc8c0b0 100644 --- a/source/include/amlcode.h +++ b/source/include/amlcode.h @@ -46,9 +46,6 @@ #ifndef __AMLCODE_H__ #define __AMLCODE_H__ -#pragma pack(push) /* Set default struct packing */ - - /* primary opcodes */ #define AML_NULL_CHAR (UINT16) 0x00 @@ -512,6 +509,4 @@ typedef enum #define AML_METHOD_SYNC_LEVEL 0xF0 -#pragma pack(pop) /* Restore original struct packing */ - #endif /* __AMLCODE_H__ */ diff --git a/source/include/amlresrc.h b/source/include/amlresrc.h index 03b1317..23c4400 100644 --- a/source/include/amlresrc.h +++ b/source/include/amlresrc.h @@ -47,8 +47,6 @@ #define __AMLRESRC_H -#pragma pack(push) /* Set default struct packing */ - /* * Resource descriptor tags, as defined in the ACPI specification. * Used to symbolically reference fields within a descriptor. @@ -576,7 +574,4 @@ typedef union aml_resource } AML_RESOURCE; - -#pragma pack(pop) /* Restore original struct packing */ - #endif diff --git a/source/include/platform/acgcc.h b/source/include/platform/acgcc.h index 501bf2b..23db324 100644 --- a/source/include/platform/acgcc.h +++ b/source/include/platform/acgcc.h @@ -64,4 +64,15 @@ */ #define ACPI_UNUSED_VAR __attribute__ ((unused)) +/* + * Some versions of gcc implement strchr() with a buggy macro. So, + * undef it here. Prevents error messages of this form (usually from the + * file getopt.c): + * + * error: logical '&&' with non-zero constant will always evaluate as true + */ +#ifdef strchr +#undef strchr +#endif + #endif /* __ACGCC_H__ */ diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h index 097ba3e..994c941 100644 --- a/source/include/platform/aclinux.h +++ b/source/include/platform/aclinux.h @@ -84,12 +84,23 @@ #include #include +/* Define/disable kernel-specific declarators */ + +#ifndef __init +#define __init +#endif + +#ifndef __iomem +#define __iomem +#endif + /* Host-dependent types and defines for user-space ACPICA */ #define ACPI_FLUSH_CPU_CACHE() #define ACPI_CAST_PTHREAD_T(Pthread) ((ACPI_THREAD_ID) (Pthread)) -#if defined(__ia64__) || defined(__x86_64__) || defined(__aarch64__) +#if defined(__ia64__) || defined(__x86_64__) ||\ + defined(__aarch64__) || defined(__PPC64__) #define ACPI_MACHINE_WIDTH 64 #define COMPILER_DEPENDENT_INT64 long #define COMPILER_DEPENDENT_UINT64 unsigned long diff --git a/source/os_specific/service_layers/oslinuxtbl.c b/source/os_specific/service_layers/oslinuxtbl.c index 551f0b7..f6e94c0 100644 --- a/source/os_specific/service_layers/oslinuxtbl.c +++ b/source/os_specific/service_layers/oslinuxtbl.c @@ -55,9 +55,9 @@ /* List of information about obtained ACPI tables */ -typedef struct table_info +typedef struct osl_table_info { - struct table_info *Next; + struct osl_table_info *Next; UINT32 Instance; char Signature[ACPI_NAME_SIZE]; @@ -253,22 +253,22 @@ AcpiOsGetTableByAddress ( if (TableLength == 0) { Status = AE_BAD_HEADER; - goto ErrorExit; + goto Exit; } LocalTable = calloc (1, TableLength); if (!LocalTable) { Status = AE_NO_MEMORY; - goto ErrorExit; + goto Exit; } ACPI_MEMCPY (LocalTable, MappedTable, TableLength); -ErrorExit: +Exit: OslUnmapTable (MappedTable); *Table = LocalTable; - return (AE_OK); + return (Status); } @@ -1003,7 +1003,7 @@ OslGetBiosTable ( if (TableLength == 0) { Status = AE_BAD_HEADER; - goto ErrorExit; + goto Exit; } /* Copy table to local buffer and return it */ @@ -1012,16 +1012,16 @@ OslGetBiosTable ( if (!LocalTable) { Status = AE_NO_MEMORY; - goto ErrorExit; + goto Exit; } ACPI_MEMCPY (LocalTable, MappedTable, TableLength); *Address = TableAddress; *Table = LocalTable; -ErrorExit: +Exit: OslUnmapTable (MappedTable); - return (AE_OK); + return (Status); } @@ -1290,7 +1290,7 @@ OslReadTableFromFile ( { fprintf (stderr, "Could not read table header: %s\n", Filename); Status = AE_BAD_HEADER; - goto ErrorExit; + goto Exit; } /* If signature is specified, it must match the table */ @@ -1301,14 +1301,14 @@ OslReadTableFromFile ( fprintf (stderr, "Incorrect signature: Expecting %4.4s, found %4.4s\n", Signature, Header.Signature); Status = AE_BAD_SIGNATURE; - goto ErrorExit; + goto Exit; } TableLength = ApGetTableLength (&Header); if (TableLength == 0) { Status = AE_BAD_HEADER; - goto ErrorExit; + goto Exit; } /* Read the entire table into a local buffer */ @@ -1320,7 +1320,7 @@ OslReadTableFromFile ( "%4.4s: Could not allocate buffer for table of length %X\n", Header.Signature, TableLength); Status = AE_NO_MEMORY; - goto ErrorExit; + goto Exit; } fseek (TableFile, FileOffset, SEEK_SET); @@ -1333,7 +1333,7 @@ OslReadTableFromFile ( fprintf (stderr, "%4.4s: Could not read table content\n", Header.Signature); Status = AE_INVALID_TABLE_LENGTH; - goto ErrorExit; + goto Exit; } Total += Count; @@ -1343,7 +1343,7 @@ OslReadTableFromFile ( (void) ApIsValidChecksum (LocalTable); -ErrorExit: +Exit: fclose (TableFile); *Table = LocalTable; return (Status); diff --git a/source/os_specific/service_layers/osunixdir.c b/source/os_specific/service_layers/osunixdir.c index cd01559..835eee3 100644 --- a/source/os_specific/service_layers/osunixdir.c +++ b/source/os_specific/service_layers/osunixdir.c @@ -41,7 +41,7 @@ * POSSIBILITY OF SUCH DAMAGES. */ -#include +#include "acpi.h" #include #include diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c index 3610548..224f345 100644 --- a/source/os_specific/service_layers/osunixxf.c +++ b/source/os_specific/service_layers/osunixxf.c @@ -1345,7 +1345,7 @@ AcpiOsWritable ( * * FUNCTION: AcpiOsSignal * - * PARAMETERS: Function - ACPI CA signal function code + * PARAMETERS: Function - ACPI A signal function code * Info - Pointer to function-dependent structure * * RETURN: Status diff --git a/source/os_specific/service_layers/oswintbl.c b/source/os_specific/service_layers/oswintbl.c index daff7fe..0afde68 100644 --- a/source/os_specific/service_layers/oswintbl.c +++ b/source/os_specific/service_layers/oswintbl.c @@ -222,6 +222,7 @@ AcpiOsGetTableByName ( HKEY SubKey; ULONG i; ACPI_TABLE_HEADER *ReturnTable; + ACPI_STATUS Status = AE_OK; /* @@ -294,7 +295,8 @@ AcpiOsGetTableByName ( { fprintf (stderr, "Could not open %s entry: %s\n", Signature, WindowsFormatException (WinStatus)); - return (AE_ERROR); + Status = AE_ERROR; + goto Cleanup; } RegCloseKey (Handle); @@ -313,7 +315,8 @@ AcpiOsGetTableByName ( { fprintf (stderr, "Could not get %s registry entry: %s\n", Signature, WindowsFormatException (WinStatus)); - return (AE_ERROR); + Status = AE_ERROR; + goto Cleanup; } if (Type == REG_BINARY) @@ -326,11 +329,12 @@ AcpiOsGetTableByName ( WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, NULL, &DataSize); - if (WinStatus != ERROR_SUCCESS) + if (WinStatus = ERROR_SUCCESS) { fprintf (stderr, "Could not read the %s table size: %s\n", Signature, WindowsFormatException (WinStatus)); - return (AE_ERROR); + Status = AE_ERROR; + goto Cleanup; } /* Allocate a new buffer for the table */ @@ -338,6 +342,7 @@ AcpiOsGetTableByName ( ReturnTable = malloc (DataSize); if (!ReturnTable) { + Status = AE_NO_MEMORY; goto Cleanup; } @@ -345,20 +350,21 @@ AcpiOsGetTableByName ( WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, (UCHAR *) ReturnTable, &DataSize); - if (WinStatus != ERROR_SUCCESS) + if (WinStatus = ERROR_SUCCESS) { fprintf (stderr, "Could not read %s data: %s\n", Signature, WindowsFormatException (WinStatus)); free (ReturnTable); - return (AE_ERROR); + Status = AE_ERROR; + goto Cleanup; } -Cleanup: - RegCloseKey (Handle); - *Table = ReturnTable; *Address = 0; - return (AE_OK); + +Cleanup: + RegCloseKey (Handle); + return (Status); } diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c index ebb007e..667a9f9 100644 --- a/source/os_specific/service_layers/oswinxf.c +++ b/source/os_specific/service_layers/oswinxf.c @@ -1324,7 +1324,7 @@ AcpiOsWriteMemory ( * * FUNCTION: AcpiOsSignal * - * PARAMETERS: Function - ACPI CA signal function code + * PARAMETERS: Function - ACPICA signal function code * Info - Pointer to function-dependent structure * * RETURN: Status diff --git a/source/tools/acpibin/abcompare.c b/source/tools/acpibin/abcompare.c index 6bf5f96..d843400 100644 --- a/source/tools/acpibin/abcompare.c +++ b/source/tools/acpibin/abcompare.c @@ -42,10 +42,9 @@ */ #include "acpibin.h" +#include "acapps.h" -FILE *File1; -FILE *File2; ACPI_TABLE_HEADER Header1; ACPI_TABLE_HEADER Header2; @@ -69,10 +68,6 @@ AbGetFile ( char *Filename, UINT32 *FileSize); -static UINT32 -AbGetFileSize ( - FILE *File); - static void AbPrintHeaderInfo ( ACPI_TABLE_HEADER *Header); @@ -87,68 +82,6 @@ AeLocalGetRootPointer ( void); -/******************************************************************************* - * - * FUNCTION: UtHexCharToValue - * - * PARAMETERS: HexChar - Hex character in Ascii - * - * RETURN: The binary value of the hex character - * - * DESCRIPTION: Perform ascii-to-hex translation - * - ******************************************************************************/ - -static UINT8 -UtHexCharToValue ( - int HexChar, - UINT8 *OutBinary) -{ - - if (HexChar >= 0x30 && HexChar <= 0x39) - { - *OutBinary = (UINT8) (HexChar - 0x30); - return (1); - } - - else if (HexChar >= 0x41 && HexChar <= 0x46) - { - *OutBinary = (UINT8) (HexChar - 0x37); - return (1); - } - - else if (HexChar >= 0x61 && HexChar <= 0x66) - { - *OutBinary = (UINT8) (HexChar - 0x57); - return (1); - } - return (0); -} - -static UINT8 -AbHexByteToBinary ( - char *HexString, - char *OutBinary) -{ - UINT8 Local1; - UINT8 Local2; - - - if (!UtHexCharToValue (HexString[0], &Local1)) - { - return (0); - } - if (!UtHexCharToValue (HexString[1], &Local2)) - { - return (0); - } - - *OutBinary = (UINT8) ((Local1 << 4) | Local2); - return (2); - -} - - /****************************************************************************** * * FUNCTION: AbValidateHeader @@ -190,23 +123,24 @@ AcpiTbSumTable ( void *Buffer, UINT32 Length) { - const UINT8 *limit; - const UINT8 *rover; - UINT8 sum = 0; + const UINT8 *Limit; + const UINT8 *Rover; + UINT8 Sum = 0; if (Buffer && Length) { /* Buffer and Length are valid */ - limit = (UINT8 *) Buffer + Length; + Limit = (UINT8 *) Buffer + Length; - for (rover = Buffer; rover < limit; rover++) + for (Rover = Buffer; Rover < Limit; Rover++) { - sum = (UINT8) (sum + *rover); + Sum = (UINT8) (Sum + *Rover); } } - return (sum); + + return (Sum); } @@ -233,10 +167,10 @@ AbPrintHeaderInfo ( printf ("Length : %8.8X\n", Header->Length); printf ("Revision : %2.2X\n", Header->Revision); printf ("Checksum : %2.2X\n", Header->Checksum); - printf ("OEM ID : %6.6s\n", Header->OemId); - printf ("OEM Table ID : %8.8s\n", Header->OemTableId); + printf ("OEM ID : %.6s\n", Header->OemId); + printf ("OEM Table ID : %.8s\n", Header->OemTableId); printf ("OEM Revision : %8.8X\n", Header->OemRevision); - printf ("ASL Compiler ID : %4.4s\n", Header->AslCompilerId); + printf ("ASL Compiler ID : %.4s\n", Header->AslCompilerId); printf ("Compiler Revision : %8.8X\n", Header->AslCompilerRevision); printf ("\n"); } @@ -253,10 +187,10 @@ AbPrintHeadersInfo ( printf ("Length %8.8X : %8.8X\n", Header->Length, Header2->Length); printf ("Revision %8.2X : %2.2X\n", Header->Revision, Header2->Revision); printf ("Checksum %8.2X : %2.2X\n", Header->Checksum, Header2->Checksum); - printf ("OEM ID %8.6s : %6.6s\n", Header->OemId, Header2->OemId); - printf ("OEM Table ID %8.8s : %8.8s\n", Header->OemTableId, Header2->OemTableId); + printf ("OEM ID %8.6s : %.6s\n", Header->OemId, Header2->OemId); + printf ("OEM Table ID %8.8s : %.8s\n", Header->OemTableId, Header2->OemTableId); printf ("OEM Revision %8.8X : %8.8X\n", Header->OemRevision, Header2->OemRevision); - printf ("ASL Compiler ID %8.4s : %4.4s\n", Header->AslCompilerId, Header2->AslCompilerId); + printf ("ASL Compiler ID %8.4s : %.4s\n", Header->AslCompilerId, Header2->AslCompilerId); printf ("Compiler Revision %8.8X : %8.8X\n", Header->AslCompilerRevision, Header2->AslCompilerRevision); printf ("\n"); } @@ -272,22 +206,25 @@ AbPrintHeadersInfo ( void AbDisplayHeader ( - char *File1Path) + char *FilePath) { UINT32 Actual; + FILE *File; - File1 = fopen (File1Path, "rb"); - if (!File1) + File = fopen (FilePath, "rb"); + if (!File) { - printf ("Could not open file %s\n", File1Path); + printf ("Could not open file %s\n", FilePath); return; } - Actual = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1); + Actual = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File); + fclose (File); + if (Actual != sizeof (ACPI_TABLE_HEADER)) { - printf ("File %s does not contain an ACPI table header\n", File1Path); + printf ("File %s does not contain a valid ACPI table header\n", FilePath); return; } @@ -310,30 +247,31 @@ AbDisplayHeader ( void AbComputeChecksum ( - char *File1Path) + char *FilePath) { UINT32 Actual; ACPI_TABLE_HEADER *Table; UINT8 Checksum; + FILE *File; - File1 = fopen (File1Path, "rb"); - if (!File1) + File = fopen (FilePath, "rb"); + if (!File) { - printf ("Could not open file %s\n", File1Path); + printf ("Could not open file %s\n", FilePath); return; } - Actual = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1); + Actual = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File); if (Actual < sizeof (ACPI_TABLE_HEADER)) { - printf ("File %s does not contain an ACPI table header\n", File1Path); - return; + printf ("File %s does not contain a valid ACPI table header\n", FilePath); + goto Exit1; } if (!AbValidateHeader (&Header1)) { - return; + goto Exit1; } if (!Gbl_TerseMode) @@ -346,18 +284,18 @@ AbComputeChecksum ( Table = AcpiOsAllocate (Header1.Length); if (!Table) { - printf ("could not allocate\n"); - return; + printf ("Could not allocate buffer for table\n"); + goto Exit1; } /* Read the entire table, including header */ - fseek (File1, 0, SEEK_SET); - Actual = fread (Table, 1, Header1.Length, File1); + fseek (File, 0, SEEK_SET); + Actual = fread (Table, 1, Header1.Length, File); if (Actual != Header1.Length) { - printf ("could not read table, length %u\n", Header1.Length); - return; + printf ("Could not read table, length %u\n", Header1.Length); + goto Exit2; } /* Compute the checksum for the table */ @@ -369,32 +307,41 @@ AbComputeChecksum ( if (Header1.Checksum == Checksum) { - printf ("Checksum ok in AML file, not updating\n"); - return; + printf ("Checksum OK in AML file, not updating\n"); + goto Exit2; } /* Open the target file for writing, to update checksum */ - fclose (File1); - File1 = fopen (File1Path, "r+b"); - if (!File1) + fclose (File); + File = fopen (FilePath, "r+b"); + if (!File) { - printf ("Could not open file %s for writing\n", File1Path); - return; + printf ("Could not open file %s for writing\n", FilePath); + goto Exit2; } /* Set the checksum, write the new header */ Header1.Checksum = Checksum; - Actual = fwrite (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1); + Actual = fwrite (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File); if (Actual != sizeof (ACPI_TABLE_HEADER)) { printf ("Could not write updated table header\n"); - return; + goto Exit2; } printf ("Wrote new checksum\n"); + +Exit2: + AcpiOsFree (Table); + +Exit1: + if (File) + { + fclose (File); + } return; } @@ -419,6 +366,9 @@ AbCompareAmlFiles ( UINT8 Char2; UINT8 Mismatches = 0; BOOLEAN HeaderMismatch = FALSE; + FILE *File1; + FILE *File2; + int Status = -1; File1 = fopen (File1Path, "rb"); @@ -432,7 +382,7 @@ AbCompareAmlFiles ( if (!File2) { printf ("Could not open file %s\n", File2Path); - return (-1); + goto Exit1; } /* Read the ACPI header from each file */ @@ -441,20 +391,20 @@ AbCompareAmlFiles ( if (Actual1 != sizeof (ACPI_TABLE_HEADER)) { printf ("File %s does not contain an ACPI table header\n", File1Path); - return (-1); + goto Exit2; } Actual2 = fread (&Header2, 1, sizeof (ACPI_TABLE_HEADER), File2); if (Actual2 != sizeof (ACPI_TABLE_HEADER)) { printf ("File %s does not contain an ACPI table header\n", File2Path); - return (-1); + goto Exit2; } if ((!AbValidateHeader (&Header1)) || (!AbValidateHeader (&Header2))) { - return (-1); + goto Exit2; } /* Table signatures must match */ @@ -462,7 +412,7 @@ AbCompareAmlFiles ( if (*((UINT32 *) Header1.Signature) != *((UINT32 *) Header2.Signature)) { printf ("Table signatures do not match\n"); - return (-1); + goto Exit2; } if (!Gbl_TerseMode) @@ -494,7 +444,7 @@ AbCompareAmlFiles ( if (Mismatches > 100) { printf ("100 Mismatches: Too many mismatches\n"); - return (-1); + goto Exit2; } } @@ -526,43 +476,14 @@ AbCompareAmlFiles ( } printf ("%u Mismatches found\n", Mismatches); - return (0); -} - - -/****************************************************************************** - * - * FUNCTION: AbGetFileSize - * - * DESCRIPTION: Get the size of an open file - * - ******************************************************************************/ + Status = 0; -static UINT32 -AbGetFileSize ( - FILE *File) -{ - UINT32 FileSize; - long Offset; - - - Offset = ftell (File); +Exit2: + fclose (File2); - if (fseek (File, 0, SEEK_END)) - { - return (0); - } - - FileSize = (UINT32) ftell (File); - - /* Restore file pointer */ - - if (fseek (File, Offset, SEEK_SET)) - { - return (0); - } - - return (FileSize); +Exit1: + fclose (File1); + return (Status); } @@ -596,8 +517,8 @@ AbGetFile ( /* Need file size to allocate a buffer */ - Size = AbGetFileSize (File); - if (!Size) + Size = CmGetFileSize (File); + if (Size == ACPI_UINT32_MAX) { printf ("Could not get file size (seek) for %s\n", Filename); goto ErrorExit; @@ -647,6 +568,7 @@ AbDumpAmlFile ( char *FileBuffer; FILE *FileOutHandle; UINT32 FileSize = 0; + int Status = -1; /* Get the entire AML file, validate header */ @@ -664,12 +586,12 @@ AbDumpAmlFile ( if (!FileOutHandle) { printf ("Could not open file %s\n", File2Path); - return (-1); + goto Exit1; } if (!AbValidateHeader ((ACPI_TABLE_HEADER *) FileBuffer)) { - return (-1); + goto Exit2; } /* Convert binary AML to text, using common dump buffer routine */ @@ -684,133 +606,18 @@ AbDumpAmlFile ( /* Summary for the output file */ - FileSize = AbGetFileSize (FileOutHandle); + FileSize = CmGetFileSize (FileOutHandle); printf ("Output file: %s contains %u (0x%X) bytes\n\n", File2Path, FileSize, FileSize); - return (0); -} - + Status = 0; -/****************************************************************************** - * - * FUNCTION: AbExtractAmlFile - * - * DESCRIPTION: Extract a binary AML file from a text file (as produced by the - * DumpAmlFile procedure or the "acpidump" table utility. - * - ******************************************************************************/ - -int -AbExtractAmlFile ( - char *TableSig, - char *File1Path, - char *File2Path) -{ - char *Table; - char Value; - UINT32 i; - FILE *FileHandle; - FILE *FileOutHandle; - UINT32 Count = 0; - int Scanned; - - - /* Open in/out files. input is in text mode, output is in binary mode */ - - FileHandle = fopen (File1Path, "rt"); - if (!FileHandle) - { - printf ("Could not open file %s\n", File1Path); - return (-1); - } - - FileOutHandle = fopen (File2Path, "w+b"); - if (!FileOutHandle) - { - printf ("Could not open file %s\n", File2Path); - return (-1); - } - - /* Force input table sig to uppercase */ - - AcpiUtStrupr (TableSig); - - - /* TBD: examine input for ASCII */ - - - /* We have an ascii file, grab one line at a time */ - - while (fgets (Buffer, BUFFER_SIZE, FileHandle)) - { - /* The 4-char ACPI signature appears at the beginning of a line */ - - if (ACPI_COMPARE_NAME (Buffer, TableSig)) - { - printf ("Found table [%4.4s]\n", TableSig); - - /* - * Eat all lines in the table, of the form: - * : <16 bytes of hex data, separated by spaces> - * - * Example: - * - * 02C0: 5F 53 42 5F 4C 4E 4B 44 00 12 13 04 0C FF FF 08 _SB_LNKD........ - * - */ - while (fgets (Buffer, BUFFER_SIZE, FileHandle)) - { - /* Get past the offset, terminated by a colon */ - - Table = strchr (Buffer, ':'); - if (!Table) - { - /* No colon, all done */ - goto Exit; - } - - Table += 2; /* Eat the colon + space */ - - for (i = 0; i < 16; i++) - { - Scanned = AbHexByteToBinary (Table, &Value); - if (!Scanned) - { - goto Exit; - } - - Table += 3; /* Go past this hex byte and space */ - - /* Write the converted (binary) byte */ - - if (fwrite (&Value, 1, 1, FileOutHandle) != 1) - { - printf ("Error writing byte %u to output file: %s\n", - Count, File2Path); - goto Exit; - } - Count++; - } - } - - /* No more lines, EOF, all done */ - - goto Exit; - } - } - - /* Searched entire file, no match to table signature */ - - printf ("Could not match table signature\n"); - fclose (FileHandle); - return (-1); - -Exit: - printf ("%u (0x%X) bytes written to %s\n", Count, Count, File2Path); - fclose (FileHandle); +Exit2: fclose (FileOutHandle); - return (0); + +Exit1: + free (FileBuffer); + return (Status); } diff --git a/source/tools/acpibin/abmain.c b/source/tools/acpibin/abmain.c index 6eb6eb1..d8c740c 100644 --- a/source/tools/acpibin/abmain.c +++ b/source/tools/acpibin/abmain.c @@ -54,7 +54,7 @@ AbDisplayUsage ( #define AB_UTILITY_NAME "ACPI Binary Table Dump Utility" -#define AB_SUPPORTED_OPTIONS "c:d:e:h:s:tv" +#define AB_SUPPORTED_OPTIONS "c:d:h:s:tv" /****************************************************************************** @@ -79,7 +79,6 @@ AbDisplayUsage ( ACPI_OPTION ("-c ", "Compare two binary AML files"); ACPI_OPTION ("-d ", "Dump AML binary to text file"); - ACPI_OPTION ("-e ", "Extract binary AML table from AcpiDump file"); ACPI_OPTION ("-h ", "Display table header for binary AML file"); ACPI_OPTION ("-s ", "Update checksum for binary AML file"); ACPI_OPTION ("-t", "Terse mode"); @@ -144,18 +143,6 @@ main ( Status = AbDumpAmlFile (AcpiGbl_Optarg, argv[AcpiGbl_Optind]); break; - case 'e': /* Extract AML text file */ - - if (argc < 5) - { - AbDisplayUsage (3); - return (-1); - } - - Status = AbExtractAmlFile (AcpiGbl_Optarg, argv[AcpiGbl_Optind], - argv[AcpiGbl_Optind+1]); - break; - case 'h': /* Display ACPI table header */ if (argc < 3) diff --git a/source/tools/acpibin/acpibin.h b/source/tools/acpibin/acpibin.h index 515f155..7f93d43 100644 --- a/source/tools/acpibin/acpibin.h +++ b/source/tools/acpibin/acpibin.h @@ -76,12 +76,6 @@ AbCompareAmlFiles ( char *File2Path); int -AbExtractAmlFile ( - char *TableSig, - char *File1Path, - char *File2Path); - -int AbDumpAmlFile ( char *File1Path, char *File2Path); diff --git a/source/tools/acpidump/acpidump.h b/source/tools/acpidump/acpidump.h index e3b705b..4b0f01c 100644 --- a/source/tools/acpidump/acpidump.h +++ b/source/tools/acpidump/acpidump.h @@ -142,10 +142,6 @@ ApGetTableLength ( /* * apfiles - File I/O utilities */ -UINT32 -ApGetFileSize ( - FILE *File); - int ApOpenOutputFile ( char *Pathname); diff --git a/source/tools/acpidump/apdump.c b/source/tools/acpidump/apdump.c index d11919b..0bd0294 100644 --- a/source/tools/acpidump/apdump.c +++ b/source/tools/acpidump/apdump.c @@ -69,6 +69,7 @@ BOOLEAN ApIsValidHeader ( ACPI_TABLE_HEADER *Table) { + if (!ACPI_VALIDATE_RSDP_SIG (Table->Signature)) { /* Make sure signature is all ASCII and a valid ACPI name */ @@ -100,9 +101,9 @@ ApIsValidHeader ( * * PARAMETERS: Table - Pointer to table to be validated * - * RETURN: TRUE if the checksum appears to be valid. FALSE otherwise + * RETURN: TRUE if the checksum appears to be valid. FALSE otherwise. * - * DESCRIPTION: Check for a valid ACPI table checksum + * DESCRIPTION: Check for a valid ACPI table checksum. * ******************************************************************************/ @@ -120,7 +121,6 @@ ApIsValidChecksum ( * Checksum for RSDP. * Note: Other checksums are computed during the table dump. */ - Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); Status = AcpiTbValidateRsdp (Rsdp); } @@ -131,7 +131,7 @@ ApIsValidChecksum ( if (ACPI_FAILURE (Status)) { - fprintf (stderr, "%4.4s: Warning: wrong checksum\n", + fprintf (stderr, "%4.4s: Warning: wrong checksum in table\n", Table->Signature); } @@ -147,7 +147,7 @@ ApIsValidChecksum ( * * RETURN: Table length * - * DESCRIPTION: Obtain table length according to table signature + * DESCRIPTION: Obtain table length according to table signature. * ******************************************************************************/ @@ -170,10 +170,10 @@ ApGetTableLength ( Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table); return (Rsdp->Length); } - else - { - return (Table->Length); - } + + /* Normal ACPI table */ + + return (Table->Length); } @@ -219,7 +219,7 @@ ApDumpTableBuffer ( } /* - * Dump the table with header for use with acpixtract utility + * Dump the table with header for use with acpixtract utility. * Note: simplest to just always emit a 64-bit address. AcpiXtract * utility can handle this. */ @@ -254,6 +254,7 @@ ApDumpAllTables ( UINT32 Instance = 0; ACPI_PHYSICAL_ADDRESS Address; ACPI_STATUS Status; + int TableStatus; UINT32 i; @@ -284,11 +285,13 @@ ApDumpAllTables ( } } - if (ApDumpTableBuffer (Table, Instance, Address)) + TableStatus = ApDumpTableBuffer (Table, Instance, Address); + free (Table); + + if (TableStatus) { - return (-1); + break; } - free (Table); } /* Something seriously bad happened if the loop terminates here */ @@ -368,6 +371,7 @@ ApDumpTableByName ( ACPI_TABLE_HEADER *Table; ACPI_PHYSICAL_ADDRESS Address; ACPI_STATUS Status; + int TableStatus; if (strlen (Signature) != ACPI_NAME_SIZE) @@ -415,11 +419,13 @@ ApDumpTableByName ( return (-1); } - if (ApDumpTableBuffer (Table, Instance, Address)) + TableStatus = ApDumpTableBuffer (Table, Instance, Address); + free (Table); + + if (TableStatus) { - return (-1); + break; } - free (Table); } /* Something seriously bad happened if the loop terminates here */ @@ -446,7 +452,7 @@ ApDumpTableFromFile ( { ACPI_TABLE_HEADER *Table; UINT32 FileSize = 0; - int TableStatus; + int TableStatus = -1; /* Get the entire ACPI table from the file */ @@ -464,7 +470,7 @@ ApDumpTableFromFile ( fprintf (stderr, "Table length (0x%X) is too large for input file (0x%X) %s\n", Table->Length, FileSize, Pathname); - return (-1); + goto Exit; } if (Gbl_VerboseMode) @@ -475,6 +481,8 @@ ApDumpTableFromFile ( } TableStatus = ApDumpTableBuffer (Table, 0, 0); + +Exit: free (Table); return (TableStatus); } diff --git a/source/tools/acpidump/apfiles.c b/source/tools/acpidump/apfiles.c index e719f54..1588f2e 100644 --- a/source/tools/acpidump/apfiles.c +++ b/source/tools/acpidump/apfiles.c @@ -215,8 +215,8 @@ ApGetTableFromFile ( /* Need file size to allocate a buffer */ - FileSize = ApGetFileSize (File); - if (!FileSize) + FileSize = CmGetFileSize (File); + if (FileSize == ACPI_UINT32_MAX) { fprintf (stderr, "Could not get input file size: %s\n", Pathname); @@ -251,41 +251,3 @@ Cleanup: fclose (File); return (Buffer); } - - -/****************************************************************************** - * - * FUNCTION: ApGetFileSize - * - * PARAMETERS: File - Open file descriptor - * - * RETURN: File size in bytes - * - * DESCRIPTION: Get the size of an open file - * - ******************************************************************************/ - -UINT32 -ApGetFileSize ( - FILE *File) -{ - UINT32 FileSize; - long Offset; - - - Offset = ftell (File); - if (fseek (File, 0, SEEK_END)) - { - return (0); - } - - /* Get size and restore file pointer */ - - FileSize = (UINT32) ftell (File); - if (fseek (File, Offset, SEEK_SET)) - { - return (0); - } - - return (FileSize); -} diff --git a/source/tools/acpidump/apmain.c b/source/tools/acpidump/apmain.c index 38c6d92..a16f583 100644 --- a/source/tools/acpidump/apmain.c +++ b/source/tools/acpidump/apmain.c @@ -358,7 +358,7 @@ main ( { /* Summary for the output file */ - FileSize = ApGetFileSize (Gbl_OutputFile); + FileSize = CmGetFileSize (Gbl_OutputFile); fprintf (stderr, "Output file %s contains 0x%X (%u) bytes\n\n", Gbl_OutputFilename, FileSize, FileSize); } diff --git a/source/tools/acpiexec/aecommon.h b/source/tools/acpiexec/aecommon.h index 5f65795..c27338d 100644 --- a/source/tools/acpiexec/aecommon.h +++ b/source/tools/acpiexec/aecommon.h @@ -63,8 +63,6 @@ #include #include -#pragma pack(push) /* Set default struct packing */ - extern BOOLEAN AcpiGbl_IgnoreErrors; extern UINT8 AcpiGbl_RegionFillValue; extern UINT8 AcpiGbl_UseHwReducedFadt; @@ -198,7 +196,4 @@ AeGlobalEventHandler ( UINT32 EventNumber, void *Context); - -#pragma pack(pop) /* Restore original struct packing */ - #endif /* _AECOMMON */ diff --git a/source/tools/acpiexec/aehandlers.c b/source/tools/acpiexec/aehandlers.c index faffdd9..ee2d2cf 100644 --- a/source/tools/acpiexec/aehandlers.c +++ b/source/tools/acpiexec/aehandlers.c @@ -312,7 +312,7 @@ AeCommonNotifyHandler ( printf ("[AcpiExec] Handler %u: Received a %s Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", HandlerId, Type, AcpiUtGetNodeName (Device), Device, Value, - AcpiUtGetNotifyName (Value)); + AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY)); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Handler %u: Received a %s notify, Value 0x%2.2X\n", @@ -348,7 +348,7 @@ AeSystemNotifyHandler ( printf ("[AcpiExec] Global: Received a System Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", AcpiUtGetNodeName (Device), Device, Value, - AcpiUtGetNotifyName (Value)); + AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY)); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Global: Received a System Notify, Value 0x%2.2X\n", Value); @@ -381,7 +381,7 @@ AeDeviceNotifyHandler ( printf ("[AcpiExec] Global: Received a Device Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", AcpiUtGetNodeName (Device), Device, Value, - AcpiUtGetNotifyName (Value)); + AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY)); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Global: Received a Device Notify, Value 0x%2.2X\n", Value); diff --git a/source/tools/acpihelp/acpihelp.h b/source/tools/acpihelp/acpihelp.h index fba2754..da15e4e 100644 --- a/source/tools/acpihelp/acpihelp.h +++ b/source/tools/acpihelp/acpihelp.h @@ -70,6 +70,7 @@ #define AH_DECODE_AML_OPCODE 5 #define AH_DISPLAY_DEVICE_IDS 6 #define AH_DECODE_EXCEPTION 7 +#define AH_DECODE_ASL_AML 8 #define AH_MAX_ASL_LINE_LENGTH 70 #define AH_MAX_AML_LINE_LENGTH 100 @@ -104,13 +105,6 @@ typedef struct ah_asl_keyword } AH_ASL_KEYWORD; -typedef struct ah_device_id -{ - char *Name; - char *Description; - -} AH_DEVICE_ID; - extern const AH_AML_OPCODE AmlOpcodeInfo[]; extern const AH_ASL_OPERATOR AslOperatorInfo[]; @@ -138,6 +132,10 @@ AhFindPredefinedNames ( char *Name); void +AhFindAslAndAmlOperators ( + char *Name); + +UINT32 AhFindAslOperators ( char *Name); @@ -147,6 +145,6 @@ AhFindAslKeywords ( void AhDisplayDeviceIds ( - void); + char *Name); #endif /* __ACPIHELP_H */ diff --git a/source/tools/acpihelp/ahamlops.c b/source/tools/acpihelp/ahamlops.c index faa4c19..9ac1351 100644 --- a/source/tools/acpihelp/ahamlops.c +++ b/source/tools/acpihelp/ahamlops.c @@ -141,7 +141,7 @@ const AH_AML_OPCODE AmlOpcodeInfo[] = "DefFatal := FatalOp FatalType FatalCode FatalArg"}, {0x5B33, 0x5B33, "0x5B33", "TimerOp", "TermObject", NULL, NULL, "DefTimer := TimerOp"}, - {0x5B80, 0x5B80, "0x5B80", "OpRegionOp", "TermObject", "NameString ByteData TermArg TermArg", NULL, + {0x5B80, 0x5B80, "0x5B80", "OperationRegionOp", "TermObject", "NameString ByteData TermArg TermArg", NULL, "DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset RegionLen"}, {0x5B81, 0x5B81, "0x5B81", "FieldOp", "TermObject", "NameString ByteData", "FieldList", "DefField := FieldOp PkgLength NameString FieldFlags FieldList"}, diff --git a/source/tools/acpihelp/ahdecode.c b/source/tools/acpihelp/ahdecode.c index 556dc6c..60e3808 100644 --- a/source/tools/acpihelp/ahdecode.c +++ b/source/tools/acpihelp/ahdecode.c @@ -48,41 +48,6 @@ #include "acpredef.h" -/* Device IDs defined in the ACPI specification */ - -static const AH_DEVICE_ID AhDeviceIds[] = -{ - {"PNP0A05", "Generic Container Device"}, - {"PNP0A06", "Generic Container Device"}, - {"PNP0C08", "ACPI core hardware"}, - {"PNP0C09", "Embedded Controller Device"}, - {"PNP0C0A", "Control Method Battery"}, - {"PNP0C0B", "Fan"}, - {"PNP0C0C", "Power Button Device"}, - {"PNP0C0D", "Lid Device"}, - {"PNP0C0E", "Sleep Button Device"}, - {"PNP0C0F", "PCI Interrupt Link Device"}, - {"PNP0C80", "Memory Device"}, - - {"ACPI0001", "SMBus 1.0 Host Controller"}, - {"ACPI0002", "Smart Battery Subsystem"}, - {"ACPI0003", "Power Source Device"}, - {"ACPI0004", "Module Device"}, - {"ACPI0005", "SMBus 2.0 Host Controller"}, - {"ACPI0006", "GPE Block Device"}, - {"ACPI0007", "Processor Device"}, - {"ACPI0008", "Ambient Light Sensor Device"}, - {"ACPI0009", "I/O xAPIC Device"}, - {"ACPI000A", "I/O APIC Device"}, - {"ACPI000B", "I/O SAPIC Device"}, - {"ACPI000C", "Processor Aggregator Device"}, - {"ACPI000D", "Power Meter Device"}, - {"ACPI000E", "Time/Alarm Device"}, - {"ACPI000F", "User Presence Detection Device"}, - - {NULL, NULL} -}; - #define AH_DISPLAY_EXCEPTION(Status, Name) \ printf ("%.4X: %s\n", Status, Name) @@ -589,7 +554,7 @@ AhDisplayAslKeyword ( /******************************************************************************* * - * FUNCTION: AhFindAslOperators (entry point for ASL operator search) + * FUNCTION: AhFindAslAndAmlOperators * * PARAMETERS: Name - Name or prefix for an ASL operator. * NULL means "find all" @@ -597,16 +562,46 @@ AhDisplayAslKeyword ( * RETURN: None * * DESCRIPTION: Find all ASL operators that match the input Name or name - * prefix. + * prefix. Also displays the AML information if only one entry + * matches. * ******************************************************************************/ void +AhFindAslAndAmlOperators ( + char *Name) +{ + UINT32 MatchCount; + + + MatchCount = AhFindAslOperators (Name); + if (MatchCount == 1) + { + AhFindAmlOpcode (Name); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhFindAslOperators (entry point for ASL operator search) + * + * PARAMETERS: Name - Name or prefix for an ASL operator. + * NULL means "find all" + * + * RETURN: Number of operators that matched the name prefix. + * + * DESCRIPTION: Find all ASL operators that match the input Name or name + * prefix. + * + ******************************************************************************/ + +UINT32 AhFindAslOperators ( char *Name) { const AH_ASL_OPERATOR *Operator; - BOOLEAN Found = FALSE; + BOOLEAN MatchCount = 0; AhStrupr (Name); @@ -618,7 +613,7 @@ AhFindAslOperators ( if (!Name) { AhDisplayAslOperator (Operator); - Found = TRUE; + MatchCount++; continue; } @@ -630,14 +625,16 @@ AhFindAslOperators ( if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) { AhDisplayAslOperator (Operator); - Found = TRUE; + MatchCount++; } } - if (!Found) + if (!MatchCount) { printf ("%s, no matching ASL operators\n", Name); } + + return (MatchCount); } @@ -805,26 +802,71 @@ AhPrintOneField ( * * FUNCTION: AhDisplayDeviceIds * - * PARAMETERS: None + * PARAMETERS: Name - Device Hardware ID string. + * NULL means "find all" * * RETURN: None * - * DESCRIPTION: Display all PNP* and ACPI* device IDs defined in the ACPI spec. + * DESCRIPTION: Display PNP* and ACPI* device IDs. * ******************************************************************************/ void AhDisplayDeviceIds ( - void) + char *Name) { - const AH_DEVICE_ID *DeviceId = AhDeviceIds; + const AH_DEVICE_ID *Info; + UINT32 Length; + BOOLEAN Matched; + UINT32 i; + BOOLEAN Found = FALSE; + + + /* Null input name indicates "display all" */ + + if (!Name) + { + printf ("ACPI and PNP Device/Hardware IDs:\n\n"); + for (Info = AslDeviceIds; Info->Name; Info++) + { + printf ("%8s %s\n", Info->Name, Info->Description); + } + + return; + } + Length = strlen (Name); + if (Length > 8) + { + printf ("%.8s: Hardware ID must be 8 characters maximum\n", Name); + return; + } - printf ("ACPI and PNP Device IDs defined in the ACPI specification:\n\n"); - while (DeviceId->Name) + /* Find/display all names that match the input name prefix */ + + AhStrupr (Name); + for (Info = AslDeviceIds; Info->Name; Info++) + { + Matched = TRUE; + for (i = 0; i < Length; i++) + { + if (Info->Name[i] != Name[i]) + { + Matched = FALSE; + break; + } + } + + if (Matched) + { + Found = TRUE; + printf ("%8s %s\n", Info->Name, Info->Description); + } + } + + if (!Found) { - printf ("%8s %s\n", DeviceId->Name, DeviceId->Description); - DeviceId++; + printf ("%s, Hardware ID not found\n", Name); } } diff --git a/source/tools/acpihelp/ahmain.c b/source/tools/acpihelp/ahmain.c index 1a8de1e..a340598 100644 --- a/source/tools/acpihelp/ahmain.c +++ b/source/tools/acpihelp/ahmain.c @@ -51,7 +51,7 @@ AhDisplayUsage ( void); #define AH_UTILITY_NAME "ACPI Help Utility" -#define AH_SUPPORTED_OPTIONS "ehikmopsv" +#define AH_SUPPORTED_OPTIONS "aehikmopsv" /****************************************************************************** @@ -67,24 +67,29 @@ AhDisplayUsage ( void) { - ACPI_USAGE_HEADER ("acpihelp [NamePrefix | HexValue]"); + ACPI_USAGE_HEADER ("acpihelp [Name/Prefix | HexValue]"); ACPI_OPTION ("-h", "Display help"); ACPI_OPTION ("-v", "Display version information"); - printf ("\nACPI Names and Symbols:\n"); - ACPI_OPTION ("-k [NamePrefix]", "Find/Display ASL non-operator keyword(s)"); - ACPI_OPTION ("-m [NamePrefix]", "Find/Display AML opcode name(s)"); - ACPI_OPTION ("-p [NamePrefix]", "Find/Display ASL predefined method name(s)"); - ACPI_OPTION ("-s [NamePrefix]", "Find/Display ASL operator name(s)"); + printf ("\nAML (ACPI Machine Language) Names and Encodings:\n"); + ACPI_OPTION ("-a [Name/Prefix]", "Find/Display both ASL operator and AML opcode name(s)"); + ACPI_OPTION ("-m [Name/Prefix]", "Find/Display AML opcode name(s)"); + + printf ("\nASL (ACPI Source Language) Names and Symbols:\n"); + ACPI_OPTION ("-k [Name/Prefix]", "Find/Display ASL non-operator keyword(s)"); + ACPI_OPTION ("-p [Name/Prefix]", "Find/Display ASL predefined method name(s)"); + ACPI_OPTION ("-s [Name/Prefix]", "Find/Display ASL operator name(s)"); + + printf ("\nOther ACPI Names:\n"); + ACPI_OPTION ("-i [Name/Prefix]", "Find/Display ACPI/PNP Hardware ID(s)"); printf ("\nACPI Values:\n"); ACPI_OPTION ("-e [HexValue]", "Decode ACPICA exception code"); - ACPI_OPTION ("-i", "Display known ACPI Device IDs (_HID)"); ACPI_OPTION ("-o [HexValue]", "Decode hex AML opcode"); - printf ("\nNamePrefix/HexValue not specified means \"Display All\"\n"); - printf ("\nDefault search with NamePrefix and no options:\n"); - printf (" Find ASL operator names - if NamePrefix does not start with underscore\n"); + printf ("\nName/Prefix or HexValue not specified means \"Display All\"\n"); + printf ("\nDefault search with valid Name/Prefix and no options:\n"); + printf (" Find ASL/AML operator names - if NamePrefix does not start with underscore\n"); printf (" Find ASL predefined method names - if NamePrefix starts with underscore\n"); } @@ -121,6 +126,11 @@ main ( while ((j = AcpiGetopt (argc, argv, AH_SUPPORTED_OPTIONS)) != EOF) switch (j) { + case 'a': + + DecodeType = AH_DECODE_ASL_AML; + break; + case 'e': DecodeType = AH_DECODE_EXCEPTION; @@ -173,6 +183,11 @@ main ( switch (DecodeType) { + case AH_DECODE_ASL_AML: + + AhFindAslAndAmlOperators (Name); + break; + case AH_DECODE_AML: AhFindAmlOpcode (Name); @@ -200,7 +215,7 @@ main ( case AH_DISPLAY_DEVICE_IDS: - AhDisplayDeviceIds (); + AhDisplayDeviceIds (Name); break; case AH_DECODE_EXCEPTION: @@ -222,7 +237,7 @@ main ( } else { - AhFindAslOperators (Name); + AhFindAslAndAmlOperators (Name); } break; } diff --git a/source/tools/acpisrc/asfile.c b/source/tools/acpisrc/asfile.c index 42cefa4..d3b72de 100644 --- a/source/tools/acpisrc/asfile.c +++ b/source/tools/acpisrc/asfile.c @@ -42,6 +42,7 @@ */ #include "acpisrc.h" +#include "acapps.h" /* Local prototypes */ @@ -714,8 +715,6 @@ AsGetFile ( FILE *File; UINT32 Size; char *Buffer; - int Seek1; - int Seek2; size_t Actual; @@ -730,11 +729,8 @@ AsGetFile ( /* Need file size to allocate a buffer */ - Seek1 = fseek (File, 0L, SEEK_END); - Size = ftell (File); - Seek2 = fseek (File, 0L, SEEK_SET); - - if (Seek1 || Seek2 || (Size == -1)) + Size = CmGetFileSize (File); + if (Size == ACPI_UINT32_MAX) { printf ("Could not get file size for %s\n", Filename); goto ErrorExit; diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c index 7c3d663..0073128 100644 --- a/source/tools/acpisrc/astable.c +++ b/source/tools/acpisrc/astable.c @@ -637,6 +637,10 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"PR_MACRO_ARG", SRC_TYPE_STRUCT}, {"PR_OPERATOR_INFO", SRC_TYPE_STRUCT}, + /* AcpiDump utility */ + + {"AP_DUMP_ACTION", SRC_TYPE_STRUCT}, + /* AcpiHelp utility */ {"AH_AML_OPCODE", SRC_TYPE_STRUCT}, @@ -648,6 +652,11 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"AX_TABLE_INFO", SRC_TYPE_STRUCT}, + /* OS service layers */ + + {"EXTERNAL_FIND_INFO", SRC_TYPE_STRUCT}, + {"OSL_TABLE_INFO", SRC_TYPE_STRUCT}, + {NULL, 0} }; diff --git a/tests/aapits/Makefile b/tests/aapits/Makefile index 586c784..81971fa 100644 --- a/tests/aapits/Makefile +++ b/tests/aapits/Makefile @@ -18,6 +18,7 @@ SRCS= atexec.c atmain.c \ ../../source/components/hardware/hwtimer.c \ ../../source/components/hardware/hwvalid.c \ ../../source/components/hardware/hwxface.c \ + ../../source/common/cmfsize.c \ ../../source/common/getopt.c \ ../../source/components/debugger/dbcmds.c \ ../../source/components/debugger/dbconvert.c \ diff --git a/tests/misc/grammar.aml b/tests/misc/grammar.aml new file mode 100755 index 0000000..27ba71f Binary files /dev/null and b/tests/misc/grammar.aml differ