acpisrc: Add LPIT table conversions.

The following commit hasn't correctly updated acpisrc, which breaks Linux
builds after the linuxized result has been merged by Linux kernel.
  Commit: 6d8ce6539f40de7b6259ca882d8b4fbcfac65708
  Subject: Add support for LPIT table.
This patch fixes this issue.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Executer: Fix buffer allocation issue for GenericSerialBus region field accesses.

The size of the buffer allocated for GenericSerialBus region access
is not correct.  This patch introduces AcpiExGetSerialAccessLength()
to be invoked to obtain correct data buffer length.  Reported by
Lan Tianyu, Fixed by Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Merge pull request #29 from zetalog/acpica-201404

Merge from Lv Zheng's Acpica 201404 tree.
Debugger: free Pathname on error return path

Fix a memory leak on Pathname on an error return path.
bugs.acpica.org, bug #1086.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Utilities: Fix memory leak in AcpiUtCopyIobjectToIobject

Adds return status check on copy routines to delete the allocated destination
object if either copy fails. Reported by Colin Ian King on bugs.acpica.org,
Bug 1087.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
acpidump: Fix an issue that reserved tables are dumped multiple times in -n mode.

In "-n" mode, reserved tables (RSDP/RSDT/XSDT/DSDT/FACS) are dumped
multiple times, the root cause is there is no instance check for such
tables in OslGetBiosTable().

This patch fixes this issue. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
acpidump: Fix an issue for Linux version that EFI ACPI 1.0 GUID is not used if ACPI 2.0 GUID doesn't exist.

This patch facilitates Linux acpidump with the ability to find RSDP on an
EFI platform using ACPI 1.0 GUID when 2.0 GUID fails. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Utilities: Fix an issue for non-native ACPI_IS_PRINT() by replacing _ACPI_SP with _ACPI_XS.

There is a difference between standard isprint() and ACPICA provided non
native ACPI_IS_PRINT():
  The GNU libc isprint('\n') test result:
   isprint(0x20) is FALSE
  The Linux kernel isprint('\n') test result:
   ACPI: isprint(0x20) is FALSE
  The _acpi_ctype isprint('\n') test result:
   isprint(0x20) is TRUE

The ACPI_IS_PRINT() macro generated for _acpi_ctype is wrong, it should use
_ACPI_XS instead of _ACPI_SP.  The _ACPI_XS only means 0x20 - the white
space, other space characters should be non printable.

This patch fixes this issue. For OSPMs that are using native standard
isprint() implementations, this patch is a no-op. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Utilities: Fix an issue that non-native string API usage cannot find AcpiUtStrchr() to link.

This patch enables non-native ACPI_STRCHR(), for OSPMs that are using
native standard implementations, this patch is a no-op. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
OSL: Export initialized global variables of AcpiOsVprintf().

This patch exports initialized global variables used in AcpiOsVprintf() for
ACPICA applications.

This patch is useful for portable applications. Such applications need to
link osPLATxf.c, thus need some global variables used by
AcpiOsVprintf()/AcpiOsPrintf() to be initialized correctly for them to use.
While the initialization code in utglobal.c may not be linked into such
applications. This patch uses ACPI_INIT_GLOBAL() mechanism to solve this
issue. Lv Zheng.

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

This patch introduces new compilation environment
ACPI_USE_NATIVE_MEMORY_MAPPING to improve the portability of the generic
OSL.

In order to convert acpidump to be a portable applicatiion, acpidump need
to link osPLATxf.c, then there will be 2 instances of
AcpiOsMapMemory()/AcpiOsUnmapMemory() linked by acpidump, one is only used
by acpidump to perform file mapping, the other is a generic memory mapping
implementation for other applications. It thus requires a mechanism for
acpidump to exclude the generic one. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
OSL: Add AcpiOsAllocateZeroed() to improve portability.

This patch implements AcpiOsAllocateZeroed() in generic OSL for the
applicatiions that have USE_NATIVE_ALLOCATED_ZEROED enabled. This can help
to improve the portability of the generic OSL.

Some utilities may include only osunixxf.c/oswinxf.c without including
utalloc.c, the default AcpiOsAllocateZeroed() is useful in such case to
link a default implementation. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
OSL: Cleanup AcpiOsGetRootPointer() to improve portability.

This patch cleans up AcpiOsGetRootPointer() by deleting the
AeLocalGetRootPointer() and adding ACPI_USE_NATIVE_RSDP_POINTER.  This can
help to improve the portability of the generic OSL.

The AeLocalGetRootPointer() referenced by osunixxf.c/oswinxf.c is
preventing portable applications that do not have this function implemented
to directly link the useful generic OSL.

This patch changes the way to achieve a default empty
AcpiOsGetRootPointer() by deleting all AeLocalGetRootPointer(). If a
utility wants to have a specific and functioning AcpiOsGetRootPointer(), it
now should define ACPI_USE_NATIVE_RSDP_POINTER and implement its own
AcpiOsGetRootPointer(). 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 define
DEFINE_ACPI_GLOBALS 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 adding DEFINE_ACPI_GLOBALS and AcpiOsInitialize() are as
follows:
1. acpiexamples/acpiexec/acpinames have already invoked
   AcpiInitializeSubsystem() very early, thus no need to add
   AcpiOsInitialize() for them.
2. 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.
3. acpidump has its own AcpiOsPrintf() implementation, this is not needed
   after applying this patch to use generic OSL.
4. acpidump/acpihelp/acpisrc/acpixtract are the only applications that do
   not have utglobal.o linked, so DEFINE_ACPI_GLOBALS need to be defined
   for them.
5. acpidump already defines DEFINE_ACPI_GLOBALS.
6. 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.

Though makefiles are updated to include osunixxf.c in this patch, MSVS
project files are not updated. It can be done by further patches with
proper build tests performed. 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>