Subversion Repositories Kolibri OS

Rev

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