177422Smsmith/******************************************************************************
277422Smsmith *
377422Smsmith * Name: acstruct.h - Internal structs
477422Smsmith *
577422Smsmith *****************************************************************************/
677422Smsmith
7217365Sjkim/*
8245582Sjkim * Copyright (C) 2000 - 2013, Intel Corp.
977422Smsmith * All rights reserved.
1077422Smsmith *
11217365Sjkim * Redistribution and use in source and binary forms, with or without
12217365Sjkim * modification, are permitted provided that the following conditions
13217365Sjkim * are met:
14217365Sjkim * 1. Redistributions of source code must retain the above copyright
15217365Sjkim *    notice, this list of conditions, and the following disclaimer,
16217365Sjkim *    without modification.
17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
19217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
20217365Sjkim *    including a substantially similar Disclaimer requirement for further
21217365Sjkim *    binary redistribution.
22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
23217365Sjkim *    of any contributors may be used to endorse or promote products derived
24217365Sjkim *    from this software without specific prior written permission.
2577422Smsmith *
26217365Sjkim * Alternatively, this software may be distributed under the terms of the
27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
28217365Sjkim * Software Foundation.
2977422Smsmith *
30217365Sjkim * NO WARRANTY
31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
42217365Sjkim */
4377422Smsmith
4477422Smsmith#ifndef __ACSTRUCT_H__
4577422Smsmith#define __ACSTRUCT_H__
4677422Smsmith
47167802Sjkim/* acpisrc:StructDefs -- for acpisrc conversion */
4877422Smsmith
4977422Smsmith/*****************************************************************************
5077422Smsmith *
5177422Smsmith * Tree walking typedefs and structs
5277422Smsmith *
5377422Smsmith ****************************************************************************/
5477422Smsmith
5577422Smsmith
5677422Smsmith/*
57241973Sjkim * Walk state - current state of a parse tree walk. Used for both a leisurely
58167802Sjkim * stroll through the tree (for whatever reason), and for control method
59167802Sjkim * execution.
6077422Smsmith */
6199679Siwasaki#define ACPI_NEXT_OP_DOWNWARD       1
6299679Siwasaki#define ACPI_NEXT_OP_UPWARD         2
6377422Smsmith
64167802Sjkim/*
65167802Sjkim * Groups of definitions for WalkType used for different implementations of
66167802Sjkim * walkers (never simultaneously) - flags for interpreter:
67167802Sjkim */
6899679Siwasaki#define ACPI_WALK_NON_METHOD        0
69167802Sjkim#define ACPI_WALK_METHOD            0x01
70167802Sjkim#define ACPI_WALK_METHOD_RESTART    0x02
7177422Smsmith
72167802Sjkim/* Flags for iASL compiler only */
73167802Sjkim
74167802Sjkim#define ACPI_WALK_CONST_REQUIRED    0x10
75167802Sjkim#define ACPI_WALK_CONST_OPTIONAL    0x20
76167802Sjkim
77167802Sjkim
7877422Smsmithtypedef struct acpi_walk_state
7977422Smsmith{
80167802Sjkim    struct acpi_walk_state          *Next;              /* Next WalkState in list */
81167802Sjkim    UINT8                           DescriptorType;     /* To differentiate various internal objs */
82167802Sjkim    UINT8                           WalkType;
83167802Sjkim    UINT16                          Opcode;             /* Current AML opcode */
84167802Sjkim    UINT8                           NextOpInfo;         /* Info about NextOp */
85167802Sjkim    UINT8                           NumOperands;        /* Stack pointer for Operands[] array */
86167802Sjkim    UINT8                           OperandIndex;       /* Index into operand stack, to be used by AcpiDsObjStackPush */
87167802Sjkim    ACPI_OWNER_ID                   OwnerId;            /* Owner of objects created during the walk */
88167802Sjkim    BOOLEAN                         LastPredicate;      /* Result of last predicate */
89167802Sjkim    UINT8                           CurrentResult;
90167802Sjkim    UINT8                           ReturnUsed;
91167802Sjkim    UINT8                           ScopeDepth;
92167802Sjkim    UINT8                           PassNumber;         /* Parse pass during table load */
93167802Sjkim    UINT8                           ResultSize;         /* Total elements for the result stack */
94167802Sjkim    UINT8                           ResultCount;        /* Current number of occupied elements of result stack */
95167802Sjkim    UINT32                          AmlOffset;
96167802Sjkim    UINT32                          ArgTypes;
97167802Sjkim    UINT32                          MethodBreakpoint;   /* For single stepping */
98167802Sjkim    UINT32                          UserBreakpoint;     /* User AML breakpoint */
99167802Sjkim    UINT32                          ParseFlags;
10077422Smsmith
101167802Sjkim    ACPI_PARSE_STATE                ParserState;        /* Current state of parser */
102167802Sjkim    UINT32                          PrevArgTypes;
103167802Sjkim    UINT32                          ArgCount;           /* push for fixed or var args */
10484491Smsmith
105167802Sjkim    struct acpi_namespace_node      Arguments[ACPI_METHOD_NUM_ARGS];        /* Control method arguments */
106167802Sjkim    struct acpi_namespace_node      LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */
107167802Sjkim    union acpi_operand_object       *Operands[ACPI_OBJ_NUM_OPERANDS + 1];   /* Operands passed to the interpreter (+1 for NULL terminator) */
108167802Sjkim    union acpi_operand_object       **Params;
10977422Smsmith
110167802Sjkim    UINT8                           *AmlLastWhile;
111167802Sjkim    union acpi_operand_object       **CallerReturnDesc;
112167802Sjkim    ACPI_GENERIC_STATE              *ControlState;      /* List of control states (nested IFs) */
113167802Sjkim    struct acpi_namespace_node      *DeferredNode;      /* Used when executing deferred opcodes */
114167802Sjkim    union acpi_operand_object       *ImplicitReturnObj;
115167802Sjkim    struct acpi_namespace_node      *MethodCallNode;    /* Called method Node*/
116167802Sjkim    ACPI_PARSE_OBJECT               *MethodCallOp;      /* MethodCall Op if running a method */
117167802Sjkim    union acpi_operand_object       *MethodDesc;        /* Method descriptor if running a method */
118167802Sjkim    struct acpi_namespace_node      *MethodNode;        /* Method node if running a method. */
119167802Sjkim    ACPI_PARSE_OBJECT               *Op;                /* Current parser op */
120167802Sjkim    const ACPI_OPCODE_INFO          *OpInfo;            /* Info on current opcode */
121167802Sjkim    ACPI_PARSE_OBJECT               *Origin;            /* Start of walk [Obsolete] */
122167802Sjkim    union acpi_operand_object       *ResultObj;
123167802Sjkim    ACPI_GENERIC_STATE              *Results;           /* Stack of accumulated results */
124167802Sjkim    union acpi_operand_object       *ReturnDesc;        /* Return object, if any */
125167802Sjkim    ACPI_GENERIC_STATE              *ScopeInfo;         /* Stack of nested scopes */
126167802Sjkim    ACPI_PARSE_OBJECT               *PrevOp;            /* Last op that was processed */
127167802Sjkim    ACPI_PARSE_OBJECT               *NextOp;            /* next op to be processed */
128167802Sjkim    ACPI_THREAD_STATE               *Thread;
129167802Sjkim    ACPI_PARSE_DOWNWARDS            DescendingCallback;
130167802Sjkim    ACPI_PARSE_UPWARDS              AscendingCallback;
131167802Sjkim
13277422Smsmith} ACPI_WALK_STATE;
13377422Smsmith
13477422Smsmith
135209746Sjkim/* Info used by AcpiNsInitializeObjects and AcpiDsInitializeObjects */
13677422Smsmith
13777422Smsmithtypedef struct acpi_init_walk_info
13877422Smsmith{
139209746Sjkim    UINT32                          TableIndex;
140209746Sjkim    UINT32                          ObjectCount;
141209746Sjkim    UINT32                          MethodCount;
142209746Sjkim    UINT32                          DeviceCount;
143209746Sjkim    UINT32                          OpRegionCount;
144209746Sjkim    UINT32                          FieldCount;
145209746Sjkim    UINT32                          BufferCount;
146209746Sjkim    UINT32                          PackageCount;
147209746Sjkim    UINT32                          OpRegionInit;
148209746Sjkim    UINT32                          FieldInit;
149209746Sjkim    UINT32                          BufferInit;
150209746Sjkim    UINT32                          PackageInit;
151167802Sjkim    ACPI_OWNER_ID                   OwnerId;
15277422Smsmith
15377422Smsmith} ACPI_INIT_WALK_INFO;
15477422Smsmith
15577422Smsmith
15677422Smsmithtypedef struct acpi_get_devices_info
15777422Smsmith{
158167802Sjkim    ACPI_WALK_CALLBACK              UserFunction;
159167802Sjkim    void                            *Context;
160167802Sjkim    char                            *Hid;
16177422Smsmith
16277422Smsmith} ACPI_GET_DEVICES_INFO;
16377422Smsmith
16477422Smsmith
16585756Smsmithtypedef union acpi_aml_operands
16685756Smsmith{
167167802Sjkim    ACPI_OPERAND_OBJECT             *Operands[7];
16885756Smsmith
16985756Smsmith    struct
17085756Smsmith    {
171167802Sjkim        ACPI_OBJECT_INTEGER             *Type;
172167802Sjkim        ACPI_OBJECT_INTEGER             *Code;
173167802Sjkim        ACPI_OBJECT_INTEGER             *Argument;
17485756Smsmith
17585756Smsmith    } Fatal;
17685756Smsmith
17785756Smsmith    struct
17885756Smsmith    {
179167802Sjkim        ACPI_OPERAND_OBJECT             *Source;
180167802Sjkim        ACPI_OBJECT_INTEGER             *Index;
181167802Sjkim        ACPI_OPERAND_OBJECT             *Target;
18285756Smsmith
18385756Smsmith    } Index;
18485756Smsmith
18585756Smsmith    struct
18685756Smsmith    {
187167802Sjkim        ACPI_OPERAND_OBJECT             *Source;
188167802Sjkim        ACPI_OBJECT_INTEGER             *Index;
189167802Sjkim        ACPI_OBJECT_INTEGER             *Length;
190167802Sjkim        ACPI_OPERAND_OBJECT             *Target;
19185756Smsmith
19285756Smsmith    } Mid;
19385756Smsmith
19485756Smsmith} ACPI_AML_OPERANDS;
19585756Smsmith
19685756Smsmith
197167802Sjkim/*
198249663Sjkim * Structure used to pass object evaluation information and parameters.
199167802Sjkim * Purpose is to reduce CPU stack use.
200167802Sjkim */
201167802Sjkimtypedef struct acpi_evaluate_info
202129684Snjl{
203249663Sjkim    /* The first 3 elements are passed by the caller to AcpiNsEvaluate */
204129684Snjl
205249663Sjkim    ACPI_NAMESPACE_NODE             *PrefixNode;        /* Input: starting node */
206249663Sjkim    char                            *RelativePathname;  /* Input: path relative to PrefixNode */
207249663Sjkim    ACPI_OPERAND_OBJECT             **Parameters;       /* Input: argument list */
208249663Sjkim
209249663Sjkim    ACPI_NAMESPACE_NODE             *Node;              /* Resolved node (PrefixNode:RelativePathname) */
210249663Sjkim    ACPI_OPERAND_OBJECT             *ObjDesc;           /* Object attached to the resolved node */
211249663Sjkim    char                            *FullPathname;      /* Full pathname of the resolved node */
212249663Sjkim
213249663Sjkim    const ACPI_PREDEFINED_INFO      *Predefined;        /* Used if Node is a predefined name */
214249663Sjkim    ACPI_OPERAND_OBJECT             *ReturnObject;      /* Object returned from the evaluation */
215249663Sjkim    union acpi_operand_object       *ParentPackage;     /* Used if return object is a Package */
216249663Sjkim
217249663Sjkim    UINT32                          ReturnFlags;        /* Used for return value analysis */
218249663Sjkim    UINT32                          ReturnBtype;        /* Bitmapped type of the returned object */
219249663Sjkim    UINT16                          ParamCount;         /* Count of the input argument list */
220249663Sjkim    UINT8                           PassNumber;         /* Parser pass number */
221249663Sjkim    UINT8                           ReturnObjectType;   /* Object type of the returned object */
222249663Sjkim    UINT8                           NodeFlags;          /* Same as Node->Flags */
223249663Sjkim    UINT8                           Flags;              /* General flags */
224249663Sjkim
225167802Sjkim} ACPI_EVALUATE_INFO;
226129684Snjl
227167802Sjkim/* Values for Flags above */
228129684Snjl
229249663Sjkim#define ACPI_IGNORE_RETURN_VALUE    1
230167802Sjkim
231249663Sjkim/* Defines for ReturnFlags field above */
232167802Sjkim
233249663Sjkim#define ACPI_OBJECT_REPAIRED        1
234249663Sjkim#define ACPI_OBJECT_WRAPPED         2
235249663Sjkim
236249663Sjkim
237167802Sjkim/* Info used by AcpiNsInitializeDevices */
238167802Sjkim
239167802Sjkimtypedef struct acpi_device_walk_info
240167802Sjkim{
241167802Sjkim    ACPI_TABLE_DESC                 *TableDesc;
242167802Sjkim    ACPI_EVALUATE_INFO              *EvaluateInfo;
243209746Sjkim    UINT32                          DeviceCount;
244209746Sjkim    UINT32                          Num_STA;
245209746Sjkim    UINT32                          Num_INI;
246167802Sjkim
247167802Sjkim} ACPI_DEVICE_WALK_INFO;
248167802Sjkim
249167802Sjkim
250167802Sjkim/* TBD: [Restructure] Merge with struct above */
251167802Sjkim
252167802Sjkimtypedef struct acpi_walk_info
253167802Sjkim{
254167802Sjkim    UINT32                          DebugLevel;
255167802Sjkim    UINT32                          Count;
256167802Sjkim    ACPI_OWNER_ID                   OwnerId;
257167802Sjkim    UINT8                           DisplayType;
258167802Sjkim
259167802Sjkim} ACPI_WALK_INFO;
260167802Sjkim
261167802Sjkim/* Display Types */
262167802Sjkim
263167802Sjkim#define ACPI_DISPLAY_SUMMARY        (UINT8) 0
264167802Sjkim#define ACPI_DISPLAY_OBJECTS        (UINT8) 1
265167802Sjkim#define ACPI_DISPLAY_MASK           (UINT8) 1
266167802Sjkim
267167802Sjkim#define ACPI_DISPLAY_SHORT          (UINT8) 2
268167802Sjkim
269167802Sjkim
27077422Smsmith#endif
271