ACPICA: Improve support for 32/64 bit physical addresses in printf().

This change improves the support for physical addresses in printf
debug statements and other output on both 32-bit and 64-bit hosts.
It consistently outputs the appropriate number of bytes for each
host. The %p specifier is unsatisfactory since it does not emit
uniform output on all hosts/clib implementations (on some, leading
zeros are not supported, leading to difficult-to-read output).

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Deploy new 32/64 printf support for table override mechanism.

Similar to the earlier tbprint.c change.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Utilities: Load of local test tables is now optional.

The utility has the capability to load some various tables to test
features of ACPICA. However, there are enough of them that the output
of the utility became confusing. With this change, only the required
local tables are displayed (RSDP, XSDT, etc.) along with the actual
tables loaded via the command line specification. This makes the
default output simler and easier to understand. The -el command line
option restores the original behavior for testing purposes.

This patch doesn't affect kernel behavior as Linux doesn't use ACPICA
allocation tracking implementation.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Improve parameter validation for acpi_install_gpe_block.

Add the following checks:
1) The incoming device handle refers to type ACPI_TYPE_DEVICE.
2) There is not already a gpe block attached to the device.

Likewise, with acpi_remove_gpe_block, ensure that the incoming object
is a device.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Update ACPICA copyrights to 2014.

Update ACPICA copyrights to 2014. Includes all source headers and
signons for the various tools.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Correctly support references in the union acpi_object.

This change fixes the support to allow references (namespace nodes)
to be passed as arguments to control methods via the evaluate object
interface. This is probably most useful for testing purposes, however.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Debugger: Add new command to read/write/compare all namespace objects.

This command "test objects" will exercise the entire namespace by
writing new values to each data object, and ensuring that the write
was successful. The original value is then restored and verified.

This patch doesn't affect kernel behavior as the debugger is
currently not shipped in the Linux source tree.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Update the conditions to enable the utility resource dump strings.

This patch enables resource dump functions for debugging purpose where
ACPI_DEBUG_OUTPUT is enabled.  Such functions are useful for developers
to track kernel issues when composing debugging patches.  They will be
optimized out during link stage for normal builds.

This patch updates the compilation condition used for the resource dump
related string tables to match the compilation environment used for
rsdump.c and rsdumpinfo.c.

This patch can help to improve the ACPICA release automation.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Add support for extra, optional OS-specific header file.

If OSPMs have something should appear after actypes.h to reference type
definitions, the platform/acxxx.h is not sufficient as it is included by
platform/acenv.h before including actypes.h.

This patch introduces an OSPMs declarable headers to allow OSPMs to handle
such requirement for their own purposes.

This kind of header can also be used by Linux to collect the divergences
that haven't been back ported yet.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Update version to 20140114.

Version 20140114.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Add "Windows 2013" string to _OSI support.

This urgent patch is cherry picked from ACPICA upstream.
It is reported that some platforms fail to boot without this new _OSI
string.

This change adds this string for Windows 8.1 and Server 2012 R2.

Reported-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Bob Moore <Robert.Moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: acpidump: Add sparse declarators support.

Linux kernel resident ACPICA headers include some sparse declarators for
kernel static checkers.  This patch adds code to disable them for non
__KERNEL__ defined code so that it is possible for the ACPICA user space
tool's source files to be built with Linux kernel ACPICA header files
included.  Lv Zheng.

Linux kernel build is not affected by this commit.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: acpidump: Remove integer types translation protection.

Remove translation protection for applications as Linux tools folder will
start to use such types.

In Linux kernel source tree, after removing this translation protection,
the u8/u16/u32/u64/s32/s64 typedefs are exposed for both __KERNEL__ builds
and !__KERNEL__ builds (tools/power/acpi) and the original definitions of
ACPI_UINT8/16/32/64_MAX are changed.

For !__KERNEL__ builds, this kind of defintions should already been tested
by the distribution vendors that are distributing binary ACPICA package and
we've achieved the successful built/run test result in the kernel source
tree.

For __KERNEL__ builds, there are 2 things affected:
1. u8/u16/u32/u64/s32/s64 type definitions:
   Since Linux has already type defined u8/u16/u32/u64/s32/s64 in
   include/uapi/asm-generic/int-ll64.h for __KERNEL__.  In order not to
   introduce build regressions where the 2 typedefs are differed,
   ACPI_USE_SYSTEM_INTTYPES is introduced to mask out ACPICA's typedefs.
   It must be defined for Linux __KERNEL__ builds.
2. ACPI_UINT8/16/32/64_MAX definitions:
   Before applying this change:
     ACPI_UINT8_MAX: sizeof (UINT8)
      UINT8: unsigned char
     ACPI_UINT16_MAX: sizeof (UINT16)
      UINT16: unsigned short
     ACPI_UINT32_MAX: sizeof (UINT32)
      INT32: int
      UINT32: unsigned int
     ACPI_UINT64_MAX: sizeof (UINT64)
      INT64: COMPILER_DEPENDENT_INT64
       COMPILER_DEPENDENT_INT64: signed long (IA64) or
                                 signed long long (IA32)
      UINT64: COMPILER_DEPENDENT_UINT64
       COMPILER_DEPENDENT_UINT64: unsigned long (IA64) or
                                  unsigned long long (IA32)
   After applying this change:
     ACPI_UINT8_MAX: sizeof (u8)
      u8: unsigned char
      UINT8: (removed from actypes.h)
     ACPI_UINT16_MAX: sizeof (u16)
      u16: unsigned short
      UINT16: (removed from actypes.h)
     ACPI_UINT32_MAX: sizeof (u32)
      INT32/UINT32: (removed from actypes.h)
      s32: signed int
      u32: unsigned int
     ACPI_UINT64_MAX: sizeof (u64)
      INT64/UINT64: (removed from actypes.h)
      u64: unsigned long long
      s64: signed long long
      COMPILER_DEPENDENT_INT64: signed long (IA64) (not used any more)
                                signed long long (IA32) (not used any more)
      COMPILER_DEPENDENT_UINT64: unsigned long (IA64) (not used any more)
                                 unsigned long long (IA32) (not used any more)
   All definitions are equal except ACPI_UINT64_MAX for CONFIG_IA64.  It
   is changed from sizeof(unsigned long) to sizeof(unsigned long long).
   By investigation, 64bit Linux kernel build is LP64 compliant, i.e.,
   sizeof(long) and (pointer) are 64.  As sizeof(unsigned long) equals to
   sizeof(unsigned long long) on IA64 platform where CONFIG_64BIT cannot be
   disabled, this change actually will not affect the value of
   ACPI_UINT64_MAX on IA64 platforms.

This patch is necessary for the ACPICA's acpidump tool to build
correctly.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Add boot option to disable auto return object repair

Sometimes, there might be bugs caused by unexpected AML which is compliant
to the Windows but not compliant to the Linux implementation.

There is a predefined validation mechanism implemented in ACPICA to repair
the unexpected AML evaluation results that are caused by the unexpected
AMLs.  For example, BIOS may return misorder _CST result and the repair
mechanism can make an ascending order on the returned _CST package object
based on the C-state type.
This mechanism is quite useful to implement an AML interpreter with better
compliance with the real world where Windows is the de-facto standard and
BIOS codes are only tested on one platform thus not compliant to the
ACPI specification.

But if a compliance issue hasn't been figured out yet, it will be
difficult for developers to identify if the unexpected evaluation result
is caused by this mechanism or by the AML interpreter.
For example, _PR0 is expected to be a control method, but BIOS may use
Package: "Name(_PR0, Package(1) {P1PR})".
This boot option can disable the predefined validation mechanism so that
developers can make sure the root cause comes from the parser/executer.

This patch adds a new kernel parameter to disable this feature.

A build test has been made on a Dell Inspiron mini 1100 (i386 z530)
machine when this patch is applied and the corresponding boot test is
performed w/ or w/o the new kernel parameter specified.

References: https://bugzilla.kernel.org/show_bug.cgi?id=67901
Tested-by: Fabian Wehning <fabian.wehning@googlemail.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Headers: Deploy #pragma pack (push) and (pop).

Use push and pop to both guarantee that the correct alignment is used,
and to restore the alignment to whatever it was before the header
was included.

It is reported that the #pragma pack(push/pop) directives are not supported
by the specific GCCs, but this patch still doesn't affect kernel build
as there are already #pragma pack([1]) directives used in the old ACPICA
headers, which means there shouldn't be GCCs that are currently used to
compile the ACPI kernels do not support #pragma pack() directives.

References: https://bugs.acpica.org/show_bug.cgi?id=1058
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Predefined names: Add support for the _PRP method.

This is not an official predefined name yet, but we add it to assist
with development.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Update conditional compilation flags for resource dump functions.

Corrects ACPI_DISASSEMBLER to the compile conditions.  The wrong
condition was introduced by this commit:
  Commit: 3334861b1e9947631230b573eba27bcd778b93c8
  Subject: ACPICA: Update the conditions to enable the utility resource dump strings.

This was detected in the ACPICA upstream.  Linux is not affected by the
wrong commit as the disassembler is not shipped in the Linux.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Properly handle NULL entries in _PRT return packages.

This change enables proper handling of NULL package entries in a _PRT
return value, during construction of the PCI routing table.
Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Restore code that repairs NULL package elements in return values.

The original code was lost accidently, it was not generated along with the
following commit of mechanism improvements and thus not get merged:

  Commit: d5a36100f62fa6db5541344e08b361b34e9114c5
  Subject: ACPICA: Add mechanism for early object repairs on a per-name basis

  Adds the framework to allow object repairs very early in the
  return object analysis. Enables repairs like string->unicode,
  etc.

This patch restores the implementation of the NULL element repair code for
ACPI_RTYPE_NONE.  In the original design, ACPI_RTYPE_NONE is defined to
collect simple NULL object repairs.
Lv Zheng.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=67901
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Cc: 3.10+ <stable@vger.kernel.org> # 3.10+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Harden _PRT repair code; check for minimum package length.

This change prevents a fault during the repair by checking up
front if the _PRT subpackage contains the minimum number of
elements (4).

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>