Commit Graph

12899 Commits

Author SHA1 Message Date
Robert Moore d18654bc94 Revert "Acpica parser" 2016-07-01 07:20:27 -07:00
Robert Moore badd47cbd3 Revert "Update for local 64-bit version of strtoul"
This reverts commit 43fa9b91b4.
Needs extra partitioning to handle the multiple "types" of
string-to-integer conversions defined in the ACPI spec.
2016-06-30 12:17:37 -07:00
Robert Moore 43fa9b91b4 Update for local 64-bit version of strtoul
Update function AcpiUtStrtoul64:
Remove dead code.
Restructure to eliminate support for all numeric bases, only
base 16 and base 10 are needed.
Split off the base 10 and base 16 support into separate functions.
Added new exception for overflow during conversion.
Improved error detection and handling.
2016-06-30 08:19:21 -07:00
Robert Moore 7545c65eba Merge pull request #134 from zetalog/acpica-parser
Acpica parser
2016-06-29 09:41:32 -07:00
Robert Moore 135865a19d AcpiHelp: Add support for AML flags values and other grammar
All flags values, name grammar, package length encoding, etc.
Adds a new startup option, -g
2016-06-24 09:49:55 -07:00
Lv Zheng f3a77b60fb Interpreter: Fix MLC issues by switching to new TermList grammar for table loading
The MLC (Module Level Code) is an ACPICA terminology describing the AML
code out of any control method, its support is an indication of the
interpreter behavior during the table loading.

The original implementation of MLC in ACPICA had several issues:
1. Out of any control method, besides of the object creating opcodes, only
   the code blocks wrapped by "If/Else/While" opcodes were supported.
2. The supported MLC code blocks were executed after loading the table
   rather than being executed right in place.
   ============================================================
   The demo of this order issue is as follows:
     Name (OBJ1, 1)
     If (CND1 == 1)
     {
       Name (OBJ2, 2)
     }
     Name (OBJ3, 3)
   The original MLC support created OBJ2 after OBJ3's creation.
   ============================================================
Other than these limitations, MLC support in ACPICA looks correct. And
supporting this should be easy/natural for ACPICA, but enabling of this was
blocked by some ACPICA internal and OSPM specific initialization order
issues we've fixed recently. The wrong support started from the following
false bug fixing commit:
  Commit: 80d7951177
  Subject: Add support for module-level executable AML code.

We can confirm Windows interpreter behavior via reverse engineering means.
It can be proven that not only If/Else/While wrapped code blocks, all
opcodes can be executed at the module level, including operation region
accesses. And it can be proven that the MLC should be executed right in
place, not in such a deferred way executed after loading the table.

And the above facts indeed reflect the spec words around ACPI definition
block tables (DSDT/SSDT/...), the entire table and the Scope object is
defined by the AML specification in BNF style as:
  AMLCode := DefBlockHeader TermList
  DefScope := ScopeOp PkgLength NameString TermList
The bodies of the scope opening terms (AMLCode/Scope) are all TermList,
thus the table loading should be no difference than the control method
evaluations as the body of the Method is also defined by the AML
specification as TermList:
  DefMethod := MethodOp PkgLength NameString MethodFlags TermList
The only difference is: after evaluating control method, created named
objects may be freed due to no reference, while named objects created by
the table loading should only be freed after unloading the table.

So this patch follows the spec and the de-facto standard behavior, enables
the new grammar (TermList) for the table loading.

By doing so, beyond the fixes to the above issues, we can see additional
differences comparing to the old grammar based table loading:
1. Originally, beyond the scope opening terms (AMLCode/Scope),
   If/Else/While wrapped code blocks under the scope creating terms
   (Device/PowerResource/Processor/ThermalZone) are also supported as
   deferred MLC, which violates the spec defined grammar where ObjectList
   is enforced. With MLC support improved as non-deferred, the interpreter
   parses such scope creating terms as TermList rather ObjectList like the
   scope opening terms.
   After probing the Windows behavior and proving that it also parses these
   terms as TermList, we submitted an ECR (Engineering Change Request) to
   the ASWG (ACPI Specification Working Group) to clarify this. The ECR is
   titled as "ASL Grammar Clarification for Executable AML Opcodes" and has
   been accepted by the ASWG. The new grammar will appear in ACPI
   specification 6.2.
2. Originally, Buffer/Package/OperationRegion/CreateXXXField/BankField
   arguments are evaluated in a deferred way after loading the table. With
   MLC support improved, they are also parsed right in place during the
   table loading.
   This is also Windows compliant and the only difference is the removal
   of the debugging messages implemented before AcpiDsExecuteArguments(),
   see Link 1 for the details. A previous commit should have ensured that
   AcpiCheckAddressRange() won't regress.

Note that enabling this feature may cause regressions due to long term
Linux ACPI support on top of the wrong grammar. So this patch also prepares
a global option to be used to roll back to the old grammar during the
period between a regression is reported and the regression is
root-cause-fixed. Lv Zheng.

Link 1: https://bugzilla.kernel.org/show_bug.cgi?id=112911
Tested-by: Chris Bainbridge <chris.bainbridge@gmail.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-22 09:28:54 +08:00
Lv Zheng 5590b7aee0 ASLTS: Add cases to demonstrate MLC order issue
Original ACPICA executes If/Else/While wrapped MLC code block in a deferred
way, this patch introduces ASLTS cases to demonstrate this issue.
file index: order.asl 182
overall file index: order.asl z182

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-22 09:28:53 +08:00
Lv Zheng 6f52b66ca1 ASLTS: Add cases to validate if Type2Opcode is supported at module level
This patch adds test cases to validate if Type2Opcode is supported at
module level.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-22 09:28:53 +08:00
Lv Zheng 8488fcf57a Dispatcher: Fix an issue that the opregions created by the linked MLC were not tracked
Operation regions created by MLC were not tracked by
AcpiCheckAddressRange(), this patch fixes this issue. ACPICA BZ 1279. Fixed
by Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-22 09:20:10 +08:00
Lv Zheng bfe03ffcde Namespace: Fix a regression that MLC support triggers dead lock in dynamic table loading
The new MLC approach invokes MLC per-table basis. But the dynamic loading
support of this is incorrect because of the lock order:
 AcpiNsEvaluate
   AcpiExEnterIntperter
     AcpiNsLoadTable (triggered by Load opcode)
       AcpiNsExecModuleCodeList
         AcpiExEnterIntperter
The regression is introduced by the following commit:
  Commit: 071eff738c
  Subject: Add per-table execution of module-level code, early region handlers
This patch fixes this regression by unlocking the interpreter lock before
invoking MLC. However the unlocking is done to the AcpiNsLoadTable(), in
which, the interpreter lock should be locked by AcpiNsParseTable() but
wasn't. Reported by Mika Westerberg. Fixed by Lv Zheng.

Reported-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-22 09:20:09 +08:00
Robert Moore 2b896c59e5 Use os_allocate_zeroed
Eliminates an unnecessary memset.
Change proposed by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
2016-06-20 10:21:37 -07:00
Robert Moore f39a732d2a iASL/Parser: Split a bunch of very long lines
Some lines were terribly long.
2016-06-17 08:34:32 -07:00
Robert Moore a42901c660 Merge pull request #116 from zetalog/acpica-diverg
Acpica diverg
2016-06-16 09:55:34 -07:00
Robert Moore 58e68b6755 Merge pull request #144 from acpica/revert-143-efi-edk2
Revert "Efi edk2"
2016-06-15 10:53:17 -07:00
Robert Moore d776c9ee6e Revert "Efi edk2" 2016-06-15 10:51:12 -07:00
Robert Moore 8aac0be3c8 Merge pull request #143 from zetalog/efi-edk2
Efi edk2
2016-06-15 10:33:47 -07:00
Robert Moore f78ce8644e Merge branch 'master' of ssh://ssh.github.com/acpica/acpica 2016-06-15 10:23:07 -07:00
Robert Moore fc0f12b1ef iASL/Disassembler: Add a check for missing filename
Add check for required filename for the -d and -da options.
ACPICA BZ 1285.
2016-06-15 10:16:52 -07:00
Lv Zheng c160cae765 Divergence: Port declarators back to ACPICA
Linux uses asmlinkage and sparse macros to mark function symbols.  This
leads to the divergences between the Linux and the ACPICA.
This patch ports such declarators back to ACPICA. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-15 08:33:28 +08:00
Lv Zheng cc7c7ebe27 EFI: Port acpiexec/acpidump to EDK2 environment
This patch adds necessary build files for EDK2 environment to build ACPICA
tools.
The command steps of building edk2 binaries are (if you are using gcc4.7):
  # cd edk2
  # . ./edksetup.sh
  # ln -s <path to acpica> AcpiPkg
  # build -p AcpiPkg/AcpiPkg.dsc -t GCC47 -a X64 -a IA32
Note the above test was done in Linux, and the Windows hasn't been tested
when this patch is generated. For building edk2 binaries in the MSVC
environment, you need to modify acpidump.inf/acpiexec.inf, adding necessary
options when they cannot pass the build in the following configure items:
MSFT:*_*_IA32_CC_FLAGS/MSFT:*_*_X64_CC_FLAGS. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-12 14:15:05 +08:00
Robert Moore e62fd48444 iASL: update makefile
Don't use new bison file (internal file for now).
2016-06-10 18:42:24 -07:00
Robert Moore 5eb659ffbb iASL: Split some of the ASL parse rules files.
Broken into more logical groups of rules.i
2016-06-10 10:34:08 -07:00
Robert Moore 3c128da487 Merge pull request #142 from Lekensteyn/windows-ssdt
Windows: add support for dumping SSDT tables
2016-06-07 09:07:51 -07:00
Lv Zheng 904347fbea EFI: Rename EFI stuff to ACPI_EFI to improve portability
This patch renames the EFI stuffs to ACPI_EFI stuffs so that there won't be
namespace conflicts when this code is ported to the different EFI
development environment.
No functional changes. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:35 +08:00
Lv Zheng 4de4519bb6 EFI/acpiexec: Add EFI support for acpiexec
This patch enables acpiexec for EFI environment. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:34 +08:00
Lv Zheng 6bbbef8811 EFI/acpiexec: Disable object override mechanism
This mechanism requires sscanf to be implemented for almost no
significant benefit for EFI environment, so disables it. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:34 +08:00
Lv Zheng def0dcd048 EFI/acpiexec: Add stubs for Ctrl+C signal handling
Currently we do not support console termination caused by Ctrl+C for EFI
environment. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:34 +08:00
Lv Zheng 43cb45b8e1 EFI: Add table OSL supports for acpiexec
This patch implements table OSLs for acpiexec in EFI environment:
1. Adds AcpiOsTableOverride() to use acpiexec loaded xSDT tables.
2. Adds a stub AcpiOsPhysicalTableOverride().
Note that currently we only support emulator mode acpiexec in EFI
environment, thus all table overrides, RSDP location are implemented in the
same way as its windows/unix versions. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:33 +08:00
Lv Zheng feba919da4 EFI: Add AcpiOsStall()/AcpiOsSleep() support
This patch adds AcpiOsStall() and AcpiOsSleep() support.
Currently we do not support asynchronous polling of key stroke and timer,
so AcpiOsSleep() is simply an invocation of AcpiOsStall(). Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:33 +08:00
Lv Zheng 27a9dec7e5 EFI: Add AcpiOsGetTimer() support
This patch adds AcpiOsGetTimer() support for EFI environment.
Note that currently we don't support timezone. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:33 +08:00
Lv Zheng 370047064c EFI: Add stubs for hardware access OSLs to make EFI ported applications running
This patch only adds stub supports for hardware access OSLs to make EFI
ported application running.

This patch adds the following OSLs for efi:
1. AcpiOsInstallInterruptHandler()/RemoveInterruptHandler().
2. AcpiOsReadPort()/AcpiOsWritePort().
3. AcpiOsReadMemory()/AcpiOsWriteMemory().
3. AcpiOsReadPciConfigration()/AcpiOsWritePciConfiguration().
Currently we will not support real hardware accesses in the EFI
environment, so they can stay stubs. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:32 +08:00
Lv Zheng 24b89b61ac EFI: Add stubs for multi-threading OSLs to make EFI ported applications running
This patch only adds stub supports for multi-threading OSLs to make
EFI ported application running.

In order to fully support acpiexec in a non multi-threading environment,
ACPICA core itself need to be upgraded to contain full asynchrnous support.
Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:32 +08:00
Lv Zheng d919618187 EFI: Add OSL supports for those can be empty
This patch adds OSLs that can be empty under EFI environment. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:32 +08:00
Lv Zheng 52cca74dad Clib: Add putchar()/getchar() to improve portability
This patch implements putchar()/getchar() invoked in AcpiOsGetLine() to
improve the portability.
No functional changes for Unix/Windows environments. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:31 +08:00
Lv Zheng 01f6a32f55 Clib: Add generic strpbrk() and strtok() to improve portability
This patch implements the native string APIs of strpbrk()/strtok().
Unit tests have been done to these two functions in unix environment and no
bugs have been found. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:31 +08:00
Lv Zheng 452f283aa5 Clib/EFI: Add fgets() to improve portability
This patch adds fgets(). Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:31 +08:00
Lv Zheng fa8cacd857 Clib/EFI: Add file position seeking/telling support
This patch adds file position seeking/telling support. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:31 +08:00
Lv Zheng 9bba284f4d Clib/EFI: Add standard input descriptor support
This patch implements stdin for EFI environment using
SIMPLE_INPUT_INTERFACE. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:30 +08:00
Lv Zheng 973f73ca34 Clib/EFI: Add fgetc()/fputc() to improve portability
This patch added two new Clibrary functions: fgetc()/fputc() for EFI
environment, they are implemented using fread()/fwrite().

Note in this patch, stdin is simply defined as NULL for EFI
environment. Its EFI support should be implemented by further patches.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:30 +08:00
Lv Zheng 17d2c00994 Clib: Add memmove() to improve portability
This patch implements memmove(). Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:30 +08:00
Lv Zheng 33f019a5bf Applications: Fix a potential issue that help messages may be dumped to AcpiGbl_DebugFile
There is an issue for usage macros, if an command line option changed
AcpiGbl_DebugFile, then the follow up usage may errornously dumped to the
debug file.
This is just a bug in theory, because currently AcpiGbl_DebugFile can only
be modified by acpibin and acpiexec. Currently this will not trigger such
issue because:
1. For acpibin, AcpiGbl_DebugFile will be modified by "-t" option and the
   program exit after processing this option without dumping help message
   or other error options.
2. For acpiexec, AcpiGbl_DebugFile will only be modified by the open
   command, which happens after parsing the command line options, so no
   help message will be dumped into the debug file.
But maintaining this logic is difficult, so this patch modifies
AcpiOsPrintf() into printf() for usage macros so that the help messages are
ensured to be dumped to the stdout. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:29 +08:00
Lv Zheng fe92a821a0 acpidump: Fix a duplicate variable definition
AcpiGbl_IntegerByteWidth has already been instantiated by ACPI_GLOBAL() in
acglobal.h. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:29 +08:00
Lv Zheng a33ba9f856 Clib: Eliminate AcpiOsXXXFile()/AcpiLogError and link clibrary fxxx()/errno/perror() instead
This patch follows new ACPICA design, eliminates old portable OSLs, and
implements fopen/fread/fwrite/fclose/fseek/ftell for GNU EFI
environment. This patch also eliminates AcpiLogError(), convering them
into fprintf(stderr)/perror(). Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:29 +08:00
Lv Zheng 70e4161656 Clib: Add -nostdinc support for EFI layer
This patch adds sprintf()/snprintf()/vsnprintf()/printf()/vfprintf()
support for OSPMs that have ACPI_USE_SYSTEM_CLIBRARY defined but do not
have ACPI_USE_STANDARD_HEADERS defined.

This patch also converts the entire EFI porting layer to use the standard
system Clibrary and implements GNU EFI specific standard Clibrary stdio
operations.

-fno-builtin is required for GCC to avoid optimization performed printf().
This optimization cannot be automatically disabled by specifying -nostdlib.
Please refer to the Link 1 for the details.
-iwithprefix include is required to include <stdarg.h> which contains
compiler specific implementation of vargs. It is unclear why there is the
vargs macros defined for OSPMs that do not have ACPI_USE_SYSTEM_CLIBRARY
defined. After applying this patch, this special vargs implementation
should also get deleted.

Standard C header files shouldn't be included here and there throughout the
entire ACPICA code base. This patch corrects some of them. Lv Zheng.

Link 1: http://www.ciselant.de/projects/gcc_printf/gcc_printf.html
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:28 +08:00
Lv Zheng 831b85c7b5 Applications: Enable USE_NATIVE_ALLOCATE_ZEROED environment for all applications
We now safe to enable USE_NATIVE_ALLOCATE_ZEROED for all applications as
there are implementations in oswinxf.c, osunixxf.c and osefixf.c. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:28 +08:00
Lv Zheng 8825041d5e OSL: Add correct AcpiGbl_DebugTimeout export to allow acpiexec to link
The AcpiGbl_DebugTimeout which is used by acpiexec -et option now is only
implemented in oswinxf.c and used for WIN32 builds. This makes it very
difficult to remember to add this variable to other os specificy layer
files in order to link. This patch makes it a global option so that it can
always be linked. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:27 +08:00
Lv Zheng 9fcf90766f EFI/acpidump: Remove Gbl_DumpCustomizedTables awareness
EFI environment doesn't support any table customization mechanism, and
acpidump defaults to use "-c on", it then is a problem that in UEFI
environment, user can obtain nothing by just type "acpidump.efi". This
patch removes Gbl_DumpCustomizedTables awaness to fix this issue. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:27 +08:00
Lv Zheng 3a81e13d16 EFI: Add a missing object file which is split recently
This patch adds utnonansi.o linkage to EFI builds. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2016-06-06 12:58:26 +08:00
Robert Moore 37131916c8 iASL/Table-compiler/Disassembler: Support for RASF table
Provides full support for RASF.
With assistance from Vikas Sajjan (ha.sajjan@hpe.com)
2016-06-02 07:32:41 -07:00
Robert Moore 857c510d70 Simplify configuration for "Max Loops" system parameter
Allow for static configuration of this parameter. It is used
to abort out of infinite loops caused by non-response from
hardware.
2016-06-01 07:44:46 -07:00