1 /******************************************************************************
2 *
3 * Module Name: dsfield - Dispatcher field routines
4 *
5 *****************************************************************************/
6
7 /******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************
115 *
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
118 *
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
133 *
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 *
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
149 *
150 *****************************************************************************/
151
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/amlcode.h>
155 #include <contrib/dev/acpica/include/acdispat.h>
156 #include <contrib/dev/acpica/include/acinterp.h>
157 #include <contrib/dev/acpica/include/acnamesp.h>
158 #include <contrib/dev/acpica/include/acparser.h>
159
160 #if !defined(ACPI_DB_APP) && defined(ACPI_EXEC_APP)
161 #include "aecommon.h"
162 #endif
163
164
165 #define _COMPONENT ACPI_DISPATCHER
166 ACPI_MODULE_NAME ("dsfield")
167
168 /* Local prototypes */
169
170 #ifdef ACPI_ASL_COMPILER
171 #include <contrib/dev/acpica/include/acdisasm.h>
172
173 static ACPI_STATUS
174 AcpiDsCreateExternalRegion (
175 ACPI_STATUS LookupStatus,
176 ACPI_PARSE_OBJECT *Op,
177 char *Path,
178 ACPI_WALK_STATE *WalkState,
179 ACPI_NAMESPACE_NODE **Node);
180 #endif
181
182 static ACPI_STATUS
183 AcpiDsGetFieldNames (
184 ACPI_CREATE_FIELD_INFO *Info,
185 ACPI_WALK_STATE *WalkState,
186 ACPI_PARSE_OBJECT *Arg);
187
188
189 #ifdef ACPI_ASL_COMPILER
190 /*******************************************************************************
191 *
192 * FUNCTION: AcpiDsCreateExternalRegion (iASL Disassembler only)
193 *
194 * PARAMETERS: LookupStatus - Status from NsLookup operation
195 * Op - Op containing the Field definition and args
196 * Path - Pathname of the region
197 * ` WalkState - Current method state
198 * Node - Where the new region node is returned
199 *
200 * RETURN: Status
201 *
202 * DESCRIPTION: Add region to the external list if NOT_FOUND. Create a new
203 * region node/object.
204 *
205 ******************************************************************************/
206
207 static ACPI_STATUS
AcpiDsCreateExternalRegion(ACPI_STATUS LookupStatus,ACPI_PARSE_OBJECT * Op,char * Path,ACPI_WALK_STATE * WalkState,ACPI_NAMESPACE_NODE ** Node)208 AcpiDsCreateExternalRegion (
209 ACPI_STATUS LookupStatus,
210 ACPI_PARSE_OBJECT *Op,
211 char *Path,
212 ACPI_WALK_STATE *WalkState,
213 ACPI_NAMESPACE_NODE **Node)
214 {
215 ACPI_STATUS Status;
216 ACPI_OPERAND_OBJECT *ObjDesc;
217
218
219 if (LookupStatus != AE_NOT_FOUND)
220 {
221 return (LookupStatus);
222 }
223
224 /*
225 * Table disassembly:
226 * OperationRegion not found. Generate an External for it, and
227 * insert the name into the namespace.
228 */
229 AcpiDmAddOpToExternalList (Op, Path, ACPI_TYPE_REGION, 0, 0);
230
231 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_REGION,
232 ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, Node);
233 if (ACPI_FAILURE (Status))
234 {
235 return (Status);
236 }
237
238 /* Must create and install a region object for the new node */
239
240 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
241 if (!ObjDesc)
242 {
243 return (AE_NO_MEMORY);
244 }
245
246 ObjDesc->Region.Node = *Node;
247 Status = AcpiNsAttachObject (*Node, ObjDesc, ACPI_TYPE_REGION);
248 return (Status);
249 }
250 #endif
251
252
253 /*******************************************************************************
254 *
255 * FUNCTION: AcpiDsCreateBufferField
256 *
257 * PARAMETERS: Op - Current parse op (CreateXXField)
258 * WalkState - Current state
259 *
260 * RETURN: Status
261 *
262 * DESCRIPTION: Execute the CreateField operators:
263 * CreateBitFieldOp,
264 * CreateByteFieldOp,
265 * CreateWordFieldOp,
266 * CreateDwordFieldOp,
267 * CreateQwordFieldOp,
268 * CreateFieldOp (all of which define a field in a buffer)
269 *
270 ******************************************************************************/
271
272 ACPI_STATUS
AcpiDsCreateBufferField(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)273 AcpiDsCreateBufferField (
274 ACPI_PARSE_OBJECT *Op,
275 ACPI_WALK_STATE *WalkState)
276 {
277 ACPI_PARSE_OBJECT *Arg;
278 ACPI_NAMESPACE_NODE *Node;
279 ACPI_STATUS Status;
280 ACPI_OPERAND_OBJECT *ObjDesc;
281 ACPI_OPERAND_OBJECT *SecondDesc = NULL;
282 UINT32 Flags;
283
284
285 ACPI_FUNCTION_TRACE (DsCreateBufferField);
286
287
288 /*
289 * Get the NameString argument (name of the new BufferField)
290 */
291 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
292 {
293 /* For CreateField, name is the 4th argument */
294
295 Arg = AcpiPsGetArg (Op, 3);
296 }
297 else
298 {
299 /* For all other CreateXXXField operators, name is the 3rd argument */
300
301 Arg = AcpiPsGetArg (Op, 2);
302 }
303
304 if (!Arg)
305 {
306 return_ACPI_STATUS (AE_AML_NO_OPERAND);
307 }
308
309 if (WalkState->DeferredNode)
310 {
311 Node = WalkState->DeferredNode;
312 Status = AE_OK;
313 }
314 else
315 {
316 /* Execute flag should always be set when this function is entered */
317
318 if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
319 {
320 ACPI_ERROR ((AE_INFO,
321 "Parse execute mode is not set"));
322 return_ACPI_STATUS (AE_AML_INTERNAL);
323 }
324
325 /* Creating new namespace node, should not already exist */
326
327 Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
328 ACPI_NS_ERROR_IF_FOUND;
329
330 /*
331 * Mark node temporary if we are executing a normal control
332 * method. (Don't mark if this is a module-level code method)
333 */
334 if (WalkState->MethodNode &&
335 !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
336 {
337 Flags |= ACPI_NS_TEMPORARY;
338 }
339
340 /* Enter the NameString into the namespace */
341
342 Status = AcpiNsLookup (WalkState->ScopeInfo,
343 Arg->Common.Value.String, ACPI_TYPE_ANY,
344 ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node);
345 if (ACPI_FAILURE (Status))
346 {
347 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
348 Arg->Common.Value.String, Status);
349 return_ACPI_STATUS (Status);
350 }
351 }
352
353 /*
354 * We could put the returned object (Node) on the object stack for later,
355 * but for now, we will put it in the "op" object that the parser uses,
356 * so we can get it again at the end of this scope.
357 */
358 Op->Common.Node = Node;
359
360 /*
361 * If there is no object attached to the node, this node was just created
362 * and we need to create the field object. Otherwise, this was a lookup
363 * of an existing node and we don't want to create the field object again.
364 */
365 ObjDesc = AcpiNsGetAttachedObject (Node);
366 if (ObjDesc)
367 {
368 return_ACPI_STATUS (AE_OK);
369 }
370
371 /*
372 * The Field definition is not fully parsed at this time.
373 * (We must save the address of the AML for the buffer and index operands)
374 */
375
376 /* Create the buffer field object */
377
378 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD);
379 if (!ObjDesc)
380 {
381 Status = AE_NO_MEMORY;
382 goto Cleanup;
383 }
384
385 /*
386 * Remember location in AML stream of the field unit opcode and operands
387 * -- since the buffer and index operands must be evaluated.
388 */
389 SecondDesc = ObjDesc->Common.NextObject;
390 SecondDesc->Extra.AmlStart = Op->Named.Data;
391 SecondDesc->Extra.AmlLength = Op->Named.Length;
392 ObjDesc->BufferField.Node = Node;
393
394 /* Attach constructed field descriptors to parent node */
395
396 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD);
397 if (ACPI_FAILURE (Status))
398 {
399 goto Cleanup;
400 }
401
402
403 Cleanup:
404
405 /* Remove local reference to the object */
406
407 AcpiUtRemoveReference (ObjDesc);
408 return_ACPI_STATUS (Status);
409 }
410
411
412 /*******************************************************************************
413 *
414 * FUNCTION: AcpiDsGetFieldNames
415 *
416 * PARAMETERS: Info - CreateField info structure
417 * ` WalkState - Current method state
418 * Arg - First parser arg for the field name list
419 *
420 * RETURN: Status
421 *
422 * DESCRIPTION: Process all named fields in a field declaration. Names are
423 * entered into the namespace.
424 *
425 ******************************************************************************/
426
427 static ACPI_STATUS
AcpiDsGetFieldNames(ACPI_CREATE_FIELD_INFO * Info,ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Arg)428 AcpiDsGetFieldNames (
429 ACPI_CREATE_FIELD_INFO *Info,
430 ACPI_WALK_STATE *WalkState,
431 ACPI_PARSE_OBJECT *Arg)
432 {
433 ACPI_STATUS Status;
434 UINT64 Position;
435 ACPI_PARSE_OBJECT *Child;
436
437 #if !defined(ACPI_DB_APP) && defined(ACPI_EXEC_APP)
438 UINT64 Value = 0;
439 ACPI_OPERAND_OBJECT *ResultDesc;
440 ACPI_OPERAND_OBJECT *ObjDesc;
441 char *NamePath;
442 #endif
443
444
445 ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info);
446
447
448 /* First field starts at bit zero */
449
450 Info->FieldBitPosition = 0;
451
452 /* Process all elements in the field list (of parse nodes) */
453
454 while (Arg)
455 {
456 /*
457 * Four types of field elements are handled:
458 * 1) Name - Enters a new named field into the namespace
459 * 2) Offset - specifies a bit offset
460 * 3) AccessAs - changes the access mode/attributes
461 * 4) Connection - Associate a resource template with the field
462 */
463 switch (Arg->Common.AmlOpcode)
464 {
465 case AML_INT_RESERVEDFIELD_OP:
466
467 Position = (UINT64) Info->FieldBitPosition +
468 (UINT64) Arg->Common.Value.Size;
469
470 if (Position > ACPI_UINT32_MAX)
471 {
472 ACPI_ERROR ((AE_INFO,
473 "Bit offset within field too large (> 0xFFFFFFFF)"));
474 return_ACPI_STATUS (AE_SUPPORT);
475 }
476
477 Info->FieldBitPosition = (UINT32) Position;
478 break;
479
480 case AML_INT_ACCESSFIELD_OP:
481 case AML_INT_EXTACCESSFIELD_OP:
482 /*
483 * Get new AccessType, AccessAttribute, and AccessLength fields
484 * -- to be used for all field units that follow, until the
485 * end-of-field or another AccessAs keyword is encountered.
486 * NOTE. These three bytes are encoded in the integer value
487 * of the parseop for convenience.
488 *
489 * In FieldFlags, preserve the flag bits other than the
490 * ACCESS_TYPE bits.
491 */
492
493 /* AccessType (ByteAcc, WordAcc, etc.) */
494
495 Info->FieldFlags = (UINT8)
496 ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
497 ((UINT8) ((UINT32) (Arg->Common.Value.Integer & 0x07))));
498
499 /* AccessAttribute (AttribQuick, AttribByte, etc.) */
500
501 Info->Attribute = (UINT8)
502 ((Arg->Common.Value.Integer >> 8) & 0xFF);
503
504 /* AccessLength (for serial/buffer protocols) */
505
506 Info->AccessLength = (UINT8)
507 ((Arg->Common.Value.Integer >> 16) & 0xFF);
508 break;
509
510 case AML_INT_CONNECTION_OP:
511 /*
512 * Clear any previous connection. New connection is used for all
513 * fields that follow, similar to AccessAs
514 */
515 Info->ResourceBuffer = NULL;
516 Info->ConnectionNode = NULL;
517 Info->PinNumberIndex = 0;
518
519 /*
520 * A Connection() is either an actual resource descriptor (buffer)
521 * or a named reference to a resource template
522 */
523 Child = Arg->Common.Value.Arg;
524 if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
525 {
526 Info->ResourceBuffer = Child->Named.Data;
527 Info->ResourceLength = (UINT16) Child->Named.Value.Integer;
528 }
529 else
530 {
531 /* Lookup the Connection() namepath, it should already exist */
532
533 Status = AcpiNsLookup (WalkState->ScopeInfo,
534 Child->Common.Value.Name, ACPI_TYPE_ANY,
535 ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
536 WalkState, &Info->ConnectionNode);
537 if (ACPI_FAILURE (Status))
538 {
539 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
540 Child->Common.Value.Name, Status);
541 return_ACPI_STATUS (Status);
542 }
543 }
544 break;
545
546 case AML_INT_NAMEDFIELD_OP:
547
548 /* Lookup the name, it should already exist */
549
550 Status = AcpiNsLookup (WalkState->ScopeInfo,
551 (char *) &Arg->Named.Name, Info->FieldType,
552 ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
553 WalkState, &Info->FieldNode);
554 if (ACPI_FAILURE (Status))
555 {
556 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
557 (char *) &Arg->Named.Name, Status);
558 return_ACPI_STATUS (Status);
559 }
560 else
561 {
562 Arg->Common.Node = Info->FieldNode;
563 Info->FieldBitLength = Arg->Common.Value.Size;
564
565 /*
566 * If there is no object attached to the node, this node was
567 * just created and we need to create the field object.
568 * Otherwise, this was a lookup of an existing node and we
569 * don't want to create the field object again.
570 */
571 if (!AcpiNsGetAttachedObject (Info->FieldNode))
572 {
573 Status = AcpiExPrepFieldValue (Info);
574 if (ACPI_FAILURE (Status))
575 {
576 return_ACPI_STATUS (Status);
577 }
578 #if !defined(ACPI_DB_APP) && defined(ACPI_EXEC_APP)
579 NamePath = AcpiNsGetExternalPathname (Info->FieldNode);
580 ObjDesc = AcpiUtCreateIntegerObject (Value);
581 if (ACPI_SUCCESS (AeLookupInitFileEntry (NamePath, &Value)))
582 {
583 AcpiExWriteDataToField (ObjDesc,
584 AcpiNsGetAttachedObject (Info->FieldNode),
585 &ResultDesc);
586 }
587 AcpiUtRemoveReference (ObjDesc);
588 ACPI_FREE (NamePath);
589 #endif
590 }
591 }
592
593 /* Keep track of bit position for the next field */
594
595 Position = (UINT64) Info->FieldBitPosition +
596 (UINT64) Arg->Common.Value.Size;
597
598 if (Position > ACPI_UINT32_MAX)
599 {
600 ACPI_ERROR ((AE_INFO,
601 "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
602 ACPI_CAST_PTR (char, &Info->FieldNode->Name)));
603 return_ACPI_STATUS (AE_SUPPORT);
604 }
605
606 Info->FieldBitPosition += Info->FieldBitLength;
607 Info->PinNumberIndex++; /* Index relative to previous Connection() */
608 break;
609
610 default:
611
612 ACPI_ERROR ((AE_INFO,
613 "Invalid opcode in field list: 0x%X",
614 Arg->Common.AmlOpcode));
615 return_ACPI_STATUS (AE_AML_BAD_OPCODE);
616 }
617
618 Arg = Arg->Common.Next;
619 }
620
621 return_ACPI_STATUS (AE_OK);
622 }
623
624
625 /*******************************************************************************
626 *
627 * FUNCTION: AcpiDsCreateField
628 *
629 * PARAMETERS: Op - Op containing the Field definition and args
630 * RegionNode - Object for the containing Operation Region
631 * ` WalkState - Current method state
632 *
633 * RETURN: Status
634 *
635 * DESCRIPTION: Create a new field in the specified operation region
636 *
637 ******************************************************************************/
638
639 ACPI_STATUS
AcpiDsCreateField(ACPI_PARSE_OBJECT * Op,ACPI_NAMESPACE_NODE * RegionNode,ACPI_WALK_STATE * WalkState)640 AcpiDsCreateField (
641 ACPI_PARSE_OBJECT *Op,
642 ACPI_NAMESPACE_NODE *RegionNode,
643 ACPI_WALK_STATE *WalkState)
644 {
645 ACPI_STATUS Status;
646 ACPI_PARSE_OBJECT *Arg;
647 ACPI_CREATE_FIELD_INFO Info;
648
649
650 ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op);
651
652
653 /* First arg is the name of the parent OpRegion (must already exist) */
654
655 Arg = Op->Common.Value.Arg;
656
657 if (!RegionNode)
658 {
659 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
660 ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
661 ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
662 #ifdef ACPI_ASL_COMPILER
663 Status = AcpiDsCreateExternalRegion (Status, Arg,
664 Arg->Common.Value.Name, WalkState, &RegionNode);
665 #endif
666 if (ACPI_FAILURE (Status))
667 {
668 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
669 Arg->Common.Value.Name, Status);
670 return_ACPI_STATUS (Status);
671 }
672 }
673
674 memset (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO));
675
676 /* Second arg is the field flags */
677
678 Arg = Arg->Common.Next;
679 Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
680 Info.Attribute = 0;
681
682 /* Each remaining arg is a Named Field */
683
684 Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD;
685 Info.RegionNode = RegionNode;
686
687 Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
688 return_ACPI_STATUS (Status);
689 }
690
691
692 /*******************************************************************************
693 *
694 * FUNCTION: AcpiDsInitFieldObjects
695 *
696 * PARAMETERS: Op - Op containing the Field definition and args
697 * ` WalkState - Current method state
698 *
699 * RETURN: Status
700 *
701 * DESCRIPTION: For each "Field Unit" name in the argument list that is
702 * part of the field declaration, enter the name into the
703 * namespace.
704 *
705 ******************************************************************************/
706
707 ACPI_STATUS
AcpiDsInitFieldObjects(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)708 AcpiDsInitFieldObjects (
709 ACPI_PARSE_OBJECT *Op,
710 ACPI_WALK_STATE *WalkState)
711 {
712 ACPI_STATUS Status;
713 ACPI_PARSE_OBJECT *Arg = NULL;
714 ACPI_NAMESPACE_NODE *Node;
715 UINT8 Type = 0;
716 UINT32 Flags;
717
718
719 ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op);
720
721
722 /* Execute flag should always be set when this function is entered */
723
724 if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
725 {
726 if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)
727 {
728 /* BankField Op is deferred, just return OK */
729
730 return_ACPI_STATUS (AE_OK);
731 }
732
733 ACPI_ERROR ((AE_INFO,
734 "Parse deferred mode is not set"));
735 return_ACPI_STATUS (AE_AML_INTERNAL);
736 }
737
738 /*
739 * Get the FieldList argument for this opcode. This is the start of the
740 * list of field elements.
741 */
742 switch (WalkState->Opcode)
743 {
744 case AML_FIELD_OP:
745
746 Arg = AcpiPsGetArg (Op, 2);
747 Type = ACPI_TYPE_LOCAL_REGION_FIELD;
748 break;
749
750 case AML_BANK_FIELD_OP:
751
752 Arg = AcpiPsGetArg (Op, 4);
753 Type = ACPI_TYPE_LOCAL_BANK_FIELD;
754 break;
755
756 case AML_INDEX_FIELD_OP:
757
758 Arg = AcpiPsGetArg (Op, 3);
759 Type = ACPI_TYPE_LOCAL_INDEX_FIELD;
760 break;
761
762 default:
763
764 return_ACPI_STATUS (AE_BAD_PARAMETER);
765 }
766
767 /* Creating new namespace node(s), should not already exist */
768
769 Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
770 ACPI_NS_ERROR_IF_FOUND;
771
772 /*
773 * Mark node(s) temporary if we are executing a normal control
774 * method. (Don't mark if this is a module-level code method)
775 */
776 if (WalkState->MethodNode &&
777 !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
778 {
779 Flags |= ACPI_NS_TEMPORARY;
780 }
781
782 #ifdef ACPI_EXEC_APP
783 Flags |= ACPI_NS_OVERRIDE_IF_FOUND;
784 #endif
785 /*
786 * Walk the list of entries in the FieldList
787 * Note: FieldList can be of zero length. In this case, Arg will be NULL.
788 */
789 while (Arg)
790 {
791 /*
792 * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested
793 * in the field names in order to enter them into the namespace.
794 */
795 if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
796 {
797 Status = AcpiNsLookup (WalkState->ScopeInfo,
798 (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
799 Flags, WalkState, &Node);
800 if (ACPI_FAILURE (Status))
801 {
802 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
803 (char *) &Arg->Named.Name, Status);
804 if (Status != AE_ALREADY_EXISTS)
805 {
806 return_ACPI_STATUS (Status);
807 }
808
809 /* Name already exists, just ignore this error */
810
811 Status = AE_OK;
812 }
813
814 Arg->Common.Node = Node;
815 }
816
817 /* Get the next field element in the list */
818
819 Arg = Arg->Common.Next;
820 }
821
822 return_ACPI_STATUS (AE_OK);
823 }
824
825
826 /*******************************************************************************
827 *
828 * FUNCTION: AcpiDsCreateBankField
829 *
830 * PARAMETERS: Op - Op containing the Field definition and args
831 * RegionNode - Object for the containing Operation Region
832 * WalkState - Current method state
833 *
834 * RETURN: Status
835 *
836 * DESCRIPTION: Create a new bank field in the specified operation region
837 *
838 ******************************************************************************/
839
840 ACPI_STATUS
AcpiDsCreateBankField(ACPI_PARSE_OBJECT * Op,ACPI_NAMESPACE_NODE * RegionNode,ACPI_WALK_STATE * WalkState)841 AcpiDsCreateBankField (
842 ACPI_PARSE_OBJECT *Op,
843 ACPI_NAMESPACE_NODE *RegionNode,
844 ACPI_WALK_STATE *WalkState)
845 {
846 ACPI_STATUS Status;
847 ACPI_PARSE_OBJECT *Arg;
848 ACPI_CREATE_FIELD_INFO Info;
849
850
851 ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op);
852
853
854 /* First arg is the name of the parent OpRegion (must already exist) */
855
856 Arg = Op->Common.Value.Arg;
857 if (!RegionNode)
858 {
859 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name,
860 ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE,
861 ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode);
862 #ifdef ACPI_ASL_COMPILER
863 Status = AcpiDsCreateExternalRegion (Status, Arg,
864 Arg->Common.Value.Name, WalkState, &RegionNode);
865 #endif
866 if (ACPI_FAILURE (Status))
867 {
868 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
869 Arg->Common.Value.Name, Status);
870 return_ACPI_STATUS (Status);
871 }
872 }
873
874 /* Second arg is the Bank Register (Field) (must already exist) */
875
876 Arg = Arg->Common.Next;
877 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
878 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
879 ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
880 if (ACPI_FAILURE (Status))
881 {
882 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
883 Arg->Common.Value.String, Status);
884 return_ACPI_STATUS (Status);
885 }
886
887 /*
888 * Third arg is the BankValue
889 * This arg is a TermArg, not a constant
890 * It will be evaluated later, by AcpiDsEvalBankFieldOperands
891 */
892 Arg = Arg->Common.Next;
893
894 /* Fourth arg is the field flags */
895
896 Arg = Arg->Common.Next;
897 Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
898
899 /* Each remaining arg is a Named Field */
900
901 Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD;
902 Info.RegionNode = RegionNode;
903
904 /*
905 * Use Info.DataRegisterNode to store BankField Op
906 * It's safe because DataRegisterNode will never be used when create
907 * bank field \we store AmlStart and AmlLength in the BankField Op for
908 * late evaluation. Used in AcpiExPrepFieldValue(Info)
909 *
910 * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like
911 * "void *ParentOp"?
912 */
913 Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op;
914
915 Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
916 return_ACPI_STATUS (Status);
917 }
918
919
920 /*******************************************************************************
921 *
922 * FUNCTION: AcpiDsCreateIndexField
923 *
924 * PARAMETERS: Op - Op containing the Field definition and args
925 * RegionNode - Object for the containing Operation Region
926 * ` WalkState - Current method state
927 *
928 * RETURN: Status
929 *
930 * DESCRIPTION: Create a new index field in the specified operation region
931 *
932 ******************************************************************************/
933
934 ACPI_STATUS
AcpiDsCreateIndexField(ACPI_PARSE_OBJECT * Op,ACPI_NAMESPACE_NODE * RegionNode,ACPI_WALK_STATE * WalkState)935 AcpiDsCreateIndexField (
936 ACPI_PARSE_OBJECT *Op,
937 ACPI_NAMESPACE_NODE *RegionNode,
938 ACPI_WALK_STATE *WalkState)
939 {
940 ACPI_STATUS Status;
941 ACPI_PARSE_OBJECT *Arg;
942 ACPI_CREATE_FIELD_INFO Info;
943
944
945 ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op);
946
947
948 /* First arg is the name of the Index register (must already exist) */
949
950 Arg = Op->Common.Value.Arg;
951 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
952 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
953 ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode);
954 if (ACPI_FAILURE (Status))
955 {
956 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
957 Arg->Common.Value.String, Status);
958 return_ACPI_STATUS (Status);
959 }
960
961 /* Second arg is the data register (must already exist) */
962
963 Arg = Arg->Common.Next;
964 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
965 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
966 ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode);
967 if (ACPI_FAILURE (Status))
968 {
969 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
970 Arg->Common.Value.String, Status);
971 return_ACPI_STATUS (Status);
972 }
973
974 /* Next arg is the field flags */
975
976 Arg = Arg->Common.Next;
977 Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
978
979 /* Each remaining arg is a Named Field */
980
981 Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD;
982 Info.RegionNode = RegionNode;
983
984 Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next);
985 return_ACPI_STATUS (Status);
986 }
987