Deleted Added
sdiff udiff text old ( 128212 ) new ( 131440 )
full compact
1/******************************************************************************
2 *
3 * Module Name: exfldio - Aml Field I/O
4 * $Revision: 104 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.

--- 828 unchanged lines hidden (view full) ---

841 }
842
843 return_VOID;
844}
845
846
847/*******************************************************************************
848 *
849 * FUNCTION: AcpiExExtractFromField
850 *
851 * PARAMETERS: *ObjDesc - Field to be read
852 * *Value - Where to store value
853 *
854 * RETURN: Status
855 *
856 * DESCRIPTION: Retrieve the value of the given field
857 *
858 ******************************************************************************/
859
860ACPI_STATUS
861AcpiExExtractFromField (
862 ACPI_OPERAND_OBJECT *ObjDesc,
863 void *Buffer,
864 UINT32 BufferLength)
865{
866 ACPI_STATUS Status;
867 UINT32 FieldDatumByteOffset;
868 UINT32 BufferDatumOffset;
869 ACPI_INTEGER PreviousRawDatum = 0;
870 ACPI_INTEGER ThisRawDatum = 0;
871 ACPI_INTEGER MergedDatum = 0;
872 UINT32 ByteFieldLength;
873 UINT32 DatumCount;
874 UINT32 i;
875
876
877 ACPI_FUNCTION_TRACE ("ExExtractFromField");
878
879
880 /*
881 * The field must fit within the caller's buffer
882 */
883 ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength);
884 if (ByteFieldLength > BufferLength)
885 {
886 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
887 "Field size %X (bytes) too large for buffer (%X)\n",
888 ByteFieldLength, BufferLength));
889
890 return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
891 }
892
893 /* Convert field byte count to datum count, round up if necessary */
894
895 DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength,
896 ObjDesc->CommonField.AccessByteWidth);
897
898 /*
899 * If the field is not aligned on a datum boundary and does not
900 * fit within a single datum, we must read an extra datum.
901 *
902 * We could just split the aligned and non-aligned cases since the
903 * aligned case is so very simple, but this would require more code.
904 */
905 if ((ObjDesc->CommonField.EndFieldValidBits != 0) &&
906 (!(ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM)))
907 {
908 DatumCount++;
909 }
910
911 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
912 "ByteLen %X, DatumLen %X, ByteGran %X\n",
913 ByteFieldLength, DatumCount,ObjDesc->CommonField.AccessByteWidth));
914
915 /*
916 * Clear the caller's buffer (the whole buffer length as given)
917 * This is very important, especially in the cases where the buffer
918 * is longer than the size of the field.
919 */
920 ACPI_MEMSET (Buffer, 0, BufferLength);
921
922 FieldDatumByteOffset = 0;

--- 105 unchanged lines hidden (view full) ---

1028 return_ACPI_STATUS (AE_OK);
1029}
1030
1031
1032/*******************************************************************************
1033 *
1034 * FUNCTION: AcpiExInsertIntoField
1035 *
1036 * PARAMETERS: *ObjDesc - Field to be set
1037 * Buffer - Value to store
1038 *
1039 * RETURN: Status
1040 *
1041 * DESCRIPTION: Store the value into the given field
1042 *
1043 ******************************************************************************/
1044
1045ACPI_STATUS
1046AcpiExInsertIntoField (
1047 ACPI_OPERAND_OBJECT *ObjDesc,
1048 void *Buffer,
1049 UINT32 BufferLength)
1050{
1051 ACPI_STATUS Status;
1052 UINT32 FieldDatumByteOffset;
1053 UINT32 DatumOffset;
1054 ACPI_INTEGER Mask;
1055 ACPI_INTEGER MergedDatum;
1056 ACPI_INTEGER PreviousRawDatum;
1057 ACPI_INTEGER ThisRawDatum;
1058 UINT32 ByteFieldLength;
1059 UINT32 DatumCount;
1060
1061
1062 ACPI_FUNCTION_TRACE ("ExInsertIntoField");
1063
1064
1065 /*
1066 * Incoming buffer must be at least as long as the field, we do not
1067 * allow "partial" field writes. We do not care if the buffer is
1068 * larger than the field, this typically happens when an integer is
1069 * written to a field that is actually smaller than an integer.
1070 */
1071 ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
1072 ObjDesc->CommonField.BitLength);
1073 if (BufferLength < ByteFieldLength)
1074 {
1075 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
1076 "Buffer length %X too small for field %X\n",
1077 BufferLength, ByteFieldLength));
1078
1079 return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
1080 }
1081
1082 ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
1083 ObjDesc->CommonField.StartFieldBitOffset +
1084 ObjDesc->CommonField.BitLength);
1085
1086 /* Convert byte count to datum count, round up if necessary */
1087
1088 DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength,
1089 ObjDesc->CommonField.AccessByteWidth);
1090
1091 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
1092 "Bytes %X, Datums %X, ByteGran %X\n",
1093 ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessByteWidth));
1094
1095 /*
1096 * Break the request into up to three parts (similar to an I/O request):
1097 * 1) non-aligned part at start
1098 * 2) aligned part in middle
1099 * 3) non-aligned part at the end
1100 */
1101 FieldDatumByteOffset = 0;
1102 DatumOffset= 0;

--- 151 unchanged lines hidden ---