Home | History | Annotate | Line # | Download | only in examples
examples.c revision 1.1.1.4
      1      1.1    jruoho /******************************************************************************
      2      1.1    jruoho  *
      3  1.1.1.4  christos  * Module Name: examples - Example ACPICA initialization and execution code
      4      1.1    jruoho  *
      5      1.1    jruoho  *****************************************************************************/
      6      1.1    jruoho 
      7  1.1.1.2    jruoho /*
      8  1.1.1.4  christos  * Copyright (C) 2000 - 2013, Intel Corp.
      9      1.1    jruoho  * All rights reserved.
     10      1.1    jruoho  *
     11  1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13  1.1.1.2    jruoho  * are met:
     14  1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.2    jruoho  *    without modification.
     17  1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.2    jruoho  *    binary redistribution.
     22  1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25  1.1.1.2    jruoho  *
     26  1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.2    jruoho  * Software Foundation.
     29  1.1.1.2    jruoho  *
     30  1.1.1.2    jruoho  * NO WARRANTY
     31  1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.2    jruoho  */
     43      1.1    jruoho 
     44  1.1.1.4  christos #define __EXAMPLES_C__
     45  1.1.1.4  christos #include "examples.h"
     46      1.1    jruoho 
     47      1.1    jruoho #define _COMPONENT          ACPI_EXAMPLE
     48      1.1    jruoho         ACPI_MODULE_NAME    ("examples")
     49      1.1    jruoho 
     50      1.1    jruoho 
     51      1.1    jruoho /******************************************************************************
     52      1.1    jruoho  *
     53      1.1    jruoho  * ACPICA Example Code
     54      1.1    jruoho  *
     55      1.1    jruoho  * This module contains examples of how the host OS should interface to the
     56      1.1    jruoho  * ACPICA subsystem.
     57      1.1    jruoho  *
     58      1.1    jruoho  * 1) How to use the platform/acenv.h file and how to set configuration
     59      1.1    jruoho  *      options.
     60      1.1    jruoho  *
     61      1.1    jruoho  * 2) main - using the debug output mechanism and the error/warning output
     62      1.1    jruoho  *      macros.
     63      1.1    jruoho  *
     64      1.1    jruoho  * 3) Two examples of the ACPICA initialization sequence. The first is a
     65      1.1    jruoho  *      initialization with no "early" ACPI table access. The second shows
     66      1.1    jruoho  *      how to use ACPICA to obtain the tables very early during kernel
     67      1.1    jruoho  *      initialization, even before dynamic memory is available.
     68      1.1    jruoho  *
     69      1.1    jruoho  * 4) How to invoke a control method, including argument setup and how to
     70      1.1    jruoho  *      access the return value.
     71      1.1    jruoho  *
     72      1.1    jruoho  *****************************************************************************/
     73      1.1    jruoho 
     74      1.1    jruoho 
     75      1.1    jruoho /* Local Prototypes */
     76      1.1    jruoho 
     77  1.1.1.4  christos static ACPI_STATUS
     78  1.1.1.4  christos InitializeFullAcpica (void);
     79      1.1    jruoho 
     80  1.1.1.4  christos static ACPI_STATUS
     81      1.1    jruoho InstallHandlers (void);
     82      1.1    jruoho 
     83  1.1.1.4  christos static void
     84  1.1.1.4  christos NotifyHandler (
     85  1.1.1.4  christos     ACPI_HANDLE             Device,
     86  1.1.1.4  christos     UINT32                  Value,
     87  1.1.1.4  christos     void                    *Context);
     88  1.1.1.4  christos 
     89  1.1.1.4  christos static void
     90  1.1.1.4  christos ExecuteMAIN (void);
     91  1.1.1.4  christos 
     92  1.1.1.4  christos static void
     93      1.1    jruoho ExecuteOSI (void);
     94      1.1    jruoho 
     95  1.1.1.4  christos ACPI_STATUS
     96  1.1.1.4  christos InitializeAcpiTables (
     97  1.1.1.4  christos     void);
     98  1.1.1.4  christos 
     99  1.1.1.4  christos ACPI_STATUS
    100  1.1.1.4  christos InitializeAcpi (
    101  1.1.1.4  christos     void);
    102  1.1.1.4  christos 
    103      1.1    jruoho 
    104      1.1    jruoho /******************************************************************************
    105      1.1    jruoho  *
    106      1.1    jruoho  * FUNCTION:    main
    107      1.1    jruoho  *
    108      1.1    jruoho  * PARAMETERS:  argc, argv
    109      1.1    jruoho  *
    110      1.1    jruoho  * RETURN:      Status
    111      1.1    jruoho  *
    112      1.1    jruoho  * DESCRIPTION: Main routine. Shows the use of the various output macros, as
    113      1.1    jruoho  *              well as the use of the debug layer/level globals.
    114      1.1    jruoho  *
    115      1.1    jruoho  *****************************************************************************/
    116      1.1    jruoho 
    117      1.1    jruoho int ACPI_SYSTEM_XFACE
    118      1.1    jruoho main (
    119      1.1    jruoho     int                     argc,
    120      1.1    jruoho     char                    **argv)
    121      1.1    jruoho {
    122      1.1    jruoho 
    123  1.1.1.4  christos     ACPI_DEBUG_INITIALIZE (); /* For debug version only */
    124  1.1.1.4  christos 
    125  1.1.1.4  christos     printf (ACPI_COMMON_SIGNON ("ACPI Example Code"));
    126      1.1    jruoho 
    127  1.1.1.4  christos     /* Initialize the local ACPI tables (RSDP/RSDT/XSDT/FADT/DSDT/FACS) */
    128      1.1    jruoho 
    129  1.1.1.4  christos     ExInitializeAcpiTables ();
    130      1.1    jruoho 
    131  1.1.1.4  christos     /* Initialize the ACPICA subsystem */
    132  1.1.1.4  christos 
    133  1.1.1.4  christos     InitializeFullAcpica ();
    134      1.1    jruoho 
    135      1.1    jruoho     /* Example warning and error output */
    136      1.1    jruoho 
    137  1.1.1.4  christos     ACPI_INFO        ((AE_INFO, "Example ACPICA info message"));
    138  1.1.1.4  christos     ACPI_WARNING     ((AE_INFO, "Example ACPICA warning message"));
    139  1.1.1.4  christos     ACPI_ERROR       ((AE_INFO, "Example ACPICA error message"));
    140  1.1.1.4  christos     ACPI_EXCEPTION   ((AE_INFO, AE_AML_OPERAND_TYPE, "Example ACPICA exception message"));
    141      1.1    jruoho 
    142      1.1    jruoho     ExecuteOSI ();
    143  1.1.1.4  christos     ExecuteMAIN ();
    144      1.1    jruoho     return (0);
    145      1.1    jruoho }
    146      1.1    jruoho 
    147      1.1    jruoho 
    148      1.1    jruoho /******************************************************************************
    149      1.1    jruoho  *
    150      1.1    jruoho  * Example ACPICA initialization code. This shows a full initialization with
    151      1.1    jruoho  * no early ACPI table access.
    152      1.1    jruoho  *
    153      1.1    jruoho  *****************************************************************************/
    154      1.1    jruoho 
    155  1.1.1.4  christos static ACPI_STATUS
    156  1.1.1.4  christos InitializeFullAcpica (void)
    157      1.1    jruoho {
    158      1.1    jruoho     ACPI_STATUS             Status;
    159      1.1    jruoho 
    160      1.1    jruoho 
    161      1.1    jruoho     /* Initialize the ACPICA subsystem */
    162      1.1    jruoho 
    163      1.1    jruoho     Status = AcpiInitializeSubsystem ();
    164      1.1    jruoho     if (ACPI_FAILURE (Status))
    165      1.1    jruoho     {
    166      1.1    jruoho         ACPI_EXCEPTION ((AE_INFO, Status, "While initializing ACPICA"));
    167      1.1    jruoho         return (Status);
    168      1.1    jruoho     }
    169      1.1    jruoho 
    170      1.1    jruoho     /* Initialize the ACPICA Table Manager and get all ACPI tables */
    171      1.1    jruoho 
    172  1.1.1.4  christos     ACPI_INFO ((AE_INFO, "Loading ACPI tables"));
    173  1.1.1.4  christos 
    174      1.1    jruoho     Status = AcpiInitializeTables (NULL, 16, FALSE);
    175      1.1    jruoho     if (ACPI_FAILURE (Status))
    176      1.1    jruoho     {
    177      1.1    jruoho         ACPI_EXCEPTION ((AE_INFO, Status, "While initializing Table Manager"));
    178      1.1    jruoho         return (Status);
    179      1.1    jruoho     }
    180      1.1    jruoho 
    181      1.1    jruoho     /* Create the ACPI namespace from ACPI tables */
    182      1.1    jruoho 
    183      1.1    jruoho     Status = AcpiLoadTables ();
    184      1.1    jruoho     if (ACPI_FAILURE (Status))
    185      1.1    jruoho     {
    186      1.1    jruoho         ACPI_EXCEPTION ((AE_INFO, Status, "While loading ACPI tables"));
    187      1.1    jruoho         return (Status);
    188      1.1    jruoho     }
    189      1.1    jruoho 
    190      1.1    jruoho     /* Install local handlers */
    191      1.1    jruoho 
    192      1.1    jruoho     Status = InstallHandlers ();
    193      1.1    jruoho     if (ACPI_FAILURE (Status))
    194      1.1    jruoho     {
    195      1.1    jruoho         ACPI_EXCEPTION ((AE_INFO, Status, "While installing handlers"));
    196      1.1    jruoho         return (Status);
    197      1.1    jruoho     }
    198      1.1    jruoho 
    199      1.1    jruoho     /* Initialize the ACPI hardware */
    200      1.1    jruoho 
    201      1.1    jruoho     Status = AcpiEnableSubsystem (ACPI_FULL_INITIALIZATION);
    202      1.1    jruoho     if (ACPI_FAILURE (Status))
    203      1.1    jruoho     {
    204      1.1    jruoho         ACPI_EXCEPTION ((AE_INFO, Status, "While enabling ACPICA"));
    205      1.1    jruoho         return (Status);
    206      1.1    jruoho     }
    207      1.1    jruoho 
    208      1.1    jruoho     /* Complete the ACPI namespace object initialization */
    209      1.1    jruoho 
    210      1.1    jruoho     Status = AcpiInitializeObjects (ACPI_FULL_INITIALIZATION);
    211      1.1    jruoho     if (ACPI_FAILURE (Status))
    212      1.1    jruoho     {
    213      1.1    jruoho         ACPI_EXCEPTION ((AE_INFO, Status, "While initializing ACPICA objects"));
    214      1.1    jruoho         return (Status);
    215      1.1    jruoho     }
    216      1.1    jruoho 
    217      1.1    jruoho     return (AE_OK);
    218      1.1    jruoho }
    219      1.1    jruoho 
    220      1.1    jruoho 
    221      1.1    jruoho /******************************************************************************
    222      1.1    jruoho  *
    223      1.1    jruoho  * Example ACPICA initialization code with early ACPI table access. This shows
    224      1.1    jruoho  * an initialization that requires early access to ACPI tables (before
    225      1.1    jruoho  * kernel dynamic memory is available)
    226      1.1    jruoho  *
    227      1.1    jruoho  *****************************************************************************/
    228      1.1    jruoho 
    229      1.1    jruoho /*
    230      1.1    jruoho  * The purpose of this static table array is to avoid the use of kernel
    231      1.1    jruoho  * dynamic memory which may not be available during early ACPI table
    232      1.1    jruoho  * access.
    233      1.1    jruoho  */
    234      1.1    jruoho #define ACPI_MAX_INIT_TABLES    16
    235      1.1    jruoho static ACPI_TABLE_DESC      TableArray[ACPI_MAX_INIT_TABLES];
    236      1.1    jruoho 
    237      1.1    jruoho 
    238      1.1    jruoho /*
    239      1.1    jruoho  * This function would be called early in kernel initialization. After this
    240      1.1    jruoho  * is called, all ACPI tables are available to the host.
    241      1.1    jruoho  */
    242      1.1    jruoho ACPI_STATUS
    243  1.1.1.4  christos InitializeAcpiTables (
    244  1.1.1.4  christos     void)
    245      1.1    jruoho {
    246      1.1    jruoho     ACPI_STATUS             Status;
    247      1.1    jruoho 
    248      1.1    jruoho 
    249      1.1    jruoho     /* Initialize the ACPICA Table Manager and get all ACPI tables */
    250      1.1    jruoho 
    251      1.1    jruoho     Status = AcpiInitializeTables (TableArray, ACPI_MAX_INIT_TABLES, TRUE);
    252      1.1    jruoho     return (Status);
    253      1.1    jruoho }
    254      1.1    jruoho 
    255      1.1    jruoho 
    256      1.1    jruoho /*
    257      1.1    jruoho  * This function would be called after the kernel is initialized and
    258      1.1    jruoho  * dynamic/virtual memory is available. It completes the initialization of
    259      1.1    jruoho  * the ACPICA subsystem.
    260      1.1    jruoho  */
    261      1.1    jruoho ACPI_STATUS
    262  1.1.1.4  christos InitializeAcpi (
    263  1.1.1.4  christos     void)
    264      1.1    jruoho {
    265      1.1    jruoho     ACPI_STATUS             Status;
    266      1.1    jruoho 
    267      1.1    jruoho 
    268      1.1    jruoho     /* Initialize the ACPICA subsystem */
    269      1.1    jruoho 
    270      1.1    jruoho     Status = AcpiInitializeSubsystem ();
    271      1.1    jruoho     if (ACPI_FAILURE (Status))
    272      1.1    jruoho     {
    273      1.1    jruoho         return (Status);
    274      1.1    jruoho     }
    275      1.1    jruoho 
    276      1.1    jruoho     /* Copy the root table list to dynamic memory */
    277      1.1    jruoho 
    278      1.1    jruoho     Status = AcpiReallocateRootTable ();
    279      1.1    jruoho     if (ACPI_FAILURE (Status))
    280      1.1    jruoho     {
    281      1.1    jruoho         return (Status);
    282      1.1    jruoho     }
    283      1.1    jruoho 
    284      1.1    jruoho     /* Create the ACPI namespace from ACPI tables */
    285      1.1    jruoho 
    286      1.1    jruoho     Status = AcpiLoadTables ();
    287      1.1    jruoho     if (ACPI_FAILURE (Status))
    288      1.1    jruoho     {
    289      1.1    jruoho         return (Status);
    290      1.1    jruoho     }
    291      1.1    jruoho 
    292      1.1    jruoho     /* Install local handlers */
    293      1.1    jruoho 
    294      1.1    jruoho     Status = InstallHandlers ();
    295      1.1    jruoho     if (ACPI_FAILURE (Status))
    296      1.1    jruoho     {
    297      1.1    jruoho         ACPI_EXCEPTION ((AE_INFO, Status, "While installing handlers"));
    298      1.1    jruoho         return (Status);
    299      1.1    jruoho     }
    300      1.1    jruoho 
    301      1.1    jruoho     /* Initialize the ACPI hardware */
    302      1.1    jruoho 
    303      1.1    jruoho     Status = AcpiEnableSubsystem (ACPI_FULL_INITIALIZATION);
    304      1.1    jruoho     if (ACPI_FAILURE (Status))
    305      1.1    jruoho     {
    306      1.1    jruoho         return (Status);
    307      1.1    jruoho     }
    308      1.1    jruoho 
    309      1.1    jruoho     /* Complete the ACPI namespace object initialization */
    310      1.1    jruoho 
    311      1.1    jruoho     Status = AcpiInitializeObjects (ACPI_FULL_INITIALIZATION);
    312      1.1    jruoho     if (ACPI_FAILURE (Status))
    313      1.1    jruoho     {
    314      1.1    jruoho         return (Status);
    315      1.1    jruoho     }
    316      1.1    jruoho 
    317      1.1    jruoho     return (AE_OK);
    318      1.1    jruoho }
    319      1.1    jruoho 
    320      1.1    jruoho 
    321      1.1    jruoho /******************************************************************************
    322      1.1    jruoho  *
    323      1.1    jruoho  * Example ACPICA handler and handler installation
    324      1.1    jruoho  *
    325      1.1    jruoho  *****************************************************************************/
    326      1.1    jruoho 
    327  1.1.1.4  christos static void
    328      1.1    jruoho NotifyHandler (
    329      1.1    jruoho     ACPI_HANDLE                 Device,
    330      1.1    jruoho     UINT32                      Value,
    331      1.1    jruoho     void                        *Context)
    332      1.1    jruoho {
    333      1.1    jruoho 
    334      1.1    jruoho     ACPI_INFO ((AE_INFO, "Received a notify 0x%X", Value));
    335      1.1    jruoho }
    336      1.1    jruoho 
    337      1.1    jruoho 
    338  1.1.1.4  christos static ACPI_STATUS
    339      1.1    jruoho InstallHandlers (void)
    340      1.1    jruoho {
    341      1.1    jruoho     ACPI_STATUS             Status;
    342      1.1    jruoho 
    343      1.1    jruoho 
    344      1.1    jruoho     /* Install global notify handler */
    345      1.1    jruoho 
    346      1.1    jruoho     Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
    347      1.1    jruoho                                         NotifyHandler, NULL);
    348      1.1    jruoho     if (ACPI_FAILURE (Status))
    349      1.1    jruoho     {
    350      1.1    jruoho         ACPI_EXCEPTION ((AE_INFO, Status, "While installing Notify handler"));
    351      1.1    jruoho         return (Status);
    352      1.1    jruoho     }
    353      1.1    jruoho 
    354      1.1    jruoho     return (AE_OK);
    355      1.1    jruoho }
    356      1.1    jruoho 
    357      1.1    jruoho 
    358      1.1    jruoho /******************************************************************************
    359      1.1    jruoho  *
    360  1.1.1.4  christos  * Examples of control method execution.
    361      1.1    jruoho  *
    362      1.1    jruoho  * _OSI is a predefined method that is implemented internally within ACPICA.
    363      1.1    jruoho  *
    364      1.1    jruoho  * Shows the following elements:
    365      1.1    jruoho  *
    366      1.1    jruoho  * 1) How to setup a control method argument and argument list
    367      1.1    jruoho  * 2) How to setup the return value object
    368      1.1    jruoho  * 3) How to invoke AcpiEvaluateObject
    369      1.1    jruoho  * 4) How to check the returned ACPI_STATUS
    370      1.1    jruoho  * 5) How to analyze the return value
    371      1.1    jruoho  *
    372      1.1    jruoho  *****************************************************************************/
    373      1.1    jruoho 
    374  1.1.1.4  christos static void
    375      1.1    jruoho ExecuteOSI (void)
    376      1.1    jruoho {
    377      1.1    jruoho     ACPI_STATUS             Status;
    378      1.1    jruoho     ACPI_OBJECT_LIST        ArgList;
    379      1.1    jruoho     ACPI_OBJECT             Arg[1];
    380      1.1    jruoho     ACPI_BUFFER             ReturnValue;
    381      1.1    jruoho     ACPI_OBJECT             *Object;
    382      1.1    jruoho 
    383      1.1    jruoho 
    384  1.1.1.4  christos     ACPI_INFO ((AE_INFO, "Executing _OSI reserved method"));
    385      1.1    jruoho 
    386      1.1    jruoho     /* Setup input argument */
    387      1.1    jruoho 
    388      1.1    jruoho     ArgList.Count = 1;
    389      1.1    jruoho     ArgList.Pointer = Arg;
    390      1.1    jruoho 
    391      1.1    jruoho     Arg[0].Type = ACPI_TYPE_STRING;
    392      1.1    jruoho     Arg[0].String.Pointer = "Windows 2001";
    393      1.1    jruoho     Arg[0].String.Length = strlen (Arg[0].String.Pointer);
    394      1.1    jruoho 
    395      1.1    jruoho     /* Ask ACPICA to allocate space for the return object */
    396      1.1    jruoho 
    397      1.1    jruoho     ReturnValue.Length = ACPI_ALLOCATE_BUFFER;
    398      1.1    jruoho 
    399      1.1    jruoho     Status = AcpiEvaluateObject (NULL, "\\_OSI", &ArgList, &ReturnValue);
    400      1.1    jruoho     if (ACPI_FAILURE (Status))
    401      1.1    jruoho     {
    402      1.1    jruoho         ACPI_EXCEPTION ((AE_INFO, Status, "While executing _OSI"));
    403      1.1    jruoho         return;
    404      1.1    jruoho     }
    405      1.1    jruoho 
    406      1.1    jruoho     /* Ensure that the return object is large enough */
    407      1.1    jruoho 
    408      1.1    jruoho     if (ReturnValue.Length < sizeof (ACPI_OBJECT))
    409      1.1    jruoho     {
    410      1.1    jruoho         AcpiOsPrintf ("Return value from _OSI method too small, %.8X\n",
    411      1.1    jruoho             ReturnValue.Length);
    412  1.1.1.4  christos         goto ErrorExit;
    413      1.1    jruoho     }
    414      1.1    jruoho 
    415      1.1    jruoho     /* Expect an integer return value from execution of _OSI */
    416      1.1    jruoho 
    417      1.1    jruoho     Object = ReturnValue.Pointer;
    418      1.1    jruoho     if (Object->Type != ACPI_TYPE_INTEGER)
    419      1.1    jruoho     {
    420      1.1    jruoho         AcpiOsPrintf ("Invalid return type from _OSI, %.2X\n", Object->Type);
    421      1.1    jruoho     }
    422      1.1    jruoho 
    423      1.1    jruoho     ACPI_INFO ((AE_INFO, "_OSI returned 0x%8.8X", (UINT32) Object->Integer.Value));
    424  1.1.1.4  christos 
    425  1.1.1.4  christos 
    426  1.1.1.4  christos ErrorExit:
    427  1.1.1.4  christos 
    428  1.1.1.4  christos     /* Free a buffer created via ACPI_ALLOCATE_BUFFER */
    429  1.1.1.4  christos 
    430  1.1.1.4  christos     AcpiOsFree (ReturnValue.Pointer);
    431      1.1    jruoho }
    432      1.1    jruoho 
    433      1.1    jruoho 
    434      1.1    jruoho /******************************************************************************
    435      1.1    jruoho  *
    436  1.1.1.4  christos  * Execute an actual control method in the DSDT (MAIN)
    437      1.1    jruoho  *
    438      1.1    jruoho  *****************************************************************************/
    439      1.1    jruoho 
    440  1.1.1.4  christos static void
    441  1.1.1.4  christos ExecuteMAIN (void)
    442      1.1    jruoho {
    443  1.1.1.4  christos     ACPI_STATUS             Status;
    444  1.1.1.4  christos     ACPI_OBJECT_LIST        ArgList;
    445  1.1.1.4  christos     ACPI_OBJECT             Arg[1];
    446  1.1.1.4  christos     ACPI_BUFFER             ReturnValue;
    447  1.1.1.4  christos     ACPI_OBJECT             *Object;
    448      1.1    jruoho 
    449      1.1    jruoho 
    450  1.1.1.4  christos     ACPI_INFO ((AE_INFO, "Executing MAIN method"));
    451  1.1.1.3    jruoho 
    452  1.1.1.4  christos     /* Setup input argument */
    453  1.1.1.4  christos 
    454  1.1.1.4  christos     ArgList.Count = 1;
    455  1.1.1.4  christos     ArgList.Pointer = Arg;
    456  1.1.1.4  christos 
    457  1.1.1.4  christos     Arg[0].Type = ACPI_TYPE_STRING;
    458  1.1.1.4  christos     Arg[0].String.Pointer = "Method [MAIN] is executing";
    459  1.1.1.4  christos     Arg[0].String.Length = strlen (Arg[0].String.Pointer);
    460  1.1.1.4  christos 
    461  1.1.1.4  christos     /* Ask ACPICA to allocate space for the return object */
    462  1.1.1.4  christos 
    463  1.1.1.4  christos     ReturnValue.Length = ACPI_ALLOCATE_BUFFER;
    464  1.1.1.4  christos 
    465  1.1.1.4  christos     Status = AcpiEvaluateObject (NULL, "\\MAIN", &ArgList, &ReturnValue);
    466  1.1.1.4  christos     if (ACPI_FAILURE (Status))
    467  1.1.1.4  christos     {
    468  1.1.1.4  christos         ACPI_EXCEPTION ((AE_INFO, Status, "While executing MAIN"));
    469  1.1.1.4  christos         return;
    470  1.1.1.4  christos     }
    471  1.1.1.4  christos 
    472  1.1.1.4  christos     if (ReturnValue.Pointer)
    473  1.1.1.4  christos     {
    474  1.1.1.4  christos         /* Obtain and validate the returned ACPI_OBJECT */
    475  1.1.1.4  christos 
    476  1.1.1.4  christos         Object = ReturnValue.Pointer;
    477  1.1.1.4  christos         if (Object->Type == ACPI_TYPE_STRING)
    478  1.1.1.4  christos         {
    479  1.1.1.4  christos             AcpiOsPrintf ("Method [MAIN] returned: \"%s\"\n", Object->String.Pointer);
    480  1.1.1.4  christos         }
    481  1.1.1.4  christos 
    482  1.1.1.4  christos         ACPI_FREE (ReturnValue.Pointer);
    483  1.1.1.4  christos     }
    484  1.1.1.3    jruoho }
    485