1 /*******************************************************************************
3 * Module Name: rsmem24 - Acpi_rs_memory24_resource
4 * Acpi_rs_memory24_stream
5 * Acpi_rs_memory32_range_resource
6 * Acpi_rs_fixed_memory32_resource
7 * Acpi_rs_memory32_range_stream
8 * Acpi_rs_fixed_memory32_stream
11 ******************************************************************************/
14 * Copyright (C) 2000, 2001 R. Byron Moore
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #define _COMPONENT ACPI_RESOURCES
36 MODULE_NAME ("rsmemory")
39 /*******************************************************************************
41 * FUNCTION: Acpi_rs_memory24_resource
43 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
45 * Bytes_consumed - u32 pointer that is filled with
46 * the number of bytes consumed from
47 * the Byte_stream_buffer
48 * Output_buffer - Pointer to the user's return buffer
49 * Structure_size - u32 pointer that is filled with
50 * the number of bytes in the filled
53 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
55 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
56 * structure pointed to by the Output_buffer. Return the
57 * number of bytes consumed from the byte stream.
59 ******************************************************************************/
62 acpi_rs_memory24_resource (
63 u8 *byte_stream_buffer,
68 u8 *buffer = byte_stream_buffer;
69 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
72 u32 struct_size = sizeof (MEMORY24_RESOURCE) +
73 RESOURCE_LENGTH_NO_DATA;
77 * Point past the Descriptor to get the number of bytes consumed
81 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
83 *bytes_consumed = temp16 + 3;
84 output_struct->id = memory24;
87 * Check Byte 3 the Read/Write bit
91 output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
94 * Get Min_base_address (Bytes 4-5)
96 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
98 output_struct->data.memory24.min_base_address = temp16;
101 * Get Max_base_address (Bytes 6-7)
103 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
105 output_struct->data.memory24.max_base_address = temp16;
108 * Get Alignment (Bytes 8-9)
110 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
112 output_struct->data.memory24.alignment = temp16;
115 * Get Range_length (Bytes 10-11)
117 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
118 output_struct->data.memory24.range_length = temp16;
121 * Set the Length parameter
123 output_struct->length = struct_size;
126 * Return the final size of the structure
128 *structure_size = struct_size;
134 /*******************************************************************************
136 * FUNCTION: Acpi_rs_memory24_stream
138 * PARAMETERS: Linked_list - Pointer to the resource linked list
139 * Output_buffer - Pointer to the user's return buffer
140 * Bytes_consumed - u32 pointer that is filled with
141 * the number of bytes of the
144 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
146 * DESCRIPTION: Take the linked list resource structure and fills in the
147 * the appropriate bytes in a byte stream
149 ******************************************************************************/
152 acpi_rs_memory24_stream (
153 RESOURCE *linked_list,
157 u8 *buffer = *output_buffer;
163 * The descriptor field is static
169 * The length field is static
172 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
176 * Set the Information Byte
178 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01);
183 * Set the Range minimum base address
185 MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
189 * Set the Range maximum base address
191 MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
195 * Set the base alignment
197 MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.alignment);
201 * Set the range length
203 MOVE_UNALIGNED16_TO_16 (buffer, &linked_list->data.memory24.range_length);
207 * Return the number of bytes consumed in this operation
209 *bytes_consumed = (u32) ((NATIVE_UINT) buffer -
210 (NATIVE_UINT) *output_buffer);
216 /*******************************************************************************
218 * FUNCTION: Acpi_rs_memory32_range_resource
220 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
222 * Bytes_consumed - u32 pointer that is filled with
223 * the number of bytes consumed from
224 * the Byte_stream_buffer
225 * Output_buffer - Pointer to the user's return buffer
226 * Structure_size - u32 pointer that is filled with
227 * the number of bytes in the filled
230 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
232 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
233 * structure pointed to by the Output_buffer. Return the
234 * number of bytes consumed from the byte stream.
236 ******************************************************************************/
239 acpi_rs_memory32_range_resource (
240 u8 *byte_stream_buffer,
245 u8 *buffer = byte_stream_buffer;
246 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
249 u32 struct_size = sizeof (MEMORY32_RESOURCE) +
250 RESOURCE_LENGTH_NO_DATA;
254 * Point past the Descriptor to get the number of bytes consumed
258 MOVE_UNALIGNED16_TO_16 (&temp16, buffer);
260 *bytes_consumed = temp16 + 3;
262 output_struct->id = memory32;
265 * Point to the place in the output buffer where the data portion will
267 * 1. Set the RESOURCE_DATA * Data to point to it's own address, then
268 * 2. Set the pointer to the next address.
270 * NOTE: Output_struct->Data is cast to u8, otherwise, this addition adds
271 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
275 * Check Byte 3 the Read/Write bit
280 output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
283 * Get Min_base_address (Bytes 4-7)
285 MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.min_base_address,
290 * Get Max_base_address (Bytes 8-11)
292 MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.max_base_address,
297 * Get Alignment (Bytes 12-15)
299 MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.alignment, buffer);
303 * Get Range_length (Bytes 16-19)
305 MOVE_UNALIGNED32_TO_32 (&output_struct->data.memory32.range_length, buffer);
308 * Set the Length parameter
310 output_struct->length = struct_size;
313 * Return the final size of the structure
315 *structure_size = struct_size;
321 /*******************************************************************************
323 * FUNCTION: Acpi_rs_fixed_memory32_resource
325 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
327 * Bytes_consumed - u32 pointer that is filled with
328 * the number of bytes consumed from
329 * the Byte_stream_buffer
330 * Output_buffer - Pointer to the user's return buffer
331 * Structure_size - u32 pointer that is filled with
332 * the number of bytes in the filled
335 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
337 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
338 * structure pointed to by the Output_buffer. Return the
339 * number of bytes consumed from the byte stream.
341 ******************************************************************************/
344 acpi_rs_fixed_memory32_resource (
345 u8 *byte_stream_buffer,
350 u8 *buffer = byte_stream_buffer;
351 RESOURCE *output_struct = (RESOURCE *) * output_buffer;
354 u32 struct_size = sizeof (FIXED_MEMORY32_RESOURCE) +
355 RESOURCE_LENGTH_NO_DATA;
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 = fixed_memory32;
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;
403 /*******************************************************************************
405 * FUNCTION: Acpi_rs_memory32_range_stream
407 * PARAMETERS: Linked_list - Pointer to the resource linked list
408 * Output_buffer - Pointer to the user's return buffer
409 * Bytes_consumed - u32 pointer that is filled with
410 * the number of bytes of the
413 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
415 * DESCRIPTION: Take the linked list resource structure and fills in the
416 * the appropriate bytes in a byte stream
418 ******************************************************************************/
421 acpi_rs_memory32_range_stream (
422 RESOURCE *linked_list,
426 u8 *buffer = *output_buffer;
432 * The descriptor field is static
438 * The length field is static
442 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
446 * Set the Information Byte
448 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
453 * Set the Range minimum base address
455 MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
459 * Set the Range maximum base address
461 MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
465 * Set the base alignment
467 MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.alignment);
471 * Set the range length
473 MOVE_UNALIGNED32_TO_32 (buffer, &linked_list->data.memory32.range_length);
477 * Return the number of bytes consumed in this operation
479 *bytes_consumed = (u32) ((NATIVE_UINT) buffer -
480 (NATIVE_UINT) *output_buffer);
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
496 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
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 RESOURCE *linked_list,
509 u8 *buffer = *output_buffer;
515 * The descriptor field is static
521 * The length field is static
525 MOVE_UNALIGNED16_TO_16 (buffer, &temp16);
529 * Set the Information Byte
531 temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
536 * Set the Range base address
538 MOVE_UNALIGNED32_TO_32 (buffer,
539 &linked_list->data.fixed_memory32.range_base_address);
543 * Set the range length
545 MOVE_UNALIGNED32_TO_32 (buffer,
546 &linked_list->data.fixed_memory32.range_length);
550 * Return the number of bytes consumed in this operation
552 *bytes_consumed = (u32) ((NATIVE_UINT) buffer -
553 (NATIVE_UINT) *output_buffer);