aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/dev/acpica/Subsystem/Resources
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/Subsystem/Resources')
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rsaddr.c922
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c986
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c548
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c1044
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rsio.c636
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rsirq.c683
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rslist.c606
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rsmemory.c660
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rsmisc.c725
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rsutils.c511
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Resources/rsxface.c326
11 files changed, 7647 insertions, 0 deletions
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsaddr.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsaddr.c
new file mode 100644
index 000000000000..478441cfd083
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsaddr.c
@@ -0,0 +1,922 @@
+/*******************************************************************************
+ *
+ * Module Name: rsaddr - AcpiRsAddress16Resource
+ * AcpiRsAddress16Stream
+ * AcpiRsAddress32Resource
+ * AcpiRsAddress32Stream
+ * $Revision: 11 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __RSADDR_C__
+
+#include "acpi.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rsaddr")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress16Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress16Resource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT16 Temp16;
+ UINT8 Temp8;
+ UINT32 Index;
+ UINT32 StructSize = sizeof(ADDRESS16_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsAddress16Resource");
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ *BytesConsumed = Temp16 + 3;
+
+ OutputStruct->Id = Address16;
+
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Get the Resource Type (Byte3)
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ /* Values 0-2 are valid */
+ if (Temp8 > 2)
+ {
+ return_ACPI_STATUS (AE_AML_ERROR);
+ }
+
+ OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03;
+
+ /*
+ * Get the General Flags (Byte4)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /*
+ * Producer / Consumer
+ */
+ OutputStruct->Data.Address16.ProducerConsumer = Temp8 & 0x01;
+
+ /*
+ * Decode
+ */
+ OutputStruct->Data.Address16.Decode = (Temp8 >> 1) & 0x01;
+
+ /*
+ * Min Address Fixed
+ */
+ OutputStruct->Data.Address16.MinAddressFixed = (Temp8 >> 2) & 0x01;
+
+ /*
+ * Max Address Fixed
+ */
+ OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01;
+
+ /*
+ * Get the Type Specific Flags (Byte5)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ if (MEMORY_RANGE == OutputStruct->Data.Address16.ResourceType)
+ {
+ OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute =
+ (UINT16) (Temp8 & 0x01);
+ OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute =
+ (UINT16) ((Temp8 >> 1) & 0x0F);
+ }
+
+ else
+ {
+ if (IO_RANGE == OutputStruct->Data.Address16.ResourceType)
+ {
+ OutputStruct->Data.Address16.Attribute.Io.RangeAttribute =
+ (UINT16) (Temp8 & 0x03);
+ }
+
+ else
+ {
+ /* BUS_NUMBER_RANGE == Address32Data->ResourceType */
+ /* Nothing needs to be filled in */
+ }
+ }
+
+ /*
+ * Get Granularity (Bytes 6-7)
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.Granularity,
+ Buffer);
+
+ /*
+ * Get MinAddressRange (Bytes 8-9)
+ */
+ Buffer += 2;
+ MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.MinAddressRange,
+ Buffer);
+
+ /*
+ * Get MaxAddressRange (Bytes 10-11)
+ */
+ Buffer += 2;
+ MOVE_UNALIGNED16_TO_16
+ (&OutputStruct->Data.Address16.MaxAddressRange,
+ Buffer);
+
+ /*
+ * Get AddressTranslationOffset (Bytes 12-13)
+ */
+ Buffer += 2;
+ MOVE_UNALIGNED16_TO_16
+ (&OutputStruct->Data.Address16.AddressTranslationOffset,
+ Buffer);
+
+ /*
+ * Get AddressLength (Bytes 14-15)
+ */
+ Buffer += 2;
+ MOVE_UNALIGNED16_TO_16
+ (&OutputStruct->Data.Address16.AddressLength,
+ Buffer);
+
+ /*
+ * Resource Source Index (if present)
+ */
+ Buffer += 2;
+
+ /*
+ * This will leave us pointing to the Resource Source Index
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
+ * Each Interrupt takes 32-bits + the 5 bytes of the
+ * stream that are default.
+ */
+ if (*BytesConsumed > 16)
+ {
+ /* Dereference the Index */
+
+ Temp8 = *Buffer;
+ OutputStruct->Data.Address16.ResourceSourceIndex =
+ (UINT32) Temp8;
+
+ /* Point to the String */
+
+ Buffer += 1;
+
+ /* Copy the string into the buffer */
+
+ Index = 0;
+
+ while (0x00 != *Buffer)
+ {
+ OutputStruct->Data.Address16.ResourceSource[Index] =
+ *Buffer;
+
+ Buffer += 1;
+ Index += 1;
+ }
+
+ /*
+ * Add the terminating null
+ */
+ OutputStruct->Data.Address16.ResourceSource[Index] = 0x00;
+
+ OutputStruct->Data.Address16.ResourceSourceStringLength =
+ Index + 1;
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundry,
+ * calculate the length of the string and expand the
+ * StructSize to the next 32-bit boundry.
+ */
+ Temp8 = (UINT8) (Index + 1);
+ StructSize += ROUND_UP_TO_32BITS (Temp8);
+ OutputStruct->Length = StructSize;
+ }
+ else
+ {
+ OutputStruct->Data.Address16.ResourceSourceIndex = 0x00;
+ OutputStruct->Data.Address16.ResourceSourceStringLength = 0;
+ OutputStruct->Data.Address16.ResourceSource[0] = 0x00;
+ }
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress16Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress16Stream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT8 *LengthField;
+ UINT8 Temp8;
+ NATIVE_CHAR *TempPointer = NULL;
+ UINT32 ActualBytes;
+
+
+ FUNCTION_TRACE ("RsAddress16Stream");
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x88;
+ Buffer += 1;
+
+ /*
+ * Save a pointer to the Length field - to be filled in later
+ */
+ LengthField = Buffer;
+ Buffer += 2;
+
+ /*
+ * Set the Resource Type (Memory, Io, BusNumber)
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03);
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the general flags
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01);
+
+ Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1;
+ Temp8 |= (LinkedList->Data.Address16.MinAddressFixed & 0x01) << 2;
+ Temp8 |= (LinkedList->Data.Address16.MaxAddressFixed & 0x01) << 3;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the type specific flags
+ */
+ Temp8 = 0;
+
+ if (MEMORY_RANGE == LinkedList->Data.Address16.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address16.Attribute.Memory.ReadWriteAttribute &
+ 0x01);
+
+ Temp8 |=
+ (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute &
+ 0x0F) << 1;
+ }
+
+ else if (IO_RANGE == LinkedList->Data.Address16.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address16.Attribute.Io.RangeAttribute &
+ 0x03);
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the address space granularity
+ */
+ MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.Granularity);
+ Buffer += 2;
+
+ /*
+ * Set the address range minimum
+ */
+ MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.MinAddressRange);
+ Buffer += 2;
+
+ /*
+ * Set the address range maximum
+ */
+ MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.MaxAddressRange);
+ Buffer += 2;
+
+ /*
+ * Set the address translation offset
+ */
+ MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.AddressTranslationOffset);
+ Buffer += 2;
+
+ /*
+ * Set the address length
+ */
+ MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.AddressLength);
+ Buffer += 2;
+
+ /*
+ * Resource Source Index and Resource Source are optional
+ */
+ if (0 != LinkedList->Data.Address16.ResourceSourceStringLength)
+ {
+ Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSourceIndex;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ TempPointer = (NATIVE_CHAR *) Buffer;
+
+ /*
+ * Copy the string
+ */
+ STRCPY (TempPointer, LinkedList->Data.Address16.ResourceSource);
+
+ /*
+ * Buffer needs to be set to the length of the sting + one for the
+ * terminating null
+ */
+ Buffer += (STRLEN (LinkedList->Data.Address16.ResourceSource) + 1);
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ ActualBytes = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ *BytesConsumed = ActualBytes;
+
+ /*
+ * Set the length field to the number of bytes consumed
+ * minus the header size (3 bytes)
+ */
+ ActualBytes -= 3;
+ MOVE_UNALIGNED16_TO_16 (LengthField, &ActualBytes);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress32Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress32Resource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer;
+ RESOURCE *OutputStruct;
+ UINT16 Temp16;
+ UINT8 Temp8;
+ UINT32 StructSize;
+ UINT32 Index;
+
+
+ FUNCTION_TRACE ("RsAddress32Resource");
+
+ Buffer = ByteStreamBuffer;
+
+ OutputStruct = (RESOURCE *) *OutputBuffer;
+
+ StructSize = sizeof (ADDRESS32_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ *BytesConsumed = Temp16 + 3;
+
+ OutputStruct->Id = Address32;
+
+ /*
+ * Get the Resource Type (Byte3)
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ /* Values 0-2 are valid */
+ if(Temp8 > 2)
+ {
+ return_ACPI_STATUS (AE_AML_ERROR);
+ }
+
+ OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03;
+
+ /*
+ * Get the General Flags (Byte4)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /*
+ * Producer / Consumer
+ */
+ OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01;
+
+ /*
+ * Decode
+ */
+ OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01;
+
+ /*
+ * Min Address Fixed
+ */
+ OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01;
+
+ /*
+ * Max Address Fixed
+ */
+ OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01;
+
+ /*
+ * Get the Type Specific Flags (Byte5)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ if (MEMORY_RANGE == OutputStruct->Data.Address32.ResourceType)
+ {
+ OutputStruct->Data.Address32.Attribute.Memory.ReadWriteAttribute =
+ (UINT16) (Temp8 & 0x01);
+
+ OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute =
+ (UINT16) ((Temp8 >> 1) & 0x0F);
+ }
+
+ else
+ {
+ if (IO_RANGE == OutputStruct->Data.Address32.ResourceType)
+ {
+ OutputStruct->Data.Address32.Attribute.Io.RangeAttribute =
+ (UINT16) (Temp8 & 0x03);
+ }
+
+ else
+ {
+ /* BUS_NUMBER_RANGE == OutputStruct->Data.Address32.ResourceType */
+ /* Nothing needs to be filled in */
+ }
+ }
+
+ /*
+ * Get Granularity (Bytes 6-9)
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.Granularity,
+ Buffer);
+
+ /*
+ * Get MinAddressRange (Bytes 10-13)
+ */
+ Buffer += 4;
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange,
+ Buffer);
+
+ /*
+ * Get MaxAddressRange (Bytes 14-17)
+ */
+ Buffer += 4;
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange,
+ Buffer);
+
+ /*
+ * Get AddressTranslationOffset (Bytes 18-21)
+ */
+ Buffer += 4;
+ MOVE_UNALIGNED32_TO_32
+ (&OutputStruct->Data.Address32.AddressTranslationOffset,
+ Buffer);
+
+ /*
+ * Get AddressLength (Bytes 22-25)
+ */
+ Buffer += 4;
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.AddressLength,
+ Buffer);
+
+ /*
+ * Resource Source Index (if present)
+ */
+ Buffer += 4;
+
+ /*
+ * This will leave us pointing to the Resource Source Index
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
+ * Each Interrupt takes 32-bits + the 5 bytes of the
+ * stream that are default.
+ */
+ if (*BytesConsumed > 26)
+ {
+ /* Dereference the Index */
+
+ Temp8 = *Buffer;
+ OutputStruct->Data.Address32.ResourceSourceIndex = (UINT32)Temp8;
+
+ /* Point to the String */
+
+ Buffer += 1;
+
+ /* Copy the string into the buffer */
+
+ Index = 0;
+
+ while (0x00 != *Buffer)
+ {
+ OutputStruct->Data.Address32.ResourceSource[Index] = *Buffer;
+ Buffer += 1;
+ Index += 1;
+ }
+
+ /*
+ * Add the terminating null
+ */
+ OutputStruct->Data.Address32.ResourceSource[Index] = 0x00;
+
+ OutputStruct->Data.Address32.ResourceSourceStringLength = Index + 1;
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundry,
+ * calculate the length of the string and expand the
+ * StructSize to the next 32-bit boundry.
+ */
+ Temp8 = (UINT8) (Index + 1);
+ StructSize += ROUND_UP_TO_32BITS (Temp8);
+ }
+
+ else
+ {
+ OutputStruct->Data.Address32.ResourceSourceIndex = 0x00;
+ OutputStruct->Data.Address32.ResourceSourceStringLength = 0;
+ OutputStruct->Data.Address32.ResourceSource[0] = 0x00;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress32Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress32Stream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer;
+ UINT16 *LengthField;
+ UINT8 Temp8;
+ NATIVE_CHAR *TempPointer;
+
+
+ FUNCTION_TRACE ("RsAddress32Stream");
+
+ Buffer = *OutputBuffer;
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x87;
+ Buffer += 1;
+
+ /*
+ * Set a pointer to the Length field - to be filled in later
+ */
+
+ LengthField = (UINT16 *)Buffer;
+ Buffer += 2;
+
+ /*
+ * Set the Resource Type (Memory, Io, BusNumber)
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03);
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the general flags
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01);
+ Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1;
+ Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2;
+ Temp8 |= (LinkedList->Data.Address32.MaxAddressFixed & 0x01) << 3;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the type specific flags
+ */
+ Temp8 = 0;
+
+ if(MEMORY_RANGE == LinkedList->Data.Address32.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address32.Attribute.Memory.ReadWriteAttribute &
+ 0x01);
+
+ Temp8 |=
+ (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute &
+ 0x0F) << 1;
+ }
+
+ else if (IO_RANGE == LinkedList->Data.Address32.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address32.Attribute.Io.RangeAttribute &
+ 0x03);
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the address space granularity
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.Granularity);
+ Buffer += 4;
+
+ /*
+ * Set the address range minimum
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.MinAddressRange);
+ Buffer += 4;
+
+ /*
+ * Set the address range maximum
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.MaxAddressRange);
+ Buffer += 4;
+
+ /*
+ * Set the address translation offset
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.AddressTranslationOffset);
+ Buffer += 4;
+
+ /*
+ * Set the address length
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.AddressLength);
+ Buffer += 4;
+
+ /*
+ * Resource Source Index and Resource Source are optional
+ */
+ if (0 != LinkedList->Data.Address32.ResourceSourceStringLength)
+ {
+ Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSourceIndex;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ TempPointer = (NATIVE_CHAR *) Buffer;
+
+ /*
+ * Copy the string
+ */
+ STRCPY (TempPointer, LinkedList->Data.Address32.ResourceSource);
+
+ /*
+ * Buffer needs to be set to the length of the sting + one for the
+ * terminating null
+ */
+ Buffer += (STRLEN (LinkedList->Data.Address32.ResourceSource) + 1);
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ /*
+ * Set the length field to the number of bytes consumed
+ * minus the header size (3 bytes)
+ */
+ *LengthField = (UINT16) (*BytesConsumed - 3);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c b/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c
new file mode 100644
index 000000000000..5911adf73f40
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rscalc.c
@@ -0,0 +1,986 @@
+/*******************************************************************************
+ *
+ * Module Name: rscalc - AcpiRsCalculateByteStreamLength
+ * AcpiRsCalculateListLength
+ * $Revision: 11 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __RSCALC_C__
+
+#include "acpi.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rscalc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCalculateByteStreamLength
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * SizeNeeded - UINT32 pointer of the size buffer needed
+ * to properly return the parsed data
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Takes the resource byte stream and parses it once, calculating
+ * the size buffer needed to hold the linked list that conveys
+ * the resource data.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCalculateByteStreamLength (
+ RESOURCE *LinkedList,
+ UINT32 *SizeNeeded)
+{
+ UINT32 ByteStreamSizeNeeded = 0;
+ UINT32 SegmentSize;
+ EXTENDED_IRQ_RESOURCE *ExIrq = NULL;
+ BOOLEAN Done = FALSE;
+
+
+ FUNCTION_TRACE ("RsCalculateByteStreamLength");
+
+
+ while (!Done)
+ {
+
+ /*
+ * Init the variable that will hold the size to add to the
+ * total.
+ */
+ SegmentSize = 0;
+
+ switch (LinkedList->Id)
+ {
+ case Irq:
+ /*
+ * IRQ Resource
+ */
+ /*
+ * For an IRQ Resource, Byte 3, although optional, will
+ * always be created - it holds IRQ information.
+ */
+ SegmentSize = 4;
+ break;
+
+ case Dma:
+ /*
+ * DMA Resource
+ */
+ /*
+ * For this resource the size is static
+ */
+ SegmentSize = 3;
+ break;
+
+ case StartDependentFunctions:
+ /*
+ * Start Dependent Functions Resource
+ */
+ /*
+ * For a StartDependentFunctions Resource, Byte 1,
+ * although optional, will always be created.
+ */
+ SegmentSize = 2;
+ break;
+
+ case EndDependentFunctions:
+ /*
+ * End Dependent Functions Resource
+ */
+ /*
+ * For this resource the size is static
+ */
+ SegmentSize = 1;
+ break;
+
+ case Io:
+ /*
+ * IO Port Resource
+ */
+ /*
+ * For this resource the size is static
+ */
+ SegmentSize = 8;
+ break;
+
+ case FixedIo:
+ /*
+ * Fixed IO Port Resource
+ */
+ /*
+ * For this resource the size is static
+ */
+ SegmentSize = 4;
+ break;
+
+ case VendorSpecific:
+ /*
+ * Vendor Defined Resource
+ */
+ /*
+ * For a Vendor Specific resource, if the Length is
+ * between 1 and 7 it will be created as a Small
+ * Resource data type, otherwise it is a Large
+ * Resource data type.
+ */
+ if(LinkedList->Data.VendorSpecific.Length > 7)
+ {
+ SegmentSize = 3;
+ }
+ else
+ {
+ SegmentSize = 1;
+ }
+ SegmentSize +=
+ LinkedList->Data.VendorSpecific.Length;
+ break;
+
+ case EndTag:
+ /*
+ * End Tag
+ */
+ /*
+ * For this resource the size is static
+ */
+ SegmentSize = 2;
+ Done = TRUE;
+ break;
+
+ case Memory24:
+ /*
+ * 24-Bit Memory Resource
+ */
+ /*
+ * For this resource the size is static
+ */
+ SegmentSize = 12;
+ break;
+
+ case Memory32:
+ /*
+ * 32-Bit Memory Range Resource
+ */
+ /*
+ * For this resource the size is static
+ */
+ SegmentSize = 20;
+ break;
+
+ case FixedMemory32:
+ /*
+ * 32-Bit Fixed Memory Resource
+ */
+ /*
+ * For this resource the size is static
+ */
+ SegmentSize = 12;
+ break;
+
+ case Address16:
+ /*
+ * 16-Bit Address Resource
+ */
+ /*
+ * The base size of this byte stream is 16. If a
+ * Resource Source string is not NULL, add 1 for
+ * the Index + the length of the null terminated
+ * string Resource Source + 1 for the null.
+ */
+ SegmentSize = 16;
+
+ if(NULL != LinkedList->Data.Address16.ResourceSource)
+ {
+ SegmentSize += (1 +
+ LinkedList->Data.Address16.ResourceSourceStringLength);
+ }
+ break;
+
+ case Address32:
+ /*
+ * 32-Bit Address Resource
+ */
+ /*
+ * The base size of this byte stream is 26. If a Resource
+ * Source string is not NULL, add 1 for the Index + the
+ * length of the null terminated string Resource Source +
+ * 1 for the null.
+ */
+ SegmentSize = 26;
+
+ if(NULL != LinkedList->Data.Address16.ResourceSource)
+ {
+ SegmentSize += (1 +
+ LinkedList->Data.Address16.ResourceSourceStringLength);
+ }
+ break;
+
+ case ExtendedIrq:
+ /*
+ * Extended IRQ Resource
+ */
+ /*
+ * The base size of this byte stream is 9. This is for an
+ * Interrupt table length of 1. For each additional
+ * interrupt, add 4.
+ * If a Resource Source string is not NULL, add 1 for the
+ * Index + the length of the null terminated string
+ * Resource Source + 1 for the null.
+ */
+ SegmentSize = 9;
+
+ SegmentSize +=
+ (LinkedList->Data.ExtendedIrq.NumberOfInterrupts -
+ 1) * 4;
+
+ if(NULL != ExIrq->ResourceSource)
+ {
+ SegmentSize += (1 +
+ LinkedList->Data.ExtendedIrq.ResourceSourceStringLength);
+ }
+ break;
+
+ default:
+ /*
+ * If we get here, everything is out of sync,
+ * so exit with an error
+ */
+ return_ACPI_STATUS (AE_AML_ERROR);
+ break;
+
+ } /* switch (LinkedList->Id) */
+
+ /*
+ * Update the total
+ */
+ ByteStreamSizeNeeded += SegmentSize;
+
+ /*
+ * Point to the next object
+ */
+ LinkedList = (RESOURCE *) ((NATIVE_UINT) LinkedList +
+ (NATIVE_UINT) LinkedList->Length);
+ }
+
+ /*
+ * This is the data the caller needs
+ */
+ *SizeNeeded = ByteStreamSizeNeeded;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCalculateListLength
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream
+ * ByteStreamBufferLength - Size of ByteStreamBuffer
+ * SizeNeeded - UINT32 pointer of the size buffer
+ * needed to properly return the
+ * parsed data
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Takes the resource byte stream and parses it once, calculating
+ * the size buffer needed to hold the linked list that conveys
+ * the resource data.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCalculateListLength (
+ UINT8 *ByteStreamBuffer,
+ UINT32 ByteStreamBufferLength,
+ UINT32 *SizeNeeded)
+{
+ UINT32 BufferSize = 0;
+ UINT32 BytesParsed = 0;
+ UINT8 NumberOfInterrupts = 0;
+ UINT8 NumberOfChannels = 0;
+ UINT8 ResourceType;
+ UINT32 StructureSize;
+ UINT32 BytesConsumed;
+ UINT8 *Buffer;
+ UINT8 Temp8;
+ UINT16 Temp16;
+ UINT8 Index;
+ UINT8 AdditionalBytes;
+
+
+ FUNCTION_TRACE ("RsCalculateListLength");
+
+
+ while (BytesParsed < ByteStreamBufferLength)
+ {
+ /*
+ * Look at the next byte in the stream
+ */
+ ResourceType = *ByteStreamBuffer;
+
+ /*
+ * See if this is a small or large resource
+ */
+ if(ResourceType & 0x80)
+ {
+ /*
+ * Large Resource Type
+ */
+ switch (ResourceType)
+ {
+ case MEMORY_RANGE_24:
+ /*
+ * 24-Bit Memory Resource
+ */
+ BytesConsumed = 12;
+
+ StructureSize = sizeof (MEMORY24_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+ break;
+
+ case LARGE_VENDOR_DEFINED:
+ /*
+ * Vendor Defined Resource
+ */
+ Buffer = ByteStreamBuffer;
+ ++Buffer;
+
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ BytesConsumed = Temp16 + 3;
+
+ /*
+ * Ensure a 32-bit boundary for the structure
+ */
+ Temp16 = (UINT16) ROUND_UP_TO_32BITS (Temp16);
+
+ StructureSize = sizeof (VENDOR_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA +
+ (Temp16 * sizeof (UINT8));
+ break;
+
+ case MEMORY_RANGE_32:
+ /*
+ * 32-Bit Memory Range Resource
+ */
+
+ BytesConsumed = 20;
+
+ StructureSize = sizeof (MEMORY32_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+ break;
+
+ case FIXED_MEMORY_RANGE_32:
+ /*
+ * 32-Bit Fixed Memory Resource
+ */
+ BytesConsumed = 12;
+
+ StructureSize = sizeof(FIXED_MEMORY32_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+ break;
+
+ case DWORD_ADDRESS_SPACE:
+ /*
+ * 32-Bit Address Resource
+ */
+ Buffer = ByteStreamBuffer;
+
+ ++Buffer;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ BytesConsumed = Temp16 + 3;
+
+ /*
+ * Resource Source Index and Resource Source are
+ * optional elements. Check the length of the
+ * Bytestream. If it is greater than 23, that
+ * means that an Index exists and is followed by
+ * a null termininated string. Therefore, set
+ * the temp variable to the length minus the minimum
+ * byte stream length plus the byte for the Index to
+ * determine the size of the NULL terminiated string.
+ */
+ if (23 < Temp16)
+ {
+ Temp8 = (UINT8) (Temp16 - 24);
+ }
+ else
+ {
+ Temp8 = 0;
+ }
+
+ /*
+ * Ensure a 32-bit boundary for the structure
+ */
+ Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8);
+
+ StructureSize = sizeof (ADDRESS32_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA +
+ (Temp8 * sizeof (UINT8));
+ break;
+
+ case WORD_ADDRESS_SPACE:
+ /*
+ * 16-Bit Address Resource
+ */
+ Buffer = ByteStreamBuffer;
+
+ ++Buffer;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ BytesConsumed = Temp16 + 3;
+
+ /*
+ * Resource Source Index and Resource Source are
+ * optional elements. Check the length of the
+ * Bytestream. If it is greater than 13, that
+ * means that an Index exists and is followed by
+ * a null termininated string. Therefore, set
+ * the temp variable to the length minus the minimum
+ * byte stream length plus the byte for the Index to
+ * determine the size of the NULL terminiated string.
+ */
+ if (13 < Temp16)
+ {
+ Temp8 = (UINT8) (Temp16 - 14);
+ }
+ else
+ {
+ Temp8 = 0;
+ }
+
+ /*
+ * Ensure a 32-bit boundry for the structure
+ */
+ Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8);
+
+ StructureSize = sizeof (ADDRESS16_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA +
+ (Temp8 * sizeof (UINT8));
+ break;
+
+ case EXTENDED_IRQ:
+ /*
+ * Extended IRQ
+ */
+ Buffer = ByteStreamBuffer;
+
+ ++Buffer;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ BytesConsumed = Temp16 + 3;
+
+ /*
+ * Point past the length field and the
+ * Interrupt vector flags to save off the
+ * Interrupt table length to the Temp8 variable.
+ */
+ Buffer += 3;
+ Temp8 = *Buffer;
+
+ /*
+ * To compensate for multiple interrupt numbers,
+ * Add 4 bytes for each additional interrupts
+ * greater than 1
+ */
+ AdditionalBytes = (UINT8) ((Temp8 - 1) * 4);
+
+ /*
+ * Resource Source Index and Resource Source are
+ * optional elements. Check the length of the
+ * Bytestream. If it is greater than 9, that
+ * means that an Index exists and is followed by
+ * a null termininated string. Therefore, set
+ * the temp variable to the length minus the minimum
+ * byte stream length plus the byte for the Index to
+ * determine the size of the NULL terminiated string.
+ */
+ if (9 + AdditionalBytes < Temp16)
+ {
+ Temp8 = (UINT8) (Temp16 - (9 + AdditionalBytes));
+ }
+
+ else
+ {
+ Temp8 = 0;
+ }
+
+ /*
+ * Ensure a 32-bit boundry for the structure
+ */
+ Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8);
+
+ StructureSize = sizeof (EXTENDED_IRQ_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA +
+ (AdditionalBytes * sizeof (UINT8)) +
+ (Temp8 * sizeof (UINT8));
+
+ break;
+
+/* TBD: [Future] 64-bit not currently supported */
+/*
+ case 0x8A:
+ break;
+*/
+
+ default:
+ /*
+ * If we get here, everything is out of sync,
+ * so exit with an error
+ */
+ return_ACPI_STATUS (AE_AML_ERROR);
+ break;
+ }
+ }
+
+ else
+ {
+ /*
+ * Small Resource Type
+ * Only bits 7:3 are valid
+ */
+ ResourceType >>= 3;
+
+ switch (ResourceType)
+ {
+ case IRQ_FORMAT:
+ /*
+ * IRQ Resource
+ */
+ /*
+ * Determine if it there are two or three
+ * trailing bytes
+ */
+ Buffer = ByteStreamBuffer;
+ Temp8 = *Buffer;
+
+ if(Temp8 & 0x01)
+ {
+ BytesConsumed = 4;
+ }
+
+ else
+ {
+ BytesConsumed = 3;
+ }
+
+ /*
+ * Point past the descriptor
+ */
+ ++Buffer;
+
+ /*
+ * Look at the number of bits set
+ */
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ for (Index = 0; Index < 16; Index++)
+ {
+ if (Temp16 & 0x1)
+ {
+ ++NumberOfInterrupts;
+ }
+
+ Temp16 >>= 1;
+ }
+
+ StructureSize = sizeof (IO_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA +
+ (NumberOfInterrupts * sizeof (UINT32));
+ break;
+
+
+ case DMA_FORMAT:
+
+ /*
+ * DMA Resource
+ */
+ Buffer = ByteStreamBuffer;
+
+ BytesConsumed = 3;
+
+ /*
+ * Point past the descriptor
+ */
+ ++Buffer;
+
+ /*
+ * Look at the number of bits set
+ */
+ Temp8 = *Buffer;
+
+ for(Index = 0; Index < 8; Index++)
+ {
+ if(Temp8 & 0x1)
+ {
+ ++NumberOfChannels;
+ }
+
+ Temp8 >>= 1;
+ }
+
+ StructureSize = sizeof (DMA_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA +
+ (NumberOfChannels * sizeof (UINT32));
+ break;
+
+
+ case START_DEPENDENT_TAG:
+
+ /*
+ * Start Dependent Functions Resource
+ */
+ /*
+ * Determine if it there are two or three trailing bytes
+ */
+ Buffer = ByteStreamBuffer;
+ Temp8 = *Buffer;
+
+ if(Temp8 & 0x01)
+ {
+ BytesConsumed = 2;
+ }
+ else
+ {
+ BytesConsumed = 1;
+ }
+
+
+ StructureSize =
+ sizeof (START_DEPENDENT_FUNCTIONS_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+ break;
+
+
+ case END_DEPENDENT_TAG:
+
+ /*
+ * End Dependent Functions Resource
+ */
+ BytesConsumed = 1;
+ StructureSize = RESOURCE_LENGTH;
+ break;
+
+
+ case IO_PORT_DESCRIPTOR:
+ /*
+ * IO Port Resource
+ */
+ BytesConsumed = 8;
+ StructureSize = sizeof (IO_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+ break;
+
+
+ case FIXED_LOCATION_IO_DESCRIPTOR:
+
+ /*
+ * Fixed IO Port Resource
+ */
+ BytesConsumed = 4;
+ StructureSize = sizeof (FIXED_IO_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+ break;
+
+
+ case SMALL_VENDOR_DEFINED:
+
+ /*
+ * Vendor Specific Resource
+ */
+ Buffer = ByteStreamBuffer;
+
+ Temp8 = *Buffer;
+ Temp8 = (UINT8) (Temp8 & 0x7);
+ BytesConsumed = Temp8 + 1;
+
+ /*
+ * Ensure a 32-bit boundry for the structure
+ */
+ Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8);
+ StructureSize = sizeof (VENDOR_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA +
+ (Temp8 * sizeof (UINT8));
+ break;
+
+
+ case END_TAG:
+
+ /*
+ * End Tag
+ */
+ BytesConsumed = 2;
+ StructureSize = RESOURCE_LENGTH;
+ break;
+
+
+ default:
+ /*
+ * If we get here, everything is out of sync,
+ * so exit with an error
+ */
+ return_ACPI_STATUS (AE_AML_ERROR);
+ break;
+
+ } /* switch */
+
+ } /* if(ResourceType & 0x80) */
+
+ /*
+ * Update the return value and counter
+ */
+ BufferSize += StructureSize;
+ BytesParsed += BytesConsumed;
+
+ /*
+ * Set the byte stream to point to the next resource
+ */
+ ByteStreamBuffer += BytesConsumed;
+
+ }
+
+ /*
+ * This is the data the caller needs
+ */
+ *SizeNeeded = BufferSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCalculatePciRoutingTableLength
+ *
+ * PARAMETERS: PackageObject - Pointer to the package object
+ * BufferSizeNeeded - UINT32 pointer of the size buffer
+ * needed to properly return the
+ * parsed data
+ *
+ * RETURN: Status AE_OK
+ *
+ * DESCRIPTION: Given a package representing a PCI routing table, this
+ * calculates the size of the corresponding linked list of
+ * descriptions.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCalculatePciRoutingTableLength (
+ ACPI_OPERAND_OBJECT *PackageObject,
+ UINT32 *BufferSizeNeeded)
+{
+ UINT32 NumberOfElements;
+ UINT32 TempSizeNeeded;
+ ACPI_OPERAND_OBJECT **TopObjectList;
+ UINT32 Index;
+ ACPI_OPERAND_OBJECT *PackageElement;
+ ACPI_OPERAND_OBJECT **SubObjectList;
+ BOOLEAN NameFound;
+ UINT32 TableIndex;
+
+
+ FUNCTION_TRACE ("AcpiRsCalculatePciRoutingTableLength");
+
+
+ NumberOfElements = PackageObject->Package.Count;
+
+ /*
+ * Calculate the size of the return buffer.
+ * The base size is the number of elements * the sizes of the
+ * structures. Additional space for the strings is added below.
+ * The minus one is to subtract the size of the UINT8 Source[1]
+ * member because it is added below.
+ *
+ * NOTE: The NumberOfElements is incremented by one to add an end
+ * table structure that is essentially a structure of zeros.
+ */
+ TempSizeNeeded = (NumberOfElements + 1) *
+ (sizeof (PCI_ROUTING_TABLE) - 1);
+
+ /*
+ * But each PRT_ENTRY structure has a pointer to a string and
+ * the size of that string must be found.
+ */
+ TopObjectList = PackageObject->Package.Elements;
+
+ for (Index = 0; Index < NumberOfElements; Index++)
+ {
+ /*
+ * Dereference the sub-package
+ */
+ PackageElement = *TopObjectList;
+
+ /*
+ * The SubObjectList will now point to an array of the
+ * four IRQ elements: Address, Pin, Source and SourceIndex
+ */
+ SubObjectList = PackageElement->Package.Elements;
+
+ /*
+ * Scan the IrqTableElements for the Source Name String
+ */
+ NameFound = FALSE;
+
+ for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++)
+ {
+ if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type)
+ {
+ NameFound = TRUE;
+ }
+
+ else
+ {
+ /*
+ * Look at the next element
+ */
+ SubObjectList++;
+ }
+ }
+
+ /*
+ * Was a String type found?
+ */
+ if (TRUE == NameFound)
+ {
+ /*
+ * The length String.Length field includes the
+ * terminating NULL
+ */
+ TempSizeNeeded += (*SubObjectList)->String.Length;
+ }
+
+ else
+ {
+ /*
+ * If no name was found, then this is a NULL, which is
+ * translated as a UINT32 zero.
+ */
+ TempSizeNeeded += sizeof(UINT32);
+ }
+
+ /*
+ * Point to the next ACPI_OPERAND_OBJECT
+ */
+ TopObjectList++;
+ }
+
+ /* Align the count before returning it */
+
+ *BufferSizeNeeded = ROUND_UP_TO_32BITS (TempSizeNeeded);
+
+ return_ACPI_STATUS (AE_OK);
+} \ No newline at end of file
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c b/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c
new file mode 100644
index 000000000000..07f3f5126678
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rscreate.c
@@ -0,0 +1,548 @@
+/*******************************************************************************
+ *
+ * Module Name: rscreate - AcpiRsCreateResourceList
+ * AcpiRsCreatePciRoutingTable
+ * AcpiRsCreateByteStream
+ * $Revision: 19 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#define __RSCREATE_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rscreate")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCreateResourceList
+ *
+ * PARAMETERS:
+ * ByteStreamBuffer - Pointer to the resource byte stream
+ * OutputBuffer - Pointer to the user's buffer
+ * OutputBufferLength - Pointer to the size of OutputBuffer
+ *
+ * RETURN: Status - AE_OK if okay, else a valid ACPI_STATUS code
+ * If OutputBuffer is not large enough, OutputBufferLength
+ * indicates how large OutputBuffer should be, else it
+ * indicates how may UINT8 elements of OutputBuffer are valid.
+ *
+ * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
+ * execution and parses the stream to create a linked list
+ * of device resources.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCreateResourceList (
+ ACPI_OPERAND_OBJECT *ByteStreamBuffer,
+ UINT8 *OutputBuffer,
+ UINT32 *OutputBufferLength)
+{
+
+ ACPI_STATUS Status;
+ UINT8 *ByteStreamStart = NULL;
+ UINT32 ListSizeNeeded = 0;
+ UINT32 ByteStreamBufferLength = 0;
+
+
+ FUNCTION_TRACE ("RsCreateResourceList");
+
+
+ DEBUG_PRINT (VERBOSE_INFO, ("RsCreateResourceList: ByteStreamBuffer = %p\n",
+ ByteStreamBuffer));
+
+ /*
+ * Params already validated, so we don't re-validate here
+ */
+
+ ByteStreamBufferLength = ByteStreamBuffer->Buffer.Length;
+ ByteStreamStart = ByteStreamBuffer->Buffer.Pointer;
+
+ /*
+ * Pass the ByteStreamBuffer into a module that can calculate
+ * the buffer size needed for the linked list
+ */
+ Status = AcpiRsCalculateListLength (ByteStreamStart,
+ ByteStreamBufferLength,
+ &ListSizeNeeded);
+
+ DEBUG_PRINT (VERBOSE_INFO,
+ ("RsCreateResourceList: Status=%d ListSizeNeeded=%d\n",
+ Status, ListSizeNeeded));
+
+ /*
+ * Exit with the error passed back
+ */
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * If the linked list will fit into the available buffer
+ * call to fill in the list
+ */
+
+ if (ListSizeNeeded <= *OutputBufferLength)
+ {
+ /*
+ * Zero out the return buffer before proceeding
+ */
+ MEMSET (OutputBuffer, 0x00, *OutputBufferLength);
+
+ Status = AcpiRsByteStreamToList (ByteStreamStart,
+ ByteStreamBufferLength,
+ &OutputBuffer);
+
+ /*
+ * Exit with the error passed back
+ */
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ DEBUG_PRINT (VERBOSE_INFO, ("RsByteStreamToList: OutputBuffer = %p\n",
+ OutputBuffer));
+ }
+
+ else
+ {
+ *OutputBufferLength = ListSizeNeeded;
+ return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ }
+
+ *OutputBufferLength = ListSizeNeeded;
+ return_ACPI_STATUS (AE_OK);
+
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCreatePciRoutingTable
+ *
+ * PARAMETERS:
+ * PackageObject - Pointer to an ACPI_OPERAND_OBJECT
+ * package
+ * OutputBuffer - Pointer to the user's buffer
+ * OutputBufferLength - Size of OutputBuffer
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
+ * If the OutputBuffer is too small, the error will be
+ * AE_BUFFER_OVERFLOW and OutputBufferLength will point
+ * to the size buffer needed.
+ *
+ * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
+ * linked list of PCI interrupt descriptions
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCreatePciRoutingTable (
+ ACPI_OPERAND_OBJECT *PackageObject,
+ UINT8 *OutputBuffer,
+ UINT32 *OutputBufferLength)
+{
+ UINT8 *Buffer = OutputBuffer;
+ ACPI_OPERAND_OBJECT **TopObjectList = NULL;
+ ACPI_OPERAND_OBJECT **SubObjectList = NULL;
+ ACPI_OPERAND_OBJECT *PackageElement = NULL;
+ UINT32 BufferSizeNeeded = 0;
+ UINT32 NumberOfElements = 0;
+ UINT32 Index = 0;
+ PCI_ROUTING_TABLE *UserPrt = NULL;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("RsCreatePciRoutingTable");
+
+
+ /*
+ * Params already validated, so we don't re-validate here
+ */
+
+ Status = AcpiRsCalculatePciRoutingTableLength(PackageObject,
+ &BufferSizeNeeded);
+
+ DEBUG_PRINT (VERBOSE_INFO,
+ ("RsCreatePciRoutingTable: BufferSizeNeeded = %d\n",
+ BufferSizeNeeded));
+
+ /*
+ * If the data will fit into the available buffer
+ * call to fill in the list
+ */
+ if (BufferSizeNeeded <= *OutputBufferLength)
+ {
+ /*
+ * Zero out the return buffer before proceeding
+ */
+ MEMSET (OutputBuffer, 0x00, *OutputBufferLength);
+
+ /*
+ * Loop through the ACPI_INTERNAL_OBJECTS - Each object should
+ * contain a UINT32 Address, a UINT8 Pin, a Name and a UINT8
+ * SourceIndex.
+ */
+ TopObjectList = PackageObject->Package.Elements;
+ NumberOfElements = PackageObject->Package.Count;
+ UserPrt = (PCI_ROUTING_TABLE *) Buffer;
+
+ for (Index = 0; Index < NumberOfElements; Index++)
+ {
+ /*
+ * Point UserPrt past this current structure
+ *
+ * NOTE: On the first iteration, UserPrt->Length will
+ * be zero because we cleared the return buffer earlier
+ */
+ Buffer += UserPrt->Length;
+ Buffer = ROUND_PTR_UP_TO_4 (Buffer, UINT8);
+ UserPrt = (PCI_ROUTING_TABLE *) Buffer;
+
+ /*
+ * Fill in the Length field with the information we
+ * have at this point.
+ * The minus one is to subtract the size of the
+ * UINT8 Source[1] member because it is added below.
+ */
+ UserPrt->Length = (sizeof (PCI_ROUTING_TABLE) - 1);
+
+ /*
+ * Dereference the sub-package
+ */
+ PackageElement = *TopObjectList;
+
+ /*
+ * The SubObjectList will now point to an array of
+ * the four IRQ elements: Address, Pin, Source and
+ * SourceIndex
+ */
+ SubObjectList = PackageElement->Package.Elements;
+
+ /*
+ * Dereference the Address
+ */
+ if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type)
+ {
+ UserPrt->Data.Address =
+ (*SubObjectList)->Number.Value;
+ }
+
+ else
+ {
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /*
+ * Dereference the Pin
+ */
+ SubObjectList++;
+
+ if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type)
+ {
+ UserPrt->Data.Pin =
+ (UINT32) (*SubObjectList)->Number.Value;
+ }
+
+ else
+ {
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /*
+ * Dereference the Source Name
+ */
+ SubObjectList++;
+
+ if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type)
+ {
+ STRCPY (UserPrt->Data.Source,
+ (*SubObjectList)->String.Pointer);
+
+ /*
+ * Add to the Length field the length of the string
+ */
+ UserPrt->Length += (*SubObjectList)->String.Length;
+ }
+
+ else
+ {
+ /*
+ * If this is a number, then the Source Name
+ * is NULL, since the entire buffer was zeroed
+ * out, we can leave this alone.
+ */
+ if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type)
+ {
+ /*
+ * Add to the Length field the length of
+ * the UINT32 NULL
+ */
+ UserPrt->Length += sizeof (UINT32);
+ }
+
+ else
+ {
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+ }
+
+ /* Now align the current length */
+
+ UserPrt->Length = ROUND_UP_TO_32BITS (UserPrt->Length);
+
+ /*
+ * Dereference the Source Index
+ */
+ SubObjectList++;
+
+ if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type)
+ {
+ UserPrt->Data.SourceIndex =
+ (UINT32) (*SubObjectList)->Number.Value;
+ }
+
+ else
+ {
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /*
+ * Point to the next ACPI_OPERAND_OBJECT
+ */
+ TopObjectList++;
+ }
+
+ DEBUG_PRINT (VERBOSE_INFO,
+ ("RsCreatePciRoutingTable: OutputBuffer = %p\n",
+ OutputBuffer));
+ }
+
+ else
+ {
+ *OutputBufferLength = BufferSizeNeeded;
+
+ return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ }
+
+ /*
+ * Report the amount of buffer used
+ */
+ *OutputBufferLength = BufferSizeNeeded;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCreateByteStream
+ *
+ * PARAMETERS:
+ * LinkedListBuffer - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's buffer
+ * OutputBufferLength - Size of OutputBuffer
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
+ * If the OutputBuffer is too small, the error will be
+ * AE_BUFFER_OVERFLOW and OutputBufferLength will point
+ * to the size buffer needed.
+ *
+ * DESCRIPTION: Takes the linked list of device resources and
+ * creates a bytestream to be used as input for the
+ * _SRS control method.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCreateByteStream (
+ RESOURCE *LinkedListBuffer,
+ UINT8 *OutputBuffer,
+ UINT32 *OutputBufferLength)
+{
+ ACPI_STATUS Status;
+ UINT32 ByteStreamSizeNeeded = 0;
+
+
+ FUNCTION_TRACE ("RsCreateByteStream");
+
+
+ DEBUG_PRINT (VERBOSE_INFO,
+ ("RsCreateByteStream: LinkedListBuffer = %p\n",
+ LinkedListBuffer));
+
+ /*
+ * Params already validated, so we don't re-validate here
+ *
+ * Pass the LinkedListBuffer into a module that can calculate
+ * the buffer size needed for the byte stream.
+ */
+ Status = AcpiRsCalculateByteStreamLength (LinkedListBuffer,
+ &ByteStreamSizeNeeded);
+
+ DEBUG_PRINT (VERBOSE_INFO,
+ ("RsCreateByteStream: ByteStreamSizeNeeded=%d, %s\n",
+ ByteStreamSizeNeeded,
+ AcpiCmFormatException (Status)));
+
+ /*
+ * Exit with the error passed back
+ */
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * If the linked list will fit into the available buffer
+ * call to fill in the list
+ */
+
+ if (ByteStreamSizeNeeded <= *OutputBufferLength)
+ {
+ /*
+ * Zero out the return buffer before proceeding
+ */
+ MEMSET (OutputBuffer, 0x00, *OutputBufferLength);
+
+ Status = AcpiRsListToByteStream (LinkedListBuffer,
+ ByteStreamSizeNeeded,
+ &OutputBuffer);
+
+ /*
+ * Exit with the error passed back
+ */
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ DEBUG_PRINT (VERBOSE_INFO,
+ ("RsListToByteStream: OutputBuffer = %p\n",
+ OutputBuffer));
+ }
+ else
+ {
+ *OutputBufferLength = ByteStreamSizeNeeded;
+ return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c
new file mode 100644
index 000000000000..8df18fbf8dd4
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsdump.c
@@ -0,0 +1,1044 @@
+/*******************************************************************************
+ *
+ * Module Name: rsdump - Functions do dump out the resource structures.
+ * $Revision: 11 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#define __RSDUMP_C__
+
+#include "acpi.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rsdump")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpIrq
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpIrq (
+ RESOURCE_DATA *Data)
+{
+ IRQ_RESOURCE *IrqData = (IRQ_RESOURCE*) Data;
+ UINT8 Index = 0;
+
+
+ AcpiOsPrintf ("\tIRQ Resource\n");
+
+ AcpiOsPrintf ("\t\t%s Triggered\n",
+ LEVEL_SENSITIVE == IrqData->EdgeLevel ?
+ "Level" : "Edge");
+
+ AcpiOsPrintf ("\t\tActive %s\n",
+ ACTIVE_LOW == IrqData->ActiveHighLow ?
+ "Low" : "High");
+
+ AcpiOsPrintf ("\t\t%s\n",
+ SHARED == IrqData->SharedExclusive ?
+ "Shared" : "Exclusive");
+
+ AcpiOsPrintf ("\t\t%d Interrupts ( ",
+ IrqData->NumberOfInterrupts);
+
+ for (Index = 0; Index < IrqData->NumberOfInterrupts; Index++)
+ {
+ AcpiOsPrintf ("%d ", IrqData->Interrupts[Index]);
+ }
+
+ AcpiOsPrintf (")\n");
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpDma
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpDma (
+ RESOURCE_DATA *Data)
+{
+ DMA_RESOURCE *DmaData = (DMA_RESOURCE*) Data;
+ UINT8 Index = 0;
+
+
+ AcpiOsPrintf ("\tDMA Resource\n");
+
+ switch (DmaData->Type)
+ {
+ case COMPATIBILITY:
+ AcpiOsPrintf ("\t\tCompatibility mode\n");
+ break;
+
+ case TYPE_A:
+ AcpiOsPrintf ("\t\tType A\n");
+ break;
+
+ case TYPE_B:
+ AcpiOsPrintf ("\t\tType B\n");
+ break;
+
+ case TYPE_F:
+ AcpiOsPrintf ("\t\tType F\n");
+ break;
+
+ default:
+ AcpiOsPrintf ("\t\tInvalid DMA type\n");
+ break;
+ }
+
+ AcpiOsPrintf ("\t\t%sBus Master\n",
+ BUS_MASTER == DmaData->BusMaster ?
+ "" : "Not a ");
+
+ switch (DmaData->Transfer)
+ {
+ case TRANSFER_8:
+ AcpiOsPrintf ("\t\t8-bit only transfer\n");
+ break;
+
+ case TRANSFER_8_16:
+ AcpiOsPrintf ("\t\t8 and 16-bit transfer\n");
+ break;
+
+ case TRANSFER_16:
+ AcpiOsPrintf ("\t\t16 bit only transfer\n");
+ break;
+
+ default:
+ AcpiOsPrintf ("\t\tInvalid transfer preference\n");
+ break;
+ }
+
+ AcpiOsPrintf ("\t\tNumber of Channels: %d ( ",
+ DmaData->NumberOfChannels);
+
+ for (Index = 0; Index < DmaData->NumberOfChannels; Index++)
+ {
+ AcpiOsPrintf ("%d ", DmaData->Channels[Index]);
+ }
+
+ AcpiOsPrintf (")\n");
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpStartDependentFunctions
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpStartDependentFunctions (
+ RESOURCE_DATA *Data)
+{
+ START_DEPENDENT_FUNCTIONS_RESOURCE *SdfData =
+ (START_DEPENDENT_FUNCTIONS_RESOURCE*) Data;
+
+
+ AcpiOsPrintf ("\tStart Dependent Functions Resource\n");
+
+ switch (SdfData->CompatibilityPriority)
+ {
+ case GOOD_CONFIGURATION:
+ AcpiOsPrintf ("\t\tGood configuration\n");
+ break;
+
+ case ACCEPTABLE_CONFIGURATION:
+ AcpiOsPrintf ("\t\tAcceptable configuration\n");
+ break;
+
+ case SUB_OPTIMAL_CONFIGURATION:
+ AcpiOsPrintf ("\t\tSub-optimal configuration\n");
+ break;
+
+ default:
+ AcpiOsPrintf ("\t\tInvalid compatibility priority\n");
+ break;
+ }
+
+ switch(SdfData->PerformanceRobustness)
+ {
+ case GOOD_CONFIGURATION:
+ AcpiOsPrintf ("\t\tGood configuration\n");
+ break;
+
+ case ACCEPTABLE_CONFIGURATION:
+ AcpiOsPrintf ("\t\tAcceptable configuration\n");
+ break;
+
+ case SUB_OPTIMAL_CONFIGURATION:
+ AcpiOsPrintf ("\t\tSub-optimal configuration\n");
+ break;
+
+ default:
+ AcpiOsPrintf ("\t\tInvalid performance "
+ "robustness preference\n");
+ break;
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpIo
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpIo (
+ RESOURCE_DATA *Data)
+{
+ IO_RESOURCE *IoData = (IO_RESOURCE*) Data;
+
+
+ AcpiOsPrintf ("\tIo Resource\n");
+
+ AcpiOsPrintf ("\t\t%d bit decode\n",
+ DECODE_16 == IoData->IoDecode ? 16 : 10);
+
+ AcpiOsPrintf ("\t\tRange minimum base: 0x%08x\n",
+ IoData->MinBaseAddress);
+
+ AcpiOsPrintf ("\t\tRange maximum base: 0x%08x\n",
+ IoData->MaxBaseAddress);
+
+ AcpiOsPrintf ("\t\tAlignment: 0x%08x\n",
+ IoData->Alignment);
+
+ AcpiOsPrintf ("\t\tRange Length: 0x%08x\n",
+ IoData->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpFixedIo
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpFixedIo (
+ RESOURCE_DATA *Data)
+{
+ FIXED_IO_RESOURCE *FixedIoData = (FIXED_IO_RESOURCE*) Data;
+
+
+ AcpiOsPrintf ("\tFixed Io Resource\n");
+ AcpiOsPrintf ("\t\tRange base address: 0x%08x",
+ FixedIoData->BaseAddress);
+
+ AcpiOsPrintf ("\t\tRange length: 0x%08x",
+ FixedIoData->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpVendorSpecific
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpVendorSpecific (
+ RESOURCE_DATA *Data)
+{
+ VENDOR_RESOURCE *VendorData = (VENDOR_RESOURCE*) Data;
+ UINT16 Index = 0;
+
+
+ AcpiOsPrintf ("\tVendor Specific Resource\n");
+
+ AcpiOsPrintf ("\t\tLength: 0x%08x\n", VendorData->Length);
+
+ for (Index = 0; Index < VendorData->Length; Index++)
+ {
+ AcpiOsPrintf ("\t\tByte %d: 0x%08x\n",
+ Index, VendorData->Reserved[Index]);
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpMemory24
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpMemory24 (
+ RESOURCE_DATA *Data)
+{
+ MEMORY24_RESOURCE *Memory24Data = (MEMORY24_RESOURCE*) Data;
+
+
+ AcpiOsPrintf ("\t24-Bit Memory Range Resource\n");
+
+ AcpiOsPrintf ("\t\tRead%s\n",
+ READ_WRITE_MEMORY ==
+ Memory24Data->ReadWriteAttribute ?
+ "/Write" : " only");
+
+ AcpiOsPrintf ("\t\tRange minimum base: 0x%08x\n",
+ Memory24Data->MinBaseAddress);
+
+ AcpiOsPrintf ("\t\tRange maximum base: 0x%08x\n",
+ Memory24Data->MaxBaseAddress);
+
+ AcpiOsPrintf ("\t\tAlignment: 0x%08x\n",
+ Memory24Data->Alignment);
+
+ AcpiOsPrintf ("\t\tRange length: 0x%08x\n",
+ Memory24Data->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpMemory32
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpMemory32 (
+ RESOURCE_DATA *Data)
+{
+ MEMORY32_RESOURCE *Memory32Data = (MEMORY32_RESOURCE*) Data;
+
+
+ AcpiOsPrintf ("\t32-Bit Memory Range Resource\n");
+
+ AcpiOsPrintf ("\t\tRead%s\n",
+ READ_WRITE_MEMORY ==
+ Memory32Data->ReadWriteAttribute ?
+ "/Write" : " only");
+
+ AcpiOsPrintf ("\t\tRange minimum base: 0x%08x\n",
+ Memory32Data->MinBaseAddress);
+
+ AcpiOsPrintf ("\t\tRange maximum base: 0x%08x\n",
+ Memory32Data->MaxBaseAddress);
+
+ AcpiOsPrintf ("\t\tAlignment: 0x%08x\n",
+ Memory32Data->Alignment);
+
+ AcpiOsPrintf ("\t\tRange length: 0x%08x\n",
+ Memory32Data->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpFixedMemory32
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpFixedMemory32 (
+ RESOURCE_DATA *Data)
+{
+ FIXED_MEMORY32_RESOURCE *FixedMemory32Data = (FIXED_MEMORY32_RESOURCE*) Data;
+
+
+ AcpiOsPrintf ("\t32-Bit Fixed Location Memory Range Resource\n");
+
+ AcpiOsPrintf ("\t\tRead%s\n",
+ READ_WRITE_MEMORY ==
+ FixedMemory32Data->ReadWriteAttribute ?
+ "/Write" : " Only");
+
+ AcpiOsPrintf ("\t\tRange base address: 0x%08x\n",
+ FixedMemory32Data->RangeBaseAddress);
+
+ AcpiOsPrintf ("\t\tRange length: 0x%08x\n",
+ FixedMemory32Data->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpAddress16
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpAddress16 (
+ RESOURCE_DATA *Data)
+{
+ ADDRESS16_RESOURCE *Address16Data = (ADDRESS16_RESOURCE*) Data;
+
+
+ AcpiOsPrintf ("\t16-Bit Address Space Resource\n");
+ AcpiOsPrintf ("\t\tResource Type: ");
+
+ switch (Address16Data->ResourceType)
+ {
+ case MEMORY_RANGE:
+
+ AcpiOsPrintf ("Memory Range\n");
+
+ switch (Address16Data->Attribute.Memory.CacheAttribute)
+ {
+ case NON_CACHEABLE_MEMORY:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Noncacheable memory\n");
+ break;
+
+ case CACHABLE_MEMORY:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Cacheable memory\n");
+ break;
+
+ case WRITE_COMBINING_MEMORY:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Write-combining memory\n");
+ break;
+
+ case PREFETCHABLE_MEMORY:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Prefetchable memory\n");
+ break;
+
+ default:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Invalid cache attribute\n");
+ break;
+ }
+
+ AcpiOsPrintf ("\t\tType Specific: Read%s\n",
+ READ_WRITE_MEMORY ==
+ Address16Data->Attribute.Memory.ReadWriteAttribute ?
+ "/Write" : " Only");
+ break;
+
+ case IO_RANGE:
+
+ AcpiOsPrintf ("I/O Range\n");
+
+ switch (Address16Data->Attribute.Io.RangeAttribute)
+ {
+ case NON_ISA_ONLY_RANGES:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Non-ISA Io Addresses\n");
+ break;
+
+ case ISA_ONLY_RANGES:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "ISA Io Addresses\n");
+ break;
+
+ case ENTIRE_RANGE:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "ISA and non-ISA Io Addresses\n");
+ break;
+
+ default:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Invalid range attribute\n");
+ break;
+ }
+ break;
+
+ case BUS_NUMBER_RANGE:
+
+ AcpiOsPrintf ("Bus Number Range\n");
+ break;
+
+ default:
+
+ AcpiOsPrintf ("Invalid resource type. Exiting.\n");
+ return;
+ }
+
+ AcpiOsPrintf ("\t\tResource %s\n",
+ CONSUMER == Address16Data->ProducerConsumer ?
+ "Consumer" : "Producer");
+
+ AcpiOsPrintf ("\t\t%s decode\n",
+ SUB_DECODE == Address16Data->Decode ?
+ "Subtractive" : "Positive");
+
+ AcpiOsPrintf ("\t\tMin address is %s fixed\n",
+ ADDRESS_FIXED == Address16Data->MinAddressFixed ?
+ "" : "not");
+
+ AcpiOsPrintf ("\t\tMax address is %s fixed\n",
+ ADDRESS_FIXED == Address16Data->MaxAddressFixed ?
+ "" : "not");
+
+ AcpiOsPrintf ("\t\tGranularity: 0x%08x\n",
+ Address16Data->Granularity);
+
+ AcpiOsPrintf ("\t\tAddress range min: 0x%08x\n",
+ Address16Data->MinAddressRange);
+
+ AcpiOsPrintf ("\t\tAddress range max: 0x%08x\n",
+ Address16Data->MaxAddressRange);
+
+ AcpiOsPrintf ("\t\tAddress translation offset: 0x%08x\n",
+ Address16Data->AddressTranslationOffset);
+
+ AcpiOsPrintf ("\t\tAddress Length: 0x%08x\n",
+ Address16Data->AddressLength);
+
+ if (0xFF != Address16Data->ResourceSourceIndex)
+ {
+ AcpiOsPrintf ("\t\tResource Source Index: %d\n",
+ Address16Data->ResourceSourceIndex);
+ AcpiOsPrintf ("\t\tResource Source: %s\n",
+ Address16Data->ResourceSource);
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpAddress32
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpAddress32 (
+ RESOURCE_DATA *Data)
+{
+ ADDRESS32_RESOURCE *Address32Data = (ADDRESS32_RESOURCE*) Data;
+
+
+ AcpiOsPrintf ("\t32-Bit Address Space Resource\n");
+
+ switch (Address32Data->ResourceType)
+ {
+ case MEMORY_RANGE:
+
+ AcpiOsPrintf ("\t\tResource Type: Memory Range\n");
+
+ switch (Address32Data->Attribute.Memory.CacheAttribute)
+ {
+ case NON_CACHEABLE_MEMORY:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Noncacheable memory\n");
+ break;
+
+ case CACHABLE_MEMORY:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Cacheable memory\n");
+ break;
+
+ case WRITE_COMBINING_MEMORY:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Write-combining memory\n");
+ break;
+
+ case PREFETCHABLE_MEMORY:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Prefetchable memory\n");
+ break;
+
+ default:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Invalid cache attribute\n");
+ break;
+ }
+
+ AcpiOsPrintf ("\t\tType Specific: Read%s\n",
+ READ_WRITE_MEMORY ==
+ Address32Data->Attribute.Memory.ReadWriteAttribute ?
+ "/Write" : " Only");
+ break;
+
+ case IO_RANGE:
+
+ AcpiOsPrintf ("\t\tResource Type: Io Range\n");
+
+ switch (Address32Data->Attribute.Io.RangeAttribute)
+ {
+ case NON_ISA_ONLY_RANGES:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Non-ISA Io Addresses\n");
+ break;
+
+ case ISA_ONLY_RANGES:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "ISA Io Addresses\n");
+ break;
+
+ case ENTIRE_RANGE:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "ISA and non-ISA Io Addresses\n");
+ break;
+
+ default:
+ AcpiOsPrintf ("\t\tType Specific: "
+ "Invalid Range attribute");
+ break;
+ }
+ break;
+
+ case BUS_NUMBER_RANGE:
+
+ AcpiOsPrintf ("\t\tResource Type: Bus Number Range\n");
+ break;
+
+ default:
+
+ AcpiOsPrintf ("\t\tInvalid Resource Type..exiting.\n");
+ return;
+ }
+
+ AcpiOsPrintf ("\t\tResource %s\n",
+ CONSUMER == Address32Data->ProducerConsumer ?
+ "Consumer" : "Producer");
+
+ AcpiOsPrintf ("\t\t%s decode\n",
+ SUB_DECODE == Address32Data->Decode ?
+ "Subtractive" : "Positive");
+
+ AcpiOsPrintf ("\t\tMin address is %s fixed\n",
+ ADDRESS_FIXED == Address32Data->MinAddressFixed ?
+ "" : "not ");
+
+ AcpiOsPrintf ("\t\tMax address is %s fixed\n",
+ ADDRESS_FIXED == Address32Data->MaxAddressFixed ?
+ "" : "not ");
+
+ AcpiOsPrintf ("\t\tGranularity: 0x%08x\n",
+ Address32Data->Granularity);
+
+ AcpiOsPrintf ("\t\tAddress range min: 0x%08x\n",
+ Address32Data->MinAddressRange);
+
+ AcpiOsPrintf ("\t\tAddress range max: 0x%08x\n",
+ Address32Data->MaxAddressRange);
+
+ AcpiOsPrintf ("\t\tAddress translation offset: 0x%08x\n",
+ Address32Data->AddressTranslationOffset);
+
+ AcpiOsPrintf ("\t\tAddress Length: 0x%08x\n",
+ Address32Data->AddressLength);
+
+ if(0xFF != Address32Data->ResourceSourceIndex)
+ {
+ AcpiOsPrintf ("\t\tResource Source Index: %d\n",
+ Address32Data->ResourceSourceIndex);
+ AcpiOsPrintf ("\t\tResource Source: %s\n",
+ Address32Data->ResourceSource);
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpExtendedIrq
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpExtendedIrq (
+ RESOURCE_DATA *Data)
+{
+ EXTENDED_IRQ_RESOURCE *ExtIrqData = (EXTENDED_IRQ_RESOURCE*) Data;
+ UINT8 Index = 0;
+
+
+ AcpiOsPrintf ("\tExtended IRQ Resource\n");
+
+ AcpiOsPrintf ("\t\tResource %s\n",
+ CONSUMER == ExtIrqData->ProducerConsumer ?
+ "Consumer" : "Producer");
+
+ AcpiOsPrintf ("\t\t%s\n",
+ LEVEL_SENSITIVE == ExtIrqData->EdgeLevel ?
+ "Level" : "Edge");
+
+ AcpiOsPrintf ("\t\tActive %s\n",
+ ACTIVE_LOW == ExtIrqData->ActiveHighLow ?
+ "low" : "high");
+
+ AcpiOsPrintf ("\t\t%s\n",
+ SHARED == ExtIrqData->SharedExclusive ?
+ "Shared" : "Exclusive");
+
+ AcpiOsPrintf ("\t\tInterrupts : %d ( ",
+ ExtIrqData->NumberOfInterrupts);
+
+ for (Index = 0; Index < ExtIrqData->NumberOfInterrupts; Index++)
+ {
+ AcpiOsPrintf ("%d ", ExtIrqData->Interrupts[Index]);
+ }
+
+ AcpiOsPrintf (")\n");
+
+ if(0xFF != ExtIrqData->ResourceSourceIndex)
+ {
+ AcpiOsPrintf ("\t\tResource Source Index: %d",
+ ExtIrqData->ResourceSourceIndex);
+ AcpiOsPrintf ("\t\tResource Source: %s",
+ ExtIrqData->ResourceSource);
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpResourceList
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Dispatches the structure to the correct dump routine.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpResourceList (
+ RESOURCE *Resource)
+{
+ UINT8 Count = 0;
+ BOOLEAN Done = FALSE;
+
+
+ if (AcpiDbgLevel & TRACE_RESOURCES && _COMPONENT & AcpiDbgLayer)
+ {
+ while (!Done)
+ {
+ AcpiOsPrintf ("\tResource structure %x.\n", Count++);
+
+ switch (Resource->Id)
+ {
+ case Irq:
+ AcpiRsDumpIrq (&Resource->Data);
+ break;
+
+ case Dma:
+ AcpiRsDumpDma (&Resource->Data);
+ break;
+
+ case StartDependentFunctions:
+ AcpiRsDumpStartDependentFunctions (&Resource->Data);
+ break;
+
+ case EndDependentFunctions:
+ AcpiOsPrintf ("\tEndDependentFunctions Resource\n");
+ /* AcpiRsDumpEndDependentFunctions (Resource->Data);*/
+ break;
+
+ case Io:
+ AcpiRsDumpIo (&Resource->Data);
+ break;
+
+ case FixedIo:
+ AcpiRsDumpFixedIo (&Resource->Data);
+ break;
+
+ case VendorSpecific:
+ AcpiRsDumpVendorSpecific (&Resource->Data);
+ break;
+
+ case EndTag:
+ /*RsDumpEndTag (Resource->Data);*/
+ AcpiOsPrintf ("\tEndTag Resource\n");
+ Done = TRUE;
+ break;
+
+ case Memory24:
+ AcpiRsDumpMemory24 (&Resource->Data);
+ break;
+
+ case Memory32:
+ AcpiRsDumpMemory32 (&Resource->Data);
+ break;
+
+ case FixedMemory32:
+ AcpiRsDumpFixedMemory32 (&Resource->Data);
+ break;
+
+ case Address16:
+ AcpiRsDumpAddress16 (&Resource->Data);
+ break;
+
+ case Address32:
+ AcpiRsDumpAddress32 (&Resource->Data);
+ break;
+
+ case ExtendedIrq:
+ AcpiRsDumpExtendedIrq (&Resource->Data);
+ break;
+
+ default:
+ AcpiOsPrintf ("Invalid resource type\n");
+ break;
+
+ }
+
+ Resource = (RESOURCE *) ((NATIVE_UINT) Resource +
+ (NATIVE_UINT) Resource->Length);
+ }
+ }
+
+ return;
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpIrqList
+ *
+ * PARAMETERS: Data - pointer to the routing table to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Dispatches the structures to the correct dump routine.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpIrqList (
+ UINT8 *RouteTable)
+{
+ UINT8 *Buffer = RouteTable;
+ UINT8 Count = 0;
+ BOOLEAN Done = FALSE;
+ PCI_ROUTING_TABLE *PrtElement;
+
+
+ if (AcpiDbgLevel & TRACE_RESOURCES && _COMPONENT & AcpiDbgLayer)
+ {
+ PrtElement = (PCI_ROUTING_TABLE *)Buffer;
+
+ while (!Done)
+ {
+ AcpiOsPrintf ("\tPCI IRQ Routing Table structure %x.\n", Count++);
+
+ AcpiOsPrintf ("\t\tAddress: 0x%x\n",
+ PrtElement->Data.Address);
+
+ AcpiOsPrintf ("\t\tPin: 0x%x\n", PrtElement->Data.Pin);
+
+ AcpiOsPrintf ("\t\tSource: %s\n", PrtElement->Data.Source);
+
+ AcpiOsPrintf ("\t\tSourceIndex: 0x%x\n",
+ PrtElement->Data.SourceIndex);
+
+ Buffer += PrtElement->Length;
+
+ PrtElement = (PCI_ROUTING_TABLE *)Buffer;
+
+ if(0 == PrtElement->Length)
+ {
+ Done = TRUE;
+ }
+ }
+ }
+
+ return;
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsio.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsio.c
new file mode 100644
index 000000000000..0895fcf36b0d
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsio.c
@@ -0,0 +1,636 @@
+/*******************************************************************************
+ *
+ * Module Name: rsio - AcpiRsIoResource
+ * AcpiRsFixedIoResource
+ * AcpiRsIoStream
+ * AcpiRsFixedIoStream
+ * AcpiRsDmaResource
+ * AcpiRsDmaStream
+ * $Revision: 9 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __RSIO_C__
+
+#include "acpi.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rsio")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsIoResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsIoResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT32 StructSize = sizeof (IO_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsIoResource");
+
+ /*
+ * The number of bytes consumed are Constant
+ */
+ *BytesConsumed = 8;
+
+ OutputStruct->Id = Io;
+
+ /*
+ * Check Decode
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.Io.IoDecode = Temp8 & 0x01;
+
+ /*
+ * Check MinBase Address
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ OutputStruct->Data.Io.MinBaseAddress = Temp16;
+
+ /*
+ * Check MaxBase Address
+ */
+ Buffer += 2;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ OutputStruct->Data.Io.MaxBaseAddress = Temp16;
+
+ /*
+ * Check Base alignment
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.Io.Alignment = Temp8;
+
+ /*
+ * Check RangeLength
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.Io.RangeLength = Temp8;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsFixedIoResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsFixedIoResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT32 StructSize = sizeof (FIXED_IO_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsFixedIoResource");
+
+ /*
+ * The number of bytes consumed are Constant
+ */
+ *BytesConsumed = 4;
+
+ OutputStruct->Id = FixedIo;
+
+ /*
+ * Check Range Base Address
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ OutputStruct->Data.FixedIo.BaseAddress = Temp16;
+
+ /*
+ * Check RangeLength
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.FixedIo.RangeLength = Temp8;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsIoStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsIoStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ FUNCTION_TRACE ("RsIoStream");
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x47;
+ Buffer += 1;
+
+ /*
+ * Io Information Byte
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Io.IoDecode & 0x01);
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Range minimum base address
+ */
+ Temp16 = (UINT16) LinkedList->Data.Io.MinBaseAddress;
+
+ MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the Range maximum base address
+ */
+ Temp16 = (UINT16) LinkedList->Data.Io.MaxBaseAddress;
+
+ MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the base alignment
+ */
+ Temp8 = (UINT8) LinkedList->Data.Io.Alignment;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the range length
+ */
+ Temp8 = (UINT8) LinkedList->Data.Io.RangeLength;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsFixedIoStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsFixedIoStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ FUNCTION_TRACE ("RsFixedIoStream");
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x4B;
+
+ Buffer += 1;
+
+ /*
+ * Set the Range base address
+ */
+ Temp16 = (UINT16) LinkedList->Data.FixedIo.BaseAddress;
+
+ MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the range length
+ */
+ Temp8 = (UINT8) LinkedList->Data.FixedIo.RangeLength;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDmaResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsDmaResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ UINT8 i;
+ UINT32 StructSize = sizeof(DMA_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsDmaResource");
+
+ /*
+ * The number of bytes consumed are Constant
+ */
+ *BytesConsumed = 3;
+ OutputStruct->Id = Dma;
+
+ /*
+ * Point to the 8-bits of Byte 1
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /* Decode the IRQ bits */
+
+ for (i = 0, Index = 0; Index < 8; Index++)
+ {
+ if ((Temp8 >> Index) & 0x01)
+ {
+ OutputStruct->Data.Dma.Channels[i] = Index;
+ i++;
+ }
+ }
+ OutputStruct->Data.Dma.NumberOfChannels = i;
+
+
+ /*
+ * Calculate the structure size based upon the number of interrupts
+ */
+ StructSize += (OutputStruct->Data.Dma.NumberOfChannels - 1) * 4;
+
+ /*
+ * Point to Byte 2
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /*
+ * Check for transfer preference (Bits[1:0])
+ */
+ OutputStruct->Data.Dma.Transfer = Temp8 & 0x03;
+
+ if (0x03 == OutputStruct->Data.Dma.Transfer)
+ {
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /*
+ * Get bus master preference (Bit[2])
+ */
+ OutputStruct->Data.Dma.BusMaster = (Temp8 >> 2) & 0x01;
+
+ /*
+ * Get channel speed support (Bits[6:5])
+ */
+ OutputStruct->Data.Dma.Type = (Temp8 >> 5) & 0x03;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDmaStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsDmaStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+
+
+ FUNCTION_TRACE ("RsDmaStream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x2A;
+ Buffer += 1;
+ Temp8 = 0;
+
+ /*
+ * Loop through all of the Channels and set the mask bits
+ */
+ for (Index = 0;
+ Index < LinkedList->Data.Dma.NumberOfChannels;
+ Index++)
+ {
+ Temp16 = (UINT16) LinkedList->Data.Dma.Channels[Index];
+ Temp8 |= 0x1 << Temp16;
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the DMA Info
+ */
+ Temp8 = (UINT8) ((LinkedList->Data.Dma.Type & 0x03) << 5);
+ Temp8 |= ((LinkedList->Data.Dma.BusMaster & 0x01) << 2);
+ Temp8 |= (LinkedList->Data.Dma.Transfer & 0x03);
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsirq.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsirq.c
new file mode 100644
index 000000000000..7f16c4d08946
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsirq.c
@@ -0,0 +1,683 @@
+/*******************************************************************************
+ *
+ * Module Name: rsirq - AcpiRsIrqResource,
+ * AcpiRsIrqStream
+ * AcpiRsExtendedIrqResource
+ * AcpiRsExtendedIrqStream
+ * $Revision: 10 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __RSIRQ_C__
+
+#include "acpi.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rsirq")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsIrqResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsIrqResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ UINT8 i;
+ UINT32 StructSize = sizeof (IRQ_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsIrqResource");
+
+ /*
+ * The number of bytes consumed are contained in the descriptor
+ * (Bits:0-1)
+ */
+ Temp8 = *Buffer;
+ *BytesConsumed = (Temp8 & 0x03) + 1;
+ OutputStruct->Id = Irq;
+
+ /*
+ * Point to the 16-bits of Bytes 1 and 2
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ OutputStruct->Data.Irq.NumberOfInterrupts = 0;
+
+ /* Decode the IRQ bits */
+
+ for (i = 0, Index = 0; Index < 16; Index++)
+ {
+ if((Temp16 >> Index) & 0x01)
+ {
+ OutputStruct->Data.Irq.Interrupts[i] = Index;
+ i++;
+ }
+ }
+ OutputStruct->Data.Irq.NumberOfInterrupts = i;
+
+ /*
+ * Calculate the structure size based upon the number of interrupts
+ */
+ StructSize += (OutputStruct->Data.Irq.NumberOfInterrupts - 1) * 4;
+
+ /*
+ * Point to Byte 3 if it is used
+ */
+ if (4 == *BytesConsumed)
+ {
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ /*
+ * Check for HE, LL or HL
+ */
+ if (Temp8 & 0x01)
+ {
+ OutputStruct->Data.Irq.EdgeLevel = EDGE_SENSITIVE;
+ OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_HIGH;
+ }
+
+ else
+ {
+ if (Temp8 & 0x8)
+ {
+ OutputStruct->Data.Irq.EdgeLevel = LEVEL_SENSITIVE;
+ OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_LOW;
+ }
+
+ else
+ {
+ /*
+ * Only _LL and _HE polarity/trigger interrupts
+ * are allowed (ACPI spec v1.0b ection 6.4.2.1),
+ * so an error will occur if we reach this point
+ */
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+ }
+
+ /*
+ * Check for sharable
+ */
+ OutputStruct->Data.Irq.SharedExclusive = (Temp8 >> 3) & 0x01;
+ }
+
+ else
+ {
+ /*
+ * Assume Edge Sensitive, Active High, Non-Sharable
+ * per ACPI Specification
+ */
+ OutputStruct->Data.Irq.EdgeLevel = EDGE_SENSITIVE;
+ OutputStruct->Data.Irq.ActiveHighLow = ACTIVE_HIGH;
+ OutputStruct->Data.Irq.SharedExclusive = EXCLUSIVE;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsIrqStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsIrqStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ BOOLEAN IRQInfoByteNeeded;
+
+
+ FUNCTION_TRACE ("RsIrqStream");
+
+
+ /*
+ * The descriptor field is set based upon whether a third byte is
+ * needed to contain the IRQ Information.
+ */
+ if (EDGE_SENSITIVE == LinkedList->Data.Irq.EdgeLevel &&
+ ACTIVE_HIGH == LinkedList->Data.Irq.ActiveHighLow &&
+ EXCLUSIVE == LinkedList->Data.Irq.SharedExclusive)
+ {
+ *Buffer = 0x22;
+ IRQInfoByteNeeded = FALSE;
+ }
+ else
+ {
+ *Buffer = 0x23;
+ IRQInfoByteNeeded = TRUE;
+ }
+
+ Buffer += 1;
+ Temp16 = 0;
+
+ /*
+ * Loop through all of the interrupts and set the mask bits
+ */
+ for(Index = 0;
+ Index < LinkedList->Data.Irq.NumberOfInterrupts;
+ Index++)
+ {
+ Temp8 = (UINT8) LinkedList->Data.Irq.Interrupts[Index];
+ Temp16 |= 0x1 << Temp8;
+ }
+
+ MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the IRQ Info byte if needed.
+ */
+ if (IRQInfoByteNeeded)
+ {
+ Temp8 = 0;
+ Temp8 = (UINT8) ((LinkedList->Data.Irq.SharedExclusive &
+ 0x01) << 4);
+
+ if (LEVEL_SENSITIVE == LinkedList->Data.Irq.EdgeLevel &&
+ ACTIVE_LOW == LinkedList->Data.Irq.ActiveHighLow)
+ {
+ Temp8 |= 0x08;
+ }
+
+ else
+ {
+ Temp8 |= 0x01;
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsExtendedIrqResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsExtendedIrqResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ UINT32 StructSize = sizeof (EXTENDED_IRQ_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsExtendedIrqResource");
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ *BytesConsumed = Temp16 + 3;
+ OutputStruct->Id = ExtendedIrq;
+
+ /*
+ * Point to the Byte3
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.ExtendedIrq.ProducerConsumer = Temp8 & 0x01;
+
+ /*
+ * Check for HE, LL or HL
+ */
+ if(Temp8 & 0x02)
+ {
+ OutputStruct->Data.ExtendedIrq.EdgeLevel = EDGE_SENSITIVE;
+ OutputStruct->Data.ExtendedIrq.ActiveHighLow = ACTIVE_HIGH;
+ }
+
+ else
+ {
+ if(Temp8 & 0x4)
+ {
+ OutputStruct->Data.ExtendedIrq.EdgeLevel = LEVEL_SENSITIVE;
+ OutputStruct->Data.ExtendedIrq.ActiveHighLow = ACTIVE_LOW;
+ }
+
+ else
+ {
+ /*
+ * Only _LL and _HE polarity/trigger interrupts
+ * are allowed (ACPI spec v1.0b ection 6.4.2.1),
+ * so an error will occur if we reach this point
+ */
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+ }
+
+ /*
+ * Check for sharable
+ */
+ OutputStruct->Data.ExtendedIrq.SharedExclusive =
+ (Temp8 >> 3) & 0x01;
+
+ /*
+ * Point to Byte4 (IRQ Table length)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.ExtendedIrq.NumberOfInterrupts = Temp8;
+
+ /*
+ * Add any additional structure size to properly calculate
+ * the next pointer at the end of this function
+ */
+ StructSize += (Temp8 - 1) * 4;
+
+ /*
+ * Point to Byte5 (First IRQ Number)
+ */
+ Buffer += 1;
+
+ /*
+ * Cycle through every IRQ in the table
+ */
+ for (Index = 0; Index < Temp8; Index++)
+ {
+ OutputStruct->Data.ExtendedIrq.Interrupts[Index] =
+ (UINT32)*Buffer;
+
+ /* Point to the next IRQ */
+
+ Buffer += 4;
+ }
+
+ /*
+ * This will leave us pointing to the Resource Source Index
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
+ * Each Interrupt takes 32-bits + the 5 bytes of the
+ * stream that are default.
+ */
+ if (*BytesConsumed >
+ (UINT32)(OutputStruct->Data.ExtendedIrq.NumberOfInterrupts *
+ 4) + 5)
+ {
+ /* Dereference the Index */
+
+ Temp8 = *Buffer;
+ OutputStruct->Data.ExtendedIrq.ResourceSourceIndex =
+ (UINT32)Temp8;
+
+ /* Point to the String */
+
+ Buffer += 1;
+
+ /* Copy the string into the buffer */
+
+ Index = 0;
+
+ while (0x00 != *Buffer)
+ {
+ OutputStruct->Data.ExtendedIrq.ResourceSource[Index] =
+ *Buffer;
+
+ Buffer += 1;
+ Index += 1;
+ }
+
+ /*
+ * Add the terminating null
+ */
+ OutputStruct->Data.ExtendedIrq.ResourceSource[Index] = 0x00;
+ OutputStruct->Data.ExtendedIrq.ResourceSourceStringLength =
+ Index + 1;
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundry,
+ * calculate the length of the string and expand the
+ * StructSize to the next 32-bit boundry.
+ */
+ Temp8 = (UINT8) (Index + 1);
+ Temp8 = (UINT8) ROUND_UP_TO_32BITS (Temp8);
+ }
+
+ else
+ {
+ OutputStruct->Data.ExtendedIrq.ResourceSourceIndex = 0x00;
+ OutputStruct->Data.ExtendedIrq.ResourceSourceStringLength = 0;
+ OutputStruct->Data.ExtendedIrq.ResourceSource[0] = 0x00;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsExtendedIrqStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsExtendedIrqStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 *LengthField;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ NATIVE_CHAR *TempPointer = NULL;
+
+
+ FUNCTION_TRACE ("RsExtendedIrqStream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x89;
+ Buffer += 1;
+
+ /*
+ * Set a pointer to the Length field - to be filled in later
+ */
+
+ LengthField = (UINT16 *)Buffer;
+ Buffer += 2;
+
+ /*
+ * Set the Interrupt vector flags
+ */
+ Temp8 = (UINT8)(LinkedList->Data.ExtendedIrq.ProducerConsumer & 0x01);
+
+ Temp8 |= ((LinkedList->Data.ExtendedIrq.SharedExclusive & 0x01) << 3);
+
+ if (LEVEL_SENSITIVE == LinkedList->Data.ExtendedIrq.EdgeLevel &&
+ ACTIVE_LOW == LinkedList->Data.ExtendedIrq.ActiveHighLow)
+ {
+ Temp8 |= 0x04;
+ }
+ else
+ {
+ Temp8 |= 0x02;
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Interrupt table length
+ */
+ Temp8 = (UINT8) LinkedList->Data.ExtendedIrq.NumberOfInterrupts;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ for (Index = 0;
+ Index < LinkedList->Data.ExtendedIrq.NumberOfInterrupts;
+ Index++)
+ {
+ MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.ExtendedIrq.Interrupts[Index]);
+ Buffer += 4;
+ }
+
+ /*
+ * Resource Source Index and Resource Source are optional
+ */
+ if (0 != LinkedList->Data.ExtendedIrq.ResourceSourceStringLength)
+ {
+ *Buffer = (UINT8) LinkedList->Data.ExtendedIrq.ResourceSourceIndex;
+ Buffer += 1;
+
+ TempPointer = (NATIVE_CHAR *) Buffer;
+
+ /*
+ * Copy the string
+ */
+ STRCPY (TempPointer, LinkedList->Data.ExtendedIrq.ResourceSource);
+
+ /*
+ * Buffer needs to be set to the length of the sting + one for the
+ * terminating null
+ */
+ Buffer += (STRLEN (LinkedList->Data.ExtendedIrq.ResourceSource) + 1);
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ /*
+ * Set the length field to the number of bytes consumed
+ * minus the header size (3 bytes)
+ */
+ *LengthField = (UINT16) (*BytesConsumed - 3);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c b/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c
new file mode 100644
index 000000000000..463cee38e366
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rslist.c
@@ -0,0 +1,606 @@
+/*******************************************************************************
+ *
+ * Module Name: rslist - AcpiRsByteStreamToList
+ * AcpiListToByteStream
+ * $Revision: 8 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __RSLIST_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rslist")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsByteStreamToList
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream
+ * ByteStreamBufferLength - Length of ByteStreamBuffer
+ * OutputBuffer - Pointer to the buffer that will
+ * contain the output structures
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Takes the resource byte stream and parses it, creating a
+ * linked list of resources in the caller's output buffer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsByteStreamToList (
+ UINT8 *ByteStreamBuffer,
+ UINT32 ByteStreamBufferLength,
+ UINT8 **OutputBuffer)
+{
+ ACPI_STATUS Status;
+ UINT32 BytesParsed = 0;
+ UINT8 ResourceType = 0;
+ UINT32 BytesConsumed = 0;
+ UINT8 **Buffer = OutputBuffer;
+ UINT32 StructureSize = 0;
+ BOOLEAN EndTagProcessed = FALSE;
+
+
+ FUNCTION_TRACE ("RsByteStreamToList");
+
+
+ while (BytesParsed < ByteStreamBufferLength &&
+ FALSE == EndTagProcessed)
+ {
+ /*
+ * Look at the next byte in the stream
+ */
+ ResourceType = *ByteStreamBuffer;
+
+ /*
+ * See if this is a small or large resource
+ */
+ if(ResourceType & 0x80)
+ {
+ /*
+ * Large Resource Type
+ */
+ switch (ResourceType)
+ {
+ case MEMORY_RANGE_24:
+ /*
+ * 24-Bit Memory Resource
+ */
+ Status = AcpiRsMemory24Resource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case LARGE_VENDOR_DEFINED:
+ /*
+ * Vendor Defined Resource
+ */
+ Status = AcpiRsVendorResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case MEMORY_RANGE_32:
+ /*
+ * 32-Bit Memory Range Resource
+ */
+ Status = AcpiRsMemory32RangeResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case FIXED_MEMORY_RANGE_32:
+ /*
+ * 32-Bit Fixed Memory Resource
+ */
+ Status = AcpiRsFixedMemory32Resource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case DWORD_ADDRESS_SPACE:
+ /*
+ * 32-Bit Address Resource
+ */
+ Status = AcpiRsAddress32Resource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case WORD_ADDRESS_SPACE:
+ /*
+ * 16-Bit Address Resource
+ */
+ Status = AcpiRsAddress16Resource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case EXTENDED_IRQ:
+ /*
+ * Extended IRQ
+ */
+ Status = AcpiRsExtendedIrqResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+/* TBD: [Future] 64-bit not currently supported */
+/*
+ case 0x8A:
+ break;
+*/
+
+ default:
+ /*
+ * If we get here, everything is out of sync,
+ * so exit with an error
+ */
+ return_ACPI_STATUS (AE_AML_ERROR);
+ break;
+ }
+ }
+
+ else
+ {
+ /*
+ * Small Resource Type
+ * Only bits 7:3 are valid
+ */
+ ResourceType >>= 3;
+
+ switch(ResourceType)
+ {
+ case IRQ_FORMAT:
+ /*
+ * IRQ Resource
+ */
+ Status = AcpiRsIrqResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case DMA_FORMAT:
+ /*
+ * DMA Resource
+ */
+ Status = AcpiRsDmaResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case START_DEPENDENT_TAG:
+ /*
+ * Start Dependent Functions Resource
+ */
+ Status = AcpiRsStartDependentFunctionsResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case END_DEPENDENT_TAG:
+ /*
+ * End Dependent Functions Resource
+ */
+ Status = AcpiRsEndDependentFunctionsResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case IO_PORT_DESCRIPTOR:
+ /*
+ * IO Port Resource
+ */
+ Status = AcpiRsIoResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case FIXED_LOCATION_IO_DESCRIPTOR:
+ /*
+ * Fixed IO Port Resource
+ */
+ Status = AcpiRsFixedIoResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case SMALL_VENDOR_DEFINED:
+ /*
+ * Vendor Specific Resource
+ */
+ Status = AcpiRsVendorResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+
+ break;
+
+ case END_TAG:
+ /*
+ * End Tag
+ */
+ Status = AcpiRsEndTagResource(ByteStreamBuffer,
+ &BytesConsumed,
+ Buffer,
+ &StructureSize);
+ EndTagProcessed = TRUE;
+
+ break;
+
+ default:
+ /*
+ * If we get here, everything is out of sync,
+ * so exit with an error
+ */
+ return_ACPI_STATUS (AE_AML_ERROR);
+ break;
+
+ } /* switch */
+ } /* end else */
+
+ /*
+ * Update the return value and counter
+ */
+ BytesParsed += BytesConsumed;
+
+ /*
+ * Set the byte stream to point to the next resource
+ */
+ ByteStreamBuffer += BytesConsumed;
+
+ /*
+ * Set the Buffer to the next structure
+ */
+ *Buffer += StructureSize;
+
+ } /* end while */
+
+ /*
+ * Check the reason for exiting the while loop
+ */
+ if (!(ByteStreamBufferLength == BytesParsed) ||
+ (TRUE != EndTagProcessed))
+ {
+ return_ACPI_STATUS (AE_AML_ERROR);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsListToByteStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * ByteSteamSizeNeeded - Calculated size of the byte stream
+ * needed from calling
+ * AcpiRsCalculateByteStreamLength()
+ * The size of the OutputBuffer is
+ * guaranteed to be >=
+ * ByteStreamSizeNeeded
+ * OutputBuffer - Pointer to the buffer that will
+ * contain the byte stream
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Takes the resource linked list and parses it, creating a
+ * byte stream of resources in the caller's output buffer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsListToByteStream (
+ RESOURCE *LinkedList,
+ UINT32 ByteStreamSizeNeeded,
+ UINT8 **OutputBuffer)
+{
+ ACPI_STATUS Status;
+ UINT8 *Buffer = *OutputBuffer;
+ UINT32 BytesConsumed = 0;
+ BOOLEAN Done = FALSE;
+
+
+ FUNCTION_TRACE ("RsListToByteStream");
+
+ while (!Done)
+ {
+ switch (LinkedList->Id)
+ {
+ case Irq:
+ /*
+ * IRQ Resource
+ */
+ Status = AcpiRsIrqStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case Dma:
+ /*
+ * DMA Resource
+ */
+ Status = AcpiRsDmaStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case StartDependentFunctions:
+ /*
+ * Start Dependent Functions Resource
+ */
+ Status = AcpiRsStartDependentFunctionsStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case EndDependentFunctions:
+ /*
+ * End Dependent Functions Resource
+ */
+ Status = AcpiRsEndDependentFunctionsStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case Io:
+ /*
+ * IO Port Resource
+ */
+ Status = AcpiRsIoStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case FixedIo:
+ /*
+ * Fixed IO Port Resource
+ */
+ Status = AcpiRsFixedIoStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case VendorSpecific:
+ /*
+ * Vendor Defined Resource
+ */
+ Status = AcpiRsVendorStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case EndTag:
+ /*
+ * End Tag
+ */
+ Status = AcpiRsEndTagStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+
+ /*
+ * An End Tag indicates the end of the Resource Template
+ */
+ Done = TRUE;
+ break;
+
+ case Memory24:
+ /*
+ * 24-Bit Memory Resource
+ */
+ Status = AcpiRsMemory24Stream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case Memory32:
+ /*
+ * 32-Bit Memory Range Resource
+ */
+ Status = AcpiRsMemory32RangeStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case FixedMemory32:
+ /*
+ * 32-Bit Fixed Memory Resource
+ */
+ Status = AcpiRsFixedMemory32Stream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case Address16:
+ /*
+ * 16-Bit Address Descriptor Resource
+ */
+ Status = AcpiRsAddress16Stream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case Address32:
+ /*
+ * 32-Bit Address Descriptor Resource
+ */
+ Status = AcpiRsAddress32Stream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ case ExtendedIrq:
+ /*
+ * Extended IRQ Resource
+ */
+ Status = AcpiRsExtendedIrqStream (LinkedList,
+ &Buffer,
+ &BytesConsumed);
+ break;
+
+ default:
+ /*
+ * If we get here, everything is out of sync,
+ * so exit with an error
+ */
+ return_ACPI_STATUS (AE_BAD_DATA);
+ break;
+
+ } /* switch (LinkedList->Id) */
+
+ /*
+ * Set the Buffer to point to the open byte
+ */
+ Buffer += BytesConsumed;
+
+ /*
+ * Point to the next object
+ */
+ LinkedList = (RESOURCE *) ((NATIVE_UINT) LinkedList +
+ (NATIVE_UINT) LinkedList->Length);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsmemory.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsmemory.c
new file mode 100644
index 000000000000..bc1ab297143e
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsmemory.c
@@ -0,0 +1,660 @@
+/*******************************************************************************
+ *
+ * Module Name: rsmem24 - AcpiRsMemory24Resource
+ * AcpiRsMemory24Stream
+ * AcpiRsMemory32RangeResource
+ * AcpiRsFixedMemory32Resource
+ * AcpiRsMemory32RangeStream
+ * AcpiRsFixedMemory32Stream
+ * $Revision: 9 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __RSMEMORY_C__
+
+#include "acpi.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rsmemory")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMemory24Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsMemory24Resource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT32 StructSize = sizeof (MEMORY24_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsMemory24Resource");
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ *BytesConsumed = Temp16 + 3;
+ OutputStruct->Id = Memory24;
+
+ /*
+ * Check Byte 3 the Read/Write bit
+ */
+ Temp8 = *Buffer;
+ Buffer += 1;
+ OutputStruct->Data.Memory24.ReadWriteAttribute = Temp8 & 0x01;
+
+ /*
+ * Get MinBaseAddress (Bytes 4-5)
+ */
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ OutputStruct->Data.Memory24.MinBaseAddress = Temp16;
+
+ /*
+ * Get MaxBaseAddress (Bytes 6-7)
+ */
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ OutputStruct->Data.Memory24.MaxBaseAddress = Temp16;
+
+ /*
+ * Get Alignment (Bytes 8-9)
+ */
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ OutputStruct->Data.Memory24.Alignment = Temp16;
+
+ /*
+ * Get RangeLength (Bytes 10-11)
+ */
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ OutputStruct->Data.Memory24.RangeLength = Temp16;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMemory24Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsMemory24Stream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ FUNCTION_TRACE ("RsMemory24Stream");
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x81;
+ Buffer += 1;
+
+ /*
+ * The length field is static
+ */
+ Temp16 = 0x09;
+ MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the Information Byte
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Memory24.ReadWriteAttribute & 0x01);
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Range minimum base address
+ */
+ MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MinBaseAddress);
+ Buffer += 2;
+
+ /*
+ * Set the Range maximum base address
+ */
+ MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MaxBaseAddress);
+ Buffer += 2;
+
+ /*
+ * Set the base alignment
+ */
+ MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.Alignment);
+ Buffer += 2;
+
+ /*
+ * Set the range length
+ */
+ MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.RangeLength);
+ Buffer += 2;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMemory32RangeResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsMemory32RangeResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT32 StructSize = sizeof (MEMORY32_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsMemory32RangeResource");
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ *BytesConsumed = Temp16 + 3;
+
+ OutputStruct->Id = Memory32;
+
+ /*
+ * Point to the place in the output buffer where the data portion will
+ * begin.
+ * 1. Set the RESOURCE_DATA * Data to point to it's own address, then
+ * 2. Set the pointer to the next address.
+ *
+ * NOTE: OutputStruct->Data is cast to UINT8, otherwise, this addition adds
+ * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(UINT8)
+ */
+
+ /*
+ * Check Byte 3 the Read/Write bit
+ */
+ Temp8 = *Buffer;
+ Buffer += 1;
+
+ OutputStruct->Data.Memory32.ReadWriteAttribute = Temp8 & 0x01;
+
+ /*
+ * Get MinBaseAddress (Bytes 4-7)
+ */
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MinBaseAddress,
+ Buffer);
+ Buffer += 4;
+
+ /*
+ * Get MaxBaseAddress (Bytes 8-11)
+ */
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MaxBaseAddress,
+ Buffer);
+ Buffer += 4;
+
+ /*
+ * Get Alignment (Bytes 12-15)
+ */
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.Alignment, Buffer);
+ Buffer += 4;
+
+ /*
+ * Get RangeLength (Bytes 16-19)
+ */
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.RangeLength, Buffer);
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsFixedMemory32Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsFixedMemory32Resource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT32 StructSize = sizeof (FIXED_MEMORY32_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsFixedMemory32Resource");
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ Buffer += 2;
+ *BytesConsumed = Temp16 + 3;
+
+ OutputStruct->Id = FixedMemory32;
+
+ /*
+ * Check Byte 3 the Read/Write bit
+ */
+ Temp8 = *Buffer;
+ Buffer += 1;
+ OutputStruct->Data.FixedMemory32.ReadWriteAttribute = Temp8 & 0x01;
+
+ /*
+ * Get RangeBaseAddress (Bytes 4-7)
+ */
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeBaseAddress,
+ Buffer);
+ Buffer += 4;
+
+ /*
+ * Get RangeLength (Bytes 8-11)
+ */
+ MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeLength,
+ Buffer);
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMemory32RangeStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsMemory32RangeStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ FUNCTION_TRACE ("RsMemory32RangeStream");
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x85;
+ Buffer += 1;
+
+ /*
+ * The length field is static
+ */
+ Temp16 = 0x11;
+
+ MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the Information Byte
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Memory32.ReadWriteAttribute & 0x01);
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Range minimum base address
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MinBaseAddress);
+ Buffer += 4;
+
+ /*
+ * Set the Range maximum base address
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MaxBaseAddress);
+ Buffer += 4;
+
+ /*
+ * Set the base alignment
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.Alignment);
+ Buffer += 4;
+
+ /*
+ * Set the range length
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.RangeLength);
+ Buffer += 4;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsFixedMemory32Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsFixedMemory32Stream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ FUNCTION_TRACE ("RsFixedMemory32Stream");
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x86;
+ Buffer += 1;
+
+ /*
+ * The length field is static
+ */
+ Temp16 = 0x09;
+
+ MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the Information Byte
+ */
+ Temp8 = (UINT8) (LinkedList->Data.FixedMemory32.ReadWriteAttribute & 0x01);
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Range base address
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.FixedMemory32.RangeBaseAddress);
+ Buffer += 4;
+
+ /*
+ * Set the range length
+ */
+ MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.FixedMemory32.RangeLength);
+ Buffer += 4;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsmisc.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsmisc.c
new file mode 100644
index 000000000000..23170e6a4714
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsmisc.c
@@ -0,0 +1,725 @@
+/*******************************************************************************
+ *
+ * Module Name: rsmisc - AcpiRsEndTagResource
+ * AcpiRsEndTagStream
+ * AcpiRsVendorResource
+ * AcpiRsVendorStream
+ * AcpiRsStartDependentFunctionsResource
+ * AcpiRsEndDependentFunctionsResource
+ * AcpiRsStartDependentFunctionsStream
+ * AcpiRsEndDependentFunctionsStream
+ * $Revision: 9 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __RSMISC_C__
+
+#include "acpi.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rsmisc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsEndTagResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsEndTagResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT32 StructSize = RESOURCE_LENGTH;
+
+
+ FUNCTION_TRACE ("RsEndTagResource");
+
+ /*
+ * The number of bytes consumed is static
+ */
+ *BytesConsumed = 2;
+
+ /*
+ * Fill out the structure
+ */
+ OutputStruct->Id = EndTag;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = 0;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsEndTagStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsEndTagStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT8 Temp8 = 0;
+
+
+ FUNCTION_TRACE ("RsEndTagStream");
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x79;
+ Buffer += 1;
+
+ /*
+ * Set the Checksum - zero means that the resource data is treated as if
+ * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
+ */
+ Temp8 = 0;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsVendorResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsVendorResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ UINT32 StructSize = sizeof (VENDOR_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsVendorResource");
+
+ /*
+ * Dereference the Descriptor to find if this is a large or small item.
+ */
+ Temp8 = *Buffer;
+
+ if (Temp8 & 0x80)
+ {
+ /*
+ * Large Item
+ */
+ /* Point to the length field */
+
+ Buffer += 1;
+
+ /* Dereference */
+
+ MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ /* Calculate bytes consumed */
+
+ *BytesConsumed = Temp16 + 3;
+
+ /* Point to the first vendor byte */
+
+ Buffer += 2;
+ }
+
+ else
+ {
+ /*
+ * Small Item
+ */
+
+ /* Dereference the size */
+
+ Temp16 = (UINT8)(*Buffer & 0x07);
+
+ /* Calculate bytes consumed */
+
+ *BytesConsumed = Temp16 + 1;
+
+ /* Point to the first vendor byte */
+
+ Buffer += 1;
+ }
+
+ OutputStruct->Id = VendorSpecific;
+ OutputStruct->Data.VendorSpecific.Length = Temp16;
+
+ for (Index = 0; Index < Temp16; Index++)
+ {
+ OutputStruct->Data.VendorSpecific.Reserved[Index] = *Buffer;
+ Buffer += 1;
+ }
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundry,
+ * calculate the length of the vendor string and expand the
+ * StructSize to the next 32-bit boundry.
+ */
+ StructSize += ROUND_UP_TO_32BITS (Temp16);
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsVendorStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsVendorStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+
+
+ FUNCTION_TRACE ("RsVendorStream");
+
+ /*
+ * Dereference the length to find if this is a large or small item.
+ */
+
+ if(LinkedList->Data.VendorSpecific.Length > 7)
+ {
+ /*
+ * Large Item
+ */
+ /*
+ * Set the descriptor field and length bytes
+ */
+ *Buffer = 0x84;
+ Buffer += 1;
+
+ Temp16 = (UINT16) LinkedList->Data.VendorSpecific.Length;
+
+ MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+ }
+
+ else
+ {
+ /*
+ * Small Item
+ */
+
+ /*
+ * Set the descriptor field
+ */
+ Temp8 = 0x70;
+ Temp8 |= LinkedList->Data.VendorSpecific.Length;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+ }
+
+ /*
+ * Loop through all of the Vendor Specific fields
+ */
+ for (Index = 0; Index < LinkedList->Data.VendorSpecific.Length; Index++)
+ {
+ Temp8 = LinkedList->Data.VendorSpecific.Reserved[Index];
+
+ *Buffer = Temp8;
+ Buffer += 1;
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsStartDependentFunctionsResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsStartDependentFunctionsResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT8 Temp8 = 0;
+ UINT32 StructSize =
+ sizeof(START_DEPENDENT_FUNCTIONS_RESOURCE) +
+ RESOURCE_LENGTH_NO_DATA;
+
+
+ FUNCTION_TRACE ("RsStartDependentFunctionsResource");
+
+ /*
+ * The number of bytes consumed are contained in the descriptor (Bits:0-1)
+ */
+ Temp8 = *Buffer;
+
+ *BytesConsumed = (Temp8 & 0x01) + 1;
+
+ OutputStruct->Id = StartDependentFunctions;
+
+ /*
+ * Point to Byte 1 if it is used
+ */
+ if (2 == *BytesConsumed)
+ {
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /*
+ * Check Compatibility priority
+ */
+ OutputStruct->Data.StartDependentFunctions.CompatibilityPriority =
+ Temp8 & 0x03;
+
+ if (3 == OutputStruct->Data.StartDependentFunctions.CompatibilityPriority)
+ {
+ return_ACPI_STATUS (AE_AML_ERROR);
+ }
+
+ /*
+ * Check Performance/Robustness preference
+ */
+ OutputStruct->Data.StartDependentFunctions.PerformanceRobustness =
+ (Temp8 >> 2) & 0x03;
+
+ if (3 == OutputStruct->Data.StartDependentFunctions.PerformanceRobustness)
+ {
+ return_ACPI_STATUS (AE_AML_ERROR);
+ }
+ }
+
+ else
+ {
+ OutputStruct->Data.StartDependentFunctions.CompatibilityPriority =
+ ACCEPTABLE_CONFIGURATION;
+
+ OutputStruct->Data.StartDependentFunctions.PerformanceRobustness =
+ ACCEPTABLE_CONFIGURATION;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsEndDependentFunctionsResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes consumed from
+ * the ByteStreamBuffer
+ * OutputBuffer - Pointer to the user's return buffer
+ * StructureSize - UINT32 pointer that is filled with
+ * the number of bytes in the filled
+ * in structure
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsEndDependentFunctionsResource (
+ UINT8 *ByteStreamBuffer,
+ UINT32 *BytesConsumed,
+ UINT8 **OutputBuffer,
+ UINT32 *StructureSize)
+{
+ RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
+ UINT32 StructSize = RESOURCE_LENGTH;
+
+
+ FUNCTION_TRACE ("RsEndDependentFunctionsResource");
+
+ /*
+ * The number of bytes consumed is static
+ */
+ *BytesConsumed = 1;
+
+ /*
+ * Fill out the structure
+ */
+ OutputStruct->Id = EndDependentFunctions;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsStartDependentFunctionsStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsStartDependentFunctionsStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT8 Temp8 = 0;
+
+
+ FUNCTION_TRACE ("RsStartDependentFunctionsStream");
+
+ /*
+ * The descriptor field is set based upon whether a byte is needed
+ * to contain Priority data.
+ */
+ if (ACCEPTABLE_CONFIGURATION ==
+ LinkedList->Data.StartDependentFunctions.CompatibilityPriority &&
+ ACCEPTABLE_CONFIGURATION ==
+ LinkedList->Data.StartDependentFunctions.PerformanceRobustness)
+ {
+ *Buffer = 0x30;
+ }
+ else
+ {
+ *Buffer = 0x31;
+ Buffer += 1;
+
+ /*
+ * Set the Priority Byte Definition
+ */
+ Temp8 = 0;
+ Temp8 = (UINT8)
+ ((LinkedList->Data.StartDependentFunctions.PerformanceRobustness &
+ 0x03) << 2);
+ Temp8 |=
+ (LinkedList->Data.StartDependentFunctions.CompatibilityPriority &
+ 0x03);
+
+ *Buffer = Temp8;
+ }
+
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsEndDependentFunctionsStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsEndDependentFunctionsStream (
+ RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ UINT32 *BytesConsumed
+ )
+{
+ UINT8 *Buffer = *OutputBuffer;
+
+
+ FUNCTION_TRACE ("RsEndDependentFunctionsStream");
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x38;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
+ (NATIVE_UINT) *OutputBuffer);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsutils.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsutils.c
new file mode 100644
index 000000000000..3ec5fa6ecba3
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsutils.c
@@ -0,0 +1,511 @@
+/*******************************************************************************
+ *
+ * Module Name: rsutils - Utilities for the resource manager
+ * $Revision: 12 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#define __RSUTILS_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+#include "acresrc.h"
+
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rsutils")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetPrtMethodData
+ *
+ * PARAMETERS: Handle - a handle to the containing object
+ * RetBuffer - a pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to get the _PRT value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetPrtMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *RetObj;
+ ACPI_STATUS Status;
+ UINT32 BufferSpaceNeeded;
+
+
+ FUNCTION_TRACE ("RsGetPrtMethodData");
+
+
+ /* already validated params, so we won't repeat here */
+
+ BufferSpaceNeeded = RetBuffer->Length;
+
+ /*
+ * Execute the method, no parameters
+ */
+ Status = AcpiNsEvaluateRelative (Handle, "_PRT", NULL, &RetObj);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (!RetObj)
+ {
+ /* Return object is required */
+
+ DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _PRT\n"));
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+
+ /*
+ * The return object will be a package, so check the
+ * parameters. If the return object is not a package,
+ * then the underlying AML code is corrupt or improperly
+ * written.
+ */
+ if (ACPI_TYPE_PACKAGE != RetObj->Common.Type)
+ {
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
+ */
+ Status = AcpiRsCreatePciRoutingTable (RetObj,
+ RetBuffer->Pointer,
+ &BufferSpaceNeeded);
+
+ /*
+ * Tell the user how much of the buffer we have used or is needed
+ * and return the final status.
+ */
+ RetBuffer->Length = BufferSpaceNeeded;
+
+
+ /* On exit, we must delete the object returned by evaluateObject */
+
+Cleanup:
+
+ AcpiCmRemoveReference (RetObj);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetCrsMethodData
+ *
+ * PARAMETERS: Handle - a handle to the containing object
+ * RetBuffer - a pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to get the _CRS value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetCrsMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *RetObj;
+ ACPI_STATUS Status;
+ UINT32 BufferSpaceNeeded = RetBuffer->Length;
+
+
+ FUNCTION_TRACE ("RsGetCrsMethodData");
+
+
+ /* already validated params, so we won't repeat here */
+
+ /*
+ * Execute the method, no parameters
+ */
+ Status = AcpiNsEvaluateRelative (Handle, "_CRS", NULL, &RetObj);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (!RetObj)
+ {
+ /* Return object is required */
+
+ DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _CRS\n"));
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ /*
+ * The return object will be a buffer, but check the
+ * parameters. If the return object is not a buffer,
+ * then the underlying AML code is corrupt or improperly
+ * written.
+ */
+ if (ACPI_TYPE_BUFFER != RetObj->Common.Type)
+ {
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
+ */
+ Status = AcpiRsCreateResourceList (RetObj,
+ RetBuffer->Pointer,
+ &BufferSpaceNeeded);
+
+
+ if (ACPI_SUCCESS (Status))
+ {
+ DUMP_RESOURCE_LIST(RetBuffer->Pointer);
+ }
+
+ /*
+ * Tell the user how much of the buffer we have used or is needed
+ * and return the final status.
+ */
+ RetBuffer->Length = BufferSpaceNeeded;
+
+
+ /* On exit, we must delete the object returned by evaluateObject */
+
+Cleanup:
+
+ AcpiCmRemoveReference (RetObj);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetPrsMethodData
+ *
+ * PARAMETERS: Handle - a handle to the containing object
+ * RetBuffer - a pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to get the _PRS value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetPrsMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *RetObj;
+ ACPI_STATUS Status;
+ UINT32 BufferSpaceNeeded = RetBuffer->Length;
+
+
+ FUNCTION_TRACE ("RsGetPrsMethodData");
+
+
+ /* already validated params, so we won't repeat here */
+
+ /*
+ * Execute the method, no parameters
+ */
+ Status = AcpiNsEvaluateRelative (Handle, "_PRS", NULL, &RetObj);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (!RetObj)
+ {
+ /* Return object is required */
+
+ DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _PRS\n"));
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ /*
+ * The return object will be a buffer, but check the
+ * parameters. If the return object is not a buffer,
+ * then the underlying AML code is corrupt or improperly
+ * written..
+ */
+ if (ACPI_TYPE_BUFFER != RetObj->Common.Type)
+ {
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
+ */
+ Status = AcpiRsCreateResourceList (RetObj,
+ RetBuffer->Pointer,
+ &BufferSpaceNeeded);
+
+ /*
+ * Tell the user how much of the buffer we have used or is needed
+ * and return the final status.
+ */
+ RetBuffer->Length = BufferSpaceNeeded;
+
+
+ /* On exit, we must delete the object returned by evaluateObject */
+
+Cleanup:
+
+ AcpiCmRemoveReference (RetObj);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsSetSrsMethodData
+ *
+ * PARAMETERS: Handle - a handle to the containing object
+ * InBuffer - a pointer to a buffer structure of the
+ * parameter
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to set the _SRS of an object contained
+ * in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsSetSrsMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *InBuffer)
+{
+ ACPI_OPERAND_OBJECT *Params[2];
+ ACPI_OPERAND_OBJECT ParamObj;
+ ACPI_STATUS Status;
+ UINT8 *ByteStream = NULL;
+ UINT32 BufferSizeNeeded = 0;
+
+
+ FUNCTION_TRACE ("RsSetSrsMethodData");
+
+
+ /* already validated params, so we won't repeat here */
+
+ /*
+ * The InBuffer parameter will point to a linked list of
+ * resource parameters. It needs to be formatted into a
+ * byte stream to be sent in as an input parameter.
+ */
+ BufferSizeNeeded = 0;
+
+ /*
+ * First call is to get the buffer size needed
+ */
+ Status = AcpiRsCreateByteStream (InBuffer->Pointer,
+ ByteStream,
+ &BufferSizeNeeded);
+ /*
+ * We expect a return of AE_BUFFER_OVERFLOW
+ * if not, exit with the error
+ */
+ if (AE_BUFFER_OVERFLOW != Status)
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Allocate the buffer needed
+ */
+ ByteStream = AcpiCmCallocate(BufferSizeNeeded);
+ if (NULL == ByteStream)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Now call to convert the linked list into a byte stream
+ */
+ Status = AcpiRsCreateByteStream (InBuffer->Pointer,
+ ByteStream,
+ &BufferSizeNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ /*
+ * Init the param object
+ */
+ AcpiCmInitStaticObject (&ParamObj);
+
+ /*
+ * Method requires one parameter. Set it up
+ */
+ Params [0] = &ParamObj;
+ Params [1] = NULL;
+
+ /*
+ * Set up the parameter object
+ */
+ ParamObj.Common.Type = ACPI_TYPE_BUFFER;
+ ParamObj.Buffer.Length = BufferSizeNeeded;
+ ParamObj.Buffer.Pointer = ByteStream;
+
+ /*
+ * Execute the method, no return value
+ */
+ Status = AcpiNsEvaluateRelative (Handle, "_SRS", Params, NULL);
+
+ /*
+ * Clean up and return the status from AcpiNsEvaluateRelative
+ */
+
+Cleanup:
+
+ AcpiCmFree (ByteStream);
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Resources/rsxface.c b/sys/contrib/dev/acpica/Subsystem/Resources/rsxface.c
new file mode 100644
index 000000000000..c3dc221e8174
--- /dev/null
+++ b/sys/contrib/dev/acpica/Subsystem/Resources/rsxface.c
@@ -0,0 +1,326 @@
+/*******************************************************************************
+ *
+ * Module Name: rsxface - Public interfaces to the ACPI subsystem
+ * $Revision: 8 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
+ * reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+#define __RSXFACE_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+#include "acresrc.h"
+
+#define _COMPONENT RESOURCE_MANAGER
+ MODULE_NAME ("rsxface")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetIrqRoutingTable
+ *
+ * PARAMETERS: DeviceHandle - a handle to the Bus device we are querying
+ * RetBuffer - a pointer to a buffer to receive the
+ * current resources for the device
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to get the IRQ routing table for a
+ * specific bus. The caller must first acquire a handle for the
+ * desired bus. The routine table is placed in the buffer pointed
+ * to by the RetBuffer variable parameter.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of RetBuffer is undefined.
+ *
+ * This function attempts to execute the _PRT method contained in
+ * the object indicated by the passed DeviceHandle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetIrqRoutingTable (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AcpiGetIrqRoutingTable ");
+
+ /*
+ * Must have a valid handle and buffer, So we have to have a handle
+ * and a return buffer structure, and if there is a non-zero buffer length
+ * we also need a valid pointer in the buffer. If it's a zero buffer length,
+ * we'll be returning the needed buffer size, so keep going.
+ */
+ if ((!DeviceHandle) ||
+ (!RetBuffer) ||
+ ((!RetBuffer->Pointer) && (RetBuffer->Length)))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiRsGetPrtMethodData (DeviceHandle, RetBuffer);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetCurrentResources
+ *
+ * PARAMETERS: DeviceHandle - a handle to the device object for the
+ * device we are querying
+ * RetBuffer - a pointer to a buffer to receive the
+ * current resources for the device
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to get the current resources for a
+ * specific device. The caller must first acquire a handle for
+ * the desired device. The resource data is placed in the buffer
+ * pointed to by the RetBuffer variable parameter.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of RetBuffer is undefined.
+ *
+ * This function attempts to execute the _CRS method contained in
+ * the object indicated by the passed DeviceHandle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetCurrentResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AcpiGetCurrentResources");
+
+ /*
+ * Must have a valid handle and buffer, So we have to have a handle
+ * and a return buffer structure, and if there is a non-zero buffer length
+ * we also need a valid pointer in the buffer. If it's a zero buffer length,
+ * we'll be returning the needed buffer size, so keep going.
+ */
+ if ((!DeviceHandle) ||
+ (!RetBuffer) ||
+ ((RetBuffer->Length) && (!RetBuffer->Pointer)))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiRsGetCrsMethodData (DeviceHandle, RetBuffer);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetPossibleResources
+ *
+ * PARAMETERS: DeviceHandle - a handle to the device object for the
+ * device we are querying
+ * RetBuffer - a pointer to a buffer to receive the
+ * resources for the device
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to get a list of the possible resources
+ * for a specific device. The caller must first acquire a handle
+ * for the desired device. The resource data is placed in the
+ * buffer pointed to by the RetBuffer variable.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of RetBuffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetPossibleResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AcpiGetPossibleResources");
+
+ /*
+ * Must have a valid handle and buffer, So we have to have a handle
+ * and a return buffer structure, and if there is a non-zero buffer length
+ * we also need a valid pointer in the buffer. If it's a zero buffer length,
+ * we'll be returning the needed buffer size, so keep going.
+ */
+ if ((!DeviceHandle) ||
+ (!RetBuffer) ||
+ ((RetBuffer->Length) && (!RetBuffer->Pointer)))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiRsGetPrsMethodData (DeviceHandle, RetBuffer);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiSetCurrentResources
+ *
+ * PARAMETERS: DeviceHandle - a handle to the device object for the
+ * device we are changing the resources of
+ * InBuffer - a pointer to a buffer containing the
+ * resources to be set for the device
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to set the current resources for a
+ * specific device. The caller must first acquire a handle for
+ * the desired device. The resource data is passed to the routine
+ * the buffer pointed to by the InBuffer variable.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetCurrentResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *InBuffer)
+{
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE ("AcpiSetCurrentResources");
+
+ /*
+ * Must have a valid handle and buffer
+ */
+ if ((!DeviceHandle) ||
+ (!InBuffer) ||
+ (!InBuffer->Pointer) ||
+ (!InBuffer->Length))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiRsSetSrsMethodData (DeviceHandle, InBuffer);
+
+ return_ACPI_STATUS (Status);
+}