Linux headers: Remove ACPI_PREEMPTION_POINT() due to no usages.

This patch deletes deprecated ACPI_PREEMPTION_POINT(), there is no user for
it in Linux kernel now. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Linux headers: Add <acpi/platform/aclinuxex.h> to remove mis-ordered inclusion of <acpi/actypes.h> from <acpi/platform/aclinux.h>.

From ACPICA's perspective, <acpi/actypes.h> should be included after
inclusion of <acpi/platform/acenv.h>.  But currently in Linux,
<acpi/platform/aclinux.h> included by <acpi/platform/acenv.h> has
included <acpi/actypes.h> to find ACPICA types for inline functions.

This causes the following problem:
1. Redundant code in <asm/acpi.h> and <acpi/platform/aclinux.h>:
   Linux must be careful to keep conditions for <acpi/actypes.h> inclusion
   consistent with the conditions for <acpi/platform/aclinux.h> inclusion.
   Which finally leads to the issue that we have to keep many useless macro
   definitions in <acpi/platform/aclinux.h> or <asm/acpi.h>.
   Such conditions include:
     COMPILER_DEPENDENT_UINT64
     COMPILER_DEPENDENT_INT64
     ACPI_INLINE
     ACPI_SYSTEM_XFACE
     ACPI_EXTERNAL_XFACE
     ACPI_INTERNAL_XFACE
     ACPI_INTERNAL_VAR_XFACE
     ACPI_MUTEX_TYPE
     DEBUGGER_THREADING
     ACPI_ACQUIRE_GLOBAL_LOCK
     ACPI_RELEASE_GLOBAL_LOCK
     ACPI_FLUSH_CPU_CACHE
   They have default implementations in <include/acpi/platform/acenv.h>
   while Linux need to keep a copy in <asm/acpi.h> to avoid build errors.
   Typical Linux build error if we deletes COMPILER_DEPENDENT_x and
   ACPI_x_XFACE definitions from asm/acpi.h:
      CC      init/main.o
    In file included from include/acpi/platform/aclinux.h:293:0,
                     from include/acpi/platform/acenv.h:149,
                     from include/acpi/acpi.h:56,
                     from include/linux/acpi.h:41,
                     from init/main.c:27:
    include/acpi/actypes.h:129:1: error: unknown type name 'COMPILER_DEPENDENT_UINT64'
    include/acpi/actypes.h:130:1: error: unknown type name 'COMPILER_DEPENDENT_INT64'
    In file included from include/acpi/platform/aclinux.h:293:0,
                     from include/acpi/platform/acenv.h:149,
                     from include/acpi/acpi.h:56,
                     from include/linux/acpi.h:41,
                     from init/main.c:27:
    include/acpi/actypes.h:1025:21: error: expected ')' before '*' token
    include/acpi/actypes.h:1028:21: error: expected ')' before '*' token
    In file included from include/acpi/acpi.h:63:0,
                     from include/linux/acpi.h:41,
                     from init/main.c:27:
    include/acpi/acpiosxf.h:240:7: error: unknown type name 'acpi_osd_handler'
    include/acpi/acpiosxf.h:247:6: error: unknown type name 'acpi_osd_handler'
    include/acpi/acpiosxf.h:260:3: error: unknown type name 'acpi_osd_exec_callback'

This patch introduces <acpi/platform/aclinuxex.h> to fix this issue by
splitting conditions and declarations (most of them are inline functions)
into 2 header files so that the wrong inclusion of <acpi/actypes.h> can be
removed from <acpi/platform/aclinux.h>.

This patch also removes old ACPI_NATIVE_INTERFACE_HEADER mechanism which is
not preferred by Linux and adds the platform/acenvex.h to be the solution
to solve this issue. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Linux headers: Add <asm/acenv.h> to remove mis-ordered inclusion of <asm/acpi.h> from <acpi/platform/aclinux.h>.

There is a mis-order inclusion for <asm/acpi.h>.

As we will enforce including <linux/acpi.h> for all Linux ACPI users, we
can find the inclusion order is as follows:

<linux/acpi.h>
  <acpi/acpi.h>
   <acpi/platform/acenv.h>
    (acenv.h before including aclinux.h)
    <acpi/platform/aclinux.h>
...........................................................................
     (aclinux.h before including asm/acpi.h)
     <asm/acpi.h>                             @Redundant@
      (ACPICA specific stuff)
...........................................................................
...........................................................................
      (Linux ACPI specific stuff) ? - - - - - - - - - - - - +
     (aclinux.h after including asm/acpi.h)   @Invisible@   |
    (acenv.h after including aclinux.h)       @Invisible@   |
   other ACPICA headers                       @Invisible@   |
............................................................|..............
  <acpi/acpi_bus.h>                                         |
  <acpi/acpi_drivers.h>                                     |
  <asm/acpi.h> (Excluded)                                   |
   (Linux ACPI specific stuff) ! <- - - - - - - - - - - - - +

NOTE that, in ACPICA, <acpi/platform/acenv.h> is more like Kconfig
generated <generated/autoconf.h> for Linux, it is meant to be included
before including any ACPICA code.

In the above figure, there is a question mark for "Linux ACPI specific
stuff" in <asm/acpi.h> which should be included after including all other
ACPICA header files.  Thus they really need to be moved to the position
marked with exclaimation mark or the definitions in the blocks marked with
"@Invisible@" will be invisible to such architecture specific "Linux ACPI
specific stuff" header blocks.  This leaves 2 issues:
1. All environmental definitions in these blocks should have a copy in the
   area marked with "@Redundant@" if they are required by the "Linux ACPI
   specific stuff".
2. We cannot use any ACPICA defined types in <asm/acpi.h>.

This patch splits architecture specific ACPICA stuff from <asm/acpi.h> to
fix this issue. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Linux headers: Cleanup redudant definitions that already have defaults in <acpi/platform/acenv.h>.

Since mis-order issues have been solved, we can cleanup redundant
definitions that already have defaults in <acpi/platform/acenv.h>.

This patch removes redudant environments for __KERNEL__ surrounded code.
Lv Zheng.

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

ACPI hardware reduced mode exists to allow newer platforms to use a
simpler form of ACPI that does not require supporting legacy versions
of the specification and their associated hardware.  This mode was
introduced in the ACPI 5.0 specification.

The ACPI hardware reduced mode is supposed to be used on systems
having the HW_REDUCED_ACPI flag set in the FADT.  ACPICA checks
that flag to determine whether or not it should work in the HW
reduced mode and there are pieces of code in it that will never
be used in that case.

Since some architecutres will always use the ACPI HW reduced mode,
it doesn't make sense for them to ever compile support for anything
else.  Thus, they should set the flag ACPI_REDUCED_HARDWARE to TRUE
in the ACPICA source.  To enable them to do that, introduce a new
kernel configuration option, CONFIG_ACPI_REDUCED_HARDWARE_ONLY, that
will cause the ACPICA's ACPI_REDUCED_HARDWARE flag to be TRUE when
set.

Introducing this configuration item is based on suggestions from Lv
Zheng saying that this does not belong in ACPICA, but rather to the
Linux kernel itself.  Al Stone.

References: http://www.spinics.net/lists/linux-acpi/msg46369.html
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Al Stone <al.stone@linaro.org>
[rjw: Subject and changelog]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Revert "Predefined names: _PRP proposal changed to _DSD"

Reverting the patch while work on the proposed addition remains in flux.
OSL: Cleanup AcpiOsAllocateZeroed() stubs.

This patch implements AcpiOsAllocateZeroed() in generic OSL for
applications that have USE_NATIVE_ALLOCATED_ZEROED enabled.

Some utilities may only include osunixxf.c/oswinxf.c without including
utalloc.c. In such cases the default AcpiOsAllocateZeroed() implementation
is useful. Lv Zheng.

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

This patch cleans up the single threaded application stubs,
AcpiOsGetThreadId() and AcpiOsExecute(), by moving them to the OSL layer,
implemented when ACPI_SINGLE_THREADED is defined.

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

This patch cleans up AcpiOsGetRootPointer() by deleting the
AeLocalGetRootPointer() and adding ACPI_USE_NATIVE_RSDP_POINTER.

The use of AeLocalGetRootPointer(), referenced by osunixxf.c/oswinxf.c,
prevents portable applications that do not have this function implemented
from being able to directly link the useful generic OSL.

This patch uses ACPI_USE_NATIVE_RSDP_POINTER to define whether
AcpiOsGetRootPointer() should be used as a stub. If a utility needs a specific
and functioning AcpiOsGetRootPointer(), it now should define
ACPI_USE_NATIVE_RSDP_POINTER and implement its own.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Utilities: Cleanup use of ACPI_DEBUGGER

The acpinames code defines ACPI_DEBUGGER in order to link
AcpiDbReadTableFromFile(). This patch splits the AcpiDbReadTableFromFile()
function from the debugger and implements it in a generic utilities API so that
acpinames no longer needs to link the debugger for this.

Because acpinames needs access to dump functions, ACPI_DEBUG_OUTPUT needs to be
defined and AcpiDbgLevel needs to be set to maintain consistent behavior.

This patch also cleans up ACPI_DEBUGGER for acpihelp.

This patch is required for removing anstubs.c. Without doing this first,
removing anstubs.c will lead to many link requirements to all debugger and
disassembler objects for acpinames.

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

In order to make acpidump a portable applicatiion it will need to link
osunixxf.c/oswinxf.c, which will create 2 instances of AcpiOsMapMemory() and
AcpiOsUnmapMemory(). This patch introduces ACPI_USE_NATIVE_MEMORY_MAPPING as a
mechanism to exclude using the the generic verisons of these functions in
acpidump.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Merge pull request #33 from zetalog/acpica-linux
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>