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
34 #define _COMPONENT ACPI_RESOURCES
35 MODULE_NAME ("rsmemory")
38 /*******************************************************************************
40 * FUNCTION: Acpi_rs_memory24_resource
42 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
44 * Bytes_consumed - u32 pointer that is filled with
45 * the number of bytes consumed from
46 * the Byte_stream_buffer
47 * Output_buffer - Pointer to the user's return buffer
48 * Structure_size - u32 pointer that is filled with
49 * the number of bytes in the filled
52 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
54 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
55 * structure pointed to by the Output_buffer. Return the
56 * number of bytes consumed from the byte stream.
58 ******************************************************************************/
61 acpi_rs_memory24_resource (
62 u8
*byte_stream_buffer
,
67 u8
*buffer
= byte_stream_buffer
;
68 RESOURCE
*output_struct
= (RESOURCE
*) * output_buffer
;
71 u32 struct_size
= sizeof (MEMORY24_RESOURCE
) +
72 RESOURCE_LENGTH_NO_DATA
;
76 * Point past the Descriptor to get the number of bytes consumed
80 MOVE_UNALIGNED16_TO_16 (&temp16
, buffer
);
82 *bytes_consumed
= temp16
+ 3;
83 output_struct
->id
= memory24
;
86 * Check Byte 3 the Read/Write bit
90 output_struct
->data
.memory24
.read_write_attribute
= temp8
& 0x01;
93 * Get Min_base_address (Bytes 4-5)
95 MOVE_UNALIGNED16_TO_16 (&temp16
, buffer
);
97 output_struct
->data
.memory24
.min_base_address
= temp16
;
100 * Get Max_base_address (Bytes 6-7)
102 MOVE_UNALIGNED16_TO_16 (&temp16
, buffer
);
104 output_struct
->data
.memory24
.max_base_address
= temp16
;
107 * Get Alignment (Bytes 8-9)
109 MOVE_UNALIGNED16_TO_16 (&temp16
, buffer
);
111 output_struct
->data
.memory24
.alignment
= temp16
;
114 * Get Range_length (Bytes 10-11)
116 MOVE_UNALIGNED16_TO_16 (&temp16
, buffer
);
117 output_struct
->data
.memory24
.range_length
= temp16
;
120 * Set the Length parameter
122 output_struct
->length
= struct_size
;
125 * Return the final size of the structure
127 *structure_size
= struct_size
;
133 /*******************************************************************************
135 * FUNCTION: Acpi_rs_memory24_stream
137 * PARAMETERS: Linked_list - Pointer to the resource linked list
138 * Output_buffer - Pointer to the user's return buffer
139 * Bytes_consumed - u32 pointer that is filled with
140 * the number of bytes of the
143 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
145 * DESCRIPTION: Take the linked list resource structure and fills in the
146 * the appropriate bytes in a byte stream
148 ******************************************************************************/
151 acpi_rs_memory24_stream (
152 RESOURCE
*linked_list
,
156 u8
*buffer
= *output_buffer
;
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
= (u32
) ((NATIVE_UINT
) buffer
-
209 (NATIVE_UINT
) *output_buffer
);
215 /*******************************************************************************
217 * FUNCTION: Acpi_rs_memory32_range_resource
219 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
221 * Bytes_consumed - u32 pointer that is filled with
222 * the number of bytes consumed from
223 * the Byte_stream_buffer
224 * Output_buffer - Pointer to the user's return buffer
225 * Structure_size - u32 pointer that is filled with
226 * the number of bytes in the filled
229 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
231 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
232 * structure pointed to by the Output_buffer. Return the
233 * number of bytes consumed from the byte stream.
235 ******************************************************************************/
238 acpi_rs_memory32_range_resource (
239 u8
*byte_stream_buffer
,
244 u8
*buffer
= byte_stream_buffer
;
245 RESOURCE
*output_struct
= (RESOURCE
*) * output_buffer
;
248 u32 struct_size
= sizeof (MEMORY32_RESOURCE
) +
249 RESOURCE_LENGTH_NO_DATA
;
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
= memory32
;
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
;
320 /*******************************************************************************
322 * FUNCTION: Acpi_rs_fixed_memory32_resource
324 * PARAMETERS: Byte_stream_buffer - Pointer to the resource input byte
326 * Bytes_consumed - u32 pointer that is filled with
327 * the number of bytes consumed from
328 * the Byte_stream_buffer
329 * Output_buffer - Pointer to the user's return buffer
330 * Structure_size - u32 pointer that is filled with
331 * the number of bytes in the filled
334 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
336 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
337 * structure pointed to by the Output_buffer. Return the
338 * number of bytes consumed from the byte stream.
340 ******************************************************************************/
343 acpi_rs_fixed_memory32_resource (
344 u8
*byte_stream_buffer
,
349 u8
*buffer
= byte_stream_buffer
;
350 RESOURCE
*output_struct
= (RESOURCE
*) * output_buffer
;
353 u32 struct_size
= sizeof (FIXED_MEMORY32_RESOURCE
) +
354 RESOURCE_LENGTH_NO_DATA
;
358 * Point past the Descriptor to get the number of bytes consumed
361 MOVE_UNALIGNED16_TO_16 (&temp16
, buffer
);
364 *bytes_consumed
= temp16
+ 3;
366 output_struct
->id
= fixed_memory32
;
369 * Check Byte 3 the Read/Write bit
373 output_struct
->data
.fixed_memory32
.read_write_attribute
= temp8
& 0x01;
376 * Get Range_base_address (Bytes 4-7)
378 MOVE_UNALIGNED32_TO_32 (&output_struct
->data
.fixed_memory32
.range_base_address
,
383 * Get Range_length (Bytes 8-11)
385 MOVE_UNALIGNED32_TO_32 (&output_struct
->data
.fixed_memory32
.range_length
,
389 * Set the Length parameter
391 output_struct
->length
= struct_size
;
394 * Return the final size of the structure
396 *structure_size
= struct_size
;
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
412 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
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 RESOURCE
*linked_list
,
425 u8
*buffer
= *output_buffer
;
431 * The descriptor field is static
437 * The length field is static
441 MOVE_UNALIGNED16_TO_16 (buffer
, &temp16
);
445 * Set the Information Byte
447 temp8
= (u8
) (linked_list
->data
.memory32
.read_write_attribute
& 0x01);
452 * Set the Range minimum base address
454 MOVE_UNALIGNED32_TO_32 (buffer
, &linked_list
->data
.memory32
.min_base_address
);
458 * Set the Range maximum base address
460 MOVE_UNALIGNED32_TO_32 (buffer
, &linked_list
->data
.memory32
.max_base_address
);
464 * Set the base alignment
466 MOVE_UNALIGNED32_TO_32 (buffer
, &linked_list
->data
.memory32
.alignment
);
470 * Set the range length
472 MOVE_UNALIGNED32_TO_32 (buffer
, &linked_list
->data
.memory32
.range_length
);
476 * Return the number of bytes consumed in this operation
478 *bytes_consumed
= (u32
) ((NATIVE_UINT
) buffer
-
479 (NATIVE_UINT
) *output_buffer
);
485 /*******************************************************************************
487 * FUNCTION: Acpi_rs_fixed_memory32_stream
489 * PARAMETERS: Linked_list - Pointer to the resource linked list
490 * Output_buffer - Pointer to the user's return buffer
491 * Bytes_consumed - u32 pointer that is filled with
492 * the number of bytes of the
495 * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code
497 * DESCRIPTION: Take the linked list resource structure and fills in the
498 * the appropriate bytes in a byte stream
500 ******************************************************************************/
503 acpi_rs_fixed_memory32_stream (
504 RESOURCE
*linked_list
,
508 u8
*buffer
= *output_buffer
;
514 * The descriptor field is static
520 * The length field is static
524 MOVE_UNALIGNED16_TO_16 (buffer
, &temp16
);
528 * Set the Information Byte
530 temp8
= (u8
) (linked_list
->data
.fixed_memory32
.read_write_attribute
& 0x01);
535 * Set the Range base address
537 MOVE_UNALIGNED32_TO_32 (buffer
,
538 &linked_list
->data
.fixed_memory32
.range_base_address
);
542 * Set the range length
544 MOVE_UNALIGNED32_TO_32 (buffer
,
545 &linked_list
->data
.fixed_memory32
.range_length
);
549 * Return the number of bytes consumed in this operation
551 *bytes_consumed
= (u32
) ((NATIVE_UINT
) buffer
-
552 (NATIVE_UINT
) *output_buffer
);