Deleted Added
full compact
rsmisc.c (117521) rsmisc.c (126372)
1/*******************************************************************************
2 *
3 * Module Name: rsmisc - Miscellaneous resource descriptors
1/*******************************************************************************
2 *
3 * Module Name: rsmisc - Miscellaneous resource descriptors
4 * $Revision: 26 $
4 * $Revision: 27 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
12 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __RSMISC_C__
118
119#include "acpi.h"
120#include "acresrc.h"
121
122#define _COMPONENT ACPI_RESOURCES
123 ACPI_MODULE_NAME ("rsmisc")
124
125
126/*******************************************************************************
127 *
128 * FUNCTION: AcpiRsEndTagResource
129 *
130 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
131 * stream
132 * BytesConsumed - Pointer to where the number of bytes
133 * consumed the ByteStreamBuffer is
134 * returned
135 * OutputBuffer - Pointer to the return data buffer
136 * StructureSize - Pointer to where the number of bytes
137 * in the return data struct is returned
138 *
139 * RETURN: Status
140 *
141 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
142 * structure pointed to by the OutputBuffer. Return the
143 * number of bytes consumed from the byte stream.
144 *
145 ******************************************************************************/
146
147ACPI_STATUS
148AcpiRsEndTagResource (
149 UINT8 *ByteStreamBuffer,
150 ACPI_SIZE *BytesConsumed,
151 UINT8 **OutputBuffer,
152 ACPI_SIZE *StructureSize)
153{
154 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
155 ACPI_SIZE StructSize = ACPI_RESOURCE_LENGTH;
156
157
158 ACPI_FUNCTION_TRACE ("RsEndTagResource");
159
160
161 /*
162 * The number of bytes consumed is static
163 */
164 *BytesConsumed = 2;
165
166 /*
167 * Fill out the structure
168 */
169 OutputStruct->Id = ACPI_RSTYPE_END_TAG;
170
171 /*
172 * Set the Length parameter
173 */
174 OutputStruct->Length = 0;
175
176 /*
177 * Return the final size of the structure
178 */
179 *StructureSize = StructSize;
180 return_ACPI_STATUS (AE_OK);
181}
182
183
184/*******************************************************************************
185 *
186 * FUNCTION: AcpiRsEndTagStream
187 *
188 * PARAMETERS: LinkedList - Pointer to the resource linked list
189 * OutputBuffer - Pointer to the user's return buffer
190 * BytesConsumed - Pointer to where the number of bytes
191 * used in the OutputBuffer is returned
192 *
193 * RETURN: Status
194 *
195 * DESCRIPTION: Take the linked list resource structure and fills in the
196 * the appropriate bytes in a byte stream
197 *
198 ******************************************************************************/
199
200ACPI_STATUS
201AcpiRsEndTagStream (
202 ACPI_RESOURCE *LinkedList,
203 UINT8 **OutputBuffer,
204 ACPI_SIZE *BytesConsumed)
205{
206 UINT8 *Buffer = *OutputBuffer;
207 UINT8 Temp8 = 0;
208
209
210 ACPI_FUNCTION_TRACE ("RsEndTagStream");
211
212
213 /*
214 * The descriptor field is static
215 */
216 *Buffer = 0x79;
217 Buffer += 1;
218
219 /*
220 * Set the Checksum - zero means that the resource data is treated as if
221 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
222 */
223 Temp8 = 0;
224
225 *Buffer = Temp8;
226 Buffer += 1;
227
228 /*
229 * Return the number of bytes consumed in this operation
230 */
231 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
232 return_ACPI_STATUS (AE_OK);
233}
234
235
236/*******************************************************************************
237 *
238 * FUNCTION: AcpiRsVendorResource
239 *
240 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
241 * stream
242 * BytesConsumed - Pointer to where the number of bytes
243 * consumed the ByteStreamBuffer is
244 * returned
245 * OutputBuffer - Pointer to the return data buffer
246 * StructureSize - Pointer to where the number of bytes
247 * in the return data struct is returned
248 *
249 * RETURN: Status
250 *
251 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
252 * structure pointed to by the OutputBuffer. Return the
253 * number of bytes consumed from the byte stream.
254 *
255 ******************************************************************************/
256
257ACPI_STATUS
258AcpiRsVendorResource (
259 UINT8 *ByteStreamBuffer,
260 ACPI_SIZE *BytesConsumed,
261 UINT8 **OutputBuffer,
262 ACPI_SIZE *StructureSize)
263{
264 UINT8 *Buffer = ByteStreamBuffer;
265 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
266 UINT16 Temp16 = 0;
267 UINT8 Temp8 = 0;
268 UINT8 Index;
269 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR);
270
271
272 ACPI_FUNCTION_TRACE ("RsVendorResource");
273
274
275 /*
276 * Dereference the Descriptor to find if this is a large or small item.
277 */
278 Temp8 = *Buffer;
279
280 if (Temp8 & 0x80)
281 {
282 /*
283 * Large Item, point to the length field
284 */
285 Buffer += 1;
286
287 /* Dereference */
288
289 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
290
291 /* Calculate bytes consumed */
292
293 *BytesConsumed = (ACPI_SIZE) Temp16 + 3;
294
295 /* Point to the first vendor byte */
296
297 Buffer += 2;
298 }
299 else
300 {
301 /*
302 * Small Item, dereference the size
303 */
304 Temp16 = (UINT8)(*Buffer & 0x07);
305
306 /* Calculate bytes consumed */
307
308 *BytesConsumed = (ACPI_SIZE) Temp16 + 1;
309
310 /* Point to the first vendor byte */
311
312 Buffer += 1;
313 }
314
315 OutputStruct->Id = ACPI_RSTYPE_VENDOR;
316 OutputStruct->Data.VendorSpecific.Length = Temp16;
317
318 for (Index = 0; Index < Temp16; Index++)
319 {
320 OutputStruct->Data.VendorSpecific.Reserved[Index] = *Buffer;
321 Buffer += 1;
322 }
323
324 /*
325 * In order for the StructSize to fall on a 32-bit boundary,
326 * calculate the length of the vendor string and expand the
327 * StructSize to the next 32-bit boundary.
328 */
329 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp16);
330
331 /*
332 * Set the Length parameter
333 */
334 OutputStruct->Length = (UINT32) StructSize;
335
336 /*
337 * Return the final size of the structure
338 */
339 *StructureSize = StructSize;
340 return_ACPI_STATUS (AE_OK);
341}
342
343
344/*******************************************************************************
345 *
346 * FUNCTION: AcpiRsVendorStream
347 *
348 * PARAMETERS: LinkedList - Pointer to the resource linked list
349 * OutputBuffer - Pointer to the user's return buffer
350 * BytesConsumed - Pointer to where the number of bytes
351 * used in the OutputBuffer is returned
352 *
353 * RETURN: Status
354 *
355 * DESCRIPTION: Take the linked list resource structure and fills in the
356 * the appropriate bytes in a byte stream
357 *
358 ******************************************************************************/
359
360ACPI_STATUS
361AcpiRsVendorStream (
362 ACPI_RESOURCE *LinkedList,
363 UINT8 **OutputBuffer,
364 ACPI_SIZE *BytesConsumed)
365{
366 UINT8 *Buffer = *OutputBuffer;
367 UINT16 Temp16 = 0;
368 UINT8 Temp8 = 0;
369 UINT8 Index;
370
371
372 ACPI_FUNCTION_TRACE ("RsVendorStream");
373
374
375 /*
376 * Dereference the length to find if this is a large or small item.
377 */
378 if(LinkedList->Data.VendorSpecific.Length > 7)
379 {
380 /*
381 * Large Item, Set the descriptor field and length bytes
382 */
383 *Buffer = 0x84;
384 Buffer += 1;
385
386 Temp16 = (UINT16) LinkedList->Data.VendorSpecific.Length;
387
388 ACPI_MOVE_16_TO_16 (Buffer, &Temp16);
389 Buffer += 2;
390 }
391 else
392 {
393 /*
394 * Small Item, Set the descriptor field
395 */
396 Temp8 = 0x70;
397 Temp8 |= (UINT8) LinkedList->Data.VendorSpecific.Length;
398
399 *Buffer = Temp8;
400 Buffer += 1;
401 }
402
403 /*
404 * Loop through all of the Vendor Specific fields
405 */
406 for (Index = 0; Index < LinkedList->Data.VendorSpecific.Length; Index++)
407 {
408 Temp8 = LinkedList->Data.VendorSpecific.Reserved[Index];
409
410 *Buffer = Temp8;
411 Buffer += 1;
412 }
413
414 /*
415 * Return the number of bytes consumed in this operation
416 */
417 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
418 return_ACPI_STATUS (AE_OK);
419}
420
421
422/*******************************************************************************
423 *
424 * FUNCTION: AcpiRsStartDependFnsResource
425 *
426 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
427 * stream
428 * BytesConsumed - Pointer to where the number of bytes
429 * consumed the ByteStreamBuffer is
430 * returned
431 * OutputBuffer - Pointer to the return data buffer
432 * StructureSize - Pointer to where the number of bytes
433 * in the return data struct is returned
434 *
435 * RETURN: Status
436 *
437 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
438 * structure pointed to by the OutputBuffer. Return the
439 * number of bytes consumed from the byte stream.
440 *
441 ******************************************************************************/
442
443ACPI_STATUS
444AcpiRsStartDependFnsResource (
445 UINT8 *ByteStreamBuffer,
446 ACPI_SIZE *BytesConsumed,
447 UINT8 **OutputBuffer,
448 ACPI_SIZE *StructureSize)
449{
450 UINT8 *Buffer = ByteStreamBuffer;
451 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
452 UINT8 Temp8 = 0;
453 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_START_DPF);
454
455
456 ACPI_FUNCTION_TRACE ("RsStartDependFnsResource");
457
458
459 /*
460 * The number of bytes consumed are contained in the descriptor (Bits:0-1)
461 */
462 Temp8 = *Buffer;
463
464 *BytesConsumed = (Temp8 & 0x01) + 1;
465
466 OutputStruct->Id = ACPI_RSTYPE_START_DPF;
467
468 /*
469 * Point to Byte 1 if it is used
470 */
471 if (2 == *BytesConsumed)
472 {
473 Buffer += 1;
474 Temp8 = *Buffer;
475
476 /*
477 * Check Compatibility priority
478 */
479 OutputStruct->Data.StartDpf.CompatibilityPriority = Temp8 & 0x03;
480
481 if (3 == OutputStruct->Data.StartDpf.CompatibilityPriority)
482 {
483 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
484 }
485
486 /*
487 * Check Performance/Robustness preference
488 */
489 OutputStruct->Data.StartDpf.PerformanceRobustness = (Temp8 >> 2) & 0x03;
490
491 if (3 == OutputStruct->Data.StartDpf.PerformanceRobustness)
492 {
493 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
494 }
495 }
496 else
497 {
498 OutputStruct->Data.StartDpf.CompatibilityPriority =
499 ACPI_ACCEPTABLE_CONFIGURATION;
500
501 OutputStruct->Data.StartDpf.PerformanceRobustness =
502 ACPI_ACCEPTABLE_CONFIGURATION;
503 }
504
505 /*
506 * Set the Length parameter
507 */
508 OutputStruct->Length = (UINT32) StructSize;
509
510 /*
511 * Return the final size of the structure
512 */
513 *StructureSize = StructSize;
514 return_ACPI_STATUS (AE_OK);
515}
516
517
518/*******************************************************************************
519 *
520 * FUNCTION: AcpiRsEndDependFnsResource
521 *
522 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
523 * stream
524 * BytesConsumed - Pointer to where the number of bytes
525 * consumed the ByteStreamBuffer is
526 * returned
527 * OutputBuffer - Pointer to the return data buffer
528 * StructureSize - Pointer to where the number of bytes
529 * in the return data struct is returned
530 *
531 * RETURN: Status
532 *
533 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
534 * structure pointed to by the OutputBuffer. Return the
535 * number of bytes consumed from the byte stream.
536 *
537 ******************************************************************************/
538
539ACPI_STATUS
540AcpiRsEndDependFnsResource (
541 UINT8 *ByteStreamBuffer,
542 ACPI_SIZE *BytesConsumed,
543 UINT8 **OutputBuffer,
544 ACPI_SIZE *StructureSize)
545{
546 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
547 ACPI_SIZE StructSize = ACPI_RESOURCE_LENGTH;
548
549
550 ACPI_FUNCTION_TRACE ("RsEndDependFnsResource");
551
552
553 /*
554 * The number of bytes consumed is static
555 */
556 *BytesConsumed = 1;
557
558 /*
559 * Fill out the structure
560 */
561 OutputStruct->Id = ACPI_RSTYPE_END_DPF;
562
563 /*
564 * Set the Length parameter
565 */
566 OutputStruct->Length = (UINT32) StructSize;
567
568 /*
569 * Return the final size of the structure
570 */
571 *StructureSize = StructSize;
572 return_ACPI_STATUS (AE_OK);
573}
574
575
576/*******************************************************************************
577 *
578 * FUNCTION: AcpiRsStartDependFnsStream
579 *
580 * PARAMETERS: LinkedList - Pointer to the resource linked list
581 * OutputBuffer - Pointer to the user's return buffer
582 * BytesConsumed - UINT32 pointer that is filled with
583 * the number of bytes of the
584 * OutputBuffer used
585 *
586 * RETURN: Status
587 *
588 * DESCRIPTION: Take the linked list resource structure and fills in the
589 * the appropriate bytes in a byte stream
590 *
591 ******************************************************************************/
592
593ACPI_STATUS
594AcpiRsStartDependFnsStream (
595 ACPI_RESOURCE *LinkedList,
596 UINT8 **OutputBuffer,
597 ACPI_SIZE *BytesConsumed)
598{
599 UINT8 *Buffer = *OutputBuffer;
600 UINT8 Temp8 = 0;
601
602
603 ACPI_FUNCTION_TRACE ("RsStartDependFnsStream");
604
605
606 /*
607 * The descriptor field is set based upon whether a byte is needed
608 * to contain Priority data.
609 */
610 if (ACPI_ACCEPTABLE_CONFIGURATION ==
611 LinkedList->Data.StartDpf.CompatibilityPriority &&
612 ACPI_ACCEPTABLE_CONFIGURATION ==
613 LinkedList->Data.StartDpf.PerformanceRobustness)
614 {
615 *Buffer = 0x30;
616 }
617 else
618 {
619 *Buffer = 0x31;
620 Buffer += 1;
621
622 /*
623 * Set the Priority Byte Definition
624 */
625 Temp8 = 0;
626 Temp8 = (UINT8) ((LinkedList->Data.StartDpf.PerformanceRobustness &
627 0x03) << 2);
628 Temp8 |= (LinkedList->Data.StartDpf.CompatibilityPriority &
629 0x03);
630 *Buffer = Temp8;
631 }
632
633 Buffer += 1;
634
635 /*
636 * Return the number of bytes consumed in this operation
637 */
638 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
639 return_ACPI_STATUS (AE_OK);
640}
641
642
643/*******************************************************************************
644 *
645 * FUNCTION: AcpiRsEndDependFnsStream
646 *
647 * PARAMETERS: LinkedList - Pointer to the resource linked list
648 * OutputBuffer - Pointer to the user's return buffer
649 * BytesConsumed - Pointer to where the number of bytes
650 * used in the OutputBuffer is returned
651 *
652 * RETURN: Status
653 *
654 * DESCRIPTION: Take the linked list resource structure and fills in the
655 * the appropriate bytes in a byte stream
656 *
657 ******************************************************************************/
658
659ACPI_STATUS
660AcpiRsEndDependFnsStream (
661 ACPI_RESOURCE *LinkedList,
662 UINT8 **OutputBuffer,
663 ACPI_SIZE *BytesConsumed)
664{
665 UINT8 *Buffer = *OutputBuffer;
666
667
668 ACPI_FUNCTION_TRACE ("RsEndDependFnsStream");
669
670
671 /*
672 * The descriptor field is static
673 */
674 *Buffer = 0x38;
675 Buffer += 1;
676
677 /*
678 * Return the number of bytes consumed in this operation
679 */
680 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
681 return_ACPI_STATUS (AE_OK);
682}
683
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __RSMISC_C__
118
119#include "acpi.h"
120#include "acresrc.h"
121
122#define _COMPONENT ACPI_RESOURCES
123 ACPI_MODULE_NAME ("rsmisc")
124
125
126/*******************************************************************************
127 *
128 * FUNCTION: AcpiRsEndTagResource
129 *
130 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
131 * stream
132 * BytesConsumed - Pointer to where the number of bytes
133 * consumed the ByteStreamBuffer is
134 * returned
135 * OutputBuffer - Pointer to the return data buffer
136 * StructureSize - Pointer to where the number of bytes
137 * in the return data struct is returned
138 *
139 * RETURN: Status
140 *
141 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
142 * structure pointed to by the OutputBuffer. Return the
143 * number of bytes consumed from the byte stream.
144 *
145 ******************************************************************************/
146
147ACPI_STATUS
148AcpiRsEndTagResource (
149 UINT8 *ByteStreamBuffer,
150 ACPI_SIZE *BytesConsumed,
151 UINT8 **OutputBuffer,
152 ACPI_SIZE *StructureSize)
153{
154 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
155 ACPI_SIZE StructSize = ACPI_RESOURCE_LENGTH;
156
157
158 ACPI_FUNCTION_TRACE ("RsEndTagResource");
159
160
161 /*
162 * The number of bytes consumed is static
163 */
164 *BytesConsumed = 2;
165
166 /*
167 * Fill out the structure
168 */
169 OutputStruct->Id = ACPI_RSTYPE_END_TAG;
170
171 /*
172 * Set the Length parameter
173 */
174 OutputStruct->Length = 0;
175
176 /*
177 * Return the final size of the structure
178 */
179 *StructureSize = StructSize;
180 return_ACPI_STATUS (AE_OK);
181}
182
183
184/*******************************************************************************
185 *
186 * FUNCTION: AcpiRsEndTagStream
187 *
188 * PARAMETERS: LinkedList - Pointer to the resource linked list
189 * OutputBuffer - Pointer to the user's return buffer
190 * BytesConsumed - Pointer to where the number of bytes
191 * used in the OutputBuffer is returned
192 *
193 * RETURN: Status
194 *
195 * DESCRIPTION: Take the linked list resource structure and fills in the
196 * the appropriate bytes in a byte stream
197 *
198 ******************************************************************************/
199
200ACPI_STATUS
201AcpiRsEndTagStream (
202 ACPI_RESOURCE *LinkedList,
203 UINT8 **OutputBuffer,
204 ACPI_SIZE *BytesConsumed)
205{
206 UINT8 *Buffer = *OutputBuffer;
207 UINT8 Temp8 = 0;
208
209
210 ACPI_FUNCTION_TRACE ("RsEndTagStream");
211
212
213 /*
214 * The descriptor field is static
215 */
216 *Buffer = 0x79;
217 Buffer += 1;
218
219 /*
220 * Set the Checksum - zero means that the resource data is treated as if
221 * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
222 */
223 Temp8 = 0;
224
225 *Buffer = Temp8;
226 Buffer += 1;
227
228 /*
229 * Return the number of bytes consumed in this operation
230 */
231 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
232 return_ACPI_STATUS (AE_OK);
233}
234
235
236/*******************************************************************************
237 *
238 * FUNCTION: AcpiRsVendorResource
239 *
240 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
241 * stream
242 * BytesConsumed - Pointer to where the number of bytes
243 * consumed the ByteStreamBuffer is
244 * returned
245 * OutputBuffer - Pointer to the return data buffer
246 * StructureSize - Pointer to where the number of bytes
247 * in the return data struct is returned
248 *
249 * RETURN: Status
250 *
251 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
252 * structure pointed to by the OutputBuffer. Return the
253 * number of bytes consumed from the byte stream.
254 *
255 ******************************************************************************/
256
257ACPI_STATUS
258AcpiRsVendorResource (
259 UINT8 *ByteStreamBuffer,
260 ACPI_SIZE *BytesConsumed,
261 UINT8 **OutputBuffer,
262 ACPI_SIZE *StructureSize)
263{
264 UINT8 *Buffer = ByteStreamBuffer;
265 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
266 UINT16 Temp16 = 0;
267 UINT8 Temp8 = 0;
268 UINT8 Index;
269 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR);
270
271
272 ACPI_FUNCTION_TRACE ("RsVendorResource");
273
274
275 /*
276 * Dereference the Descriptor to find if this is a large or small item.
277 */
278 Temp8 = *Buffer;
279
280 if (Temp8 & 0x80)
281 {
282 /*
283 * Large Item, point to the length field
284 */
285 Buffer += 1;
286
287 /* Dereference */
288
289 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
290
291 /* Calculate bytes consumed */
292
293 *BytesConsumed = (ACPI_SIZE) Temp16 + 3;
294
295 /* Point to the first vendor byte */
296
297 Buffer += 2;
298 }
299 else
300 {
301 /*
302 * Small Item, dereference the size
303 */
304 Temp16 = (UINT8)(*Buffer & 0x07);
305
306 /* Calculate bytes consumed */
307
308 *BytesConsumed = (ACPI_SIZE) Temp16 + 1;
309
310 /* Point to the first vendor byte */
311
312 Buffer += 1;
313 }
314
315 OutputStruct->Id = ACPI_RSTYPE_VENDOR;
316 OutputStruct->Data.VendorSpecific.Length = Temp16;
317
318 for (Index = 0; Index < Temp16; Index++)
319 {
320 OutputStruct->Data.VendorSpecific.Reserved[Index] = *Buffer;
321 Buffer += 1;
322 }
323
324 /*
325 * In order for the StructSize to fall on a 32-bit boundary,
326 * calculate the length of the vendor string and expand the
327 * StructSize to the next 32-bit boundary.
328 */
329 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp16);
330
331 /*
332 * Set the Length parameter
333 */
334 OutputStruct->Length = (UINT32) StructSize;
335
336 /*
337 * Return the final size of the structure
338 */
339 *StructureSize = StructSize;
340 return_ACPI_STATUS (AE_OK);
341}
342
343
344/*******************************************************************************
345 *
346 * FUNCTION: AcpiRsVendorStream
347 *
348 * PARAMETERS: LinkedList - Pointer to the resource linked list
349 * OutputBuffer - Pointer to the user's return buffer
350 * BytesConsumed - Pointer to where the number of bytes
351 * used in the OutputBuffer is returned
352 *
353 * RETURN: Status
354 *
355 * DESCRIPTION: Take the linked list resource structure and fills in the
356 * the appropriate bytes in a byte stream
357 *
358 ******************************************************************************/
359
360ACPI_STATUS
361AcpiRsVendorStream (
362 ACPI_RESOURCE *LinkedList,
363 UINT8 **OutputBuffer,
364 ACPI_SIZE *BytesConsumed)
365{
366 UINT8 *Buffer = *OutputBuffer;
367 UINT16 Temp16 = 0;
368 UINT8 Temp8 = 0;
369 UINT8 Index;
370
371
372 ACPI_FUNCTION_TRACE ("RsVendorStream");
373
374
375 /*
376 * Dereference the length to find if this is a large or small item.
377 */
378 if(LinkedList->Data.VendorSpecific.Length > 7)
379 {
380 /*
381 * Large Item, Set the descriptor field and length bytes
382 */
383 *Buffer = 0x84;
384 Buffer += 1;
385
386 Temp16 = (UINT16) LinkedList->Data.VendorSpecific.Length;
387
388 ACPI_MOVE_16_TO_16 (Buffer, &Temp16);
389 Buffer += 2;
390 }
391 else
392 {
393 /*
394 * Small Item, Set the descriptor field
395 */
396 Temp8 = 0x70;
397 Temp8 |= (UINT8) LinkedList->Data.VendorSpecific.Length;
398
399 *Buffer = Temp8;
400 Buffer += 1;
401 }
402
403 /*
404 * Loop through all of the Vendor Specific fields
405 */
406 for (Index = 0; Index < LinkedList->Data.VendorSpecific.Length; Index++)
407 {
408 Temp8 = LinkedList->Data.VendorSpecific.Reserved[Index];
409
410 *Buffer = Temp8;
411 Buffer += 1;
412 }
413
414 /*
415 * Return the number of bytes consumed in this operation
416 */
417 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
418 return_ACPI_STATUS (AE_OK);
419}
420
421
422/*******************************************************************************
423 *
424 * FUNCTION: AcpiRsStartDependFnsResource
425 *
426 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
427 * stream
428 * BytesConsumed - Pointer to where the number of bytes
429 * consumed the ByteStreamBuffer is
430 * returned
431 * OutputBuffer - Pointer to the return data buffer
432 * StructureSize - Pointer to where the number of bytes
433 * in the return data struct is returned
434 *
435 * RETURN: Status
436 *
437 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
438 * structure pointed to by the OutputBuffer. Return the
439 * number of bytes consumed from the byte stream.
440 *
441 ******************************************************************************/
442
443ACPI_STATUS
444AcpiRsStartDependFnsResource (
445 UINT8 *ByteStreamBuffer,
446 ACPI_SIZE *BytesConsumed,
447 UINT8 **OutputBuffer,
448 ACPI_SIZE *StructureSize)
449{
450 UINT8 *Buffer = ByteStreamBuffer;
451 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
452 UINT8 Temp8 = 0;
453 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_START_DPF);
454
455
456 ACPI_FUNCTION_TRACE ("RsStartDependFnsResource");
457
458
459 /*
460 * The number of bytes consumed are contained in the descriptor (Bits:0-1)
461 */
462 Temp8 = *Buffer;
463
464 *BytesConsumed = (Temp8 & 0x01) + 1;
465
466 OutputStruct->Id = ACPI_RSTYPE_START_DPF;
467
468 /*
469 * Point to Byte 1 if it is used
470 */
471 if (2 == *BytesConsumed)
472 {
473 Buffer += 1;
474 Temp8 = *Buffer;
475
476 /*
477 * Check Compatibility priority
478 */
479 OutputStruct->Data.StartDpf.CompatibilityPriority = Temp8 & 0x03;
480
481 if (3 == OutputStruct->Data.StartDpf.CompatibilityPriority)
482 {
483 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
484 }
485
486 /*
487 * Check Performance/Robustness preference
488 */
489 OutputStruct->Data.StartDpf.PerformanceRobustness = (Temp8 >> 2) & 0x03;
490
491 if (3 == OutputStruct->Data.StartDpf.PerformanceRobustness)
492 {
493 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
494 }
495 }
496 else
497 {
498 OutputStruct->Data.StartDpf.CompatibilityPriority =
499 ACPI_ACCEPTABLE_CONFIGURATION;
500
501 OutputStruct->Data.StartDpf.PerformanceRobustness =
502 ACPI_ACCEPTABLE_CONFIGURATION;
503 }
504
505 /*
506 * Set the Length parameter
507 */
508 OutputStruct->Length = (UINT32) StructSize;
509
510 /*
511 * Return the final size of the structure
512 */
513 *StructureSize = StructSize;
514 return_ACPI_STATUS (AE_OK);
515}
516
517
518/*******************************************************************************
519 *
520 * FUNCTION: AcpiRsEndDependFnsResource
521 *
522 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
523 * stream
524 * BytesConsumed - Pointer to where the number of bytes
525 * consumed the ByteStreamBuffer is
526 * returned
527 * OutputBuffer - Pointer to the return data buffer
528 * StructureSize - Pointer to where the number of bytes
529 * in the return data struct is returned
530 *
531 * RETURN: Status
532 *
533 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
534 * structure pointed to by the OutputBuffer. Return the
535 * number of bytes consumed from the byte stream.
536 *
537 ******************************************************************************/
538
539ACPI_STATUS
540AcpiRsEndDependFnsResource (
541 UINT8 *ByteStreamBuffer,
542 ACPI_SIZE *BytesConsumed,
543 UINT8 **OutputBuffer,
544 ACPI_SIZE *StructureSize)
545{
546 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
547 ACPI_SIZE StructSize = ACPI_RESOURCE_LENGTH;
548
549
550 ACPI_FUNCTION_TRACE ("RsEndDependFnsResource");
551
552
553 /*
554 * The number of bytes consumed is static
555 */
556 *BytesConsumed = 1;
557
558 /*
559 * Fill out the structure
560 */
561 OutputStruct->Id = ACPI_RSTYPE_END_DPF;
562
563 /*
564 * Set the Length parameter
565 */
566 OutputStruct->Length = (UINT32) StructSize;
567
568 /*
569 * Return the final size of the structure
570 */
571 *StructureSize = StructSize;
572 return_ACPI_STATUS (AE_OK);
573}
574
575
576/*******************************************************************************
577 *
578 * FUNCTION: AcpiRsStartDependFnsStream
579 *
580 * PARAMETERS: LinkedList - Pointer to the resource linked list
581 * OutputBuffer - Pointer to the user's return buffer
582 * BytesConsumed - UINT32 pointer that is filled with
583 * the number of bytes of the
584 * OutputBuffer used
585 *
586 * RETURN: Status
587 *
588 * DESCRIPTION: Take the linked list resource structure and fills in the
589 * the appropriate bytes in a byte stream
590 *
591 ******************************************************************************/
592
593ACPI_STATUS
594AcpiRsStartDependFnsStream (
595 ACPI_RESOURCE *LinkedList,
596 UINT8 **OutputBuffer,
597 ACPI_SIZE *BytesConsumed)
598{
599 UINT8 *Buffer = *OutputBuffer;
600 UINT8 Temp8 = 0;
601
602
603 ACPI_FUNCTION_TRACE ("RsStartDependFnsStream");
604
605
606 /*
607 * The descriptor field is set based upon whether a byte is needed
608 * to contain Priority data.
609 */
610 if (ACPI_ACCEPTABLE_CONFIGURATION ==
611 LinkedList->Data.StartDpf.CompatibilityPriority &&
612 ACPI_ACCEPTABLE_CONFIGURATION ==
613 LinkedList->Data.StartDpf.PerformanceRobustness)
614 {
615 *Buffer = 0x30;
616 }
617 else
618 {
619 *Buffer = 0x31;
620 Buffer += 1;
621
622 /*
623 * Set the Priority Byte Definition
624 */
625 Temp8 = 0;
626 Temp8 = (UINT8) ((LinkedList->Data.StartDpf.PerformanceRobustness &
627 0x03) << 2);
628 Temp8 |= (LinkedList->Data.StartDpf.CompatibilityPriority &
629 0x03);
630 *Buffer = Temp8;
631 }
632
633 Buffer += 1;
634
635 /*
636 * Return the number of bytes consumed in this operation
637 */
638 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
639 return_ACPI_STATUS (AE_OK);
640}
641
642
643/*******************************************************************************
644 *
645 * FUNCTION: AcpiRsEndDependFnsStream
646 *
647 * PARAMETERS: LinkedList - Pointer to the resource linked list
648 * OutputBuffer - Pointer to the user's return buffer
649 * BytesConsumed - Pointer to where the number of bytes
650 * used in the OutputBuffer is returned
651 *
652 * RETURN: Status
653 *
654 * DESCRIPTION: Take the linked list resource structure and fills in the
655 * the appropriate bytes in a byte stream
656 *
657 ******************************************************************************/
658
659ACPI_STATUS
660AcpiRsEndDependFnsStream (
661 ACPI_RESOURCE *LinkedList,
662 UINT8 **OutputBuffer,
663 ACPI_SIZE *BytesConsumed)
664{
665 UINT8 *Buffer = *OutputBuffer;
666
667
668 ACPI_FUNCTION_TRACE ("RsEndDependFnsStream");
669
670
671 /*
672 * The descriptor field is static
673 */
674 *Buffer = 0x38;
675 Buffer += 1;
676
677 /*
678 * Return the number of bytes consumed in this operation
679 */
680 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
681 return_ACPI_STATUS (AE_OK);
682}
683