Update ACPI build wrappers to use new ACPICA(20050309) code.
[dragonfly.git] / sys / contrib / dev / acpica-unix-20050211 / interpreter / executer / exprep.c
1
2 /******************************************************************************
3  *
4  * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
5  *              $Revision: 130 $
6  *
7  *****************************************************************************/
8
9 /******************************************************************************
10  *
11  * 1. Copyright Notice
12  *
13  * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
14  * All rights reserved.
15  *
16  * 2. License
17  *
18  * 2.1. This is your license from Intel Corp. under its intellectual property
19  * rights.  You may have additional license terms from the party that provided
20  * you this software, covering your right to use that party's intellectual
21  * property rights.
22  *
23  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24  * copy of the source code appearing in this file ("Covered Code") an
25  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26  * base code distributed originally by Intel ("Original Intel Code") to copy,
27  * make derivatives, distribute, use and display any portion of the Covered
28  * Code in any form, with the right to sublicense such rights; and
29  *
30  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31  * license (with the right to sublicense), under only those claims of Intel
32  * patents that are infringed by the Original Intel Code, to make, use, sell,
33  * offer to sell, and import the Covered Code and derivative works thereof
34  * solely to the minimum extent necessary to exercise the above copyright
35  * license, and in no event shall the patent license extend to any additions
36  * to or modifications of the Original Intel Code.  No other license or right
37  * is granted directly or by implication, estoppel or otherwise;
38  *
39  * The above copyright and patent license is granted only if the following
40  * conditions are met:
41  *
42  * 3. Conditions
43  *
44  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45  * Redistribution of source code of any substantial portion of the Covered
46  * Code or modification with rights to further distribute source must include
47  * the above Copyright Notice, the above License, this list of Conditions,
48  * and the following Disclaimer and Export Compliance provision.  In addition,
49  * Licensee must cause all Covered Code to which Licensee contributes to
50  * contain a file documenting the changes Licensee made to create that Covered
51  * Code and the date of any change.  Licensee must include in that file the
52  * documentation of any changes made by any predecessor Licensee.  Licensee
53  * must include a prominent statement that the modification is derived,
54  * directly or indirectly, from Original Intel Code.
55  *
56  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57  * Redistribution of source code of any substantial portion of the Covered
58  * Code or modification without rights to further distribute source must
59  * include the following Disclaimer and Export Compliance provision in the
60  * documentation and/or other materials provided with distribution.  In
61  * addition, Licensee may not authorize further sublicense of source of any
62  * portion of the Covered Code, and must include terms to the effect that the
63  * license from Licensee to its licensee is limited to the intellectual
64  * property embodied in the software Licensee provides to its licensee, and
65  * not to intellectual property embodied in modifications its licensee may
66  * make.
67  *
68  * 3.3. Redistribution of Executable. Redistribution in executable form of any
69  * substantial portion of the Covered Code or modification must reproduce the
70  * above Copyright Notice, and the following Disclaimer and Export Compliance
71  * provision in the documentation and/or other materials provided with the
72  * distribution.
73  *
74  * 3.4. Intel retains all right, title, and interest in and to the Original
75  * Intel Code.
76  *
77  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78  * Intel shall be used in advertising or otherwise to promote the sale, use or
79  * other dealings in products derived from or relating to the Covered Code
80  * without prior written authorization from Intel.
81  *
82  * 4. Disclaimer and Export Compliance
83  *
84  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
87  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
88  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
89  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90  * PARTICULAR PURPOSE.
91  *
92  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
98  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99  * LIMITED REMEDY.
100  *
101  * 4.3. Licensee shall not export, either directly or indirectly, any of this
102  * software or system incorporating such software without first obtaining any
103  * required license or other approval from the U. S. Department of Commerce or
104  * any other agency or department of the United States Government.  In the
105  * event Licensee exports any such software from the United States or
106  * re-exports any such software from a foreign destination, Licensee shall
107  * ensure that the distribution and export/re-export of the software is in
108  * compliance with all laws, regulations, orders, or other restrictions of the
109  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110  * any of its subsidiaries will export/re-export any technical data, process,
111  * software, or service, directly or indirectly, to any country for which the
112  * United States government or any agency thereof requires an export license,
113  * other governmental approval, or letter of assurance, without first obtaining
114  * such license, approval or letter.
115  *
116  *****************************************************************************/
117
118 #define __EXPREP_C__
119
120 #include "acpi.h"
121 #include "acinterp.h"
122 #include "amlcode.h"
123 #include "acnamesp.h"
124
125
126 #define _COMPONENT          ACPI_EXECUTER
127         ACPI_MODULE_NAME    ("exprep")
128
129
130 #ifdef ACPI_UNDER_DEVELOPMENT
131 /*******************************************************************************
132  *
133  * FUNCTION:    AcpiExGenerateAccess
134  *
135  * PARAMETERS:  FieldBitOffset      - Start of field within parent region/buffer
136  *              FieldBitLength      - Length of field in bits
137  *              RegionLength        - Length of parent in bytes
138  *
139  * RETURN:      Field granularity (8, 16, 32 or 64) and
140  *              ByteAlignment (1, 2, 3, or 4)
141  *
142  * DESCRIPTION: Generate an optimal access width for fields defined with the
143  *              AnyAcc keyword.
144  *
145  * NOTE: Need to have the RegionLength in order to check for boundary
146  *       conditions (end-of-region).  However, the RegionLength is a deferred
147  *       operation.  Therefore, to complete this implementation, the generation
148  *       of this access width must be deferred until the region length has
149  *       been evaluated.
150  *
151  ******************************************************************************/
152
153 static UINT32
154 AcpiExGenerateAccess (
155     UINT32                  FieldBitOffset,
156     UINT32                  FieldBitLength,
157     UINT32                  RegionLength)
158 {
159     UINT32                  FieldByteLength;
160     UINT32                  FieldByteOffset;
161     UINT32                  FieldByteEndOffset;
162     UINT32                  AccessByteWidth;
163     UINT32                  FieldStartOffset;
164     UINT32                  FieldEndOffset;
165     UINT32                  MinimumAccessWidth = 0xFFFFFFFF;
166     UINT32                  MinimumAccesses = 0xFFFFFFFF;
167     UINT32                  Accesses;
168
169
170     ACPI_FUNCTION_TRACE ("ExGenerateAccess");
171
172
173     /* Round Field start offset and length to "minimal" byte boundaries */
174
175     FieldByteOffset    = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8));
176     FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP   (FieldBitLength + FieldBitOffset, 8));
177     FieldByteLength    = FieldByteEndOffset - FieldByteOffset;
178
179     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
180             "Bit length %d, Bit offset %d\n",
181             FieldBitLength, FieldBitOffset));
182     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
183             "Byte Length %d, Byte Offset %d, End Offset %d\n",
184             FieldByteLength, FieldByteOffset, FieldByteEndOffset));
185
186     /*
187      * Iterative search for the maximum access width that is both aligned
188      * and does not go beyond the end of the region
189      *
190      * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes)
191      */
192     for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1)
193     {
194         /*
195          * 1) Round end offset up to next access boundary and make sure that this
196          *    does not go beyond the end of the parent region.
197          * 2) When the Access width is greater than the FieldByteLength, we are done.
198          *    (This does not optimize for the perfectly aligned case yet).
199          */
200         if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength)
201         {
202             FieldStartOffset = ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) /
203                                                     AccessByteWidth;
204             FieldEndOffset   = ACPI_ROUND_UP   ((FieldByteLength + FieldByteOffset),
205                                                     AccessByteWidth) / AccessByteWidth;
206             Accesses         = FieldEndOffset - FieldStartOffset;
207
208             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
209                     "AccessWidth %d end is within region\n", AccessByteWidth));
210             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
211                     "Field Start %d, Field End %d -- requires %d accesses\n",
212                     FieldStartOffset, FieldEndOffset, Accesses));
213
214             /* Single access is optimal */
215
216             if (Accesses <= 1)
217             {
218                 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
219                         "Entire field can be accessed with one operation of size %d\n",
220                         AccessByteWidth));
221                 return_VALUE (AccessByteWidth);
222             }
223
224             /*
225              * Fits in the region, but requires more than one read/write.
226              * try the next wider access on next iteration
227              */
228             if (Accesses < MinimumAccesses)
229             {
230                 MinimumAccesses    = Accesses;
231                 MinimumAccessWidth = AccessByteWidth;
232             }
233         }
234         else
235         {
236             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
237                     "AccessWidth %d end is NOT within region\n", AccessByteWidth));
238             if (AccessByteWidth == 1)
239             {
240                 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
241                         "Field goes beyond end-of-region!\n"));
242                 return_VALUE (0);     /* Field does not fit in the region at all */
243             }
244
245             /* This width goes beyond the end-of-region, back off to previous access */
246
247             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
248                     "Backing off to previous optimal access width of %d\n",
249                     MinimumAccessWidth));
250             return_VALUE (MinimumAccessWidth);
251         }
252     }
253
254     /* Could not read/write field with one operation, just use max access width */
255
256     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
257             "Cannot access field in one operation, using width 8\n"));
258     return_VALUE (8);
259 }
260 #endif /* ACPI_UNDER_DEVELOPMENT */
261
262
263 /*******************************************************************************
264  *
265  * FUNCTION:    AcpiExDecodeFieldAccess
266  *
267  * PARAMETERS:  Access          - Encoded field access bits
268  *              Length          - Field length.
269  *
270  * RETURN:      Field granularity (8, 16, 32 or 64) and
271  *              ByteAlignment (1, 2, 3, or 4)
272  *
273  * DESCRIPTION: Decode the AccessType bits of a field definition.
274  *
275  ******************************************************************************/
276
277 static UINT32
278 AcpiExDecodeFieldAccess (
279     ACPI_OPERAND_OBJECT     *ObjDesc,
280     UINT8                   FieldFlags,
281     UINT32                  *ReturnByteAlignment)
282 {
283     UINT32                  Access;
284     UINT32                  ByteAlignment;
285     UINT32                  BitLength;
286
287
288     ACPI_FUNCTION_TRACE ("ExDecodeFieldAccess");
289
290
291     Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK);
292
293     switch (Access)
294     {
295     case AML_FIELD_ACCESS_ANY:
296
297 #ifdef ACPI_UNDER_DEVELOPMENT
298         ByteAlignment = AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset,
299                                 ObjDesc->CommonField.BitLength,
300                                 0xFFFFFFFF /* Temp until we pass RegionLength as param */);
301         BitLength = ByteAlignment * 8;
302 #endif
303
304         ByteAlignment = 1;
305         BitLength = 8;
306         break;
307
308     case AML_FIELD_ACCESS_BYTE:
309     case AML_FIELD_ACCESS_BUFFER:   /* ACPI 2.0 (SMBus Buffer) */
310         ByteAlignment = 1;
311         BitLength     = 8;
312         break;
313
314     case AML_FIELD_ACCESS_WORD:
315         ByteAlignment = 2;
316         BitLength     = 16;
317         break;
318
319     case AML_FIELD_ACCESS_DWORD:
320         ByteAlignment = 4;
321         BitLength     = 32;
322         break;
323
324     case AML_FIELD_ACCESS_QWORD:    /* ACPI 2.0 */
325         ByteAlignment = 8;
326         BitLength     = 64;
327         break;
328
329     default:
330         /* Invalid field access type */
331
332         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
333             "Unknown field access type %X\n",
334             Access));
335         return_VALUE (0);
336     }
337
338     if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD)
339     {
340         /*
341          * BufferField access can be on any byte boundary, so the
342          * ByteAlignment is always 1 byte -- regardless of any ByteAlignment
343          * implied by the field access type.
344          */
345         ByteAlignment = 1;
346     }
347
348     *ReturnByteAlignment = ByteAlignment;
349     return_VALUE (BitLength);
350 }
351
352
353 /*******************************************************************************
354  *
355  * FUNCTION:    AcpiExPrepCommonFieldObject
356  *
357  * PARAMETERS:  ObjDesc             - The field object
358  *              FieldFlags          - Access, LockRule, and UpdateRule.
359  *                                    The format of a FieldFlag is described
360  *                                    in the ACPI specification
361  *              FieldBitPosition    - Field start position
362  *              FieldBitLength      - Field length in number of bits
363  *
364  * RETURN:      Status
365  *
366  * DESCRIPTION: Initialize the areas of the field object that are common
367  *              to the various types of fields.  Note: This is very "sensitive"
368  *              code because we are solving the general case for field
369  *              alignment.
370  *
371  ******************************************************************************/
372
373 ACPI_STATUS
374 AcpiExPrepCommonFieldObject (
375     ACPI_OPERAND_OBJECT     *ObjDesc,
376     UINT8                   FieldFlags,
377     UINT8                   FieldAttribute,
378     UINT32                  FieldBitPosition,
379     UINT32                  FieldBitLength)
380 {
381     UINT32                  AccessBitWidth;
382     UINT32                  ByteAlignment;
383     UINT32                  NearestByteAddress;
384
385
386     ACPI_FUNCTION_TRACE ("ExPrepCommonFieldObject");
387
388
389     /*
390      * Note: the structure being initialized is the
391      * ACPI_COMMON_FIELD_INFO;  No structure fields outside of the common
392      * area are initialized by this procedure.
393      */
394     ObjDesc->CommonField.FieldFlags = FieldFlags;
395     ObjDesc->CommonField.Attribute  = FieldAttribute;
396     ObjDesc->CommonField.BitLength  = FieldBitLength;
397
398     /*
399      * Decode the access type so we can compute offsets.  The access type gives
400      * two pieces of information - the width of each field access and the
401      * necessary ByteAlignment (address granularity) of the access.
402      *
403      * For AnyAcc, the AccessBitWidth is the largest width that is both
404      * necessary and possible in an attempt to access the whole field in one
405      * I/O operation.  However, for AnyAcc, the ByteAlignment is always one
406      * byte.
407      *
408      * For all Buffer Fields, the ByteAlignment is always one byte.
409      *
410      * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is
411      * the same (equivalent) as the ByteAlignment.
412      */
413     AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags,
414                                 &ByteAlignment);
415     if (!AccessBitWidth)
416     {
417         return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
418     }
419
420     /* Setup width (access granularity) fields */
421
422     ObjDesc->CommonField.AccessByteWidth = (UINT8)
423             ACPI_DIV_8 (AccessBitWidth); /* 1,  2,  4,  8 */
424
425     ObjDesc->CommonField.AccessBitWidth = (UINT8) AccessBitWidth;
426
427     /*
428      * BaseByteOffset is the address of the start of the field within the
429      * region.  It is the byte address of the first *datum* (field-width data
430      * unit) of the field. (i.e., the first datum that contains at least the
431      * first *bit* of the field.)
432      *
433      * Note: ByteAlignment is always either equal to the AccessBitWidth or 8
434      * (Byte access), and it defines the addressing granularity of the parent
435      * region or buffer.
436      */
437     NearestByteAddress =
438             ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition);
439     ObjDesc->CommonField.BaseByteOffset = (UINT32)
440             ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment);
441
442     /*
443      * StartFieldBitOffset is the offset of the first bit of the field within
444      * a field datum.
445      */
446     ObjDesc->CommonField.StartFieldBitOffset = (UINT8)
447         (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset));
448
449     /*
450      * Does the entire field fit within a single field access element? (datum)
451      * (i.e., without crossing a datum boundary)
452      */
453     if ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) <=
454             (UINT16) AccessBitWidth)
455     {
456         ObjDesc->Common.Flags |= AOPOBJ_SINGLE_DATUM;
457     }
458
459     return_ACPI_STATUS (AE_OK);
460 }
461
462
463 /*******************************************************************************
464  *
465  * FUNCTION:    AcpiExPrepFieldValue
466  *
467  * PARAMETERS:  Node                - Owning Node
468  *              RegionNode          - Region in which field is being defined
469  *              FieldFlags          - Access, LockRule, and UpdateRule.
470  *              FieldBitPosition    - Field start position
471  *              FieldBitLength      - Field length in number of bits
472  *
473  * RETURN:      Status
474  *
475  * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and
476  *              connect it to the parent Node.
477  *
478  ******************************************************************************/
479
480 ACPI_STATUS
481 AcpiExPrepFieldValue (
482     ACPI_CREATE_FIELD_INFO  *Info)
483 {
484     ACPI_OPERAND_OBJECT     *ObjDesc;
485     UINT32                  Type;
486     ACPI_STATUS             Status;
487
488
489     ACPI_FUNCTION_TRACE ("ExPrepFieldValue");
490
491
492     /* Parameter validation */
493
494     if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD)
495     {
496         if (!Info->RegionNode)
497         {
498             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null RegionNode\n"));
499             return_ACPI_STATUS (AE_AML_NO_OPERAND);
500         }
501
502         Type = AcpiNsGetType (Info->RegionNode);
503         if (Type != ACPI_TYPE_REGION)
504         {
505             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
506                 "Needed Region, found type %X (%s)\n",
507                 Type, AcpiUtGetTypeName (Type)));
508
509             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
510         }
511     }
512
513     /* Allocate a new field object */
514
515     ObjDesc = AcpiUtCreateInternalObject (Info->FieldType);
516     if (!ObjDesc)
517     {
518         return_ACPI_STATUS (AE_NO_MEMORY);
519     }
520
521     /* Initialize areas of the object that are common to all fields */
522
523     ObjDesc->CommonField.Node = Info->FieldNode;
524     Status = AcpiExPrepCommonFieldObject (ObjDesc, Info->FieldFlags,
525                 Info->Attribute, Info->FieldBitPosition, Info->FieldBitLength);
526     if (ACPI_FAILURE (Status))
527     {
528         AcpiUtDeleteObjectDesc (ObjDesc);
529         return_ACPI_STATUS (Status);
530     }
531
532     /* Initialize areas of the object that are specific to the field type */
533
534     switch (Info->FieldType)
535     {
536     case ACPI_TYPE_LOCAL_REGION_FIELD:
537
538         ObjDesc->Field.RegionObj     = AcpiNsGetAttachedObject (Info->RegionNode);
539
540         /* An additional reference for the container */
541
542         AcpiUtAddReference (ObjDesc->Field.RegionObj);
543
544         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
545             "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
546             ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset,
547             ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj));
548         break;
549
550
551     case ACPI_TYPE_LOCAL_BANK_FIELD:
552
553         ObjDesc->BankField.Value     = Info->BankValue;
554         ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode);
555         ObjDesc->BankField.BankObj   = AcpiNsGetAttachedObject (Info->RegisterNode);
556
557         /* An additional reference for the attached objects */
558
559         AcpiUtAddReference (ObjDesc->BankField.RegionObj);
560         AcpiUtAddReference (ObjDesc->BankField.BankObj);
561
562         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
563             "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n",
564             ObjDesc->BankField.StartFieldBitOffset,
565             ObjDesc->BankField.BaseByteOffset,
566             ObjDesc->Field.AccessByteWidth,
567             ObjDesc->BankField.RegionObj,
568             ObjDesc->BankField.BankObj));
569         break;
570
571
572     case ACPI_TYPE_LOCAL_INDEX_FIELD:
573
574         ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject (Info->RegisterNode);
575         ObjDesc->IndexField.DataObj  = AcpiNsGetAttachedObject (Info->DataRegisterNode);
576         ObjDesc->IndexField.Value    = (UINT32)
577             (Info->FieldBitPosition / ACPI_MUL_8 (ObjDesc->Field.AccessByteWidth));
578
579         if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj)
580         {
581             ACPI_REPORT_ERROR (("Null Index Object during field prep\n"));
582             AcpiUtDeleteObjectDesc (ObjDesc);
583             return_ACPI_STATUS (AE_AML_INTERNAL);
584         }
585
586         /* An additional reference for the attached objects */
587
588         AcpiUtAddReference (ObjDesc->IndexField.DataObj);
589         AcpiUtAddReference (ObjDesc->IndexField.IndexObj);
590
591         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
592             "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n",
593             ObjDesc->IndexField.StartFieldBitOffset,
594             ObjDesc->IndexField.BaseByteOffset,
595             ObjDesc->IndexField.Value,
596             ObjDesc->Field.AccessByteWidth,
597             ObjDesc->IndexField.IndexObj,
598             ObjDesc->IndexField.DataObj));
599         break;
600
601     default:
602         /* No other types should get here */
603         break;
604     }
605
606     /*
607      * Store the constructed descriptor (ObjDesc) into the parent Node,
608      * preserving the current type of that NamedObj.
609      */
610     Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc,
611                     AcpiNsGetType (Info->FieldNode));
612
613     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n",
614             Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc));
615
616     /* Remove local reference to the object */
617
618     AcpiUtRemoveReference (ObjDesc);
619     return_ACPI_STATUS (Status);
620 }
621