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