1 /*******************************************************************************
3 * Module Name: rsaddr - Address resource descriptors (16/32/64)
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2003, 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");
166 * Point past the Descriptor to get the number of bytes consumed
169 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
171 /* Validate minimum descriptor length */
175 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
178 *BytesConsumed = Temp16 + 3;
179 OutputStruct->Id = ACPI_RSTYPE_ADDRESS16;
182 * Get the Resource Type (Byte3)
187 /* Values 0-2 are valid */
191 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
194 OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03;
197 * Get the General Flags (Byte4)
202 /* Producer / Consumer */
204 OutputStruct->Data.Address16.ProducerConsumer = Temp8 & 0x01;
208 OutputStruct->Data.Address16.Decode = (Temp8 >> 1) & 0x01;
210 /* Min Address Fixed */
212 OutputStruct->Data.Address16.MinAddressFixed = (Temp8 >> 2) & 0x01;
214 /* Max Address Fixed */
216 OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01;
219 * Get the Type Specific Flags (Byte5)
224 if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address16.ResourceType)
226 OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute =
227 (UINT16) (Temp8 & 0x01);
228 OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute =
229 (UINT16) ((Temp8 >> 1) & 0x0F);
233 if (ACPI_IO_RANGE == OutputStruct->Data.Address16.ResourceType)
235 OutputStruct->Data.Address16.Attribute.Io.RangeAttribute =
236 (UINT16) (Temp8 & 0x03);
237 OutputStruct->Data.Address16.Attribute.Io.TranslationAttribute =
238 (UINT16) ((Temp8 >> 4) & 0x03);
242 /* BUS_NUMBER_RANGE == Address16.Data->ResourceType */
243 /* Nothing needs to be filled in */
248 * Get Granularity (Bytes 6-7)
251 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.Granularity, Buffer);
254 * Get MinAddressRange (Bytes 8-9)
257 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MinAddressRange, Buffer);
260 * Get MaxAddressRange (Bytes 10-11)
263 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MaxAddressRange, Buffer);
266 * Get AddressTranslationOffset (Bytes 12-13)
269 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressTranslationOffset, Buffer);
272 * Get AddressLength (Bytes 14-15)
275 ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressLength, Buffer);
278 * Resource Source Index (if present)
283 * This will leave us pointing to the Resource Source Index
284 * If it is present, then save it off and calculate the
285 * pointer to where the null terminated string goes:
286 * Each Interrupt takes 32-bits + the 5 bytes of the
287 * stream that are default.
289 * Note: Some resource descriptors will have an additional null, so
290 * we add 1 to the length.
292 if (*BytesConsumed > (16 + 1))
294 /* Dereference the Index */
297 OutputStruct->Data.Address16.ResourceSource.Index = (UINT32) Temp8;
299 /* Point to the String */
303 /* Point the String pointer to the end of this structure */
305 OutputStruct->Data.Address16.ResourceSource.StringPtr =
306 (char *)((UINT8 * )OutputStruct + StructSize);
308 TempPtr = (UINT8 *) OutputStruct->Data.Address16.ResourceSource.StringPtr;
310 /* Copy the string into the buffer */
314 while (0x00 != *Buffer)
324 * Add the terminating null
328 OutputStruct->Data.Address16.ResourceSource.StringLength = Index + 1;
331 * In order for the StructSize to fall on a 32-bit boundary,
332 * calculate the length of the string and expand the
333 * StructSize to the next 32-bit boundary.
335 Temp8 = (UINT8) (Index + 1);
336 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
340 OutputStruct->Data.Address16.ResourceSource.Index = 0x00;
341 OutputStruct->Data.Address16.ResourceSource.StringLength = 0;
342 OutputStruct->Data.Address16.ResourceSource.StringPtr = NULL;
346 * Set the Length parameter
348 OutputStruct->Length = (UINT32) StructSize;
351 * Return the final size of the structure
353 *StructureSize = StructSize;
354 return_ACPI_STATUS (AE_OK);
358 /*******************************************************************************
360 * FUNCTION: AcpiRsAddress16Stream
362 * PARAMETERS: LinkedList - Pointer to the resource linked list
363 * OutputBuffer - Pointer to the user's return buffer
364 * BytesConsumed - Pointer to where the number of bytes
365 * used in the OutputBuffer is returned
369 * DESCRIPTION: Take the linked list resource structure and fills in the
370 * the appropriate bytes in a byte stream
372 ******************************************************************************/
375 AcpiRsAddress16Stream (
376 ACPI_RESOURCE *LinkedList,
377 UINT8 **OutputBuffer,
378 ACPI_SIZE *BytesConsumed)
380 UINT8 *Buffer = *OutputBuffer;
383 char *TempPointer = NULL;
384 ACPI_SIZE ActualBytes;
387 ACPI_FUNCTION_TRACE ("RsAddress16Stream");
391 * The descriptor field is static
397 * Save a pointer to the Length field - to be filled in later
399 LengthField = Buffer;
403 * Set the Resource Type (Memory, Io, BusNumber)
405 Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03);
410 * Set the general flags
412 Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01);
414 Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1;
415 Temp8 |= (LinkedList->Data.Address16.MinAddressFixed & 0x01) << 2;
416 Temp8 |= (LinkedList->Data.Address16.MaxAddressFixed & 0x01) << 3;
422 * Set the type specific flags
426 if (ACPI_MEMORY_RANGE == LinkedList->Data.Address16.ResourceType)
429 (LinkedList->Data.Address16.Attribute.Memory.ReadWriteAttribute &
433 (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute &
436 else if (ACPI_IO_RANGE == LinkedList->Data.Address16.ResourceType)
439 (LinkedList->Data.Address16.Attribute.Io.RangeAttribute &
442 (LinkedList->Data.Address16.Attribute.Io.TranslationAttribute &
450 * Set the address space granularity
452 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.Granularity);
456 * Set the address range minimum
458 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MinAddressRange);
462 * Set the address range maximum
464 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MaxAddressRange);
468 * Set the address translation offset
470 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressTranslationOffset);
474 * Set the address length
476 ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressLength);
480 * Resource Source Index and Resource Source are optional
482 if (0 != LinkedList->Data.Address16.ResourceSource.StringLength)
484 Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSource.Index;
489 TempPointer = (char *) Buffer;
494 ACPI_STRCPY (TempPointer,
495 LinkedList->Data.Address16.ResourceSource.StringPtr);
498 * Buffer needs to be set to the length of the sting + one for the
501 Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address16.ResourceSource.StringPtr) + 1);
505 * Return the number of bytes consumed in this operation
507 ActualBytes = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
508 *BytesConsumed = ActualBytes;
511 * Set the length field to the number of bytes consumed
512 * minus the header size (3 bytes)
515 ACPI_MOVE_SIZE_TO_16 (LengthField, &ActualBytes);
516 return_ACPI_STATUS (AE_OK);
520 /*******************************************************************************
522 * FUNCTION: AcpiRsAddress32Resource
524 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
526 * BytesConsumed - Pointer to where the number of bytes
527 * consumed the ByteStreamBuffer is
529 * OutputBuffer - Pointer to the return data buffer
530 * StructureSize - Pointer to where the number of bytes
531 * in the return data struct is returned
535 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
536 * structure pointed to by the OutputBuffer. Return the
537 * number of bytes consumed from the byte stream.
539 ******************************************************************************/
542 AcpiRsAddress32Resource (
543 UINT8 *ByteStreamBuffer,
544 ACPI_SIZE *BytesConsumed,
545 UINT8 **OutputBuffer,
546 ACPI_SIZE *StructureSize)
549 ACPI_RESOURCE *OutputStruct= (void *) *OutputBuffer;
553 ACPI_SIZE StructSize;
557 ACPI_FUNCTION_TRACE ("RsAddress32Resource");
560 Buffer = ByteStreamBuffer;
561 StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS32);
564 * Point past the Descriptor to get the number of bytes consumed
567 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
569 /* Validate minimum descriptor length */
573 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
576 *BytesConsumed = Temp16 + 3;
577 OutputStruct->Id = ACPI_RSTYPE_ADDRESS32;
580 * Get the Resource Type (Byte3)
585 /* Values 0-2 are valid */
588 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
591 OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03;
594 * Get the General Flags (Byte4)
600 * Producer / Consumer
602 OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01;
607 OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01;
612 OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01;
617 OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01;
620 * Get the Type Specific Flags (Byte5)
625 if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address32.ResourceType)
627 OutputStruct->Data.Address32.Attribute.Memory.ReadWriteAttribute =
628 (UINT16) (Temp8 & 0x01);
630 OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute =
631 (UINT16) ((Temp8 >> 1) & 0x0F);
635 if (ACPI_IO_RANGE == OutputStruct->Data.Address32.ResourceType)
637 OutputStruct->Data.Address32.Attribute.Io.RangeAttribute =
638 (UINT16) (Temp8 & 0x03);
639 OutputStruct->Data.Address32.Attribute.Io.TranslationAttribute =
640 (UINT16) ((Temp8 >> 4) & 0x03);
644 /* BUS_NUMBER_RANGE == OutputStruct->Data.Address32.ResourceType */
645 /* Nothing needs to be filled in */
650 * Get Granularity (Bytes 6-9)
653 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.Granularity, Buffer);
656 * Get MinAddressRange (Bytes 10-13)
659 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange, Buffer);
662 * Get MaxAddressRange (Bytes 14-17)
665 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange, Buffer);
668 * Get AddressTranslationOffset (Bytes 18-21)
671 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressTranslationOffset, Buffer);
674 * Get AddressLength (Bytes 22-25)
677 ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressLength, Buffer);
680 * Resource Source Index (if present)
685 * This will leave us pointing to the Resource Source Index
686 * If it is present, then save it off and calculate the
687 * pointer to where the null terminated string goes:
689 * Note: Some resource descriptors will have an additional null, so
690 * we add 1 to the length.
692 if (*BytesConsumed > (26 + 1))
694 /* Dereference the Index */
697 OutputStruct->Data.Address32.ResourceSource.Index =
700 /* Point to the String */
704 /* Point the String pointer to the end of this structure */
706 OutputStruct->Data.Address32.ResourceSource.StringPtr =
707 (char *)((UINT8 *)OutputStruct + StructSize);
709 TempPtr = (UINT8 *) OutputStruct->Data.Address32.ResourceSource.StringPtr;
711 /* Copy the string into the buffer */
714 while (0x00 != *Buffer)
724 * Add the terminating null
727 OutputStruct->Data.Address32.ResourceSource.StringLength = Index + 1;
730 * In order for the StructSize to fall on a 32-bit boundary,
731 * calculate the length of the string and expand the
732 * StructSize to the next 32-bit boundary.
734 Temp8 = (UINT8) (Index + 1);
735 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
739 OutputStruct->Data.Address32.ResourceSource.Index = 0x00;
740 OutputStruct->Data.Address32.ResourceSource.StringLength = 0;
741 OutputStruct->Data.Address32.ResourceSource.StringPtr = NULL;
745 * Set the Length parameter
747 OutputStruct->Length = (UINT32) StructSize;
750 * Return the final size of the structure
752 *StructureSize = StructSize;
753 return_ACPI_STATUS (AE_OK);
757 /*******************************************************************************
759 * FUNCTION: AcpiRsAddress32Stream
761 * PARAMETERS: LinkedList - Pointer to the resource linked list
762 * OutputBuffer - Pointer to the user's return buffer
763 * BytesConsumed - Pointer to where the number of bytes
764 * used in the OutputBuffer is returned
768 * DESCRIPTION: Take the linked list resource structure and fills in the
769 * the appropriate bytes in a byte stream
771 ******************************************************************************/
774 AcpiRsAddress32Stream (
775 ACPI_RESOURCE *LinkedList,
776 UINT8 **OutputBuffer,
777 ACPI_SIZE *BytesConsumed)
785 ACPI_FUNCTION_TRACE ("RsAddress32Stream");
788 Buffer = *OutputBuffer;
791 * The descriptor field is static
797 * Set a pointer to the Length field - to be filled in later
799 LengthField = ACPI_CAST_PTR (UINT16, Buffer);
803 * Set the Resource Type (Memory, Io, BusNumber)
805 Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03);
811 * Set the general flags
813 Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01);
814 Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1;
815 Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2;
816 Temp8 |= (LinkedList->Data.Address32.MaxAddressFixed & 0x01) << 3;
822 * Set the type specific flags
826 if (ACPI_MEMORY_RANGE == LinkedList->Data.Address32.ResourceType)
829 (LinkedList->Data.Address32.Attribute.Memory.ReadWriteAttribute &
833 (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute &
836 else if (ACPI_IO_RANGE == LinkedList->Data.Address32.ResourceType)
839 (LinkedList->Data.Address32.Attribute.Io.RangeAttribute &
842 (LinkedList->Data.Address32.Attribute.Io.TranslationAttribute &
850 * Set the address space granularity
852 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.Granularity);
856 * Set the address range minimum
858 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MinAddressRange);
862 * Set the address range maximum
864 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MaxAddressRange);
868 * Set the address translation offset
870 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressTranslationOffset);
874 * Set the address length
876 ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressLength);
880 * Resource Source Index and Resource Source are optional
882 if (0 != LinkedList->Data.Address32.ResourceSource.StringLength)
884 Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSource.Index;
889 TempPointer = (char *) Buffer;
894 ACPI_STRCPY (TempPointer,
895 LinkedList->Data.Address32.ResourceSource.StringPtr);
898 * Buffer needs to be set to the length of the sting + one for the
901 Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address32.ResourceSource.StringPtr) + 1);
905 * Return the number of bytes consumed in this operation
907 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
910 * Set the length field to the number of bytes consumed
911 * minus the header size (3 bytes)
913 *LengthField = (UINT16) (*BytesConsumed - 3);
914 return_ACPI_STATUS (AE_OK);
918 /*******************************************************************************
920 * FUNCTION: AcpiRsAddress64Resource
922 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
924 * BytesConsumed - Pointer to where the number of bytes
925 * consumed the ByteStreamBuffer is
927 * OutputBuffer - Pointer to the return data buffer
928 * StructureSize - Pointer to where the number of bytes
929 * in the return data struct is returned
933 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
934 * structure pointed to by the OutputBuffer. Return the
935 * number of bytes consumed from the byte stream.
937 ******************************************************************************/
940 AcpiRsAddress64Resource (
941 UINT8 *ByteStreamBuffer,
942 ACPI_SIZE *BytesConsumed,
943 UINT8 **OutputBuffer,
944 ACPI_SIZE *StructureSize)
947 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
951 ACPI_SIZE StructSize;
955 ACPI_FUNCTION_TRACE ("RsAddress64Resource");
958 Buffer = ByteStreamBuffer;
959 StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64);
962 * Point past the Descriptor to get the number of bytes consumed
965 ACPI_MOVE_16_TO_16 (&Temp16, Buffer);
967 /* Validate minimum descriptor length */
971 return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
974 *BytesConsumed = Temp16 + 3;
975 OutputStruct->Id = ACPI_RSTYPE_ADDRESS64;
978 * Get the Resource Type (Byte3)
983 /* Values 0-2 are valid */
987 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
990 OutputStruct->Data.Address64.ResourceType = Temp8 & 0x03;
993 * Get the General Flags (Byte4)
999 * Producer / Consumer
1001 OutputStruct->Data.Address64.ProducerConsumer = Temp8 & 0x01;
1006 OutputStruct->Data.Address64.Decode = (Temp8 >> 1) & 0x01;
1011 OutputStruct->Data.Address64.MinAddressFixed = (Temp8 >> 2) & 0x01;
1016 OutputStruct->Data.Address64.MaxAddressFixed = (Temp8 >> 3) & 0x01;
1019 * Get the Type Specific Flags (Byte5)
1024 if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address64.ResourceType)
1026 OutputStruct->Data.Address64.Attribute.Memory.ReadWriteAttribute =
1027 (UINT16) (Temp8 & 0x01);
1029 OutputStruct->Data.Address64.Attribute.Memory.CacheAttribute =
1030 (UINT16) ((Temp8 >> 1) & 0x0F);
1034 if (ACPI_IO_RANGE == OutputStruct->Data.Address64.ResourceType)
1036 OutputStruct->Data.Address64.Attribute.Io.RangeAttribute =
1037 (UINT16) (Temp8 & 0x03);
1038 OutputStruct->Data.Address64.Attribute.Io.TranslationAttribute =
1039 (UINT16) ((Temp8 >> 4) & 0x03);
1043 /* BUS_NUMBER_RANGE == OutputStruct->Data.Address64.ResourceType */
1044 /* Nothing needs to be filled in */
1049 * Get Granularity (Bytes 6-13)
1052 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.Granularity, Buffer);
1055 * Get MinAddressRange (Bytes 14-21)
1058 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MinAddressRange, Buffer);
1061 * Get MaxAddressRange (Bytes 22-29)
1064 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MaxAddressRange, Buffer);
1067 * Get AddressTranslationOffset (Bytes 30-37)
1070 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressTranslationOffset, Buffer);
1073 * Get AddressLength (Bytes 38-45)
1076 ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressLength, Buffer);
1079 * Resource Source Index (if present)
1084 * This will leave us pointing to the Resource Source Index
1085 * If it is present, then save it off and calculate the
1086 * pointer to where the null terminated string goes:
1087 * Each Interrupt takes 32-bits + the 5 bytes of the
1088 * stream that are default.
1090 * Note: Some resource descriptors will have an additional null, so
1091 * we add 1 to the length.
1093 if (*BytesConsumed > (46 + 1))
1095 /* Dereference the Index */
1098 OutputStruct->Data.Address64.ResourceSource.Index =
1101 /* Point to the String */
1105 /* Point the String pointer to the end of this structure */
1107 OutputStruct->Data.Address64.ResourceSource.StringPtr =
1108 (char *)((UINT8 *)OutputStruct + StructSize);
1110 TempPtr = (UINT8 *) OutputStruct->Data.Address64.ResourceSource.StringPtr;
1112 /* Copy the string into the buffer */
1115 while (0x00 != *Buffer)
1125 * Add the terminating null
1128 OutputStruct->Data.Address64.ResourceSource.StringLength = Index + 1;
1131 * In order for the StructSize to fall on a 32-bit boundary,
1132 * calculate the length of the string and expand the
1133 * StructSize to the next 32-bit boundary.
1135 Temp8 = (UINT8) (Index + 1);
1136 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
1140 OutputStruct->Data.Address64.ResourceSource.Index = 0x00;
1141 OutputStruct->Data.Address64.ResourceSource.StringLength = 0;
1142 OutputStruct->Data.Address64.ResourceSource.StringPtr = NULL;
1146 * Set the Length parameter
1148 OutputStruct->Length = (UINT32) StructSize;
1151 * Return the final size of the structure
1153 *StructureSize = StructSize;
1154 return_ACPI_STATUS (AE_OK);
1158 /*******************************************************************************
1160 * FUNCTION: AcpiRsAddress64Stream
1162 * PARAMETERS: LinkedList - Pointer to the resource linked list
1163 * OutputBuffer - Pointer to the user's return buffer
1164 * BytesConsumed - Pointer to where the number of bytes
1165 * used in the OutputBuffer is returned
1169 * DESCRIPTION: Take the linked list resource structure and fills in the
1170 * the appropriate bytes in a byte stream
1172 ******************************************************************************/
1175 AcpiRsAddress64Stream (
1176 ACPI_RESOURCE *LinkedList,
1177 UINT8 **OutputBuffer,
1178 ACPI_SIZE *BytesConsumed)
1181 UINT16 *LengthField;
1186 ACPI_FUNCTION_TRACE ("RsAddress64Stream");
1189 Buffer = *OutputBuffer;
1192 * The descriptor field is static
1198 * Set a pointer to the Length field - to be filled in later
1200 LengthField = ACPI_CAST_PTR (UINT16, Buffer);
1204 * Set the Resource Type (Memory, Io, BusNumber)
1206 Temp8 = (UINT8) (LinkedList->Data.Address64.ResourceType & 0x03);
1212 * Set the general flags
1214 Temp8 = (UINT8) (LinkedList->Data.Address64.ProducerConsumer & 0x01);
1215 Temp8 |= (LinkedList->Data.Address64.Decode & 0x01) << 1;
1216 Temp8 |= (LinkedList->Data.Address64.MinAddressFixed & 0x01) << 2;
1217 Temp8 |= (LinkedList->Data.Address64.MaxAddressFixed & 0x01) << 3;
1223 * Set the type specific flags
1227 if (ACPI_MEMORY_RANGE == LinkedList->Data.Address64.ResourceType)
1230 (LinkedList->Data.Address64.Attribute.Memory.ReadWriteAttribute &
1234 (LinkedList->Data.Address64.Attribute.Memory.CacheAttribute &
1237 else if (ACPI_IO_RANGE == LinkedList->Data.Address64.ResourceType)
1240 (LinkedList->Data.Address64.Attribute.Io.RangeAttribute &
1243 (LinkedList->Data.Address64.Attribute.Io.RangeAttribute &
1251 * Set the address space granularity
1253 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.Granularity);
1257 * Set the address range minimum
1259 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MinAddressRange);
1263 * Set the address range maximum
1265 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MaxAddressRange);
1269 * Set the address translation offset
1271 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressTranslationOffset);
1275 * Set the address length
1277 ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressLength);
1281 * Resource Source Index and Resource Source are optional
1283 if (0 != LinkedList->Data.Address64.ResourceSource.StringLength)
1285 Temp8 = (UINT8) LinkedList->Data.Address64.ResourceSource.Index;
1290 TempPointer = (char *) Buffer;
1295 ACPI_STRCPY (TempPointer, LinkedList->Data.Address64.ResourceSource.StringPtr);
1298 * Buffer needs to be set to the length of the sting + one for the
1301 Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address64.ResourceSource.StringPtr) + 1);
1305 * Return the number of bytes consumed in this operation
1307 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
1310 * Set the length field to the number of bytes consumed
1311 * minus the header size (3 bytes)
1313 *LengthField = (UINT16) (*BytesConsumed - 3);
1314 return_ACPI_STATUS (AE_OK);