1 /*******************************************************************************
3 * Module Name: rsmem24 - Memory resource descriptors
6 ******************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #define _COMPONENT ACPI_RESOURCES
31 MODULE_NAME ("rsmemory")
34 /*******************************************************************************
36 * FUNCTION: Acpi_rs_memory24_resource
38 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
40 * Bytes_consumed - u32 pointer that is filled with
41 * the number of bytes consumed from
42 * the Byte_stream_buffer
43 * Output_buffer - Pointer to the user's return buffer
44 * Structure_size - u32 pointer that is filled with
45 * the number of bytes in the filled
50 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
51 * structure pointed to by the Output_buffer. Return the
52 * number of bytes consumed from the byte stream.
54 ******************************************************************************/
57 acpi_rs_memory24_resource (
58 u8 *byte_stream_buffer,
63 u8 *buffer = byte_stream_buffer;
64 acpi_resource *output_struct = (acpi_resource *) *output_buffer;
67 u32 struct_size = SIZEOF_RESOURCE (acpi_resource_mem24);
70 FUNCTION_TRACE ("Rs_memory24_resource");
74 * Point past the Descriptor to get the number of bytes consumed
78 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
80 *bytes_consumed = temp16 + 3;
81 output_struct->id = ACPI_RSTYPE_MEM24;
84 * Check Byte 3 the Read/Write bit
88 output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
91 * Get Min_base_address (Bytes 4-5)
93 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
95 output_struct->data.memory24.min_base_address = temp16;
98 * Get Max_base_address (Bytes 6-7)
100 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
102 output_struct->data.memory24.max_base_address = temp16;
105 * Get Alignment (Bytes 8-9)
107 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
109 output_struct->data.memory24.alignment = temp16;
112 * Get Range_length (Bytes 10-11)
114 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
115 output_struct->data.memory24.range_length = temp16;
118 * Set the Length parameter
120 output_struct->length = struct_size;
123 * Return the final size of the structure
125 *structure_size = struct_size;
126 return_ACPI_STATUS (AE_OK);
130 /*******************************************************************************
132 * FUNCTION: Acpi_rs_memory24_stream
134 * PARAMETERS: Linked_list - Pointer to the resource linked list
135 * Output_buffer - Pointer to the user's return buffer
136 * Bytes_consumed - u32 pointer that is filled with
137 * the number of bytes of the
142 * DESCRIPTION: Take the linked list resource structure and fills in the
143 * the appropriate bytes in a byte stream
145 ******************************************************************************/
148 acpi_rs_memory24_stream (
149 acpi_resource *linked_list,
153 u8 *buffer = *output_buffer;
158 FUNCTION_TRACE ("Rs_memory24_stream");
162 * The descriptor field is static
168 * The length field is static
171 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
175 * Set the Information Byte
177 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01);
182 * Set the Range minimum base address
184 MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
188 * Set the Range maximum base address
190 MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
194 * Set the base alignment
196 MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.alignment);
200 * Set the range length
202 MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.range_length);
206 * Return the number of bytes consumed in this operation
208 *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
209 return_ACPI_STATUS (AE_OK);
213 /*******************************************************************************
215 * FUNCTION: Acpi_rs_memory32_range_resource
217 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
219 * Bytes_consumed - u32 pointer that is filled with
220 * the number of bytes consumed from
221 * the Byte_stream_buffer
222 * Output_buffer - Pointer to the user's return buffer
223 * Structure_size - u32 pointer that is filled with
224 * the number of bytes in the filled
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,
242 u8 *buffer = byte_stream_buffer;
243 acpi_resource *output_struct = (acpi_resource *) *output_buffer;
246 u32 struct_size = SIZEOF_RESOURCE (acpi_resource_mem32);
249 FUNCTION_TRACE ("Rs_memory32_range_resource");
253 * Point past the Descriptor to get the number of bytes consumed
257 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
259 *bytes_consumed = 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 it's 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)
274 * Check Byte 3 the Read/Write bit
279 output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
282 * Get Min_base_address (Bytes 4-7)
284 MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.min_base_address,
289 * Get Max_base_address (Bytes 8-11)
291 MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.max_base_address,
296 * Get Alignment (Bytes 12-15)
298 MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.alignment, buffer);
302 * Get Range_length (Bytes 16-19)
304 MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.range_length, buffer);
307 * Set the Length parameter
309 output_struct->length = struct_size;
312 * Return the final size of the structure
314 *structure_size = struct_size;
315 return_ACPI_STATUS (AE_OK);
319 /*******************************************************************************
321 * FUNCTION: Acpi_rs_fixed_memory32_resource
323 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
325 * Bytes_consumed - u32 pointer that is filled with
326 * the number of bytes consumed from
327 * the Byte_stream_buffer
328 * Output_buffer - Pointer to the user's return buffer
329 * Structure_size - u32 pointer that is filled with
330 * the number of bytes in the filled
335 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
336 * structure pointed to by the Output_buffer. Return the
337 * number of bytes consumed from the byte stream.
339 ******************************************************************************/
342 acpi_rs_fixed_memory32_resource (
343 u8 *byte_stream_buffer,
348 u8 *buffer = byte_stream_buffer;
349 acpi_resource *output_struct = (acpi_resource *) *output_buffer;
352 u32 struct_size = SIZEOF_RESOURCE (acpi_resource_fixed_mem32);
355 FUNCTION_TRACE ("Rs_fixed_memory32_resource");
359 * Point past the Descriptor to get the number of bytes consumed
362 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
365 *bytes_consumed = temp16 + 3;
367 output_struct->id = ACPI_RSTYPE_FIXED_MEM32;
370 * Check Byte 3 the Read/Write bit
374 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
377 * Get Range_base_address (Bytes 4-7)
379 MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_base_address,
384 * Get Range_length (Bytes 8-11)
386 MOVE_UNALIGNED32_TO_32 (&output_struct->data.fixed_memory32.range_length,
390 * Set the Length parameter
392 output_struct->length = struct_size;
395 * Return the final size of the structure
397 *structure_size = struct_size;
398 return_ACPI_STATUS (AE_OK);
402 /*******************************************************************************
404 * FUNCTION: Acpi_rs_memory32_range_stream
406 * PARAMETERS: Linked_list - Pointer to the resource linked list
407 * Output_buffer - Pointer to the user's return buffer
408 * Bytes_consumed - u32 pointer that is filled with
409 * the number of bytes of the
414 * DESCRIPTION: Take the linked list resource structure and fills in the
415 * the appropriate bytes in a byte stream
417 ******************************************************************************/
420 acpi_rs_memory32_range_stream (
421 acpi_resource *linked_list,
425 u8 *buffer = *output_buffer;
430 FUNCTION_TRACE ("Rs_memory32_range_stream");
434 * The descriptor field is static
440 * The length field is static
444 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
448 * Set the Information Byte
450 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
455 * Set the Range minimum base address
457 MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
461 * Set the Range maximum base address
463 MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
467 * Set the base alignment
469 MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.alignment);
473 * Set the range length
475 MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.range_length);
479 * Return the number of bytes consumed in this operation
481 *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
482 return_ACPI_STATUS (AE_OK);
486 /*******************************************************************************
488 * FUNCTION: Acpi_rs_fixed_memory32_stream
490 * PARAMETERS: Linked_list - Pointer to the resource linked list
491 * Output_buffer - Pointer to the user's return buffer
492 * Bytes_consumed - u32 pointer that is filled with
493 * the number of bytes of the
498 * DESCRIPTION: Take the linked list resource structure and fills in the
499 * the appropriate bytes in a byte stream
501 ******************************************************************************/
504 acpi_rs_fixed_memory32_stream (
505 acpi_resource *linked_list,
509 u8 *buffer = *output_buffer;
514 FUNCTION_TRACE ("Rs_fixed_memory32_stream");
518 * The descriptor field is static
524 * The length field is static
528 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
532 * Set the Information Byte
534 temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
539 * Set the Range base address
541 MOVE_UNALIGNED32_TO_32 (buffer,
542 &linked_list->data.fixed_memory32.range_base_address);
546 * Set the range length
548 MOVE_UNALIGNED32_TO_32 (buffer,
549 &linked_list->data.fixed_memory32.range_length);
553 * Return the number of bytes consumed in this operation
555 *bytes_consumed = POINTER_DIFF (buffer, *output_buffer);
556 return_ACPI_STATUS (AE_OK);