Namespace: Remove _PRP method support.

The _PRP method is not going to be a part of the ACPI standard. This patch
removes its support code introduced by the following commits:
 1. Predefined names: Add support for the _PRP method.
 2. Update for _PRP predefined name.
 3. Add support for _LPD and _PRP methods.
 4. iASL: Add check for _PRP/_HID dependency, with error message.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Hardware: Fix possible recursive locking in hwregs.c

In Linux calling pm-suspend might trigger a recursive lock in it's code path.
In function AcpiHwClearAcpiStatus(), AcpiOsAcquireLock() holds the lock
AcpiGbl_HardwareLock before calling AcpiHwRegisterWrite(), then without
releasing AcpiGbl_HardwareLock, this function calls AcpiEvWalkGpeList(), which
tries to hold AcpiGbl_GpeLock. Both AcpiGbl_HardwareLock and AcpiGbl_GpeLock
are at same lock-class and which might cause lock recursion deadlock.

Following patch fixes this scenario by just releasing
AcpiGbl_HardwareLock before calling AcpiEvWalkGpeList().

 Changes since v0(https://lkml.org/lkml/2011/9/21/355):
	- Fix changelog, thanks to Lin Ming.

 Changes since v1 (https://lkml.org/lkml/2011/11/3/89):
	- Update changelog and rename goto label, courtesy Srivatsa S. Bhat.

Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
Merge branch 'master' of git://github.com/acpica/acpica
Tables: Add mechanism to control early table checksum verification.

It is reported that Linux x86 kernel cannot map large tables. The following
large SSDT table on such platform fails to pass checksum verification and
cannot be installed:
 ACPI: SSDT 0x00000000B9638018 07A0C4 (v02 INTEL  S2600CP  00004000 INTL 20100331)

It sounds strange that in the 64-bit virtual memory address space, we
cannot map a single ACPI table to do checksum verification. The root cause
is:
1. ACPICA doesn't split IO memory mapping and table mapping;
2. Linux x86 OSL implements AcpiOsMapMemory() using a size limited fix-map
   mechanism during early boot stage, which is more suitable for only IO
   mappings.

ACPICA originally only mapped table header for signature validation, and
this header mapping is required by OSL override mechanism. There was no
checksum verification because we could not map the whole table using this
OSL. While the following ACPICA commit enforces checksum verification by
mapping the whole table during Linux boot stage and it finally triggers
this issue on some platforms:
 Commit: bf959821a98985b69b118ad6e6676a142c2e3241
 Subject: Tables: Fix table checksums verification before installation.

Before doing further cleanups for the OSL table mapping and override
implementation, this patch introduces an option for such OSPMs to
temporarily discard the checksum verification feature. It then can be
re-enabled easily when the ACPICA and the underlying OSL is ready.

This patch also deletes a comment around the limitation of mappings because
it is not correct. The limitation is not how many times we can map in the
early stage, but the OSL mapping facility may not be suitable for mapping
the ACPI tables and thus may complain us the size limitation.

The AcpiTbVerifyTable() is renamed to AcpiTbVerifyTempTable() due to the
work around added, it now only applies to the table descriptor that hasn't
been installed and cannot be used in other cases. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Reported-and-tested-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Merge branch 'master' of git://github.com/acpica/acpica
Utilities: Validate full RSDP header

Implement proper RSDP validation in AcpiUtReadTable(). Prevents a segmentation
fault that can occur if a user passes the wrong file to iasl.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Namespace: Properly null terminate objects detached from a namespace node

Fixes a bug exposed by commit 6af53b030395bb6bfa7a36812c41e9557a0bb003 where the
failure to null terminate a detached object led to the creation of a circular
linked list (and infinite looping) when the object is reattached.

Reported in acpica bugzilla #1063

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
AcpiExec: Add support to test attach/delete root node objects.

This change attaches two objects to the root node to test both
the attach and the actual object deletion upon ACPICA termination.

06/10/14: Patched reapplied after fixing inifinite loop error it
exposed when it was first applied. Dave Box
acpiexamples: Enable notify/region examples.

The patch is generated in the purposes of:
1. AcpiOsPrintf()/AcpiOsVprintf() need to be linked by applications;
2. utglobal.o linkage is prefered than defining DEFINE_ACPI_GLOBALS for
   applications, then applications that have already linked to utinit.o
   need to be updated, especially, their stubs need to be updated.

The acpiexamples loads tables and invokes control methods, waiting for
notifications, possibly in the future we can add region demonstrations.
Thus it makes senses to link acpiexamples to all of the following
components:
  tables
  namespace
  dispatcher
  executer
  parser
  events (notify/region part)

This patch updates acpiexamples in the way of:
1. Linking all namespace/utilities objects and deleting stubs of
   AcpiUt/AcpiNs functions from exstubs.c;
2. Linking all region/notify objects and deleting relevent stubs of AcpiEv
   functions from exstubs.c;
3. Adding region/notify examples in the DSDT.
4. Converting AcpiOsExecute() into a direct callback invocation.
5. Linking hwpci.c, the file has nothing to do with hardware, it is more
   suitable to be utpci.c;
6. Since no hardware samples are demonstrated in acpiexamples, defining
   ACPI_REDUCED_HARDWARE to 1 and deleting relevent stubs of AcpiHw
   functions from exstubs.c.

This patch thus updates exstubs.c with such minimal efforts. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
acpinames: Cleanup stubs by linking some utilities objects.

This patch tries to reduce stubs for acpinames by adding some utilities
objects to link.

By doing so, we have to create stubs for AcpiEvTerminate(). While
definining ACPI_REDUCED_HARDWARED can eliminate such requirements
permanently. Then we are able to delete some AcpiHwXXX() AcpiEvXXX() stubs
from anstubs.c

It also makes senses to link exsystem.o and exmutex.o because they've
already been made no-op by underlying OSL. By doing so, we can reduce some
AcpiExXXX() stubs.

Linking utids.o and uteval.o can help to reduce lots of stubs. It's safe to
do so as such functions are not invoked by acpinames.

This is the minimal effort to removing stubs from acpinames. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Utilities: Cleanup DEFINE_ACPI_GLOBALS by moving AcpiUtInitGlobal() from utglobal.c to utinit.c.

The utglobal.c is used to define and initialize global variables.  It makes
sense if just adding utglobal.o to applications that are using such
variables. But AcpiUtInitGlobals() is preventing us from doing so as this
initialization function references other components' initializations code,
which leads to the requirement that many files should also get linked if
one wants to link utglobal.o.

By eliminating the stubs for acpiexamples, acpinames, iasl, now it is
possible to just move AcpiUtInitGlobal() to utinit.c for applications that
require this function to link.

By linking utglobal.o, we can stop defining DEFINE_ACPI_GLOBALS for
applications (currently only acpidump is affected). Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
OSL: Cleanup AcpiOsPrintf()/AcpiOsVprintf() stubs.

This patch is mainly for acpidump where there are redundant
AcpiOsPrintf()/AcpiOsVprintf() stubs implemented. This patch cleans up such
specific implementation by linking acpidump to osunixxf.c/oswinxf.c.

To make AcpiOsPrintf() exported by osunixxf.c/oswinxf.c to behave as the
old acpidump specific ones, applications need to:
1. Initialize AcpiGbl_DbOutputFlags to ACPI_DB_CONSOLE_OUTPUT.
   This is automatically done by ACPI_INIT_GLOBAL(), applications need to
   link utglobal.o to utilize this mechanism.
2. Initialize AcpiGbl_OutputFile to stdout.
   For GCC, assigning stdout to AcpiGbl_OutputFile using ACPI_INIT_GLOBAL()
   is not possible as stdout is not a constant in GCC environment. As an
   alternative solution, stdout assignment is put into AcpiOsInitialize().
   Thus AcpiOsInitialize() need to be invoked very early by the
   applications to initialize the default output of AcpiOsPrintf().

Note that acpidump has been released to Linux kernel, after adding
osunixxf.c to generate/unix/acpidump/Makefile, libacpica.sh also need to be
updated to release osunixxf.c to Linux kernel. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
OSL: Add portable file IO to improve portability.

This patch adds portable file IO to generic OSL to improve the portability
of the applications.

A portable application may use different file IO interaces than the
standard C library ones. This patch thus introduces an abstract file IO
layer into the generic OSL.

Note that this patch does not introduce users of such interfaces, further
patches should introduce users one by one carefully with build tests
performed. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Utilities: Add formatted printing APIs.

This patch introduces formatted printing APIs to handle ACPICA specific
formatted print requirements.

The specific formatted printing APIs are useful to ACPICA as:
1. Some portable applications do not link standard C library, so they
   cannot use standard formatted print APIs directly.
2. Platform specific printing format may differ and thus not portable, for
   example, UINT64 is %ull for Linux kernel and is %uI64 for some MSVC
   versions.
3. Platform specific printing format may conflict with ACPICA's usages
   while it is not possible for ACPICA developers to test their code for
   all platforms. For example, developers may generate %pRxxx while Linux
   kernel treats %pR as structured resource printing and decodes variable
   argument as a "struct resource" pointer.
This patch solves above issues by introducing the new APIs.

Note that users of such APIs are not introduced in this patch. Users of
AcpiOsFileVprintf()/AcpiUtFilePrintf() need to invoke AcpiOsInitialize(),
this should be taken care by the further patches where such users are
introduced. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Utilities: Introduce AcpiLogError() to improve portability.

Invocations like fprintf(stderr) and perror() are not portable, this patch
introduces AcpiLogError() as a replacement, it is implemented using new
portable API - AcpiUtFileVprintf().

Some applications are already referencing utdebug.c, they now need to build
utlibcfs.c/utprint.c as well.

Note that though AcpiOsInitialize() need to be invoked prior than using
this new API, since no users are introduced in this patch, such invocations
are not added for applications that link utprint.c in this patch. Futher
patches that introduce users of AcpiLogError() should take care of this.
Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Application: Enhance ACPI_USAGE_xxx/ACPI_OPTION with AcpiOsPrintf() to improve portability.

This patch enhances ACPI_USAGE_xxx/ACPI_OPTION macros to use portable
AcpiOsPrintf() so that usage functions for applications no longer rely on
the printf() API.

To use AcpiOsPrintf() exported by osunixxf.c/oswinxf.c as a replacement of
printf, applications need to initialize AcpiGbl_OutputFile to stdout and
initialize AcpiGbl_DbOutputFlags to ACPI_DB_CONSOLE_OUTPUT. The latter is
automatically done by ACPI_INIT_GLOBAL(), applications need to link
utglobal.o to utilize this mechanism. For GCC, assigning stdout to
AcpiGbl_OutputFile using ACPI_INIT_GLOBAL() is not possible as stdout is
not a constant in GCC environment. As an alternative solution, stdout
assignment has been put into AcpiOsInitialize(). Thus AcpiOsInitialize()
need to be invoked very early by the applications to initialize the default
output of AcpiOsPrintf() to keep behavior consistency.

The details of AcpiOsInitialize() are as follows:
1. acpidump have already invoked AcpiOsInitialize(), thus no need to add.
2. acpiexamples/acpiexec/acpinames have already invoked
   AcpiInitializeSubsystem() very early, thus no need to add
   AcpiOsInitialize() for them.
3. iasl have already invoked AcpiOsInitialize(), but the invocation is not
   early enough to make its usage functioning proper. This patch adds an
   early AcpiOsInitialize() invocation for it.

Unix makefiles are also updated to include osunixxf.o/utglobal.o in this
patch.  The acpihelp/acpisrc/acpixtract applications are the only ones that
do not have the 2 object files linked. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Common: Enhance CmGetFileSize() to improve portability.

This patch uses abstract file IO and AcpiLogError() APIs to enhance
CmGetFileSize() so that applications that invoke this API could have
portability improved.

With actual references added to abstract file IO and AcpiLogError(), the
applications need to link utlibcfs.o, utdebug.o, utexcep.o, utmath.o,
utprint.o and utxferror.o.
Though it is required to add AcpiOsInitialize() invocations if an
application starts to use AcpiLogError(), this doesn't appear in this
patch. A previous patch in the same series should have already added
AcpiOsInitialize() invocations for all applications. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Common: Enhance AcpiGetopt() to improve portability.

This patch enhances AcpiGetopt() by converting the standard C library
invocations into portable ACPI string APIs and AcpiLogError() to improve
portability.

With actual references added to AcpiLogError(), the applications need to
link utlibcfs.o, utdebug.o, utexcep.o, utmath.o, utprint.o and utxferror.o.
Though it is required to add AcpiOsInitialize() invocations if an
application starts to use AcpiLogError(), this doesn't appear in this
patch. A previous patch in the same series should have already added
AcpiOsInitialize() invocations for all applications. Lv Zheng.

With actual references added, some utilities need to add utlibcfs.o,
utdebug.o, utexcep.o, utmath.o, utprint.o and utxferror.o in order to
link. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
acpidump: Add memory/string OSL usage to improve portability.

This patch adds code to use generic OSL for acpidump to improve the
portability of this tool. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
acpidump: Remove exit() from generic layer to improve portability.

This patch removes exit() from generic acpidump code to improve the
portability of this tool. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>