1 /*******************************************************************************
3 * Module Name: rsmem24 - Memory 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/rsmemory.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $ */
118 #define __RSMEMORY_C__
123 #define _COMPONENT ACPI_RESOURCES
124 ACPI_MODULE_NAME ("rsmemory")
127 /*******************************************************************************
129 * FUNCTION: AcpiRsMemory24Resource
131 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
133 * BytesConsumed - Pointer to where the number of bytes
134 * consumed the ByteStreamBuffer is
136 * OutputBuffer - Pointer to the return data buffer
137 * StructureSize - Pointer to where the number of bytes
138 * in the return data struct is returned
142 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
143 * structure pointed to by the OutputBuffer. Return the
144 * number of bytes consumed from the byte stream.
146 ******************************************************************************/
149 AcpiRsMemory24Resource (
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_MEM24);
162 ACPI_FUNCTION_TRACE ("RsMemory24Resource");
166 * Point past the Descriptor to get the number of bytes consumed
170 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
172 *BytesConsumed = (ACPI_SIZE) Temp16 + 3;
173 OutputStruct->Id = ACPI_RSTYPE_MEM24;
176 * Check Byte 3 the Read/Write bit
180 OutputStruct->Data.Memory24.ReadWriteAttribute = Temp8 & 0x01;
183 * Get MinBaseAddress (Bytes 4-5)
185 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
187 OutputStruct->Data.Memory24.MinBaseAddress = Temp16;
190 * Get MaxBaseAddress (Bytes 6-7)
192 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
194 OutputStruct->Data.Memory24.MaxBaseAddress = Temp16;
197 * Get Alignment (Bytes 8-9)
199 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
201 OutputStruct->Data.Memory24.Alignment = Temp16;
204 * Get RangeLength (Bytes 10-11)
206 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
207 OutputStruct->Data.Memory24.RangeLength = Temp16;
210 * Set the Length parameter
212 OutputStruct->Length = (UINT32) StructSize;
215 * Return the final size of the structure
217 *StructureSize = StructSize;
218 return_ACPI_STATUS (AE_OK);
222 /*******************************************************************************
224 * FUNCTION: AcpiRsMemory24Stream
226 * PARAMETERS: LinkedList - Pointer to the resource linked list
227 * OutputBuffer - Pointer to the user's return buffer
228 * BytesConsumed - Pointer to where the number of bytes
229 * used in the OutputBuffer is returned
233 * DESCRIPTION: Take the linked list resource structure and fills in the
234 * the appropriate bytes in a byte stream
236 ******************************************************************************/
239 AcpiRsMemory24Stream (
240 ACPI_RESOURCE *LinkedList,
241 UINT8 **OutputBuffer,
242 ACPI_SIZE *BytesConsumed)
244 UINT8 *Buffer = *OutputBuffer;
249 ACPI_FUNCTION_TRACE ("RsMemory24Stream");
253 * The descriptor field is static
259 * The length field is static
262 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
266 * Set the Information Byte
268 Temp8 = (UINT8) (LinkedList->Data.Memory24.ReadWriteAttribute & 0x01);
273 * Set the Range minimum base address
275 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MinBaseAddress);
279 * Set the Range maximum base address
281 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MaxBaseAddress);
285 * Set the base alignment
287 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.Alignment);
291 * Set the range length
293 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.RangeLength);
297 * Return the number of bytes consumed in this operation
299 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
300 return_ACPI_STATUS (AE_OK);
304 /*******************************************************************************
306 * FUNCTION: AcpiRsMemory32RangeResource
308 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
310 * BytesConsumed - Pointer to where the number of bytes
311 * consumed the ByteStreamBuffer is
313 * OutputBuffer - Pointer to the return data buffer
314 * StructureSize - Pointer to where the number of bytes
315 * in the return data struct is returned
319 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
320 * structure pointed to by the OutputBuffer. Return the
321 * number of bytes consumed from the byte stream.
323 ******************************************************************************/
326 AcpiRsMemory32RangeResource (
327 UINT8 *ByteStreamBuffer,
328 ACPI_SIZE *BytesConsumed,
329 UINT8 **OutputBuffer,
330 ACPI_SIZE *StructureSize)
332 UINT8 *Buffer = ByteStreamBuffer;
333 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
336 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM32);
339 ACPI_FUNCTION_TRACE ("RsMemory32RangeResource");
343 * Point past the Descriptor to get the number of bytes consumed
347 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
349 *BytesConsumed = (ACPI_SIZE) Temp16 + 3;
351 OutputStruct->Id = ACPI_RSTYPE_MEM32;
354 * Point to the place in the output buffer where the data portion will
356 * 1. Set the RESOURCE_DATA * Data to point to its own address, then
357 * 2. Set the pointer to the next address.
359 * NOTE: OutputStruct->Data is cast to UINT8, otherwise, this addition adds
360 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(UINT8)
364 * Check Byte 3 the Read/Write bit
369 OutputStruct->Data.Memory32.ReadWriteAttribute = Temp8 & 0x01;
372 * Get MinBaseAddress (Bytes 4-7)
374 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MinBaseAddress,
379 * Get MaxBaseAddress (Bytes 8-11)
381 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MaxBaseAddress,
386 * Get Alignment (Bytes 12-15)
388 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.Alignment, Buffer);
392 * Get RangeLength (Bytes 16-19)
394 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.RangeLength, Buffer);
397 * Set the Length parameter
399 OutputStruct->Length = (UINT32) StructSize;
402 * Return the final size of the structure
404 *StructureSize = StructSize;
405 return_ACPI_STATUS (AE_OK);
409 /*******************************************************************************
411 * FUNCTION: AcpiRsFixedMemory32Resource
413 * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
415 * BytesConsumed - Pointer to where the number of bytes
416 * consumed the ByteStreamBuffer is
418 * OutputBuffer - Pointer to the return data buffer
419 * StructureSize - Pointer to where the number of bytes
420 * in the return data struct is returned
424 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
425 * structure pointed to by the OutputBuffer. Return the
426 * number of bytes consumed from the byte stream.
428 ******************************************************************************/
431 AcpiRsFixedMemory32Resource (
432 UINT8 *ByteStreamBuffer,
433 ACPI_SIZE *BytesConsumed,
434 UINT8 **OutputBuffer,
435 ACPI_SIZE *StructureSize)
437 UINT8 *Buffer = ByteStreamBuffer;
438 ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
441 ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_MEM32);
444 ACPI_FUNCTION_TRACE ("RsFixedMemory32Resource");
448 * Point past the Descriptor to get the number of bytes consumed
451 ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
454 *BytesConsumed = (ACPI_SIZE) Temp16 + 3;
456 OutputStruct->Id = ACPI_RSTYPE_FIXED_MEM32;
459 * Check Byte 3 the Read/Write bit
463 OutputStruct->Data.FixedMemory32.ReadWriteAttribute = Temp8 & 0x01;
466 * Get RangeBaseAddress (Bytes 4-7)
468 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeBaseAddress,
473 * Get RangeLength (Bytes 8-11)
475 ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeLength,
479 * Set the Length parameter
481 OutputStruct->Length = (UINT32) StructSize;
484 * Return the final size of the structure
486 *StructureSize = StructSize;
487 return_ACPI_STATUS (AE_OK);
491 /*******************************************************************************
493 * FUNCTION: AcpiRsMemory32RangeStream
495 * PARAMETERS: LinkedList - Pointer to the resource linked list
496 * OutputBuffer - Pointer to the user's return buffer
497 * BytesConsumed - Pointer to where the number of bytes
498 * used in the OutputBuffer is returned
502 * DESCRIPTION: Take the linked list resource structure and fills in the
503 * the appropriate bytes in a byte stream
505 ******************************************************************************/
508 AcpiRsMemory32RangeStream (
509 ACPI_RESOURCE *LinkedList,
510 UINT8 **OutputBuffer,
511 ACPI_SIZE *BytesConsumed)
513 UINT8 *Buffer = *OutputBuffer;
518 ACPI_FUNCTION_TRACE ("RsMemory32RangeStream");
522 * The descriptor field is static
528 * The length field is static
532 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
536 * Set the Information Byte
538 Temp8 = (UINT8) (LinkedList->Data.Memory32.ReadWriteAttribute & 0x01);
543 * Set the Range minimum base address
545 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MinBaseAddress);
549 * Set the Range maximum base address
551 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MaxBaseAddress);
555 * Set the base alignment
557 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.Alignment);
561 * Set the range length
563 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.RangeLength);
567 * Return the number of bytes consumed in this operation
569 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
570 return_ACPI_STATUS (AE_OK);
574 /*******************************************************************************
576 * FUNCTION: AcpiRsFixedMemory32Stream
578 * PARAMETERS: LinkedList - Pointer to the resource linked list
579 * OutputBuffer - Pointer to the user's return buffer
580 * BytesConsumed - Pointer to where the number of bytes
581 * used in the OutputBuffer is returned
585 * DESCRIPTION: Take the linked list resource structure and fills in the
586 * the appropriate bytes in a byte stream
588 ******************************************************************************/
591 AcpiRsFixedMemory32Stream (
592 ACPI_RESOURCE *LinkedList,
593 UINT8 **OutputBuffer,
594 ACPI_SIZE *BytesConsumed)
596 UINT8 *Buffer = *OutputBuffer;
601 ACPI_FUNCTION_TRACE ("RsFixedMemory32Stream");
605 * The descriptor field is static
611 * The length field is static
615 ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
619 * Set the Information Byte
621 Temp8 = (UINT8) (LinkedList->Data.FixedMemory32.ReadWriteAttribute & 0x01);
626 * Set the Range base address
628 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
629 &LinkedList->Data.FixedMemory32.RangeBaseAddress);
633 * Set the range length
635 ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
636 &LinkedList->Data.FixedMemory32.RangeLength);
640 * Return the number of bytes consumed in this operation
642 *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
643 return_ACPI_STATUS (AE_OK);