[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / drivers / acpi / resources / rsmemory.c
blob7c935aecf0752a5dfcb73ad3fd6cdb27393b81fc
1 /*******************************************************************************
3 * Module Name: rsmem24 - Memory resource descriptors
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
30 * NO WARRANTY
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
57 * stream
58 * bytes_consumed - Pointer to where the number of bytes
59 * consumed the byte_stream_buffer is
60 * returned
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
65 * RETURN: Status
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 ******************************************************************************/
73 acpi_status
74 acpi_rs_memory24_resource (
75 u8 *byte_stream_buffer,
76 acpi_size *bytes_consumed,
77 u8 **output_buffer,
78 acpi_size *structure_size)
80 u8 *buffer = byte_stream_buffer;
81 struct acpi_resource *output_struct = (void *) *output_buffer;
82 u16 temp16 = 0;
83 u8 temp8 = 0;
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
93 buffer += 1;
95 ACPI_MOVE_16_TO_16 (&temp16, buffer);
96 buffer += 2;
97 *bytes_consumed = (acpi_size) temp16 + 3;
98 output_struct->id = ACPI_RSTYPE_MEM24;
101 * Check Byte 3 the Read/Write bit
103 temp8 = *buffer;
104 buffer += 1;
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);
111 buffer += 2;
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);
118 buffer += 2;
119 output_struct->data.memory24.max_base_address = temp16;
122 * Get Alignment (Bytes 8-9)
124 ACPI_MOVE_16_TO_16 (&temp16, buffer);
125 buffer += 2;
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
156 * RETURN: Status
158 * DESCRIPTION: Take the linked list resource structure and fills in the
159 * the appropriate bytes in a byte stream
161 ******************************************************************************/
163 acpi_status
164 acpi_rs_memory24_stream (
165 struct acpi_resource *linked_list,
166 u8 **output_buffer,
167 acpi_size *bytes_consumed)
169 u8 *buffer = *output_buffer;
170 u16 temp16 = 0;
171 u8 temp8 = 0;
174 ACPI_FUNCTION_TRACE ("rs_memory24_stream");
178 * The descriptor field is static
180 *buffer = 0x81;
181 buffer += 1;
184 * The length field is static
186 temp16 = 0x09;
187 ACPI_MOVE_16_TO_16 (buffer, &temp16);
188 buffer += 2;
191 * Set the Information Byte
193 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01);
194 *buffer = temp8;
195 buffer += 1;
198 * Set the Range minimum base address
200 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
201 buffer += 2;
204 * Set the Range maximum base address
206 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
207 buffer += 2;
210 * Set the base alignment
212 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment);
213 buffer += 2;
216 * Set the range length
218 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length);
219 buffer += 2;
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
234 * stream
235 * bytes_consumed - Pointer to where the number of bytes
236 * consumed the byte_stream_buffer is
237 * returned
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
242 * RETURN: Status
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 ******************************************************************************/
250 acpi_status
251 acpi_rs_memory32_range_resource (
252 u8 *byte_stream_buffer,
253 acpi_size *bytes_consumed,
254 u8 **output_buffer,
255 acpi_size *structure_size)
257 u8 *buffer = byte_stream_buffer;
258 struct acpi_resource *output_struct = (void *) *output_buffer;
259 u16 temp16 = 0;
260 u8 temp8 = 0;
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
270 buffer += 1;
272 ACPI_MOVE_16_TO_16 (&temp16, buffer);
273 buffer += 2;
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
280 * begin.
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
291 temp8 = *buffer;
292 buffer += 1;
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);
300 buffer += 4;
303 * Get max_base_address (Bytes 8-11)
305 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer);
306 buffer += 4;
309 * Get Alignment (Bytes 12-15)
311 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer);
312 buffer += 4;
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
337 * stream
338 * bytes_consumed - Pointer to where the number of bytes
339 * consumed the byte_stream_buffer is
340 * returned
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
345 * RETURN: Status
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 ******************************************************************************/
353 acpi_status
354 acpi_rs_fixed_memory32_resource (
355 u8 *byte_stream_buffer,
356 acpi_size *bytes_consumed,
357 u8 **output_buffer,
358 acpi_size *structure_size)
360 u8 *buffer = byte_stream_buffer;
361 struct acpi_resource *output_struct = (void *) *output_buffer;
362 u16 temp16 = 0;
363 u8 temp8 = 0;
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
373 buffer += 1;
374 ACPI_MOVE_16_TO_16 (&temp16, buffer);
376 buffer += 2;
377 *bytes_consumed = (acpi_size) temp16 + 3;
379 output_struct->id = ACPI_RSTYPE_FIXED_MEM32;
382 * Check Byte 3 the Read/Write bit
384 temp8 = *buffer;
385 buffer += 1;
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);
392 buffer += 4;
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
421 * RETURN: Status
423 * DESCRIPTION: Take the linked list resource structure and fills in the
424 * the appropriate bytes in a byte stream
426 ******************************************************************************/
428 acpi_status
429 acpi_rs_memory32_range_stream (
430 struct acpi_resource *linked_list,
431 u8 **output_buffer,
432 acpi_size *bytes_consumed)
434 u8 *buffer = *output_buffer;
435 u16 temp16 = 0;
436 u8 temp8 = 0;
439 ACPI_FUNCTION_TRACE ("rs_memory32_range_stream");
443 * The descriptor field is static
445 *buffer = 0x85;
446 buffer += 1;
449 * The length field is static
451 temp16 = 0x11;
453 ACPI_MOVE_16_TO_16 (buffer, &temp16);
454 buffer += 2;
457 * Set the Information Byte
459 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
460 *buffer = temp8;
461 buffer += 1;
464 * Set the Range minimum base address
466 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
467 buffer += 4;
470 * Set the Range maximum base address
472 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
473 buffer += 4;
476 * Set the base alignment
478 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment);
479 buffer += 4;
482 * Set the range length
484 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length);
485 buffer += 4;
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
504 * RETURN: Status
506 * DESCRIPTION: Take the linked list resource structure and fills in the
507 * the appropriate bytes in a byte stream
509 ******************************************************************************/
511 acpi_status
512 acpi_rs_fixed_memory32_stream (
513 struct acpi_resource *linked_list,
514 u8 **output_buffer,
515 acpi_size *bytes_consumed)
517 u8 *buffer = *output_buffer;
518 u16 temp16 = 0;
519 u8 temp8 = 0;
522 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream");
526 * The descriptor field is static
528 *buffer = 0x86;
529 buffer += 1;
532 * The length field is static
534 temp16 = 0x09;
536 ACPI_MOVE_16_TO_16 (buffer, &temp16);
537 buffer += 2;
540 * Set the Information Byte
542 temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
543 *buffer = temp8;
544 buffer += 1;
547 * Set the Range base address
549 ACPI_MOVE_32_TO_32 (buffer,
550 &linked_list->data.fixed_memory32.range_base_address);
551 buffer += 4;
554 * Set the range length
556 ACPI_MOVE_32_TO_32 (buffer,
557 &linked_list->data.fixed_memory32.range_length);
558 buffer += 4;
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);