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 *****************************************************************************/
116 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/rsaddr.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $ */
123 #define _COMPONENT ACPI_RESOURCES
124 ACPI_MODULE_NAME ("rsaddr")
127 /*******************************************************************************
129 * FUNCTION: AcpiRsAddress16Resource
131 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
133 * BytesConsumed - Pointer to where the number of bytes
134 * consumed the ByteStreamBuffer is
136 * OutputBuffer - Pointer to the return data buffer
137 * StructureSize - Pointer to where the number of bytes
138 * in the return data struct is returned
142 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
143 * structure pointed to by the OutputBuffer. Return the
144 * number of bytes consumed from the byte stream.
146 ******************************************************************************/
149 AcpiRsAddress16Resource (
150 UINT8 *ByteStreamBuffer,
151 ACPI_SIZE *BytesConsumed,
152 UINT8 **OutputBuffer,
153 ACPI_SIZE *StructureSize)
155 UINT8 *Buffer = ByteStreamBuffer;
156 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
158 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16);
164 ACPI_FUNCTION_TRACE ("RsAddress16Resource");
167 * Point past the Descriptor to get the number of bytes consumed
170 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
172 *BytesConsumed = Temp16 + 3;
173 OutputStruct->Id = ACPI_RSTYPE_ADDRESS16;
176 * Get the Resource Type (Byte3)
181 /* Values 0-2 are valid */
185 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
188 OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03;
191 * Get the General Flags (Byte4)
196 /* Producer / Consumer */
198 OutputStruct->Data.Address16.ProducerConsumer = Temp8 & 0x01;
202 OutputStruct->Data.Address16.Decode = (Temp8 >> 1) & 0x01;
204 /* Min Address Fixed */
206 OutputStruct->Data.Address16.MinAddressFixed = (Temp8 >> 2) & 0x01;
208 /* Max Address Fixed */
210 OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01;
213 * Get the Type Specific Flags (Byte5)
218 if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address16.ResourceType)
220 OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute =
221 (UINT16) (Temp8 & 0x01);
222 OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute =
223 (UINT16) ((Temp8 >> 1) & 0x0F);
227 if (ACPI_IO_RANGE == OutputStruct->Data.Address16.ResourceType)
229 OutputStruct->Data.Address16.Attribute.Io.RangeAttribute =
230 (UINT16) (Temp8 & 0x03);
231 OutputStruct->Data.Address16.Attribute.Io.TranslationAttribute =
232 (UINT16) ((Temp8 >> 4) & 0x03);
236 /* BUS_NUMBER_RANGE == Address16.Data->ResourceType */
237 /* Nothing needs to be filled in */
242 * Get Granularity (Bytes 6-7)
245 ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.Granularity,
249 * Get MinAddressRange (Bytes 8-9)
252 ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.MinAddressRange,
256 * Get MaxAddressRange (Bytes 10-11)
259 ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.MaxAddressRange,
263 * Get AddressTranslationOffset (Bytes 12-13)
266 ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.AddressTranslationOffset,
270 * Get AddressLength (Bytes 14-15)
273 ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.AddressLength,
277 * Resource Source Index (if present)
282 * This will leave us pointing to the Resource Source Index
283 * If it is present, then save it off and calculate the
284 * pointer to where the null terminated string goes:
285 * Each Interrupt takes 32-bits + the 5 bytes of the
286 * stream that are default.
288 if (*BytesConsumed > 16)
290 /* Dereference the Index */
293 OutputStruct->Data.Address16.ResourceSource.Index = (UINT32) Temp8;
295 /* Point to the String */
299 /* Point the String pointer to the end of this structure */
301 OutputStruct->Data.Address16.ResourceSource.StringPtr =
302 (char *)((UINT8 * )OutputStruct + StructSize);
304 TempPtr = (UINT8 *) OutputStruct->Data.Address16.ResourceSource.StringPtr;
306 /* Copy the string into the buffer */
310 while (0x00 != *Buffer)
320 * Add the terminating null
324 OutputStruct->Data.Address16.ResourceSource.StringLength = Index + 1;
327 * In order for the StructSize to fall on a 32-bit boundary,
328 * calculate the length of the string and expand the
329 * StructSize to the next 32-bit boundary.
331 Temp8 = (UINT8) (Index + 1);
332 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
336 OutputStruct->Data.Address16.ResourceSource.Index = 0x00;
337 OutputStruct->Data.Address16.ResourceSource.StringLength = 0;
338 OutputStruct->Data.Address16.ResourceSource.StringPtr = NULL;
342 * Set the Length parameter
344 OutputStruct->Length = (UINT32) StructSize;
347 * Return the final size of the structure
349 *StructureSize = StructSize;
350 return_ACPI_STATUS (AE_OK);
354 /*******************************************************************************
356 * FUNCTION: AcpiRsAddress16Stream
358 * PARAMETERS: LinkedList - Pointer to the resource linked list
359 * OutputBuffer - Pointer to the user's return buffer
360 * BytesConsumed - Pointer to where the number of bytes
361 * used in the OutputBuffer is returned
365 * DESCRIPTION: Take the linked list resource structure and fills in the
366 * the appropriate bytes in a byte stream
368 ******************************************************************************/
371 AcpiRsAddress16Stream (
372 ACPI_RESOURCE *LinkedList,
373 UINT8 **OutputBuffer,
374 ACPI_SIZE *BytesConsumed)
376 UINT8 *Buffer = *OutputBuffer;
379 char *TempPointer = NULL;
380 ACPI_SIZE ActualBytes;
383 ACPI_FUNCTION_TRACE ("RsAddress16Stream");
387 * The descriptor field is static
393 * Save a pointer to the Length field - to be filled in later
395 LengthField = Buffer;
399 * Set the Resource Type (Memory, Io, BusNumber)
401 Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03);
406 * Set the general flags
408 Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01);
410 Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1;
411 Temp8 |= (LinkedList->Data.Address16.MinAddressFixed & 0x01) << 2;
412 Temp8 |= (LinkedList->Data.Address16.MaxAddressFixed & 0x01) << 3;
418 * Set the type specific flags
422 if (ACPI_MEMORY_RANGE == LinkedList->Data.Address16.ResourceType)
425 (LinkedList->Data.Address16.Attribute.Memory.ReadWriteAttribute &
429 (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute &
432 else if (ACPI_IO_RANGE == LinkedList->Data.Address16.ResourceType)
435 (LinkedList->Data.Address16.Attribute.Io.RangeAttribute &
438 (LinkedList->Data.Address16.Attribute.Io.TranslationAttribute &
446 * Set the address space granularity
448 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
449 &LinkedList->Data.Address16.Granularity);
453 * Set the address range minimum
455 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
456 &LinkedList->Data.Address16.MinAddressRange);
460 * Set the address range maximum
462 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
463 &LinkedList->Data.Address16.MaxAddressRange);
467 * Set the address translation offset
469 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
470 &LinkedList->Data.Address16.AddressTranslationOffset);
474 * Set the address length
476 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
477 &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_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_UNALIGNED16_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_UNALIGNED16_TO_16 (&Temp16, Buffer);
569 *BytesConsumed = Temp16 + 3;
571 OutputStruct->Id = ACPI_RSTYPE_ADDRESS32;
574 * Get the Resource Type (Byte3)
579 /* Values 0-2 are valid */
582 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
585 OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03;
588 * Get the General Flags (Byte4)
594 * Producer / Consumer
596 OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01;
601 OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01;
606 OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01;
611 OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01;
614 * Get the Type Specific Flags (Byte5)
619 if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address32.ResourceType)
621 OutputStruct->Data.Address32.Attribute.Memory.ReadWriteAttribute =
622 (UINT16) (Temp8 & 0x01);
624 OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute =
625 (UINT16) ((Temp8 >> 1) & 0x0F);
629 if (ACPI_IO_RANGE == OutputStruct->Data.Address32.ResourceType)
631 OutputStruct->Data.Address32.Attribute.Io.RangeAttribute =
632 (UINT16) (Temp8 & 0x03);
633 OutputStruct->Data.Address32.Attribute.Io.TranslationAttribute =
634 (UINT16) ((Temp8 >> 4) & 0x03);
638 /* BUS_NUMBER_RANGE == OutputStruct->Data.Address32.ResourceType */
639 /* Nothing needs to be filled in */
644 * Get Granularity (Bytes 6-9)
647 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.Granularity,
651 * Get MinAddressRange (Bytes 10-13)
654 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange,
658 * Get MaxAddressRange (Bytes 14-17)
661 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange,
665 * Get AddressTranslationOffset (Bytes 18-21)
668 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.AddressTranslationOffset,
672 * Get AddressLength (Bytes 22-25)
675 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.AddressLength,
679 * Resource Source Index (if present)
684 * This will leave us pointing to the Resource Source Index
685 * If it is present, then save it off and calculate the
686 * pointer to where the null terminated string goes:
688 if (*BytesConsumed > 26)
690 /* Dereference the Index */
693 OutputStruct->Data.Address32.ResourceSource.Index =
696 /* Point to the String */
700 /* Point the String pointer to the end of this structure */
702 OutputStruct->Data.Address32.ResourceSource.StringPtr =
703 (char *)((UINT8 *)OutputStruct + StructSize);
705 TempPtr = (UINT8 *) OutputStruct->Data.Address32.ResourceSource.StringPtr;
707 /* Copy the string into the buffer */
710 while (0x00 != *Buffer)
720 * Add the terminating null
723 OutputStruct->Data.Address32.ResourceSource.StringLength = Index + 1;
726 * In order for the StructSize to fall on a 32-bit boundary,
727 * calculate the length of the string and expand the
728 * StructSize to the next 32-bit boundary.
730 Temp8 = (UINT8) (Index + 1);
731 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
735 OutputStruct->Data.Address32.ResourceSource.Index = 0x00;
736 OutputStruct->Data.Address32.ResourceSource.StringLength = 0;
737 OutputStruct->Data.Address32.ResourceSource.StringPtr = NULL;
741 * Set the Length parameter
743 OutputStruct->Length = (UINT32) StructSize;
746 * Return the final size of the structure
748 *StructureSize = StructSize;
749 return_ACPI_STATUS (AE_OK);
753 /*******************************************************************************
755 * FUNCTION: AcpiRsAddress32Stream
757 * PARAMETERS: LinkedList - Pointer to the resource linked list
758 * OutputBuffer - Pointer to the user's return buffer
759 * BytesConsumed - Pointer to where the number of bytes
760 * used in the OutputBuffer is returned
764 * DESCRIPTION: Take the linked list resource structure and fills in the
765 * the appropriate bytes in a byte stream
767 ******************************************************************************/
770 AcpiRsAddress32Stream (
771 ACPI_RESOURCE *LinkedList,
772 UINT8 **OutputBuffer,
773 ACPI_SIZE *BytesConsumed)
781 ACPI_FUNCTION_TRACE ("RsAddress32Stream");
784 Buffer = *OutputBuffer;
787 * The descriptor field is static
793 * Set a pointer to the Length field - to be filled in later
795 LengthField = ACPI_CAST_PTR (UINT16, Buffer);
799 * Set the Resource Type (Memory, Io, BusNumber)
801 Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03);
807 * Set the general flags
809 Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01);
810 Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1;
811 Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2;
812 Temp8 |= (LinkedList->Data.Address32.MaxAddressFixed & 0x01) << 3;
818 * Set the type specific flags
822 if (ACPI_MEMORY_RANGE == LinkedList->Data.Address32.ResourceType)
825 (LinkedList->Data.Address32.Attribute.Memory.ReadWriteAttribute &
829 (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute &
832 else if (ACPI_IO_RANGE == LinkedList->Data.Address32.ResourceType)
835 (LinkedList->Data.Address32.Attribute.Io.RangeAttribute &
838 (LinkedList->Data.Address32.Attribute.Io.TranslationAttribute &
846 * Set the address space granularity
848 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
849 &LinkedList->Data.Address32.Granularity);
853 * Set the address range minimum
855 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
856 &LinkedList->Data.Address32.MinAddressRange);
860 * Set the address range maximum
862 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
863 &LinkedList->Data.Address32.MaxAddressRange);
867 * Set the address translation offset
869 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
870 &LinkedList->Data.Address32.AddressTranslationOffset);
874 * Set the address length
876 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
877 &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_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_UNALIGNED16_TO_16 (&Temp16, Buffer);
968 *BytesConsumed = Temp16 + 3;
969 OutputStruct->Id = ACPI_RSTYPE_ADDRESS64;
972 * Get the Resource Type (Byte3)
977 /* Values 0-2 are valid */
981 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
984 OutputStruct->Data.Address64.ResourceType = Temp8 & 0x03;
987 * Get the General Flags (Byte4)
993 * Producer / Consumer
995 OutputStruct->Data.Address64.ProducerConsumer = Temp8 & 0x01;
1000 OutputStruct->Data.Address64.Decode = (Temp8 >> 1) & 0x01;
1005 OutputStruct->Data.Address64.MinAddressFixed = (Temp8 >> 2) & 0x01;
1010 OutputStruct->Data.Address64.MaxAddressFixed = (Temp8 >> 3) & 0x01;
1013 * Get the Type Specific Flags (Byte5)
1018 if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address64.ResourceType)
1020 OutputStruct->Data.Address64.Attribute.Memory.ReadWriteAttribute =
1021 (UINT16) (Temp8 & 0x01);
1023 OutputStruct->Data.Address64.Attribute.Memory.CacheAttribute =
1024 (UINT16) ((Temp8 >> 1) & 0x0F);
1028 if (ACPI_IO_RANGE == OutputStruct->Data.Address64.ResourceType)
1030 OutputStruct->Data.Address64.Attribute.Io.RangeAttribute =
1031 (UINT16) (Temp8 & 0x03);
1032 OutputStruct->Data.Address64.Attribute.Io.TranslationAttribute =
1033 (UINT16) ((Temp8 >> 4) & 0x03);
1037 /* BUS_NUMBER_RANGE == OutputStruct->Data.Address64.ResourceType */
1038 /* Nothing needs to be filled in */
1043 * Get Granularity (Bytes 6-13)
1046 ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.Granularity,
1050 * Get MinAddressRange (Bytes 14-21)
1053 ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.MinAddressRange,
1057 * Get MaxAddressRange (Bytes 22-29)
1060 ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.MaxAddressRange,
1064 * Get AddressTranslationOffset (Bytes 30-37)
1067 ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.AddressTranslationOffset,
1071 * Get AddressLength (Bytes 38-45)
1074 ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.AddressLength,
1078 * Resource Source Index (if present)
1083 * This will leave us pointing to the Resource Source Index
1084 * If it is present, then save it off and calculate the
1085 * pointer to where the null terminated string goes:
1086 * Each Interrupt takes 32-bits + the 5 bytes of the
1087 * stream that are default.
1089 if (*BytesConsumed > 46)
1091 /* Dereference the Index */
1094 OutputStruct->Data.Address64.ResourceSource.Index =
1097 /* Point to the String */
1101 /* Point the String pointer to the end of this structure */
1103 OutputStruct->Data.Address64.ResourceSource.StringPtr =
1104 (char *)((UINT8 *)OutputStruct + StructSize);
1106 TempPtr = (UINT8 *) OutputStruct->Data.Address64.ResourceSource.StringPtr;
1108 /* Copy the string into the buffer */
1111 while (0x00 != *Buffer)
1121 * Add the terminating null
1125 OutputStruct->Data.Address64.ResourceSource.StringLength = Index + 1;
1128 * In order for the StructSize to fall on a 32-bit boundary,
1129 * calculate the length of the string and expand the
1130 * StructSize to the next 32-bit boundary.
1132 Temp8 = (UINT8) (Index + 1);
1133 StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
1137 OutputStruct->Data.Address64.ResourceSource.Index = 0x00;
1138 OutputStruct->Data.Address64.ResourceSource.StringLength = 0;
1139 OutputStruct->Data.Address64.ResourceSource.StringPtr = NULL;
1143 * Set the Length parameter
1145 OutputStruct->Length = (UINT32) StructSize;
1148 * Return the final size of the structure
1150 *StructureSize = StructSize;
1151 return_ACPI_STATUS (AE_OK);
1155 /*******************************************************************************
1157 * FUNCTION: AcpiRsAddress64Stream
1159 * PARAMETERS: LinkedList - Pointer to the resource linked list
1160 * OutputBuffer - Pointer to the user's return buffer
1161 * BytesConsumed - Pointer to where the number of bytes
1162 * used in the OutputBuffer is returned
1166 * DESCRIPTION: Take the linked list resource structure and fills in the
1167 * the appropriate bytes in a byte stream
1169 ******************************************************************************/
1172 AcpiRsAddress64Stream (
1173 ACPI_RESOURCE *LinkedList,
1174 UINT8 **OutputBuffer,
1175 ACPI_SIZE *BytesConsumed)
1178 UINT16 *LengthField;
1183 ACPI_FUNCTION_TRACE ("RsAddress64Stream");
1186 Buffer = *OutputBuffer;
1189 * The descriptor field is static
1195 * Set a pointer to the Length field - to be filled in later
1198 LengthField = ACPI_CAST_PTR (UINT16, Buffer);
1202 * Set the Resource Type (Memory, Io, BusNumber)
1204 Temp8 = (UINT8) (LinkedList->Data.Address64.ResourceType & 0x03);
1210 * Set the general flags
1212 Temp8 = (UINT8) (LinkedList->Data.Address64.ProducerConsumer & 0x01);
1213 Temp8 |= (LinkedList->Data.Address64.Decode & 0x01) << 1;
1214 Temp8 |= (LinkedList->Data.Address64.MinAddressFixed & 0x01) << 2;
1215 Temp8 |= (LinkedList->Data.Address64.MaxAddressFixed & 0x01) << 3;
1221 * Set the type specific flags
1225 if (ACPI_MEMORY_RANGE == LinkedList->Data.Address64.ResourceType)
1228 (LinkedList->Data.Address64.Attribute.Memory.ReadWriteAttribute &
1232 (LinkedList->Data.Address64.Attribute.Memory.CacheAttribute &
1235 else if (ACPI_IO_RANGE == LinkedList->Data.Address64.ResourceType)
1238 (LinkedList->Data.Address64.Attribute.Io.RangeAttribute &
1241 (LinkedList->Data.Address64.Attribute.Io.RangeAttribute &
1249 * Set the address space granularity
1251 ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
1252 &LinkedList->Data.Address64.Granularity);
1256 * Set the address range minimum
1258 ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
1259 &LinkedList->Data.Address64.MinAddressRange);
1263 * Set the address range maximum
1265 ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
1266 &LinkedList->Data.Address64.MaxAddressRange);
1270 * Set the address translation offset
1272 ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
1273 &LinkedList->Data.Address64.AddressTranslationOffset);
1277 * Set the address length
1279 ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
1280 &LinkedList->Data.Address64.AddressLength);
1284 * Resource Source Index and Resource Source are optional
1286 if (0 != LinkedList->Data.Address64.ResourceSource.StringLength)
1288 Temp8 = (UINT8) LinkedList->Data.Address64.ResourceSource.Index;
1293 TempPointer = (char *) Buffer;
1298 ACPI_STRCPY (TempPointer, LinkedList->Data.Address64.ResourceSource.StringPtr);
1301 * Buffer needs to be set to the length of the sting + one for the
1304 Buffer += (ACPI_STRLEN (LinkedList->Data.Address64.ResourceSource.StringPtr) + 1);
1308 * Return the number of bytes consumed in this operation
1310 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
1313 * Set the length field to the number of bytes consumed
1314 * minus the header size (3 bytes)
1316 *LengthField = (UINT16) (*BytesConsumed - 3);
1317 return_ACPI_STATUS (AE_OK);