1 /******************************************************************************
3 * Module Name: exfldio - Aml Field I/O
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2006, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include <acpi/acpi.h>
45 #include <acpi/acinterp.h>
46 #include <acpi/amlcode.h>
47 #include <acpi/acevents.h>
48 #include <acpi/acdispat.h>
50 #define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME("exfldio")
53 /* Local prototypes */
55 acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
56 u32 field_datum_byte_offset,
57 acpi_integer * value, u32 read_write);
60 acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
64 acpi_ex_setup_region(union acpi_operand_object *obj_desc,
65 u32 field_datum_byte_offset);
67 /*******************************************************************************
69 * FUNCTION: acpi_ex_setup_region
71 * PARAMETERS: obj_desc - Field to be read or written
72 * field_datum_byte_offset - Byte offset of this datum within the
77 * DESCRIPTION: Common processing for acpi_ex_extract_from_field and
78 * acpi_ex_insert_into_field. Initialize the Region if necessary and
79 * validate the request.
81 ******************************************************************************/
84 acpi_ex_setup_region(union acpi_operand_object *obj_desc,
85 u32 field_datum_byte_offset)
87 acpi_status status = AE_OK;
88 union acpi_operand_object *rgn_desc;
90 ACPI_FUNCTION_TRACE_U32("ex_setup_region", field_datum_byte_offset);
92 rgn_desc = obj_desc->common_field.region_obj;
94 /* We must have a valid region */
96 if (ACPI_GET_OBJECT_TYPE(rgn_desc) != ACPI_TYPE_REGION) {
97 ACPI_REPORT_ERROR(("Needed Region, found type %X (%s)\n",
98 ACPI_GET_OBJECT_TYPE(rgn_desc),
99 acpi_ut_get_object_type_name(rgn_desc)));
101 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
105 * If the Region Address and Length have not been previously evaluated,
106 * evaluate them now and save the results.
108 if (!(rgn_desc->common.flags & AOPOBJ_DATA_VALID)) {
109 status = acpi_ds_get_region_arguments(rgn_desc);
110 if (ACPI_FAILURE(status)) {
111 return_ACPI_STATUS(status);
115 if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS) {
116 /* SMBus has a non-linear address space */
118 return_ACPI_STATUS(AE_OK);
120 #ifdef ACPI_UNDER_DEVELOPMENT
122 * If the Field access is any_acc, we can now compute the optimal
123 * access (because we know know the length of the parent region)
125 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
126 if (ACPI_FAILURE(status)) {
127 return_ACPI_STATUS(status);
133 * Validate the request. The entire request from the byte offset for a
134 * length of one field datum (access width) must fit within the region.
135 * (Region length is specified in bytes)
137 if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset +
138 field_datum_byte_offset +
139 obj_desc->common_field.
140 access_byte_width)) {
141 if (acpi_gbl_enable_interpreter_slack) {
143 * Slack mode only: We will go ahead and allow access to this
144 * field if it is within the region length rounded up to the next
145 * access width boundary.
147 if (ACPI_ROUND_UP(rgn_desc->region.length,
148 obj_desc->common_field.
149 access_byte_width) >=
150 (obj_desc->common_field.base_byte_offset +
151 (acpi_native_uint) obj_desc->common_field.
152 access_byte_width + field_datum_byte_offset)) {
153 return_ACPI_STATUS(AE_OK);
157 if (rgn_desc->region.length <
158 obj_desc->common_field.access_byte_width) {
160 * This is the case where the access_type (acc_word, etc.) is wider
161 * than the region itself. For example, a region of length one
162 * byte, and a field with Dword access specified.
164 ACPI_REPORT_ERROR(("Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", acpi_ut_get_node_name(obj_desc->common_field.node), obj_desc->common_field.access_byte_width, acpi_ut_get_node_name(rgn_desc->region.node), rgn_desc->region.length));
168 * Offset rounded up to next multiple of field width
169 * exceeds region length, indicate an error
171 ACPI_REPORT_ERROR(("Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n", acpi_ut_get_node_name(obj_desc->common_field.node), obj_desc->common_field.base_byte_offset, field_datum_byte_offset, obj_desc->common_field.access_byte_width, acpi_ut_get_node_name(rgn_desc->region.node), rgn_desc->region.length));
173 return_ACPI_STATUS(AE_AML_REGION_LIMIT);
176 return_ACPI_STATUS(AE_OK);
179 /*******************************************************************************
181 * FUNCTION: acpi_ex_access_region
183 * PARAMETERS: obj_desc - Field to be read
184 * field_datum_byte_offset - Byte offset of this datum within the
186 * Value - Where to store value (must at least
187 * the size of acpi_integer)
188 * Function - Read or Write flag plus other region-
193 * DESCRIPTION: Read or Write a single field datum to an Operation Region.
195 ******************************************************************************/
198 acpi_ex_access_region(union acpi_operand_object *obj_desc,
199 u32 field_datum_byte_offset,
200 acpi_integer * value, u32 function)
203 union acpi_operand_object *rgn_desc;
204 acpi_physical_address address;
206 ACPI_FUNCTION_TRACE("ex_access_region");
209 * Ensure that the region operands are fully evaluated and verify
210 * the validity of the request
212 status = acpi_ex_setup_region(obj_desc, field_datum_byte_offset);
213 if (ACPI_FAILURE(status)) {
214 return_ACPI_STATUS(status);
218 * The physical address of this field datum is:
220 * 1) The base of the region, plus
221 * 2) The base offset of the field, plus
222 * 3) The current offset into the field
224 rgn_desc = obj_desc->common_field.region_obj;
225 address = rgn_desc->region.address +
226 obj_desc->common_field.base_byte_offset + field_datum_byte_offset;
228 if ((function & ACPI_IO_MASK) == ACPI_READ) {
229 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "[READ]"));
231 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "[WRITE]"));
234 ACPI_DEBUG_PRINT_RAW((ACPI_DB_BFIELD,
235 " Region [%s:%X], Width %X, byte_base %X, Offset %X at %8.8X%8.8X\n",
236 acpi_ut_get_region_name(rgn_desc->region.
238 rgn_desc->region.space_id,
239 obj_desc->common_field.access_byte_width,
240 obj_desc->common_field.base_byte_offset,
241 field_datum_byte_offset,
242 ACPI_FORMAT_UINT64(address)));
244 /* Invoke the appropriate address_space/op_region handler */
246 status = acpi_ev_address_space_dispatch(rgn_desc, function,
248 ACPI_MUL_8(obj_desc->
253 if (ACPI_FAILURE(status)) {
254 if (status == AE_NOT_IMPLEMENTED) {
255 ACPI_REPORT_ERROR(("Region %s(%X) not implemented\n",
256 acpi_ut_get_region_name(rgn_desc->
259 rgn_desc->region.space_id));
260 } else if (status == AE_NOT_EXIST) {
261 ACPI_REPORT_ERROR(("Region %s(%X) has no handler\n",
262 acpi_ut_get_region_name(rgn_desc->
265 rgn_desc->region.space_id));
269 return_ACPI_STATUS(status);
272 /*******************************************************************************
274 * FUNCTION: acpi_ex_register_overflow
276 * PARAMETERS: obj_desc - Register(Field) to be written
277 * Value - Value to be stored
279 * RETURN: TRUE if value overflows the field, FALSE otherwise
281 * DESCRIPTION: Check if a value is out of range of the field being written.
282 * Used to check if the values written to Index and Bank registers
283 * are out of range. Normally, the value is simply truncated
284 * to fit the field, but this case is most likely a serious
285 * coding error in the ASL.
287 ******************************************************************************/
290 acpi_ex_register_overflow(union acpi_operand_object *obj_desc,
294 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
296 * The field is large enough to hold the maximum integer, so we can
302 if (value >= ((acpi_integer) 1 << obj_desc->common_field.bit_length)) {
304 * The Value is larger than the maximum value that can fit into
310 /* The Value will fit into the field with no truncation */
315 /*******************************************************************************
317 * FUNCTION: acpi_ex_field_datum_io
319 * PARAMETERS: obj_desc - Field to be read
320 * field_datum_byte_offset - Byte offset of this datum within the
322 * Value - Where to store value (must be 64 bits)
323 * read_write - Read or Write flag
327 * DESCRIPTION: Read or Write a single datum of a field. The field_type is
328 * demultiplexed here to handle the different types of fields
329 * (buffer_field, region_field, index_field, bank_field)
331 ******************************************************************************/
334 acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
335 u32 field_datum_byte_offset,
336 acpi_integer * value, u32 read_write)
339 acpi_integer local_value;
341 ACPI_FUNCTION_TRACE_U32("ex_field_datum_io", field_datum_byte_offset);
343 if (read_write == ACPI_READ) {
347 /* To support reads without saving return value */
348 value = &local_value;
351 /* Clear the entire return buffer first, [Very Important!] */
357 * The four types of fields are:
359 * buffer_field - Read/write from/to a Buffer
360 * region_field - Read/write from/to a Operation Region.
361 * bank_field - Write to a Bank Register, then read/write from/to an
363 * index_field - Write to an Index Register, then read/write from/to a
366 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
367 case ACPI_TYPE_BUFFER_FIELD:
369 * If the buffer_field arguments have not been previously evaluated,
370 * evaluate them now and save the results.
372 if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) {
373 status = acpi_ds_get_buffer_field_arguments(obj_desc);
374 if (ACPI_FAILURE(status)) {
375 return_ACPI_STATUS(status);
379 if (read_write == ACPI_READ) {
381 * Copy the data from the source buffer.
382 * Length is the field width in bytes.
385 (obj_desc->buffer_field.buffer_obj)->buffer.
387 obj_desc->buffer_field.base_byte_offset +
388 field_datum_byte_offset,
389 obj_desc->common_field.access_byte_width);
392 * Copy the data to the target buffer.
393 * Length is the field width in bytes.
395 ACPI_MEMCPY((obj_desc->buffer_field.buffer_obj)->buffer.
397 obj_desc->buffer_field.base_byte_offset +
398 field_datum_byte_offset, value,
399 obj_desc->common_field.access_byte_width);
405 case ACPI_TYPE_LOCAL_BANK_FIELD:
408 * Ensure that the bank_value is not beyond the capacity of
411 if (acpi_ex_register_overflow(obj_desc->bank_field.bank_obj,
412 (acpi_integer) obj_desc->
414 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
418 * For bank_fields, we must write the bank_value to the bank_register
419 * (itself a region_field) before we can access the data.
422 acpi_ex_insert_into_field(obj_desc->bank_field.bank_obj,
423 &obj_desc->bank_field.value,
424 sizeof(obj_desc->bank_field.
426 if (ACPI_FAILURE(status)) {
427 return_ACPI_STATUS(status);
431 * Now that the Bank has been selected, fall through to the
432 * region_field case and write the datum to the Operation Region
435 /*lint -fallthrough */
437 case ACPI_TYPE_LOCAL_REGION_FIELD:
439 * For simple region_fields, we just directly access the owning
443 acpi_ex_access_region(obj_desc, field_datum_byte_offset,
447 case ACPI_TYPE_LOCAL_INDEX_FIELD:
450 * Ensure that the index_value is not beyond the capacity of
453 if (acpi_ex_register_overflow(obj_desc->index_field.index_obj,
454 (acpi_integer) obj_desc->
455 index_field.value)) {
456 return_ACPI_STATUS(AE_AML_REGISTER_LIMIT);
459 /* Write the index value to the index_register (itself a region_field) */
461 field_datum_byte_offset += obj_desc->index_field.value;
463 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
464 "Write to Index Register: Value %8.8X\n",
465 field_datum_byte_offset));
468 acpi_ex_insert_into_field(obj_desc->index_field.index_obj,
469 &field_datum_byte_offset,
470 sizeof(field_datum_byte_offset));
471 if (ACPI_FAILURE(status)) {
472 return_ACPI_STATUS(status);
475 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
476 "I/O to Data Register: value_ptr %p\n",
479 if (read_write == ACPI_READ) {
480 /* Read the datum from the data_register */
483 acpi_ex_extract_from_field(obj_desc->index_field.
485 sizeof(acpi_integer));
487 /* Write the datum to the data_register */
490 acpi_ex_insert_into_field(obj_desc->index_field.
492 sizeof(acpi_integer));
498 ACPI_REPORT_ERROR(("Wrong object type in field I/O %X\n",
499 ACPI_GET_OBJECT_TYPE(obj_desc)));
500 status = AE_AML_INTERNAL;
504 if (ACPI_SUCCESS(status)) {
505 if (read_write == ACPI_READ) {
506 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
507 "Value Read %8.8X%8.8X, Width %d\n",
508 ACPI_FORMAT_UINT64(*value),
509 obj_desc->common_field.
512 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
513 "Value Written %8.8X%8.8X, Width %d\n",
514 ACPI_FORMAT_UINT64(*value),
515 obj_desc->common_field.
520 return_ACPI_STATUS(status);
523 /*******************************************************************************
525 * FUNCTION: acpi_ex_write_with_update_rule
527 * PARAMETERS: obj_desc - Field to be written
528 * Mask - bitmask within field datum
529 * field_value - Value to write
530 * field_datum_byte_offset - Offset of datum within field
534 * DESCRIPTION: Apply the field update rule to a field write
536 ******************************************************************************/
539 acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
541 acpi_integer field_value,
542 u32 field_datum_byte_offset)
544 acpi_status status = AE_OK;
545 acpi_integer merged_value;
546 acpi_integer current_value;
548 ACPI_FUNCTION_TRACE_U32("ex_write_with_update_rule", mask);
550 /* Start with the new bits */
552 merged_value = field_value;
554 /* If the mask is all ones, we don't need to worry about the update rule */
556 if (mask != ACPI_INTEGER_MAX) {
557 /* Decode the update rule */
559 switch (obj_desc->common_field.
560 field_flags & AML_FIELD_UPDATE_RULE_MASK) {
561 case AML_FIELD_UPDATE_PRESERVE:
563 * Check if update rule needs to be applied (not if mask is all
564 * ones) The left shift drops the bits we want to ignore.
566 if ((~mask << (ACPI_MUL_8(sizeof(mask)) -
567 ACPI_MUL_8(obj_desc->common_field.
568 access_byte_width))) != 0) {
570 * Read the current contents of the byte/word/dword containing
571 * the field, and merge with the new field value.
574 acpi_ex_field_datum_io(obj_desc,
575 field_datum_byte_offset,
578 if (ACPI_FAILURE(status)) {
579 return_ACPI_STATUS(status);
582 merged_value |= (current_value & ~mask);
586 case AML_FIELD_UPDATE_WRITE_AS_ONES:
588 /* Set positions outside the field to all ones */
590 merged_value |= ~mask;
593 case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
595 /* Set positions outside the field to all zeros */
597 merged_value &= mask;
602 ACPI_REPORT_ERROR(("Unknown update_rule value: %X\n",
603 (obj_desc->common_field.
605 AML_FIELD_UPDATE_RULE_MASK)));
606 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
610 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
611 "Mask %8.8X%8.8X, datum_offset %X, Width %X, Value %8.8X%8.8X, merged_value %8.8X%8.8X\n",
612 ACPI_FORMAT_UINT64(mask),
613 field_datum_byte_offset,
614 obj_desc->common_field.access_byte_width,
615 ACPI_FORMAT_UINT64(field_value),
616 ACPI_FORMAT_UINT64(merged_value)));
618 /* Write the merged value */
620 status = acpi_ex_field_datum_io(obj_desc, field_datum_byte_offset,
621 &merged_value, ACPI_WRITE);
623 return_ACPI_STATUS(status);
626 /*******************************************************************************
628 * FUNCTION: acpi_ex_extract_from_field
630 * PARAMETERS: obj_desc - Field to be read
631 * Buffer - Where to store the field data
632 * buffer_length - Length of Buffer
636 * DESCRIPTION: Retrieve the current value of the given field
638 ******************************************************************************/
641 acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
642 void *buffer, u32 buffer_length)
645 acpi_integer raw_datum;
646 acpi_integer merged_datum;
647 u32 field_offset = 0;
648 u32 buffer_offset = 0;
649 u32 buffer_tail_bits;
651 u32 field_datum_count;
654 ACPI_FUNCTION_TRACE("ex_extract_from_field");
656 /* Validate target buffer and clear it */
659 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
660 ACPI_REPORT_ERROR(("Field size %X (bits) is too large for buffer (%X)\n", obj_desc->common_field.bit_length, buffer_length));
662 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
664 ACPI_MEMSET(buffer, 0, buffer_length);
666 /* Compute the number of datums (access width data items) */
668 datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
669 obj_desc->common_field.access_bit_width);
670 field_datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length +
671 obj_desc->common_field.
672 start_field_bit_offset,
673 obj_desc->common_field.
676 /* Priming read from the field */
679 acpi_ex_field_datum_io(obj_desc, field_offset, &raw_datum,
681 if (ACPI_FAILURE(status)) {
682 return_ACPI_STATUS(status);
685 raw_datum >> obj_desc->common_field.start_field_bit_offset;
687 /* Read the rest of the field */
689 for (i = 1; i < field_datum_count; i++) {
690 /* Get next input datum from the field */
692 field_offset += obj_desc->common_field.access_byte_width;
693 status = acpi_ex_field_datum_io(obj_desc, field_offset,
694 &raw_datum, ACPI_READ);
695 if (ACPI_FAILURE(status)) {
696 return_ACPI_STATUS(status);
699 /* Merge with previous datum if necessary */
701 merged_datum |= raw_datum <<
702 (obj_desc->common_field.access_bit_width -
703 obj_desc->common_field.start_field_bit_offset);
705 if (i == datum_count) {
709 /* Write merged datum to target buffer */
711 ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum,
712 ACPI_MIN(obj_desc->common_field.access_byte_width,
713 buffer_length - buffer_offset));
715 buffer_offset += obj_desc->common_field.access_byte_width;
717 raw_datum >> obj_desc->common_field.start_field_bit_offset;
720 /* Mask off any extra bits in the last datum */
722 buffer_tail_bits = obj_desc->common_field.bit_length %
723 obj_desc->common_field.access_bit_width;
724 if (buffer_tail_bits) {
725 merged_datum &= ACPI_MASK_BITS_ABOVE(buffer_tail_bits);
728 /* Write the last datum to the buffer */
730 ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum,
731 ACPI_MIN(obj_desc->common_field.access_byte_width,
732 buffer_length - buffer_offset));
734 return_ACPI_STATUS(AE_OK);
737 /*******************************************************************************
739 * FUNCTION: acpi_ex_insert_into_field
741 * PARAMETERS: obj_desc - Field to be written
742 * Buffer - Data to be written
743 * buffer_length - Length of Buffer
747 * DESCRIPTION: Store the Buffer contents into the given field
749 ******************************************************************************/
752 acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
753 void *buffer, u32 buffer_length)
757 acpi_integer merged_datum;
758 acpi_integer raw_datum = 0;
759 u32 field_offset = 0;
760 u32 buffer_offset = 0;
761 u32 buffer_tail_bits;
763 u32 field_datum_count;
766 ACPI_FUNCTION_TRACE("ex_insert_into_field");
768 /* Validate input buffer */
771 ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length)) {
772 ACPI_REPORT_ERROR(("Field size %X (bits) is too large for buffer (%X)\n", obj_desc->common_field.bit_length, buffer_length));
774 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
777 /* Compute the number of datums (access width data items) */
780 ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);
782 ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
783 obj_desc->common_field.access_bit_width);
785 ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length +
786 obj_desc->common_field.start_field_bit_offset,
787 obj_desc->common_field.access_bit_width);
789 /* Get initial Datum from the input buffer */
791 ACPI_MEMCPY(&raw_datum, buffer,
792 ACPI_MIN(obj_desc->common_field.access_byte_width,
793 buffer_length - buffer_offset));
796 raw_datum << obj_desc->common_field.start_field_bit_offset;
798 /* Write the entire field */
800 for (i = 1; i < field_datum_count; i++) {
801 /* Write merged datum to the target field */
803 merged_datum &= mask;
804 status = acpi_ex_write_with_update_rule(obj_desc, mask,
807 if (ACPI_FAILURE(status)) {
808 return_ACPI_STATUS(status);
811 /* Start new output datum by merging with previous input datum */
813 field_offset += obj_desc->common_field.access_byte_width;
814 merged_datum = raw_datum >>
815 (obj_desc->common_field.access_bit_width -
816 obj_desc->common_field.start_field_bit_offset);
817 mask = ACPI_INTEGER_MAX;
819 if (i == datum_count) {
823 /* Get the next input datum from the buffer */
825 buffer_offset += obj_desc->common_field.access_byte_width;
826 ACPI_MEMCPY(&raw_datum, ((char *)buffer) + buffer_offset,
827 ACPI_MIN(obj_desc->common_field.access_byte_width,
828 buffer_length - buffer_offset));
830 raw_datum << obj_desc->common_field.start_field_bit_offset;
833 /* Mask off any extra bits in the last datum */
835 buffer_tail_bits = (obj_desc->common_field.bit_length +
836 obj_desc->common_field.start_field_bit_offset) %
837 obj_desc->common_field.access_bit_width;
838 if (buffer_tail_bits) {
839 mask &= ACPI_MASK_BITS_ABOVE(buffer_tail_bits);
842 /* Write the last datum to the field */
844 merged_datum &= mask;
845 status = acpi_ex_write_with_update_rule(obj_desc,
849 return_ACPI_STATUS(status);