177422Smsmith/******************************************************************************
277422Smsmith *
377422Smsmith * Name: acstruct.h - Internal structs
477422Smsmith *
577422Smsmith *****************************************************************************/
677422Smsmith
7217365Sjkim/*
8306536Sjkim * Copyright (C) 2000 - 2016, 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
7377422Smsmithtypedef struct acpi_walk_state
7477422Smsmith{
75167802Sjkim    struct acpi_walk_state          *Next;              /* Next WalkState in list */
76167802Sjkim    UINT8                           DescriptorType;     /* To differentiate various internal objs */
77167802Sjkim    UINT8                           WalkType;
78167802Sjkim    UINT16                          Opcode;             /* Current AML opcode */
79167802Sjkim    UINT8                           NextOpInfo;         /* Info about NextOp */
80167802Sjkim    UINT8                           NumOperands;        /* Stack pointer for Operands[] array */
81167802Sjkim    UINT8                           OperandIndex;       /* Index into operand stack, to be used by AcpiDsObjStackPush */
82167802Sjkim    ACPI_OWNER_ID                   OwnerId;            /* Owner of objects created during the walk */
83167802Sjkim    BOOLEAN                         LastPredicate;      /* Result of last predicate */
84167802Sjkim    UINT8                           CurrentResult;
85167802Sjkim    UINT8                           ReturnUsed;
86167802Sjkim    UINT8                           ScopeDepth;
87167802Sjkim    UINT8                           PassNumber;         /* Parse pass during table load */
88306536Sjkim    BOOLEAN                         NamespaceOverride;  /* Override existing objects */
89167802Sjkim    UINT8                           ResultSize;         /* Total elements for the result stack */
90167802Sjkim    UINT8                           ResultCount;        /* Current number of occupied elements of result stack */
91306536Sjkim    UINT8                           *Aml;
92167802Sjkim    UINT32                          ArgTypes;
93167802Sjkim    UINT32                          MethodBreakpoint;   /* For single stepping */
94167802Sjkim    UINT32                          UserBreakpoint;     /* User AML breakpoint */
95167802Sjkim    UINT32                          ParseFlags;
9677422Smsmith
97167802Sjkim    ACPI_PARSE_STATE                ParserState;        /* Current state of parser */
98167802Sjkim    UINT32                          PrevArgTypes;
99167802Sjkim    UINT32                          ArgCount;           /* push for fixed or var args */
10084491Smsmith
101167802Sjkim    struct acpi_namespace_node      Arguments[ACPI_METHOD_NUM_ARGS];        /* Control method arguments */
102167802Sjkim    struct acpi_namespace_node      LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */
103167802Sjkim    union acpi_operand_object       *Operands[ACPI_OBJ_NUM_OPERANDS + 1];   /* Operands passed to the interpreter (+1 for NULL terminator) */
104167802Sjkim    union acpi_operand_object       **Params;
10577422Smsmith
106167802Sjkim    UINT8                           *AmlLastWhile;
107167802Sjkim    union acpi_operand_object       **CallerReturnDesc;
108167802Sjkim    ACPI_GENERIC_STATE              *ControlState;      /* List of control states (nested IFs) */
109167802Sjkim    struct acpi_namespace_node      *DeferredNode;      /* Used when executing deferred opcodes */
110167802Sjkim    union acpi_operand_object       *ImplicitReturnObj;
111167802Sjkim    struct acpi_namespace_node      *MethodCallNode;    /* Called method Node*/
112167802Sjkim    ACPI_PARSE_OBJECT               *MethodCallOp;      /* MethodCall Op if running a method */
113167802Sjkim    union acpi_operand_object       *MethodDesc;        /* Method descriptor if running a method */
114167802Sjkim    struct acpi_namespace_node      *MethodNode;        /* Method node if running a method. */
115167802Sjkim    ACPI_PARSE_OBJECT               *Op;                /* Current parser op */
116167802Sjkim    const ACPI_OPCODE_INFO          *OpInfo;            /* Info on current opcode */
117167802Sjkim    ACPI_PARSE_OBJECT               *Origin;            /* Start of walk [Obsolete] */
118167802Sjkim    union acpi_operand_object       *ResultObj;
119167802Sjkim    ACPI_GENERIC_STATE              *Results;           /* Stack of accumulated results */
120167802Sjkim    union acpi_operand_object       *ReturnDesc;        /* Return object, if any */
121167802Sjkim    ACPI_GENERIC_STATE              *ScopeInfo;         /* Stack of nested scopes */
122167802Sjkim    ACPI_PARSE_OBJECT               *PrevOp;            /* Last op that was processed */
123167802Sjkim    ACPI_PARSE_OBJECT               *NextOp;            /* next op to be processed */
124167802Sjkim    ACPI_THREAD_STATE               *Thread;
125167802Sjkim    ACPI_PARSE_DOWNWARDS            DescendingCallback;
126167802Sjkim    ACPI_PARSE_UPWARDS              AscendingCallback;
127167802Sjkim
12877422Smsmith} ACPI_WALK_STATE;
12977422Smsmith
13077422Smsmith
131209746Sjkim/* Info used by AcpiNsInitializeObjects and AcpiDsInitializeObjects */
13277422Smsmith
13377422Smsmithtypedef struct acpi_init_walk_info
13477422Smsmith{
135209746Sjkim    UINT32                          TableIndex;
136209746Sjkim    UINT32                          ObjectCount;
137209746Sjkim    UINT32                          MethodCount;
138281075Sdim    UINT32                          SerialMethodCount;
139281075Sdim    UINT32                          NonSerialMethodCount;
140281075Sdim    UINT32                          SerializedMethodCount;
141209746Sjkim    UINT32                          DeviceCount;
142209746Sjkim    UINT32                          OpRegionCount;
143209746Sjkim    UINT32                          FieldCount;
144209746Sjkim    UINT32                          BufferCount;
145209746Sjkim    UINT32                          PackageCount;
146209746Sjkim    UINT32                          OpRegionInit;
147209746Sjkim    UINT32                          FieldInit;
148209746Sjkim    UINT32                          BufferInit;
149209746Sjkim    UINT32                          PackageInit;
150167802Sjkim    ACPI_OWNER_ID                   OwnerId;
15177422Smsmith
15277422Smsmith} ACPI_INIT_WALK_INFO;
15377422Smsmith
15477422Smsmith
15577422Smsmithtypedef struct acpi_get_devices_info
15677422Smsmith{
157167802Sjkim    ACPI_WALK_CALLBACK              UserFunction;
158167802Sjkim    void                            *Context;
159167802Sjkim    char                            *Hid;
16077422Smsmith
16177422Smsmith} ACPI_GET_DEVICES_INFO;
16277422Smsmith
16377422Smsmith
16485756Smsmithtypedef union acpi_aml_operands
16585756Smsmith{
166167802Sjkim    ACPI_OPERAND_OBJECT             *Operands[7];
16785756Smsmith
16885756Smsmith    struct
16985756Smsmith    {
170167802Sjkim        ACPI_OBJECT_INTEGER             *Type;
171167802Sjkim        ACPI_OBJECT_INTEGER             *Code;
172167802Sjkim        ACPI_OBJECT_INTEGER             *Argument;
17385756Smsmith
17485756Smsmith    } Fatal;
17585756Smsmith
17685756Smsmith    struct
17785756Smsmith    {
178167802Sjkim        ACPI_OPERAND_OBJECT             *Source;
179167802Sjkim        ACPI_OBJECT_INTEGER             *Index;
180167802Sjkim        ACPI_OPERAND_OBJECT             *Target;
18185756Smsmith
18285756Smsmith    } Index;
18385756Smsmith
18485756Smsmith    struct
18585756Smsmith    {
186167802Sjkim        ACPI_OPERAND_OBJECT             *Source;
187167802Sjkim        ACPI_OBJECT_INTEGER             *Index;
188167802Sjkim        ACPI_OBJECT_INTEGER             *Length;
189167802Sjkim        ACPI_OPERAND_OBJECT             *Target;
19085756Smsmith
19185756Smsmith    } Mid;
19285756Smsmith
19385756Smsmith} ACPI_AML_OPERANDS;
19485756Smsmith
19585756Smsmith
196167802Sjkim/*
197249663Sjkim * Structure used to pass object evaluation information and parameters.
198167802Sjkim * Purpose is to reduce CPU stack use.
199167802Sjkim */
200167802Sjkimtypedef struct acpi_evaluate_info
201129684Snjl{
202249663Sjkim    /* The first 3 elements are passed by the caller to AcpiNsEvaluate */
203129684Snjl
204249663Sjkim    ACPI_NAMESPACE_NODE             *PrefixNode;        /* Input: starting node */
205306536Sjkim    const char                      *RelativePathname;  /* Input: path relative to PrefixNode */
206249663Sjkim    ACPI_OPERAND_OBJECT             **Parameters;       /* Input: argument list */
207249663Sjkim
208249663Sjkim    ACPI_NAMESPACE_NODE             *Node;              /* Resolved node (PrefixNode:RelativePathname) */
209249663Sjkim    ACPI_OPERAND_OBJECT             *ObjDesc;           /* Object attached to the resolved node */
210249663Sjkim    char                            *FullPathname;      /* Full pathname of the resolved node */
211249663Sjkim
212249663Sjkim    const ACPI_PREDEFINED_INFO      *Predefined;        /* Used if Node is a predefined name */
213249663Sjkim    ACPI_OPERAND_OBJECT             *ReturnObject;      /* Object returned from the evaluation */
214249663Sjkim    union acpi_operand_object       *ParentPackage;     /* Used if return object is a Package */
215249663Sjkim
216249663Sjkim    UINT32                          ReturnFlags;        /* Used for return value analysis */
217249663Sjkim    UINT32                          ReturnBtype;        /* Bitmapped type of the returned object */
218249663Sjkim    UINT16                          ParamCount;         /* Count of the input argument list */
219249663Sjkim    UINT8                           PassNumber;         /* Parser pass number */
220249663Sjkim    UINT8                           ReturnObjectType;   /* Object type of the returned object */
221249663Sjkim    UINT8                           NodeFlags;          /* Same as Node->Flags */
222249663Sjkim    UINT8                           Flags;              /* General flags */
223249663Sjkim
224167802Sjkim} ACPI_EVALUATE_INFO;
225129684Snjl
226167802Sjkim/* Values for Flags above */
227129684Snjl
228249663Sjkim#define ACPI_IGNORE_RETURN_VALUE    1
229167802Sjkim
230249663Sjkim/* Defines for ReturnFlags field above */
231167802Sjkim
232249663Sjkim#define ACPI_OBJECT_REPAIRED        1
233249663Sjkim#define ACPI_OBJECT_WRAPPED         2
234249663Sjkim
235249663Sjkim
236167802Sjkim/* Info used by AcpiNsInitializeDevices */
237167802Sjkim
238167802Sjkimtypedef struct acpi_device_walk_info
239167802Sjkim{
240167802Sjkim    ACPI_TABLE_DESC                 *TableDesc;
241167802Sjkim    ACPI_EVALUATE_INFO              *EvaluateInfo;
242209746Sjkim    UINT32                          DeviceCount;
243209746Sjkim    UINT32                          Num_STA;
244209746Sjkim    UINT32                          Num_INI;
245167802Sjkim
246167802Sjkim} ACPI_DEVICE_WALK_INFO;
247167802Sjkim
248167802Sjkim
249167802Sjkim/* TBD: [Restructure] Merge with struct above */
250167802Sjkim
251167802Sjkimtypedef struct acpi_walk_info
252167802Sjkim{
253167802Sjkim    UINT32                          DebugLevel;
254167802Sjkim    UINT32                          Count;
255167802Sjkim    ACPI_OWNER_ID                   OwnerId;
256167802Sjkim    UINT8                           DisplayType;
257167802Sjkim
258167802Sjkim} ACPI_WALK_INFO;
259167802Sjkim
260167802Sjkim/* Display Types */
261167802Sjkim
262167802Sjkim#define ACPI_DISPLAY_SUMMARY        (UINT8) 0
263167802Sjkim#define ACPI_DISPLAY_OBJECTS        (UINT8) 1
264167802Sjkim#define ACPI_DISPLAY_MASK           (UINT8) 1
265167802Sjkim
266167802Sjkim#define ACPI_DISPLAY_SHORT          (UINT8) 2
267167802Sjkim
268167802Sjkim
26977422Smsmith#endif
270