1 /*******************************************************************************
3 * Module Name: rsio - IO and DMA resource descriptors
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
116 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/rsio.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $ */
123 #define _COMPONENT ACPI_RESOURCES
124 ACPI_MODULE_NAME ("rsio")
127 /*******************************************************************************
129 * FUNCTION: AcpiRsIoResource
131 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
133 * BytesConsumed - Pointer to where the number of bytes
134 * consumed the ByteStreamBuffer is
136 * OutputBuffer - Pointer to the return data buffer
137 * StructureSize - Pointer to where the number of bytes
138 * in the return data struct is returned
142 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
143 * structure pointed to by the OutputBuffer. Return the
144 * number of bytes consumed from the byte stream.
146 ******************************************************************************/
150 UINT8 *ByteStreamBuffer,
151 ACPI_SIZE *BytesConsumed,
152 UINT8 **OutputBuffer,
153 ACPI_SIZE *StructureSize)
155 UINT8 *Buffer = ByteStreamBuffer;
156 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
159 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IO);
162 ACPI_FUNCTION_TRACE ("RsIoResource");
166 * The number of bytes consumed are Constant
170 OutputStruct->Id = ACPI_RSTYPE_IO;
178 OutputStruct->Data.Io.IoDecode = Temp8 & 0x01;
181 * Check MinBase Address
184 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
186 OutputStruct->Data.Io.MinBaseAddress = Temp16;
189 * Check MaxBase Address
192 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
194 OutputStruct->Data.Io.MaxBaseAddress = Temp16;
197 * Check Base alignment
202 OutputStruct->Data.Io.Alignment = Temp8;
210 OutputStruct->Data.Io.RangeLength = Temp8;
213 * Set the Length parameter
215 OutputStruct->Length = (UINT32) StructSize;
218 * Return the final size of the structure
220 *StructureSize = StructSize;
221 return_ACPI_STATUS (AE_OK);
225 /*******************************************************************************
227 * FUNCTION: AcpiRsFixedIoResource
229 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
231 * BytesConsumed - Pointer to where the number of bytes
232 * consumed the ByteStreamBuffer is
234 * OutputBuffer - Pointer to the return data buffer
235 * StructureSize - Pointer to where the number of bytes
236 * in the return data struct is returned
240 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
241 * structure pointed to by the OutputBuffer. Return the
242 * number of bytes consumed from the byte stream.
244 ******************************************************************************/
247 AcpiRsFixedIoResource (
248 UINT8 *ByteStreamBuffer,
249 ACPI_SIZE *BytesConsumed,
250 UINT8 **OutputBuffer,
251 ACPI_SIZE *StructureSize)
253 UINT8 *Buffer = ByteStreamBuffer;
254 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
257 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_IO);
260 ACPI_FUNCTION_TRACE ("RsFixedIoResource");
264 * The number of bytes consumed are Constant
268 OutputStruct->Id = ACPI_RSTYPE_FIXED_IO;
271 * Check Range Base Address
274 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
276 OutputStruct->Data.FixedIo.BaseAddress = Temp16;
284 OutputStruct->Data.FixedIo.RangeLength = Temp8;
287 * Set the Length parameter
289 OutputStruct->Length = (UINT32) StructSize;
292 * Return the final size of the structure
294 *StructureSize = StructSize;
295 return_ACPI_STATUS (AE_OK);
299 /*******************************************************************************
301 * FUNCTION: AcpiRsIoStream
303 * PARAMETERS: LinkedList - Pointer to the resource linked list
304 * OutputBuffer - Pointer to the user's return buffer
305 * BytesConsumed - Pointer to where the number of bytes
306 * used in the OutputBuffer is returned
310 * DESCRIPTION: Take the linked list resource structure and fills in the
311 * the appropriate bytes in a byte stream
313 ******************************************************************************/
317 ACPI_RESOURCE *LinkedList,
318 UINT8 **OutputBuffer,
319 ACPI_SIZE *BytesConsumed)
321 UINT8 *Buffer = *OutputBuffer;
326 ACPI_FUNCTION_TRACE ("RsIoStream");
330 * The descriptor field is static
336 * Io Information Byte
338 Temp8 = (UINT8) (LinkedList->Data.Io.IoDecode & 0x01);
344 * Set the Range minimum base address
346 Temp16 = (UINT16) LinkedList->Data.Io.MinBaseAddress;
348 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
352 * Set the Range maximum base address
354 Temp16 = (UINT16) LinkedList->Data.Io.MaxBaseAddress;
356 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
360 * Set the base alignment
362 Temp8 = (UINT8) LinkedList->Data.Io.Alignment;
368 * Set the range length
370 Temp8 = (UINT8) LinkedList->Data.Io.RangeLength;
376 * Return the number of bytes consumed in this operation
378 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
379 return_ACPI_STATUS (AE_OK);
383 /*******************************************************************************
385 * FUNCTION: AcpiRsFixedIoStream
387 * PARAMETERS: LinkedList - Pointer to the resource linked list
388 * OutputBuffer - Pointer to the user's return buffer
389 * BytesConsumed - Pointer to where the number of bytes
390 * used in the OutputBuffer is returned
394 * DESCRIPTION: Take the linked list resource structure and fills in the
395 * the appropriate bytes in a byte stream
397 ******************************************************************************/
400 AcpiRsFixedIoStream (
401 ACPI_RESOURCE *LinkedList,
402 UINT8 **OutputBuffer,
403 ACPI_SIZE *BytesConsumed)
405 UINT8 *Buffer = *OutputBuffer;
410 ACPI_FUNCTION_TRACE ("RsFixedIoStream");
414 * The descriptor field is static
421 * Set the Range base address
423 Temp16 = (UINT16) LinkedList->Data.FixedIo.BaseAddress;
425 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
429 * Set the range length
431 Temp8 = (UINT8) LinkedList->Data.FixedIo.RangeLength;
437 * Return the number of bytes consumed in this operation
439 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
440 return_ACPI_STATUS (AE_OK);
444 /*******************************************************************************
446 * FUNCTION: AcpiRsDmaResource
448 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
450 * BytesConsumed - Pointer to where the number of bytes
451 * consumed the ByteStreamBuffer is
453 * OutputBuffer - Pointer to the return data buffer
454 * StructureSize - Pointer to where the number of bytes
455 * in the return data struct is returned
459 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
460 * structure pointed to by the OutputBuffer. Return the
461 * number of bytes consumed from the byte stream.
463 ******************************************************************************/
467 UINT8 *ByteStreamBuffer,
468 ACPI_SIZE *BytesConsumed,
469 UINT8 **OutputBuffer,
470 ACPI_SIZE *StructureSize)
472 UINT8 *Buffer = ByteStreamBuffer;
473 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
477 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_DMA);
480 ACPI_FUNCTION_TRACE ("RsDmaResource");
484 * The number of bytes consumed are Constant
487 OutputStruct->Id = ACPI_RSTYPE_DMA;
490 * Point to the 8-bits of Byte 1
495 /* Decode the DMA channel bits */
497 for (i = 0, Index = 0; Index < 8; Index++)
499 if ((Temp8 >> Index) & 0x01)
501 OutputStruct->Data.Dma.Channels[i] = Index;
506 /* Zero DMA channels is valid */
508 OutputStruct->Data.Dma.NumberOfChannels = i;
512 * Calculate the structure size based upon the number of interrupts
514 StructSize += ((ACPI_SIZE) i - 1) * 4;
524 * Check for transfer preference (Bits[1:0])
526 OutputStruct->Data.Dma.Transfer = Temp8 & 0x03;
528 if (0x03 == OutputStruct->Data.Dma.Transfer)
530 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid DMA.Transfer preference (3)\n"));
531 return_ACPI_STATUS (AE_BAD_DATA);
535 * Get bus master preference (Bit[2])
537 OutputStruct->Data.Dma.BusMaster = (Temp8 >> 2) & 0x01;
540 * Get channel speed support (Bits[6:5])
542 OutputStruct->Data.Dma.Type = (Temp8 >> 5) & 0x03;
545 * Set the Length parameter
547 OutputStruct->Length = (UINT32) StructSize;
550 * Return the final size of the structure
552 *StructureSize = StructSize;
553 return_ACPI_STATUS (AE_OK);
557 /*******************************************************************************
559 * FUNCTION: AcpiRsDmaStream
561 * PARAMETERS: LinkedList - Pointer to the resource linked list
562 * OutputBuffer - Pointer to the user's return buffer
563 * BytesConsumed - Pointer to where the number of bytes
564 * used in the OutputBuffer is returned
568 * DESCRIPTION: Take the linked list resource structure and fills in the
569 * the appropriate bytes in a byte stream
571 ******************************************************************************/
575 ACPI_RESOURCE *LinkedList,
576 UINT8 **OutputBuffer,
577 ACPI_SIZE *BytesConsumed)
579 UINT8 *Buffer = *OutputBuffer;
585 ACPI_FUNCTION_TRACE ("RsDmaStream");
589 * The descriptor field is static
596 * Loop through all of the Channels and set the mask bits
599 Index < LinkedList->Data.Dma.NumberOfChannels;
602 Temp16 = (UINT16) LinkedList->Data.Dma.Channels[Index];
603 Temp8 |= 0x1 << Temp16;
612 Temp8 = (UINT8) ((LinkedList->Data.Dma.Type & 0x03) << 5);
613 Temp8 |= ((LinkedList->Data.Dma.BusMaster & 0x01) << 2);
614 Temp8 |= (LinkedList->Data.Dma.Transfer & 0x03);
620 * Return the number of bytes consumed in this operation
622 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
623 return_ACPI_STATUS (AE_OK);