asllookup.c revision 1.1.1.2.4.2 1 1.1.1.2.4.2 rmind /******************************************************************************
2 1.1.1.2.4.2 rmind *
3 1.1.1.2.4.2 rmind * Module Name: asllookup- Namespace lookup
4 1.1.1.2.4.2 rmind *
5 1.1.1.2.4.2 rmind *****************************************************************************/
6 1.1.1.2.4.2 rmind
7 1.1.1.2.4.2 rmind /*
8 1.1.1.2.4.2 rmind * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.4.2 rmind * All rights reserved.
10 1.1.1.2.4.2 rmind *
11 1.1.1.2.4.2 rmind * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.4.2 rmind * modification, are permitted provided that the following conditions
13 1.1.1.2.4.2 rmind * are met:
14 1.1.1.2.4.2 rmind * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.4.2 rmind * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.4.2 rmind * without modification.
17 1.1.1.2.4.2 rmind * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.4.2 rmind * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.4.2 rmind * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.4.2 rmind * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.4.2 rmind * binary redistribution.
22 1.1.1.2.4.2 rmind * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.4.2 rmind * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.4.2 rmind * from this software without specific prior written permission.
25 1.1.1.2.4.2 rmind *
26 1.1.1.2.4.2 rmind * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.4.2 rmind * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.4.2 rmind * Software Foundation.
29 1.1.1.2.4.2 rmind *
30 1.1.1.2.4.2 rmind * NO WARRANTY
31 1.1.1.2.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.4.2 rmind * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.4.2 rmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.4.2 rmind * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.4.2 rmind * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.4.2 rmind * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.4.2 rmind */
43 1.1.1.2.4.2 rmind
44 1.1.1.2.4.2 rmind
45 1.1.1.2.4.2 rmind #include "aslcompiler.h"
46 1.1.1.2.4.2 rmind #include "aslcompiler.y.h"
47 1.1.1.2.4.2 rmind
48 1.1.1.2.4.2 rmind #include "acparser.h"
49 1.1.1.2.4.2 rmind #include "amlcode.h"
50 1.1.1.2.4.2 rmind #include "acnamesp.h"
51 1.1.1.2.4.2 rmind #include "acdispat.h"
52 1.1.1.2.4.2 rmind
53 1.1.1.2.4.2 rmind
54 1.1.1.2.4.2 rmind #define _COMPONENT ACPI_COMPILER
55 1.1.1.2.4.2 rmind ACPI_MODULE_NAME ("asllookup")
56 1.1.1.2.4.2 rmind
57 1.1.1.2.4.2 rmind /* Local prototypes */
58 1.1.1.2.4.2 rmind
59 1.1.1.2.4.2 rmind static ACPI_STATUS
60 1.1.1.2.4.2 rmind LsCompareOneNamespaceObject (
61 1.1.1.2.4.2 rmind ACPI_HANDLE ObjHandle,
62 1.1.1.2.4.2 rmind UINT32 Level,
63 1.1.1.2.4.2 rmind void *Context,
64 1.1.1.2.4.2 rmind void **ReturnValue);
65 1.1.1.2.4.2 rmind
66 1.1.1.2.4.2 rmind static ACPI_STATUS
67 1.1.1.2.4.2 rmind LsDoOneNamespaceObject (
68 1.1.1.2.4.2 rmind ACPI_HANDLE ObjHandle,
69 1.1.1.2.4.2 rmind UINT32 Level,
70 1.1.1.2.4.2 rmind void *Context,
71 1.1.1.2.4.2 rmind void **ReturnValue);
72 1.1.1.2.4.2 rmind
73 1.1.1.2.4.2 rmind static BOOLEAN
74 1.1.1.2.4.2 rmind LkObjectExists (
75 1.1.1.2.4.2 rmind char *Name);
76 1.1.1.2.4.2 rmind
77 1.1.1.2.4.2 rmind static void
78 1.1.1.2.4.2 rmind LkCheckFieldRange (
79 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
80 1.1.1.2.4.2 rmind UINT32 RegionBitLength,
81 1.1.1.2.4.2 rmind UINT32 FieldBitOffset,
82 1.1.1.2.4.2 rmind UINT32 FieldBitLength,
83 1.1.1.2.4.2 rmind UINT32 AccessBitWidth);
84 1.1.1.2.4.2 rmind
85 1.1.1.2.4.2 rmind static ACPI_STATUS
86 1.1.1.2.4.2 rmind LkNamespaceLocateBegin (
87 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
88 1.1.1.2.4.2 rmind UINT32 Level,
89 1.1.1.2.4.2 rmind void *Context);
90 1.1.1.2.4.2 rmind
91 1.1.1.2.4.2 rmind static ACPI_STATUS
92 1.1.1.2.4.2 rmind LkNamespaceLocateEnd (
93 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
94 1.1.1.2.4.2 rmind UINT32 Level,
95 1.1.1.2.4.2 rmind void *Context);
96 1.1.1.2.4.2 rmind
97 1.1.1.2.4.2 rmind static ACPI_STATUS
98 1.1.1.2.4.2 rmind LkIsObjectUsed (
99 1.1.1.2.4.2 rmind ACPI_HANDLE ObjHandle,
100 1.1.1.2.4.2 rmind UINT32 Level,
101 1.1.1.2.4.2 rmind void *Context,
102 1.1.1.2.4.2 rmind void **ReturnValue);
103 1.1.1.2.4.2 rmind
104 1.1.1.2.4.2 rmind static ACPI_STATUS
105 1.1.1.2.4.2 rmind LsDoOnePathname (
106 1.1.1.2.4.2 rmind ACPI_HANDLE ObjHandle,
107 1.1.1.2.4.2 rmind UINT32 Level,
108 1.1.1.2.4.2 rmind void *Context,
109 1.1.1.2.4.2 rmind void **ReturnValue);
110 1.1.1.2.4.2 rmind
111 1.1.1.2.4.2 rmind static ACPI_PARSE_OBJECT *
112 1.1.1.2.4.2 rmind LkGetNameOp (
113 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op);
114 1.1.1.2.4.2 rmind
115 1.1.1.2.4.2 rmind
116 1.1.1.2.4.2 rmind /*******************************************************************************
117 1.1.1.2.4.2 rmind *
118 1.1.1.2.4.2 rmind * FUNCTION: LsDoOneNamespaceObject
119 1.1.1.2.4.2 rmind *
120 1.1.1.2.4.2 rmind * PARAMETERS: ACPI_WALK_CALLBACK
121 1.1.1.2.4.2 rmind *
122 1.1.1.2.4.2 rmind * RETURN: Status
123 1.1.1.2.4.2 rmind *
124 1.1.1.2.4.2 rmind * DESCRIPTION: Dump a namespace object to the namespace output file.
125 1.1.1.2.4.2 rmind * Called during the walk of the namespace to dump all objects.
126 1.1.1.2.4.2 rmind *
127 1.1.1.2.4.2 rmind ******************************************************************************/
128 1.1.1.2.4.2 rmind
129 1.1.1.2.4.2 rmind static ACPI_STATUS
130 1.1.1.2.4.2 rmind LsDoOneNamespaceObject (
131 1.1.1.2.4.2 rmind ACPI_HANDLE ObjHandle,
132 1.1.1.2.4.2 rmind UINT32 Level,
133 1.1.1.2.4.2 rmind void *Context,
134 1.1.1.2.4.2 rmind void **ReturnValue)
135 1.1.1.2.4.2 rmind {
136 1.1.1.2.4.2 rmind ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
137 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *ObjDesc;
138 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op;
139 1.1.1.2.4.2 rmind
140 1.1.1.2.4.2 rmind
141 1.1.1.2.4.2 rmind Gbl_NumNamespaceObjects++;
142 1.1.1.2.4.2 rmind
143 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5u [%u] %*s %4.4s - %s",
144 1.1.1.2.4.2 rmind Gbl_NumNamespaceObjects, Level, (Level * 3), " ",
145 1.1.1.2.4.2 rmind &Node->Name,
146 1.1.1.2.4.2 rmind AcpiUtGetTypeName (Node->Type));
147 1.1.1.2.4.2 rmind
148 1.1.1.2.4.2 rmind Op = Node->Op;
149 1.1.1.2.4.2 rmind ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node->Object);
150 1.1.1.2.4.2 rmind
151 1.1.1.2.4.2 rmind if (!Op)
152 1.1.1.2.4.2 rmind {
153 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n");
154 1.1.1.2.4.2 rmind return (AE_OK);
155 1.1.1.2.4.2 rmind }
156 1.1.1.2.4.2 rmind
157 1.1.1.2.4.2 rmind
158 1.1.1.2.4.2 rmind if ((ObjDesc) &&
159 1.1.1.2.4.2 rmind (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND))
160 1.1.1.2.4.2 rmind {
161 1.1.1.2.4.2 rmind switch (Node->Type)
162 1.1.1.2.4.2 rmind {
163 1.1.1.2.4.2 rmind case ACPI_TYPE_INTEGER:
164 1.1.1.2.4.2 rmind
165 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
166 1.1.1.2.4.2 rmind " [Initial Value 0x%8.8X%8.8X]",
167 1.1.1.2.4.2 rmind ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
168 1.1.1.2.4.2 rmind break;
169 1.1.1.2.4.2 rmind
170 1.1.1.2.4.2 rmind
171 1.1.1.2.4.2 rmind case ACPI_TYPE_STRING:
172 1.1.1.2.4.2 rmind
173 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
174 1.1.1.2.4.2 rmind " [Initial Value \"%s\"]",
175 1.1.1.2.4.2 rmind ObjDesc->String.Pointer);
176 1.1.1.2.4.2 rmind break;
177 1.1.1.2.4.2 rmind
178 1.1.1.2.4.2 rmind default:
179 1.1.1.2.4.2 rmind /* Nothing to do for other types */
180 1.1.1.2.4.2 rmind break;
181 1.1.1.2.4.2 rmind }
182 1.1.1.2.4.2 rmind
183 1.1.1.2.4.2 rmind }
184 1.1.1.2.4.2 rmind else
185 1.1.1.2.4.2 rmind {
186 1.1.1.2.4.2 rmind switch (Node->Type)
187 1.1.1.2.4.2 rmind {
188 1.1.1.2.4.2 rmind case ACPI_TYPE_INTEGER:
189 1.1.1.2.4.2 rmind
190 1.1.1.2.4.2 rmind if (Op->Asl.ParseOpcode == PARSEOP_NAME)
191 1.1.1.2.4.2 rmind {
192 1.1.1.2.4.2 rmind Op = Op->Asl.Child;
193 1.1.1.2.4.2 rmind }
194 1.1.1.2.4.2 rmind if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
195 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
196 1.1.1.2.4.2 rmind {
197 1.1.1.2.4.2 rmind Op = Op->Asl.Next;
198 1.1.1.2.4.2 rmind }
199 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
200 1.1.1.2.4.2 rmind " [Initial Value 0x%8.8X%8.8X]",
201 1.1.1.2.4.2 rmind ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
202 1.1.1.2.4.2 rmind break;
203 1.1.1.2.4.2 rmind
204 1.1.1.2.4.2 rmind
205 1.1.1.2.4.2 rmind case ACPI_TYPE_STRING:
206 1.1.1.2.4.2 rmind
207 1.1.1.2.4.2 rmind if (Op->Asl.ParseOpcode == PARSEOP_NAME)
208 1.1.1.2.4.2 rmind {
209 1.1.1.2.4.2 rmind Op = Op->Asl.Child;
210 1.1.1.2.4.2 rmind }
211 1.1.1.2.4.2 rmind if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
212 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
213 1.1.1.2.4.2 rmind {
214 1.1.1.2.4.2 rmind Op = Op->Asl.Next;
215 1.1.1.2.4.2 rmind }
216 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
217 1.1.1.2.4.2 rmind " [Initial Value \"%s\"]",
218 1.1.1.2.4.2 rmind Op->Asl.Value.String);
219 1.1.1.2.4.2 rmind break;
220 1.1.1.2.4.2 rmind
221 1.1.1.2.4.2 rmind
222 1.1.1.2.4.2 rmind case ACPI_TYPE_LOCAL_REGION_FIELD:
223 1.1.1.2.4.2 rmind
224 1.1.1.2.4.2 rmind if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
225 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
226 1.1.1.2.4.2 rmind {
227 1.1.1.2.4.2 rmind Op = Op->Asl.Child;
228 1.1.1.2.4.2 rmind }
229 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
230 1.1.1.2.4.2 rmind " [Offset 0x%04X Length 0x%04X bits]",
231 1.1.1.2.4.2 rmind Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer);
232 1.1.1.2.4.2 rmind break;
233 1.1.1.2.4.2 rmind
234 1.1.1.2.4.2 rmind
235 1.1.1.2.4.2 rmind case ACPI_TYPE_BUFFER_FIELD:
236 1.1.1.2.4.2 rmind
237 1.1.1.2.4.2 rmind switch (Op->Asl.ParseOpcode)
238 1.1.1.2.4.2 rmind {
239 1.1.1.2.4.2 rmind case PARSEOP_CREATEBYTEFIELD:
240 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BYTE ( 8 bit)]");
241 1.1.1.2.4.2 rmind break;
242 1.1.1.2.4.2 rmind
243 1.1.1.2.4.2 rmind case PARSEOP_CREATEDWORDFIELD:
244 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [DWORD (32 bit)]");
245 1.1.1.2.4.2 rmind break;
246 1.1.1.2.4.2 rmind
247 1.1.1.2.4.2 rmind case PARSEOP_CREATEQWORDFIELD:
248 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [QWORD (64 bit)]");
249 1.1.1.2.4.2 rmind break;
250 1.1.1.2.4.2 rmind
251 1.1.1.2.4.2 rmind case PARSEOP_CREATEWORDFIELD:
252 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [WORD (16 bit)]");
253 1.1.1.2.4.2 rmind break;
254 1.1.1.2.4.2 rmind
255 1.1.1.2.4.2 rmind case PARSEOP_CREATEBITFIELD:
256 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BIT ( 1 bit)]");
257 1.1.1.2.4.2 rmind break;
258 1.1.1.2.4.2 rmind
259 1.1.1.2.4.2 rmind case PARSEOP_CREATEFIELD:
260 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Arbitrary Bit Field]");
261 1.1.1.2.4.2 rmind break;
262 1.1.1.2.4.2 rmind
263 1.1.1.2.4.2 rmind default:
264 1.1.1.2.4.2 rmind break;
265 1.1.1.2.4.2 rmind
266 1.1.1.2.4.2 rmind }
267 1.1.1.2.4.2 rmind break;
268 1.1.1.2.4.2 rmind
269 1.1.1.2.4.2 rmind
270 1.1.1.2.4.2 rmind case ACPI_TYPE_PACKAGE:
271 1.1.1.2.4.2 rmind
272 1.1.1.2.4.2 rmind if (Op->Asl.ParseOpcode == PARSEOP_NAME)
273 1.1.1.2.4.2 rmind {
274 1.1.1.2.4.2 rmind Op = Op->Asl.Child;
275 1.1.1.2.4.2 rmind }
276 1.1.1.2.4.2 rmind if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
277 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
278 1.1.1.2.4.2 rmind {
279 1.1.1.2.4.2 rmind Op = Op->Asl.Next;
280 1.1.1.2.4.2 rmind }
281 1.1.1.2.4.2 rmind Op = Op->Asl.Child;
282 1.1.1.2.4.2 rmind
283 1.1.1.2.4.2 rmind if ((Op->Asl.ParseOpcode == PARSEOP_BYTECONST) ||
284 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_RAW_DATA))
285 1.1.1.2.4.2 rmind {
286 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
287 1.1.1.2.4.2 rmind " [Initial Length 0x%.2X elements]",
288 1.1.1.2.4.2 rmind Op->Asl.Value.Integer);
289 1.1.1.2.4.2 rmind }
290 1.1.1.2.4.2 rmind break;
291 1.1.1.2.4.2 rmind
292 1.1.1.2.4.2 rmind
293 1.1.1.2.4.2 rmind case ACPI_TYPE_BUFFER:
294 1.1.1.2.4.2 rmind
295 1.1.1.2.4.2 rmind if (Op->Asl.ParseOpcode == PARSEOP_NAME)
296 1.1.1.2.4.2 rmind {
297 1.1.1.2.4.2 rmind Op = Op->Asl.Child;
298 1.1.1.2.4.2 rmind }
299 1.1.1.2.4.2 rmind if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
300 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
301 1.1.1.2.4.2 rmind {
302 1.1.1.2.4.2 rmind Op = Op->Asl.Next;
303 1.1.1.2.4.2 rmind }
304 1.1.1.2.4.2 rmind Op = Op->Asl.Child;
305 1.1.1.2.4.2 rmind
306 1.1.1.2.4.2 rmind if (Op && (Op->Asl.ParseOpcode == PARSEOP_INTEGER))
307 1.1.1.2.4.2 rmind {
308 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
309 1.1.1.2.4.2 rmind " [Initial Length 0x%.2X bytes]",
310 1.1.1.2.4.2 rmind Op->Asl.Value.Integer);
311 1.1.1.2.4.2 rmind }
312 1.1.1.2.4.2 rmind break;
313 1.1.1.2.4.2 rmind
314 1.1.1.2.4.2 rmind
315 1.1.1.2.4.2 rmind case ACPI_TYPE_METHOD:
316 1.1.1.2.4.2 rmind
317 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
318 1.1.1.2.4.2 rmind " [Code Length 0x%.4X bytes]",
319 1.1.1.2.4.2 rmind Op->Asl.AmlSubtreeLength);
320 1.1.1.2.4.2 rmind break;
321 1.1.1.2.4.2 rmind
322 1.1.1.2.4.2 rmind
323 1.1.1.2.4.2 rmind case ACPI_TYPE_LOCAL_RESOURCE:
324 1.1.1.2.4.2 rmind
325 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
326 1.1.1.2.4.2 rmind " [Desc Offset 0x%.4X Bytes]", Node->Value);
327 1.1.1.2.4.2 rmind break;
328 1.1.1.2.4.2 rmind
329 1.1.1.2.4.2 rmind
330 1.1.1.2.4.2 rmind case ACPI_TYPE_LOCAL_RESOURCE_FIELD:
331 1.1.1.2.4.2 rmind
332 1.1.1.2.4.2 rmind if (Node->Flags & 0x80)
333 1.1.1.2.4.2 rmind {
334 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
335 1.1.1.2.4.2 rmind " [Field Offset 0x%.4X Bits 0x%.4X Bytes]",
336 1.1.1.2.4.2 rmind Node->Value, Node->Value / 8);
337 1.1.1.2.4.2 rmind }
338 1.1.1.2.4.2 rmind else
339 1.1.1.2.4.2 rmind {
340 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
341 1.1.1.2.4.2 rmind " [Field Offset 0x%.4X Bytes]", Node->Value);
342 1.1.1.2.4.2 rmind }
343 1.1.1.2.4.2 rmind break;
344 1.1.1.2.4.2 rmind
345 1.1.1.2.4.2 rmind
346 1.1.1.2.4.2 rmind default:
347 1.1.1.2.4.2 rmind /* Nothing to do for other types */
348 1.1.1.2.4.2 rmind break;
349 1.1.1.2.4.2 rmind }
350 1.1.1.2.4.2 rmind }
351 1.1.1.2.4.2 rmind
352 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n");
353 1.1.1.2.4.2 rmind return (AE_OK);
354 1.1.1.2.4.2 rmind }
355 1.1.1.2.4.2 rmind
356 1.1.1.2.4.2 rmind
357 1.1.1.2.4.2 rmind /*******************************************************************************
358 1.1.1.2.4.2 rmind *
359 1.1.1.2.4.2 rmind * FUNCTION: LsSetupNsList
360 1.1.1.2.4.2 rmind *
361 1.1.1.2.4.2 rmind * PARAMETERS: Handle - local file handle
362 1.1.1.2.4.2 rmind *
363 1.1.1.2.4.2 rmind * RETURN: None
364 1.1.1.2.4.2 rmind *
365 1.1.1.2.4.2 rmind * DESCRIPTION: Set the namespace output file to the input handle
366 1.1.1.2.4.2 rmind *
367 1.1.1.2.4.2 rmind ******************************************************************************/
368 1.1.1.2.4.2 rmind
369 1.1.1.2.4.2 rmind void
370 1.1.1.2.4.2 rmind LsSetupNsList (
371 1.1.1.2.4.2 rmind void *Handle)
372 1.1.1.2.4.2 rmind {
373 1.1.1.2.4.2 rmind
374 1.1.1.2.4.2 rmind Gbl_NsOutputFlag = TRUE;
375 1.1.1.2.4.2 rmind Gbl_Files[ASL_FILE_NAMESPACE_OUTPUT].Handle = Handle;
376 1.1.1.2.4.2 rmind }
377 1.1.1.2.4.2 rmind
378 1.1.1.2.4.2 rmind
379 1.1.1.2.4.2 rmind /*******************************************************************************
380 1.1.1.2.4.2 rmind *
381 1.1.1.2.4.2 rmind * FUNCTION: LsDoOnePathname
382 1.1.1.2.4.2 rmind *
383 1.1.1.2.4.2 rmind * PARAMETERS: ACPI_WALK_CALLBACK
384 1.1.1.2.4.2 rmind *
385 1.1.1.2.4.2 rmind * RETURN: Status
386 1.1.1.2.4.2 rmind *
387 1.1.1.2.4.2 rmind * DESCRIPTION: Print the full pathname for a namespace node.
388 1.1.1.2.4.2 rmind *
389 1.1.1.2.4.2 rmind ******************************************************************************/
390 1.1.1.2.4.2 rmind
391 1.1.1.2.4.2 rmind static ACPI_STATUS
392 1.1.1.2.4.2 rmind LsDoOnePathname (
393 1.1.1.2.4.2 rmind ACPI_HANDLE ObjHandle,
394 1.1.1.2.4.2 rmind UINT32 Level,
395 1.1.1.2.4.2 rmind void *Context,
396 1.1.1.2.4.2 rmind void **ReturnValue)
397 1.1.1.2.4.2 rmind {
398 1.1.1.2.4.2 rmind ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
399 1.1.1.2.4.2 rmind ACPI_STATUS Status;
400 1.1.1.2.4.2 rmind ACPI_BUFFER TargetPath;
401 1.1.1.2.4.2 rmind
402 1.1.1.2.4.2 rmind
403 1.1.1.2.4.2 rmind TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
404 1.1.1.2.4.2 rmind Status = AcpiNsHandleToPathname (Node, &TargetPath);
405 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
406 1.1.1.2.4.2 rmind {
407 1.1.1.2.4.2 rmind return (Status);
408 1.1.1.2.4.2 rmind }
409 1.1.1.2.4.2 rmind
410 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%s\n", TargetPath.Pointer);
411 1.1.1.2.4.2 rmind ACPI_FREE (TargetPath.Pointer);
412 1.1.1.2.4.2 rmind
413 1.1.1.2.4.2 rmind return (AE_OK);
414 1.1.1.2.4.2 rmind }
415 1.1.1.2.4.2 rmind
416 1.1.1.2.4.2 rmind
417 1.1.1.2.4.2 rmind /*******************************************************************************
418 1.1.1.2.4.2 rmind *
419 1.1.1.2.4.2 rmind * FUNCTION: LsDisplayNamespace
420 1.1.1.2.4.2 rmind *
421 1.1.1.2.4.2 rmind * PARAMETERS: None
422 1.1.1.2.4.2 rmind *
423 1.1.1.2.4.2 rmind * RETURN: Status
424 1.1.1.2.4.2 rmind *
425 1.1.1.2.4.2 rmind * DESCRIPTION: Walk the namespace an display information about each node
426 1.1.1.2.4.2 rmind * in the tree. Information is written to the optional
427 1.1.1.2.4.2 rmind * namespace output file.
428 1.1.1.2.4.2 rmind *
429 1.1.1.2.4.2 rmind ******************************************************************************/
430 1.1.1.2.4.2 rmind
431 1.1.1.2.4.2 rmind ACPI_STATUS
432 1.1.1.2.4.2 rmind LsDisplayNamespace (
433 1.1.1.2.4.2 rmind void)
434 1.1.1.2.4.2 rmind {
435 1.1.1.2.4.2 rmind ACPI_STATUS Status;
436 1.1.1.2.4.2 rmind
437 1.1.1.2.4.2 rmind
438 1.1.1.2.4.2 rmind if (!Gbl_NsOutputFlag)
439 1.1.1.2.4.2 rmind {
440 1.1.1.2.4.2 rmind return (AE_OK);
441 1.1.1.2.4.2 rmind }
442 1.1.1.2.4.2 rmind
443 1.1.1.2.4.2 rmind Gbl_NumNamespaceObjects = 0;
444 1.1.1.2.4.2 rmind
445 1.1.1.2.4.2 rmind /* File header */
446 1.1.1.2.4.2 rmind
447 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Contents of ACPI Namespace\n\n");
448 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Count Depth Name - Type\n\n");
449 1.1.1.2.4.2 rmind
450 1.1.1.2.4.2 rmind /* Walk entire namespace from the root */
451 1.1.1.2.4.2 rmind
452 1.1.1.2.4.2 rmind Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
453 1.1.1.2.4.2 rmind ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject, NULL,
454 1.1.1.2.4.2 rmind NULL, NULL);
455 1.1.1.2.4.2 rmind
456 1.1.1.2.4.2 rmind /* Print the full pathname for each namespace node */
457 1.1.1.2.4.2 rmind
458 1.1.1.2.4.2 rmind FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\nNamespace pathnames\n\n");
459 1.1.1.2.4.2 rmind
460 1.1.1.2.4.2 rmind Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
461 1.1.1.2.4.2 rmind ACPI_UINT32_MAX, FALSE, LsDoOnePathname, NULL,
462 1.1.1.2.4.2 rmind NULL, NULL);
463 1.1.1.2.4.2 rmind
464 1.1.1.2.4.2 rmind return (Status);
465 1.1.1.2.4.2 rmind }
466 1.1.1.2.4.2 rmind
467 1.1.1.2.4.2 rmind
468 1.1.1.2.4.2 rmind /*******************************************************************************
469 1.1.1.2.4.2 rmind *
470 1.1.1.2.4.2 rmind * FUNCTION: LsCompareOneNamespaceObject
471 1.1.1.2.4.2 rmind *
472 1.1.1.2.4.2 rmind * PARAMETERS: ACPI_WALK_CALLBACK
473 1.1.1.2.4.2 rmind *
474 1.1.1.2.4.2 rmind * RETURN: Status
475 1.1.1.2.4.2 rmind *
476 1.1.1.2.4.2 rmind * DESCRIPTION: Compare name of one object.
477 1.1.1.2.4.2 rmind *
478 1.1.1.2.4.2 rmind ******************************************************************************/
479 1.1.1.2.4.2 rmind
480 1.1.1.2.4.2 rmind static ACPI_STATUS
481 1.1.1.2.4.2 rmind LsCompareOneNamespaceObject (
482 1.1.1.2.4.2 rmind ACPI_HANDLE ObjHandle,
483 1.1.1.2.4.2 rmind UINT32 Level,
484 1.1.1.2.4.2 rmind void *Context,
485 1.1.1.2.4.2 rmind void **ReturnValue)
486 1.1.1.2.4.2 rmind {
487 1.1.1.2.4.2 rmind ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
488 1.1.1.2.4.2 rmind
489 1.1.1.2.4.2 rmind
490 1.1.1.2.4.2 rmind /* Simply check the name */
491 1.1.1.2.4.2 rmind
492 1.1.1.2.4.2 rmind if (*((UINT32 *) (Context)) == Node->Name.Integer)
493 1.1.1.2.4.2 rmind {
494 1.1.1.2.4.2 rmind /* Abort walk if we found one instance */
495 1.1.1.2.4.2 rmind
496 1.1.1.2.4.2 rmind return (AE_CTRL_TRUE);
497 1.1.1.2.4.2 rmind }
498 1.1.1.2.4.2 rmind
499 1.1.1.2.4.2 rmind return (AE_OK);
500 1.1.1.2.4.2 rmind }
501 1.1.1.2.4.2 rmind
502 1.1.1.2.4.2 rmind
503 1.1.1.2.4.2 rmind /*******************************************************************************
504 1.1.1.2.4.2 rmind *
505 1.1.1.2.4.2 rmind * FUNCTION: LkObjectExists
506 1.1.1.2.4.2 rmind *
507 1.1.1.2.4.2 rmind * PARAMETERS: Name - 4 char ACPI name
508 1.1.1.2.4.2 rmind *
509 1.1.1.2.4.2 rmind * RETURN: TRUE if name exists in namespace
510 1.1.1.2.4.2 rmind *
511 1.1.1.2.4.2 rmind * DESCRIPTION: Walk the namespace to find an object
512 1.1.1.2.4.2 rmind *
513 1.1.1.2.4.2 rmind ******************************************************************************/
514 1.1.1.2.4.2 rmind
515 1.1.1.2.4.2 rmind static BOOLEAN
516 1.1.1.2.4.2 rmind LkObjectExists (
517 1.1.1.2.4.2 rmind char *Name)
518 1.1.1.2.4.2 rmind {
519 1.1.1.2.4.2 rmind ACPI_STATUS Status;
520 1.1.1.2.4.2 rmind
521 1.1.1.2.4.2 rmind
522 1.1.1.2.4.2 rmind /* Walk entire namespace from the supplied root */
523 1.1.1.2.4.2 rmind
524 1.1.1.2.4.2 rmind Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
525 1.1.1.2.4.2 rmind ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject, NULL,
526 1.1.1.2.4.2 rmind Name, NULL);
527 1.1.1.2.4.2 rmind if (Status == AE_CTRL_TRUE)
528 1.1.1.2.4.2 rmind {
529 1.1.1.2.4.2 rmind /* At least one instance of the name was found */
530 1.1.1.2.4.2 rmind
531 1.1.1.2.4.2 rmind return (TRUE);
532 1.1.1.2.4.2 rmind }
533 1.1.1.2.4.2 rmind
534 1.1.1.2.4.2 rmind return (FALSE);
535 1.1.1.2.4.2 rmind }
536 1.1.1.2.4.2 rmind
537 1.1.1.2.4.2 rmind
538 1.1.1.2.4.2 rmind /*******************************************************************************
539 1.1.1.2.4.2 rmind *
540 1.1.1.2.4.2 rmind * FUNCTION: LkGetNameOp
541 1.1.1.2.4.2 rmind *
542 1.1.1.2.4.2 rmind * PARAMETERS: Op - Current Op
543 1.1.1.2.4.2 rmind *
544 1.1.1.2.4.2 rmind * RETURN: NameOp associated with the input op
545 1.1.1.2.4.2 rmind *
546 1.1.1.2.4.2 rmind * DESCRIPTION: Find the name declaration op associated with the operator
547 1.1.1.2.4.2 rmind *
548 1.1.1.2.4.2 rmind ******************************************************************************/
549 1.1.1.2.4.2 rmind
550 1.1.1.2.4.2 rmind static ACPI_PARSE_OBJECT *
551 1.1.1.2.4.2 rmind LkGetNameOp (
552 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op)
553 1.1.1.2.4.2 rmind {
554 1.1.1.2.4.2 rmind const ACPI_OPCODE_INFO *OpInfo;
555 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *NameOp = Op;
556 1.1.1.2.4.2 rmind
557 1.1.1.2.4.2 rmind
558 1.1.1.2.4.2 rmind OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
559 1.1.1.2.4.2 rmind
560 1.1.1.2.4.2 rmind
561 1.1.1.2.4.2 rmind /* Get the NamePath from the appropriate place */
562 1.1.1.2.4.2 rmind
563 1.1.1.2.4.2 rmind if (OpInfo->Flags & AML_NAMED)
564 1.1.1.2.4.2 rmind {
565 1.1.1.2.4.2 rmind /* For nearly all NAMED operators, the name reference is the first child */
566 1.1.1.2.4.2 rmind
567 1.1.1.2.4.2 rmind NameOp = Op->Asl.Child;
568 1.1.1.2.4.2 rmind if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
569 1.1.1.2.4.2 rmind {
570 1.1.1.2.4.2 rmind /*
571 1.1.1.2.4.2 rmind * ALIAS is the only oddball opcode, the name declaration
572 1.1.1.2.4.2 rmind * (alias name) is the second operand
573 1.1.1.2.4.2 rmind */
574 1.1.1.2.4.2 rmind NameOp = Op->Asl.Child->Asl.Next;
575 1.1.1.2.4.2 rmind }
576 1.1.1.2.4.2 rmind }
577 1.1.1.2.4.2 rmind else if (OpInfo->Flags & AML_CREATE)
578 1.1.1.2.4.2 rmind {
579 1.1.1.2.4.2 rmind /* Name must appear as the last parameter */
580 1.1.1.2.4.2 rmind
581 1.1.1.2.4.2 rmind NameOp = Op->Asl.Child;
582 1.1.1.2.4.2 rmind while (!(NameOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
583 1.1.1.2.4.2 rmind {
584 1.1.1.2.4.2 rmind NameOp = NameOp->Asl.Next;
585 1.1.1.2.4.2 rmind }
586 1.1.1.2.4.2 rmind }
587 1.1.1.2.4.2 rmind
588 1.1.1.2.4.2 rmind return (NameOp);
589 1.1.1.2.4.2 rmind }
590 1.1.1.2.4.2 rmind
591 1.1.1.2.4.2 rmind
592 1.1.1.2.4.2 rmind /*******************************************************************************
593 1.1.1.2.4.2 rmind *
594 1.1.1.2.4.2 rmind * FUNCTION: LkIsObjectUsed
595 1.1.1.2.4.2 rmind *
596 1.1.1.2.4.2 rmind * PARAMETERS: ACPI_WALK_CALLBACK
597 1.1.1.2.4.2 rmind *
598 1.1.1.2.4.2 rmind * RETURN: Status
599 1.1.1.2.4.2 rmind *
600 1.1.1.2.4.2 rmind * DESCRIPTION: Check for an unreferenced namespace object and emit a warning.
601 1.1.1.2.4.2 rmind * We have to be careful, because some types and names are
602 1.1.1.2.4.2 rmind * typically or always unreferenced, we don't want to issue
603 1.1.1.2.4.2 rmind * excessive warnings.
604 1.1.1.2.4.2 rmind *
605 1.1.1.2.4.2 rmind ******************************************************************************/
606 1.1.1.2.4.2 rmind
607 1.1.1.2.4.2 rmind static ACPI_STATUS
608 1.1.1.2.4.2 rmind LkIsObjectUsed (
609 1.1.1.2.4.2 rmind ACPI_HANDLE ObjHandle,
610 1.1.1.2.4.2 rmind UINT32 Level,
611 1.1.1.2.4.2 rmind void *Context,
612 1.1.1.2.4.2 rmind void **ReturnValue)
613 1.1.1.2.4.2 rmind {
614 1.1.1.2.4.2 rmind ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
615 1.1.1.2.4.2 rmind
616 1.1.1.2.4.2 rmind
617 1.1.1.2.4.2 rmind /* Referenced flag is set during the namespace xref */
618 1.1.1.2.4.2 rmind
619 1.1.1.2.4.2 rmind if (Node->Flags & ANOBJ_IS_REFERENCED)
620 1.1.1.2.4.2 rmind {
621 1.1.1.2.4.2 rmind return (AE_OK);
622 1.1.1.2.4.2 rmind }
623 1.1.1.2.4.2 rmind
624 1.1.1.2.4.2 rmind /*
625 1.1.1.2.4.2 rmind * Ignore names that start with an underscore,
626 1.1.1.2.4.2 rmind * these are the reserved ACPI names and are typically not referenced,
627 1.1.1.2.4.2 rmind * they are called by the host OS.
628 1.1.1.2.4.2 rmind */
629 1.1.1.2.4.2 rmind if (Node->Name.Ascii[0] == '_')
630 1.1.1.2.4.2 rmind {
631 1.1.1.2.4.2 rmind return (AE_OK);
632 1.1.1.2.4.2 rmind }
633 1.1.1.2.4.2 rmind
634 1.1.1.2.4.2 rmind /* There are some types that are typically not referenced, ignore them */
635 1.1.1.2.4.2 rmind
636 1.1.1.2.4.2 rmind switch (Node->Type)
637 1.1.1.2.4.2 rmind {
638 1.1.1.2.4.2 rmind case ACPI_TYPE_DEVICE:
639 1.1.1.2.4.2 rmind case ACPI_TYPE_PROCESSOR:
640 1.1.1.2.4.2 rmind case ACPI_TYPE_POWER:
641 1.1.1.2.4.2 rmind case ACPI_TYPE_LOCAL_RESOURCE:
642 1.1.1.2.4.2 rmind return (AE_OK);
643 1.1.1.2.4.2 rmind
644 1.1.1.2.4.2 rmind default:
645 1.1.1.2.4.2 rmind break;
646 1.1.1.2.4.2 rmind }
647 1.1.1.2.4.2 rmind
648 1.1.1.2.4.2 rmind /* All others are valid unreferenced namespace objects */
649 1.1.1.2.4.2 rmind
650 1.1.1.2.4.2 rmind if (Node->Op)
651 1.1.1.2.4.2 rmind {
652 1.1.1.2.4.2 rmind AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED, LkGetNameOp (Node->Op), NULL);
653 1.1.1.2.4.2 rmind }
654 1.1.1.2.4.2 rmind return (AE_OK);
655 1.1.1.2.4.2 rmind }
656 1.1.1.2.4.2 rmind
657 1.1.1.2.4.2 rmind
658 1.1.1.2.4.2 rmind /*******************************************************************************
659 1.1.1.2.4.2 rmind *
660 1.1.1.2.4.2 rmind * FUNCTION: LkFindUnreferencedObjects
661 1.1.1.2.4.2 rmind *
662 1.1.1.2.4.2 rmind * PARAMETERS: None
663 1.1.1.2.4.2 rmind *
664 1.1.1.2.4.2 rmind * RETURN: None
665 1.1.1.2.4.2 rmind *
666 1.1.1.2.4.2 rmind * DESCRIPTION: Namespace walk to find objects that are not referenced in any
667 1.1.1.2.4.2 rmind * way. Must be called after the namespace has been cross
668 1.1.1.2.4.2 rmind * referenced.
669 1.1.1.2.4.2 rmind *
670 1.1.1.2.4.2 rmind ******************************************************************************/
671 1.1.1.2.4.2 rmind
672 1.1.1.2.4.2 rmind void
673 1.1.1.2.4.2 rmind LkFindUnreferencedObjects (
674 1.1.1.2.4.2 rmind void)
675 1.1.1.2.4.2 rmind {
676 1.1.1.2.4.2 rmind
677 1.1.1.2.4.2 rmind /* Walk entire namespace from the supplied root */
678 1.1.1.2.4.2 rmind
679 1.1.1.2.4.2 rmind (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
680 1.1.1.2.4.2 rmind ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, NULL,
681 1.1.1.2.4.2 rmind NULL, NULL);
682 1.1.1.2.4.2 rmind }
683 1.1.1.2.4.2 rmind
684 1.1.1.2.4.2 rmind
685 1.1.1.2.4.2 rmind /*******************************************************************************
686 1.1.1.2.4.2 rmind *
687 1.1.1.2.4.2 rmind * FUNCTION: LkCrossReferenceNamespace
688 1.1.1.2.4.2 rmind *
689 1.1.1.2.4.2 rmind * PARAMETERS: None
690 1.1.1.2.4.2 rmind *
691 1.1.1.2.4.2 rmind * RETURN: Status
692 1.1.1.2.4.2 rmind *
693 1.1.1.2.4.2 rmind * DESCRIPTION: Perform a cross reference check of the parse tree against the
694 1.1.1.2.4.2 rmind * namespace. Every named referenced within the parse tree
695 1.1.1.2.4.2 rmind * should be get resolved with a namespace lookup. If not, the
696 1.1.1.2.4.2 rmind * original reference in the ASL code is invalid -- i.e., refers
697 1.1.1.2.4.2 rmind * to a non-existent object.
698 1.1.1.2.4.2 rmind *
699 1.1.1.2.4.2 rmind * NOTE: The ASL "External" operator causes the name to be inserted into the
700 1.1.1.2.4.2 rmind * namespace so that references to the external name will be resolved
701 1.1.1.2.4.2 rmind * correctly here.
702 1.1.1.2.4.2 rmind *
703 1.1.1.2.4.2 rmind ******************************************************************************/
704 1.1.1.2.4.2 rmind
705 1.1.1.2.4.2 rmind ACPI_STATUS
706 1.1.1.2.4.2 rmind LkCrossReferenceNamespace (
707 1.1.1.2.4.2 rmind void)
708 1.1.1.2.4.2 rmind {
709 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState;
710 1.1.1.2.4.2 rmind
711 1.1.1.2.4.2 rmind
712 1.1.1.2.4.2 rmind DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n");
713 1.1.1.2.4.2 rmind
714 1.1.1.2.4.2 rmind /*
715 1.1.1.2.4.2 rmind * Create a new walk state for use when looking up names
716 1.1.1.2.4.2 rmind * within the namespace (Passed as context to the callbacks)
717 1.1.1.2.4.2 rmind */
718 1.1.1.2.4.2 rmind WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL);
719 1.1.1.2.4.2 rmind if (!WalkState)
720 1.1.1.2.4.2 rmind {
721 1.1.1.2.4.2 rmind return AE_NO_MEMORY;
722 1.1.1.2.4.2 rmind }
723 1.1.1.2.4.2 rmind
724 1.1.1.2.4.2 rmind /* Walk the entire parse tree */
725 1.1.1.2.4.2 rmind
726 1.1.1.2.4.2 rmind TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, LkNamespaceLocateBegin,
727 1.1.1.2.4.2 rmind LkNamespaceLocateEnd, WalkState);
728 1.1.1.2.4.2 rmind return AE_OK;
729 1.1.1.2.4.2 rmind }
730 1.1.1.2.4.2 rmind
731 1.1.1.2.4.2 rmind
732 1.1.1.2.4.2 rmind /*******************************************************************************
733 1.1.1.2.4.2 rmind *
734 1.1.1.2.4.2 rmind * FUNCTION: LkCheckFieldRange
735 1.1.1.2.4.2 rmind *
736 1.1.1.2.4.2 rmind * PARAMETERS: RegionBitLength - Length of entire parent region
737 1.1.1.2.4.2 rmind * FieldBitOffset - Start of the field unit (within region)
738 1.1.1.2.4.2 rmind * FieldBitLength - Entire length of field unit
739 1.1.1.2.4.2 rmind * AccessBitWidth - Access width of the field unit
740 1.1.1.2.4.2 rmind *
741 1.1.1.2.4.2 rmind * RETURN: None
742 1.1.1.2.4.2 rmind *
743 1.1.1.2.4.2 rmind * DESCRIPTION: Check one field unit to make sure it fits in the parent
744 1.1.1.2.4.2 rmind * op region.
745 1.1.1.2.4.2 rmind *
746 1.1.1.2.4.2 rmind * Note: AccessBitWidth must be either 8,16,32, or 64
747 1.1.1.2.4.2 rmind *
748 1.1.1.2.4.2 rmind ******************************************************************************/
749 1.1.1.2.4.2 rmind
750 1.1.1.2.4.2 rmind static void
751 1.1.1.2.4.2 rmind LkCheckFieldRange (
752 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
753 1.1.1.2.4.2 rmind UINT32 RegionBitLength,
754 1.1.1.2.4.2 rmind UINT32 FieldBitOffset,
755 1.1.1.2.4.2 rmind UINT32 FieldBitLength,
756 1.1.1.2.4.2 rmind UINT32 AccessBitWidth)
757 1.1.1.2.4.2 rmind {
758 1.1.1.2.4.2 rmind UINT32 FieldEndBitOffset;
759 1.1.1.2.4.2 rmind
760 1.1.1.2.4.2 rmind
761 1.1.1.2.4.2 rmind /*
762 1.1.1.2.4.2 rmind * Check each field unit against the region size. The entire
763 1.1.1.2.4.2 rmind * field unit (start offset plus length) must fit within the
764 1.1.1.2.4.2 rmind * region.
765 1.1.1.2.4.2 rmind */
766 1.1.1.2.4.2 rmind FieldEndBitOffset = FieldBitOffset + FieldBitLength;
767 1.1.1.2.4.2 rmind
768 1.1.1.2.4.2 rmind if (FieldEndBitOffset > RegionBitLength)
769 1.1.1.2.4.2 rmind {
770 1.1.1.2.4.2 rmind /* Field definition itself is beyond the end-of-region */
771 1.1.1.2.4.2 rmind
772 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL);
773 1.1.1.2.4.2 rmind return;
774 1.1.1.2.4.2 rmind }
775 1.1.1.2.4.2 rmind
776 1.1.1.2.4.2 rmind /*
777 1.1.1.2.4.2 rmind * Now check that the field plus AccessWidth doesn't go beyond
778 1.1.1.2.4.2 rmind * the end-of-region. Assumes AccessBitWidth is a power of 2
779 1.1.1.2.4.2 rmind */
780 1.1.1.2.4.2 rmind FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth);
781 1.1.1.2.4.2 rmind
782 1.1.1.2.4.2 rmind if (FieldEndBitOffset > RegionBitLength)
783 1.1.1.2.4.2 rmind {
784 1.1.1.2.4.2 rmind /* Field definition combined with the access is beyond EOR */
785 1.1.1.2.4.2 rmind
786 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL);
787 1.1.1.2.4.2 rmind }
788 1.1.1.2.4.2 rmind }
789 1.1.1.2.4.2 rmind
790 1.1.1.2.4.2 rmind /*******************************************************************************
791 1.1.1.2.4.2 rmind *
792 1.1.1.2.4.2 rmind * FUNCTION: LkNamespaceLocateBegin
793 1.1.1.2.4.2 rmind *
794 1.1.1.2.4.2 rmind * PARAMETERS: ASL_WALK_CALLBACK
795 1.1.1.2.4.2 rmind *
796 1.1.1.2.4.2 rmind * RETURN: Status
797 1.1.1.2.4.2 rmind *
798 1.1.1.2.4.2 rmind * DESCRIPTION: Descending callback used during cross-reference. For named
799 1.1.1.2.4.2 rmind * object references, attempt to locate the name in the
800 1.1.1.2.4.2 rmind * namespace.
801 1.1.1.2.4.2 rmind *
802 1.1.1.2.4.2 rmind * NOTE: ASL references to named fields within resource descriptors are
803 1.1.1.2.4.2 rmind * resolved to integer values here. Therefore, this step is an
804 1.1.1.2.4.2 rmind * important part of the code generation. We don't know that the
805 1.1.1.2.4.2 rmind * name refers to a resource descriptor until now.
806 1.1.1.2.4.2 rmind *
807 1.1.1.2.4.2 rmind ******************************************************************************/
808 1.1.1.2.4.2 rmind
809 1.1.1.2.4.2 rmind static ACPI_STATUS
810 1.1.1.2.4.2 rmind LkNamespaceLocateBegin (
811 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
812 1.1.1.2.4.2 rmind UINT32 Level,
813 1.1.1.2.4.2 rmind void *Context)
814 1.1.1.2.4.2 rmind {
815 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
816 1.1.1.2.4.2 rmind ACPI_NAMESPACE_NODE *Node;
817 1.1.1.2.4.2 rmind ACPI_STATUS Status;
818 1.1.1.2.4.2 rmind ACPI_OBJECT_TYPE ObjectType;
819 1.1.1.2.4.2 rmind char *Path;
820 1.1.1.2.4.2 rmind UINT8 PassedArgs;
821 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *NextOp;
822 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *OwningOp;
823 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *SpaceIdOp;
824 1.1.1.2.4.2 rmind UINT32 MinimumLength;
825 1.1.1.2.4.2 rmind UINT32 Temp;
826 1.1.1.2.4.2 rmind const ACPI_OPCODE_INFO *OpInfo;
827 1.1.1.2.4.2 rmind UINT32 Flags;
828 1.1.1.2.4.2 rmind
829 1.1.1.2.4.2 rmind
830 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE_PTR (LkNamespaceLocateBegin, Op);
831 1.1.1.2.4.2 rmind
832 1.1.1.2.4.2 rmind /*
833 1.1.1.2.4.2 rmind * If this node is the actual declaration of a name
834 1.1.1.2.4.2 rmind * [such as the XXXX name in "Method (XXXX)"],
835 1.1.1.2.4.2 rmind * we are not interested in it here. We only care about names that are
836 1.1.1.2.4.2 rmind * references to other objects within the namespace and the parent objects
837 1.1.1.2.4.2 rmind * of name declarations
838 1.1.1.2.4.2 rmind */
839 1.1.1.2.4.2 rmind if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)
840 1.1.1.2.4.2 rmind {
841 1.1.1.2.4.2 rmind return (AE_OK);
842 1.1.1.2.4.2 rmind }
843 1.1.1.2.4.2 rmind
844 1.1.1.2.4.2 rmind /* We are only interested in opcodes that have an associated name */
845 1.1.1.2.4.2 rmind
846 1.1.1.2.4.2 rmind OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
847 1.1.1.2.4.2 rmind
848 1.1.1.2.4.2 rmind if ((!(OpInfo->Flags & AML_NAMED)) &&
849 1.1.1.2.4.2 rmind (!(OpInfo->Flags & AML_CREATE)) &&
850 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
851 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
852 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
853 1.1.1.2.4.2 rmind {
854 1.1.1.2.4.2 rmind return (AE_OK);
855 1.1.1.2.4.2 rmind }
856 1.1.1.2.4.2 rmind
857 1.1.1.2.4.2 rmind /*
858 1.1.1.2.4.2 rmind * One special case: CondRefOf operator - we don't care if the name exists
859 1.1.1.2.4.2 rmind * or not at this point, just ignore it, the point of the operator is to
860 1.1.1.2.4.2 rmind * determine if the name exists at runtime.
861 1.1.1.2.4.2 rmind */
862 1.1.1.2.4.2 rmind if ((Op->Asl.Parent) &&
863 1.1.1.2.4.2 rmind (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF))
864 1.1.1.2.4.2 rmind {
865 1.1.1.2.4.2 rmind return (AE_OK);
866 1.1.1.2.4.2 rmind }
867 1.1.1.2.4.2 rmind
868 1.1.1.2.4.2 rmind /*
869 1.1.1.2.4.2 rmind * We must enable the "search-to-root" for single NameSegs, but
870 1.1.1.2.4.2 rmind * we have to be very careful about opening up scopes
871 1.1.1.2.4.2 rmind */
872 1.1.1.2.4.2 rmind Flags = ACPI_NS_SEARCH_PARENT;
873 1.1.1.2.4.2 rmind if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
874 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
875 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
876 1.1.1.2.4.2 rmind {
877 1.1.1.2.4.2 rmind /*
878 1.1.1.2.4.2 rmind * These are name references, do not push the scope stack
879 1.1.1.2.4.2 rmind * for them.
880 1.1.1.2.4.2 rmind */
881 1.1.1.2.4.2 rmind Flags |= ACPI_NS_DONT_OPEN_SCOPE;
882 1.1.1.2.4.2 rmind }
883 1.1.1.2.4.2 rmind
884 1.1.1.2.4.2 rmind /* Get the NamePath from the appropriate place */
885 1.1.1.2.4.2 rmind
886 1.1.1.2.4.2 rmind if (OpInfo->Flags & AML_NAMED)
887 1.1.1.2.4.2 rmind {
888 1.1.1.2.4.2 rmind /* For nearly all NAMED operators, the name reference is the first child */
889 1.1.1.2.4.2 rmind
890 1.1.1.2.4.2 rmind Path = Op->Asl.Child->Asl.Value.String;
891 1.1.1.2.4.2 rmind if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
892 1.1.1.2.4.2 rmind {
893 1.1.1.2.4.2 rmind /*
894 1.1.1.2.4.2 rmind * ALIAS is the only oddball opcode, the name declaration
895 1.1.1.2.4.2 rmind * (alias name) is the second operand
896 1.1.1.2.4.2 rmind */
897 1.1.1.2.4.2 rmind Path = Op->Asl.Child->Asl.Next->Asl.Value.String;
898 1.1.1.2.4.2 rmind }
899 1.1.1.2.4.2 rmind }
900 1.1.1.2.4.2 rmind else if (OpInfo->Flags & AML_CREATE)
901 1.1.1.2.4.2 rmind {
902 1.1.1.2.4.2 rmind /* Name must appear as the last parameter */
903 1.1.1.2.4.2 rmind
904 1.1.1.2.4.2 rmind NextOp = Op->Asl.Child;
905 1.1.1.2.4.2 rmind while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))
906 1.1.1.2.4.2 rmind {
907 1.1.1.2.4.2 rmind NextOp = NextOp->Asl.Next;
908 1.1.1.2.4.2 rmind }
909 1.1.1.2.4.2 rmind Path = NextOp->Asl.Value.String;
910 1.1.1.2.4.2 rmind }
911 1.1.1.2.4.2 rmind else
912 1.1.1.2.4.2 rmind {
913 1.1.1.2.4.2 rmind Path = Op->Asl.Value.String;
914 1.1.1.2.4.2 rmind }
915 1.1.1.2.4.2 rmind
916 1.1.1.2.4.2 rmind ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
917 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
918 1.1.1.2.4.2 rmind "Type=%s\n", AcpiUtGetTypeName (ObjectType)));
919 1.1.1.2.4.2 rmind
920 1.1.1.2.4.2 rmind /*
921 1.1.1.2.4.2 rmind * Lookup the name in the namespace. Name must exist at this point, or it
922 1.1.1.2.4.2 rmind * is an invalid reference.
923 1.1.1.2.4.2 rmind *
924 1.1.1.2.4.2 rmind * The namespace is also used as a lookup table for references to resource
925 1.1.1.2.4.2 rmind * descriptors and the fields within them.
926 1.1.1.2.4.2 rmind */
927 1.1.1.2.4.2 rmind Gbl_NsLookupCount++;
928 1.1.1.2.4.2 rmind
929 1.1.1.2.4.2 rmind Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
930 1.1.1.2.4.2 rmind ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node));
931 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
932 1.1.1.2.4.2 rmind {
933 1.1.1.2.4.2 rmind if (Status == AE_NOT_FOUND)
934 1.1.1.2.4.2 rmind {
935 1.1.1.2.4.2 rmind /*
936 1.1.1.2.4.2 rmind * We didn't find the name reference by path -- we can qualify this
937 1.1.1.2.4.2 rmind * a little better before we print an error message
938 1.1.1.2.4.2 rmind */
939 1.1.1.2.4.2 rmind if (strlen (Path) == ACPI_NAME_SIZE)
940 1.1.1.2.4.2 rmind {
941 1.1.1.2.4.2 rmind /* A simple, one-segment ACPI name */
942 1.1.1.2.4.2 rmind
943 1.1.1.2.4.2 rmind if (LkObjectExists (Path))
944 1.1.1.2.4.2 rmind {
945 1.1.1.2.4.2 rmind /*
946 1.1.1.2.4.2 rmind * There exists such a name, but we couldn't get to it
947 1.1.1.2.4.2 rmind * from this scope
948 1.1.1.2.4.2 rmind */
949 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op,
950 1.1.1.2.4.2 rmind Op->Asl.ExternalName);
951 1.1.1.2.4.2 rmind }
952 1.1.1.2.4.2 rmind else
953 1.1.1.2.4.2 rmind {
954 1.1.1.2.4.2 rmind /* The name doesn't exist, period */
955 1.1.1.2.4.2 rmind
956 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_NOT_EXIST,
957 1.1.1.2.4.2 rmind Op, Op->Asl.ExternalName);
958 1.1.1.2.4.2 rmind }
959 1.1.1.2.4.2 rmind }
960 1.1.1.2.4.2 rmind else
961 1.1.1.2.4.2 rmind {
962 1.1.1.2.4.2 rmind /* Check for a fully qualified path */
963 1.1.1.2.4.2 rmind
964 1.1.1.2.4.2 rmind if (Path[0] == AML_ROOT_PREFIX)
965 1.1.1.2.4.2 rmind {
966 1.1.1.2.4.2 rmind /* Gave full path, the object does not exist */
967 1.1.1.2.4.2 rmind
968 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op,
969 1.1.1.2.4.2 rmind Op->Asl.ExternalName);
970 1.1.1.2.4.2 rmind }
971 1.1.1.2.4.2 rmind else
972 1.1.1.2.4.2 rmind {
973 1.1.1.2.4.2 rmind /*
974 1.1.1.2.4.2 rmind * We can't tell whether it doesn't exist or just
975 1.1.1.2.4.2 rmind * can't be reached.
976 1.1.1.2.4.2 rmind */
977 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
978 1.1.1.2.4.2 rmind Op->Asl.ExternalName);
979 1.1.1.2.4.2 rmind }
980 1.1.1.2.4.2 rmind }
981 1.1.1.2.4.2 rmind
982 1.1.1.2.4.2 rmind Status = AE_OK;
983 1.1.1.2.4.2 rmind }
984 1.1.1.2.4.2 rmind return (Status);
985 1.1.1.2.4.2 rmind }
986 1.1.1.2.4.2 rmind
987 1.1.1.2.4.2 rmind /* Check for a reference vs. name declaration */
988 1.1.1.2.4.2 rmind
989 1.1.1.2.4.2 rmind if (!(OpInfo->Flags & AML_NAMED) &&
990 1.1.1.2.4.2 rmind !(OpInfo->Flags & AML_CREATE))
991 1.1.1.2.4.2 rmind {
992 1.1.1.2.4.2 rmind /* This node has been referenced, mark it for reference check */
993 1.1.1.2.4.2 rmind
994 1.1.1.2.4.2 rmind Node->Flags |= ANOBJ_IS_REFERENCED;
995 1.1.1.2.4.2 rmind }
996 1.1.1.2.4.2 rmind
997 1.1.1.2.4.2 rmind /* Attempt to optimize the NamePath */
998 1.1.1.2.4.2 rmind
999 1.1.1.2.4.2 rmind OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node);
1000 1.1.1.2.4.2 rmind
1001 1.1.1.2.4.2 rmind /*
1002 1.1.1.2.4.2 rmind * 1) Dereference an alias (A name reference that is an alias)
1003 1.1.1.2.4.2 rmind * Aliases are not nested, the alias always points to the final object
1004 1.1.1.2.4.2 rmind */
1005 1.1.1.2.4.2 rmind if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) &&
1006 1.1.1.2.4.2 rmind (Node->Type == ACPI_TYPE_LOCAL_ALIAS))
1007 1.1.1.2.4.2 rmind {
1008 1.1.1.2.4.2 rmind /* This node points back to the original PARSEOP_ALIAS */
1009 1.1.1.2.4.2 rmind
1010 1.1.1.2.4.2 rmind NextOp = Node->Op;
1011 1.1.1.2.4.2 rmind
1012 1.1.1.2.4.2 rmind /* The first child is the alias target op */
1013 1.1.1.2.4.2 rmind
1014 1.1.1.2.4.2 rmind NextOp = NextOp->Asl.Child;
1015 1.1.1.2.4.2 rmind
1016 1.1.1.2.4.2 rmind /* That in turn points back to original target alias node */
1017 1.1.1.2.4.2 rmind
1018 1.1.1.2.4.2 rmind if (NextOp->Asl.Node)
1019 1.1.1.2.4.2 rmind {
1020 1.1.1.2.4.2 rmind Node = NextOp->Asl.Node;
1021 1.1.1.2.4.2 rmind }
1022 1.1.1.2.4.2 rmind
1023 1.1.1.2.4.2 rmind /* Else - forward reference to alias, will be resolved later */
1024 1.1.1.2.4.2 rmind }
1025 1.1.1.2.4.2 rmind
1026 1.1.1.2.4.2 rmind /* 2) Check for a reference to a resource descriptor */
1027 1.1.1.2.4.2 rmind
1028 1.1.1.2.4.2 rmind if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
1029 1.1.1.2.4.2 rmind (Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
1030 1.1.1.2.4.2 rmind {
1031 1.1.1.2.4.2 rmind /*
1032 1.1.1.2.4.2 rmind * This was a reference to a field within a resource descriptor. Extract
1033 1.1.1.2.4.2 rmind * the associated field offset (either a bit or byte offset depending on
1034 1.1.1.2.4.2 rmind * the field type) and change the named reference into an integer for
1035 1.1.1.2.4.2 rmind * AML code generation
1036 1.1.1.2.4.2 rmind */
1037 1.1.1.2.4.2 rmind Temp = Node->Value;
1038 1.1.1.2.4.2 rmind if (Node->Flags & ANOBJ_IS_BIT_OFFSET)
1039 1.1.1.2.4.2 rmind {
1040 1.1.1.2.4.2 rmind Op->Asl.CompileFlags |= NODE_IS_BIT_OFFSET;
1041 1.1.1.2.4.2 rmind }
1042 1.1.1.2.4.2 rmind
1043 1.1.1.2.4.2 rmind /* Perform BitOffset <--> ByteOffset conversion if necessary */
1044 1.1.1.2.4.2 rmind
1045 1.1.1.2.4.2 rmind switch (Op->Asl.Parent->Asl.AmlOpcode)
1046 1.1.1.2.4.2 rmind {
1047 1.1.1.2.4.2 rmind case AML_CREATE_FIELD_OP:
1048 1.1.1.2.4.2 rmind
1049 1.1.1.2.4.2 rmind /* We allow a Byte offset to Bit Offset conversion for this op */
1050 1.1.1.2.4.2 rmind
1051 1.1.1.2.4.2 rmind if (!(Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET))
1052 1.1.1.2.4.2 rmind {
1053 1.1.1.2.4.2 rmind /* Simply multiply byte offset times 8 to get bit offset */
1054 1.1.1.2.4.2 rmind
1055 1.1.1.2.4.2 rmind Temp = ACPI_MUL_8 (Temp);
1056 1.1.1.2.4.2 rmind }
1057 1.1.1.2.4.2 rmind break;
1058 1.1.1.2.4.2 rmind
1059 1.1.1.2.4.2 rmind
1060 1.1.1.2.4.2 rmind case AML_CREATE_BIT_FIELD_OP:
1061 1.1.1.2.4.2 rmind
1062 1.1.1.2.4.2 rmind /* This op requires a Bit Offset */
1063 1.1.1.2.4.2 rmind
1064 1.1.1.2.4.2 rmind if (!(Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET))
1065 1.1.1.2.4.2 rmind {
1066 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_BYTES_TO_BITS, Op, NULL);
1067 1.1.1.2.4.2 rmind }
1068 1.1.1.2.4.2 rmind break;
1069 1.1.1.2.4.2 rmind
1070 1.1.1.2.4.2 rmind
1071 1.1.1.2.4.2 rmind case AML_CREATE_BYTE_FIELD_OP:
1072 1.1.1.2.4.2 rmind case AML_CREATE_WORD_FIELD_OP:
1073 1.1.1.2.4.2 rmind case AML_CREATE_DWORD_FIELD_OP:
1074 1.1.1.2.4.2 rmind case AML_CREATE_QWORD_FIELD_OP:
1075 1.1.1.2.4.2 rmind case AML_INDEX_OP:
1076 1.1.1.2.4.2 rmind
1077 1.1.1.2.4.2 rmind /* These Ops require Byte offsets */
1078 1.1.1.2.4.2 rmind
1079 1.1.1.2.4.2 rmind if (Op->Asl.CompileFlags & NODE_IS_BIT_OFFSET)
1080 1.1.1.2.4.2 rmind {
1081 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_BITS_TO_BYTES, Op, NULL);
1082 1.1.1.2.4.2 rmind }
1083 1.1.1.2.4.2 rmind break;
1084 1.1.1.2.4.2 rmind
1085 1.1.1.2.4.2 rmind
1086 1.1.1.2.4.2 rmind default:
1087 1.1.1.2.4.2 rmind /* Nothing to do for other opcodes */
1088 1.1.1.2.4.2 rmind break;
1089 1.1.1.2.4.2 rmind }
1090 1.1.1.2.4.2 rmind
1091 1.1.1.2.4.2 rmind /* Now convert this node to an integer whose value is the field offset */
1092 1.1.1.2.4.2 rmind
1093 1.1.1.2.4.2 rmind Op->Asl.AmlLength = 0;
1094 1.1.1.2.4.2 rmind Op->Asl.ParseOpcode = PARSEOP_INTEGER;
1095 1.1.1.2.4.2 rmind Op->Asl.Value.Integer = (UINT64) Temp;
1096 1.1.1.2.4.2 rmind Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD;
1097 1.1.1.2.4.2 rmind
1098 1.1.1.2.4.2 rmind OpcGenerateAmlOpcode (Op);
1099 1.1.1.2.4.2 rmind }
1100 1.1.1.2.4.2 rmind
1101 1.1.1.2.4.2 rmind /* 3) Check for a method invocation */
1102 1.1.1.2.4.2 rmind
1103 1.1.1.2.4.2 rmind else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) &&
1104 1.1.1.2.4.2 rmind (Node->Type == ACPI_TYPE_METHOD) &&
1105 1.1.1.2.4.2 rmind (Op->Asl.Parent) &&
1106 1.1.1.2.4.2 rmind (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD)) ||
1107 1.1.1.2.4.2 rmind
1108 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
1109 1.1.1.2.4.2 rmind {
1110 1.1.1.2.4.2 rmind
1111 1.1.1.2.4.2 rmind /*
1112 1.1.1.2.4.2 rmind * A reference to a method within one of these opcodes is not an
1113 1.1.1.2.4.2 rmind * invocation of the method, it is simply a reference to the method.
1114 1.1.1.2.4.2 rmind */
1115 1.1.1.2.4.2 rmind if ((Op->Asl.Parent) &&
1116 1.1.1.2.4.2 rmind ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) ||
1117 1.1.1.2.4.2 rmind (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF) ||
1118 1.1.1.2.4.2 rmind (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE)))
1119 1.1.1.2.4.2 rmind {
1120 1.1.1.2.4.2 rmind return (AE_OK);
1121 1.1.1.2.4.2 rmind }
1122 1.1.1.2.4.2 rmind /*
1123 1.1.1.2.4.2 rmind * There are two types of method invocation:
1124 1.1.1.2.4.2 rmind * 1) Invocation with arguments -- the parser recognizes this
1125 1.1.1.2.4.2 rmind * as a METHODCALL.
1126 1.1.1.2.4.2 rmind * 2) Invocation with no arguments --the parser cannot determine that
1127 1.1.1.2.4.2 rmind * this is a method invocation, therefore we have to figure it out
1128 1.1.1.2.4.2 rmind * here.
1129 1.1.1.2.4.2 rmind */
1130 1.1.1.2.4.2 rmind if (Node->Type != ACPI_TYPE_METHOD)
1131 1.1.1.2.4.2 rmind {
1132 1.1.1.2.4.2 rmind sprintf (MsgBuffer, "%s is a %s",
1133 1.1.1.2.4.2 rmind Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type));
1134 1.1.1.2.4.2 rmind
1135 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer);
1136 1.1.1.2.4.2 rmind return (AE_OK);
1137 1.1.1.2.4.2 rmind }
1138 1.1.1.2.4.2 rmind
1139 1.1.1.2.4.2 rmind /* Save the method node in the caller's op */
1140 1.1.1.2.4.2 rmind
1141 1.1.1.2.4.2 rmind Op->Asl.Node = Node;
1142 1.1.1.2.4.2 rmind if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)
1143 1.1.1.2.4.2 rmind {
1144 1.1.1.2.4.2 rmind return (AE_OK);
1145 1.1.1.2.4.2 rmind }
1146 1.1.1.2.4.2 rmind
1147 1.1.1.2.4.2 rmind /*
1148 1.1.1.2.4.2 rmind * This is a method invocation, with or without arguments.
1149 1.1.1.2.4.2 rmind * Count the number of arguments, each appears as a child
1150 1.1.1.2.4.2 rmind * under the parent node
1151 1.1.1.2.4.2 rmind */
1152 1.1.1.2.4.2 rmind Op->Asl.ParseOpcode = PARSEOP_METHODCALL;
1153 1.1.1.2.4.2 rmind UtSetParseOpName (Op);
1154 1.1.1.2.4.2 rmind
1155 1.1.1.2.4.2 rmind PassedArgs = 0;
1156 1.1.1.2.4.2 rmind NextOp = Op->Asl.Child;
1157 1.1.1.2.4.2 rmind
1158 1.1.1.2.4.2 rmind while (NextOp)
1159 1.1.1.2.4.2 rmind {
1160 1.1.1.2.4.2 rmind PassedArgs++;
1161 1.1.1.2.4.2 rmind NextOp = NextOp->Asl.Next;
1162 1.1.1.2.4.2 rmind }
1163 1.1.1.2.4.2 rmind
1164 1.1.1.2.4.2 rmind if (Node->Value != ASL_EXTERNAL_METHOD)
1165 1.1.1.2.4.2 rmind {
1166 1.1.1.2.4.2 rmind /*
1167 1.1.1.2.4.2 rmind * Check the parsed arguments with the number expected by the
1168 1.1.1.2.4.2 rmind * method declaration itself
1169 1.1.1.2.4.2 rmind */
1170 1.1.1.2.4.2 rmind if (PassedArgs != Node->Value)
1171 1.1.1.2.4.2 rmind {
1172 1.1.1.2.4.2 rmind sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName,
1173 1.1.1.2.4.2 rmind Node->Value);
1174 1.1.1.2.4.2 rmind
1175 1.1.1.2.4.2 rmind if (PassedArgs < Node->Value)
1176 1.1.1.2.4.2 rmind {
1177 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, MsgBuffer);
1178 1.1.1.2.4.2 rmind }
1179 1.1.1.2.4.2 rmind else
1180 1.1.1.2.4.2 rmind {
1181 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, MsgBuffer);
1182 1.1.1.2.4.2 rmind }
1183 1.1.1.2.4.2 rmind }
1184 1.1.1.2.4.2 rmind }
1185 1.1.1.2.4.2 rmind }
1186 1.1.1.2.4.2 rmind
1187 1.1.1.2.4.2 rmind /* 4) Check for an ASL Field definition */
1188 1.1.1.2.4.2 rmind
1189 1.1.1.2.4.2 rmind else if ((Op->Asl.Parent) &&
1190 1.1.1.2.4.2 rmind ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD) ||
1191 1.1.1.2.4.2 rmind (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD)))
1192 1.1.1.2.4.2 rmind {
1193 1.1.1.2.4.2 rmind /*
1194 1.1.1.2.4.2 rmind * Offset checking for fields. If the parent operation region has a
1195 1.1.1.2.4.2 rmind * constant length (known at compile time), we can check fields
1196 1.1.1.2.4.2 rmind * defined in that region against the region length. This will catch
1197 1.1.1.2.4.2 rmind * fields and field units that cannot possibly fit within the region.
1198 1.1.1.2.4.2 rmind *
1199 1.1.1.2.4.2 rmind * Note: Index fields do not directly reference an operation region,
1200 1.1.1.2.4.2 rmind * thus they are not included in this check.
1201 1.1.1.2.4.2 rmind */
1202 1.1.1.2.4.2 rmind if (Op == Op->Asl.Parent->Asl.Child)
1203 1.1.1.2.4.2 rmind {
1204 1.1.1.2.4.2 rmind /*
1205 1.1.1.2.4.2 rmind * This is the first child of the field node, which is
1206 1.1.1.2.4.2 rmind * the name of the region. Get the parse node for the
1207 1.1.1.2.4.2 rmind * region -- which contains the length of the region.
1208 1.1.1.2.4.2 rmind */
1209 1.1.1.2.4.2 rmind OwningOp = Node->Op;
1210 1.1.1.2.4.2 rmind Op->Asl.Parent->Asl.ExtraValue =
1211 1.1.1.2.4.2 rmind ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer);
1212 1.1.1.2.4.2 rmind
1213 1.1.1.2.4.2 rmind /* Examine the field access width */
1214 1.1.1.2.4.2 rmind
1215 1.1.1.2.4.2 rmind switch ((UINT8) Op->Asl.Parent->Asl.Value.Integer)
1216 1.1.1.2.4.2 rmind {
1217 1.1.1.2.4.2 rmind case AML_FIELD_ACCESS_ANY:
1218 1.1.1.2.4.2 rmind case AML_FIELD_ACCESS_BYTE:
1219 1.1.1.2.4.2 rmind case AML_FIELD_ACCESS_BUFFER:
1220 1.1.1.2.4.2 rmind default:
1221 1.1.1.2.4.2 rmind MinimumLength = 1;
1222 1.1.1.2.4.2 rmind break;
1223 1.1.1.2.4.2 rmind
1224 1.1.1.2.4.2 rmind case AML_FIELD_ACCESS_WORD:
1225 1.1.1.2.4.2 rmind MinimumLength = 2;
1226 1.1.1.2.4.2 rmind break;
1227 1.1.1.2.4.2 rmind
1228 1.1.1.2.4.2 rmind case AML_FIELD_ACCESS_DWORD:
1229 1.1.1.2.4.2 rmind MinimumLength = 4;
1230 1.1.1.2.4.2 rmind break;
1231 1.1.1.2.4.2 rmind
1232 1.1.1.2.4.2 rmind case AML_FIELD_ACCESS_QWORD:
1233 1.1.1.2.4.2 rmind MinimumLength = 8;
1234 1.1.1.2.4.2 rmind break;
1235 1.1.1.2.4.2 rmind }
1236 1.1.1.2.4.2 rmind
1237 1.1.1.2.4.2 rmind /*
1238 1.1.1.2.4.2 rmind * Is the region at least as big as the access width?
1239 1.1.1.2.4.2 rmind * Note: DataTableRegions have 0 length
1240 1.1.1.2.4.2 rmind */
1241 1.1.1.2.4.2 rmind if (((UINT32) OwningOp->Asl.Value.Integer) &&
1242 1.1.1.2.4.2 rmind ((UINT32) OwningOp->Asl.Value.Integer < MinimumLength))
1243 1.1.1.2.4.2 rmind {
1244 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_FIELD_ACCESS_WIDTH, Op, NULL);
1245 1.1.1.2.4.2 rmind }
1246 1.1.1.2.4.2 rmind
1247 1.1.1.2.4.2 rmind /*
1248 1.1.1.2.4.2 rmind * Check EC/CMOS/SMBUS fields to make sure that the correct
1249 1.1.1.2.4.2 rmind * access type is used (BYTE for EC/CMOS, BUFFER for SMBUS)
1250 1.1.1.2.4.2 rmind */
1251 1.1.1.2.4.2 rmind SpaceIdOp = OwningOp->Asl.Child->Asl.Next;
1252 1.1.1.2.4.2 rmind switch ((UINT32) SpaceIdOp->Asl.Value.Integer)
1253 1.1.1.2.4.2 rmind {
1254 1.1.1.2.4.2 rmind case REGION_EC:
1255 1.1.1.2.4.2 rmind case REGION_CMOS:
1256 1.1.1.2.4.2 rmind
1257 1.1.1.2.4.2 rmind if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE)
1258 1.1.1.2.4.2 rmind {
1259 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL);
1260 1.1.1.2.4.2 rmind }
1261 1.1.1.2.4.2 rmind break;
1262 1.1.1.2.4.2 rmind
1263 1.1.1.2.4.2 rmind case REGION_SMBUS:
1264 1.1.1.2.4.2 rmind case REGION_IPMI:
1265 1.1.1.2.4.2 rmind
1266 1.1.1.2.4.2 rmind if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER)
1267 1.1.1.2.4.2 rmind {
1268 1.1.1.2.4.2 rmind AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL);
1269 1.1.1.2.4.2 rmind }
1270 1.1.1.2.4.2 rmind break;
1271 1.1.1.2.4.2 rmind
1272 1.1.1.2.4.2 rmind default:
1273 1.1.1.2.4.2 rmind
1274 1.1.1.2.4.2 rmind /* Nothing to do for other address spaces */
1275 1.1.1.2.4.2 rmind break;
1276 1.1.1.2.4.2 rmind }
1277 1.1.1.2.4.2 rmind }
1278 1.1.1.2.4.2 rmind else
1279 1.1.1.2.4.2 rmind {
1280 1.1.1.2.4.2 rmind /*
1281 1.1.1.2.4.2 rmind * This is one element of the field list. Check to make sure
1282 1.1.1.2.4.2 rmind * that it does not go beyond the end of the parent operation region.
1283 1.1.1.2.4.2 rmind *
1284 1.1.1.2.4.2 rmind * In the code below:
1285 1.1.1.2.4.2 rmind * Op->Asl.Parent->Asl.ExtraValue - Region Length (bits)
1286 1.1.1.2.4.2 rmind * Op->Asl.ExtraValue - Field start offset (bits)
1287 1.1.1.2.4.2 rmind * Op->Asl.Child->Asl.Value.Integer32 - Field length (bits)
1288 1.1.1.2.4.2 rmind * Op->Asl.Child->Asl.ExtraValue - Field access width (bits)
1289 1.1.1.2.4.2 rmind */
1290 1.1.1.2.4.2 rmind if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child)
1291 1.1.1.2.4.2 rmind {
1292 1.1.1.2.4.2 rmind LkCheckFieldRange (Op,
1293 1.1.1.2.4.2 rmind Op->Asl.Parent->Asl.ExtraValue,
1294 1.1.1.2.4.2 rmind Op->Asl.ExtraValue,
1295 1.1.1.2.4.2 rmind (UINT32) Op->Asl.Child->Asl.Value.Integer,
1296 1.1.1.2.4.2 rmind Op->Asl.Child->Asl.ExtraValue);
1297 1.1.1.2.4.2 rmind }
1298 1.1.1.2.4.2 rmind }
1299 1.1.1.2.4.2 rmind }
1300 1.1.1.2.4.2 rmind
1301 1.1.1.2.4.2 rmind Op->Asl.Node = Node;
1302 1.1.1.2.4.2 rmind return (Status);
1303 1.1.1.2.4.2 rmind }
1304 1.1.1.2.4.2 rmind
1305 1.1.1.2.4.2 rmind
1306 1.1.1.2.4.2 rmind /*******************************************************************************
1307 1.1.1.2.4.2 rmind *
1308 1.1.1.2.4.2 rmind * FUNCTION: LkNamespaceLocateEnd
1309 1.1.1.2.4.2 rmind *
1310 1.1.1.2.4.2 rmind * PARAMETERS: ASL_WALK_CALLBACK
1311 1.1.1.2.4.2 rmind *
1312 1.1.1.2.4.2 rmind * RETURN: Status
1313 1.1.1.2.4.2 rmind *
1314 1.1.1.2.4.2 rmind * DESCRIPTION: Ascending callback used during cross reference. We only
1315 1.1.1.2.4.2 rmind * need to worry about scope management here.
1316 1.1.1.2.4.2 rmind *
1317 1.1.1.2.4.2 rmind ******************************************************************************/
1318 1.1.1.2.4.2 rmind
1319 1.1.1.2.4.2 rmind static ACPI_STATUS
1320 1.1.1.2.4.2 rmind LkNamespaceLocateEnd (
1321 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
1322 1.1.1.2.4.2 rmind UINT32 Level,
1323 1.1.1.2.4.2 rmind void *Context)
1324 1.1.1.2.4.2 rmind {
1325 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState = (ACPI_WALK_STATE *) Context;
1326 1.1.1.2.4.2 rmind const ACPI_OPCODE_INFO *OpInfo;
1327 1.1.1.2.4.2 rmind
1328 1.1.1.2.4.2 rmind
1329 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE (LkNamespaceLocateEnd);
1330 1.1.1.2.4.2 rmind
1331 1.1.1.2.4.2 rmind
1332 1.1.1.2.4.2 rmind /* We are only interested in opcodes that have an associated name */
1333 1.1.1.2.4.2 rmind
1334 1.1.1.2.4.2 rmind OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
1335 1.1.1.2.4.2 rmind if (!(OpInfo->Flags & AML_NAMED))
1336 1.1.1.2.4.2 rmind {
1337 1.1.1.2.4.2 rmind return (AE_OK);
1338 1.1.1.2.4.2 rmind }
1339 1.1.1.2.4.2 rmind
1340 1.1.1.2.4.2 rmind /* Not interested in name references, we did not open a scope for them */
1341 1.1.1.2.4.2 rmind
1342 1.1.1.2.4.2 rmind if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
1343 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
1344 1.1.1.2.4.2 rmind (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
1345 1.1.1.2.4.2 rmind {
1346 1.1.1.2.4.2 rmind return (AE_OK);
1347 1.1.1.2.4.2 rmind }
1348 1.1.1.2.4.2 rmind
1349 1.1.1.2.4.2 rmind /* Pop the scope stack if necessary */
1350 1.1.1.2.4.2 rmind
1351 1.1.1.2.4.2 rmind if (AcpiNsOpensScope (AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode)))
1352 1.1.1.2.4.2 rmind {
1353 1.1.1.2.4.2 rmind
1354 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
1355 1.1.1.2.4.2 rmind "%s: Popping scope for Op %p\n",
1356 1.1.1.2.4.2 rmind AcpiUtGetTypeName (OpInfo->ObjectType), Op));
1357 1.1.1.2.4.2 rmind
1358 1.1.1.2.4.2 rmind (void) AcpiDsScopeStackPop (WalkState);
1359 1.1.1.2.4.2 rmind }
1360 1.1.1.2.4.2 rmind
1361 1.1.1.2.4.2 rmind return (AE_OK);
1362 1.1.1.2.4.2 rmind }
1363 1.1.1.2.4.2 rmind
1364 1.1.1.2.4.2 rmind
1365