diff options
| author | Jung-uk Kim <jkim@FreeBSD.org> | 2013-12-19 05:51:01 +0000 | 
|---|---|---|
| committer | Jung-uk Kim <jkim@FreeBSD.org> | 2013-12-19 05:51:01 +0000 | 
| commit | 86e94f4ac956e0aed23de30c7a458d215f54749a (patch) | |
| tree | 7fcfdcc62c3319ffd669b18b080d40c9c5897210 /source/tools/examples | |
| parent | de06c6b7e0851b337ee530b0ab8818f4216b06b2 (diff) | |
Notes
Diffstat (limited to 'source/tools/examples')
| -rw-r--r-- | source/tools/examples/examples.c | 164 | ||||
| -rw-r--r-- | source/tools/examples/examples.h | 59 | ||||
| -rw-r--r-- | source/tools/examples/exstubs.c | 339 | ||||
| -rw-r--r-- | source/tools/examples/extables.c | 484 | 
4 files changed, 981 insertions, 65 deletions
diff --git a/source/tools/examples/examples.c b/source/tools/examples/examples.c index d90715d84492..ad31945bc273 100644 --- a/source/tools/examples/examples.c +++ b/source/tools/examples/examples.c @@ -1,6 +1,6 @@  /******************************************************************************   * - * Module Name: examples - Example ACPICA code + * Module Name: examples - Example ACPICA initialization and execution code   *   *****************************************************************************/ @@ -41,18 +41,8 @@   * POSSIBILITY OF SUCH DAMAGES.   */ - -/* Set the ACPICA application type for use in include/platform/acenv.h */ - -#ifndef WIN32 -#define WIN32 -#endif - -#define ACPI_DEBUG_OUTPUT - -/* ACPICA public headers */ - -#include "acpi.h" +#define __EXAMPLES_C__ +#include "examples.h"  #define _COMPONENT          ACPI_EXAMPLE          ACPI_MODULE_NAME    ("examples") @@ -81,22 +71,35 @@   *   *****************************************************************************/ -/* Standard Clib headers */ - -#include <stdio.h> -#include <string.h>  /* Local Prototypes */ -ACPI_STATUS -InitializeFullAcpi (void); +static ACPI_STATUS +InitializeFullAcpica (void); -ACPI_STATUS +static ACPI_STATUS  InstallHandlers (void); -void +static void +NotifyHandler ( +    ACPI_HANDLE             Device, +    UINT32                  Value, +    void                    *Context); + +static void +ExecuteMAIN (void); + +static void  ExecuteOSI (void); +ACPI_STATUS +InitializeAcpiTables ( +    void); + +ACPI_STATUS +InitializeAcpi ( +    void); +  /******************************************************************************   * @@ -116,26 +119,28 @@ main (      int                     argc,      char                    **argv)  { -    ACPI_FUNCTION_NAME (Examples-main); -      ACPI_DEBUG_INITIALIZE (); /* For debug version only */ -    InitializeFullAcpi (); -    /* Enable debug output, example debug print */ +    printf (ACPI_COMMON_SIGNON ("ACPI Example Code")); + +    /* Initialize the local ACPI tables (RSDP/RSDT/XSDT/FADT/DSDT/FACS) */ -    AcpiDbgLayer = ACPI_EXAMPLE; -    AcpiDbgLevel = ACPI_LV_INIT; -    ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Example Debug output\n")); +    ExInitializeAcpiTables (); + +    /* Initialize the ACPICA subsystem */ + +    InitializeFullAcpica ();      /* Example warning and error output */ -    ACPI_INFO        ((AE_INFO, "ACPICA example info message")); -    ACPI_WARNING     ((AE_INFO, "ACPICA example warning message")); -    ACPI_ERROR       ((AE_INFO, "ACPICA example error message")); -    ACPI_EXCEPTION   ((AE_INFO, AE_AML_OPERAND_TYPE, "Example exception message")); +    ACPI_INFO        ((AE_INFO, "Example ACPICA info message")); +    ACPI_WARNING     ((AE_INFO, "Example ACPICA warning message")); +    ACPI_ERROR       ((AE_INFO, "Example ACPICA error message")); +    ACPI_EXCEPTION   ((AE_INFO, AE_AML_OPERAND_TYPE, "Example ACPICA exception message"));      ExecuteOSI (); +    ExecuteMAIN ();      return (0);  } @@ -147,8 +152,8 @@ main (   *   *****************************************************************************/ -ACPI_STATUS -InitializeFullAcpi (void) +static ACPI_STATUS +InitializeFullAcpica (void)  {      ACPI_STATUS             Status; @@ -164,6 +169,8 @@ InitializeFullAcpi (void)      /* Initialize the ACPICA Table Manager and get all ACPI tables */ +    ACPI_INFO ((AE_INFO, "Loading ACPI tables")); +      Status = AcpiInitializeTables (NULL, 16, FALSE);      if (ACPI_FAILURE (Status))      { @@ -233,7 +240,8 @@ static ACPI_TABLE_DESC      TableArray[ACPI_MAX_INIT_TABLES];   * is called, all ACPI tables are available to the host.   */  ACPI_STATUS -InitializeAcpiTables (void) +InitializeAcpiTables ( +    void)  {      ACPI_STATUS             Status; @@ -251,7 +259,8 @@ InitializeAcpiTables (void)   * the ACPICA subsystem.   */  ACPI_STATUS -InitializeAcpi (void) +InitializeAcpi ( +    void)  {      ACPI_STATUS             Status; @@ -315,7 +324,7 @@ InitializeAcpi (void)   *   *****************************************************************************/ -void +static void  NotifyHandler (      ACPI_HANDLE                 Device,      UINT32                      Value, @@ -326,7 +335,7 @@ NotifyHandler (  } -ACPI_STATUS +static ACPI_STATUS  InstallHandlers (void)  {      ACPI_STATUS             Status; @@ -348,7 +357,7 @@ InstallHandlers (void)  /******************************************************************************   * - * Example control method execution. + * Examples of control method execution.   *   * _OSI is a predefined method that is implemented internally within ACPICA.   * @@ -362,7 +371,7 @@ InstallHandlers (void)   *   *****************************************************************************/ -void +static void  ExecuteOSI (void)  {      ACPI_STATUS             Status; @@ -372,7 +381,7 @@ ExecuteOSI (void)      ACPI_OBJECT             *Object; -    ACPI_INFO ((AE_INFO, "Executing OSI method")); +    ACPI_INFO ((AE_INFO, "Executing _OSI reserved method"));      /* Setup input argument */ @@ -400,7 +409,7 @@ ExecuteOSI (void)      {          AcpiOsPrintf ("Return value from _OSI method too small, %.8X\n",              ReturnValue.Length); -        return; +        goto ErrorExit;      }      /* Expect an integer return value from execution of _OSI */ @@ -412,39 +421,64 @@ ExecuteOSI (void)      }      ACPI_INFO ((AE_INFO, "_OSI returned 0x%8.8X", (UINT32) Object->Integer.Value)); -    AcpiOsFree (Object); -    return; + + +ErrorExit: + +    /* Free a buffer created via ACPI_ALLOCATE_BUFFER */ + +    AcpiOsFree (ReturnValue.Pointer);  }  /******************************************************************************   * - * OSL support (only needed to link to the windows OSL) + * Execute an actual control method in the DSDT (MAIN)   *   *****************************************************************************/ -FILE    *AcpiGbl_DebugFile; - -ACPI_PHYSICAL_ADDRESS -AeLocalGetRootPointer ( -    void) +static void +ExecuteMAIN (void)  { +    ACPI_STATUS             Status; +    ACPI_OBJECT_LIST        ArgList; +    ACPI_OBJECT             Arg[1]; +    ACPI_BUFFER             ReturnValue; +    ACPI_OBJECT             *Object; -    return (0); -} -ACPI_THREAD_ID -AcpiOsGetThreadId ( -    void) -{ -    return (0xFFFF); -} +    ACPI_INFO ((AE_INFO, "Executing MAIN method")); -ACPI_STATUS -AcpiOsExecute ( -    ACPI_EXECUTE_TYPE       Type, -    ACPI_OSD_EXEC_CALLBACK  Function, -    void                    *Context) -{ -    return (AE_SUPPORT); +    /* Setup input argument */ + +    ArgList.Count = 1; +    ArgList.Pointer = Arg; + +    Arg[0].Type = ACPI_TYPE_STRING; +    Arg[0].String.Pointer = "Method [MAIN] is executing"; +    Arg[0].String.Length = strlen (Arg[0].String.Pointer); + +    /* Ask ACPICA to allocate space for the return object */ + +    ReturnValue.Length = ACPI_ALLOCATE_BUFFER; + +    Status = AcpiEvaluateObject (NULL, "\\MAIN", &ArgList, &ReturnValue); +    if (ACPI_FAILURE (Status)) +    { +        ACPI_EXCEPTION ((AE_INFO, Status, "While executing MAIN")); +        return; +    } + +    if (ReturnValue.Pointer) +    { +        /* Obtain and validate the returned ACPI_OBJECT */ + +        Object = ReturnValue.Pointer; +        if (Object->Type == ACPI_TYPE_STRING) +        { +            AcpiOsPrintf ("Method [MAIN] returned: \"%s\"\n", Object->String.Pointer); +        } + +        ACPI_FREE (ReturnValue.Pointer); +    }  } diff --git a/source/tools/examples/examples.h b/source/tools/examples/examples.h new file mode 100644 index 000000000000..13b8c2d91dd5 --- /dev/null +++ b/source/tools/examples/examples.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * + * Module Name: examples.h - Common include for Examples program + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions, and the following disclaimer, + *    without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *    substantially similar to the "NO WARRANTY" disclaimer below + *    ("Disclaimer") and any redistribution must be conditioned upon + *    including a substantially similar Disclaimer requirement for further + *    binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + *    of any contributors may be used to endorse or promote products derived + *    from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#ifndef _EXAMPLES_H +#define _EXAMPLES_H + +#include "acpi.h" +#include "accommon.h" +#include "acapps.h" +#include "../acpiexec/aecommon.h" + +#include <stdio.h> + + +void +ExInitializeAcpiTables ( +    void); + +#endif diff --git a/source/tools/examples/exstubs.c b/source/tools/examples/exstubs.c new file mode 100644 index 000000000000..7028a883565b --- /dev/null +++ b/source/tools/examples/exstubs.c @@ -0,0 +1,339 @@ +/****************************************************************************** + * + * Module Name: exstubs - Stub routines for the Example program + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions, and the following disclaimer, + *    without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *    substantially similar to the "NO WARRANTY" disclaimer below + *    ("Disclaimer") and any redistribution must be conditioned upon + *    including a substantially similar Disclaimer requirement for further + *    binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + *    of any contributors may be used to endorse or promote products derived + *    from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "examples.h" + +#include <acutils.h> +#include <acevents.h> +#include <acdispat.h> + +#define _COMPONENT          ACPI_EXAMPLE +        ACPI_MODULE_NAME    ("exstubs") + + +/****************************************************************************** + * + * DESCRIPTION: Stubs used to facilitate linkage of the example program + * + *****************************************************************************/ + + +/* Utilities */ + +void +AcpiUtSubsystemShutdown ( +    void) +{ +} + +ACPI_STATUS +AcpiUtExecute_STA ( +    ACPI_NAMESPACE_NODE     *DeviceNode, +    UINT32                  *StatusFlags) +{ +    return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecute_HID ( +    ACPI_NAMESPACE_NODE     *DeviceNode, +    ACPI_PNP_DEVICE_ID      **ReturnId) +{ +    return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecute_CID ( +    ACPI_NAMESPACE_NODE     *DeviceNode, +    ACPI_PNP_DEVICE_ID_LIST **ReturnCidList) +{ +    return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecute_UID ( +    ACPI_NAMESPACE_NODE     *DeviceNode, +    ACPI_PNP_DEVICE_ID      **ReturnId) +{ +    return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecute_SUB ( +    ACPI_NAMESPACE_NODE     *DeviceNode, +    ACPI_PNP_DEVICE_ID      **ReturnId) +{ +    return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtExecutePowerMethods ( +    ACPI_NAMESPACE_NODE     *DeviceNode, +    const char              **MethodNames, +    UINT8                   MethodCount, +    UINT8                   *OutValues) +{ +    return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtEvaluateNumericObject ( +    char                    *ObjectName, +    ACPI_NAMESPACE_NODE     *DeviceNode, +    UINT64                  *Value) +{ +    return (AE_NOT_IMPLEMENTED); +} + +ACPI_STATUS +AcpiUtGetResourceEndTag ( +    ACPI_OPERAND_OBJECT     *ObjDesc, +    UINT8                   **EndTag) +{ +    return (AE_OK); +} + + +/* Hardware manager */ + +UINT32 +AcpiHwGetMode ( +    void) +{ +    return (0); +} + +ACPI_STATUS +AcpiHwReadPort ( +    ACPI_IO_ADDRESS         Address, +    UINT32                  *Value, +    UINT32                  Width) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiHwWritePort ( +    ACPI_IO_ADDRESS         Address, +    UINT32                  Value, +    UINT32                  Width) +{ +    return (AE_OK); +} + + +/* Event manager */ + +ACPI_STATUS +AcpiInstallNotifyHandler ( +    ACPI_HANDLE             Device, +    UINT32                  HandlerType, +    ACPI_NOTIFY_HANDLER     Handler, +    void                    *Context) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiEvInstallXruptHandlers ( +    void) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiEvInitializeEvents ( +    void) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiEvInstallRegionHandlers ( +    void) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiEvInitializeOpRegions ( +    void) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiEvInitializeRegion ( +    ACPI_OPERAND_OBJECT     *RegionObj, +    BOOLEAN                 AcpiNsLocked) +{ +    return (AE_OK); +} + +#if (!ACPI_REDUCED_HARDWARE) +ACPI_STATUS +AcpiEvDeleteGpeBlock ( +    ACPI_GPE_BLOCK_INFO     *GpeBlock) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiEnable ( +    void) +{ +    return (AE_OK); +} +#endif /* !ACPI_REDUCED_HARDWARE */ + +void +AcpiEvUpdateGpes ( +    ACPI_OWNER_ID           TableOwnerId) +{ +} + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( +    ACPI_OPERAND_OBJECT     *RegionObj, +    ACPI_OPERAND_OBJECT     *FieldObj, +    UINT32                  Function, +    UINT32                  RegionOffset, +    UINT32                  BitWidth, +    UINT64                  *Value) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiEvAcquireGlobalLock ( +    UINT16                  Timeout) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiEvReleaseGlobalLock ( +    void) +{ +    return (AE_OK); +} + +ACPI_STATUS +AcpiEvQueueNotifyRequest ( +    ACPI_NAMESPACE_NODE     *Node, +    UINT32                  NotifyValue) +{ +    return (AE_OK); +} + +BOOLEAN +AcpiEvIsNotifyObject ( +    ACPI_NAMESPACE_NODE     *Node) +{ +    return (TRUE); +} + + +/* Namespace manager */ + +ACPI_STATUS +AcpiNsCheckReturnValue ( +    ACPI_NAMESPACE_NODE         *Node, +    ACPI_EVALUATE_INFO          *Info, +    UINT32                      UserParamCount, +    ACPI_STATUS                 ReturnStatus, +    ACPI_OPERAND_OBJECT         **ReturnObjectPtr) +{ +    return (AE_OK); +} + +void +AcpiNsCheckArgumentTypes ( +    ACPI_EVALUATE_INFO          *Info) +{ +    return; +} + +void +AcpiNsCheckArgumentCount ( +    char                        *Pathname, +    ACPI_NAMESPACE_NODE         *Node, +    UINT32                      UserParamCount, +    const ACPI_PREDEFINED_INFO  *Predefined) +{ +    return; +} + +void +AcpiNsCheckAcpiCompliance ( +    char                        *Pathname, +    ACPI_NAMESPACE_NODE         *Node, +    const ACPI_PREDEFINED_INFO  *Predefined) +{ +    return; +} + +const ACPI_PREDEFINED_INFO * +AcpiUtMatchPredefinedMethod ( +    char                        *Name) +{ +    return (NULL); +} + +/* OSL interfaces */ + +ACPI_THREAD_ID +AcpiOsGetThreadId ( +    void) +{ +    return (1); +} + +ACPI_STATUS +AcpiOsExecute ( +    ACPI_EXECUTE_TYPE       Type, +    ACPI_OSD_EXEC_CALLBACK  Function, +    void                    *Context) +{ +    return (AE_SUPPORT); +} diff --git a/source/tools/examples/extables.c b/source/tools/examples/extables.c new file mode 100644 index 000000000000..307fe2f2977e --- /dev/null +++ b/source/tools/examples/extables.c @@ -0,0 +1,484 @@ +/****************************************************************************** + * + * Module Name: extables - ACPI tables for Example program + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions, and the following disclaimer, + *    without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *    substantially similar to the "NO WARRANTY" disclaimer below + *    ("Disclaimer") and any redistribution must be conditioned upon + *    including a substantially similar Disclaimer requirement for further + *    binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + *    of any contributors may be used to endorse or promote products derived + *    from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#define __EXTABLES_C__ + +#include "examples.h" +#include "actables.h" + +#define _COMPONENT          ACPI_EXAMPLE +        ACPI_MODULE_NAME    ("extables") + +ACPI_PHYSICAL_ADDRESS +AeLocalGetRootPointer ( +    void); + + +/****************************************************************************** + * + * ACPICA Example tables and table setup + * + * This module contains the ACPI tables used for the example program. The + * original source code for the tables appears at the end of the module. + * + *****************************************************************************/ + + +/* These tables will be modified at runtime */ + +unsigned char RsdpCode[] = +{ +    0x52,0x53,0x44,0x20,0x50,0x54,0x52,0x20,  /* 00000000    "RSD PTR " */ +    0x43,0x49,0x4E,0x54,0x45,0x4C,0x20,0x02,  /* 00000008    "CINTEL ." */ +    0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x00,  /* 00000010    "....$..." */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000018    "........" */ +    0xDC,0x00,0x00,0x00                       /* 00000020    "...."     */ +}; + +unsigned char RsdtCode[] = +{ +    0x52,0x53,0x44,0x54,0x28,0x00,0x00,0x00,  /* 00000000    "RSDT(..." */ +    0x01,0x10,0x49,0x4E,0x54,0x45,0x4C,0x20,  /* 00000008    "..INTEL " */ +    0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45,  /* 00000010    "TEMPLATE" */ +    0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */ +    0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00   /* 00000020    "... ...." */ +}; + +unsigned char XsdtCode[] = +{ +    0x58,0x53,0x44,0x54,0x2C,0x00,0x00,0x00,  /* 00000000    "XSDT,..." */ +    0x01,0x06,0x49,0x4E,0x54,0x45,0x4C,0x20,  /* 00000008    "..INTEL " */ +    0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45,  /* 00000010    "TEMPLATE" */ +    0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */ +    0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00,  /* 00000020    "... ...." */ +    0x00,0x00,0x00,0x00                       /* 00000028    "...."     */ +}; + +unsigned char FadtCode[] = +{ +    0x46,0x41,0x43,0x50,0x0C,0x01,0x00,0x00,  /* 00000000    "FACP...." */ +    0x05,0x64,0x49,0x4E,0x54,0x45,0x4C,0x20,  /* 00000008    ".dINTEL " */ +    0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45,  /* 00000010    "TEMPLATE" */ +    0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */ +    0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00,  /* 00000020    "... ...." */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000028    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000030    "........" */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000038    "........" */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000040    "........" */ +    0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,  /* 00000048    "........" */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000050    "........" */ +    0x04,0x02,0x01,0x04,0x08,0x00,0x00,0x00,  /* 00000058    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000060    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000068    "........" */ +    0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01,  /* 00000070    "........" */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000078    "........" */ +    0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,  /* 00000080    "........" */ +    0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,  /* 00000088    "........" */ +    0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x02,  /* 00000090    "..... .." */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000098    "........" */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000A0    "........" */ +    0x00,0x00,0x00,0x00,0x01,0x10,0x00,0x02,  /* 000000A8    "........" */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000B0    "........" */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000B8    "........" */ +    0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x00,  /* 000000C0    "........" */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000C8    "........" */ +    0x01,0x20,0x00,0x03,0x01,0x00,0x00,0x00,  /* 000000D0    ". ......" */ +    0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x01,  /* 000000D8    ".....@.." */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000E0    "........" */ +    0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000E8    "........" */ +    0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01,  /* 000000F0    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000F8    "........" */ +    0x01,0x08,0x00,0x01,0x00,0x00,0x00,0x00,  /* 00000100    "........" */ +    0x00,0x00,0x00,0x00                       /* 00000108    "...."     */ +}; + +/* Fixed tables */ + +static unsigned char FacsCode[] = +{ +    0x46,0x41,0x43,0x53,0x40,0x00,0x00,0x00,  /* 00000000    "FACS@..." */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000008    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000018    "........" */ +    0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000020    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000028    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000030    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00   /* 00000038    "........" */ +}; + +static unsigned char DsdtCode[] = +{ +    0x44,0x53,0x44,0x54,0x67,0x00,0x00,0x00,  /* 00000000    "DSDTg..." */ +    0x02,0x97,0x49,0x6E,0x74,0x65,0x6C,0x00,  /* 00000008    "..Intel." */ +    0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65,  /* 00000010    "Template" */ +    0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */ +    0x15,0x11,0x13,0x20,0x14,0x42,0x04,0x4D,  /* 00000020    "... .B.M" */ +    0x41,0x49,0x4E,0x01,0x70,0x73,0x0D,0x4D,  /* 00000028    "AIN.ps.M" */ +    0x61,0x69,0x6E,0x2F,0x41,0x72,0x67,0x30,  /* 00000030    "ain/Arg0" */ +    0x3A,0x20,0x00,0x68,0x00,0x5B,0x31,0xA4,  /* 00000038    ": .h.[1." */ +    0x0D,0x4D,0x61,0x69,0x6E,0x20,0x73,0x75,  /* 00000040    ".Main su" */ +    0x63,0x63,0x65,0x73,0x73,0x66,0x75,0x6C,  /* 00000048    "ccessful" */ +    0x6C,0x79,0x20,0x63,0x6F,0x6D,0x70,0x6C,  /* 00000050    "ly compl" */ +    0x65,0x74,0x65,0x64,0x20,0x65,0x78,0x65,  /* 00000058    "eted exe" */ +    0x63,0x75,0x74,0x69,0x6F,0x6E,0x00        /* 00000060    "cution."  */ +}; + + +/* Useful pointers */ + +ACPI_TABLE_RSDP *Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, RsdpCode); +ACPI_TABLE_RSDT *Rsdt = ACPI_CAST_PTR (ACPI_TABLE_RSDT, RsdtCode); +ACPI_TABLE_XSDT *Xsdt = ACPI_CAST_PTR (ACPI_TABLE_XSDT, XsdtCode); +ACPI_TABLE_FADT *Fadt = ACPI_CAST_PTR (ACPI_TABLE_FADT, FadtCode); + + +/****************************************************************************** + * + * Build the various required ACPI tables: + * + * 1) Setup RSDP to point to the RSDT and XSDT + * 2) Setup RSDT/XSDT to point to the FADT + * 3) Setup FADT to point to the DSDT and FACS + * 4) Update checksums for all modified tables + * + *****************************************************************************/ + +void +ExInitializeAcpiTables ( +    void) +{ + +    /* Setup RSDP */ + +    Rsdp->RsdtPhysicalAddress = (UINT32) ACPI_TO_INTEGER (RsdtCode); +    Rsdp->XsdtPhysicalAddress = (UINT64) ACPI_TO_INTEGER (XsdtCode); + +    /* RSDT and XSDT */ + +    Rsdt->TableOffsetEntry[0] = (UINT32) ACPI_TO_INTEGER (FadtCode); +    Xsdt->TableOffsetEntry[0] = (UINT64) ACPI_TO_INTEGER (FadtCode); + +    /* FADT */ + +    Fadt->Facs = 0; +    Fadt->Dsdt = 0; +    Fadt->XFacs = (UINT64) ACPI_TO_INTEGER (FacsCode); +    Fadt->XDsdt = (UINT64) ACPI_TO_INTEGER (DsdtCode); + +    /* Set new checksums for the modified tables */ + +    Rsdp->Checksum = 0; +    Rsdp->Checksum = (UINT8) -AcpiTbChecksum ( +        (void *) RsdpCode, ACPI_RSDP_CHECKSUM_LENGTH); + +    Rsdt->Header.Checksum = 0; +    Rsdt->Header.Checksum = (UINT8) -AcpiTbChecksum ( +        (void *) Rsdt, Rsdt->Header.Length); + +    Xsdt->Header.Checksum = 0; +    Xsdt->Header.Checksum =  (UINT8) -AcpiTbChecksum ( +        (void *) Xsdt, Xsdt->Header.Length); + +    Fadt->Header.Checksum = 0; +    Fadt->Header.Checksum =  (UINT8) -AcpiTbChecksum ( +        (void *) Fadt, Fadt->Header.Length); +} + + +/****************************************************************************** + * + * OSL support - return the address of the RSDP + * + *****************************************************************************/ + +ACPI_PHYSICAL_ADDRESS +AeLocalGetRootPointer ( +    void) +{ + +    return ((ACPI_PHYSICAL_ADDRESS) RsdpCode); +} + + +#ifdef DO_NOT_COMPILE_ACPI_TABLE_CODE +/****************************************************************************** + * + * ACPICA Example table source code + * + * This is the original source code for the tables above + * + *****************************************************************************/ + +/* RSDP */ + +[0008]                          Signature : "RSD PTR " +[0001]                           Checksum : 43 +[0006]                             Oem ID : "INTEL " +[0001]                           Revision : 02 +[0004]                       RSDT Address : 00000000 +[0004]                             Length : 00000024 +[0008]                       XSDT Address : 0000000000000000 +[0001]                  Extended Checksum : DC +[0003]                           Reserved : 000000 + + +/* RSDT */ + +[0004]                          Signature : "RSDT"    [Root System Description Table] +[0004]                       Table Length : 00000044 +[0001]                           Revision : 01 +[0001]                           Checksum : B1 +[0006]                             Oem ID : "INTEL " +[0008]                       Oem Table ID : "TEMPLATE" +[0004]                       Oem Revision : 00000001 +[0004]                    Asl Compiler ID : "INTL" +[0004]              Asl Compiler Revision : 20100528 + +[0004]             ACPI Table Address   0 : 00000001 + + +/* XSDT */ + +[0004]                          Signature : "XSDT"    [Extended System Description Table] +[0004]                       Table Length : 00000064 +[0001]                           Revision : 01 +[0001]                           Checksum : 8B +[0006]                             Oem ID : "INTEL " +[0008]                       Oem Table ID : "TEMPLATE" +[0004]                       Oem Revision : 00000001 +[0004]                    Asl Compiler ID : "INTL" +[0004]              Asl Compiler Revision : 20100528 + +[0008]             ACPI Table Address   0 : 0000000000000001 + + +/* FADT */ + +[0004]                          Signature : "FACP"    [Fixed ACPI Description Table (FADT)] +[0004]                       Table Length : 0000010C +[0001]                           Revision : 05 +[0001]                           Checksum : 18 +[0006]                             Oem ID : "INTEL " +[0008]                       Oem Table ID : "TEMPLATE" +[0004]                       Oem Revision : 00000000 +[0004]                    Asl Compiler ID : "INTL" +[0004]              Asl Compiler Revision : 20111123 + +[0004]                       FACS Address : 00000001 +[0004]                       DSDT Address : 00000001 +[0001]                              Model : 00 +[0001]                         PM Profile : 00 [Unspecified] +[0002]                      SCI Interrupt : 0000 +[0004]                   SMI Command Port : 00000000 +[0001]                  ACPI Enable Value : 00 +[0001]                 ACPI Disable Value : 00 +[0001]                     S4BIOS Command : 00 +[0001]                    P-State Control : 00 +[0004]           PM1A Event Block Address : 00000001 +[0004]           PM1B Event Block Address : 00000000 +[0004]         PM1A Control Block Address : 00000001 +[0004]         PM1B Control Block Address : 00000000 +[0004]          PM2 Control Block Address : 00000001 +[0004]             PM Timer Block Address : 00000001 +[0004]                 GPE0 Block Address : 00000001 +[0004]                 GPE1 Block Address : 00000000 +[0001]             PM1 Event Block Length : 04 +[0001]           PM1 Control Block Length : 02 +[0001]           PM2 Control Block Length : 01 +[0001]              PM Timer Block Length : 04 +[0001]                  GPE0 Block Length : 08 +[0001]                  GPE1 Block Length : 00 +[0001]                   GPE1 Base Offset : 00 +[0001]                       _CST Support : 00 +[0002]                         C2 Latency : 0000 +[0002]                         C3 Latency : 0000 +[0002]                     CPU Cache Size : 0000 +[0002]                 Cache Flush Stride : 0000 +[0001]                  Duty Cycle Offset : 00 +[0001]                   Duty Cycle Width : 00 +[0001]                RTC Day Alarm Index : 00 +[0001]              RTC Month Alarm Index : 00 +[0001]                  RTC Century Index : 00 +[0002]         Boot Flags (decoded below) : 0000 +            Legacy Devices Supported (V2) : 0 +         8042 Present on ports 60/64 (V2) : 0 +                     VGA Not Present (V4) : 0 +                   MSI Not Supported (V4) : 0 +             PCIe ASPM Not Supported (V4) : 0 +                CMOS RTC Not Present (V5) : 0 +[0001]                           Reserved : 00 +[0004]              Flags (decoded below) : 00000000 +   WBINVD instruction is operational (V1) : 0 +           WBINVD flushes all caches (V1) : 0 +                 All CPUs support C1 (V1) : 0 +               C2 works on MP system (V1) : 0 +         Control Method Power Button (V1) : 0 +         Control Method Sleep Button (V1) : 0 +     RTC wake not in fixed reg space (V1) : 0 +         RTC can wake system from S4 (V1) : 0 +                     32-bit PM Timer (V1) : 0 +                   Docking Supported (V1) : 0 +            Reset Register Supported (V2) : 0 +                         Sealed Case (V3) : 0 +                 Headless - No Video (V3) : 0 +     Use native instr after SLP_TYPx (V3) : 0 +           PCIEXP_WAK Bits Supported (V4) : 0 +                  Use Platform Timer (V4) : 0 +            RTC_STS valid on S4 wake (V4) : 0 +             Remote Power-on capable (V4) : 0 +              Use APIC Cluster Model (V4) : 0 +  Use APIC Physical Destination Mode (V4) : 0 +                    Hardware Reduced (V5) : 0 +                   Low Power S0 Idle (V5) : 0 + +[0012]                     Reset Register : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 08 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 01 [Byte Access:8] +[0008]                            Address : 0000000000000001 + +[0001]               Value to cause reset : 00 +[0003]                           Reserved : 000000 +[0008]                       FACS Address : 0000000000000001 +[0008]                       DSDT Address : 0000000000000001 +[0012]                   PM1A Event Block : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 20 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 02 [Word Access:16] +[0008]                            Address : 0000000000000001 + +[0012]                   PM1B Event Block : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 00 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 00 [Undefined/Legacy] +[0008]                            Address : 0000000000000000 + +[0012]                 PM1A Control Block : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 10 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 02 [Word Access:16] +[0008]                            Address : 0000000000000001 + +[0012]                 PM1B Control Block : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 00 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 00 [Undefined/Legacy] +[0008]                            Address : 0000000000000000 + +[0012]                  PM2 Control Block : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 08 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 00 [Undefined/Legacy] +[0008]                            Address : 0000000000000001 + +[0012]                     PM Timer Block : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 20 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 03 [DWord Access:32] +[0008]                            Address : 0000000000000001 + +[0012]                         GPE0 Block : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 40 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 01 [Byte Access:8] +[0008]                            Address : 0000000000000001 + +[0012]                         GPE1 Block : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 00 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 00 [Undefined/Legacy] +[0008]                            Address : 0000000000000000 + + +[0012]             Sleep Control Register : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 08 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 01 [Byte Access:8] +[0008]                            Address : 0000000000000000 + +[0012]              Sleep Status Register : [Generic Address Structure] +[0001]                           Space ID : 01 [SystemIO] +[0001]                          Bit Width : 08 +[0001]                         Bit Offset : 00 +[0001]               Encoded Access Width : 01 [Byte Access:8] +[0008]                            Address : 0000000000000000 + + +/* FACS */ + +[0004]                          Signature : "FACS" +[0004]                             Length : 00000040 +[0004]                 Hardware Signature : 00000000 +[0004]          32 Firmware Waking Vector : 00000000 +[0004]                        Global Lock : 00000000 +[0004]              Flags (decoded below) : 00000000 +                   S4BIOS Support Present : 0 +               64-bit Wake Supported (V2) : 0 +[0008]          64 Firmware Waking Vector : 0000000000000000 +[0001]                            Version : 02 +[0003]                           Reserved : 000000 +[0004]          OspmFlags (decoded below) : 00000000 +            64-bit Wake Env Required (V2) : 0 + + +/* DSDT - ASL code */ + +DefinitionBlock ("dsdt.aml", "DSDT", 2, "Intel", "Template", 0x00000001) +{ +    Method (MAIN, 1, NotSerialized) +    { +        Store (Concatenate ("Main/Arg0: ", Arg0), Debug) +        Return ("Main successfully completed execution") +    } +} +#endif  | 
