diff options
Diffstat (limited to 'sys/contrib/dev/acpica/exfldio.c')
-rw-r--r-- | sys/contrib/dev/acpica/exfldio.c | 94 |
1 files changed, 50 insertions, 44 deletions
diff --git a/sys/contrib/dev/acpica/exfldio.c b/sys/contrib/dev/acpica/exfldio.c index 5e21ea1..feca92c 100644 --- a/sys/contrib/dev/acpica/exfldio.c +++ b/sys/contrib/dev/acpica/exfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfldio - Aml Field I/O - * $Revision: 62 $ + * $Revision: 64 $ * *****************************************************************************/ @@ -155,6 +155,7 @@ AcpiExSetupField ( FUNCTION_TRACE_U32 ("ExSetupField", FieldDatumByteOffset); + RgnDesc = ObjDesc->CommonField.RegionObj; if (ACPI_TYPE_REGION != RgnDesc->Common.Type) @@ -191,7 +192,7 @@ AcpiExSetupField ( { if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth) { - /* + /* * This is the case where the AccessType (AccWord, etc.) is wider * than the region itself. For example, a region of length one * byte, and a field with Dword access specified. @@ -207,7 +208,7 @@ AcpiExSetupField ( */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Field base+offset+width %X+%X+%X exceeds region size (%X bytes) field=%p region=%p\n", - ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, + ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, RgnDesc->Region.Length, ObjDesc, RgnDesc)); @@ -349,10 +350,10 @@ AcpiExReadFieldDatum ( * * PARAMETERS: MergedDatum - Value to store * Buffer - Receiving buffer - * ByteGranularity - 1/2/4 Granularity of the field + * ByteGranularity - 1/2/4 Granularity of the field * (aka Datum Size) * Offset - Datum offset into the buffer - * + * * RETURN: none * * DESCRIPTION: Store the merged datum to the buffer according to the @@ -368,6 +369,9 @@ AcpiExGetBufferDatum( UINT32 Offset) { + FUNCTION_ENTRY (); + + switch (ByteGranularity) { case ACPI_FIELD_BYTE_GRANULARITY: @@ -387,14 +391,14 @@ AcpiExGetBufferDatum( /******************************************************************************* * - * FUNCTION: AcpiExSetBufferDatum + * FUNCTION: AcpiExSetBufferDatum * * PARAMETERS: MergedDatum - Value to store * Buffer - Receiving buffer - * ByteGranularity - 1/2/4 Granularity of the field + * ByteGranularity - 1/2/4 Granularity of the field * (aka Datum Size) * Offset - Datum offset into the buffer - * + * * RETURN: none * * DESCRIPTION: Store the merged datum to the buffer according to the @@ -410,6 +414,9 @@ AcpiExSetBufferDatum ( UINT32 Offset) { + FUNCTION_ENTRY (); + + switch (ByteGranularity) { case ACPI_FIELD_BYTE_GRANULARITY: @@ -477,7 +484,7 @@ AcpiExExtractFromField ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteLen=%x, DatumLen=%x, BitGran=%x, ByteGran=%x\n", - ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessBitWidth, + ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessBitWidth, ObjDesc->CommonField.AccessByteWidth)); @@ -518,7 +525,7 @@ AcpiExExtractFromField ( /* Store the datum to the caller buffer */ - AcpiExSetBufferDatum (MergedDatum, Buffer, ObjDesc->CommonField.AccessByteWidth, + AcpiExSetBufferDatum (MergedDatum, Buffer, ObjDesc->CommonField.AccessByteWidth, DatumOffset); return_ACPI_STATUS (AE_OK); @@ -567,28 +574,28 @@ AcpiExExtractFromField ( else { /* - * Put together the appropriate bits of the two raw data to make a + * Put together the appropriate bits of the two raw data to make a * single complete field datum * - * 1) Normalize the first datum down to bit 0 + * 1) Normalize the first datum down to bit 0 */ MergedDatum = (PreviousRawDatum >> ObjDesc->CommonField.StartFieldBitOffset); /* 2) Insert the second datum "above" the first datum */ MergedDatum |= (ThisRawDatum << ObjDesc->CommonField.DatumValidBits); - + if ((DatumOffset >= (DatumCount -1))) { /* * This is the last iteration of the loop. We need to clear - * any unused bits (bits that are not part of this field) that - * came from the last raw datum before we store the final + * any unused bits (bits that are not part of this field) that + * came from the last raw datum before we store the final * merged datum into the caller buffer. */ if (ObjDesc->CommonField.EndBufferValidBits) { - MergedDatum &= + MergedDatum &= MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits); } } @@ -599,11 +606,11 @@ AcpiExExtractFromField ( * Store the merged field datum in the caller's buffer, according to * the granularity of the field (size of each datum). */ - AcpiExSetBufferDatum (MergedDatum, Buffer, ObjDesc->CommonField.AccessByteWidth, + AcpiExSetBufferDatum (MergedDatum, Buffer, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* - * Save the raw datum that was just acquired since it may contain bits + * Save the raw datum that was just acquired since it may contain bits * of the *next* field datum. Update offsets */ PreviousRawDatum = ThisRawDatum; @@ -642,7 +649,6 @@ AcpiExWriteFieldDatum ( FUNCTION_TRACE_U32 ("ExWriteFieldDatum", FieldDatumByteOffset); - /* * BufferFields - Read from a Buffer * Other Fields - Read from a Operation Region. @@ -683,11 +689,11 @@ AcpiExWriteFieldDatum ( * 3) The current offset into the field */ RgnDesc = ObjDesc->CommonField.RegionObj; - Address = RgnDesc->Region.Address + + Address = RgnDesc->Region.Address + ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset; - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Store %X in Region %s(%X) at %8.8lX%8.8lX width %X\n", Value, AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId, HIDWORD(Address), LODWORD(Address), @@ -700,7 +706,7 @@ AcpiExWriteFieldDatum ( if (Status == AE_NOT_IMPLEMENTED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "**** Region type %s(%X) not implemented\n", AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId)); @@ -708,7 +714,7 @@ AcpiExWriteFieldDatum ( else if (Status == AE_NOT_EXIST) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "**** Region type %s(%X) does not have a handler\n", AcpiUtGetRegionName (RgnDesc->Region.SpaceId), RgnDesc->Region.SpaceId)); @@ -775,18 +781,18 @@ AcpiExWriteFieldDatumWithUpdateRule ( case UPDATE_PRESERVE: - /* - * Check if update rule needs to be applied (not if mask is all - * ones) The left shift drops the bits we want to ignore. + /* + * Check if update rule needs to be applied (not if mask is all + * ones) The left shift drops the bits we want to ignore. */ - if ((~Mask << (sizeof (Mask) * 8 - + if ((~Mask << (sizeof (Mask) * 8 - ObjDesc->CommonField.AccessBitWidth)) != 0) { /* * Read the current contents of the byte/word/dword containing * the field, and merge with the new field value. */ - Status = AcpiExReadFieldDatum (ObjDesc, FieldDatumByteOffset, + Status = AcpiExReadFieldDatum (ObjDesc, FieldDatumByteOffset, &CurrentValue); MergedValue |= (CurrentValue & ~Mask); } @@ -821,7 +827,7 @@ AcpiExWriteFieldDatumWithUpdateRule ( /* Write the merged value */ - Status = AcpiExWriteFieldDatum (ObjDesc, FieldDatumByteOffset, + Status = AcpiExWriteFieldDatum (ObjDesc, FieldDatumByteOffset, MergedValue); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Mask %X DatumOffset %X Value %X, MergedValue %X\n", @@ -865,7 +871,7 @@ AcpiExInsertIntoField ( /* - * Incoming buffer must be at least as long as the field, we do not + * Incoming buffer must be at least as long as the field, we do not * allow "partial" field writes. We do not care if the buffer is * larger than the field, this typically happens when an integer is * written to a field that is actually smaller than an integer. @@ -887,7 +893,7 @@ AcpiExInsertIntoField ( ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteLen=%x, DatumLen=%x, BitGran=%x, ByteGran=%x\n", - ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessBitWidth, + ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessBitWidth, ObjDesc->CommonField.AccessByteWidth)); @@ -902,7 +908,7 @@ AcpiExInsertIntoField ( /* Get a single datum from the caller's buffer */ - AcpiExGetBufferDatum (&PreviousRawDatum, Buffer, + AcpiExGetBufferDatum (&PreviousRawDatum, Buffer, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* @@ -956,8 +962,8 @@ AcpiExInsertIntoField ( * We don't need to worry about the update rule for these data, because * all of the bits in each datum are part of the field. * - * The last datum must be special cased because it might contain bits - * that are not part of the field -- therefore the "update rule" must be + * The last datum must be special cased because it might contain bits + * that are not part of the field -- therefore the "update rule" must be * applied in Part3 below. */ while (DatumOffset < DatumCount) @@ -965,11 +971,11 @@ AcpiExInsertIntoField ( DatumOffset++; FieldDatumByteOffset += ObjDesc->CommonField.AccessByteWidth; - /* - * Get the next raw buffer datum. It may contain bits of the previous + /* + * Get the next raw buffer datum. It may contain bits of the previous * field datum */ - AcpiExGetBufferDatum (&ThisRawDatum, Buffer, + AcpiExGetBufferDatum (&ThisRawDatum, Buffer, ObjDesc->CommonField.AccessByteWidth, DatumOffset); /* Create the field datum based on the field alignment */ @@ -977,10 +983,10 @@ AcpiExInsertIntoField ( if (ObjDesc->CommonField.StartFieldBitOffset != 0) { /* - * Put together appropriate bits of the two raw buffer data to make + * Put together appropriate bits of the two raw buffer data to make * a single complete field datum */ - MergedDatum = + MergedDatum = (PreviousRawDatum >> ObjDesc->CommonField.DatumValidBits) | (ThisRawDatum << ObjDesc->CommonField.StartFieldBitOffset); } @@ -1001,8 +1007,8 @@ AcpiExInsertIntoField ( if ((DatumOffset == DatumCount) && ObjDesc->CommonField.EndFieldValidBits) { - /* - * Part3: + /* + * Part3: * This is the last datum and the field does not end on a datum boundary. * Build the partial datum and write with the update rule. */ @@ -1014,7 +1020,7 @@ AcpiExInsertIntoField ( /* Write the last datum with the update rule */ - Status = AcpiExWriteFieldDatumWithUpdateRule (ObjDesc, Mask, + Status = AcpiExWriteFieldDatumWithUpdateRule (ObjDesc, Mask, MergedDatum, FieldDatumByteOffset); if (ACPI_FAILURE (Status)) { @@ -1026,7 +1032,7 @@ AcpiExInsertIntoField ( { /* Normal case -- write the completed datum */ - Status = AcpiExWriteFieldDatum (ObjDesc, + Status = AcpiExWriteFieldDatum (ObjDesc, FieldDatumByteOffset, MergedDatum); if (ACPI_FAILURE (Status)) { @@ -1035,7 +1041,7 @@ AcpiExInsertIntoField ( } /* - * Save the most recent datum since it may contain bits of the *next* + * Save the most recent datum since it may contain bits of the *next* * field datum. Update current byte offset. */ PreviousRawDatum = ThisRawDatum; |