blob: 91d0207f01ac76dd204fa3f6efe38a1fdb272c86 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: rsmem24 - Memory resource descriptors
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
10 *
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.
25 *
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.
29 *
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.
42 */
43
44
45#include <acpi/acpi.h>
46#include <acpi/acresrc.h>
47
48#define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME ("rsmemory")
50
51
52/*******************************************************************************
53 *
54 * FUNCTION: acpi_rs_memory24_resource
55 *
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
64 *
65 * RETURN: Status
66 *
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.
70 *
71 ******************************************************************************/
72
73acpi_status
74acpi_rs_memory24_resource (
75 u8 *byte_stream_buffer,
76 acpi_size *bytes_consumed,
77 u8 **output_buffer,
78 acpi_size *structure_size)
79{
80 u8 *buffer = byte_stream_buffer;
81 struct acpi_resource *output_struct = (void *) *output_buffer;
82 u16 temp16 = 0;
83 u8 temp8 = 0;
Robert Moore44f6c012005-04-18 22:49:35 -040084 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
85 struct acpi_resource_mem24);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87
88 ACPI_FUNCTION_TRACE ("rs_memory24_resource");
89
90
Robert Moore44f6c012005-04-18 22:49:35 -040091 /* Point past the Descriptor to get the number of bytes consumed */
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 buffer += 1;
94
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;
99
Robert Moore44f6c012005-04-18 22:49:35 -0400100 /* Check Byte 3 the Read/Write bit */
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 temp8 = *buffer;
103 buffer += 1;
104 output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
105
Robert Moore44f6c012005-04-18 22:49:35 -0400106 /* Get min_base_address (Bytes 4-5) */
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 ACPI_MOVE_16_TO_16 (&temp16, buffer);
109 buffer += 2;
110 output_struct->data.memory24.min_base_address = temp16;
111
Robert Moore44f6c012005-04-18 22:49:35 -0400112 /* Get max_base_address (Bytes 6-7) */
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 ACPI_MOVE_16_TO_16 (&temp16, buffer);
115 buffer += 2;
116 output_struct->data.memory24.max_base_address = temp16;
117
Robert Moore44f6c012005-04-18 22:49:35 -0400118 /* Get Alignment (Bytes 8-9) */
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 ACPI_MOVE_16_TO_16 (&temp16, buffer);
121 buffer += 2;
122 output_struct->data.memory24.alignment = temp16;
123
Robert Moore44f6c012005-04-18 22:49:35 -0400124 /* Get range_length (Bytes 10-11) */
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 ACPI_MOVE_16_TO_16 (&temp16, buffer);
127 output_struct->data.memory24.range_length = temp16;
128
Robert Moore44f6c012005-04-18 22:49:35 -0400129 /* Set the Length parameter */
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 output_struct->length = (u32) struct_size;
132
Robert Moore44f6c012005-04-18 22:49:35 -0400133 /* Return the final size of the structure */
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 *structure_size = struct_size;
136 return_ACPI_STATUS (AE_OK);
137}
138
139
140/*******************************************************************************
141 *
142 * FUNCTION: acpi_rs_memory24_stream
143 *
144 * PARAMETERS: linked_list - Pointer to the resource linked list
145 * output_buffer - Pointer to the user's return buffer
146 * bytes_consumed - Pointer to where the number of bytes
147 * used in the output_buffer is returned
148 *
149 * RETURN: Status
150 *
151 * DESCRIPTION: Take the linked list resource structure and fills in the
152 * the appropriate bytes in a byte stream
153 *
154 ******************************************************************************/
155
156acpi_status
157acpi_rs_memory24_stream (
158 struct acpi_resource *linked_list,
159 u8 **output_buffer,
160 acpi_size *bytes_consumed)
161{
162 u8 *buffer = *output_buffer;
163 u16 temp16 = 0;
164 u8 temp8 = 0;
165
166
167 ACPI_FUNCTION_TRACE ("rs_memory24_stream");
168
169
Robert Moore44f6c012005-04-18 22:49:35 -0400170 /* The descriptor field is static */
171
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 *buffer = 0x81;
173 buffer += 1;
174
Robert Moore44f6c012005-04-18 22:49:35 -0400175 /* The length field is static */
176
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 temp16 = 0x09;
178 ACPI_MOVE_16_TO_16 (buffer, &temp16);
179 buffer += 2;
180
Robert Moore44f6c012005-04-18 22:49:35 -0400181 /* Set the Information Byte */
182
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01);
184 *buffer = temp8;
185 buffer += 1;
186
Robert Moore44f6c012005-04-18 22:49:35 -0400187 /* Set the Range minimum base address */
188
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
190 buffer += 2;
191
Robert Moore44f6c012005-04-18 22:49:35 -0400192 /* Set the Range maximum base address */
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
195 buffer += 2;
196
Robert Moore44f6c012005-04-18 22:49:35 -0400197 /* Set the base alignment */
198
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment);
200 buffer += 2;
201
Robert Moore44f6c012005-04-18 22:49:35 -0400202 /* Set the range length */
203
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length);
205 buffer += 2;
206
Robert Moore44f6c012005-04-18 22:49:35 -0400207 /* Return the number of bytes consumed in this operation */
208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
210 return_ACPI_STATUS (AE_OK);
211}
212
213
214/*******************************************************************************
215 *
216 * FUNCTION: acpi_rs_memory32_range_resource
217 *
218 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
219 * stream
220 * bytes_consumed - Pointer to where the number of bytes
221 * consumed the byte_stream_buffer is
222 * returned
223 * output_buffer - Pointer to the return data buffer
224 * structure_size - Pointer to where the number of bytes
225 * in the return data struct is returned
226 *
227 * RETURN: Status
228 *
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.
232 *
233 ******************************************************************************/
234
235acpi_status
236acpi_rs_memory32_range_resource (
237 u8 *byte_stream_buffer,
238 acpi_size *bytes_consumed,
239 u8 **output_buffer,
240 acpi_size *structure_size)
241{
242 u8 *buffer = byte_stream_buffer;
243 struct acpi_resource *output_struct = (void *) *output_buffer;
244 u16 temp16 = 0;
245 u8 temp8 = 0;
Robert Moore44f6c012005-04-18 22:49:35 -0400246 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
247 struct acpi_resource_mem32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
249
250 ACPI_FUNCTION_TRACE ("rs_memory32_range_resource");
251
252
Robert Moore44f6c012005-04-18 22:49:35 -0400253 /* Point past the Descriptor to get the number of bytes consumed */
254
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 buffer += 1;
256
257 ACPI_MOVE_16_TO_16 (&temp16, buffer);
258 buffer += 2;
259 *bytes_consumed = (acpi_size) temp16 + 3;
260
261 output_struct->id = ACPI_RSTYPE_MEM32;
262
263 /*
264 * Point to the place in the output buffer where the data portion will
265 * begin.
266 * 1. Set the RESOURCE_DATA * Data to point to its own address, then
267 * 2. Set the pointer to the next address.
268 *
269 * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds
270 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
271 */
272
Robert Moore44f6c012005-04-18 22:49:35 -0400273 /* Check Byte 3 the Read/Write bit */
274
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 temp8 = *buffer;
276 buffer += 1;
277
278 output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
279
Robert Moore44f6c012005-04-18 22:49:35 -0400280 /* Get min_base_address (Bytes 4-7) */
281
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer);
283 buffer += 4;
284
Robert Moore44f6c012005-04-18 22:49:35 -0400285 /* Get max_base_address (Bytes 8-11) */
286
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer);
288 buffer += 4;
289
Robert Moore44f6c012005-04-18 22:49:35 -0400290 /* Get Alignment (Bytes 12-15) */
291
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer);
293 buffer += 4;
294
Robert Moore44f6c012005-04-18 22:49:35 -0400295 /* Get range_length (Bytes 16-19) */
296
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer);
298
Robert Moore44f6c012005-04-18 22:49:35 -0400299 /* Set the Length parameter */
300
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 output_struct->length = (u32) struct_size;
302
Robert Moore44f6c012005-04-18 22:49:35 -0400303 /* Return the final size of the structure */
304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 *structure_size = struct_size;
306 return_ACPI_STATUS (AE_OK);
307}
308
309
310/*******************************************************************************
311 *
312 * FUNCTION: acpi_rs_fixed_memory32_resource
313 *
314 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
315 * stream
316 * bytes_consumed - Pointer to where the number of bytes
317 * consumed the byte_stream_buffer is
318 * returned
319 * output_buffer - Pointer to the return data buffer
320 * structure_size - Pointer to where the number of bytes
321 * in the return data struct is returned
322 *
323 * RETURN: Status
324 *
325 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
326 * structure pointed to by the output_buffer. Return the
327 * number of bytes consumed from the byte stream.
328 *
329 ******************************************************************************/
330
331acpi_status
332acpi_rs_fixed_memory32_resource (
333 u8 *byte_stream_buffer,
334 acpi_size *bytes_consumed,
335 u8 **output_buffer,
336 acpi_size *structure_size)
337{
338 u8 *buffer = byte_stream_buffer;
339 struct acpi_resource *output_struct = (void *) *output_buffer;
340 u16 temp16 = 0;
341 u8 temp8 = 0;
Robert Moore44f6c012005-04-18 22:49:35 -0400342 acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
343 struct acpi_resource_fixed_mem32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
345
346 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource");
347
348
Robert Moore44f6c012005-04-18 22:49:35 -0400349 /* Point past the Descriptor to get the number of bytes consumed */
350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 buffer += 1;
352 ACPI_MOVE_16_TO_16 (&temp16, buffer);
353
354 buffer += 2;
355 *bytes_consumed = (acpi_size) temp16 + 3;
356
357 output_struct->id = ACPI_RSTYPE_FIXED_MEM32;
358
Robert Moore44f6c012005-04-18 22:49:35 -0400359 /* Check Byte 3 the Read/Write bit */
360
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 temp8 = *buffer;
362 buffer += 1;
363 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
364
Robert Moore44f6c012005-04-18 22:49:35 -0400365 /* Get range_base_address (Bytes 4-7) */
366
367 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address,
368 buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 buffer += 4;
370
Robert Moore44f6c012005-04-18 22:49:35 -0400371 /* Get range_length (Bytes 8-11) */
372
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer);
374
Robert Moore44f6c012005-04-18 22:49:35 -0400375 /* Set the Length parameter */
376
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 output_struct->length = (u32) struct_size;
378
Robert Moore44f6c012005-04-18 22:49:35 -0400379 /* Return the final size of the structure */
380
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 *structure_size = struct_size;
382 return_ACPI_STATUS (AE_OK);
383}
384
385
386/*******************************************************************************
387 *
388 * FUNCTION: acpi_rs_memory32_range_stream
389 *
390 * PARAMETERS: linked_list - Pointer to the resource linked list
391 * output_buffer - Pointer to the user's return buffer
392 * bytes_consumed - Pointer to where the number of bytes
393 * used in the output_buffer is returned
394 *
395 * RETURN: Status
396 *
397 * DESCRIPTION: Take the linked list resource structure and fills in the
398 * the appropriate bytes in a byte stream
399 *
400 ******************************************************************************/
401
402acpi_status
403acpi_rs_memory32_range_stream (
404 struct acpi_resource *linked_list,
405 u8 **output_buffer,
406 acpi_size *bytes_consumed)
407{
408 u8 *buffer = *output_buffer;
409 u16 temp16 = 0;
410 u8 temp8 = 0;
411
412
413 ACPI_FUNCTION_TRACE ("rs_memory32_range_stream");
414
415
Robert Moore44f6c012005-04-18 22:49:35 -0400416 /* The descriptor field is static */
417
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 *buffer = 0x85;
419 buffer += 1;
420
Robert Moore44f6c012005-04-18 22:49:35 -0400421 /* The length field is static */
422
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 temp16 = 0x11;
424
425 ACPI_MOVE_16_TO_16 (buffer, &temp16);
426 buffer += 2;
427
Robert Moore44f6c012005-04-18 22:49:35 -0400428 /* Set the Information Byte */
429
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
431 *buffer = temp8;
432 buffer += 1;
433
Robert Moore44f6c012005-04-18 22:49:35 -0400434 /* Set the Range minimum base address */
435
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
437 buffer += 4;
438
Robert Moore44f6c012005-04-18 22:49:35 -0400439 /* Set the Range maximum base address */
440
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
442 buffer += 4;
443
Robert Moore44f6c012005-04-18 22:49:35 -0400444 /* Set the base alignment */
445
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment);
447 buffer += 4;
448
Robert Moore44f6c012005-04-18 22:49:35 -0400449 /* Set the range length */
450
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length);
452 buffer += 4;
453
Robert Moore44f6c012005-04-18 22:49:35 -0400454 /* Return the number of bytes consumed in this operation */
455
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
457 return_ACPI_STATUS (AE_OK);
458}
459
460
461/*******************************************************************************
462 *
463 * FUNCTION: acpi_rs_fixed_memory32_stream
464 *
465 * PARAMETERS: linked_list - Pointer to the resource linked list
466 * output_buffer - Pointer to the user's return buffer
467 * bytes_consumed - Pointer to where the number of bytes
468 * used in the output_buffer is returned
469 *
470 * RETURN: Status
471 *
472 * DESCRIPTION: Take the linked list resource structure and fills in the
473 * the appropriate bytes in a byte stream
474 *
475 ******************************************************************************/
476
477acpi_status
478acpi_rs_fixed_memory32_stream (
479 struct acpi_resource *linked_list,
480 u8 **output_buffer,
481 acpi_size *bytes_consumed)
482{
483 u8 *buffer = *output_buffer;
484 u16 temp16 = 0;
485 u8 temp8 = 0;
486
487
488 ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream");
489
490
Robert Moore44f6c012005-04-18 22:49:35 -0400491 /* The descriptor field is static */
492
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 *buffer = 0x86;
494 buffer += 1;
495
Robert Moore44f6c012005-04-18 22:49:35 -0400496 /* The length field is static */
497
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 temp16 = 0x09;
499
500 ACPI_MOVE_16_TO_16 (buffer, &temp16);
501 buffer += 2;
502
Robert Moore44f6c012005-04-18 22:49:35 -0400503 /* Set the Information Byte */
504
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
506 *buffer = temp8;
507 buffer += 1;
508
Robert Moore44f6c012005-04-18 22:49:35 -0400509 /* Set the Range base address */
510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 ACPI_MOVE_32_TO_32 (buffer,
Robert Moore44f6c012005-04-18 22:49:35 -0400512 &linked_list->data.fixed_memory32.range_base_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 buffer += 4;
514
Robert Moore44f6c012005-04-18 22:49:35 -0400515 /* Set the range length */
516
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 ACPI_MOVE_32_TO_32 (buffer,
Robert Moore44f6c012005-04-18 22:49:35 -0400518 &linked_list->data.fixed_memory32.range_length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 buffer += 4;
520
Robert Moore44f6c012005-04-18 22:49:35 -0400521 /* Return the number of bytes consumed in this operation */
522
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 *bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
524 return_ACPI_STATUS (AE_OK);
525}
526