ACPICA / OSL: Add configurability mechanism for global variables.

This patch extends ACPI_INIT_GLOBAL mechanism to all global variables
so that the OSPMs can have full control to configure them into immediates.
This patch doesn't include any code for Linux to utilize this mechanism.

Linux practice shows there are external users out of Linux ACPI subsystem
checking ACPICA provided global variables.  Linux trends to protect such
global variables by defining them to default values when specific Kconfig
items are not enabled (particular to ACPICA, it should be CONFIG_ACPI) or
Linux will suffer from build errors complaining the absense of such global
variables.

This patch converts all ACPICA global variables into macro wrapped so that
OSPMs can configure such global variables out by defining ACPI_GLOBAL and
ACPI_INIT_GLOBAL into no-ops.  For the code still referencing such globals
when ACPICA is configured out, OSPMs can either define global variable
symbols into constant variables (static const if it doesn't increase the
size of the OSPMs' binary image) or maintain a big list of the macros in
the "#define AcpiGbl_x v" style.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / Linux: Add configurability for external globals.

Linux tends to include all header files but leave empty inline
stub variables for a feature that is not configured during build.

This patch configures ACPICA external globals out and defines them into
immediates when CONFIG_ACPI is not enabled.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / Linux: Add configurability for OSL APIs.

Linux tends to include all header files but leave empty inline
stub variables for a feature that is not configured during build.
This patch configures ACPICA internal OSL prototypes out when ACPI is
disabled to facilitate Linux with such configurability.

Note that this patch is generated in the assumption that all ACPICA OSL
APIs should only be used by ACPICA itself.  While the real world is there
are some external ACPICA macros called ACPICA OSL APIs.  This patch
doesn't include protections around the OSL APIs that are used by such
ACPICA external macros.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / OSL: Clean up external macros and add stubs for macros.

Linux tends to include all header files but leave empty stub
macros for a feature that is not configured during build.

For macros defined to constants or defined to functions without other
functions referencesd (exceptions are ACPI_ALLOCATE_BUFFER and
ACPI_OFFSET-like macros), it is safe to leave them without protections.

By investigation, there are only the following internal/external
functions referenced by the ACPICA macros:
1. C library functions, including string, ctype, stdarg APIs.  Such
   functionalities are always accessbile in the kernel source tree, so
   it is safe to leave them without protected for Linux.
2. ACPICA OSL functions, such functions are designed to be used only by
   ACPICA internal APIs.  But in the Linux kernel, there are references
   in the macros referencing mutex and memory allocation APIs.
   Fortunately, there is no external users directly invoking ACPI_MUTEX
   OSL functions.  But for ACPI_ALLOCATE and ACPI_ALLOCATE_BUFFER, there
   are AcpiOsFree or kfree called as their reversals.  This patch adds
   mechanism to protect ACPICA memory allocation APIs for Linux so that
   Linux can have full control of such macros to configure them into
   no-ops.
3. ACPI_OFFSET and other macros that would access structure members that
   are not accessible under a specific configuration.  Fortunately,
   currently Linux doesn't use such structure members when CONFIG_ACPI
   is disabled.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / OSL: Add configurability to error message functions.

This patch extends ACPI_HW_DEPENDENT_x mechanism to all error message
related functions so that the OSPMs can have full control to configure
them into stub functions.
This patch also includes code for Linux to use this new mechanism for
the code that is built without CONFIG_ACPI enabled.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / OSL: Add configurability to debug output functions.

This patch extends ACPI_HW_DEPENDENT_x mechanism to all debugging output
related functions so that the OSPMs can have full control to configure
them into stub functions.
This patch also includes code for Linux to use this new mechanism for
the code that is built without CONFIG_ACPI enabled.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / OSL: Add configurability mechanism for external APIs.

Linux tends to include all header files but leave empty inline
stub functions for a feature that is not configured during build.
This patch adds wrappers mechanism to be used around ACPICA external
interfaces to facilitate OSPM with such configurability.
This patch doesn't include code for Linux to use this mechanism.

Note that in order to the reduce the difficulties caused by the source code
differences between Linux and ACPICA upstream of maintaining large
ACPI_EXTERNAL_RETURN_x macro updates, actual ACPI_EXTERNAL_RETURN_x macro
usages are done and split into other commits.

ACPICA commits will be "linuxized" by the scripts. If there were
divergences in the middle of a diff block, the "linuxized" diff block
should require human intervention to be performed to make it possible
to apply the commit into the Linux source tree.  Sometime such human
intervention will be very difficult as the "linuxized" commits will
be messed up in addition to the normal line offsettings by the
patch/diff based utilities.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / OSL: Update ACPI_EXTERNAL_RETURN_x usages for external APIs.

Linux tends to include all header files but leave empty inline
stub variables for a feature that is not configured during build.

This patch configures ACPICA external APIs out and defines them into
function stubs when CONFIG_ACPI is not enabled.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / Linux: Add stub support for Linux specific variables and functions.

There are global variables and functions not upstreamed to the ACPICA code
base.  Such symbols still can be referenced by external users as they are
listed in the acpixf.h.  This patch uses ACPI_GLOBAL and
ACPI_EXTERNAL_RETURN_STATUS mechanism to add stub support for such symbols.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / Linux: Add architecture specific ACPICA headers.

The target is to allow inclusion of <acpi/acpi.h> for CONFIG_ACPI=n build.

This patch tries to achieve this by splitting architecture specific ACPICA
implementation from <asm/acpi.h> into <asm/acenv.h> to improve
maintainability.  Then <asm/acpi.h> could be treated as the architecture
specific part of <linux/acpi.h>, <acpi/acpi_bus.h>,
<acpi/acpi_drivers.h>.

It is necessary to delete <asm/acpi.h> from aclinux.h to achieve the
CONFIG_ACPI=n build target, but to avoid affecting the Linux build
process, that requires further cleanup on <linux/acpi.h>,
<acpi/acpi_bus.h>, <acpi/acpi_drivers.h> inclusions in advance.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / Linux: Add stub implementation of ACPICA 64-bit arithmetics.

This patch adds default 64-bit arithmetics to aclinux.h using do_div.  As
do_div can be used for all Linux architectures, this can also be used as
stub macros for ACPICA 64-bit arithmetics.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA / Linux: Add configuration item to indicate the architecture specific support.

This patch adds a kernel configuration item to indicate the presense of
the architecture specific support for ACPICA, so that <asm/acenv.h>
inclusion can be configured out.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPICA: Linux: Remove <asm/acpi.h> inclusion from ACPICA headers.

This patch removes <asm/acpi.h> inclusion from <acpi/platform/aclinux.h> as
it no longer contains useful prototypes for ACPICA.

It also introduces a top level header <linux/acpica.h> to be
included by other kernel source code.

Note that this patch changes the logic so that ACPICA header files
inclusions are no longer dependent on CONFIG_ACPI=y environment.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / SFI: Fix wrong <acpi/acpi.h> inclusion in SFI/ACPI wrapper.

This patch removes <acpi/acpi.h> inclusions from <linux/sfi_acpi.h> as
<linux/acpi.h> has already included it for CONFIG_ACPI=n builds.

Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'acpica-next' into bleeding-edge

* acpica-next:
  ACPI / SFI: Fix wrong <acpi/acpi.h> inclusion in SFI/ACPI wrapper.
  ACPICA: Linux: Remove <asm/acpi.h> inclusion from ACPICA headers.
  ACPICA / Linux: Add configuration item to indicate the architecture specific support.
  ACPICA / Linux: Add stub implementation of ACPICA 64-bit arithmetics.
  ACPICA / Linux: Add architecture specific ACPICA headers.
  ACPICA / Linux: Add stub support for Linux specific variables and functions.
  ACPICA / OSL: Update ACPI_EXTERNAL_RETURN_x usages for external APIs.
  ACPICA / OSL: Add configurability mechanism for external APIs.
  ACPICA / OSL: Add configurability to debug output functions.
  ACPICA / OSL: Add configurability to error message functions.
  ACPICA / OSL: Clean up external macros and add stubs for macros.
  ACPICA / Linux: Add configurability for OSL APIs.
  ACPICA / Linux: Add configurability for external globals.
  ACPICA / OSL: Add configurability mechanism for global variables.