Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /******************************************************************************
  2.  *
  3.  * Name: aclocal.h - Internal data types used across the ACPI subsystem
  4.  *
  5.  *****************************************************************************/
  6.  
  7. /******************************************************************************
  8.  *
  9.  * 1. Copyright Notice
  10.  *
  11.  * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
  12.  * All rights reserved.
  13.  *
  14.  * 2. License
  15.  *
  16.  * 2.1. This is your license from Intel Corp. under its intellectual property
  17.  * rights.  You may have additional license terms from the party that provided
  18.  * you this software, covering your right to use that party's intellectual
  19.  * property rights.
  20.  *
  21.  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
  22.  * copy of the source code appearing in this file ("Covered Code") an
  23.  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
  24.  * base code distributed originally by Intel ("Original Intel Code") to copy,
  25.  * make derivatives, distribute, use and display any portion of the Covered
  26.  * Code in any form, with the right to sublicense such rights; and
  27.  *
  28.  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
  29.  * license (with the right to sublicense), under only those claims of Intel
  30.  * patents that are infringed by the Original Intel Code, to make, use, sell,
  31.  * offer to sell, and import the Covered Code and derivative works thereof
  32.  * solely to the minimum extent necessary to exercise the above copyright
  33.  * license, and in no event shall the patent license extend to any additions
  34.  * to or modifications of the Original Intel Code.  No other license or right
  35.  * is granted directly or by implication, estoppel or otherwise;
  36.  *
  37.  * The above copyright and patent license is granted only if the following
  38.  * conditions are met:
  39.  *
  40.  * 3. Conditions
  41.  *
  42.  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
  43.  * Redistribution of source code of any substantial portion of the Covered
  44.  * Code or modification with rights to further distribute source must include
  45.  * the above Copyright Notice, the above License, this list of Conditions,
  46.  * and the following Disclaimer and Export Compliance provision.  In addition,
  47.  * Licensee must cause all Covered Code to which Licensee contributes to
  48.  * contain a file documenting the changes Licensee made to create that Covered
  49.  * Code and the date of any change.  Licensee must include in that file the
  50.  * documentation of any changes made by any predecessor Licensee.  Licensee
  51.  * must include a prominent statement that the modification is derived,
  52.  * directly or indirectly, from Original Intel Code.
  53.  *
  54.  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
  55.  * Redistribution of source code of any substantial portion of the Covered
  56.  * Code or modification without rights to further distribute source must
  57.  * include the following Disclaimer and Export Compliance provision in the
  58.  * documentation and/or other materials provided with distribution.  In
  59.  * addition, Licensee may not authorize further sublicense of source of any
  60.  * portion of the Covered Code, and must include terms to the effect that the
  61.  * license from Licensee to its licensee is limited to the intellectual
  62.  * property embodied in the software Licensee provides to its licensee, and
  63.  * not to intellectual property embodied in modifications its licensee may
  64.  * make.
  65.  *
  66.  * 3.3. Redistribution of Executable. Redistribution in executable form of any
  67.  * substantial portion of the Covered Code or modification must reproduce the
  68.  * above Copyright Notice, and the following Disclaimer and Export Compliance
  69.  * provision in the documentation and/or other materials provided with the
  70.  * distribution.
  71.  *
  72.  * 3.4. Intel retains all right, title, and interest in and to the Original
  73.  * Intel Code.
  74.  *
  75.  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
  76.  * Intel shall be used in advertising or otherwise to promote the sale, use or
  77.  * other dealings in products derived from or relating to the Covered Code
  78.  * without prior written authorization from Intel.
  79.  *
  80.  * 4. Disclaimer and Export Compliance
  81.  *
  82.  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
  83.  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
  84.  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
  85.  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
  86.  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
  87.  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
  88.  * PARTICULAR PURPOSE.
  89.  *
  90.  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
  91.  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
  92.  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
  93.  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
  94.  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
  95.  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
  96.  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
  97.  * LIMITED REMEDY.
  98.  *
  99.  * 4.3. Licensee shall not export, either directly or indirectly, any of this
  100.  * software or system incorporating such software without first obtaining any
  101.  * required license or other approval from the U. S. Department of Commerce or
  102.  * any other agency or department of the United States Government.  In the
  103.  * event Licensee exports any such software from the United States or
  104.  * re-exports any such software from a foreign destination, Licensee shall
  105.  * ensure that the distribution and export/re-export of the software is in
  106.  * compliance with all laws, regulations, orders, or other restrictions of the
  107.  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
  108.  * any of its subsidiaries will export/re-export any technical data, process,
  109.  * software, or service, directly or indirectly, to any country for which the
  110.  * United States government or any agency thereof requires an export license,
  111.  * other governmental approval, or letter of assurance, without first obtaining
  112.  * such license, approval or letter.
  113.  *
  114.  *****************************************************************************/
  115.  
  116. #ifndef __ACLOCAL_H__
  117. #define __ACLOCAL_H__
  118.  
  119.  
  120. /* acpisrc:StructDefs -- for acpisrc conversion */
  121.  
  122. #define ACPI_SERIALIZED                 0xFF
  123.  
  124. typedef UINT32                          ACPI_MUTEX_HANDLE;
  125. #define ACPI_GLOBAL_LOCK                (ACPI_SEMAPHORE) (-1)
  126.  
  127. /* Total number of aml opcodes defined */
  128.  
  129. #define AML_NUM_OPCODES                 0x7F
  130.  
  131.  
  132. /* Forward declarations */
  133.  
  134. struct acpi_walk_state;
  135. struct acpi_obj_mutex;
  136. union acpi_parse_object;
  137.  
  138.  
  139. /*****************************************************************************
  140.  *
  141.  * Mutex typedefs and structs
  142.  *
  143.  ****************************************************************************/
  144.  
  145.  
  146. /*
  147.  * Predefined handles for the mutex objects used within the subsystem
  148.  * All mutex objects are automatically created by AcpiUtMutexInitialize.
  149.  *
  150.  * The acquire/release ordering protocol is implied via this list. Mutexes
  151.  * with a lower value must be acquired before mutexes with a higher value.
  152.  *
  153.  * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames
  154.  * table below also!
  155.  */
  156. #define ACPI_MTX_INTERPRETER            0   /* AML Interpreter, main lock */
  157. #define ACPI_MTX_NAMESPACE              1   /* ACPI Namespace */
  158. #define ACPI_MTX_TABLES                 2   /* Data for ACPI tables */
  159. #define ACPI_MTX_EVENTS                 3   /* Data for ACPI events */
  160. #define ACPI_MTX_CACHES                 4   /* Internal caches, general purposes */
  161. #define ACPI_MTX_MEMORY                 5   /* Debug memory tracking lists */
  162. #define ACPI_MTX_DEBUG_CMD_COMPLETE     6   /* AML debugger */
  163. #define ACPI_MTX_DEBUG_CMD_READY        7   /* AML debugger */
  164.  
  165. #define ACPI_MAX_MUTEX                  7
  166. #define ACPI_NUM_MUTEX                  ACPI_MAX_MUTEX+1
  167.  
  168. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  169. #ifdef DEFINE_ACPI_GLOBALS
  170.  
  171. /* Debug names for the mutexes above */
  172.  
  173. static char                 *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
  174. {
  175.     "ACPI_MTX_Interpreter",
  176.     "ACPI_MTX_Namespace",
  177.     "ACPI_MTX_Tables",
  178.     "ACPI_MTX_Events",
  179.     "ACPI_MTX_Caches",
  180.     "ACPI_MTX_Memory",
  181.     "ACPI_MTX_CommandComplete",
  182.     "ACPI_MTX_CommandReady"
  183. };
  184.  
  185. #endif
  186. #endif
  187.  
  188. /* Lock structure for reader/writer interfaces */
  189.  
  190. typedef struct acpi_rw_lock
  191. {
  192.     ACPI_MUTEX              WriterMutex;
  193.     ACPI_MUTEX              ReaderMutex;
  194.     UINT32                  NumReaders;
  195.  
  196. } ACPI_RW_LOCK;
  197.  
  198.  
  199. /*
  200.  * Predefined handles for spinlocks used within the subsystem.
  201.  * These spinlocks are created by AcpiUtMutexInitialize
  202.  */
  203. #define ACPI_LOCK_GPES                  0
  204. #define ACPI_LOCK_HARDWARE              1
  205.  
  206. #define ACPI_MAX_LOCK                   1
  207. #define ACPI_NUM_LOCK                   ACPI_MAX_LOCK+1
  208.  
  209.  
  210. /* This Thread ID means that the mutex is not in use (unlocked) */
  211.  
  212. #define ACPI_MUTEX_NOT_ACQUIRED         (ACPI_THREAD_ID) -1
  213.  
  214. /* Table for the global mutexes */
  215.  
  216. typedef struct acpi_mutex_info
  217. {
  218.     ACPI_MUTEX                      Mutex;
  219.     UINT32                          UseCount;
  220.     ACPI_THREAD_ID                  ThreadId;
  221.  
  222. } ACPI_MUTEX_INFO;
  223.  
  224.  
  225. /* Lock flag parameter for various interfaces */
  226.  
  227. #define ACPI_MTX_DO_NOT_LOCK            0
  228. #define ACPI_MTX_LOCK                   1
  229.  
  230.  
  231. /* Field access granularities */
  232.  
  233. #define ACPI_FIELD_BYTE_GRANULARITY     1
  234. #define ACPI_FIELD_WORD_GRANULARITY     2
  235. #define ACPI_FIELD_DWORD_GRANULARITY    4
  236. #define ACPI_FIELD_QWORD_GRANULARITY    8
  237.  
  238.  
  239. #define ACPI_ENTRY_NOT_FOUND            NULL
  240.  
  241.  
  242. /*****************************************************************************
  243.  *
  244.  * Namespace typedefs and structs
  245.  *
  246.  ****************************************************************************/
  247.  
  248. /* Operational modes of the AML interpreter/scanner */
  249.  
  250. typedef enum
  251. {
  252.     ACPI_IMODE_LOAD_PASS1           = 0x01,
  253.     ACPI_IMODE_LOAD_PASS2           = 0x02,
  254.     ACPI_IMODE_EXECUTE              = 0x03
  255.  
  256. } ACPI_INTERPRETER_MODE;
  257.  
  258.  
  259. /*
  260.  * The Namespace Node describes a named object that appears in the AML.
  261.  * DescriptorType is used to differentiate between internal descriptors.
  262.  *
  263.  * The node is optimized for both 32-bit and 64-bit platforms:
  264.  * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case.
  265.  *
  266.  * Note: The DescriptorType and Type fields must appear in the identical
  267.  * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT
  268.  * structures.
  269.  */
  270. typedef struct acpi_namespace_node
  271. {
  272.     union acpi_operand_object       *Object;        /* Interpreter object */
  273.     UINT8                           DescriptorType; /* Differentiate object descriptor types */
  274.     UINT8                           Type;           /* ACPI Type associated with this name */
  275.     UINT8                           Flags;          /* Miscellaneous flags */
  276.     ACPI_OWNER_ID                   OwnerId;        /* Node creator */
  277.     ACPI_NAME_UNION                 Name;           /* ACPI Name, always 4 chars per ACPI spec */
  278.     struct acpi_namespace_node      *Parent;        /* Parent node */
  279.     struct acpi_namespace_node      *Child;         /* First child */
  280.     struct acpi_namespace_node      *Peer;          /* First peer */
  281.  
  282.     /*
  283.      * The following fields are used by the ASL compiler and disassembler only
  284.      */
  285. #ifdef ACPI_LARGE_NAMESPACE_NODE
  286.     union acpi_parse_object         *Op;
  287.     UINT32                          Value;
  288.     UINT32                          Length;
  289. #endif
  290.  
  291. } ACPI_NAMESPACE_NODE;
  292.  
  293.  
  294. /* Namespace Node flags */
  295.  
  296. #define ANOBJ_RESERVED                  0x01    /* Available for use */
  297. #define ANOBJ_TEMPORARY                 0x02    /* Node is create by a method and is temporary */
  298. #define ANOBJ_METHOD_ARG                0x04    /* Node is a method argument */
  299. #define ANOBJ_METHOD_LOCAL              0x08    /* Node is a method local */
  300. #define ANOBJ_SUBTREE_HAS_INI           0x10    /* Used to optimize device initialization */
  301. #define ANOBJ_EVALUATED                 0x20    /* Set on first evaluation of node */
  302. #define ANOBJ_ALLOCATED_BUFFER          0x40    /* Method AML buffer is dynamic (InstallMethod) */
  303.  
  304. #define ANOBJ_IS_EXTERNAL               0x08    /* iASL only: This object created via External() */
  305. #define ANOBJ_METHOD_NO_RETVAL          0x10    /* iASL only: Method has no return value */
  306. #define ANOBJ_METHOD_SOME_NO_RETVAL     0x20    /* iASL only: Method has at least one return value */
  307. #define ANOBJ_IS_BIT_OFFSET             0x40    /* iASL only: Reference is a bit offset */
  308. #define ANOBJ_IS_REFERENCED             0x80    /* iASL only: Object was referenced */
  309.  
  310.  
  311. /* Internal ACPI table management - master table list */
  312.  
  313. typedef struct acpi_table_list
  314. {
  315.     ACPI_TABLE_DESC                 *Tables;            /* Table descriptor array */
  316.     UINT32                          CurrentTableCount;  /* Tables currently in the array */
  317.     UINT32                          MaxTableCount;      /* Max tables array will hold */
  318.     UINT8                           Flags;
  319.  
  320. } ACPI_TABLE_LIST;
  321.  
  322. /* Flags for above */
  323.  
  324. #define ACPI_ROOT_ORIGIN_UNKNOWN        (0)     /* ~ORIGIN_ALLOCATED */
  325. #define ACPI_ROOT_ORIGIN_ALLOCATED      (1)
  326. #define ACPI_ROOT_ALLOW_RESIZE          (2)
  327.  
  328.  
  329. /* Predefined (fixed) table indexes */
  330.  
  331. #define ACPI_TABLE_INDEX_DSDT           (0)
  332. #define ACPI_TABLE_INDEX_FACS           (1)
  333.  
  334.  
  335. typedef struct acpi_find_context
  336. {
  337.     char                            *SearchFor;
  338.     ACPI_HANDLE                     *List;
  339.     UINT32                          *Count;
  340.  
  341. } ACPI_FIND_CONTEXT;
  342.  
  343.  
  344. typedef struct acpi_ns_search_data
  345. {
  346.     ACPI_NAMESPACE_NODE             *Node;
  347.  
  348. } ACPI_NS_SEARCH_DATA;
  349.  
  350.  
  351. /* Object types used during package copies */
  352.  
  353. #define ACPI_COPY_TYPE_SIMPLE           0
  354. #define ACPI_COPY_TYPE_PACKAGE          1
  355.  
  356.  
  357. /* Info structure used to convert external<->internal namestrings */
  358.  
  359. typedef struct acpi_namestring_info
  360. {
  361.     const char                      *ExternalName;
  362.     const char                      *NextExternalChar;
  363.     char                            *InternalName;
  364.     UINT32                          Length;
  365.     UINT32                          NumSegments;
  366.     UINT32                          NumCarats;
  367.     BOOLEAN                         FullyQualified;
  368.  
  369. } ACPI_NAMESTRING_INFO;
  370.  
  371.  
  372. /* Field creation info */
  373.  
  374. typedef struct acpi_create_field_info
  375. {
  376.     ACPI_NAMESPACE_NODE             *RegionNode;
  377.     ACPI_NAMESPACE_NODE             *FieldNode;
  378.     ACPI_NAMESPACE_NODE             *RegisterNode;
  379.     ACPI_NAMESPACE_NODE             *DataRegisterNode;
  380.     UINT32                          BankValue;
  381.     UINT32                          FieldBitPosition;
  382.     UINT32                          FieldBitLength;
  383.     UINT8                           FieldFlags;
  384.     UINT8                           Attribute;
  385.     UINT8                           FieldType;
  386.  
  387. } ACPI_CREATE_FIELD_INFO;
  388.  
  389.  
  390. typedef
  391. ACPI_STATUS (*ACPI_INTERNAL_METHOD) (
  392.     struct acpi_walk_state          *WalkState);
  393.  
  394.  
  395. /*
  396.  * Bitmapped ACPI types.  Used internally only
  397.  */
  398. #define ACPI_BTYPE_ANY                  0x00000000
  399. #define ACPI_BTYPE_INTEGER              0x00000001
  400. #define ACPI_BTYPE_STRING               0x00000002
  401. #define ACPI_BTYPE_BUFFER               0x00000004
  402. #define ACPI_BTYPE_PACKAGE              0x00000008
  403. #define ACPI_BTYPE_FIELD_UNIT           0x00000010
  404. #define ACPI_BTYPE_DEVICE               0x00000020
  405. #define ACPI_BTYPE_EVENT                0x00000040
  406. #define ACPI_BTYPE_METHOD               0x00000080
  407. #define ACPI_BTYPE_MUTEX                0x00000100
  408. #define ACPI_BTYPE_REGION               0x00000200
  409. #define ACPI_BTYPE_POWER                0x00000400
  410. #define ACPI_BTYPE_PROCESSOR            0x00000800
  411. #define ACPI_BTYPE_THERMAL              0x00001000
  412. #define ACPI_BTYPE_BUFFER_FIELD         0x00002000
  413. #define ACPI_BTYPE_DDB_HANDLE           0x00004000
  414. #define ACPI_BTYPE_DEBUG_OBJECT         0x00008000
  415. #define ACPI_BTYPE_REFERENCE            0x00010000
  416. #define ACPI_BTYPE_RESOURCE             0x00020000
  417.  
  418. #define ACPI_BTYPE_COMPUTE_DATA         (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
  419.  
  420. #define ACPI_BTYPE_DATA                 (ACPI_BTYPE_COMPUTE_DATA  | ACPI_BTYPE_PACKAGE)
  421. #define ACPI_BTYPE_DATA_REFERENCE       (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
  422. #define ACPI_BTYPE_DEVICE_OBJECTS       (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
  423. #define ACPI_BTYPE_OBJECTS_AND_REFS     0x0001FFFF  /* ARG or LOCAL */
  424. #define ACPI_BTYPE_ALL_OBJECTS          0x0000FFFF
  425.  
  426.  
  427. /*
  428.  * Information structure for ACPI predefined names.
  429.  * Each entry in the table contains the following items:
  430.  *
  431.  * Name                 - The ACPI reserved name
  432.  * ParamCount           - Number of arguments to the method
  433.  * ExpectedReturnBtypes - Allowed type(s) for the return value
  434.  */
  435. typedef struct acpi_name_info
  436. {
  437.     char                        Name[ACPI_NAME_SIZE];
  438.     UINT8                       ParamCount;
  439.     UINT8                       ExpectedBtypes;
  440.  
  441. } ACPI_NAME_INFO;
  442.  
  443. /*
  444.  * Secondary information structures for ACPI predefined objects that return
  445.  * package objects. This structure appears as the next entry in the table
  446.  * after the NAME_INFO structure above.
  447.  *
  448.  * The reason for this is to minimize the size of the predefined name table.
  449.  */
  450.  
  451. /*
  452.  * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2,
  453.  * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT
  454.  */
  455. typedef struct acpi_package_info
  456. {
  457.     UINT8                       Type;
  458.     UINT8                       ObjectType1;
  459.     UINT8                       Count1;
  460.     UINT8                       ObjectType2;
  461.     UINT8                       Count2;
  462.     UINT8                       Reserved;
  463.  
  464. } ACPI_PACKAGE_INFO;
  465.  
  466. /* Used for ACPI_PTYPE2_FIXED */
  467.  
  468. typedef struct acpi_package_info2
  469. {
  470.     UINT8                       Type;
  471.     UINT8                       Count;
  472.     UINT8                       ObjectType[4];
  473.  
  474. } ACPI_PACKAGE_INFO2;
  475.  
  476. /* Used for ACPI_PTYPE1_OPTION */
  477.  
  478. typedef struct acpi_package_info3
  479. {
  480.     UINT8                       Type;
  481.     UINT8                       Count;
  482.     UINT8                       ObjectType[2];
  483.     UINT8                       TailObjectType;
  484.     UINT8                       Reserved;
  485.  
  486. } ACPI_PACKAGE_INFO3;
  487.  
  488. typedef union acpi_predefined_info
  489. {
  490.     ACPI_NAME_INFO              Info;
  491.     ACPI_PACKAGE_INFO           RetInfo;
  492.     ACPI_PACKAGE_INFO2          RetInfo2;
  493.     ACPI_PACKAGE_INFO3          RetInfo3;
  494.  
  495. } ACPI_PREDEFINED_INFO;
  496.  
  497.  
  498. /* Data block used during object validation */
  499.  
  500. typedef struct acpi_predefined_data
  501. {
  502.     char                        *Pathname;
  503.     const ACPI_PREDEFINED_INFO  *Predefined;
  504.     union acpi_operand_object   *ParentPackage;
  505.     UINT32                      Flags;
  506.     UINT8                       NodeFlags;
  507.  
  508. } ACPI_PREDEFINED_DATA;
  509.  
  510. /* Defines for Flags field above */
  511.  
  512. #define ACPI_OBJECT_REPAIRED    1
  513.  
  514.  
  515. /*
  516.  * Bitmapped return value types
  517.  * Note: the actual data types must be contiguous, a loop in nspredef.c
  518.  * depends on this.
  519.  */
  520. #define ACPI_RTYPE_ANY                  0x00
  521. #define ACPI_RTYPE_NONE                 0x01
  522. #define ACPI_RTYPE_INTEGER              0x02
  523. #define ACPI_RTYPE_STRING               0x04
  524. #define ACPI_RTYPE_BUFFER               0x08
  525. #define ACPI_RTYPE_PACKAGE              0x10
  526. #define ACPI_RTYPE_REFERENCE            0x20
  527. #define ACPI_RTYPE_ALL                  0x3F
  528.  
  529. #define ACPI_NUM_RTYPES                 5   /* Number of actual object types */
  530.  
  531.  
  532. /*****************************************************************************
  533.  *
  534.  * Event typedefs and structs
  535.  *
  536.  ****************************************************************************/
  537.  
  538. /* Dispatch info for each GPE -- either a method or handler, cannot be both */
  539.  
  540. typedef struct acpi_handler_info
  541. {
  542.     ACPI_EVENT_HANDLER              Address;        /* Address of handler, if any */
  543.     void                            *Context;       /* Context to be passed to handler */
  544.     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level (saved) */
  545.  
  546. } ACPI_HANDLER_INFO;
  547.  
  548. typedef union acpi_gpe_dispatch_info
  549. {
  550.     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level */
  551.     struct acpi_handler_info        *Handler;
  552.  
  553. } ACPI_GPE_DISPATCH_INFO;
  554.  
  555. /*
  556.  * Information about a GPE, one per each GPE in an array.
  557.  * NOTE: Important to keep this struct as small as possible.
  558.  */
  559. typedef struct acpi_gpe_event_info
  560. {
  561.     union acpi_gpe_dispatch_info    Dispatch;       /* Either Method or Handler */
  562.     struct acpi_gpe_register_info   *RegisterInfo;  /* Backpointer to register info */
  563.     UINT8                           Flags;          /* Misc info about this GPE */
  564.     UINT8                           GpeNumber;      /* This GPE */
  565.     UINT8                           RuntimeCount;   /* References to a run GPE */
  566.     UINT8                           WakeupCount;    /* References to a wake GPE */
  567.  
  568. } ACPI_GPE_EVENT_INFO;
  569.  
  570. /* Information about a GPE register pair, one per each status/enable pair in an array */
  571.  
  572. typedef struct acpi_gpe_register_info
  573. {
  574.     ACPI_GENERIC_ADDRESS            StatusAddress;  /* Address of status reg */
  575.     ACPI_GENERIC_ADDRESS            EnableAddress;  /* Address of enable reg */
  576.     UINT8                           EnableForWake;  /* GPEs to keep enabled when sleeping */
  577.     UINT8                           EnableForRun;   /* GPEs to keep enabled when running */
  578.     UINT8                           BaseGpeNumber;  /* Base GPE number for this register */
  579.  
  580. } ACPI_GPE_REGISTER_INFO;
  581.  
  582. /*
  583.  * Information about a GPE register block, one per each installed block --
  584.  * GPE0, GPE1, and one per each installed GPE Block Device.
  585.  */
  586. typedef struct acpi_gpe_block_info
  587. {
  588.     ACPI_NAMESPACE_NODE             *Node;
  589.     struct acpi_gpe_block_info      *Previous;
  590.     struct acpi_gpe_block_info      *Next;
  591.     struct acpi_gpe_xrupt_info      *XruptBlock;    /* Backpointer to interrupt block */
  592.     ACPI_GPE_REGISTER_INFO          *RegisterInfo;  /* One per GPE register pair */
  593.     ACPI_GPE_EVENT_INFO             *EventInfo;     /* One for each GPE */
  594.     ACPI_GENERIC_ADDRESS            BlockAddress;   /* Base address of the block */
  595.     UINT32                          RegisterCount;  /* Number of register pairs in block */
  596.     UINT16                          GpeCount;       /* Number of individual GPEs in block */
  597.     UINT8                           BlockBaseNumber;/* Base GPE number for this block */
  598.  
  599. } ACPI_GPE_BLOCK_INFO;
  600.  
  601. /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
  602.  
  603. typedef struct acpi_gpe_xrupt_info
  604. {
  605.     struct acpi_gpe_xrupt_info      *Previous;
  606.     struct acpi_gpe_xrupt_info      *Next;
  607.     ACPI_GPE_BLOCK_INFO             *GpeBlockListHead;  /* List of GPE blocks for this xrupt */
  608.     UINT32                          InterruptNumber;    /* System interrupt number */
  609.  
  610. } ACPI_GPE_XRUPT_INFO;
  611.  
  612. typedef struct acpi_gpe_walk_info
  613. {
  614.     ACPI_NAMESPACE_NODE             *GpeDevice;
  615.     ACPI_GPE_BLOCK_INFO             *GpeBlock;
  616.     UINT16                          Count;
  617.     ACPI_OWNER_ID                   OwnerId;
  618.     BOOLEAN                         EnableThisGpe;
  619.     BOOLEAN                         ExecuteByOwnerId;
  620.  
  621. } ACPI_GPE_WALK_INFO;
  622.  
  623. typedef struct acpi_gpe_device_info
  624. {
  625.     UINT32                          Index;
  626.     UINT32                          NextBlockBaseIndex;
  627.     ACPI_STATUS                     Status;
  628.     ACPI_NAMESPACE_NODE             *GpeDevice;
  629.  
  630. } ACPI_GPE_DEVICE_INFO;
  631.  
  632. typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) (
  633.     ACPI_GPE_XRUPT_INFO             *GpeXruptInfo,
  634.     ACPI_GPE_BLOCK_INFO             *GpeBlock,
  635.     void                            *Context);
  636.  
  637.  
  638. /* Information about each particular fixed event */
  639.  
  640. typedef struct acpi_fixed_event_handler
  641. {
  642.     ACPI_EVENT_HANDLER              Handler;        /* Address of handler. */
  643.     void                            *Context;       /* Context to be passed to handler */
  644.  
  645. } ACPI_FIXED_EVENT_HANDLER;
  646.  
  647. typedef struct acpi_fixed_event_info
  648. {
  649.     UINT8                           StatusRegisterId;
  650.     UINT8                           EnableRegisterId;
  651.     UINT16                          StatusBitMask;
  652.     UINT16                          EnableBitMask;
  653.  
  654. } ACPI_FIXED_EVENT_INFO;
  655.  
  656. /* Information used during field processing */
  657.  
  658. typedef struct acpi_field_info
  659. {
  660.     UINT8                           SkipField;
  661.     UINT8                           FieldFlag;
  662.     UINT32                          PkgLength;
  663.  
  664. } ACPI_FIELD_INFO;
  665.  
  666.  
  667. /*****************************************************************************
  668.  *
  669.  * Generic "state" object for stacks
  670.  *
  671.  ****************************************************************************/
  672.  
  673. #define ACPI_CONTROL_NORMAL                  0xC0
  674. #define ACPI_CONTROL_CONDITIONAL_EXECUTING   0xC1
  675. #define ACPI_CONTROL_PREDICATE_EXECUTING     0xC2
  676. #define ACPI_CONTROL_PREDICATE_FALSE         0xC3
  677. #define ACPI_CONTROL_PREDICATE_TRUE          0xC4
  678.  
  679.  
  680. #define ACPI_STATE_COMMON \
  681.     void                            *Next; \
  682.     UINT8                           DescriptorType; /* To differentiate various internal objs */\
  683.     UINT8                           Flags; \
  684.     UINT16                          Value; \
  685.     UINT16                          State;
  686.  
  687.     /* There are 2 bytes available here until the next natural alignment boundary */
  688.  
  689. typedef struct acpi_common_state
  690. {
  691.     ACPI_STATE_COMMON
  692. } ACPI_COMMON_STATE;
  693.  
  694.  
  695. /*
  696.  * Update state - used to traverse complex objects such as packages
  697.  */
  698. typedef struct acpi_update_state
  699. {
  700.     ACPI_STATE_COMMON
  701.     union acpi_operand_object       *Object;
  702.  
  703. } ACPI_UPDATE_STATE;
  704.  
  705.  
  706. /*
  707.  * Pkg state - used to traverse nested package structures
  708.  */
  709. typedef struct acpi_pkg_state
  710. {
  711.     ACPI_STATE_COMMON
  712.     UINT16                          Index;
  713.     union acpi_operand_object       *SourceObject;
  714.     union acpi_operand_object       *DestObject;
  715.     struct acpi_walk_state          *WalkState;
  716.     void                            *ThisTargetObj;
  717.     UINT32                          NumPackages;
  718.  
  719. } ACPI_PKG_STATE;
  720.  
  721.  
  722. /*
  723.  * Control state - one per if/else and while constructs.
  724.  * Allows nesting of these constructs
  725.  */
  726. typedef struct acpi_control_state
  727. {
  728.     ACPI_STATE_COMMON
  729.     UINT16                          Opcode;
  730.     union acpi_parse_object         *PredicateOp;
  731.     UINT8                           *AmlPredicateStart;     /* Start of if/while predicate */
  732.     UINT8                           *PackageEnd;            /* End of if/while block */
  733.     UINT32                          LoopCount;              /* While() loop counter */
  734.  
  735. } ACPI_CONTROL_STATE;
  736.  
  737.  
  738. /*
  739.  * Scope state - current scope during namespace lookups
  740.  */
  741. typedef struct acpi_scope_state
  742. {
  743.     ACPI_STATE_COMMON
  744.     ACPI_NAMESPACE_NODE             *Node;
  745.  
  746. } ACPI_SCOPE_STATE;
  747.  
  748.  
  749. typedef struct acpi_pscope_state
  750. {
  751.     ACPI_STATE_COMMON
  752.     UINT32                          ArgCount;               /* Number of fixed arguments */
  753.     union acpi_parse_object         *Op;                    /* Current op being parsed */
  754.     UINT8                           *ArgEnd;                /* Current argument end */
  755.     UINT8                           *PkgEnd;                /* Current package end */
  756.     UINT32                          ArgList;                /* Next argument to parse */
  757.  
  758. } ACPI_PSCOPE_STATE;
  759.  
  760.  
  761. /*
  762.  * Thread state - one per thread across multiple walk states.  Multiple walk
  763.  * states are created when there are nested control methods executing.
  764.  */
  765. typedef struct acpi_thread_state
  766. {
  767.     ACPI_STATE_COMMON
  768.     UINT8                           CurrentSyncLevel;       /* Mutex Sync (nested acquire) level */
  769.     struct acpi_walk_state          *WalkStateList;         /* Head of list of WalkStates for this thread */
  770.     union acpi_operand_object       *AcquiredMutexList;     /* List of all currently acquired mutexes */
  771.     ACPI_THREAD_ID                  ThreadId;               /* Running thread ID */
  772.  
  773. } ACPI_THREAD_STATE;
  774.  
  775.  
  776. /*
  777.  * Result values - used to accumulate the results of nested
  778.  * AML arguments
  779.  */
  780. typedef struct acpi_result_values
  781. {
  782.     ACPI_STATE_COMMON
  783.     union acpi_operand_object       *ObjDesc [ACPI_RESULTS_FRAME_OBJ_NUM];
  784.  
  785. } ACPI_RESULT_VALUES;
  786.  
  787.  
  788. typedef
  789. ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) (
  790.     struct acpi_walk_state          *WalkState,
  791.     union acpi_parse_object         **OutOp);
  792.  
  793. typedef
  794. ACPI_STATUS (*ACPI_PARSE_UPWARDS) (
  795.     struct acpi_walk_state          *WalkState);
  796.  
  797.  
  798. /*
  799.  * Notify info - used to pass info to the deferred notify
  800.  * handler/dispatcher.
  801.  */
  802. typedef struct acpi_notify_info
  803. {
  804.     ACPI_STATE_COMMON
  805.     ACPI_NAMESPACE_NODE             *Node;
  806.     union acpi_operand_object       *HandlerObj;
  807.  
  808. } ACPI_NOTIFY_INFO;
  809.  
  810.  
  811. /* Generic state is union of structs above */
  812.  
  813. typedef union acpi_generic_state
  814. {
  815.     ACPI_COMMON_STATE               Common;
  816.     ACPI_CONTROL_STATE              Control;
  817.     ACPI_UPDATE_STATE               Update;
  818.     ACPI_SCOPE_STATE                Scope;
  819.     ACPI_PSCOPE_STATE               ParseScope;
  820.     ACPI_PKG_STATE                  Pkg;
  821.     ACPI_THREAD_STATE               Thread;
  822.     ACPI_RESULT_VALUES              Results;
  823.     ACPI_NOTIFY_INFO                Notify;
  824.  
  825. } ACPI_GENERIC_STATE;
  826.  
  827.  
  828. /*****************************************************************************
  829.  *
  830.  * Interpreter typedefs and structs
  831.  *
  832.  ****************************************************************************/
  833.  
  834. typedef
  835. ACPI_STATUS (*ACPI_EXECUTE_OP) (
  836.     struct acpi_walk_state          *WalkState);
  837.  
  838.  
  839. /*****************************************************************************
  840.  *
  841.  * Parser typedefs and structs
  842.  *
  843.  ****************************************************************************/
  844.  
  845. /*
  846.  * AML opcode, name, and argument layout
  847.  */
  848. typedef struct acpi_opcode_info
  849. {
  850. #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
  851.     char                            *Name;          /* Opcode name (disassembler/debug only) */
  852. #endif
  853.     UINT32                          ParseArgs;      /* Grammar/Parse time arguments */
  854.     UINT32                          RuntimeArgs;    /* Interpret time arguments */
  855.     UINT16                          Flags;          /* Misc flags */
  856.     UINT8                           ObjectType;     /* Corresponding internal object type */
  857.     UINT8                           Class;          /* Opcode class */
  858.     UINT8                           Type;           /* Opcode type */
  859.  
  860. } ACPI_OPCODE_INFO;
  861.  
  862. typedef union acpi_parse_value
  863. {
  864.     UINT64                          Integer;        /* Integer constant (Up to 64 bits) */
  865.     UINT32                          Size;           /* bytelist or field size */
  866.     char                            *String;        /* NULL terminated string */
  867.     UINT8                           *Buffer;        /* buffer or string */
  868.     char                            *Name;          /* NULL terminated string */
  869.     union acpi_parse_object         *Arg;           /* arguments and contained ops */
  870.  
  871. } ACPI_PARSE_VALUE;
  872.  
  873.  
  874. #ifdef ACPI_DISASSEMBLER
  875. #define ACPI_DISASM_ONLY_MEMBERS(a)     a;
  876. #else
  877. #define ACPI_DISASM_ONLY_MEMBERS(a)
  878. #endif
  879.  
  880. #define ACPI_PARSE_COMMON \
  881.     union acpi_parse_object         *Parent;        /* Parent op */\
  882.     UINT8                           DescriptorType; /* To differentiate various internal objs */\
  883.     UINT8                           Flags;          /* Type of Op */\
  884.     UINT16                          AmlOpcode;      /* AML opcode */\
  885.     UINT32                          AmlOffset;      /* Offset of declaration in AML */\
  886.     union acpi_parse_object         *Next;          /* Next op */\
  887.     ACPI_NAMESPACE_NODE             *Node;          /* For use by interpreter */\
  888.     ACPI_PARSE_VALUE                Value;          /* Value or args associated with the opcode */\
  889.     UINT8                           ArgListLength;  /* Number of elements in the arg list */\
  890.     ACPI_DISASM_ONLY_MEMBERS (\
  891.     UINT8                           DisasmFlags;    /* Used during AML disassembly */\
  892.     UINT8                           DisasmOpcode;   /* Subtype used for disassembly */\
  893.     char                            AmlOpName[16])  /* Op name (debug only) */
  894.  
  895.  
  896. #define ACPI_DASM_BUFFER                0x00
  897. #define ACPI_DASM_RESOURCE              0x01
  898. #define ACPI_DASM_STRING                0x02
  899. #define ACPI_DASM_UNICODE               0x03
  900. #define ACPI_DASM_EISAID                0x04
  901. #define ACPI_DASM_MATCHOP               0x05
  902. #define ACPI_DASM_LNOT_PREFIX           0x06
  903. #define ACPI_DASM_LNOT_SUFFIX           0x07
  904. #define ACPI_DASM_IGNORE                0x08
  905.  
  906. /*
  907.  * Generic operation (for example:  If, While, Store)
  908.  */
  909. typedef struct acpi_parse_obj_common
  910. {
  911.     ACPI_PARSE_COMMON
  912. } ACPI_PARSE_OBJ_COMMON;
  913.  
  914.  
  915. /*
  916.  * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions),
  917.  * and bytelists.
  918.  */
  919. typedef struct acpi_parse_obj_named
  920. {
  921.     ACPI_PARSE_COMMON
  922.     UINT8                           *Path;
  923.     UINT8                           *Data;          /* AML body or bytelist data */
  924.     UINT32                          Length;         /* AML length */
  925.     UINT32                          Name;           /* 4-byte name or zero if no name */
  926.  
  927. } ACPI_PARSE_OBJ_NAMED;
  928.  
  929.  
  930. /* This version is used by the iASL compiler only */
  931.  
  932. #define ACPI_MAX_PARSEOP_NAME   20
  933.  
  934. typedef struct acpi_parse_obj_asl
  935. {
  936.     ACPI_PARSE_COMMON
  937.     union acpi_parse_object         *Child;
  938.     union acpi_parse_object         *ParentMethod;
  939.     char                            *Filename;
  940.     char                            *ExternalName;
  941.     char                            *Namepath;
  942.     char                            NameSeg[4];
  943.     UINT32                          ExtraValue;
  944.     UINT32                          Column;
  945.     UINT32                          LineNumber;
  946.     UINT32                          LogicalLineNumber;
  947.     UINT32                          LogicalByteOffset;
  948.     UINT32                          EndLine;
  949.     UINT32                          EndLogicalLine;
  950.     UINT32                          AcpiBtype;
  951.     UINT32                          AmlLength;
  952.     UINT32                          AmlSubtreeLength;
  953.     UINT32                          FinalAmlLength;
  954.     UINT32                          FinalAmlOffset;
  955.     UINT32                          CompileFlags;
  956.     UINT16                          ParseOpcode;
  957.     UINT8                           AmlOpcodeLength;
  958.     UINT8                           AmlPkgLenBytes;
  959.     UINT8                           Extra;
  960.     char                            ParseOpName[ACPI_MAX_PARSEOP_NAME];
  961.  
  962. } ACPI_PARSE_OBJ_ASL;
  963.  
  964. typedef union acpi_parse_object
  965. {
  966.     ACPI_PARSE_OBJ_COMMON           Common;
  967.     ACPI_PARSE_OBJ_NAMED            Named;
  968.     ACPI_PARSE_OBJ_ASL              Asl;
  969.  
  970. } ACPI_PARSE_OBJECT;
  971.  
  972.  
  973. /*
  974.  * Parse state - one state per parser invocation and each control
  975.  * method.
  976.  */
  977. typedef struct acpi_parse_state
  978. {
  979.     UINT8                           *AmlStart;      /* First AML byte */
  980.     UINT8                           *Aml;           /* Next AML byte */
  981.     UINT8                           *AmlEnd;        /* (last + 1) AML byte */
  982.     UINT8                           *PkgStart;      /* Current package begin */
  983.     UINT8                           *PkgEnd;        /* Current package end */
  984.     union acpi_parse_object         *StartOp;       /* Root of parse tree */
  985.     struct acpi_namespace_node      *StartNode;
  986.     union acpi_generic_state        *Scope;         /* Current scope */
  987.     union acpi_parse_object         *StartScope;
  988.     UINT32                          AmlSize;
  989.  
  990. } ACPI_PARSE_STATE;
  991.  
  992.  
  993. /* Parse object flags */
  994.  
  995. #define ACPI_PARSEOP_GENERIC            0x01
  996. #define ACPI_PARSEOP_NAMED              0x02
  997. #define ACPI_PARSEOP_DEFERRED           0x04
  998. #define ACPI_PARSEOP_BYTELIST           0x08
  999. #define ACPI_PARSEOP_IN_STACK           0x10
  1000. #define ACPI_PARSEOP_TARGET             0x20
  1001. #define ACPI_PARSEOP_IN_CACHE           0x80
  1002.  
  1003. /* Parse object DisasmFlags */
  1004.  
  1005. #define ACPI_PARSEOP_IGNORE             0x01
  1006. #define ACPI_PARSEOP_PARAMLIST          0x02
  1007. #define ACPI_PARSEOP_EMPTY_TERMLIST     0x04
  1008. #define ACPI_PARSEOP_SPECIAL            0x10
  1009.  
  1010.  
  1011. /*****************************************************************************
  1012.  *
  1013.  * Hardware (ACPI registers) and PNP
  1014.  *
  1015.  ****************************************************************************/
  1016.  
  1017. typedef struct acpi_bit_register_info
  1018. {
  1019.     UINT8                           ParentRegister;
  1020.     UINT8                           BitPosition;
  1021.     UINT16                          AccessBitMask;
  1022.  
  1023. } ACPI_BIT_REGISTER_INFO;
  1024.  
  1025.  
  1026. /*
  1027.  * Some ACPI registers have bits that must be ignored -- meaning that they
  1028.  * must be preserved.
  1029.  */
  1030. #define ACPI_PM1_STATUS_PRESERVED_BITS          0x0800  /* Bit 11 */
  1031.  
  1032. /* Write-only bits must be zeroed by software */
  1033.  
  1034. #define ACPI_PM1_CONTROL_WRITEONLY_BITS         0x2004  /* Bits 13, 2 */
  1035.  
  1036. /* For control registers, both ignored and reserved bits must be preserved */
  1037.  
  1038. /*
  1039.  * For PM1 control, the SCI enable bit (bit 0, SCI_EN) is defined by the
  1040.  * ACPI specification to be a "preserved" bit - "OSPM always preserves this
  1041.  * bit position", section 4.7.3.2.1. However, on some machines the OS must
  1042.  * write a one to this bit after resume for the machine to work properly.
  1043.  * To enable this, we no longer attempt to preserve this bit. No machines
  1044.  * are known to fail if the bit is not preserved. (May 2009)
  1045.  */
  1046. #define ACPI_PM1_CONTROL_IGNORED_BITS           0x0200  /* Bit 9 */
  1047. #define ACPI_PM1_CONTROL_RESERVED_BITS          0xC1F8  /* Bits 14-15, 3-8 */
  1048. #define ACPI_PM1_CONTROL_PRESERVED_BITS \
  1049.          (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS)
  1050.  
  1051. #define ACPI_PM2_CONTROL_PRESERVED_BITS         0xFFFFFFFE /* All except bit 0 */
  1052.  
  1053. /*
  1054.  * Register IDs
  1055.  * These are the full ACPI registers
  1056.  */
  1057. #define ACPI_REGISTER_PM1_STATUS                0x01
  1058. #define ACPI_REGISTER_PM1_ENABLE                0x02
  1059. #define ACPI_REGISTER_PM1_CONTROL               0x03
  1060. #define ACPI_REGISTER_PM2_CONTROL               0x04
  1061. #define ACPI_REGISTER_PM_TIMER                  0x05
  1062. #define ACPI_REGISTER_PROCESSOR_BLOCK           0x06
  1063. #define ACPI_REGISTER_SMI_COMMAND_BLOCK         0x07
  1064.  
  1065.  
  1066. /* Masks used to access the BitRegisters */
  1067.  
  1068. #define ACPI_BITMASK_TIMER_STATUS               0x0001
  1069. #define ACPI_BITMASK_BUS_MASTER_STATUS          0x0010
  1070. #define ACPI_BITMASK_GLOBAL_LOCK_STATUS         0x0020
  1071. #define ACPI_BITMASK_POWER_BUTTON_STATUS        0x0100
  1072. #define ACPI_BITMASK_SLEEP_BUTTON_STATUS        0x0200
  1073. #define ACPI_BITMASK_RT_CLOCK_STATUS            0x0400
  1074. #define ACPI_BITMASK_PCIEXP_WAKE_STATUS         0x4000    /* ACPI 3.0 */
  1075. #define ACPI_BITMASK_WAKE_STATUS                0x8000
  1076.  
  1077. #define ACPI_BITMASK_ALL_FIXED_STATUS           (\
  1078.     ACPI_BITMASK_TIMER_STATUS          | \
  1079.     ACPI_BITMASK_BUS_MASTER_STATUS     | \
  1080.     ACPI_BITMASK_GLOBAL_LOCK_STATUS    | \
  1081.     ACPI_BITMASK_POWER_BUTTON_STATUS   | \
  1082.     ACPI_BITMASK_SLEEP_BUTTON_STATUS   | \
  1083.     ACPI_BITMASK_RT_CLOCK_STATUS       | \
  1084.     ACPI_BITMASK_WAKE_STATUS)
  1085.  
  1086. #define ACPI_BITMASK_TIMER_ENABLE               0x0001
  1087. #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE         0x0020
  1088. #define ACPI_BITMASK_POWER_BUTTON_ENABLE        0x0100
  1089. #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE        0x0200
  1090. #define ACPI_BITMASK_RT_CLOCK_ENABLE            0x0400
  1091. #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE        0x4000    /* ACPI 3.0 */
  1092.  
  1093. #define ACPI_BITMASK_SCI_ENABLE                 0x0001
  1094. #define ACPI_BITMASK_BUS_MASTER_RLD             0x0002
  1095. #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE        0x0004
  1096. #define ACPI_BITMASK_SLEEP_TYPE                 0x1C00
  1097. #define ACPI_BITMASK_SLEEP_ENABLE               0x2000
  1098.  
  1099. #define ACPI_BITMASK_ARB_DISABLE                0x0001
  1100.  
  1101.  
  1102. /* Raw bit position of each BitRegister */
  1103.  
  1104. #define ACPI_BITPOSITION_TIMER_STATUS           0x00
  1105. #define ACPI_BITPOSITION_BUS_MASTER_STATUS      0x04
  1106. #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS     0x05
  1107. #define ACPI_BITPOSITION_POWER_BUTTON_STATUS    0x08
  1108. #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS    0x09
  1109. #define ACPI_BITPOSITION_RT_CLOCK_STATUS        0x0A
  1110. #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS     0x0E    /* ACPI 3.0 */
  1111. #define ACPI_BITPOSITION_WAKE_STATUS            0x0F
  1112.  
  1113. #define ACPI_BITPOSITION_TIMER_ENABLE           0x00
  1114. #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE     0x05
  1115. #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE    0x08
  1116. #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE    0x09
  1117. #define ACPI_BITPOSITION_RT_CLOCK_ENABLE        0x0A
  1118. #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE    0x0E    /* ACPI 3.0 */
  1119.  
  1120. #define ACPI_BITPOSITION_SCI_ENABLE             0x00
  1121. #define ACPI_BITPOSITION_BUS_MASTER_RLD         0x01
  1122. #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE    0x02
  1123. #define ACPI_BITPOSITION_SLEEP_TYPE             0x0A
  1124. #define ACPI_BITPOSITION_SLEEP_ENABLE           0x0D
  1125.  
  1126. #define ACPI_BITPOSITION_ARB_DISABLE            0x00
  1127.  
  1128.  
  1129. /* Structs and definitions for _OSI support and I/O port validation */
  1130.  
  1131. #define ACPI_OSI_WIN_2000               0x01
  1132. #define ACPI_OSI_WIN_XP                 0x02
  1133. #define ACPI_OSI_WIN_XP_SP1             0x03
  1134. #define ACPI_OSI_WINSRV_2003            0x04
  1135. #define ACPI_OSI_WIN_XP_SP2             0x05
  1136. #define ACPI_OSI_WINSRV_2003_SP1        0x06
  1137. #define ACPI_OSI_WIN_VISTA              0x07
  1138. #define ACPI_OSI_WINSRV_2008            0x08
  1139. #define ACPI_OSI_WIN_VISTA_SP1          0x09
  1140. #define ACPI_OSI_WIN_7                  0x0A
  1141.  
  1142. #define ACPI_ALWAYS_ILLEGAL             0x00
  1143.  
  1144. typedef struct acpi_interface_info
  1145. {
  1146.     char                    *Name;
  1147.     UINT8                   Value;
  1148.  
  1149. } ACPI_INTERFACE_INFO;
  1150.  
  1151. typedef struct acpi_port_info
  1152. {
  1153.     char                    *Name;
  1154.     UINT16                  Start;
  1155.     UINT16                  End;
  1156.     UINT8                   OsiDependency;
  1157.  
  1158. } ACPI_PORT_INFO;
  1159.  
  1160.  
  1161. /*****************************************************************************
  1162.  *
  1163.  * Resource descriptors
  1164.  *
  1165.  ****************************************************************************/
  1166.  
  1167. /* ResourceType values */
  1168.  
  1169. #define ACPI_ADDRESS_TYPE_MEMORY_RANGE          0
  1170. #define ACPI_ADDRESS_TYPE_IO_RANGE              1
  1171. #define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE      2
  1172.  
  1173. /* Resource descriptor types and masks */
  1174.  
  1175. #define ACPI_RESOURCE_NAME_LARGE                0x80
  1176. #define ACPI_RESOURCE_NAME_SMALL                0x00
  1177.  
  1178. #define ACPI_RESOURCE_NAME_SMALL_MASK           0x78 /* Bits 6:3 contain the type */
  1179. #define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK    0x07 /* Bits 2:0 contain the length */
  1180. #define ACPI_RESOURCE_NAME_LARGE_MASK           0x7F /* Bits 6:0 contain the type */
  1181.  
  1182.  
  1183. /*
  1184.  * Small resource descriptor "names" as defined by the ACPI specification.
  1185.  * Note: Bits 2:0 are used for the descriptor length
  1186.  */
  1187. #define ACPI_RESOURCE_NAME_IRQ                  0x20
  1188. #define ACPI_RESOURCE_NAME_DMA                  0x28
  1189. #define ACPI_RESOURCE_NAME_START_DEPENDENT      0x30
  1190. #define ACPI_RESOURCE_NAME_END_DEPENDENT        0x38
  1191. #define ACPI_RESOURCE_NAME_IO                   0x40
  1192. #define ACPI_RESOURCE_NAME_FIXED_IO             0x48
  1193. #define ACPI_RESOURCE_NAME_RESERVED_S1          0x50
  1194. #define ACPI_RESOURCE_NAME_RESERVED_S2          0x58
  1195. #define ACPI_RESOURCE_NAME_RESERVED_S3          0x60
  1196. #define ACPI_RESOURCE_NAME_RESERVED_S4          0x68
  1197. #define ACPI_RESOURCE_NAME_VENDOR_SMALL         0x70
  1198. #define ACPI_RESOURCE_NAME_END_TAG              0x78
  1199.  
  1200. /*
  1201.  * Large resource descriptor "names" as defined by the ACPI specification.
  1202.  * Note: includes the Large Descriptor bit in bit[7]
  1203.  */
  1204. #define ACPI_RESOURCE_NAME_MEMORY24             0x81
  1205. #define ACPI_RESOURCE_NAME_GENERIC_REGISTER     0x82
  1206. #define ACPI_RESOURCE_NAME_RESERVED_L1          0x83
  1207. #define ACPI_RESOURCE_NAME_VENDOR_LARGE         0x84
  1208. #define ACPI_RESOURCE_NAME_MEMORY32             0x85
  1209. #define ACPI_RESOURCE_NAME_FIXED_MEMORY32       0x86
  1210. #define ACPI_RESOURCE_NAME_ADDRESS32            0x87
  1211. #define ACPI_RESOURCE_NAME_ADDRESS16            0x88
  1212. #define ACPI_RESOURCE_NAME_EXTENDED_IRQ         0x89
  1213. #define ACPI_RESOURCE_NAME_ADDRESS64            0x8A
  1214. #define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64   0x8B
  1215. #define ACPI_RESOURCE_NAME_LARGE_MAX            0x8B
  1216.  
  1217.  
  1218. /*****************************************************************************
  1219.  *
  1220.  * Miscellaneous
  1221.  *
  1222.  ****************************************************************************/
  1223.  
  1224. #define ACPI_ASCII_ZERO                 0x30
  1225.  
  1226.  
  1227. /*****************************************************************************
  1228.  *
  1229.  * Disassembler
  1230.  *
  1231.  ****************************************************************************/
  1232.  
  1233. typedef struct acpi_external_list
  1234. {
  1235.     char                        *Path;
  1236.     char                        *InternalPath;
  1237.     struct acpi_external_list   *Next;
  1238.     UINT32                      Value;
  1239.     UINT16                      Length;
  1240.     UINT8                       Type;
  1241.     UINT8                       Flags;
  1242.  
  1243. } ACPI_EXTERNAL_LIST;
  1244.  
  1245. /* Values for Flags field above */
  1246.  
  1247. #define ACPI_IPATH_ALLOCATED    0x01
  1248.  
  1249.  
  1250. /*****************************************************************************
  1251.  *
  1252.  * Debugger
  1253.  *
  1254.  ****************************************************************************/
  1255.  
  1256. typedef struct acpi_db_method_info
  1257. {
  1258.     ACPI_HANDLE                     MainThreadGate;
  1259.     ACPI_HANDLE                     ThreadCompleteGate;
  1260.     ACPI_HANDLE                     InfoGate;
  1261.     UINT32                          *Threads;
  1262.     UINT32                          NumThreads;
  1263.     UINT32                          NumCreated;
  1264.     UINT32                          NumCompleted;
  1265.  
  1266.     char                            *Name;
  1267.     UINT32                          Flags;
  1268.     UINT32                          NumLoops;
  1269.     char                            Pathname[128];
  1270.     char                            **Args;
  1271.  
  1272.     /*
  1273.      * Arguments to be passed to method for the command
  1274.      * Threads -
  1275.      *   the Number of threads, ID of current thread and
  1276.      *   Index of current thread inside all them created.
  1277.      */
  1278.     char                            InitArgs;
  1279.     char                            *Arguments[4];
  1280.     char                            NumThreadsStr[11];
  1281.     char                            IdOfThreadStr[11];
  1282.     char                            IndexOfThreadStr[11];
  1283.  
  1284. } ACPI_DB_METHOD_INFO;
  1285.  
  1286. typedef struct acpi_integrity_info
  1287. {
  1288.     UINT32                          Nodes;
  1289.     UINT32                          Objects;
  1290.  
  1291. } ACPI_INTEGRITY_INFO;
  1292.  
  1293.  
  1294. #define ACPI_DB_REDIRECTABLE_OUTPUT     0x01
  1295. #define ACPI_DB_CONSOLE_OUTPUT          0x02
  1296. #define ACPI_DB_DUPLICATE_OUTPUT        0x03
  1297.  
  1298.  
  1299. /*****************************************************************************
  1300.  *
  1301.  * Debug
  1302.  *
  1303.  ****************************************************************************/
  1304.  
  1305. /* Entry for a memory allocation (debug only) */
  1306.  
  1307. #define ACPI_MEM_MALLOC                 0
  1308. #define ACPI_MEM_CALLOC                 1
  1309. #define ACPI_MAX_MODULE_NAME            16
  1310.  
  1311. #define ACPI_COMMON_DEBUG_MEM_HEADER \
  1312.     struct acpi_debug_mem_block     *Previous; \
  1313.     struct acpi_debug_mem_block     *Next; \
  1314.     UINT32                          Size; \
  1315.     UINT32                          Component; \
  1316.     UINT32                          Line; \
  1317.     char                            Module[ACPI_MAX_MODULE_NAME]; \
  1318.     UINT8                           AllocType;
  1319.  
  1320. typedef struct acpi_debug_mem_header
  1321. {
  1322.     ACPI_COMMON_DEBUG_MEM_HEADER
  1323.  
  1324. } ACPI_DEBUG_MEM_HEADER;
  1325.  
  1326. typedef struct acpi_debug_mem_block
  1327. {
  1328.     ACPI_COMMON_DEBUG_MEM_HEADER
  1329.     UINT64                          UserSpace;
  1330.  
  1331. } ACPI_DEBUG_MEM_BLOCK;
  1332.  
  1333.  
  1334. #define ACPI_MEM_LIST_GLOBAL            0
  1335. #define ACPI_MEM_LIST_NSNODE            1
  1336. #define ACPI_MEM_LIST_MAX               1
  1337. #define ACPI_NUM_MEM_LISTS              2
  1338.  
  1339.  
  1340. #endif /* __ACLOCAL_H__ */
  1341.