exfldio.c revision 196970
1193323Sed/******************************************************************************
2193323Sed *
3193323Sed * Module Name: exfldio - Aml Field I/O
4193323Sed *
5193323Sed *****************************************************************************/
6193323Sed
7193323Sed/******************************************************************************
8193323Sed *
9193323Sed * 1. Copyright Notice
10193323Sed *
11193323Sed * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12193323Sed * All rights reserved.
13193323Sed *
14193323Sed * 2. License
15193323Sed *
16205218Srdivacky * 2.1. This is your license from Intel Corp. under its intellectual property
17193323Sed * rights.  You may have additional license terms from the party that provided
18198090Srdivacky * you this software, covering your right to use that party's intellectual
19193323Sed * property rights.
20193323Sed *
21193323Sed * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22208599Srdivacky * copy of the source code appearing in this file ("Covered Code") an
23193323Sed * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24198090Srdivacky * base code distributed originally by Intel ("Original Intel Code") to copy,
25202878Srdivacky * make derivatives, distribute, use and display any portion of the Covered
26202878Srdivacky * Code in any form, with the right to sublicense such rights; and
27206083Srdivacky *
28202878Srdivacky * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29202878Srdivacky * license (with the right to sublicense), under only those claims of Intel
30193323Sed * patents that are infringed by the Original Intel Code, to make, use, sell,
31193323Sed * offer to sell, and import the Covered Code and derivative works thereof
32193323Sed * solely to the minimum extent necessary to exercise the above copyright
33193323Sed * license, and in no event shall the patent license extend to any additions
34202878Srdivacky * to or modifications of the Original Intel Code.  No other license or right
35202878Srdivacky * is granted directly or by implication, estoppel or otherwise;
36193323Sed *
37193323Sed * The above copyright and patent license is granted only if the following
38193323Sed * conditions are met:
39193323Sed *
40193323Sed * 3. Conditions
41193323Sed *
42193323Sed * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43193323Sed * Redistribution of source code of any substantial portion of the Covered
44193323Sed * Code or modification with rights to further distribute source must include
45193323Sed * the above Copyright Notice, the above License, this list of Conditions,
46193323Sed * and the following Disclaimer and Export Compliance provision.  In addition,
47193323Sed * Licensee must cause all Covered Code to which Licensee contributes to
48208599Srdivacky * contain a file documenting the changes Licensee made to create that Covered
49208599Srdivacky * Code and the date of any change.  Licensee must include in that file the
50208599Srdivacky * documentation of any changes made by any predecessor Licensee.  Licensee
51208599Srdivacky * must include a prominent statement that the modification is derived,
52208599Srdivacky * directly or indirectly, from Original Intel Code.
53208599Srdivacky *
54208599Srdivacky * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55208599Srdivacky * Redistribution of source code of any substantial portion of the Covered
56208599Srdivacky * Code or modification without rights to further distribute source must
57208599Srdivacky * include the following Disclaimer and Export Compliance provision in the
58208599Srdivacky * documentation and/or other materials provided with distribution.  In
59208599Srdivacky * addition, Licensee may not authorize further sublicense of source of any
60208599Srdivacky * portion of the Covered Code, and must include terms to the effect that the
61208599Srdivacky * license from Licensee to its licensee is limited to the intellectual
62210299Sed * property embodied in the software Licensee provides to its licensee, and
63210299Sed * not to intellectual property embodied in modifications its licensee may
64210299Sed * make.
65210299Sed *
66210299Sed * 3.3. Redistribution of Executable. Redistribution in executable form of any
67208599Srdivacky * substantial portion of the Covered Code or modification must reproduce the
68208599Srdivacky * above Copyright Notice, and the following Disclaimer and Export Compliance
69208599Srdivacky * provision in the documentation and/or other materials provided with the
70193323Sed * distribution.
71193323Sed *
72193323Sed * 3.4. Intel retains all right, title, and interest in and to the Original
73193323Sed * Intel Code.
74193323Sed *
75193323Sed * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76193323Sed * Intel shall be used in advertising or otherwise to promote the sale, use or
77193323Sed * other dealings in products derived from or relating to the Covered Code
78208599Srdivacky * without prior written authorization from Intel.
79193323Sed *
80193323Sed * 4. Disclaimer and Export Compliance
81193323Sed *
82193323Sed * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83193323Sed * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84193323Sed * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85193323Sed * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86193323Sed * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87193323Sed * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88193323Sed * PARTICULAR PURPOSE.
89193323Sed *
90193323Sed * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91193323Sed * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92193323Sed * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93193323Sed * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94193323Sed * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95193323Sed * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96193323Sed * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97193323Sed * LIMITED REMEDY.
98193323Sed *
99193323Sed * 4.3. Licensee shall not export, either directly or indirectly, any of this
100193323Sed * software or system incorporating such software without first obtaining any
101193323Sed * required license or other approval from the U. S. Department of Commerce or
102193323Sed * any other agency or department of the United States Government.  In the
103193323Sed * event Licensee exports any such software from the United States or
104210299Sed * re-exports any such software from a foreign destination, Licensee shall
105193323Sed * ensure that the distribution and export/re-export of the software is in
106193323Sed * compliance with all laws, regulations, orders, or other restrictions of the
107193323Sed * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108193323Sed * any of its subsidiaries will export/re-export any technical data, process,
109193323Sed * software, or service, directly or indirectly, to any country for which the
110202878Srdivacky * United States government or any agency thereof requires an export license,
111202878Srdivacky * other governmental approval, or letter of assurance, without first obtaining
112202878Srdivacky * such license, approval or letter.
113210299Sed *
114210299Sed *****************************************************************************/
115210299Sed
116210299Sed
117210299Sed#define __EXFLDIO_C__
118210299Sed
119210299Sed#include <contrib/dev/acpica/include/acpi.h>
120210299Sed#include <contrib/dev/acpica/include/accommon.h>
121210299Sed#include <contrib/dev/acpica/include/acinterp.h>
122210299Sed#include <contrib/dev/acpica/include/amlcode.h>
123210299Sed#include <contrib/dev/acpica/include/acevents.h>
124202878Srdivacky#include <contrib/dev/acpica/include/acdispat.h>
125202878Srdivacky
126210299Sed
127202878Srdivacky#define _COMPONENT          ACPI_EXECUTER
128210299Sed        ACPI_MODULE_NAME    ("exfldio")
129210299Sed
130210299Sed/* Local prototypes */
131210299Sed
132202878Srdivackystatic ACPI_STATUS
133210299SedAcpiExFieldDatumIo (
134202878Srdivacky    ACPI_OPERAND_OBJECT     *ObjDesc,
135210299Sed    UINT32                  FieldDatumByteOffset,
136210299Sed    ACPI_INTEGER            *Value,
137210299Sed    UINT32                  ReadWrite);
138210299Sed
139210299Sedstatic BOOLEAN
140210299SedAcpiExRegisterOverflow (
141210299Sed    ACPI_OPERAND_OBJECT     *ObjDesc,
142210299Sed    ACPI_INTEGER            Value);
143210299Sed
144202878Srdivackystatic ACPI_STATUS
145210299SedAcpiExSetupRegion (
146210299Sed    ACPI_OPERAND_OBJECT     *ObjDesc,
147210299Sed    UINT32                  FieldDatumByteOffset);
148210299Sed
149202878Srdivacky
150202878Srdivacky/*******************************************************************************
151202878Srdivacky *
152202878Srdivacky * FUNCTION:    AcpiExSetupRegion
153202878Srdivacky *
154202878Srdivacky * PARAMETERS:  ObjDesc                 - Field to be read or written
155202878Srdivacky *              FieldDatumByteOffset    - Byte offset of this datum within the
156210299Sed *                                        parent field
157210299Sed *
158210299Sed * RETURN:      Status
159210299Sed *
160210299Sed * DESCRIPTION: Common processing for AcpiExExtractFromField and
161210299Sed *              AcpiExInsertIntoField.  Initialize the Region if necessary and
162210299Sed *              validate the request.
163210299Sed *
164210299Sed ******************************************************************************/
165210299Sed
166202878Srdivackystatic ACPI_STATUS
167202878SrdivackyAcpiExSetupRegion (
168202878Srdivacky    ACPI_OPERAND_OBJECT     *ObjDesc,
169210299Sed    UINT32                  FieldDatumByteOffset)
170210299Sed{
171210299Sed    ACPI_STATUS             Status = AE_OK;
172210299Sed    ACPI_OPERAND_OBJECT     *RgnDesc;
173210299Sed
174210299Sed
175202878Srdivacky    ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset);
176210299Sed
177210299Sed
178210299Sed    RgnDesc = ObjDesc->CommonField.RegionObj;
179210299Sed
180210299Sed    /* We must have a valid region */
181202878Srdivacky
182210299Sed    if (RgnDesc->Common.Type != ACPI_TYPE_REGION)
183210299Sed    {
184210299Sed        ACPI_ERROR ((AE_INFO, "Needed Region, found type %X (%s)",
185210299Sed            RgnDesc->Common.Type,
186210299Sed            AcpiUtGetObjectTypeName (RgnDesc)));
187210299Sed
188210299Sed        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
189210299Sed    }
190202878Srdivacky
191210299Sed    /*
192210299Sed     * If the Region Address and Length have not been previously evaluated,
193202878Srdivacky     * evaluate them now and save the results.
194210299Sed     */
195210299Sed    if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID))
196202878Srdivacky    {
197210299Sed        Status = AcpiDsGetRegionArguments (RgnDesc);
198210299Sed        if (ACPI_FAILURE (Status))
199210299Sed        {
200210299Sed            return_ACPI_STATUS (Status);
201210299Sed        }
202210299Sed    }
203210299Sed
204210299Sed    /*
205210299Sed     * Exit now for SMBus address space, it has a non-linear address space
206210299Sed     * and the request cannot be directly validated
207210299Sed     */
208210299Sed    if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
209210299Sed    {
210210299Sed        /* SMBus has a non-linear address space */
211202878Srdivacky
212210299Sed        return_ACPI_STATUS (AE_OK);
213210299Sed    }
214202878Srdivacky
215210299Sed#ifdef ACPI_UNDER_DEVELOPMENT
216210299Sed    /*
217210299Sed     * If the Field access is AnyAcc, we can now compute the optimal
218210299Sed     * access (because we know know the length of the parent region)
219202878Srdivacky     */
220210299Sed    if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
221210299Sed    {
222210299Sed        if (ACPI_FAILURE (Status))
223210299Sed        {
224210299Sed            return_ACPI_STATUS (Status);
225210299Sed        }
226210299Sed    }
227210299Sed#endif
228210299Sed
229210299Sed    /*
230210299Sed     * Validate the request.  The entire request from the byte offset for a
231210299Sed     * length of one field datum (access width) must fit within the region.
232210299Sed     * (Region length is specified in bytes)
233210299Sed     */
234210299Sed    if (RgnDesc->Region.Length <
235210299Sed            (ObjDesc->CommonField.BaseByteOffset +
236210299Sed            FieldDatumByteOffset +
237210299Sed            ObjDesc->CommonField.AccessByteWidth))
238210299Sed    {
239210299Sed        if (AcpiGbl_EnableInterpreterSlack)
240210299Sed        {
241202878Srdivacky            /*
242202878Srdivacky             * Slack mode only:  We will go ahead and allow access to this
243210299Sed             * field if it is within the region length rounded up to the next
244210299Sed             * access width boundary. ACPI_SIZE cast for 64-bit compile.
245210299Sed             */
246210299Sed            if (ACPI_ROUND_UP (RgnDesc->Region.Length,
247210299Sed                    ObjDesc->CommonField.AccessByteWidth) >=
248202878Srdivacky                ((ACPI_SIZE) ObjDesc->CommonField.BaseByteOffset +
249202878Srdivacky                    ObjDesc->CommonField.AccessByteWidth +
250202878Srdivacky                    FieldDatumByteOffset))
251193323Sed            {
252193323Sed                return_ACPI_STATUS (AE_OK);
253193323Sed            }
254193323Sed        }
255193323Sed
256193323Sed        if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth)
257193323Sed        {
258193323Sed            /*
259193323Sed             * This is the case where the AccessType (AccWord, etc.) is wider
260193323Sed             * than the region itself.  For example, a region of length one
261193323Sed             * byte, and a field with Dword access specified.
262193323Sed             */
263193323Sed            ACPI_ERROR ((AE_INFO,
264193323Sed                "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)",
265193323Sed                AcpiUtGetNodeName (ObjDesc->CommonField.Node),
266193323Sed                ObjDesc->CommonField.AccessByteWidth,
267193323Sed                AcpiUtGetNodeName (RgnDesc->Region.Node),
268193323Sed                RgnDesc->Region.Length));
269204642Srdivacky        }
270204642Srdivacky
271204642Srdivacky        /*
272204642Srdivacky         * Offset rounded up to next multiple of field width
273204642Srdivacky         * exceeds region length, indicate an error
274204642Srdivacky         */
275204642Srdivacky        ACPI_ERROR ((AE_INFO,
276204642Srdivacky            "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)",
277204642Srdivacky            AcpiUtGetNodeName (ObjDesc->CommonField.Node),
278204642Srdivacky            ObjDesc->CommonField.BaseByteOffset,
279204642Srdivacky            FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth,
280204642Srdivacky            AcpiUtGetNodeName (RgnDesc->Region.Node),
281204642Srdivacky            RgnDesc->Region.Length));
282204642Srdivacky
283193323Sed        return_ACPI_STATUS (AE_AML_REGION_LIMIT);
284193323Sed    }
285193323Sed
286193323Sed    return_ACPI_STATUS (AE_OK);
287193323Sed}
288193323Sed
289193323Sed
290193323Sed/*******************************************************************************
291193323Sed *
292193323Sed * FUNCTION:    AcpiExAccessRegion
293193323Sed *
294193323Sed * PARAMETERS:  ObjDesc                 - Field to be read
295193323Sed *              FieldDatumByteOffset    - Byte offset of this datum within the
296193323Sed *                                        parent field
297193323Sed *              Value                   - Where to store value (must at least
298193323Sed *                                        the size of ACPI_INTEGER)
299193323Sed *              Function                - Read or Write flag plus other region-
300193323Sed *                                        dependent flags
301193323Sed *
302193323Sed * RETURN:      Status
303193323Sed *
304193323Sed * DESCRIPTION: Read or Write a single field datum to an Operation Region.
305193323Sed *
306193323Sed ******************************************************************************/
307193323Sed
308193323SedACPI_STATUS
309193323SedAcpiExAccessRegion (
310193323Sed    ACPI_OPERAND_OBJECT     *ObjDesc,
311193323Sed    UINT32                  FieldDatumByteOffset,
312193323Sed    ACPI_INTEGER            *Value,
313193323Sed    UINT32                  Function)
314193323Sed{
315193323Sed    ACPI_STATUS             Status;
316193323Sed    ACPI_OPERAND_OBJECT     *RgnDesc;
317193323Sed    UINT32                  RegionOffset;
318193323Sed
319193323Sed
320193323Sed    ACPI_FUNCTION_TRACE (ExAccessRegion);
321193323Sed
322193323Sed
323193323Sed    /*
324193323Sed     * Ensure that the region operands are fully evaluated and verify
325193323Sed     * the validity of the request
326193323Sed     */
327193323Sed    Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset);
328193323Sed    if (ACPI_FAILURE (Status))
329193323Sed    {
330193323Sed        return_ACPI_STATUS (Status);
331208599Srdivacky    }
332193323Sed
333193323Sed    /*
334193323Sed     * The physical address of this field datum is:
335193323Sed     *
336198090Srdivacky     * 1) The base of the region, plus
337198090Srdivacky     * 2) The base offset of the field, plus
338198090Srdivacky     * 3) The current offset into the field
339198090Srdivacky     */
340198090Srdivacky    RgnDesc = ObjDesc->CommonField.RegionObj;
341193323Sed    RegionOffset =
342193323Sed        ObjDesc->CommonField.BaseByteOffset +
343193323Sed        FieldDatumByteOffset;
344193323Sed
345193323Sed    if ((Function & ACPI_IO_MASK) == ACPI_READ)
346193323Sed    {
347193323Sed        ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
348193323Sed    }
349193323Sed    else
350193323Sed    {
351193323Sed        ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
352193323Sed    }
353193323Sed
354193323Sed    ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD,
355193323Sed        " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n",
356193323Sed        AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
357193323Sed        RgnDesc->Region.SpaceId,
358193323Sed        ObjDesc->CommonField.AccessByteWidth,
359193323Sed        ObjDesc->CommonField.BaseByteOffset,
360193323Sed        FieldDatumByteOffset,
361193323Sed        ACPI_CAST_PTR (void, (RgnDesc->Region.Address + RegionOffset))));
362193323Sed
363193323Sed    /* Invoke the appropriate AddressSpace/OpRegion handler */
364198090Srdivacky
365193323Sed    Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function, RegionOffset,
366193323Sed                ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value);
367193323Sed
368193323Sed    if (ACPI_FAILURE (Status))
369193323Sed    {
370193323Sed        if (Status == AE_NOT_IMPLEMENTED)
371193323Sed        {
372193323Sed            ACPI_ERROR ((AE_INFO,
373193323Sed                "Region %s(%X) not implemented",
374193323Sed                AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
375193323Sed                RgnDesc->Region.SpaceId));
376193323Sed        }
377193323Sed        else if (Status == AE_NOT_EXIST)
378198090Srdivacky        {
379193323Sed            ACPI_ERROR ((AE_INFO,
380193323Sed                "Region %s(%X) has no handler",
381193323Sed                AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
382193323Sed                RgnDesc->Region.SpaceId));
383193323Sed        }
384193323Sed    }
385193323Sed
386193323Sed    return_ACPI_STATUS (Status);
387193323Sed}
388193323Sed
389193323Sed
390193323Sed/*******************************************************************************
391193323Sed *
392193323Sed * FUNCTION:    AcpiExRegisterOverflow
393193323Sed *
394193323Sed * PARAMETERS:  ObjDesc                 - Register(Field) to be written
395198090Srdivacky *              Value                   - Value to be stored
396210299Sed *
397210299Sed * RETURN:      TRUE if value overflows the field, FALSE otherwise
398210299Sed *
399210299Sed * DESCRIPTION: Check if a value is out of range of the field being written.
400198090Srdivacky *              Used to check if the values written to Index and Bank registers
401208599Srdivacky *              are out of range.  Normally, the value is simply truncated
402207618Srdivacky *              to fit the field, but this case is most likely a serious
403198090Srdivacky *              coding error in the ASL.
404198090Srdivacky *
405198090Srdivacky ******************************************************************************/
406193323Sed
407193323Sedstatic BOOLEAN
408193323SedAcpiExRegisterOverflow (
409193323Sed    ACPI_OPERAND_OBJECT     *ObjDesc,
410193323Sed    ACPI_INTEGER            Value)
411193323Sed{
412193323Sed
413193323Sed    if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE)
414193323Sed    {
415198090Srdivacky        /*
416210299Sed         * The field is large enough to hold the maximum integer, so we can
417210299Sed         * never overflow it.
418193323Sed         */
419193323Sed        return (FALSE);
420193323Sed    }
421193323Sed
422193323Sed    if (Value >= ((ACPI_INTEGER) 1 << ObjDesc->CommonField.BitLength))
423193323Sed    {
424193323Sed        /*
425208599Srdivacky         * The Value is larger than the maximum value that can fit into
426208599Srdivacky         * the register.
427208599Srdivacky         */
428208599Srdivacky        return (TRUE);
429208599Srdivacky    }
430208599Srdivacky
431193323Sed    /* The Value will fit into the field with no truncation */
432208599Srdivacky
433208599Srdivacky    return (FALSE);
434208599Srdivacky}
435208599Srdivacky
436193323Sed
437193323Sed/*******************************************************************************
438193323Sed *
439193323Sed * FUNCTION:    AcpiExFieldDatumIo
440193323Sed *
441193323Sed * PARAMETERS:  ObjDesc                 - Field to be read
442198090Srdivacky *              FieldDatumByteOffset    - Byte offset of this datum within the
443198090Srdivacky *                                        parent field
444193323Sed *              Value                   - Where to store value (must be 64 bits)
445193323Sed *              ReadWrite               - Read or Write flag
446193323Sed *
447208599Srdivacky * RETURN:      Status
448208599Srdivacky *
449208599Srdivacky * DESCRIPTION: Read or Write a single datum of a field.  The FieldType is
450208599Srdivacky *              demultiplexed here to handle the different types of fields
451208599Srdivacky *              (BufferField, RegionField, IndexField, BankField)
452208599Srdivacky *
453208599Srdivacky ******************************************************************************/
454208599Srdivacky
455208599Srdivackystatic ACPI_STATUS
456208599SrdivackyAcpiExFieldDatumIo (
457208599Srdivacky    ACPI_OPERAND_OBJECT     *ObjDesc,
458208599Srdivacky    UINT32                  FieldDatumByteOffset,
459208599Srdivacky    ACPI_INTEGER            *Value,
460208599Srdivacky    UINT32                  ReadWrite)
461210299Sed{
462208599Srdivacky    ACPI_STATUS             Status;
463208599Srdivacky    ACPI_INTEGER            LocalValue;
464208599Srdivacky
465208599Srdivacky
466208599Srdivacky    ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset);
467208599Srdivacky
468210299Sed
469210299Sed    if (ReadWrite == ACPI_READ)
470210299Sed    {
471210299Sed        if (!Value)
472210299Sed        {
473208599Srdivacky            LocalValue = 0;
474208599Srdivacky
475208599Srdivacky            /* To support reads without saving return value */
476208599Srdivacky            Value = &LocalValue;
477208599Srdivacky        }
478208599Srdivacky
479208599Srdivacky        /* Clear the entire return buffer first, [Very Important!] */
480208599Srdivacky
481193323Sed        *Value = 0;
482193323Sed    }
483202375Srdivacky
484193323Sed    /*
485193323Sed     * The four types of fields are:
486193323Sed     *
487193323Sed     * BufferField - Read/write from/to a Buffer
488202375Srdivacky     * RegionField - Read/write from/to a Operation Region.
489193323Sed     * BankField   - Write to a Bank Register, then read/write from/to an
490193323Sed     *               OperationRegion
491193323Sed     * IndexField  - Write to an Index Register, then read/write from/to a
492193323Sed     *               Data Register
493202375Srdivacky     */
494193323Sed    switch (ObjDesc->Common.Type)
495202375Srdivacky    {
496193323Sed    case ACPI_TYPE_BUFFER_FIELD:
497193323Sed        /*
498193323Sed         * If the BufferField arguments have not been previously evaluated,
499198090Srdivacky         * evaluate them now and save the results.
500206083Srdivacky         */
501206083Srdivacky        if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
502206083Srdivacky        {
503206083Srdivacky            Status = AcpiDsGetBufferFieldArguments (ObjDesc);
504206083Srdivacky            if (ACPI_FAILURE (Status))
505206083Srdivacky            {
506206083Srdivacky                return_ACPI_STATUS (Status);
507206083Srdivacky            }
508206083Srdivacky        }
509206083Srdivacky
510210299Sed        if (ReadWrite == ACPI_READ)
511206083Srdivacky        {
512206083Srdivacky            /*
513206083Srdivacky             * Copy the data from the source buffer.
514206083Srdivacky             * Length is the field width in bytes.
515206083Srdivacky             */
516206083Srdivacky            ACPI_MEMCPY (Value,
517206083Srdivacky                (ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
518206083Srdivacky                    ObjDesc->BufferField.BaseByteOffset +
519206083Srdivacky                    FieldDatumByteOffset,
520206083Srdivacky                ObjDesc->CommonField.AccessByteWidth);
521206083Srdivacky        }
522210299Sed        else
523206083Srdivacky        {
524206083Srdivacky            /*
525206083Srdivacky             * Copy the data to the target buffer.
526206083Srdivacky             * Length is the field width in bytes.
527206083Srdivacky             */
528210299Sed            ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
529206083Srdivacky                ObjDesc->BufferField.BaseByteOffset +
530206083Srdivacky                FieldDatumByteOffset,
531206083Srdivacky                Value, ObjDesc->CommonField.AccessByteWidth);
532206083Srdivacky        }
533206083Srdivacky
534206083Srdivacky        Status = AE_OK;
535206083Srdivacky        break;
536206083Srdivacky
537206083Srdivacky
538206083Srdivacky    case ACPI_TYPE_LOCAL_BANK_FIELD:
539206083Srdivacky
540207618Srdivacky        /*
541207618Srdivacky         * Ensure that the BankValue is not beyond the capacity of
542207618Srdivacky         * the register
543207618Srdivacky         */
544207618Srdivacky        if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj,
545206083Srdivacky                (ACPI_INTEGER) ObjDesc->BankField.Value))
546206083Srdivacky        {
547206083Srdivacky            return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
548206083Srdivacky        }
549206083Srdivacky
550206083Srdivacky        /*
551198090Srdivacky         * For BankFields, we must write the BankValue to the BankRegister
552207618Srdivacky         * (itself a RegionField) before we can access the data.
553198090Srdivacky         */
554198090Srdivacky        Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj,
555198090Srdivacky                    &ObjDesc->BankField.Value,
556206083Srdivacky                    sizeof (ObjDesc->BankField.Value));
557206083Srdivacky        if (ACPI_FAILURE (Status))
558206083Srdivacky        {
559205218Srdivacky            return_ACPI_STATUS (Status);
560207618Srdivacky        }
561207618Srdivacky
562207618Srdivacky        /*
563207618Srdivacky         * Now that the Bank has been selected, fall through to the
564207618Srdivacky         * RegionField case and write the datum to the Operation Region
565207618Srdivacky         */
566207618Srdivacky
567210299Sed        /*lint -fallthrough */
568207618Srdivacky
569207618Srdivacky
570207618Srdivacky    case ACPI_TYPE_LOCAL_REGION_FIELD:
571198090Srdivacky        /*
572198090Srdivacky         * For simple RegionFields, we just directly access the owning
573198090Srdivacky         * Operation Region.
574198090Srdivacky         */
575198090Srdivacky        Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value,
576198090Srdivacky                    ReadWrite);
577198090Srdivacky        break;
578198090Srdivacky
579198090Srdivacky
580198090Srdivacky    case ACPI_TYPE_LOCAL_INDEX_FIELD:
581198090Srdivacky
582198090Srdivacky
583198090Srdivacky        /*
584198090Srdivacky         * Ensure that the IndexValue is not beyond the capacity of
585198090Srdivacky         * the register
586198090Srdivacky         */
587198090Srdivacky        if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj,
588198090Srdivacky                (ACPI_INTEGER) ObjDesc->IndexField.Value))
589198090Srdivacky        {
590198090Srdivacky            return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
591198090Srdivacky        }
592206083Srdivacky
593198090Srdivacky        /* Write the index value to the IndexRegister (itself a RegionField) */
594207618Srdivacky
595207618Srdivacky        FieldDatumByteOffset += ObjDesc->IndexField.Value;
596206083Srdivacky
597207618Srdivacky        ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
598198090Srdivacky            "Write to Index Register: Value %8.8X\n",
599198090Srdivacky            FieldDatumByteOffset));
600198090Srdivacky
601207618Srdivacky        Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj,
602207618Srdivacky                    &FieldDatumByteOffset,
603206083Srdivacky                    sizeof (FieldDatumByteOffset));
604207618Srdivacky        if (ACPI_FAILURE (Status))
605206083Srdivacky        {
606206083Srdivacky            return_ACPI_STATUS (Status);
607206083Srdivacky        }
608207618Srdivacky
609206083Srdivacky        if (ReadWrite == ACPI_READ)
610206083Srdivacky        {
611210299Sed            /* Read the datum from the DataRegister */
612206083Srdivacky
613206083Srdivacky            ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
614206083Srdivacky                "Read from Data Register\n"));
615206083Srdivacky
616206083Srdivacky            Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj,
617206083Srdivacky                        Value, sizeof (ACPI_INTEGER));
618206083Srdivacky        }
619206083Srdivacky        else
620206083Srdivacky        {
621206083Srdivacky            /* Write the datum to the DataRegister */
622206083Srdivacky
623206083Srdivacky            ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
624206083Srdivacky                "Write to Data Register: Value %8.8X%8.8X\n",
625206083Srdivacky                ACPI_FORMAT_UINT64 (*Value)));
626206083Srdivacky
627206083Srdivacky            Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj,
628206083Srdivacky                        Value, sizeof (ACPI_INTEGER));
629206083Srdivacky        }
630206083Srdivacky        break;
631206083Srdivacky
632206083Srdivacky
633206083Srdivacky    default:
634206083Srdivacky
635206083Srdivacky        ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %X",
636206083Srdivacky            ObjDesc->Common.Type));
637206083Srdivacky        Status = AE_AML_INTERNAL;
638206083Srdivacky        break;
639207618Srdivacky    }
640207618Srdivacky
641207618Srdivacky    if (ACPI_SUCCESS (Status))
642207618Srdivacky    {
643207618Srdivacky        if (ReadWrite == ACPI_READ)
644207618Srdivacky        {
645210299Sed            ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
646210299Sed                "Value Read %8.8X%8.8X, Width %d\n",
647207618Srdivacky                ACPI_FORMAT_UINT64 (*Value),
648210299Sed                ObjDesc->CommonField.AccessByteWidth));
649207618Srdivacky        }
650206083Srdivacky        else
651205218Srdivacky        {
652206083Srdivacky            ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
653206083Srdivacky                "Value Written %8.8X%8.8X, Width %d\n",
654206083Srdivacky                ACPI_FORMAT_UINT64 (*Value),
655206083Srdivacky                ObjDesc->CommonField.AccessByteWidth));
656206083Srdivacky        }
657206083Srdivacky    }
658206083Srdivacky
659206083Srdivacky    return_ACPI_STATUS (Status);
660207618Srdivacky}
661207618Srdivacky
662207618Srdivacky
663206083Srdivacky/*******************************************************************************
664206083Srdivacky *
665206083Srdivacky * FUNCTION:    AcpiExWriteWithUpdateRule
666198090Srdivacky *
667198090Srdivacky * PARAMETERS:  ObjDesc                 - Field to be written
668198090Srdivacky *              Mask                    - bitmask within field datum
669198090Srdivacky *              FieldValue              - Value to write
670198090Srdivacky *              FieldDatumByteOffset    - Offset of datum within field
671198090Srdivacky *
672 * RETURN:      Status
673 *
674 * DESCRIPTION: Apply the field update rule to a field write
675 *
676 ******************************************************************************/
677
678ACPI_STATUS
679AcpiExWriteWithUpdateRule (
680    ACPI_OPERAND_OBJECT     *ObjDesc,
681    ACPI_INTEGER            Mask,
682    ACPI_INTEGER            FieldValue,
683    UINT32                  FieldDatumByteOffset)
684{
685    ACPI_STATUS             Status = AE_OK;
686    ACPI_INTEGER            MergedValue;
687    ACPI_INTEGER            CurrentValue;
688
689
690    ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask);
691
692
693    /* Start with the new bits  */
694
695    MergedValue = FieldValue;
696
697    /* If the mask is all ones, we don't need to worry about the update rule */
698
699    if (Mask != ACPI_INTEGER_MAX)
700    {
701        /* Decode the update rule */
702
703        switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)
704        {
705        case AML_FIELD_UPDATE_PRESERVE:
706            /*
707             * Check if update rule needs to be applied (not if mask is all
708             * ones)  The left shift drops the bits we want to ignore.
709             */
710            if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) -
711                           ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0)
712            {
713                /*
714                 * Read the current contents of the byte/word/dword containing
715                 * the field, and merge with the new field value.
716                 */
717                Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
718                            &CurrentValue, ACPI_READ);
719                if (ACPI_FAILURE (Status))
720                {
721                    return_ACPI_STATUS (Status);
722                }
723
724                MergedValue |= (CurrentValue & ~Mask);
725            }
726            break;
727
728        case AML_FIELD_UPDATE_WRITE_AS_ONES:
729
730            /* Set positions outside the field to all ones */
731
732            MergedValue |= ~Mask;
733            break;
734
735        case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
736
737            /* Set positions outside the field to all zeros */
738
739            MergedValue &= Mask;
740            break;
741
742        default:
743
744            ACPI_ERROR ((AE_INFO,
745                "Unknown UpdateRule value: %X",
746                (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)));
747            return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
748        }
749    }
750
751    ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
752        "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n",
753        ACPI_FORMAT_UINT64 (Mask),
754        FieldDatumByteOffset,
755        ObjDesc->CommonField.AccessByteWidth,
756        ACPI_FORMAT_UINT64 (FieldValue),
757        ACPI_FORMAT_UINT64 (MergedValue)));
758
759    /* Write the merged value */
760
761    Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
762                &MergedValue, ACPI_WRITE);
763
764    return_ACPI_STATUS (Status);
765}
766
767
768/*******************************************************************************
769 *
770 * FUNCTION:    AcpiExExtractFromField
771 *
772 * PARAMETERS:  ObjDesc             - Field to be read
773 *              Buffer              - Where to store the field data
774 *              BufferLength        - Length of Buffer
775 *
776 * RETURN:      Status
777 *
778 * DESCRIPTION: Retrieve the current value of the given field
779 *
780 ******************************************************************************/
781
782ACPI_STATUS
783AcpiExExtractFromField (
784    ACPI_OPERAND_OBJECT     *ObjDesc,
785    void                    *Buffer,
786    UINT32                  BufferLength)
787{
788    ACPI_STATUS             Status;
789    ACPI_INTEGER            RawDatum;
790    ACPI_INTEGER            MergedDatum;
791    UINT32                  FieldOffset = 0;
792    UINT32                  BufferOffset = 0;
793    UINT32                  BufferTailBits;
794    UINT32                  DatumCount;
795    UINT32                  FieldDatumCount;
796    UINT32                  i;
797
798
799    ACPI_FUNCTION_TRACE (ExExtractFromField);
800
801
802    /* Validate target buffer and clear it */
803
804    if (BufferLength <
805            ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength))
806    {
807        ACPI_ERROR ((AE_INFO,
808            "Field size %X (bits) is too large for buffer (%X)",
809            ObjDesc->CommonField.BitLength, BufferLength));
810
811        return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
812    }
813    ACPI_MEMSET (Buffer, 0, BufferLength);
814
815    /* Compute the number of datums (access width data items) */
816
817    DatumCount = ACPI_ROUND_UP_TO (
818                        ObjDesc->CommonField.BitLength,
819                        ObjDesc->CommonField.AccessBitWidth);
820    FieldDatumCount = ACPI_ROUND_UP_TO (
821                        ObjDesc->CommonField.BitLength +
822                        ObjDesc->CommonField.StartFieldBitOffset,
823                        ObjDesc->CommonField.AccessBitWidth);
824
825    /* Priming read from the field */
826
827    Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ);
828    if (ACPI_FAILURE (Status))
829    {
830        return_ACPI_STATUS (Status);
831    }
832    MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
833
834    /* Read the rest of the field */
835
836    for (i = 1; i < FieldDatumCount; i++)
837    {
838        /* Get next input datum from the field */
839
840        FieldOffset += ObjDesc->CommonField.AccessByteWidth;
841        Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset,
842                    &RawDatum, ACPI_READ);
843        if (ACPI_FAILURE (Status))
844        {
845            return_ACPI_STATUS (Status);
846        }
847
848        /*
849         * Merge with previous datum if necessary.
850         *
851         * Note: Before the shift, check if the shift value will be larger than
852         * the integer size. If so, there is no need to perform the operation.
853         * This avoids the differences in behavior between different compilers
854         * concerning shift values larger than the target data width.
855         */
856        if ((ObjDesc->CommonField.AccessBitWidth -
857            ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE)
858        {
859            MergedDatum |= RawDatum <<
860                (ObjDesc->CommonField.AccessBitWidth -
861                    ObjDesc->CommonField.StartFieldBitOffset);
862        }
863
864        if (i == DatumCount)
865        {
866            break;
867        }
868
869        /* Write merged datum to target buffer */
870
871        ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
872            ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
873                BufferLength - BufferOffset));
874
875        BufferOffset += ObjDesc->CommonField.AccessByteWidth;
876        MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
877    }
878
879    /* Mask off any extra bits in the last datum */
880
881    BufferTailBits = ObjDesc->CommonField.BitLength %
882                        ObjDesc->CommonField.AccessBitWidth;
883    if (BufferTailBits)
884    {
885        MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
886    }
887
888    /* Write the last datum to the buffer */
889
890    ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
891        ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
892            BufferLength - BufferOffset));
893
894    return_ACPI_STATUS (AE_OK);
895}
896
897
898/*******************************************************************************
899 *
900 * FUNCTION:    AcpiExInsertIntoField
901 *
902 * PARAMETERS:  ObjDesc             - Field to be written
903 *              Buffer              - Data to be written
904 *              BufferLength        - Length of Buffer
905 *
906 * RETURN:      Status
907 *
908 * DESCRIPTION: Store the Buffer contents into the given field
909 *
910 ******************************************************************************/
911
912ACPI_STATUS
913AcpiExInsertIntoField (
914    ACPI_OPERAND_OBJECT     *ObjDesc,
915    void                    *Buffer,
916    UINT32                  BufferLength)
917{
918    ACPI_STATUS             Status;
919    ACPI_INTEGER            Mask;
920    ACPI_INTEGER            WidthMask;
921    ACPI_INTEGER            MergedDatum;
922    ACPI_INTEGER            RawDatum = 0;
923    UINT32                  FieldOffset = 0;
924    UINT32                  BufferOffset = 0;
925    UINT32                  BufferTailBits;
926    UINT32                  DatumCount;
927    UINT32                  FieldDatumCount;
928    UINT32                  i;
929    UINT32                  RequiredLength;
930    void                    *NewBuffer;
931
932
933    ACPI_FUNCTION_TRACE (ExInsertIntoField);
934
935
936    /* Validate input buffer */
937
938    NewBuffer = NULL;
939    RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (
940                        ObjDesc->CommonField.BitLength);
941    /*
942     * We must have a buffer that is at least as long as the field
943     * we are writing to.  This is because individual fields are
944     * indivisible and partial writes are not supported -- as per
945     * the ACPI specification.
946     */
947    if (BufferLength < RequiredLength)
948    {
949        /* We need to create a new buffer */
950
951        NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength);
952        if (!NewBuffer)
953        {
954            return_ACPI_STATUS (AE_NO_MEMORY);
955        }
956
957        /*
958         * Copy the original data to the new buffer, starting
959         * at Byte zero.  All unused (upper) bytes of the
960         * buffer will be 0.
961         */
962        ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength);
963        Buffer = NewBuffer;
964        BufferLength = RequiredLength;
965    }
966
967    /*
968     * Create the bitmasks used for bit insertion.
969     * Note: This if/else is used to bypass compiler differences with the
970     * shift operator
971     */
972    if (ObjDesc->CommonField.AccessBitWidth == ACPI_INTEGER_BIT_SIZE)
973    {
974        WidthMask = ACPI_INTEGER_MAX;
975    }
976    else
977    {
978        WidthMask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.AccessBitWidth);
979    }
980
981    Mask = WidthMask &
982            ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
983
984    /* Compute the number of datums (access width data items) */
985
986    DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength,
987                    ObjDesc->CommonField.AccessBitWidth);
988
989    FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength +
990                        ObjDesc->CommonField.StartFieldBitOffset,
991                        ObjDesc->CommonField.AccessBitWidth);
992
993    /* Get initial Datum from the input buffer */
994
995    ACPI_MEMCPY (&RawDatum, Buffer,
996        ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
997            BufferLength - BufferOffset));
998
999    MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
1000
1001    /* Write the entire field */
1002
1003    for (i = 1; i < FieldDatumCount; i++)
1004    {
1005        /* Write merged datum to the target field */
1006
1007        MergedDatum &= Mask;
1008        Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask,
1009                    MergedDatum, FieldOffset);
1010        if (ACPI_FAILURE (Status))
1011        {
1012            goto Exit;
1013        }
1014
1015        FieldOffset += ObjDesc->CommonField.AccessByteWidth;
1016
1017        /*
1018         * Start new output datum by merging with previous input datum
1019         * if necessary.
1020         *
1021         * Note: Before the shift, check if the shift value will be larger than
1022         * the integer size. If so, there is no need to perform the operation.
1023         * This avoids the differences in behavior between different compilers
1024         * concerning shift values larger than the target data width.
1025         */
1026        if ((ObjDesc->CommonField.AccessBitWidth -
1027            ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE)
1028        {
1029            MergedDatum = RawDatum >>
1030                (ObjDesc->CommonField.AccessBitWidth -
1031                    ObjDesc->CommonField.StartFieldBitOffset);
1032        }
1033        else
1034        {
1035            MergedDatum = 0;
1036        }
1037
1038        Mask = WidthMask;
1039
1040        if (i == DatumCount)
1041        {
1042            break;
1043        }
1044
1045        /* Get the next input datum from the buffer */
1046
1047        BufferOffset += ObjDesc->CommonField.AccessByteWidth;
1048        ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset,
1049            ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
1050                     BufferLength - BufferOffset));
1051        MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
1052    }
1053
1054    /* Mask off any extra bits in the last datum */
1055
1056    BufferTailBits = (ObjDesc->CommonField.BitLength +
1057            ObjDesc->CommonField.StartFieldBitOffset) %
1058                ObjDesc->CommonField.AccessBitWidth;
1059    if (BufferTailBits)
1060    {
1061        Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
1062    }
1063
1064    /* Write the last datum to the field */
1065
1066    MergedDatum &= Mask;
1067    Status = AcpiExWriteWithUpdateRule (ObjDesc,
1068                Mask, MergedDatum, FieldOffset);
1069
1070Exit:
1071    /* Free temporary buffer if we used one */
1072
1073    if (NewBuffer)
1074    {
1075        ACPI_FREE (NewBuffer);
1076    }
1077    return_ACPI_STATUS (Status);
1078}
1079
1080
1081