Deleted Added
sdiff udiff text old ( 77424 ) new ( 82367 )
full compact
1/******************************************************************************
2 *
3 * Module Name: dsfield - Dispatcher field routines
4 * $Revision: 41 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __DSFIELD_C__
118
119#include "acpi.h"
120#include "amlcode.h"
121#include "acdispat.h"
122#include "acinterp.h"
123#include "acnamesp.h"
124
125
126#define _COMPONENT ACPI_DISPATCHER
127 MODULE_NAME ("dsfield")
128
129
130/*
131 * Field flags: Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.)
132 * 04 : LockRule (1 == Lock)
133 * 05 - 06 : UpdateRule
134 */
135
136#define FIELD_ACCESS_TYPE_MASK 0x0F
137#define FIELD_LOCK_RULE_MASK 0x10
138#define FIELD_UPDATE_RULE_MASK 0x60
139
140
141/*******************************************************************************
142 *
143 * FUNCTION: AcpiDsCreateField
144 *
145 * PARAMETERS: Op - Op containing the Field definition and args
146 * RegionNode - Object for the containing Operation Region
147 * ` WalkState - Current method state
148 *
149 * RETURN: Status
150 *
151 * DESCRIPTION: Create a new field in the specified operation region
152 *
153 ******************************************************************************/
154
155ACPI_STATUS
156AcpiDsCreateField (
157 ACPI_PARSE_OBJECT *Op,
158 ACPI_NAMESPACE_NODE *RegionNode,
159 ACPI_WALK_STATE *WalkState)
160{
161 ACPI_STATUS Status = AE_AML_ERROR;
162 ACPI_PARSE_OBJECT *Arg;
163 ACPI_NAMESPACE_NODE *Node;
164 UINT8 FieldFlags;
165 UINT32 FieldBitPosition = 0;
166
167
168 FUNCTION_TRACE_PTR ("DsCreateField", Op);
169
170
171 /* First arg is the name of the parent OpRegion */
172
173 Arg = Op->Value.Arg;
174 if (!RegionNode)
175 {
176 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.Name,
177 ACPI_TYPE_REGION, IMODE_EXECUTE,
178 NS_SEARCH_PARENT, WalkState, &RegionNode);
179 if (ACPI_FAILURE (Status))
180 {
181 return_ACPI_STATUS (Status);
182 }
183 }
184
185 /* Second arg is the field flags */
186
187 Arg = Arg->Next;
188 FieldFlags = (UINT8) Arg->Value.Integer;
189
190 /* Each remaining arg is a Named Field */
191
192 Arg = Arg->Next;
193 while (Arg)
194 {
195 switch (Arg->Opcode)
196 {
197 case AML_INT_RESERVEDFIELD_OP:
198
199 FieldBitPosition += Arg->Value.Size;
200 break;
201
202
203 case AML_INT_ACCESSFIELD_OP:
204
205 /*
206 * Get a new AccessType and AccessAttribute for all
207 * entries (until end or another AccessAs keyword)
208 */
209 FieldFlags = (UINT8) ((FieldFlags & FIELD_ACCESS_TYPE_MASK) ||
210 ((UINT8) (Arg->Value.Integer >> 8)));
211 break;
212
213
214 case AML_INT_NAMEDFIELD_OP:
215
216 Status = AcpiNsLookup (WalkState->ScopeInfo,
217 (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name,
218 INTERNAL_TYPE_REGION_FIELD, IMODE_LOAD_PASS1,
219 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
220 NULL, &Node);
221 if (ACPI_FAILURE (Status))
222 {
223 return_ACPI_STATUS (Status);
224 }
225
226 /*
227 * Initialize an object for the new Node that is on
228 * the object stack
229 */
230
231 Status = AcpiExPrepRegionFieldValue (Node, RegionNode, FieldFlags,
232 FieldBitPosition, Arg->Value.Size);
233 if (ACPI_FAILURE (Status))
234 {
235 return_ACPI_STATUS (Status);
236 }
237
238 /* Keep track of bit position for *next* field */
239
240 FieldBitPosition += Arg->Value.Size;
241 break;
242 }
243
244 Arg = Arg->Next;
245 }
246
247 return_ACPI_STATUS (Status);
248}
249
250
251/*******************************************************************************
252 *
253 * FUNCTION: AcpiDsCreateBankField
254 *
255 * PARAMETERS: Op - Op containing the Field definition and args
256 * RegionNode - Object for the containing Operation Region
257 * ` WalkState - Current method state
258 *
259 * RETURN: Status
260 *
261 * DESCRIPTION: Create a new bank field in the specified operation region
262 *
263 ******************************************************************************/
264
265ACPI_STATUS
266AcpiDsCreateBankField (
267 ACPI_PARSE_OBJECT *Op,
268 ACPI_NAMESPACE_NODE *RegionNode,
269 ACPI_WALK_STATE *WalkState)
270{
271 ACPI_STATUS Status = AE_AML_ERROR;
272 ACPI_PARSE_OBJECT *Arg;
273 ACPI_NAMESPACE_NODE *RegisterNode;
274 ACPI_NAMESPACE_NODE *Node;
275 UINT32 BankValue;
276 UINT8 FieldFlags;
277 UINT32 FieldBitPosition = 0;
278
279
280 FUNCTION_TRACE_PTR ("DsCreateBankField", Op);
281
282
283 /* First arg is the name of the parent OpRegion */
284
285 Arg = Op->Value.Arg;
286 if (!RegionNode)
287 {
288 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.Name,
289 ACPI_TYPE_REGION, IMODE_EXECUTE,
290 NS_SEARCH_PARENT, WalkState, &RegionNode);
291 if (ACPI_FAILURE (Status))
292 {
293 return_ACPI_STATUS (Status);
294 }
295 }
296
297 /* Second arg is the Bank Register */
298
299 Arg = Arg->Next;
300
301 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String,
302 INTERNAL_TYPE_BANK_FIELD_DEFN, IMODE_LOAD_PASS1,
303 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
304 NULL, &RegisterNode);
305 if (ACPI_FAILURE (Status))
306 {
307 return_ACPI_STATUS (Status);
308 }
309
310 /* Third arg is the BankValue */
311
312 Arg = Arg->Next;
313 BankValue = Arg->Value.Integer;
314
315
316 /* Next arg is the field flags */
317
318 Arg = Arg->Next;
319 FieldFlags = (UINT8) Arg->Value.Integer;
320
321 /* Each remaining arg is a Named Field */
322
323 Arg = Arg->Next;
324 while (Arg)
325 {
326 switch (Arg->Opcode)
327 {
328 case AML_INT_RESERVEDFIELD_OP:
329
330 FieldBitPosition += Arg->Value.Size;
331 break;
332
333
334 case AML_INT_ACCESSFIELD_OP:
335
336 /*
337 * Get a new AccessType and AccessAttribute for
338 * all entries (until end or another AccessAs keyword)
339 */
340 FieldFlags = (UINT8) ((FieldFlags & FIELD_ACCESS_TYPE_MASK) ||
341 ((UINT8) (Arg->Value.Integer >> 8)));
342 break;
343
344
345 case AML_INT_NAMEDFIELD_OP:
346
347 Status = AcpiNsLookup (WalkState->ScopeInfo,
348 (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name,
349 INTERNAL_TYPE_REGION_FIELD, IMODE_LOAD_PASS1,
350 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
351 NULL, &Node);
352 if (ACPI_FAILURE (Status))
353 {
354 return_ACPI_STATUS (Status);
355 }
356
357 /*
358 * Initialize an object for the new Node that is on
359 * the object stack
360 */
361
362 Status = AcpiExPrepBankFieldValue (Node, RegionNode, RegisterNode,
363 BankValue, FieldFlags, FieldBitPosition,
364 Arg->Value.Size);
365 if (ACPI_FAILURE (Status))
366 {
367 return_ACPI_STATUS (Status);
368 }
369
370 /* Keep track of bit position for the *next* field */
371
372 FieldBitPosition += Arg->Value.Size;
373 break;
374
375 }
376
377 Arg = Arg->Next;
378 }
379
380 return_ACPI_STATUS (Status);
381}
382
383
384/*******************************************************************************
385 *
386 * FUNCTION: AcpiDsCreateIndexField
387 *
388 * PARAMETERS: Op - Op containing the Field definition and args
389 * RegionNode - Object for the containing Operation Region
390 * ` WalkState - Current method state
391 *
392 * RETURN: Status
393 *
394 * DESCRIPTION: Create a new index field in the specified operation region
395 *
396 ******************************************************************************/
397
398ACPI_STATUS
399AcpiDsCreateIndexField (
400 ACPI_PARSE_OBJECT *Op,
401 ACPI_NAMESPACE_NODE *RegionNode,
402 ACPI_WALK_STATE *WalkState)
403{
404 ACPI_STATUS Status;
405 ACPI_PARSE_OBJECT *Arg;
406 ACPI_NAMESPACE_NODE *Node;
407 ACPI_NAMESPACE_NODE *IndexRegisterNode;
408 ACPI_NAMESPACE_NODE *DataRegisterNode;
409 UINT8 FieldFlags;
410 UINT32 FieldBitPosition = 0;
411
412
413 FUNCTION_TRACE_PTR ("DsCreateIndexField", Op);
414
415
416 Arg = Op->Value.Arg;
417
418 /* First arg is the name of the Index register */
419
420 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String,
421 ACPI_TYPE_ANY, IMODE_LOAD_PASS1,
422 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
423 NULL, &IndexRegisterNode);
424 if (ACPI_FAILURE (Status))
425 {
426 return_ACPI_STATUS (Status);
427 }
428
429 /* Second arg is the data register */
430
431 Arg = Arg->Next;
432
433 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String,
434 INTERNAL_TYPE_INDEX_FIELD_DEFN, IMODE_LOAD_PASS1,
435 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
436 NULL, &DataRegisterNode);
437 if (ACPI_FAILURE (Status))
438 {
439 return_ACPI_STATUS (Status);
440 }
441
442
443 /* Next arg is the field flags */
444
445 Arg = Arg->Next;
446 FieldFlags = (UINT8) Arg->Value.Integer;
447
448
449 /* Each remaining arg is a Named Field */
450
451 Arg = Arg->Next;
452 while (Arg)
453 {
454 switch (Arg->Opcode)
455 {
456 case AML_INT_RESERVEDFIELD_OP:
457
458 FieldBitPosition += Arg->Value.Size;
459 break;
460
461
462 case AML_INT_ACCESSFIELD_OP:
463
464 /*
465 * Get a new AccessType and AccessAttribute for all
466 * entries (until end or another AccessAs keyword)
467 */
468 FieldFlags = (UINT8) ((FieldFlags & FIELD_ACCESS_TYPE_MASK) ||
469 ((UINT8) (Arg->Value.Integer >> 8)));
470 break;
471
472
473 case AML_INT_NAMEDFIELD_OP:
474
475 Status = AcpiNsLookup (WalkState->ScopeInfo,
476 (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name,
477 INTERNAL_TYPE_INDEX_FIELD, IMODE_LOAD_PASS1,
478 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
479 NULL, &Node);
480 if (ACPI_FAILURE (Status))
481 {
482 return_ACPI_STATUS (Status);
483 }
484
485 /*
486 * Initialize an object for the new Node that is on
487 * the object stack
488 */
489
490 Status = AcpiExPrepIndexFieldValue (Node, IndexRegisterNode,
491 DataRegisterNode, FieldFlags,
492 FieldBitPosition, Arg->Value.Size);
493 if (ACPI_FAILURE (Status))
494 {
495 return_ACPI_STATUS (Status);
496 }
497
498 /* Keep track of bit position for the *next* field */
499
500 FieldBitPosition += Arg->Value.Size;
501 break;
502
503
504 default:
505
506 DEBUG_PRINTP (ACPI_ERROR, ("Invalid opcode in field list: %X\n",
507 Arg->Opcode));
508 Status = AE_AML_ERROR;
509 break;
510 }
511
512 Arg = Arg->Next;
513 }
514
515 return_ACPI_STATUS (Status);
516}
517
518