Deleted Added
full compact
exfldio.c (128212) exfldio.c (131440)
1/******************************************************************************
2 *
3 * Module Name: exfldio - Aml Field I/O
1/******************************************************************************
2 *
3 * Module Name: exfldio - Aml Field I/O
4 * $Revision: 104 $
4 * $Revision: 106 $
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 *
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: AcpiExCommonBufferSetup
850 *
851 * PARAMETERS: ObjDesc - Field object
852 * BufferLength - Length of caller's buffer
853 * DatumCount - Where the DatumCount is returned
854 *
855 * RETURN: Status, DatumCount
856 *
857 * DESCRIPTION: Common code to validate the incoming buffer size and compute
858 * the number of field "datums" that must be read or written.
859 * A "datum" is the smallest unit that can be read or written
860 * to the field, it is either 1,2,4, or 8 bytes.
861 *
862 ******************************************************************************/
863
864ACPI_STATUS
865AcpiExCommonBufferSetup (
866 ACPI_OPERAND_OBJECT *ObjDesc,
867 UINT32 BufferLength,
868 UINT32 *DatumCount)
869{
870 UINT32 ByteFieldLength;
871 UINT32 ActualByteFieldLength;
872
873
874 ACPI_FUNCTION_TRACE ("ExCommonBufferSetup");
875
876
877 /*
878 * Incoming buffer must be at least as long as the field, we do not
879 * allow "partial" field reads/writes. We do not care if the buffer is
880 * larger than the field, this typically happens when an integer is
881 * read/written to a field that is actually smaller than an integer.
882 */
883 ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
884 ObjDesc->CommonField.BitLength);
885 if (ByteFieldLength > BufferLength)
886 {
887 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
888 "Field size %X (bytes) is too large for buffer (%X)\n",
889 ByteFieldLength, BufferLength));
890
891 return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
892 }
893
894 /*
895 * Create "actual" field byte count (minimum number of bytes that
896 * must be read), then convert to datum count (minimum number
897 * of datum-sized units that must be read)
898 */
899 ActualByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (
900 ObjDesc->CommonField.StartFieldBitOffset +
901 ObjDesc->CommonField.BitLength);
902
903
904 *DatumCount = ACPI_ROUND_UP_TO (ActualByteFieldLength,
905 ObjDesc->CommonField.AccessByteWidth);
906
907 ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
908 "BufferBytes %X, ActualBytes %X, Datums %X, ByteGran %X\n",
909 ByteFieldLength, ActualByteFieldLength,
910 *DatumCount, ObjDesc->CommonField.AccessByteWidth));
911
912 return_ACPI_STATUS (AE_OK);
913}
914
915
916/*******************************************************************************
917 *
849 * FUNCTION: AcpiExExtractFromField
850 *
918 * FUNCTION: AcpiExExtractFromField
919 *
851 * PARAMETERS: *ObjDesc - Field to be read
852 * *Value - Where to store value
920 * PARAMETERS: ObjDesc - Field to be read
921 * Buffer - Where to store the field data
922 * BufferLength - Length of Buffer
853 *
854 * RETURN: Status
855 *
923 *
924 * RETURN: Status
925 *
856 * DESCRIPTION: Retrieve the value of the given field
926 * DESCRIPTION: Retrieve the current 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;
927 *
928 ******************************************************************************/
929
930ACPI_STATUS
931AcpiExExtractFromField (
932 ACPI_OPERAND_OBJECT *ObjDesc,
933 void *Buffer,
934 UINT32 BufferLength)
935{
936 ACPI_STATUS Status;
937 UINT32 FieldDatumByteOffset;
938 UINT32 BufferDatumOffset;
939 ACPI_INTEGER PreviousRawDatum = 0;
940 ACPI_INTEGER ThisRawDatum = 0;
941 ACPI_INTEGER MergedDatum = 0;
872 UINT32 ByteFieldLength;
873 UINT32 DatumCount;
874 UINT32 i;
875
876
877 ACPI_FUNCTION_TRACE ("ExExtractFromField");
878
879
942 UINT32 DatumCount;
943 UINT32 i;
944
945
946 ACPI_FUNCTION_TRACE ("ExExtractFromField");
947
948
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));
949 /* Validate buffer, compute number of datums */
889
950
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)))
951 Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount);
952 if (ACPI_FAILURE (Status))
907 {
953 {
908 DatumCount++;
954 return_ACPI_STATUS (Status);
909 }
910
955 }
956
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 *
957 /*
958 * Clear the caller's buffer (the whole buffer length as given)
959 * This is very important, especially in the cases where the buffer
960 * is longer than the size of the field.
961 */
962 ACPI_MEMSET (Buffer, 0, BufferLength);
963
964 FieldDatumByteOffset = 0;

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

1070 return_ACPI_STATUS (AE_OK);
1071}
1072
1073
1074/*******************************************************************************
1075 *
1076 * FUNCTION: AcpiExInsertIntoField
1077 *
1036 * PARAMETERS: *ObjDesc - Field to be set
1037 * Buffer - Value to store
1078 * PARAMETERS: ObjDesc - Field to be written
1079 * Buffer - Data to be written
1080 * BufferLength - Length of Buffer
1038 *
1039 * RETURN: Status
1040 *
1081 *
1082 * RETURN: Status
1083 *
1041 * DESCRIPTION: Store the value into the given field
1084 * DESCRIPTION: Store the Buffer contents 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;
1085 *
1086 ******************************************************************************/
1087
1088ACPI_STATUS
1089AcpiExInsertIntoField (
1090 ACPI_OPERAND_OBJECT *ObjDesc,
1091 void *Buffer,
1092 UINT32 BufferLength)
1093{
1094 ACPI_STATUS Status;
1095 UINT32 FieldDatumByteOffset;
1096 UINT32 DatumOffset;
1097 ACPI_INTEGER Mask;
1098 ACPI_INTEGER MergedDatum;
1099 ACPI_INTEGER PreviousRawDatum;
1100 ACPI_INTEGER ThisRawDatum;
1058 UINT32 ByteFieldLength;
1059 UINT32 DatumCount;
1060
1061
1062 ACPI_FUNCTION_TRACE ("ExInsertIntoField");
1063
1064
1101 UINT32 DatumCount;
1102
1103
1104 ACPI_FUNCTION_TRACE ("ExInsertIntoField");
1105
1106
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));
1107 /* Validate buffer, compute number of datums */
1078
1108
1079 return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
1109 Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount);
1110 if (ACPI_FAILURE (Status))
1111 {
1112 return_ACPI_STATUS (Status);
1080 }
1081
1113 }
1114
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 ---
1115 /*
1116 * Break the request into up to three parts (similar to an I/O request):
1117 * 1) non-aligned part at start
1118 * 2) aligned part in middle
1119 * 3) non-aligned part at the end
1120 */
1121 FieldDatumByteOffset = 0;
1122 DatumOffset= 0;

--- 151 unchanged lines hidden ---