1 /*******************************************************************************
3 * Module Name: rsaddr - Address resource descriptors (16/32/64)
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
13 * All rights reserved.
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
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
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;
38 * The above copyright and patent license is granted only if the following
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.
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
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
73 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
81 * 4. Disclaimer and Export Compliance
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
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
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.
115 *****************************************************************************/
122 #define _COMPONENT ACPI_RESOURCES
123 ACPI_MODULE_NAME ("rsaddr")
126 /*******************************************************************************
128 * FUNCTION: AcpiRsAddress16Resource
130 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
132 * BytesConsumed - Pointer to where the number of bytes
133 * consumed the ByteStreamBuffer is
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
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.
145 ******************************************************************************/
148 AcpiRsAddress16Resource (
149 UINT8 *ByteStreamBuffer,
150 ACPI_SIZE *BytesConsumed,
151 UINT8 **OutputBuffer,
152 ACPI_SIZE *StructureSize)
154 UINT8 *Buffer = ByteStreamBuffer;
155 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
157 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16);
163 ACPI_FUNCTION_TRACE ("RsAddress16Resource");
167 * Point past the Descriptor to get the number of bytes consumed
170 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
172 /* Validate minimum descriptor length */
176 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
179 *BytesConsumed = Temp16 + 3;
180 OutputStruct->Id = ACPI_RSTYPE_ADDRESS16;
183 * Get the Resource Type (Byte3)
188 /* Values 0-2 are valid */
192 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
195 OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03;
198 * Get the General Flags (Byte4)
203 /* Producer / Consumer */
205 OutputStruct->Data.Address16.ProducerConsumer = Temp8 & 0x01;
209 OutputStruct->Data.Address16.Decode = (Temp8 >> 1) & 0x01;
211 /* Min Address Fixed */
213 OutputStruct->Data.Address16.MinAddressFixed = (Temp8 >> 2) & 0x01;
215 /* Max Address Fixed */
217 OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01;
220 * Get the Type Specific Flags (Byte5)
225 if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address16.ResourceType)
227 OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute =
228 (UINT16) (Temp8 & 0x01);
229 OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute =
230 (UINT16) ((Temp8 >> 1) & 0x03);
234 if (ACPI_IO_RANGE == OutputStruct->Data.Address16.ResourceType)
236 OutputStruct->Data.Address16.Attribute.Io.RangeAttribute =
237 (UINT16) (Temp8 & 0x03);
238 OutputStruct->Data.Address16.Attribute.Io.TranslationAttribute =
239 (UINT16) ((Temp8 >> 4) & 0x03);
243 /* BUS_NUMBER_RANGE == Address16.Data->ResourceType */
244 /* Nothing needs to be filled in */
249 * Get Granularity (Bytes 6-7)
252 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.Granularity, Buffer);
255 * Get MinAddressRange (Bytes 8-9)
258 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MinAddressRange, Buffer);
261 * Get MaxAddressRange (Bytes 10-11)
264 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MaxAddressRange, Buffer);
267 * Get AddressTranslationOffset (Bytes 12-13)
270 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressTranslationOffset, Buffer);
273 * Get AddressLength (Bytes 14-15)
276 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressLength, Buffer);
279 * Resource Source Index (if present)
284 * This will leave us pointing to the Resource Source Index
285 * If it is present, then save it off and calculate the
286 * pointer to where the null terminated string goes:
287 * Each Interrupt takes 32-bits + the 5 bytes of the
288 * stream that are default.
290 * Note: Some resource descriptors will have an additional null, so
291 * we add 1 to the length.
293 if (*BytesConsumed > (16 + 1))
295 /* Dereference the Index */
298 OutputStruct->Data.Address16.ResourceSource.Index = (UINT32) Temp8;
300 /* Point to the String */
304 /* Point the String pointer to the end of this structure */
306 OutputStruct->Data.Address16.ResourceSource.StringPtr =
307 (char *)((UINT8 * )OutputStruct + StructSize);
309 TempPtr = (UINT8 *) OutputStruct->Data.Address16.ResourceSource.StringPtr;
311 /* Copy the string into the buffer */
315 while (0x00 != *Buffer)
325 * Add the terminating null
329 OutputStruct->Data.Address16.ResourceSource.StringLength = Index + 1;
332 * In order for the StructSize to fall on a 32-bit boundary,
333 * calculate the length of the string and expand the
334 * StructSize to the next 32-bit boundary.
336 Temp8 = (UINT8) (Index + 1);
337 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
341 OutputStruct->Data.Address16.ResourceSource.Index = 0x00;
342 OutputStruct->Data.Address16.ResourceSource.StringLength = 0;
343 OutputStruct->Data.Address16.ResourceSource.StringPtr = NULL;
347 * Set the Length parameter
349 OutputStruct->Length = (UINT32) StructSize;
352 * Return the final size of the structure
354 *StructureSize = StructSize;
355 return_ACPI_STATUS (AE_OK);
359 /*******************************************************************************
361 * FUNCTION: AcpiRsAddress16Stream
363 * PARAMETERS: LinkedList - Pointer to the resource linked list
364 * OutputBuffer - Pointer to the user's return buffer
365 * BytesConsumed - Pointer to where the number of bytes
366 * used in the OutputBuffer is returned
370 * DESCRIPTION: Take the linked list resource structure and fills in the
371 * the appropriate bytes in a byte stream
373 ******************************************************************************/
376 AcpiRsAddress16Stream (
377 ACPI_RESOURCE *LinkedList,
378 UINT8 **OutputBuffer,
379 ACPI_SIZE *BytesConsumed)
381 UINT8 *Buffer = *OutputBuffer;
384 char *TempPointer = NULL;
385 ACPI_SIZE ActualBytes;
388 ACPI_FUNCTION_TRACE ("RsAddress16Stream");
392 * The descriptor field is static
398 * Save a pointer to the Length field - to be filled in later
400 LengthField = Buffer;
404 * Set the Resource Type (Memory, Io, BusNumber)
406 Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03);
411 * Set the general flags
413 Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01);
415 Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1;
416 Temp8 |= (LinkedList->Data.Address16.MinAddressFixed & 0x01) << 2;
417 Temp8 |= (LinkedList->Data.Address16.MaxAddressFixed & 0x01) << 3;
423 * Set the type specific flags
427 if (ACPI_MEMORY_RANGE == LinkedList->Data.Address16.ResourceType)
430 (LinkedList->Data.Address16.Attribute.Memory.ReadWriteAttribute &
434 (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute &
437 else if (ACPI_IO_RANGE == LinkedList->Data.Address16.ResourceType)
440 (LinkedList->Data.Address16.Attribute.Io.RangeAttribute &
443 (LinkedList->Data.Address16.Attribute.Io.TranslationAttribute &
451 * Set the address space granularity
453 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.Granularity);
457 * Set the address range minimum
459 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MinAddressRange);
463 * Set the address range maximum
465 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MaxAddressRange);
469 * Set the address translation offset
471 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressTranslationOffset);
475 * Set the address length
477 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressLength);
481 * Resource Source Index and Resource Source are optional
483 if (0 != LinkedList->Data.Address16.ResourceSource.StringLength)
485 Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSource.Index;
490 TempPointer = (char *) Buffer;
495 ACPI_STRCPY (TempPointer,
496 LinkedList->Data.Address16.ResourceSource.StringPtr);
499 * Buffer needs to be set to the length of the sting + one for the
502 Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address16.ResourceSource.StringPtr) + 1);
506 * Return the number of bytes consumed in this operation
508 ActualBytes = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
509 *BytesConsumed = ActualBytes;
512 * Set the length field to the number of bytes consumed
513 * minus the header size (3 bytes)
516 ACPI_MOVE_SIZE_TO_16 (LengthField, &ActualBytes);
517 return_ACPI_STATUS (AE_OK);
521 /*******************************************************************************
523 * FUNCTION: AcpiRsAddress32Resource
525 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
527 * BytesConsumed - Pointer to where the number of bytes
528 * consumed the ByteStreamBuffer is
530 * OutputBuffer - Pointer to the return data buffer
531 * StructureSize - Pointer to where the number of bytes
532 * in the return data struct is returned
536 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
537 * structure pointed to by the OutputBuffer. Return the
538 * number of bytes consumed from the byte stream.
540 ******************************************************************************/
543 AcpiRsAddress32Resource (
544 UINT8 *ByteStreamBuffer,
545 ACPI_SIZE *BytesConsumed,
546 UINT8 **OutputBuffer,
547 ACPI_SIZE *StructureSize)
550 ACPI_RESOURCE *OutputStruct= (void *) *OutputBuffer;
554 ACPI_SIZE StructSize;
558 ACPI_FUNCTION_TRACE ("RsAddress32Resource");
561 Buffer = ByteStreamBuffer;
562 StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS32);
565 * Point past the Descriptor to get the number of bytes consumed
568 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
570 /* Validate minimum descriptor length */
574 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
577 *BytesConsumed = Temp16 + 3;
578 OutputStruct->Id = ACPI_RSTYPE_ADDRESS32;
581 * Get the Resource Type (Byte3)
586 /* Values 0-2 are valid */
589 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
592 OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03;
595 * Get the General Flags (Byte4)
601 * Producer / Consumer
603 OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01;
608 OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01;
613 OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01;
618 OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01;
621 * Get the Type Specific Flags (Byte5)
626 if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address32.ResourceType)
628 OutputStruct->Data.Address32.Attribute.Memory.ReadWriteAttribute =
629 (UINT16) (Temp8 & 0x01);
631 OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute =
632 (UINT16) ((Temp8 >> 1) & 0x03);
636 if (ACPI_IO_RANGE == OutputStruct->Data.Address32.ResourceType)
638 OutputStruct->Data.Address32.Attribute.Io.RangeAttribute =
639 (UINT16) (Temp8 & 0x03);
640 OutputStruct->Data.Address32.Attribute.Io.TranslationAttribute =
641 (UINT16) ((Temp8 >> 4) & 0x03);
645 /* BUS_NUMBER_RANGE == OutputStruct->Data.Address32.ResourceType */
646 /* Nothing needs to be filled in */
651 * Get Granularity (Bytes 6-9)
654 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.Granularity, Buffer);
657 * Get MinAddressRange (Bytes 10-13)
660 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange, Buffer);
663 * Get MaxAddressRange (Bytes 14-17)
666 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange, Buffer);
669 * Get AddressTranslationOffset (Bytes 18-21)
672 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressTranslationOffset, Buffer);
675 * Get AddressLength (Bytes 22-25)
678 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressLength, Buffer);
681 * Resource Source Index (if present)
686 * This will leave us pointing to the Resource Source Index
687 * If it is present, then save it off and calculate the
688 * pointer to where the null terminated string goes:
690 * Note: Some resource descriptors will have an additional null, so
691 * we add 1 to the length.
693 if (*BytesConsumed > (26 + 1))
695 /* Dereference the Index */
698 OutputStruct->Data.Address32.ResourceSource.Index =
701 /* Point to the String */
705 /* Point the String pointer to the end of this structure */
707 OutputStruct->Data.Address32.ResourceSource.StringPtr =
708 (char *)((UINT8 *)OutputStruct + StructSize);
710 TempPtr = (UINT8 *) OutputStruct->Data.Address32.ResourceSource.StringPtr;
712 /* Copy the string into the buffer */
715 while (0x00 != *Buffer)
725 * Add the terminating null
728 OutputStruct->Data.Address32.ResourceSource.StringLength = Index + 1;
731 * In order for the StructSize to fall on a 32-bit boundary,
732 * calculate the length of the string and expand the
733 * StructSize to the next 32-bit boundary.
735 Temp8 = (UINT8) (Index + 1);
736 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
740 OutputStruct->Data.Address32.ResourceSource.Index = 0x00;
741 OutputStruct->Data.Address32.ResourceSource.StringLength = 0;
742 OutputStruct->Data.Address32.ResourceSource.StringPtr = NULL;
746 * Set the Length parameter
748 OutputStruct->Length = (UINT32) StructSize;
751 * Return the final size of the structure
753 *StructureSize = StructSize;
754 return_ACPI_STATUS (AE_OK);
758 /*******************************************************************************
760 * FUNCTION: AcpiRsAddress32Stream
762 * PARAMETERS: LinkedList - Pointer to the resource linked list
763 * OutputBuffer - Pointer to the user's return buffer
764 * BytesConsumed - Pointer to where the number of bytes
765 * used in the OutputBuffer is returned
769 * DESCRIPTION: Take the linked list resource structure and fills in the
770 * the appropriate bytes in a byte stream
772 ******************************************************************************/
775 AcpiRsAddress32Stream (
776 ACPI_RESOURCE *LinkedList,
777 UINT8 **OutputBuffer,
778 ACPI_SIZE *BytesConsumed)
786 ACPI_FUNCTION_TRACE ("RsAddress32Stream");
789 Buffer = *OutputBuffer;
792 * The descriptor field is static
798 * Set a pointer to the Length field - to be filled in later
800 LengthField = ACPI_CAST_PTR (UINT16, Buffer);
804 * Set the Resource Type (Memory, Io, BusNumber)
806 Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03);
812 * Set the general flags
814 Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01);
815 Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1;
816 Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2;
817 Temp8 |= (LinkedList->Data.Address32.MaxAddressFixed & 0x01) << 3;
823 * Set the type specific flags
827 if (ACPI_MEMORY_RANGE == LinkedList->Data.Address32.ResourceType)
830 (LinkedList->Data.Address32.Attribute.Memory.ReadWriteAttribute &
834 (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute &
837 else if (ACPI_IO_RANGE == LinkedList->Data.Address32.ResourceType)
840 (LinkedList->Data.Address32.Attribute.Io.RangeAttribute &
843 (LinkedList->Data.Address32.Attribute.Io.TranslationAttribute &
851 * Set the address space granularity
853 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.Granularity);
857 * Set the address range minimum
859 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MinAddressRange);
863 * Set the address range maximum
865 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MaxAddressRange);
869 * Set the address translation offset
871 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressTranslationOffset);
875 * Set the address length
877 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressLength);
881 * Resource Source Index and Resource Source are optional
883 if (0 != LinkedList->Data.Address32.ResourceSource.StringLength)
885 Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSource.Index;
890 TempPointer = (char *) Buffer;
895 ACPI_STRCPY (TempPointer,
896 LinkedList->Data.Address32.ResourceSource.StringPtr);
899 * Buffer needs to be set to the length of the sting + one for the
902 Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address32.ResourceSource.StringPtr) + 1);
906 * Return the number of bytes consumed in this operation
908 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
911 * Set the length field to the number of bytes consumed
912 * minus the header size (3 bytes)
914 *LengthField = (UINT16) (*BytesConsumed - 3);
915 return_ACPI_STATUS (AE_OK);
919 /*******************************************************************************
921 * FUNCTION: AcpiRsAddress64Resource
923 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
925 * BytesConsumed - Pointer to where the number of bytes
926 * consumed the ByteStreamBuffer is
928 * OutputBuffer - Pointer to the return data buffer
929 * StructureSize - Pointer to where the number of bytes
930 * in the return data struct is returned
934 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
935 * structure pointed to by the OutputBuffer. Return the
936 * number of bytes consumed from the byte stream.
938 ******************************************************************************/
941 AcpiRsAddress64Resource (
942 UINT8 *ByteStreamBuffer,
943 ACPI_SIZE *BytesConsumed,
944 UINT8 **OutputBuffer,
945 ACPI_SIZE *StructureSize)
948 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
952 ACPI_SIZE StructSize;
956 ACPI_FUNCTION_TRACE ("RsAddress64Resource");
959 Buffer = ByteStreamBuffer;
960 StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64);
963 * Point past the Descriptor to get the number of bytes consumed
966 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
968 /* Validate minimum descriptor length */
972 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
975 *BytesConsumed = Temp16 + 3;
976 OutputStruct->Id = ACPI_RSTYPE_ADDRESS64;
979 * Get the Resource Type (Byte3)
984 /* Values 0-2 are valid */
988 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
991 OutputStruct->Data.Address64.ResourceType = Temp8 & 0x03;
994 * Get the General Flags (Byte4)
1000 * Producer / Consumer
1002 OutputStruct->Data.Address64.ProducerConsumer = Temp8 & 0x01;
1007 OutputStruct->Data.Address64.Decode = (Temp8 >> 1) & 0x01;
1012 OutputStruct->Data.Address64.MinAddressFixed = (Temp8 >> 2) & 0x01;
1017 OutputStruct->Data.Address64.MaxAddressFixed = (Temp8 >> 3) & 0x01;
1020 * Get the Type Specific Flags (Byte5)
1025 if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address64.ResourceType)
1027 OutputStruct->Data.Address64.Attribute.Memory.ReadWriteAttribute =
1028 (UINT16) (Temp8 & 0x01);
1030 OutputStruct->Data.Address64.Attribute.Memory.CacheAttribute =
1031 (UINT16) ((Temp8 >> 1) & 0x03);
1035 if (ACPI_IO_RANGE == OutputStruct->Data.Address64.ResourceType)
1037 OutputStruct->Data.Address64.Attribute.Io.RangeAttribute =
1038 (UINT16) (Temp8 & 0x03);
1039 OutputStruct->Data.Address64.Attribute.Io.TranslationAttribute =
1040 (UINT16) ((Temp8 >> 4) & 0x03);
1044 /* BUS_NUMBER_RANGE == OutputStruct->Data.Address64.ResourceType */
1045 /* Nothing needs to be filled in */
1050 * Get Granularity (Bytes 6-13)
1053 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.Granularity, Buffer);
1056 * Get MinAddressRange (Bytes 14-21)
1059 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MinAddressRange, Buffer);
1062 * Get MaxAddressRange (Bytes 22-29)
1065 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MaxAddressRange, Buffer);
1068 * Get AddressTranslationOffset (Bytes 30-37)
1071 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressTranslationOffset, Buffer);
1074 * Get AddressLength (Bytes 38-45)
1077 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressLength, Buffer);
1080 * Resource Source Index (if present)
1085 * This will leave us pointing to the Resource Source Index
1086 * If it is present, then save it off and calculate the
1087 * pointer to where the null terminated string goes:
1088 * Each Interrupt takes 32-bits + the 5 bytes of the
1089 * stream that are default.
1091 * Note: Some resource descriptors will have an additional null, so
1092 * we add 1 to the length.
1094 if (*BytesConsumed > (46 + 1))
1096 /* Dereference the Index */
1099 OutputStruct->Data.Address64.ResourceSource.Index =
1102 /* Point to the String */
1106 /* Point the String pointer to the end of this structure */
1108 OutputStruct->Data.Address64.ResourceSource.StringPtr =
1109 (char *)((UINT8 *)OutputStruct + StructSize);
1111 TempPtr = (UINT8 *) OutputStruct->Data.Address64.ResourceSource.StringPtr;
1113 /* Copy the string into the buffer */
1116 while (0x00 != *Buffer)
1126 * Add the terminating null
1129 OutputStruct->Data.Address64.ResourceSource.StringLength = Index + 1;
1132 * In order for the StructSize to fall on a 32-bit boundary,
1133 * calculate the length of the string and expand the
1134 * StructSize to the next 32-bit boundary.
1136 Temp8 = (UINT8) (Index + 1);
1137 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
1141 OutputStruct->Data.Address64.ResourceSource.Index = 0x00;
1142 OutputStruct->Data.Address64.ResourceSource.StringLength = 0;
1143 OutputStruct->Data.Address64.ResourceSource.StringPtr = NULL;
1147 * Set the Length parameter
1149 OutputStruct->Length = (UINT32) StructSize;
1152 * Return the final size of the structure
1154 *StructureSize = StructSize;
1155 return_ACPI_STATUS (AE_OK);
1159 /*******************************************************************************
1161 * FUNCTION: AcpiRsAddress64Stream
1163 * PARAMETERS: LinkedList - Pointer to the resource linked list
1164 * OutputBuffer - Pointer to the user's return buffer
1165 * BytesConsumed - Pointer to where the number of bytes
1166 * used in the OutputBuffer is returned
1170 * DESCRIPTION: Take the linked list resource structure and fills in the
1171 * the appropriate bytes in a byte stream
1173 ******************************************************************************/
1176 AcpiRsAddress64Stream (
1177 ACPI_RESOURCE *LinkedList,
1178 UINT8 **OutputBuffer,
1179 ACPI_SIZE *BytesConsumed)
1182 UINT16 *LengthField;
1187 ACPI_FUNCTION_TRACE ("RsAddress64Stream");
1190 Buffer = *OutputBuffer;
1193 * The descriptor field is static
1199 * Set a pointer to the Length field - to be filled in later
1201 LengthField = ACPI_CAST_PTR (UINT16, Buffer);
1205 * Set the Resource Type (Memory, Io, BusNumber)
1207 Temp8 = (UINT8) (LinkedList->Data.Address64.ResourceType & 0x03);
1213 * Set the general flags
1215 Temp8 = (UINT8) (LinkedList->Data.Address64.ProducerConsumer & 0x01);
1216 Temp8 |= (LinkedList->Data.Address64.Decode & 0x01) << 1;
1217 Temp8 |= (LinkedList->Data.Address64.MinAddressFixed & 0x01) << 2;
1218 Temp8 |= (LinkedList->Data.Address64.MaxAddressFixed & 0x01) << 3;
1224 * Set the type specific flags
1228 if (ACPI_MEMORY_RANGE == LinkedList->Data.Address64.ResourceType)
1231 (LinkedList->Data.Address64.Attribute.Memory.ReadWriteAttribute &
1235 (LinkedList->Data.Address64.Attribute.Memory.CacheAttribute &
1238 else if (ACPI_IO_RANGE == LinkedList->Data.Address64.ResourceType)
1241 (LinkedList->Data.Address64.Attribute.Io.RangeAttribute &
1244 (LinkedList->Data.Address64.Attribute.Io.RangeAttribute &
1252 * Set the address space granularity
1254 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.Granularity);
1258 * Set the address range minimum
1260 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MinAddressRange);
1264 * Set the address range maximum
1266 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MaxAddressRange);
1270 * Set the address translation offset
1272 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressTranslationOffset);
1276 * Set the address length
1278 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressLength);
1282 * Resource Source Index and Resource Source are optional
1284 if (0 != LinkedList->Data.Address64.ResourceSource.StringLength)
1286 Temp8 = (UINT8) LinkedList->Data.Address64.ResourceSource.Index;
1291 TempPointer = (char *) Buffer;
1296 ACPI_STRCPY (TempPointer, LinkedList->Data.Address64.ResourceSource.StringPtr);
1299 * Buffer needs to be set to the length of the sting + one for the
1302 Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address64.ResourceSource.StringPtr) + 1);
1306 * Return the number of bytes consumed in this operation
1308 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
1311 * Set the length field to the number of bytes consumed
1312 * minus the header size (3 bytes)
1314 *LengthField = (UINT16) (*BytesConsumed - 3);
1315 return_ACPI_STATUS (AE_OK);