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 (struct acpi_resource_mem24
);
87 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
;
101 * Check Byte 3 the Read/Write bit
105 output_struct
->data
.memory24
.read_write_attribute
= temp8
& 0x01;
108 * Get min_base_address (Bytes 4-5)
110 ACPI_MOVE_16_TO_16 (&temp16
, buffer
);
112 output_struct
->data
.memory24
.min_base_address
= temp16
;
115 * Get max_base_address (Bytes 6-7)
117 ACPI_MOVE_16_TO_16 (&temp16
, buffer
);
119 output_struct
->data
.memory24
.max_base_address
= temp16
;
122 * Get Alignment (Bytes 8-9)
124 ACPI_MOVE_16_TO_16 (&temp16
, buffer
);
126 output_struct
->data
.memory24
.alignment
= temp16
;
129 * Get range_length (Bytes 10-11)
131 ACPI_MOVE_16_TO_16 (&temp16
, buffer
);
132 output_struct
->data
.memory24
.range_length
= temp16
;
135 * Set the Length parameter
137 output_struct
->length
= (u32
) struct_size
;
140 * Return the final size of the structure
142 *structure_size
= struct_size
;
143 return_ACPI_STATUS (AE_OK
);
147 /*******************************************************************************
149 * FUNCTION: acpi_rs_memory24_stream
151 * PARAMETERS: linked_list - Pointer to the resource linked list
152 * output_buffer - Pointer to the user's return buffer
153 * bytes_consumed - Pointer to where the number of bytes
154 * used in the output_buffer is returned
158 * DESCRIPTION: Take the linked list resource structure and fills in the
159 * the appropriate bytes in a byte stream
161 ******************************************************************************/
164 acpi_rs_memory24_stream (
165 struct acpi_resource
*linked_list
,
167 acpi_size
*bytes_consumed
)
169 u8
*buffer
= *output_buffer
;
174 ACPI_FUNCTION_TRACE ("rs_memory24_stream");
178 * The descriptor field is static
184 * The length field is static
187 ACPI_MOVE_16_TO_16 (buffer
, &temp16
);
191 * Set the Information Byte
193 temp8
= (u8
) (linked_list
->data
.memory24
.read_write_attribute
& 0x01);
198 * Set the Range minimum base address
200 ACPI_MOVE_32_TO_16 (buffer
, &linked_list
->data
.memory24
.min_base_address
);
204 * Set the Range maximum base address
206 ACPI_MOVE_32_TO_16 (buffer
, &linked_list
->data
.memory24
.max_base_address
);
210 * Set the base alignment
212 ACPI_MOVE_32_TO_16 (buffer
, &linked_list
->data
.memory24
.alignment
);
216 * Set the range length
218 ACPI_MOVE_32_TO_16 (buffer
, &linked_list
->data
.memory24
.range_length
);
222 * Return the number of bytes consumed in this operation
224 *bytes_consumed
= ACPI_PTR_DIFF (buffer
, *output_buffer
);
225 return_ACPI_STATUS (AE_OK
);
229 /*******************************************************************************
231 * FUNCTION: acpi_rs_memory32_range_resource
233 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
235 * bytes_consumed - Pointer to where the number of bytes
236 * consumed the byte_stream_buffer is
238 * output_buffer - Pointer to the return data buffer
239 * structure_size - Pointer to where the number of bytes
240 * in the return data struct is returned
244 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
245 * structure pointed to by the output_buffer. Return the
246 * number of bytes consumed from the byte stream.
248 ******************************************************************************/
251 acpi_rs_memory32_range_resource (
252 u8
*byte_stream_buffer
,
253 acpi_size
*bytes_consumed
,
255 acpi_size
*structure_size
)
257 u8
*buffer
= byte_stream_buffer
;
258 struct acpi_resource
*output_struct
= (void *) *output_buffer
;
261 acpi_size struct_size
= ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32
);
264 ACPI_FUNCTION_TRACE ("rs_memory32_range_resource");
268 * Point past the Descriptor to get the number of bytes consumed
272 ACPI_MOVE_16_TO_16 (&temp16
, buffer
);
274 *bytes_consumed
= (acpi_size
) temp16
+ 3;
276 output_struct
->id
= ACPI_RSTYPE_MEM32
;
279 * Point to the place in the output buffer where the data portion will
281 * 1. Set the RESOURCE_DATA * Data to point to its own address, then
282 * 2. Set the pointer to the next address.
284 * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds
285 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
289 * Check Byte 3 the Read/Write bit
294 output_struct
->data
.memory32
.read_write_attribute
= temp8
& 0x01;
297 * Get min_base_address (Bytes 4-7)
299 ACPI_MOVE_32_TO_32 (&output_struct
->data
.memory32
.min_base_address
, buffer
);
303 * Get max_base_address (Bytes 8-11)
305 ACPI_MOVE_32_TO_32 (&output_struct
->data
.memory32
.max_base_address
, buffer
);
309 * Get Alignment (Bytes 12-15)
311 ACPI_MOVE_32_TO_32 (&output_struct
->data
.memory32
.alignment
, buffer
);
315 * Get range_length (Bytes 16-19)
317 ACPI_MOVE_32_TO_32 (&output_struct
->data
.memory32
.range_length
, buffer
);
320 * Set the Length parameter
322 output_struct
->length
= (u32
) struct_size
;
325 * Return the final size of the structure
327 *structure_size
= struct_size
;
328 return_ACPI_STATUS (AE_OK
);
332 /*******************************************************************************
334 * FUNCTION: acpi_rs_fixed_memory32_resource
336 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
338 * bytes_consumed - Pointer to where the number of bytes
339 * consumed the byte_stream_buffer is
341 * output_buffer - Pointer to the return data buffer
342 * structure_size - Pointer to where the number of bytes
343 * in the return data struct is returned
347 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
348 * structure pointed to by the output_buffer. Return the
349 * number of bytes consumed from the byte stream.
351 ******************************************************************************/
354 acpi_rs_fixed_memory32_resource (
355 u8
*byte_stream_buffer
,
356 acpi_size
*bytes_consumed
,
358 acpi_size
*structure_size
)
360 u8
*buffer
= byte_stream_buffer
;
361 struct acpi_resource
*output_struct
= (void *) *output_buffer
;
364 acpi_size struct_size
= ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_mem32
);
367 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource");
371 * Point past the Descriptor to get the number of bytes consumed
374 ACPI_MOVE_16_TO_16 (&temp16
, buffer
);
377 *bytes_consumed
= (acpi_size
) temp16
+ 3;
379 output_struct
->id
= ACPI_RSTYPE_FIXED_MEM32
;
382 * Check Byte 3 the Read/Write bit
386 output_struct
->data
.fixed_memory32
.read_write_attribute
= temp8
& 0x01;
389 * Get range_base_address (Bytes 4-7)
391 ACPI_MOVE_32_TO_32 (&output_struct
->data
.fixed_memory32
.range_base_address
, buffer
);
395 * Get range_length (Bytes 8-11)
397 ACPI_MOVE_32_TO_32 (&output_struct
->data
.fixed_memory32
.range_length
, buffer
);
400 * Set the Length parameter
402 output_struct
->length
= (u32
) struct_size
;
405 * Return the final size of the structure
407 *structure_size
= struct_size
;
408 return_ACPI_STATUS (AE_OK
);
412 /*******************************************************************************
414 * FUNCTION: acpi_rs_memory32_range_stream
416 * PARAMETERS: linked_list - Pointer to the resource linked list
417 * output_buffer - Pointer to the user's return buffer
418 * bytes_consumed - Pointer to where the number of bytes
419 * used in the output_buffer is returned
423 * DESCRIPTION: Take the linked list resource structure and fills in the
424 * the appropriate bytes in a byte stream
426 ******************************************************************************/
429 acpi_rs_memory32_range_stream (
430 struct acpi_resource
*linked_list
,
432 acpi_size
*bytes_consumed
)
434 u8
*buffer
= *output_buffer
;
439 ACPI_FUNCTION_TRACE ("rs_memory32_range_stream");
443 * The descriptor field is static
449 * The length field is static
453 ACPI_MOVE_16_TO_16 (buffer
, &temp16
);
457 * Set the Information Byte
459 temp8
= (u8
) (linked_list
->data
.memory32
.read_write_attribute
& 0x01);
464 * Set the Range minimum base address
466 ACPI_MOVE_32_TO_32 (buffer
, &linked_list
->data
.memory32
.min_base_address
);
470 * Set the Range maximum base address
472 ACPI_MOVE_32_TO_32 (buffer
, &linked_list
->data
.memory32
.max_base_address
);
476 * Set the base alignment
478 ACPI_MOVE_32_TO_32 (buffer
, &linked_list
->data
.memory32
.alignment
);
482 * Set the range length
484 ACPI_MOVE_32_TO_32 (buffer
, &linked_list
->data
.memory32
.range_length
);
488 * Return the number of bytes consumed in this operation
490 *bytes_consumed
= ACPI_PTR_DIFF (buffer
, *output_buffer
);
491 return_ACPI_STATUS (AE_OK
);
495 /*******************************************************************************
497 * FUNCTION: acpi_rs_fixed_memory32_stream
499 * PARAMETERS: linked_list - Pointer to the resource linked list
500 * output_buffer - Pointer to the user's return buffer
501 * bytes_consumed - Pointer to where the number of bytes
502 * used in the output_buffer is returned
506 * DESCRIPTION: Take the linked list resource structure and fills in the
507 * the appropriate bytes in a byte stream
509 ******************************************************************************/
512 acpi_rs_fixed_memory32_stream (
513 struct acpi_resource
*linked_list
,
515 acpi_size
*bytes_consumed
)
517 u8
*buffer
= *output_buffer
;
522 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream");
526 * The descriptor field is static
532 * The length field is static
536 ACPI_MOVE_16_TO_16 (buffer
, &temp16
);
540 * Set the Information Byte
542 temp8
= (u8
) (linked_list
->data
.fixed_memory32
.read_write_attribute
& 0x01);
547 * Set the Range base address
549 ACPI_MOVE_32_TO_32 (buffer
,
550 &linked_list
->data
.fixed_memory32
.range_base_address
);
554 * Set the range length
556 ACPI_MOVE_32_TO_32 (buffer
,
557 &linked_list
->data
.fixed_memory32
.range_length
);
561 * Return the number of bytes consumed in this operation
563 *bytes_consumed
= ACPI_PTR_DIFF (buffer
, *output_buffer
);
564 return_ACPI_STATUS (AE_OK
);