1 /*******************************************************************************
3 * Module Name: rsio - AcpiRsIoResource
4 * AcpiRsFixedIoResource
11 ******************************************************************************/
13 /******************************************************************************
17 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
18 * All rights reserved.
22 * 2.1. This is your license from Intel Corp. under its intellectual property
23 * rights. You may have additional license terms from the party that provided
24 * you this software, covering your right to use that party's intellectual
27 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
28 * copy of the source code appearing in this file ("Covered Code") an
29 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
30 * base code distributed originally by Intel ("Original Intel Code") to copy,
31 * make derivatives, distribute, use and display any portion of the Covered
32 * Code in any form, with the right to sublicense such rights; and
34 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
35 * license (with the right to sublicense), under only those claims of Intel
36 * patents that are infringed by the Original Intel Code, to make, use, sell,
37 * offer to sell, and import the Covered Code and derivative works thereof
38 * solely to the minimum extent necessary to exercise the above copyright
39 * license, and in no event shall the patent license extend to any additions
40 * to or modifications of the Original Intel Code. No other license or right
41 * is granted directly or by implication, estoppel or otherwise;
43 * The above copyright and patent license is granted only if the following
48 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
49 * Redistribution of source code of any substantial portion of the Covered
50 * Code or modification with rights to further distribute source must include
51 * the above Copyright Notice, the above License, this list of Conditions,
52 * and the following Disclaimer and Export Compliance provision. In addition,
53 * Licensee must cause all Covered Code to which Licensee contributes to
54 * contain a file documenting the changes Licensee made to create that Covered
55 * Code and the date of any change. Licensee must include in that file the
56 * documentation of any changes made by any predecessor Licensee. Licensee
57 * must include a prominent statement that the modification is derived,
58 * directly or indirectly, from Original Intel Code.
60 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
61 * Redistribution of source code of any substantial portion of the Covered
62 * Code or modification without rights to further distribute source must
63 * include the following Disclaimer and Export Compliance provision in the
64 * documentation and/or other materials provided with distribution. In
65 * addition, Licensee may not authorize further sublicense of source of any
66 * portion of the Covered Code, and must include terms to the effect that the
67 * license from Licensee to its licensee is limited to the intellectual
68 * property embodied in the software Licensee provides to its licensee, and
69 * not to intellectual property embodied in modifications its licensee may
72 * 3.3. Redistribution of Executable. Redistribution in executable form of any
73 * substantial portion of the Covered Code or modification must reproduce the
74 * above Copyright Notice, and the following Disclaimer and Export Compliance
75 * provision in the documentation and/or other materials provided with the
78 * 3.4. Intel retains all right, title, and interest in and to the Original
81 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
82 * Intel shall be used in advertising or otherwise to promote the sale, use or
83 * other dealings in products derived from or relating to the Covered Code
84 * without prior written authorization from Intel.
86 * 4. Disclaimer and Export Compliance
88 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
89 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
90 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
91 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
92 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
93 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
96 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
97 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
98 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
99 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
100 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
101 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
102 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
105 * 4.3. Licensee shall not export, either directly or indirectly, any of this
106 * software or system incorporating such software without first obtaining any
107 * required license or other approval from the U. S. Department of Commerce or
108 * any other agency or department of the United States Government. In the
109 * event Licensee exports any such software from the United States or
110 * re-exports any such software from a foreign destination, Licensee shall
111 * ensure that the distribution and export/re-export of the software is in
112 * compliance with all laws, regulations, orders, or other restrictions of the
113 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
114 * any of its subsidiaries will export/re-export any technical data, process,
115 * software, or service, directly or indirectly, to any country for which the
116 * United States government or any agency thereof requires an export license,
117 * other governmental approval, or letter of assurance, without first obtaining
118 * such license, approval or letter.
120 *****************************************************************************/
127 #define _COMPONENT RESOURCE_MANAGER
131 /*******************************************************************************
133 * FUNCTION: AcpiRsIoResource
135 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
137 * BytesConsumed - UINT32 pointer that is filled with
138 * the number of bytes consumed from
139 * the ByteStreamBuffer
140 * OutputBuffer - Pointer to the user's return buffer
141 * StructureSize - UINT32 pointer that is filled with
142 * the number of bytes in the filled
145 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
147 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
148 * structure pointed to by the OutputBuffer. Return the
149 * number of bytes consumed from the byte stream.
151 ******************************************************************************/
155 UINT8 *ByteStreamBuffer,
156 UINT32 *BytesConsumed,
157 UINT8 **OutputBuffer,
158 UINT32 *StructureSize)
160 UINT8 *Buffer = ByteStreamBuffer;
161 RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
164 UINT32 StructSize = sizeof (IO_RESOURCE) +
165 RESOURCE_LENGTH_NO_DATA;
168 FUNCTION_TRACE ("RsIoResource");
171 * The number of bytes consumed are Constant
175 OutputStruct->Id = Io;
183 OutputStruct->Data.Io.IoDecode = Temp8 & 0x01;
186 * Check MinBase Address
189 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
191 OutputStruct->Data.Io.MinBaseAddress = Temp16;
194 * Check MaxBase Address
197 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
199 OutputStruct->Data.Io.MaxBaseAddress = Temp16;
202 * Check Base alignment
207 OutputStruct->Data.Io.Alignment = Temp8;
215 OutputStruct->Data.Io.RangeLength = Temp8;
218 * Set the Length parameter
220 OutputStruct->Length = StructSize;
223 * Return the final size of the structure
225 *StructureSize = StructSize;
227 return_ACPI_STATUS (AE_OK);
231 /*******************************************************************************
233 * FUNCTION: AcpiRsFixedIoResource
235 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
237 * BytesConsumed - UINT32 pointer that is filled with
238 * the number of bytes consumed from
239 * the ByteStreamBuffer
240 * OutputBuffer - Pointer to the user's return buffer
241 * StructureSize - UINT32 pointer that is filled with
242 * the number of bytes in the filled
245 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
247 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
248 * structure pointed to by the OutputBuffer. Return the
249 * number of bytes consumed from the byte stream.
251 ******************************************************************************/
254 AcpiRsFixedIoResource (
255 UINT8 *ByteStreamBuffer,
256 UINT32 *BytesConsumed,
257 UINT8 **OutputBuffer,
258 UINT32 *StructureSize)
260 UINT8 *Buffer = ByteStreamBuffer;
261 RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
264 UINT32 StructSize = sizeof (FIXED_IO_RESOURCE) +
265 RESOURCE_LENGTH_NO_DATA;
268 FUNCTION_TRACE ("RsFixedIoResource");
271 * The number of bytes consumed are Constant
275 OutputStruct->Id = FixedIo;
278 * Check Range Base Address
281 MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
283 OutputStruct->Data.FixedIo.BaseAddress = Temp16;
291 OutputStruct->Data.FixedIo.RangeLength = Temp8;
294 * Set the Length parameter
296 OutputStruct->Length = StructSize;
299 * Return the final size of the structure
301 *StructureSize = StructSize;
303 return_ACPI_STATUS (AE_OK);
307 /*******************************************************************************
309 * FUNCTION: AcpiRsIoStream
311 * PARAMETERS: LinkedList - Pointer to the resource linked list
312 * OutputBuffer - Pointer to the user's return buffer
313 * BytesConsumed - UINT32 pointer that is filled with
314 * the number of bytes of the
317 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
319 * DESCRIPTION: Take the linked list resource structure and fills in the
320 * the appropriate bytes in a byte stream
322 ******************************************************************************/
326 RESOURCE *LinkedList,
327 UINT8 **OutputBuffer,
328 UINT32 *BytesConsumed)
330 UINT8 *Buffer = *OutputBuffer;
335 FUNCTION_TRACE ("RsIoStream");
338 * The descriptor field is static
344 * Io Information Byte
346 Temp8 = (UINT8) (LinkedList->Data.Io.IoDecode & 0x01);
352 * Set the Range minimum base address
354 Temp16 = (UINT16) LinkedList->Data.Io.MinBaseAddress;
356 MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
360 * Set the Range maximum base address
362 Temp16 = (UINT16) LinkedList->Data.Io.MaxBaseAddress;
364 MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
368 * Set the base alignment
370 Temp8 = (UINT8) LinkedList->Data.Io.Alignment;
376 * Set the range length
378 Temp8 = (UINT8) LinkedList->Data.Io.RangeLength;
384 * Return the number of bytes consumed in this operation
386 *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
387 (NATIVE_UINT) *OutputBuffer);
389 return_ACPI_STATUS (AE_OK);
393 /*******************************************************************************
395 * FUNCTION: AcpiRsFixedIoStream
397 * PARAMETERS: LinkedList - Pointer to the resource linked list
398 * OutputBuffer - Pointer to the user's return buffer
399 * BytesConsumed - UINT32 pointer that is filled with
400 * the number of bytes of the
403 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
405 * DESCRIPTION: Take the linked list resource structure and fills in the
406 * the appropriate bytes in a byte stream
408 ******************************************************************************/
411 AcpiRsFixedIoStream (
412 RESOURCE *LinkedList,
413 UINT8 **OutputBuffer,
414 UINT32 *BytesConsumed)
416 UINT8 *Buffer = *OutputBuffer;
421 FUNCTION_TRACE ("RsFixedIoStream");
424 * The descriptor field is static
431 * Set the Range base address
433 Temp16 = (UINT16) LinkedList->Data.FixedIo.BaseAddress;
435 MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
439 * Set the range length
441 Temp8 = (UINT8) LinkedList->Data.FixedIo.RangeLength;
447 * Return the number of bytes consumed in this operation
449 *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
450 (NATIVE_UINT) *OutputBuffer);
452 return_ACPI_STATUS (AE_OK);
456 /*******************************************************************************
458 * FUNCTION: AcpiRsDmaResource
460 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
462 * BytesConsumed - UINT32 pointer that is filled with
463 * the number of bytes consumed from
464 * the ByteStreamBuffer
465 * OutputBuffer - Pointer to the user's return buffer
466 * StructureSize - UINT32 pointer that is filled with
467 * the number of bytes in the filled
470 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
472 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
473 * structure pointed to by the OutputBuffer. Return the
474 * number of bytes consumed from the byte stream.
476 ******************************************************************************/
480 UINT8 *ByteStreamBuffer,
481 UINT32 *BytesConsumed,
482 UINT8 **OutputBuffer,
483 UINT32 *StructureSize)
485 UINT8 *Buffer = ByteStreamBuffer;
486 RESOURCE *OutputStruct = (RESOURCE *) * OutputBuffer;
490 UINT32 StructSize = sizeof(DMA_RESOURCE) +
491 RESOURCE_LENGTH_NO_DATA;
494 FUNCTION_TRACE ("RsDmaResource");
497 * The number of bytes consumed are Constant
500 OutputStruct->Id = Dma;
503 * Point to the 8-bits of Byte 1
508 /* Decode the IRQ bits */
510 for (i = 0, Index = 0; Index < 8; Index++)
512 if ((Temp8 >> Index) & 0x01)
514 OutputStruct->Data.Dma.Channels[i] = Index;
518 OutputStruct->Data.Dma.NumberOfChannels = i;
522 * Calculate the structure size based upon the number of interrupts
524 StructSize += (OutputStruct->Data.Dma.NumberOfChannels - 1) * 4;
533 * Check for transfer preference (Bits[1:0])
535 OutputStruct->Data.Dma.Transfer = Temp8 & 0x03;
537 if (0x03 == OutputStruct->Data.Dma.Transfer)
539 return_ACPI_STATUS (AE_BAD_DATA);
543 * Get bus master preference (Bit[2])
545 OutputStruct->Data.Dma.BusMaster = (Temp8 >> 2) & 0x01;
548 * Get channel speed support (Bits[6:5])
550 OutputStruct->Data.Dma.Type = (Temp8 >> 5) & 0x03;
553 * Set the Length parameter
555 OutputStruct->Length = StructSize;
558 * Return the final size of the structure
560 *StructureSize = StructSize;
562 return_ACPI_STATUS (AE_OK);
566 /*******************************************************************************
568 * FUNCTION: AcpiRsDmaStream
570 * PARAMETERS: LinkedList - Pointer to the resource linked list
571 * OutputBuffer - Pointer to the user's return buffer
572 * BytesConsumed - UINT32 pointer that is filled with
573 * the number of bytes of the
576 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
578 * DESCRIPTION: Take the linked list resource structure and fills in the
579 * the appropriate bytes in a byte stream
581 ******************************************************************************/
585 RESOURCE *LinkedList,
586 UINT8 **OutputBuffer,
587 UINT32 *BytesConsumed)
589 UINT8 *Buffer = *OutputBuffer;
595 FUNCTION_TRACE ("RsDmaStream");
599 * The descriptor field is static
606 * Loop through all of the Channels and set the mask bits
609 Index < LinkedList->Data.Dma.NumberOfChannels;
612 Temp16 = (UINT16) LinkedList->Data.Dma.Channels[Index];
613 Temp8 |= 0x1 << Temp16;
622 Temp8 = (UINT8) ((LinkedList->Data.Dma.Type & 0x03) << 5);
623 Temp8 |= ((LinkedList->Data.Dma.BusMaster & 0x01) << 2);
624 Temp8 |= (LinkedList->Data.Dma.Transfer & 0x03);
630 * Return the number of bytes consumed in this operation
632 *BytesConsumed = (UINT32) ((NATIVE_UINT) Buffer -
633 (NATIVE_UINT) *OutputBuffer);
635 return_ACPI_STATUS (AE_OK);