dbd294b926e69a1c274c2c8a40a17b49e41da83b
[reactos.git] / reactos / drivers / bus / acpi / acpica / executer / exfield.c
1 /******************************************************************************
2 *
3 * Module Name: exfield - ACPI AML (p-code) execution - field manipulation
4 *
5 *****************************************************************************/
6
7 /******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2015, 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 #include "acpi.h"
117 #include "accommon.h"
118 #include "acdispat.h"
119 #include "acinterp.h"
120 #include "amlcode.h"
121
122
123 #define _COMPONENT ACPI_EXECUTER
124 ACPI_MODULE_NAME ("exfield")
125
126 /* Local prototypes */
127
128 static UINT32
129 AcpiExGetSerialAccessLength (
130 UINT32 AccessorType,
131 UINT32 AccessLength);
132
133
134 /*******************************************************************************
135 *
136 * FUNCTION: AcpiExGetSerialAccessLength
137 *
138 * PARAMETERS: AccessorType - The type of the protocol indicated by region
139 * field access attributes
140 * AccessLength - The access length of the region field
141 *
142 * RETURN: Decoded access length
143 *
144 * DESCRIPTION: This routine returns the length of the GenericSerialBus
145 * protocol bytes
146 *
147 ******************************************************************************/
148
149 static UINT32
150 AcpiExGetSerialAccessLength (
151 UINT32 AccessorType,
152 UINT32 AccessLength)
153 {
154 UINT32 Length;
155
156
157 switch (AccessorType)
158 {
159 case AML_FIELD_ATTRIB_QUICK:
160
161 Length = 0;
162 break;
163
164 case AML_FIELD_ATTRIB_SEND_RCV:
165 case AML_FIELD_ATTRIB_BYTE:
166
167 Length = 1;
168 break;
169
170 case AML_FIELD_ATTRIB_WORD:
171 case AML_FIELD_ATTRIB_WORD_CALL:
172
173 Length = 2;
174 break;
175
176 case AML_FIELD_ATTRIB_MULTIBYTE:
177 case AML_FIELD_ATTRIB_RAW_BYTES:
178 case AML_FIELD_ATTRIB_RAW_PROCESS:
179
180 Length = AccessLength;
181 break;
182
183 case AML_FIELD_ATTRIB_BLOCK:
184 case AML_FIELD_ATTRIB_BLOCK_CALL:
185 default:
186
187 Length = ACPI_GSBUS_BUFFER_SIZE - 2;
188 break;
189 }
190
191 return (Length);
192 }
193
194
195 /*******************************************************************************
196 *
197 * FUNCTION: AcpiExReadDataFromField
198 *
199 * PARAMETERS: WalkState - Current execution state
200 * ObjDesc - The named field
201 * RetBufferDesc - Where the return data object is stored
202 *
203 * RETURN: Status
204 *
205 * DESCRIPTION: Read from a named field. Returns either an Integer or a
206 * Buffer, depending on the size of the field.
207 *
208 ******************************************************************************/
209
210 ACPI_STATUS
211 AcpiExReadDataFromField (
212 ACPI_WALK_STATE *WalkState,
213 ACPI_OPERAND_OBJECT *ObjDesc,
214 ACPI_OPERAND_OBJECT **RetBufferDesc)
215 {
216 ACPI_STATUS Status;
217 ACPI_OPERAND_OBJECT *BufferDesc;
218 ACPI_SIZE Length;
219 void *Buffer;
220 UINT32 Function;
221 UINT16 AccessorType;
222
223
224 ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc);
225
226
227 /* Parameter validation */
228
229 if (!ObjDesc)
230 {
231 return_ACPI_STATUS (AE_AML_NO_OPERAND);
232 }
233 if (!RetBufferDesc)
234 {
235 return_ACPI_STATUS (AE_BAD_PARAMETER);
236 }
237
238 if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
239 {
240 /*
241 * If the BufferField arguments have not been previously evaluated,
242 * evaluate them now and save the results.
243 */
244 if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
245 {
246 Status = AcpiDsGetBufferFieldArguments (ObjDesc);
247 if (ACPI_FAILURE (Status))
248 {
249 return_ACPI_STATUS (Status);
250 }
251 }
252 }
253 else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
254 (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
255 ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
256 ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
257 {
258 /*
259 * This is an SMBus, GSBus or IPMI read. We must create a buffer to hold
260 * the data and then directly access the region handler.
261 *
262 * Note: SMBus and GSBus protocol value is passed in upper 16-bits of Function
263 */
264 if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
265 {
266 Length = ACPI_SMBUS_BUFFER_SIZE;
267 Function = ACPI_READ | (ObjDesc->Field.Attribute << 16);
268 }
269 else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
270 {
271 AccessorType = ObjDesc->Field.Attribute;
272 Length = AcpiExGetSerialAccessLength (AccessorType,
273 ObjDesc->Field.AccessLength);
274
275 /*
276 * Add additional 2 bytes for the GenericSerialBus data buffer:
277 *
278 * Status; (Byte 0 of the data buffer)
279 * Length; (Byte 1 of the data buffer)
280 * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer)
281 */
282 Length += 2;
283 Function = ACPI_READ | (AccessorType << 16);
284 }
285 else /* IPMI */
286 {
287 Length = ACPI_IPMI_BUFFER_SIZE;
288 Function = ACPI_READ;
289 }
290
291 BufferDesc = AcpiUtCreateBufferObject (Length);
292 if (!BufferDesc)
293 {
294 return_ACPI_STATUS (AE_NO_MEMORY);
295 }
296
297 /* Lock entire transaction if requested */
298
299 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
300
301 /* Call the region handler for the read */
302
303 Status = AcpiExAccessRegion (ObjDesc, 0,
304 ACPI_CAST_PTR (UINT64, BufferDesc->Buffer.Pointer),
305 Function);
306 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
307 goto Exit;
308 }
309
310 /*
311 * Allocate a buffer for the contents of the field.
312 *
313 * If the field is larger than the current integer width, create
314 * a BUFFER to hold it. Otherwise, use an INTEGER. This allows
315 * the use of arithmetic operators on the returned value if the
316 * field size is equal or smaller than an Integer.
317 *
318 * Note: Field.length is in bits.
319 */
320 Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength);
321 if (Length > AcpiGbl_IntegerByteWidth)
322 {
323 /* Field is too large for an Integer, create a Buffer instead */
324
325 BufferDesc = AcpiUtCreateBufferObject (Length);
326 if (!BufferDesc)
327 {
328 return_ACPI_STATUS (AE_NO_MEMORY);
329 }
330 Buffer = BufferDesc->Buffer.Pointer;
331 }
332 else
333 {
334 /* Field will fit within an Integer (normal case) */
335
336 BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
337 if (!BufferDesc)
338 {
339 return_ACPI_STATUS (AE_NO_MEMORY);
340 }
341
342 Length = AcpiGbl_IntegerByteWidth;
343 Buffer = &BufferDesc->Integer.Value;
344 }
345
346 if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
347 (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO))
348 {
349 /*
350 * For GPIO (GeneralPurposeIo), the Address will be the bit offset
351 * from the previous Connection() operator, making it effectively a
352 * pin number index. The BitLength is the length of the field, which
353 * is thus the number of pins.
354 */
355 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
356 "GPIO FieldRead [FROM]: Pin %u Bits %u\n",
357 ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength));
358
359 /* Lock entire transaction if requested */
360
361 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
362
363 /* Perform the write */
364
365 Status = AcpiExAccessRegion (ObjDesc, 0,
366 (UINT64 *) Buffer, ACPI_READ);
367 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
368 if (ACPI_FAILURE (Status))
369 {
370 AcpiUtRemoveReference (BufferDesc);
371 }
372 else
373 {
374 *RetBufferDesc = BufferDesc;
375 }
376 return_ACPI_STATUS (Status);
377 }
378
379 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
380 "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n",
381 ObjDesc, ObjDesc->Common.Type, Buffer, (UINT32) Length));
382 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
383 "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n",
384 ObjDesc->CommonField.BitLength,
385 ObjDesc->CommonField.StartFieldBitOffset,
386 ObjDesc->CommonField.BaseByteOffset));
387
388 /* Lock entire transaction if requested */
389
390 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
391
392 /* Read from the field */
393
394 Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length);
395 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
396
397
398 Exit:
399 if (ACPI_FAILURE (Status))
400 {
401 AcpiUtRemoveReference (BufferDesc);
402 }
403 else
404 {
405 *RetBufferDesc = BufferDesc;
406 }
407
408 return_ACPI_STATUS (Status);
409 }
410
411
412 /*******************************************************************************
413 *
414 * FUNCTION: AcpiExWriteDataToField
415 *
416 * PARAMETERS: SourceDesc - Contains data to write
417 * ObjDesc - The named field
418 * ResultDesc - Where the return value is returned, if any
419 *
420 * RETURN: Status
421 *
422 * DESCRIPTION: Write to a named field
423 *
424 ******************************************************************************/
425
426 ACPI_STATUS
427 AcpiExWriteDataToField (
428 ACPI_OPERAND_OBJECT *SourceDesc,
429 ACPI_OPERAND_OBJECT *ObjDesc,
430 ACPI_OPERAND_OBJECT **ResultDesc)
431 {
432 ACPI_STATUS Status;
433 UINT32 Length;
434 void *Buffer;
435 ACPI_OPERAND_OBJECT *BufferDesc;
436 UINT32 Function;
437 UINT16 AccessorType;
438
439
440 ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc);
441
442
443 /* Parameter validation */
444
445 if (!SourceDesc || !ObjDesc)
446 {
447 return_ACPI_STATUS (AE_AML_NO_OPERAND);
448 }
449
450 if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD)
451 {
452 /*
453 * If the BufferField arguments have not been previously evaluated,
454 * evaluate them now and save the results.
455 */
456 if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
457 {
458 Status = AcpiDsGetBufferFieldArguments (ObjDesc);
459 if (ACPI_FAILURE (Status))
460 {
461 return_ACPI_STATUS (Status);
462 }
463 }
464 }
465 else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
466 (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS ||
467 ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS ||
468 ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI))
469 {
470 /*
471 * This is an SMBus, GSBus or IPMI write. We will bypass the entire field
472 * mechanism and handoff the buffer directly to the handler. For
473 * these address spaces, the buffer is bi-directional; on a write,
474 * return data is returned in the same buffer.
475 *
476 * Source must be a buffer of sufficient size:
477 * ACPI_SMBUS_BUFFER_SIZE, ACPI_GSBUS_BUFFER_SIZE, or ACPI_IPMI_BUFFER_SIZE.
478 *
479 * Note: SMBus and GSBus protocol type is passed in upper 16-bits of Function
480 */
481 if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
482 {
483 ACPI_ERROR ((AE_INFO,
484 "SMBus/IPMI/GenericSerialBus write requires Buffer, found type %s",
485 AcpiUtGetObjectTypeName (SourceDesc)));
486
487 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
488 }
489
490 if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
491 {
492 Length = ACPI_SMBUS_BUFFER_SIZE;
493 Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16);
494 }
495 else if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS)
496 {
497 AccessorType = ObjDesc->Field.Attribute;
498 Length = AcpiExGetSerialAccessLength (AccessorType,
499 ObjDesc->Field.AccessLength);
500
501 /*
502 * Add additional 2 bytes for the GenericSerialBus data buffer:
503 *
504 * Status; (Byte 0 of the data buffer)
505 * Length; (Byte 1 of the data buffer)
506 * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer)
507 */
508 Length += 2;
509 Function = ACPI_WRITE | (AccessorType << 16);
510 }
511 else /* IPMI */
512 {
513 Length = ACPI_IPMI_BUFFER_SIZE;
514 Function = ACPI_WRITE;
515 }
516
517 if (SourceDesc->Buffer.Length < Length)
518 {
519 ACPI_ERROR ((AE_INFO,
520 "SMBus/IPMI/GenericSerialBus write requires Buffer of length %u, found length %u",
521 Length, SourceDesc->Buffer.Length));
522
523 return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
524 }
525
526 /* Create the bi-directional buffer */
527
528 BufferDesc = AcpiUtCreateBufferObject (Length);
529 if (!BufferDesc)
530 {
531 return_ACPI_STATUS (AE_NO_MEMORY);
532 }
533
534 Buffer = BufferDesc->Buffer.Pointer;
535 memcpy (Buffer, SourceDesc->Buffer.Pointer, Length);
536
537 /* Lock entire transaction if requested */
538
539 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
540
541 /*
542 * Perform the write (returns status and perhaps data in the
543 * same buffer)
544 */
545 Status = AcpiExAccessRegion (ObjDesc, 0,
546 (UINT64 *) Buffer, Function);
547 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
548
549 *ResultDesc = BufferDesc;
550 return_ACPI_STATUS (Status);
551 }
552 else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
553 (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO))
554 {
555 /*
556 * For GPIO (GeneralPurposeIo), we will bypass the entire field
557 * mechanism and handoff the bit address and bit width directly to
558 * the handler. The Address will be the bit offset
559 * from the previous Connection() operator, making it effectively a
560 * pin number index. The BitLength is the length of the field, which
561 * is thus the number of pins.
562 */
563 if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
564 {
565 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
566 }
567
568 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
569 "GPIO FieldWrite [FROM]: (%s:%X), Val %.8X [TO]: Pin %u Bits %u\n",
570 AcpiUtGetTypeName (SourceDesc->Common.Type),
571 SourceDesc->Common.Type, (UINT32) SourceDesc->Integer.Value,
572 ObjDesc->Field.PinNumberIndex, ObjDesc->Field.BitLength));
573
574 Buffer = &SourceDesc->Integer.Value;
575
576 /* Lock entire transaction if requested */
577
578 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
579
580 /* Perform the write */
581
582 Status = AcpiExAccessRegion (ObjDesc, 0,
583 (UINT64 *) Buffer, ACPI_WRITE);
584 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
585 return_ACPI_STATUS (Status);
586 }
587
588 /* Get a pointer to the data to be written */
589
590 switch (SourceDesc->Common.Type)
591 {
592 case ACPI_TYPE_INTEGER:
593
594 Buffer = &SourceDesc->Integer.Value;
595 Length = sizeof (SourceDesc->Integer.Value);
596 break;
597
598 case ACPI_TYPE_BUFFER:
599
600 Buffer = SourceDesc->Buffer.Pointer;
601 Length = SourceDesc->Buffer.Length;
602 break;
603
604 case ACPI_TYPE_STRING:
605
606 Buffer = SourceDesc->String.Pointer;
607 Length = SourceDesc->String.Length;
608 break;
609
610 default:
611
612 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
613 }
614
615 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
616 "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n",
617 SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type),
618 SourceDesc->Common.Type, Buffer, Length));
619
620 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
621 "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n",
622 ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type),
623 ObjDesc->Common.Type,
624 ObjDesc->CommonField.BitLength,
625 ObjDesc->CommonField.StartFieldBitOffset,
626 ObjDesc->CommonField.BaseByteOffset));
627
628 /* Lock entire transaction if requested */
629
630 AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags);
631
632 /* Write to the field */
633
634 Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length);
635 AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags);
636
637 return_ACPI_STATUS (Status);
638 }