Rev 1498 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1498 | Rev 2216 | ||
---|---|---|---|
1 | /****************************************************************************** |
1 | /****************************************************************************** |
2 | * |
2 | * |
3 | * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities |
3 | * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities |
4 | * |
4 | * |
5 | *****************************************************************************/ |
5 | *****************************************************************************/ |
6 | 6 | ||
7 | /****************************************************************************** |
7 | /****************************************************************************** |
8 | * |
8 | * |
9 | * 1. Copyright Notice |
9 | * 1. Copyright Notice |
10 | * |
10 | * |
11 | * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
12 | * All rights reserved. |
12 | * All rights reserved. |
13 | * |
13 | * |
14 | * 2. License |
14 | * 2. License |
15 | * |
15 | * |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
17 | * rights. You may have additional license terms from the party that provided |
17 | * rights. You may have additional license terms from the party that provided |
18 | * you this software, covering your right to use that party's intellectual |
18 | * you this software, covering your right to use that party's intellectual |
19 | * property rights. |
19 | * property rights. |
20 | * |
20 | * |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
22 | * copy of the source code appearing in this file ("Covered Code") an |
22 | * copy of the source code appearing in this file ("Covered Code") an |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
25 | * make derivatives, distribute, use and display any portion of the Covered |
25 | * make derivatives, distribute, use and display any portion of the Covered |
26 | * Code in any form, with the right to sublicense such rights; and |
26 | * Code in any form, with the right to sublicense such rights; and |
27 | * |
27 | * |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
29 | * license (with the right to sublicense), under only those claims of Intel |
29 | * license (with the right to sublicense), under only those claims of Intel |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
32 | * solely to the minimum extent necessary to exercise the above copyright |
32 | * solely to the minimum extent necessary to exercise the above copyright |
33 | * license, and in no event shall the patent license extend to any additions |
33 | * license, and in no event shall the patent license extend to any additions |
34 | * to or modifications of the Original Intel Code. No other license or right |
34 | * to or modifications of the Original Intel Code. No other license or right |
35 | * is granted directly or by implication, estoppel or otherwise; |
35 | * is granted directly or by implication, estoppel or otherwise; |
36 | * |
36 | * |
37 | * The above copyright and patent license is granted only if the following |
37 | * The above copyright and patent license is granted only if the following |
38 | * conditions are met: |
38 | * conditions are met: |
39 | * |
39 | * |
40 | * 3. Conditions |
40 | * 3. Conditions |
41 | * |
41 | * |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
43 | * Redistribution of source code of any substantial portion of the Covered |
43 | * Redistribution of source code of any substantial portion of the Covered |
44 | * Code or modification with rights to further distribute source must include |
44 | * Code or modification with rights to further distribute source must include |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
48 | * contain a file documenting the changes Licensee made to create that Covered |
48 | * contain a file documenting the changes Licensee made to create that Covered |
49 | * Code and the date of any change. Licensee must include in that file the |
49 | * Code and the date of any change. Licensee must include in that file the |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
51 | * must include a prominent statement that the modification is derived, |
51 | * must include a prominent statement that the modification is derived, |
52 | * directly or indirectly, from Original Intel Code. |
52 | * directly or indirectly, from Original Intel Code. |
53 | * |
53 | * |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
55 | * Redistribution of source code of any substantial portion of the Covered |
55 | * Redistribution of source code of any substantial portion of the Covered |
56 | * Code or modification without rights to further distribute source must |
56 | * Code or modification without rights to further distribute source must |
57 | * include the following Disclaimer and Export Compliance provision in the |
57 | * include the following Disclaimer and Export Compliance provision in the |
58 | * documentation and/or other materials provided with distribution. In |
58 | * documentation and/or other materials provided with distribution. In |
59 | * addition, Licensee may not authorize further sublicense of source of any |
59 | * addition, Licensee may not authorize further sublicense of source of any |
60 | * portion of the Covered Code, and must include terms to the effect that the |
60 | * portion of the Covered Code, and must include terms to the effect that the |
61 | * license from Licensee to its licensee is limited to the intellectual |
61 | * license from Licensee to its licensee is limited to the intellectual |
62 | * property embodied in the software Licensee provides to its licensee, and |
62 | * property embodied in the software Licensee provides to its licensee, and |
63 | * not to intellectual property embodied in modifications its licensee may |
63 | * not to intellectual property embodied in modifications its licensee may |
64 | * make. |
64 | * make. |
65 | * |
65 | * |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
67 | * substantial portion of the Covered Code or modification must reproduce the |
67 | * substantial portion of the Covered Code or modification must reproduce the |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
69 | * provision in the documentation and/or other materials provided with the |
69 | * provision in the documentation and/or other materials provided with the |
70 | * distribution. |
70 | * distribution. |
71 | * |
71 | * |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
73 | * Intel Code. |
73 | * Intel Code. |
74 | * |
74 | * |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
77 | * other dealings in products derived from or relating to the Covered Code |
77 | * other dealings in products derived from or relating to the Covered Code |
78 | * without prior written authorization from Intel. |
78 | * without prior written authorization from Intel. |
79 | * |
79 | * |
80 | * 4. Disclaimer and Export Compliance |
80 | * 4. Disclaimer and Export Compliance |
81 | * |
81 | * |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
88 | * PARTICULAR PURPOSE. |
88 | * PARTICULAR PURPOSE. |
89 | * |
89 | * |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
97 | * LIMITED REMEDY. |
97 | * LIMITED REMEDY. |
98 | * |
98 | * |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
100 | * software or system incorporating such software without first obtaining any |
100 | * software or system incorporating such software without first obtaining any |
101 | * required license or other approval from the U. S. Department of Commerce or |
101 | * required license or other approval from the U. S. Department of Commerce or |
102 | * any other agency or department of the United States Government. In the |
102 | * any other agency or department of the United States Government. In the |
103 | * event Licensee exports any such software from the United States or |
103 | * event Licensee exports any such software from the United States or |
104 | * re-exports any such software from a foreign destination, Licensee shall |
104 | * re-exports any such software from a foreign destination, Licensee shall |
105 | * ensure that the distribution and export/re-export of the software is in |
105 | * ensure that the distribution and export/re-export of the software is in |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
109 | * software, or service, directly or indirectly, to any country for which the |
109 | * software, or service, directly or indirectly, to any country for which the |
110 | * United States government or any agency thereof requires an export license, |
110 | * United States government or any agency thereof requires an export license, |
111 | * other governmental approval, or letter of assurance, without first obtaining |
111 | * other governmental approval, or letter of assurance, without first obtaining |
112 | * such license, approval or letter. |
112 | * such license, approval or letter. |
113 | * |
113 | * |
114 | *****************************************************************************/ |
114 | *****************************************************************************/ |
115 | 115 | ||
116 | #define __EXPREP_C__ |
116 | #define __EXPREP_C__ |
117 | 117 | ||
118 | #include "acpi.h" |
118 | #include "acpi.h" |
119 | #include "accommon.h" |
119 | #include "accommon.h" |
120 | #include "acinterp.h" |
120 | #include "acinterp.h" |
121 | #include "amlcode.h" |
121 | #include "amlcode.h" |
122 | #include "acnamesp.h" |
122 | #include "acnamesp.h" |
123 | 123 | ||
124 | 124 | ||
125 | #define _COMPONENT ACPI_EXECUTER |
125 | #define _COMPONENT ACPI_EXECUTER |
126 | ACPI_MODULE_NAME ("exprep") |
126 | ACPI_MODULE_NAME ("exprep") |
127 | 127 | ||
128 | /* Local prototypes */ |
128 | /* Local prototypes */ |
129 | 129 | ||
130 | static UINT32 |
130 | static UINT32 |
131 | AcpiExDecodeFieldAccess ( |
131 | AcpiExDecodeFieldAccess ( |
132 | ACPI_OPERAND_OBJECT *ObjDesc, |
132 | ACPI_OPERAND_OBJECT *ObjDesc, |
133 | UINT8 FieldFlags, |
133 | UINT8 FieldFlags, |
134 | UINT32 *ReturnByteAlignment); |
134 | UINT32 *ReturnByteAlignment); |
135 | 135 | ||
136 | 136 | ||
137 | #ifdef ACPI_UNDER_DEVELOPMENT |
137 | #ifdef ACPI_UNDER_DEVELOPMENT |
138 | 138 | ||
139 | static UINT32 |
139 | static UINT32 |
140 | AcpiExGenerateAccess ( |
140 | AcpiExGenerateAccess ( |
141 | UINT32 FieldBitOffset, |
141 | UINT32 FieldBitOffset, |
142 | UINT32 FieldBitLength, |
142 | UINT32 FieldBitLength, |
143 | UINT32 RegionLength); |
143 | UINT32 RegionLength); |
144 | 144 | ||
145 | /******************************************************************************* |
145 | /******************************************************************************* |
146 | * |
146 | * |
147 | * FUNCTION: AcpiExGenerateAccess |
147 | * FUNCTION: AcpiExGenerateAccess |
148 | * |
148 | * |
149 | * PARAMETERS: FieldBitOffset - Start of field within parent region/buffer |
149 | * PARAMETERS: FieldBitOffset - Start of field within parent region/buffer |
150 | * FieldBitLength - Length of field in bits |
150 | * FieldBitLength - Length of field in bits |
151 | * RegionLength - Length of parent in bytes |
151 | * RegionLength - Length of parent in bytes |
152 | * |
152 | * |
153 | * RETURN: Field granularity (8, 16, 32 or 64) and |
153 | * RETURN: Field granularity (8, 16, 32 or 64) and |
154 | * ByteAlignment (1, 2, 3, or 4) |
154 | * ByteAlignment (1, 2, 3, or 4) |
155 | * |
155 | * |
156 | * DESCRIPTION: Generate an optimal access width for fields defined with the |
156 | * DESCRIPTION: Generate an optimal access width for fields defined with the |
157 | * AnyAcc keyword. |
157 | * AnyAcc keyword. |
158 | * |
158 | * |
159 | * NOTE: Need to have the RegionLength in order to check for boundary |
159 | * NOTE: Need to have the RegionLength in order to check for boundary |
160 | * conditions (end-of-region). However, the RegionLength is a deferred |
160 | * conditions (end-of-region). However, the RegionLength is a deferred |
161 | * operation. Therefore, to complete this implementation, the generation |
161 | * operation. Therefore, to complete this implementation, the generation |
162 | * of this access width must be deferred until the region length has |
162 | * of this access width must be deferred until the region length has |
163 | * been evaluated. |
163 | * been evaluated. |
164 | * |
164 | * |
165 | ******************************************************************************/ |
165 | ******************************************************************************/ |
166 | 166 | ||
167 | static UINT32 |
167 | static UINT32 |
168 | AcpiExGenerateAccess ( |
168 | AcpiExGenerateAccess ( |
169 | UINT32 FieldBitOffset, |
169 | UINT32 FieldBitOffset, |
170 | UINT32 FieldBitLength, |
170 | UINT32 FieldBitLength, |
171 | UINT32 RegionLength) |
171 | UINT32 RegionLength) |
172 | { |
172 | { |
173 | UINT32 FieldByteLength; |
173 | UINT32 FieldByteLength; |
174 | UINT32 FieldByteOffset; |
174 | UINT32 FieldByteOffset; |
175 | UINT32 FieldByteEndOffset; |
175 | UINT32 FieldByteEndOffset; |
176 | UINT32 AccessByteWidth; |
176 | UINT32 AccessByteWidth; |
177 | UINT32 FieldStartOffset; |
177 | UINT32 FieldStartOffset; |
178 | UINT32 FieldEndOffset; |
178 | UINT32 FieldEndOffset; |
179 | UINT32 MinimumAccessWidth = 0xFFFFFFFF; |
179 | UINT32 MinimumAccessWidth = 0xFFFFFFFF; |
180 | UINT32 MinimumAccesses = 0xFFFFFFFF; |
180 | UINT32 MinimumAccesses = 0xFFFFFFFF; |
181 | UINT32 Accesses; |
181 | UINT32 Accesses; |
182 | 182 | ||
183 | 183 | ||
184 | ACPI_FUNCTION_TRACE (ExGenerateAccess); |
184 | ACPI_FUNCTION_TRACE (ExGenerateAccess); |
185 | 185 | ||
186 | 186 | ||
187 | /* Round Field start offset and length to "minimal" byte boundaries */ |
187 | /* Round Field start offset and length to "minimal" byte boundaries */ |
188 | 188 | ||
189 | FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8)); |
189 | FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8)); |
190 | FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + |
190 | FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + |
191 | FieldBitOffset, 8)); |
191 | FieldBitOffset, 8)); |
192 | FieldByteLength = FieldByteEndOffset - FieldByteOffset; |
192 | FieldByteLength = FieldByteEndOffset - FieldByteOffset; |
193 | 193 | ||
194 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
194 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
195 | "Bit length %u, Bit offset %u\n", |
195 | "Bit length %u, Bit offset %u\n", |
196 | FieldBitLength, FieldBitOffset)); |
196 | FieldBitLength, FieldBitOffset)); |
197 | 197 | ||
198 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
198 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
199 | "Byte Length %u, Byte Offset %u, End Offset %u\n", |
199 | "Byte Length %u, Byte Offset %u, End Offset %u\n", |
200 | FieldByteLength, FieldByteOffset, FieldByteEndOffset)); |
200 | FieldByteLength, FieldByteOffset, FieldByteEndOffset)); |
201 | 201 | ||
202 | /* |
202 | /* |
203 | * Iterative search for the maximum access width that is both aligned |
203 | * Iterative search for the maximum access width that is both aligned |
204 | * and does not go beyond the end of the region |
204 | * and does not go beyond the end of the region |
205 | * |
205 | * |
206 | * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes) |
206 | * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes) |
207 | */ |
207 | */ |
208 | for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1) |
208 | for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1) |
209 | { |
209 | { |
210 | /* |
210 | /* |
211 | * 1) Round end offset up to next access boundary and make sure that |
211 | * 1) Round end offset up to next access boundary and make sure that |
212 | * this does not go beyond the end of the parent region. |
212 | * this does not go beyond the end of the parent region. |
213 | * 2) When the Access width is greater than the FieldByteLength, we |
213 | * 2) When the Access width is greater than the FieldByteLength, we |
214 | * are done. (This does not optimize for the perfectly aligned |
214 | * are done. (This does not optimize for the perfectly aligned |
215 | * case yet). |
215 | * case yet). |
216 | */ |
216 | */ |
217 | if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength) |
217 | if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength) |
218 | { |
218 | { |
219 | FieldStartOffset = |
219 | FieldStartOffset = |
220 | ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / |
220 | ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / |
221 | AccessByteWidth; |
221 | AccessByteWidth; |
222 | 222 | ||
223 | FieldEndOffset = |
223 | FieldEndOffset = |
224 | ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), |
224 | ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), |
225 | AccessByteWidth) / AccessByteWidth; |
225 | AccessByteWidth) / AccessByteWidth; |
226 | 226 | ||
227 | Accesses = FieldEndOffset - FieldStartOffset; |
227 | Accesses = FieldEndOffset - FieldStartOffset; |
228 | 228 | ||
229 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
229 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
230 | "AccessWidth %u end is within region\n", AccessByteWidth)); |
230 | "AccessWidth %u end is within region\n", AccessByteWidth)); |
231 | 231 | ||
232 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
232 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
233 | "Field Start %u, Field End %u -- requires %u accesses\n", |
233 | "Field Start %u, Field End %u -- requires %u accesses\n", |
234 | FieldStartOffset, FieldEndOffset, Accesses)); |
234 | FieldStartOffset, FieldEndOffset, Accesses)); |
235 | 235 | ||
236 | /* Single access is optimal */ |
236 | /* Single access is optimal */ |
237 | 237 | ||
238 | if (Accesses <= 1) |
238 | if (Accesses <= 1) |
239 | { |
239 | { |
240 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
240 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
241 | "Entire field can be accessed with one operation of size %u\n", |
241 | "Entire field can be accessed with one operation of size %u\n", |
242 | AccessByteWidth)); |
242 | AccessByteWidth)); |
243 | return_VALUE (AccessByteWidth); |
243 | return_VALUE (AccessByteWidth); |
244 | } |
244 | } |
245 | 245 | ||
246 | /* |
246 | /* |
247 | * Fits in the region, but requires more than one read/write. |
247 | * Fits in the region, but requires more than one read/write. |
248 | * try the next wider access on next iteration |
248 | * try the next wider access on next iteration |
249 | */ |
249 | */ |
250 | if (Accesses < MinimumAccesses) |
250 | if (Accesses < MinimumAccesses) |
251 | { |
251 | { |
252 | MinimumAccesses = Accesses; |
252 | MinimumAccesses = Accesses; |
253 | MinimumAccessWidth = AccessByteWidth; |
253 | MinimumAccessWidth = AccessByteWidth; |
254 | } |
254 | } |
255 | } |
255 | } |
256 | else |
256 | else |
257 | { |
257 | { |
258 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
258 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
259 | "AccessWidth %u end is NOT within region\n", AccessByteWidth)); |
259 | "AccessWidth %u end is NOT within region\n", AccessByteWidth)); |
260 | if (AccessByteWidth == 1) |
260 | if (AccessByteWidth == 1) |
261 | { |
261 | { |
262 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
262 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
263 | "Field goes beyond end-of-region!\n")); |
263 | "Field goes beyond end-of-region!\n")); |
264 | 264 | ||
265 | /* Field does not fit in the region at all */ |
265 | /* Field does not fit in the region at all */ |
266 | 266 | ||
267 | return_VALUE (0); |
267 | return_VALUE (0); |
268 | } |
268 | } |
269 | 269 | ||
270 | /* |
270 | /* |
271 | * This width goes beyond the end-of-region, back off to |
271 | * This width goes beyond the end-of-region, back off to |
272 | * previous access |
272 | * previous access |
273 | */ |
273 | */ |
274 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
274 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
275 | "Backing off to previous optimal access width of %u\n", |
275 | "Backing off to previous optimal access width of %u\n", |
276 | MinimumAccessWidth)); |
276 | MinimumAccessWidth)); |
277 | return_VALUE (MinimumAccessWidth); |
277 | return_VALUE (MinimumAccessWidth); |
278 | } |
278 | } |
279 | } |
279 | } |
280 | 280 | ||
281 | /* |
281 | /* |
282 | * Could not read/write field with one operation, |
282 | * Could not read/write field with one operation, |
283 | * just use max access width |
283 | * just use max access width |
284 | */ |
284 | */ |
285 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
285 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
286 | "Cannot access field in one operation, using width 8\n")); |
286 | "Cannot access field in one operation, using width 8\n")); |
287 | return_VALUE (8); |
287 | return_VALUE (8); |
288 | } |
288 | } |
289 | #endif /* ACPI_UNDER_DEVELOPMENT */ |
289 | #endif /* ACPI_UNDER_DEVELOPMENT */ |
290 | 290 | ||
291 | 291 | ||
292 | /******************************************************************************* |
292 | /******************************************************************************* |
293 | * |
293 | * |
294 | * FUNCTION: AcpiExDecodeFieldAccess |
294 | * FUNCTION: AcpiExDecodeFieldAccess |
295 | * |
295 | * |
296 | * PARAMETERS: ObjDesc - Field object |
296 | * PARAMETERS: ObjDesc - Field object |
297 | * FieldFlags - Encoded fieldflags (contains access bits) |
297 | * FieldFlags - Encoded fieldflags (contains access bits) |
298 | * ReturnByteAlignment - Where the byte alignment is returned |
298 | * ReturnByteAlignment - Where the byte alignment is returned |
299 | * |
299 | * |
300 | * RETURN: Field granularity (8, 16, 32 or 64) and |
300 | * RETURN: Field granularity (8, 16, 32 or 64) and |
301 | * ByteAlignment (1, 2, 3, or 4) |
301 | * ByteAlignment (1, 2, 3, or 4) |
302 | * |
302 | * |
303 | * DESCRIPTION: Decode the AccessType bits of a field definition. |
303 | * DESCRIPTION: Decode the AccessType bits of a field definition. |
304 | * |
304 | * |
305 | ******************************************************************************/ |
305 | ******************************************************************************/ |
306 | 306 | ||
307 | static UINT32 |
307 | static UINT32 |
308 | AcpiExDecodeFieldAccess ( |
308 | AcpiExDecodeFieldAccess ( |
309 | ACPI_OPERAND_OBJECT *ObjDesc, |
309 | ACPI_OPERAND_OBJECT *ObjDesc, |
310 | UINT8 FieldFlags, |
310 | UINT8 FieldFlags, |
311 | UINT32 *ReturnByteAlignment) |
311 | UINT32 *ReturnByteAlignment) |
312 | { |
312 | { |
313 | UINT32 Access; |
313 | UINT32 Access; |
314 | UINT32 ByteAlignment; |
314 | UINT32 ByteAlignment; |
315 | UINT32 BitLength; |
315 | UINT32 BitLength; |
316 | 316 | ||
317 | 317 | ||
318 | ACPI_FUNCTION_TRACE (ExDecodeFieldAccess); |
318 | ACPI_FUNCTION_TRACE (ExDecodeFieldAccess); |
319 | 319 | ||
320 | 320 | ||
321 | Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK); |
321 | Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK); |
322 | 322 | ||
323 | switch (Access) |
323 | switch (Access) |
324 | { |
324 | { |
325 | case AML_FIELD_ACCESS_ANY: |
325 | case AML_FIELD_ACCESS_ANY: |
326 | 326 | ||
327 | #ifdef ACPI_UNDER_DEVELOPMENT |
327 | #ifdef ACPI_UNDER_DEVELOPMENT |
328 | ByteAlignment = |
328 | ByteAlignment = |
329 | AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, |
329 | AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, |
330 | ObjDesc->CommonField.BitLength, |
330 | ObjDesc->CommonField.BitLength, |
331 | 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */); |
331 | 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */); |
332 | BitLength = ByteAlignment * 8; |
332 | BitLength = ByteAlignment * 8; |
333 | #endif |
333 | #endif |
334 | 334 | ||
335 | ByteAlignment = 1; |
335 | ByteAlignment = 1; |
336 | BitLength = 8; |
336 | BitLength = 8; |
337 | break; |
337 | break; |
338 | 338 | ||
339 | case AML_FIELD_ACCESS_BYTE: |
339 | case AML_FIELD_ACCESS_BYTE: |
340 | case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ |
340 | case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ |
341 | ByteAlignment = 1; |
341 | ByteAlignment = 1; |
342 | BitLength = 8; |
342 | BitLength = 8; |
343 | break; |
343 | break; |
344 | 344 | ||
345 | case AML_FIELD_ACCESS_WORD: |
345 | case AML_FIELD_ACCESS_WORD: |
346 | ByteAlignment = 2; |
346 | ByteAlignment = 2; |
347 | BitLength = 16; |
347 | BitLength = 16; |
348 | break; |
348 | break; |
349 | 349 | ||
350 | case AML_FIELD_ACCESS_DWORD: |
350 | case AML_FIELD_ACCESS_DWORD: |
351 | ByteAlignment = 4; |
351 | ByteAlignment = 4; |
352 | BitLength = 32; |
352 | BitLength = 32; |
353 | break; |
353 | break; |
354 | 354 | ||
355 | case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ |
355 | case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ |
356 | ByteAlignment = 8; |
356 | ByteAlignment = 8; |
357 | BitLength = 64; |
357 | BitLength = 64; |
358 | break; |
358 | break; |
359 | 359 | ||
360 | default: |
360 | default: |
361 | /* Invalid field access type */ |
361 | /* Invalid field access type */ |
362 | 362 | ||
363 | ACPI_ERROR ((AE_INFO, |
363 | ACPI_ERROR ((AE_INFO, |
364 | "Unknown field access type 0x%X", |
364 | "Unknown field access type 0x%X", |
365 | Access)); |
365 | Access)); |
366 | return_UINT32 (0); |
366 | return_UINT32 (0); |
367 | } |
367 | } |
368 | 368 | ||
369 | if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) |
369 | if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) |
370 | { |
370 | { |
371 | /* |
371 | /* |
372 | * BufferField access can be on any byte boundary, so the |
372 | * BufferField access can be on any byte boundary, so the |
373 | * ByteAlignment is always 1 byte -- regardless of any ByteAlignment |
373 | * ByteAlignment is always 1 byte -- regardless of any ByteAlignment |
374 | * implied by the field access type. |
374 | * implied by the field access type. |
375 | */ |
375 | */ |
376 | ByteAlignment = 1; |
376 | ByteAlignment = 1; |
377 | } |
377 | } |
378 | 378 | ||
379 | *ReturnByteAlignment = ByteAlignment; |
379 | *ReturnByteAlignment = ByteAlignment; |
380 | return_UINT32 (BitLength); |
380 | return_UINT32 (BitLength); |
381 | } |
381 | } |
382 | 382 | ||
383 | 383 | ||
384 | /******************************************************************************* |
384 | /******************************************************************************* |
385 | * |
385 | * |
386 | * FUNCTION: AcpiExPrepCommonFieldObject |
386 | * FUNCTION: AcpiExPrepCommonFieldObject |
387 | * |
387 | * |
388 | * PARAMETERS: ObjDesc - The field object |
388 | * PARAMETERS: ObjDesc - The field object |
389 | * FieldFlags - Access, LockRule, and UpdateRule. |
389 | * FieldFlags - Access, LockRule, and UpdateRule. |
390 | * The format of a FieldFlag is described |
390 | * The format of a FieldFlag is described |
391 | * in the ACPI specification |
391 | * in the ACPI specification |
392 | * FieldAttribute - Special attributes (not used) |
392 | * FieldAttribute - Special attributes (not used) |
393 | * FieldBitPosition - Field start position |
393 | * FieldBitPosition - Field start position |
394 | * FieldBitLength - Field length in number of bits |
394 | * FieldBitLength - Field length in number of bits |
395 | * |
395 | * |
396 | * RETURN: Status |
396 | * RETURN: Status |
397 | * |
397 | * |
398 | * DESCRIPTION: Initialize the areas of the field object that are common |
398 | * DESCRIPTION: Initialize the areas of the field object that are common |
399 | * to the various types of fields. Note: This is very "sensitive" |
399 | * to the various types of fields. Note: This is very "sensitive" |
400 | * code because we are solving the general case for field |
400 | * code because we are solving the general case for field |
401 | * alignment. |
401 | * alignment. |
402 | * |
402 | * |
403 | ******************************************************************************/ |
403 | ******************************************************************************/ |
404 | 404 | ||
405 | ACPI_STATUS |
405 | ACPI_STATUS |
406 | AcpiExPrepCommonFieldObject ( |
406 | AcpiExPrepCommonFieldObject ( |
407 | ACPI_OPERAND_OBJECT *ObjDesc, |
407 | ACPI_OPERAND_OBJECT *ObjDesc, |
408 | UINT8 FieldFlags, |
408 | UINT8 FieldFlags, |
409 | UINT8 FieldAttribute, |
409 | UINT8 FieldAttribute, |
410 | UINT32 FieldBitPosition, |
410 | UINT32 FieldBitPosition, |
411 | UINT32 FieldBitLength) |
411 | UINT32 FieldBitLength) |
412 | { |
412 | { |
413 | UINT32 AccessBitWidth; |
413 | UINT32 AccessBitWidth; |
414 | UINT32 ByteAlignment; |
414 | UINT32 ByteAlignment; |
415 | UINT32 NearestByteAddress; |
415 | UINT32 NearestByteAddress; |
416 | 416 | ||
417 | 417 | ||
418 | ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject); |
418 | ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject); |
419 | 419 | ||
420 | 420 | ||
421 | /* |
421 | /* |
422 | * Note: the structure being initialized is the |
422 | * Note: the structure being initialized is the |
423 | * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common |
423 | * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common |
424 | * area are initialized by this procedure. |
424 | * area are initialized by this procedure. |
425 | */ |
425 | */ |
426 | ObjDesc->CommonField.FieldFlags = FieldFlags; |
426 | ObjDesc->CommonField.FieldFlags = FieldFlags; |
427 | ObjDesc->CommonField.Attribute = FieldAttribute; |
427 | ObjDesc->CommonField.Attribute = FieldAttribute; |
428 | ObjDesc->CommonField.BitLength = FieldBitLength; |
428 | ObjDesc->CommonField.BitLength = FieldBitLength; |
429 | 429 | ||
430 | /* |
430 | /* |
431 | * Decode the access type so we can compute offsets. The access type gives |
431 | * Decode the access type so we can compute offsets. The access type gives |
432 | * two pieces of information - the width of each field access and the |
432 | * two pieces of information - the width of each field access and the |
433 | * necessary ByteAlignment (address granularity) of the access. |
433 | * necessary ByteAlignment (address granularity) of the access. |
434 | * |
434 | * |
435 | * For AnyAcc, the AccessBitWidth is the largest width that is both |
435 | * For AnyAcc, the AccessBitWidth is the largest width that is both |
436 | * necessary and possible in an attempt to access the whole field in one |
436 | * necessary and possible in an attempt to access the whole field in one |
437 | * I/O operation. However, for AnyAcc, the ByteAlignment is always one |
437 | * I/O operation. However, for AnyAcc, the ByteAlignment is always one |
438 | * byte. |
438 | * byte. |
439 | * |
439 | * |
440 | * For all Buffer Fields, the ByteAlignment is always one byte. |
440 | * For all Buffer Fields, the ByteAlignment is always one byte. |
441 | * |
441 | * |
442 | * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is |
442 | * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is |
443 | * the same (equivalent) as the ByteAlignment. |
443 | * the same (equivalent) as the ByteAlignment. |
444 | */ |
444 | */ |
445 | AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags, |
445 | AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags, |
446 | &ByteAlignment); |
446 | &ByteAlignment); |
447 | if (!AccessBitWidth) |
447 | if (!AccessBitWidth) |
448 | { |
448 | { |
449 | return_ACPI_STATUS (AE_AML_OPERAND_VALUE); |
449 | return_ACPI_STATUS (AE_AML_OPERAND_VALUE); |
450 | } |
450 | } |
451 | 451 | ||
452 | /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */ |
452 | /* Setup width (access granularity) fields (values are: 1, 2, 4, 8) */ |
453 | 453 | ||
454 | ObjDesc->CommonField.AccessByteWidth = (UINT8) |
454 | ObjDesc->CommonField.AccessByteWidth = (UINT8) |
455 | ACPI_DIV_8 (AccessBitWidth); |
455 | ACPI_DIV_8 (AccessBitWidth); |
456 | 456 | ||
457 | /* |
457 | /* |
458 | * BaseByteOffset is the address of the start of the field within the |
458 | * BaseByteOffset is the address of the start of the field within the |
459 | * region. It is the byte address of the first *datum* (field-width data |
459 | * region. It is the byte address of the first *datum* (field-width data |
460 | * unit) of the field. (i.e., the first datum that contains at least the |
460 | * unit) of the field. (i.e., the first datum that contains at least the |
461 | * first *bit* of the field.) |
461 | * first *bit* of the field.) |
462 | * |
462 | * |
463 | * Note: ByteAlignment is always either equal to the AccessBitWidth or 8 |
463 | * Note: ByteAlignment is always either equal to the AccessBitWidth or 8 |
464 | * (Byte access), and it defines the addressing granularity of the parent |
464 | * (Byte access), and it defines the addressing granularity of the parent |
465 | * region or buffer. |
465 | * region or buffer. |
466 | */ |
466 | */ |
467 | NearestByteAddress = |
467 | NearestByteAddress = |
468 | ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition); |
468 | ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition); |
469 | ObjDesc->CommonField.BaseByteOffset = (UINT32) |
469 | ObjDesc->CommonField.BaseByteOffset = (UINT32) |
470 | ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment); |
470 | ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment); |
471 | 471 | ||
472 | /* |
472 | /* |
473 | * StartFieldBitOffset is the offset of the first bit of the field within |
473 | * StartFieldBitOffset is the offset of the first bit of the field within |
474 | * a field datum. |
474 | * a field datum. |
475 | */ |
475 | */ |
476 | ObjDesc->CommonField.StartFieldBitOffset = (UINT8) |
476 | ObjDesc->CommonField.StartFieldBitOffset = (UINT8) |
477 | (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset)); |
477 | (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset)); |
478 | 478 | ||
479 | return_ACPI_STATUS (AE_OK); |
479 | return_ACPI_STATUS (AE_OK); |
480 | } |
480 | } |
481 | 481 | ||
482 | 482 | ||
483 | /******************************************************************************* |
483 | /******************************************************************************* |
484 | * |
484 | * |
485 | * FUNCTION: AcpiExPrepFieldValue |
485 | * FUNCTION: AcpiExPrepFieldValue |
486 | * |
486 | * |
487 | * PARAMETERS: Info - Contains all field creation info |
487 | * PARAMETERS: Info - Contains all field creation info |
488 | * |
488 | * |
489 | * RETURN: Status |
489 | * RETURN: Status |
490 | * |
490 | * |
491 | * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and |
491 | * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and |
492 | * connect it to the parent Node. |
492 | * connect it to the parent Node. |
493 | * |
493 | * |
494 | ******************************************************************************/ |
494 | ******************************************************************************/ |
495 | 495 | ||
496 | ACPI_STATUS |
496 | ACPI_STATUS |
497 | AcpiExPrepFieldValue ( |
497 | AcpiExPrepFieldValue ( |
498 | ACPI_CREATE_FIELD_INFO *Info) |
498 | ACPI_CREATE_FIELD_INFO *Info) |
499 | { |
499 | { |
500 | ACPI_OPERAND_OBJECT *ObjDesc; |
500 | ACPI_OPERAND_OBJECT *ObjDesc; |
501 | ACPI_OPERAND_OBJECT *SecondDesc = NULL; |
501 | ACPI_OPERAND_OBJECT *SecondDesc = NULL; |
502 | ACPI_STATUS Status; |
502 | ACPI_STATUS Status; |
503 | UINT32 AccessByteWidth; |
503 | UINT32 AccessByteWidth; |
504 | UINT32 Type; |
504 | UINT32 Type; |
505 | 505 | ||
506 | 506 | ||
507 | ACPI_FUNCTION_TRACE (ExPrepFieldValue); |
507 | ACPI_FUNCTION_TRACE (ExPrepFieldValue); |
508 | 508 | ||
509 | 509 | ||
510 | /* Parameter validation */ |
510 | /* Parameter validation */ |
511 | 511 | ||
512 | if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD) |
512 | if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD) |
513 | { |
513 | { |
514 | if (!Info->RegionNode) |
514 | if (!Info->RegionNode) |
515 | { |
515 | { |
516 | ACPI_ERROR ((AE_INFO, "Null RegionNode")); |
516 | ACPI_ERROR ((AE_INFO, "Null RegionNode")); |
517 | return_ACPI_STATUS (AE_AML_NO_OPERAND); |
517 | return_ACPI_STATUS (AE_AML_NO_OPERAND); |
518 | } |
518 | } |
519 | 519 | ||
520 | Type = AcpiNsGetType (Info->RegionNode); |
520 | Type = AcpiNsGetType (Info->RegionNode); |
521 | if (Type != ACPI_TYPE_REGION) |
521 | if (Type != ACPI_TYPE_REGION) |
522 | { |
522 | { |
523 | ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)", |
523 | ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)", |
524 | Type, AcpiUtGetTypeName (Type))); |
524 | Type, AcpiUtGetTypeName (Type))); |
525 | 525 | ||
526 | return_ACPI_STATUS (AE_AML_OPERAND_TYPE); |
526 | return_ACPI_STATUS (AE_AML_OPERAND_TYPE); |
527 | } |
527 | } |
528 | } |
528 | } |
529 | 529 | ||
530 | /* Allocate a new field object */ |
530 | /* Allocate a new field object */ |
531 | 531 | ||
532 | ObjDesc = AcpiUtCreateInternalObject (Info->FieldType); |
532 | ObjDesc = AcpiUtCreateInternalObject (Info->FieldType); |
533 | if (!ObjDesc) |
533 | if (!ObjDesc) |
534 | { |
534 | { |
535 | return_ACPI_STATUS (AE_NO_MEMORY); |
535 | return_ACPI_STATUS (AE_NO_MEMORY); |
536 | } |
536 | } |
537 | 537 | ||
538 | /* Initialize areas of the object that are common to all fields */ |
538 | /* Initialize areas of the object that are common to all fields */ |
539 | 539 | ||
540 | ObjDesc->CommonField.Node = Info->FieldNode; |
540 | ObjDesc->CommonField.Node = Info->FieldNode; |
541 | Status = AcpiExPrepCommonFieldObject (ObjDesc, |
541 | Status = AcpiExPrepCommonFieldObject (ObjDesc, |
542 | Info->FieldFlags, Info->Attribute, |
542 | Info->FieldFlags, Info->Attribute, |
543 | Info->FieldBitPosition, Info->FieldBitLength); |
543 | Info->FieldBitPosition, Info->FieldBitLength); |
544 | if (ACPI_FAILURE (Status)) |
544 | if (ACPI_FAILURE (Status)) |
545 | { |
545 | { |
546 | AcpiUtDeleteObjectDesc (ObjDesc); |
546 | AcpiUtDeleteObjectDesc (ObjDesc); |
547 | return_ACPI_STATUS (Status); |
547 | return_ACPI_STATUS (Status); |
548 | } |
548 | } |
549 | 549 | ||
550 | /* Initialize areas of the object that are specific to the field type */ |
550 | /* Initialize areas of the object that are specific to the field type */ |
551 | 551 | ||
552 | switch (Info->FieldType) |
552 | switch (Info->FieldType) |
553 | { |
553 | { |
554 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
554 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
555 | 555 | ||
556 | ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); |
556 | ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); |
557 | 557 | ||
558 | /* Allow full data read from EC address space */ |
558 | /* Allow full data read from EC address space */ |
559 | 559 | ||
560 | if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) && |
560 | if ((ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_EC) && |
561 | (ObjDesc->CommonField.BitLength > 8)) |
561 | (ObjDesc->CommonField.BitLength > 8)) |
562 | { |
562 | { |
563 | AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES ( |
563 | AccessByteWidth = ACPI_ROUND_BITS_UP_TO_BYTES ( |
564 | ObjDesc->CommonField.BitLength); |
564 | ObjDesc->CommonField.BitLength); |
565 | 565 | ||
566 | /* Maximum byte width supported is 255 */ |
566 | /* Maximum byte width supported is 255 */ |
567 | 567 | ||
568 | if (AccessByteWidth < 256) |
568 | if (AccessByteWidth < 256) |
569 | { |
569 | { |
570 | ObjDesc->CommonField.AccessByteWidth = (UINT8) AccessByteWidth; |
570 | ObjDesc->CommonField.AccessByteWidth = (UINT8) AccessByteWidth; |
571 | } |
571 | } |
572 | } |
572 | } |
573 | 573 | ||
574 | /* An additional reference for the container */ |
574 | /* An additional reference for the container */ |
575 | 575 | ||
576 | AcpiUtAddReference (ObjDesc->Field.RegionObj); |
576 | AcpiUtAddReference (ObjDesc->Field.RegionObj); |
577 | 577 | ||
578 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
578 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
579 | "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", |
579 | "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", |
580 | ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset, |
580 | ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset, |
581 | ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj)); |
581 | ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj)); |
582 | break; |
582 | break; |
583 | 583 | ||
584 | 584 | ||
585 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
585 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
586 | 586 | ||
587 | ObjDesc->BankField.Value = Info->BankValue; |
587 | ObjDesc->BankField.Value = Info->BankValue; |
588 | ObjDesc->BankField.RegionObj = |
588 | ObjDesc->BankField.RegionObj = |
589 | AcpiNsGetAttachedObject (Info->RegionNode); |
589 | AcpiNsGetAttachedObject (Info->RegionNode); |
590 | ObjDesc->BankField.BankObj = |
590 | ObjDesc->BankField.BankObj = |
591 | AcpiNsGetAttachedObject (Info->RegisterNode); |
591 | AcpiNsGetAttachedObject (Info->RegisterNode); |
592 | 592 | ||
593 | /* An additional reference for the attached objects */ |
593 | /* An additional reference for the attached objects */ |
594 | 594 | ||
595 | AcpiUtAddReference (ObjDesc->BankField.RegionObj); |
595 | AcpiUtAddReference (ObjDesc->BankField.RegionObj); |
596 | AcpiUtAddReference (ObjDesc->BankField.BankObj); |
596 | AcpiUtAddReference (ObjDesc->BankField.BankObj); |
597 | 597 | ||
598 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
598 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
599 | "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n", |
599 | "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n", |
600 | ObjDesc->BankField.StartFieldBitOffset, |
600 | ObjDesc->BankField.StartFieldBitOffset, |
601 | ObjDesc->BankField.BaseByteOffset, |
601 | ObjDesc->BankField.BaseByteOffset, |
602 | ObjDesc->Field.AccessByteWidth, |
602 | ObjDesc->Field.AccessByteWidth, |
603 | ObjDesc->BankField.RegionObj, |
603 | ObjDesc->BankField.RegionObj, |
604 | ObjDesc->BankField.BankObj)); |
604 | ObjDesc->BankField.BankObj)); |
605 | 605 | ||
606 | /* |
606 | /* |
607 | * Remember location in AML stream of the field unit |
607 | * Remember location in AML stream of the field unit |
608 | * opcode and operands -- since the BankValue |
608 | * opcode and operands -- since the BankValue |
609 | * operands must be evaluated. |
609 | * operands must be evaluated. |
610 | */ |
610 | */ |
611 | SecondDesc = ObjDesc->Common.NextObject; |
611 | SecondDesc = ObjDesc->Common.NextObject; |
612 | SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, |
612 | SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, |
613 | Info->DataRegisterNode)->Named.Data; |
613 | Info->DataRegisterNode)->Named.Data; |
614 | SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, |
614 | SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, |
615 | Info->DataRegisterNode)->Named.Length; |
615 | Info->DataRegisterNode)->Named.Length; |
616 | 616 | ||
617 | break; |
617 | break; |
618 | 618 | ||
619 | 619 | ||
620 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
620 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
621 | 621 | ||
622 | /* Get the Index and Data registers */ |
622 | /* Get the Index and Data registers */ |
623 | 623 | ||
624 | ObjDesc->IndexField.IndexObj = |
624 | ObjDesc->IndexField.IndexObj = |
625 | AcpiNsGetAttachedObject (Info->RegisterNode); |
625 | AcpiNsGetAttachedObject (Info->RegisterNode); |
626 | ObjDesc->IndexField.DataObj = |
626 | ObjDesc->IndexField.DataObj = |
627 | AcpiNsGetAttachedObject (Info->DataRegisterNode); |
627 | AcpiNsGetAttachedObject (Info->DataRegisterNode); |
628 | 628 | ||
629 | if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) |
629 | if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) |
630 | { |
630 | { |
631 | ACPI_ERROR ((AE_INFO, "Null Index Object during field prep")); |
631 | ACPI_ERROR ((AE_INFO, "Null Index Object during field prep")); |
632 | AcpiUtDeleteObjectDesc (ObjDesc); |
632 | AcpiUtDeleteObjectDesc (ObjDesc); |
633 | return_ACPI_STATUS (AE_AML_INTERNAL); |
633 | return_ACPI_STATUS (AE_AML_INTERNAL); |
634 | } |
634 | } |
635 | 635 | ||
636 | /* An additional reference for the attached objects */ |
636 | /* An additional reference for the attached objects */ |
637 | 637 | ||
638 | AcpiUtAddReference (ObjDesc->IndexField.DataObj); |
638 | AcpiUtAddReference (ObjDesc->IndexField.DataObj); |
639 | AcpiUtAddReference (ObjDesc->IndexField.IndexObj); |
639 | AcpiUtAddReference (ObjDesc->IndexField.IndexObj); |
640 | 640 | ||
641 | /* |
641 | /* |
642 | * April 2006: Changed to match MS behavior |
642 | * April 2006: Changed to match MS behavior |
643 | * |
643 | * |
644 | * The value written to the Index register is the byte offset of the |
644 | * The value written to the Index register is the byte offset of the |
645 | * target field in units of the granularity of the IndexField |
645 | * target field in units of the granularity of the IndexField |
646 | * |
646 | * |
647 | * Previously, the value was calculated as an index in terms of the |
647 | * Previously, the value was calculated as an index in terms of the |
648 | * width of the Data register, as below: |
648 | * width of the Data register, as below: |
649 | * |
649 | * |
650 | * ObjDesc->IndexField.Value = (UINT32) |
650 | * ObjDesc->IndexField.Value = (UINT32) |
651 | * (Info->FieldBitPosition / ACPI_MUL_8 ( |
651 | * (Info->FieldBitPosition / ACPI_MUL_8 ( |
652 | * ObjDesc->Field.AccessByteWidth)); |
652 | * ObjDesc->Field.AccessByteWidth)); |
653 | * |
653 | * |
654 | * February 2006: Tried value as a byte offset: |
654 | * February 2006: Tried value as a byte offset: |
655 | * ObjDesc->IndexField.Value = (UINT32) |
655 | * ObjDesc->IndexField.Value = (UINT32) |
656 | * ACPI_DIV_8 (Info->FieldBitPosition); |
656 | * ACPI_DIV_8 (Info->FieldBitPosition); |
657 | */ |
657 | */ |
658 | ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN ( |
658 | ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN ( |
659 | ACPI_DIV_8 (Info->FieldBitPosition), |
659 | ACPI_DIV_8 (Info->FieldBitPosition), |
660 | ObjDesc->IndexField.AccessByteWidth); |
660 | ObjDesc->IndexField.AccessByteWidth); |
661 | 661 | ||
662 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
662 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, |
663 | "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", |
663 | "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", |
664 | ObjDesc->IndexField.StartFieldBitOffset, |
664 | ObjDesc->IndexField.StartFieldBitOffset, |
665 | ObjDesc->IndexField.BaseByteOffset, |
665 | ObjDesc->IndexField.BaseByteOffset, |
666 | ObjDesc->IndexField.Value, |
666 | ObjDesc->IndexField.Value, |
667 | ObjDesc->Field.AccessByteWidth, |
667 | ObjDesc->Field.AccessByteWidth, |
668 | ObjDesc->IndexField.IndexObj, |
668 | ObjDesc->IndexField.IndexObj, |
669 | ObjDesc->IndexField.DataObj)); |
669 | ObjDesc->IndexField.DataObj)); |
670 | break; |
670 | break; |
671 | 671 | ||
672 | default: |
672 | default: |
673 | /* No other types should get here */ |
673 | /* No other types should get here */ |
674 | break; |
674 | break; |
675 | } |
675 | } |
676 | 676 | ||
677 | /* |
677 | /* |
678 | * Store the constructed descriptor (ObjDesc) into the parent Node, |
678 | * Store the constructed descriptor (ObjDesc) into the parent Node, |
679 | * preserving the current type of that NamedObj. |
679 | * preserving the current type of that NamedObj. |
680 | */ |
680 | */ |
681 | Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc, |
681 | Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc, |
682 | AcpiNsGetType (Info->FieldNode)); |
682 | AcpiNsGetType (Info->FieldNode)); |
683 | 683 | ||
684 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n", |
684 | ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n", |
685 | Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc)); |
685 | Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc)); |
686 | 686 | ||
687 | /* Remove local reference to the object */ |
687 | /* Remove local reference to the object */ |
688 | 688 | ||
689 | AcpiUtRemoveReference (ObjDesc); |
689 | AcpiUtRemoveReference (ObjDesc); |
690 | return_ACPI_STATUS (Status); |
690 | return_ACPI_STATUS (Status); |
691 | }>>=>=>=><=>=> |
691 | }>>=>=>=><=>=> |