1/****************************************************************************** 2 * 3 * Module Name: exfldio - Aml Field I/O |
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 * |
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 * |
918 * FUNCTION: AcpiExExtractFromField 919 * |
920 * PARAMETERS: ObjDesc - Field to be read 921 * Buffer - Where to store the field data 922 * BufferLength - Length of Buffer |
923 * 924 * RETURN: Status 925 * |
926 * DESCRIPTION: Retrieve the current value of the given field |
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; |
942 UINT32 DatumCount; 943 UINT32 i; 944 945 946 ACPI_FUNCTION_TRACE ("ExExtractFromField"); 947 948 |
949 /* Validate buffer, compute number of datums */ |
950 |
951 Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount); 952 if (ACPI_FAILURE (Status)) |
953 { |
954 return_ACPI_STATUS (Status); |
955 } 956 |
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 * |
1078 * PARAMETERS: ObjDesc - Field to be written 1079 * Buffer - Data to be written 1080 * BufferLength - Length of Buffer |
1081 * 1082 * RETURN: Status 1083 * |
1084 * DESCRIPTION: Store the Buffer contents into the given field |
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; |
1101 UINT32 DatumCount; 1102 1103 1104 ACPI_FUNCTION_TRACE ("ExInsertIntoField"); 1105 1106 |
1107 /* Validate buffer, compute number of datums */ |
1108 |
1109 Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount); 1110 if (ACPI_FAILURE (Status)) 1111 { 1112 return_ACPI_STATUS (Status); |
1113 } 1114 |
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 --- |