1 /*******************************************************************************
3 * Module Name: rsmem24 - Memory resource descriptors
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2005, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include <acpi/acpi.h>
46 #include <acpi/acresrc.h>
48 #define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsmemory")
52 /*******************************************************************************
54 * FUNCTION: acpi_rs_memory24_resource
56 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
58 * bytes_consumed - Pointer to where the number of bytes
59 * consumed the byte_stream_buffer is
61 * output_buffer - Pointer to the return data buffer
62 * structure_size - Pointer to where the number of bytes
63 * in the return data struct is returned
67 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
68 * structure pointed to by the output_buffer. Return the
69 * number of bytes consumed from the byte stream.
71 ******************************************************************************/
74 acpi_rs_memory24_resource (
75 u8 *byte_stream_buffer,
76 acpi_size *bytes_consumed,
78 acpi_size *structure_size)
80 u8 *buffer = byte_stream_buffer;
81 struct acpi_resource *output_struct = (void *) *output_buffer;
84 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
85 struct acpi_resource_mem24);
88 ACPI_FUNCTION_TRACE ("rs_memory24_resource");
91 /* Point past the Descriptor to get the number of bytes consumed */
95 ACPI_MOVE_16_TO_16 (&temp16, buffer);
97 *bytes_consumed = (acpi_size) temp16 + 3;
98 output_struct->id = ACPI_RSTYPE_MEM24;
100 /* Check Byte 3 the Read/Write bit */
104 output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
106 /* Get min_base_address (Bytes 4-5) */
108 ACPI_MOVE_16_TO_16 (&temp16, buffer);
110 output_struct->data.memory24.min_base_address = temp16;
112 /* Get max_base_address (Bytes 6-7) */
114 ACPI_MOVE_16_TO_16 (&temp16, buffer);
116 output_struct->data.memory24.max_base_address = temp16;
118 /* Get Alignment (Bytes 8-9) */
120 ACPI_MOVE_16_TO_16 (&temp16, buffer);
122 output_struct->data.memory24.alignment = temp16;
124 /* Get range_length (Bytes 10-11) */
126 ACPI_MOVE_16_TO_16 (&temp16, buffer);
127 output_struct->data.memory24.range_length = temp16;
129 /* Set the Length parameter */
131 output_struct->length = (u32) struct_size;
133 /* Return the final size of the structure */
135 *structure_size = struct_size;
136 return_ACPI_STATUS (AE_OK);
140 /*******************************************************************************
142 * FUNCTION: acpi_rs_memory24_stream
144 * PARAMETERS: linked_list - Pointer to the resource linked list
145 * output_buffer - Pointer to the user's return buffer
146 * bytes_consumed - Pointer to where the number of bytes
147 * used in the output_buffer is returned
151 * DESCRIPTION: Take the linked list resource structure and fills in the
152 * the appropriate bytes in a byte stream
154 ******************************************************************************/
157 acpi_rs_memory24_stream (
158 struct acpi_resource *linked_list,
160 acpi_size *bytes_consumed)
162 u8 *buffer = *output_buffer;
167 ACPI_FUNCTION_TRACE ("rs_memory24_stream");
170 /* The descriptor field is static */
175 /* The length field is static */
178 ACPI_MOVE_16_TO_16 (buffer, &temp16);
181 /* Set the Information Byte */
183 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01);
187 /* Set the Range minimum base address */
189 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
192 /* Set the Range maximum base address */
194 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
197 /* Set the base alignment */
199 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment);
202 /* Set the range length */
204 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length);
207 /* Return the number of bytes consumed in this operation */
209 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
210 return_ACPI_STATUS (AE_OK);
214 /*******************************************************************************
216 * FUNCTION: acpi_rs_memory32_range_resource
218 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
220 * bytes_consumed - Pointer to where the number of bytes
221 * consumed the byte_stream_buffer is
223 * output_buffer - Pointer to the return data buffer
224 * structure_size - Pointer to where the number of bytes
225 * in the return data struct is returned
229 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
230 * structure pointed to by the output_buffer. Return the
231 * number of bytes consumed from the byte stream.
233 ******************************************************************************/
236 acpi_rs_memory32_range_resource (
237 u8 *byte_stream_buffer,
238 acpi_size *bytes_consumed,
240 acpi_size *structure_size)
242 u8 *buffer = byte_stream_buffer;
243 struct acpi_resource *output_struct = (void *) *output_buffer;
246 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
247 struct acpi_resource_mem32);
250 ACPI_FUNCTION_TRACE ("rs_memory32_range_resource");
253 /* Point past the Descriptor to get the number of bytes consumed */
257 ACPI_MOVE_16_TO_16 (&temp16, buffer);
259 *bytes_consumed = (acpi_size) temp16 + 3;
261 output_struct->id = ACPI_RSTYPE_MEM32;
264 * Point to the place in the output buffer where the data portion will
266 * 1. Set the RESOURCE_DATA * Data to point to its own address, then
267 * 2. Set the pointer to the next address.
269 * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds
270 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
273 /* Check Byte 3 the Read/Write bit */
278 output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
280 /* Get min_base_address (Bytes 4-7) */
282 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer);
285 /* Get max_base_address (Bytes 8-11) */
287 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer);
290 /* Get Alignment (Bytes 12-15) */
292 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer);
295 /* Get range_length (Bytes 16-19) */
297 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer);
299 /* Set the Length parameter */
301 output_struct->length = (u32) struct_size;
303 /* Return the final size of the structure */
305 *structure_size = struct_size;
306 return_ACPI_STATUS (AE_OK);
310 /*******************************************************************************
312 * FUNCTION: acpi_rs_fixed_memory32_resource
314 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
316 * bytes_consumed - Pointer to where the number of bytes
317 * consumed the byte_stream_buffer is
319 * output_buffer - Pointer to the return data buffer
320 * structure_size - Pointer to where the number of bytes
321 * in the return data struct is returned
325 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
326 * structure pointed to by the output_buffer. Return the
327 * number of bytes consumed from the byte stream.
329 ******************************************************************************/
332 acpi_rs_fixed_memory32_resource (
333 u8 *byte_stream_buffer,
334 acpi_size *bytes_consumed,
336 acpi_size *structure_size)
338 u8 *buffer = byte_stream_buffer;
339 struct acpi_resource *output_struct = (void *) *output_buffer;
342 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
343 struct acpi_resource_fixed_mem32);
346 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource");
349 /* Point past the Descriptor to get the number of bytes consumed */
352 ACPI_MOVE_16_TO_16 (&temp16, buffer);
355 *bytes_consumed = (acpi_size) temp16 + 3;
357 output_struct->id = ACPI_RSTYPE_FIXED_MEM32;
359 /* Check Byte 3 the Read/Write bit */
363 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
365 /* Get range_base_address (Bytes 4-7) */
367 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address,
371 /* Get range_length (Bytes 8-11) */
373 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer);
375 /* Set the Length parameter */
377 output_struct->length = (u32) struct_size;
379 /* Return the final size of the structure */
381 *structure_size = struct_size;
382 return_ACPI_STATUS (AE_OK);
386 /*******************************************************************************
388 * FUNCTION: acpi_rs_memory32_range_stream
390 * PARAMETERS: linked_list - Pointer to the resource linked list
391 * output_buffer - Pointer to the user's return buffer
392 * bytes_consumed - Pointer to where the number of bytes
393 * used in the output_buffer is returned
397 * DESCRIPTION: Take the linked list resource structure and fills in the
398 * the appropriate bytes in a byte stream
400 ******************************************************************************/
403 acpi_rs_memory32_range_stream (
404 struct acpi_resource *linked_list,
406 acpi_size *bytes_consumed)
408 u8 *buffer = *output_buffer;
413 ACPI_FUNCTION_TRACE ("rs_memory32_range_stream");
416 /* The descriptor field is static */
421 /* The length field is static */
425 ACPI_MOVE_16_TO_16 (buffer, &temp16);
428 /* Set the Information Byte */
430 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
434 /* Set the Range minimum base address */
436 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
439 /* Set the Range maximum base address */
441 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
444 /* Set the base alignment */
446 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment);
449 /* Set the range length */
451 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length);
454 /* Return the number of bytes consumed in this operation */
456 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
457 return_ACPI_STATUS (AE_OK);
461 /*******************************************************************************
463 * FUNCTION: acpi_rs_fixed_memory32_stream
465 * PARAMETERS: linked_list - Pointer to the resource linked list
466 * output_buffer - Pointer to the user's return buffer
467 * bytes_consumed - Pointer to where the number of bytes
468 * used in the output_buffer is returned
472 * DESCRIPTION: Take the linked list resource structure and fills in the
473 * the appropriate bytes in a byte stream
475 ******************************************************************************/
478 acpi_rs_fixed_memory32_stream (
479 struct acpi_resource *linked_list,
481 acpi_size *bytes_consumed)
483 u8 *buffer = *output_buffer;
488 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream");
491 /* The descriptor field is static */
496 /* The length field is static */
500 ACPI_MOVE_16_TO_16 (buffer, &temp16);
503 /* Set the Information Byte */
505 temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
509 /* Set the Range base address */
511 ACPI_MOVE_32_TO_32 (buffer,
512 &linked_list->data.fixed_memory32.range_base_address);
515 /* Set the range length */
517 ACPI_MOVE_32_TO_32 (buffer,
518 &linked_list->data.fixed_memory32.range_length);
521 /* Return the number of bytes consumed in this operation */
523 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
524 return_ACPI_STATUS (AE_OK);