aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resources/rsmemory.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/resources/rsmemory.c')
-rw-r--r--drivers/acpi/resources/rsmemory.c517
1 files changed, 125 insertions, 392 deletions
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c
index daba1a1ed46d..a5131936d690 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/resources/rsmemory.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2005, R. Byron Moore 8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,454 +49,187 @@ ACPI_MODULE_NAME("rsmemory")
49 49
50/******************************************************************************* 50/*******************************************************************************
51 * 51 *
52 * FUNCTION: acpi_rs_memory24_resource 52 * acpi_rs_convert_memory24
53 *
54 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
55 * stream
56 * bytes_consumed - Pointer to where the number of bytes
57 * consumed the byte_stream_buffer is
58 * returned
59 * output_buffer - Pointer to the return data buffer
60 * structure_size - Pointer to where the number of bytes
61 * in the return data struct is returned
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
66 * structure pointed to by the output_buffer. Return the
67 * number of bytes consumed from the byte stream.
68 * 53 *
69 ******************************************************************************/ 54 ******************************************************************************/
70acpi_status 55struct acpi_rsconvert_info acpi_rs_convert_memory24[4] = {
71acpi_rs_memory24_resource(u8 * byte_stream_buffer, 56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24,
72 acpi_size * bytes_consumed, 57 ACPI_RS_SIZE(struct acpi_resource_memory24),
73 u8 ** output_buffer, acpi_size * structure_size) 58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory24)},
74{
75 u8 *buffer = byte_stream_buffer;
76 struct acpi_resource *output_struct = (void *)*output_buffer;
77 u16 temp16 = 0;
78 u8 temp8 = 0;
79 acpi_size struct_size =
80 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24);
81
82 ACPI_FUNCTION_TRACE("rs_memory24_resource");
83
84 /* Point past the Descriptor to get the number of bytes consumed */
85
86 buffer += 1;
87
88 ACPI_MOVE_16_TO_16(&temp16, buffer);
89 buffer += 2;
90 *bytes_consumed = (acpi_size) temp16 + 3;
91 output_struct->id = ACPI_RSTYPE_MEM24;
92
93 /* Check Byte 3 the Read/Write bit */
94
95 temp8 = *buffer;
96 buffer += 1;
97 output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
98
99 /* Get min_base_address (Bytes 4-5) */
100
101 ACPI_MOVE_16_TO_16(&temp16, buffer);
102 buffer += 2;
103 output_struct->data.memory24.min_base_address = temp16;
104
105 /* Get max_base_address (Bytes 6-7) */
106
107 ACPI_MOVE_16_TO_16(&temp16, buffer);
108 buffer += 2;
109 output_struct->data.memory24.max_base_address = temp16;
110 59
111 /* Get Alignment (Bytes 8-9) */ 60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24,
61 sizeof(struct aml_resource_memory24),
62 0},
112 63
113 ACPI_MOVE_16_TO_16(&temp16, buffer); 64 /* Read/Write bit */
114 buffer += 2;
115 output_struct->data.memory24.alignment = temp16;
116 65
117 /* Get range_length (Bytes 10-11) */ 66 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory24.write_protect),
118 67 AML_OFFSET(memory24.flags),
119 ACPI_MOVE_16_TO_16(&temp16, buffer); 68 0},
120 output_struct->data.memory24.range_length = temp16; 69 /*
121 70 * These fields are contiguous in both the source and destination:
122 /* Set the Length parameter */ 71 * Minimum Base Address
123 72 * Maximum Base Address
124 output_struct->length = (u32) struct_size; 73 * Address Base Alignment
125 74 * Range Length
126 /* Return the final size of the structure */ 75 */
127 76 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.memory24.minimum),
128 *structure_size = struct_size; 77 AML_OFFSET(memory24.minimum),
129 return_ACPI_STATUS(AE_OK); 78 4}
130} 79};
131 80
132/******************************************************************************* 81/*******************************************************************************
133 * 82 *
134 * FUNCTION: acpi_rs_memory24_stream 83 * acpi_rs_convert_memory32
135 *
136 * PARAMETERS: linked_list - Pointer to the resource linked list
137 * output_buffer - Pointer to the user's return buffer
138 * bytes_consumed - Pointer to where the number of bytes
139 * used in the output_buffer is returned
140 *
141 * RETURN: Status
142 *
143 * DESCRIPTION: Take the linked list resource structure and fills in the
144 * the appropriate bytes in a byte stream
145 * 84 *
146 ******************************************************************************/ 85 ******************************************************************************/
147 86
148acpi_status 87struct acpi_rsconvert_info acpi_rs_convert_memory32[4] = {
149acpi_rs_memory24_stream(struct acpi_resource *linked_list, 88 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32,
150 u8 ** output_buffer, acpi_size * bytes_consumed) 89 ACPI_RS_SIZE(struct acpi_resource_memory32),
151{ 90 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_memory32)},
152 u8 *buffer = *output_buffer;
153 u16 temp16 = 0;
154 u8 temp8 = 0;
155
156 ACPI_FUNCTION_TRACE("rs_memory24_stream");
157
158 /* The descriptor field is static */
159
160 *buffer = 0x81;
161 buffer += 1;
162 91
163 /* The length field is static */ 92 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32,
93 sizeof(struct aml_resource_memory32),
94 0},
164 95
165 temp16 = 0x09; 96 /* Read/Write bit */
166 ACPI_MOVE_16_TO_16(buffer, &temp16);
167 buffer += 2;
168 97
169 /* Set the Information Byte */ 98 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.memory32.write_protect),
170 99 AML_OFFSET(memory32.flags),
171 temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01); 100 0},
172 *buffer = temp8; 101 /*
173 buffer += 1; 102 * These fields are contiguous in both the source and destination:
174 103 * Minimum Base Address
175 /* Set the Range minimum base address */ 104 * Maximum Base Address
176 105 * Address Base Alignment
177 ACPI_MOVE_32_TO_16(buffer, 106 * Range Length
178 &linked_list->data.memory24.min_base_address); 107 */
179 buffer += 2; 108 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.memory32.minimum),
180 109 AML_OFFSET(memory32.minimum),
181 /* Set the Range maximum base address */ 110 4}
182 111};
183 ACPI_MOVE_32_TO_16(buffer,
184 &linked_list->data.memory24.max_base_address);
185 buffer += 2;
186
187 /* Set the base alignment */
188
189 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.alignment);
190 buffer += 2;
191
192 /* Set the range length */
193
194 ACPI_MOVE_32_TO_16(buffer, &linked_list->data.memory24.range_length);
195 buffer += 2;
196
197 /* Return the number of bytes consumed in this operation */
198
199 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
200 return_ACPI_STATUS(AE_OK);
201}
202 112
203/******************************************************************************* 113/*******************************************************************************
204 * 114 *
205 * FUNCTION: acpi_rs_memory32_range_resource 115 * acpi_rs_convert_fixed_memory32
206 *
207 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
208 * stream
209 * bytes_consumed - Pointer to where the number of bytes
210 * consumed the byte_stream_buffer is
211 * returned
212 * output_buffer - Pointer to the return data buffer
213 * structure_size - Pointer to where the number of bytes
214 * in the return data struct is returned
215 *
216 * RETURN: Status
217 *
218 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
219 * structure pointed to by the output_buffer. Return the
220 * number of bytes consumed from the byte stream.
221 * 116 *
222 ******************************************************************************/ 117 ******************************************************************************/
223 118
224acpi_status 119struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[4] = {
225acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, 120 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32,
226 acpi_size * bytes_consumed, 121 ACPI_RS_SIZE(struct acpi_resource_fixed_memory32),
227 u8 ** output_buffer, acpi_size * structure_size) 122 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_memory32)},
228{
229 u8 *buffer = byte_stream_buffer;
230 struct acpi_resource *output_struct = (void *)*output_buffer;
231 u16 temp16 = 0;
232 u8 temp8 = 0;
233 acpi_size struct_size =
234 ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32);
235
236 ACPI_FUNCTION_TRACE("rs_memory32_range_resource");
237
238 /* Point past the Descriptor to get the number of bytes consumed */
239
240 buffer += 1;
241 123
242 ACPI_MOVE_16_TO_16(&temp16, buffer); 124 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32,
243 buffer += 2; 125 sizeof(struct aml_resource_fixed_memory32),
244 *bytes_consumed = (acpi_size) temp16 + 3; 126 0},
245 127
246 output_struct->id = ACPI_RSTYPE_MEM32; 128 /* Read/Write bit */
247 129
130 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.fixed_memory32.write_protect),
131 AML_OFFSET(fixed_memory32.flags),
132 0},
248 /* 133 /*
249 * Point to the place in the output buffer where the data portion will 134 * These fields are contiguous in both the source and destination:
250 * begin. 135 * Base Address
251 * 1. Set the RESOURCE_DATA * Data to point to its own address, then 136 * Range Length
252 * 2. Set the pointer to the next address.
253 *
254 * NOTE: output_struct->Data is cast to u8, otherwise, this addition adds
255 * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
256 */ 137 */
257 138 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.fixed_memory32.address),
258 /* Check Byte 3 the Read/Write bit */ 139 AML_OFFSET(fixed_memory32.address),
259 140 2}
260 temp8 = *buffer; 141};
261 buffer += 1;
262
263 output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
264
265 /* Get min_base_address (Bytes 4-7) */
266
267 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.min_base_address,
268 buffer);
269 buffer += 4;
270
271 /* Get max_base_address (Bytes 8-11) */
272
273 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.max_base_address,
274 buffer);
275 buffer += 4;
276
277 /* Get Alignment (Bytes 12-15) */
278
279 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.alignment, buffer);
280 buffer += 4;
281
282 /* Get range_length (Bytes 16-19) */
283
284 ACPI_MOVE_32_TO_32(&output_struct->data.memory32.range_length, buffer);
285
286 /* Set the Length parameter */
287
288 output_struct->length = (u32) struct_size;
289
290 /* Return the final size of the structure */
291
292 *structure_size = struct_size;
293 return_ACPI_STATUS(AE_OK);
294}
295 142
296/******************************************************************************* 143/*******************************************************************************
297 * 144 *
298 * FUNCTION: acpi_rs_fixed_memory32_resource 145 * acpi_rs_get_vendor_small
299 *
300 * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte
301 * stream
302 * bytes_consumed - Pointer to where the number of bytes
303 * consumed the byte_stream_buffer is
304 * returned
305 * output_buffer - Pointer to the return data buffer
306 * structure_size - Pointer to where the number of bytes
307 * in the return data struct is returned
308 *
309 * RETURN: Status
310 *
311 * DESCRIPTION: Take the resource byte stream and fill out the appropriate
312 * structure pointed to by the output_buffer. Return the
313 * number of bytes consumed from the byte stream.
314 * 146 *
315 ******************************************************************************/ 147 ******************************************************************************/
316 148
317acpi_status 149struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = {
318acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, 150 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
319 acpi_size * bytes_consumed, 151 ACPI_RS_SIZE(struct acpi_resource_vendor),
320 u8 ** output_buffer, acpi_size * structure_size) 152 ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_small)},
321{
322 u8 *buffer = byte_stream_buffer;
323 struct acpi_resource *output_struct = (void *)*output_buffer;
324 u16 temp16 = 0;
325 u8 temp8 = 0;
326 acpi_size struct_size =
327 ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32);
328
329 ACPI_FUNCTION_TRACE("rs_fixed_memory32_resource");
330 153
331 /* Point past the Descriptor to get the number of bytes consumed */ 154 /* Length of the vendor data (byte count) */
332 155
333 buffer += 1; 156 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
334 ACPI_MOVE_16_TO_16(&temp16, buffer); 157 0,
158 sizeof(u8)}
159 ,
335 160
336 buffer += 2; 161 /* Vendor data */
337 *bytes_consumed = (acpi_size) temp16 + 3;
338 162
339 output_struct->id = ACPI_RSTYPE_FIXED_MEM32; 163 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
340 164 sizeof(struct aml_resource_small_header),
341 /* Check Byte 3 the Read/Write bit */ 165 0}
342 166};
343 temp8 = *buffer;
344 buffer += 1;
345 output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
346
347 /* Get range_base_address (Bytes 4-7) */
348
349 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.
350 range_base_address, buffer);
351 buffer += 4;
352
353 /* Get range_length (Bytes 8-11) */
354
355 ACPI_MOVE_32_TO_32(&output_struct->data.fixed_memory32.range_length,
356 buffer);
357
358 /* Set the Length parameter */
359
360 output_struct->length = (u32) struct_size;
361
362 /* Return the final size of the structure */
363
364 *structure_size = struct_size;
365 return_ACPI_STATUS(AE_OK);
366}
367 167
368/******************************************************************************* 168/*******************************************************************************
369 * 169 *
370 * FUNCTION: acpi_rs_memory32_range_stream 170 * acpi_rs_get_vendor_large
371 *
372 * PARAMETERS: linked_list - Pointer to the resource linked list
373 * output_buffer - Pointer to the user's return buffer
374 * bytes_consumed - Pointer to where the number of bytes
375 * used in the output_buffer is returned
376 *
377 * RETURN: Status
378 *
379 * DESCRIPTION: Take the linked list resource structure and fills in the
380 * the appropriate bytes in a byte stream
381 * 171 *
382 ******************************************************************************/ 172 ******************************************************************************/
383 173
384acpi_status 174struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = {
385acpi_rs_memory32_range_stream(struct acpi_resource *linked_list, 175 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR,
386 u8 ** output_buffer, acpi_size * bytes_consumed) 176 ACPI_RS_SIZE(struct acpi_resource_vendor),
387{ 177 ACPI_RSC_TABLE_SIZE(acpi_rs_get_vendor_large)},
388 u8 *buffer = *output_buffer;
389 u16 temp16 = 0;
390 u8 temp8 = 0;
391
392 ACPI_FUNCTION_TRACE("rs_memory32_range_stream");
393
394 /* The descriptor field is static */
395
396 *buffer = 0x85;
397 buffer += 1;
398
399 /* The length field is static */
400
401 temp16 = 0x11;
402
403 ACPI_MOVE_16_TO_16(buffer, &temp16);
404 buffer += 2;
405
406 /* Set the Information Byte */
407
408 temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
409 *buffer = temp8;
410 buffer += 1;
411
412 /* Set the Range minimum base address */
413
414 ACPI_MOVE_32_TO_32(buffer,
415 &linked_list->data.memory32.min_base_address);
416 buffer += 4;
417
418 /* Set the Range maximum base address */
419
420 ACPI_MOVE_32_TO_32(buffer,
421 &linked_list->data.memory32.max_base_address);
422 buffer += 4;
423 178
424 /* Set the base alignment */ 179 /* Length of the vendor data (byte count) */
425 180
426 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.alignment); 181 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
427 buffer += 4; 182 0,
183 sizeof(u8)}
184 ,
428 185
429 /* Set the range length */ 186 /* Vendor data */
430 187
431 ACPI_MOVE_32_TO_32(buffer, &linked_list->data.memory32.range_length); 188 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
432 buffer += 4; 189 sizeof(struct aml_resource_large_header),
433 190 0}
434 /* Return the number of bytes consumed in this operation */ 191};
435
436 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer);
437 return_ACPI_STATUS(AE_OK);
438}
439 192
440/******************************************************************************* 193/*******************************************************************************
441 * 194 *
442 * FUNCTION: acpi_rs_fixed_memory32_stream 195 * acpi_rs_set_vendor
443 *
444 * PARAMETERS: linked_list - Pointer to the resource linked list
445 * output_buffer - Pointer to the user's return buffer
446 * bytes_consumed - Pointer to where the number of bytes
447 * used in the output_buffer is returned
448 *
449 * RETURN: Status
450 *
451 * DESCRIPTION: Take the linked list resource structure and fills in the
452 * the appropriate bytes in a byte stream
453 * 196 *
454 ******************************************************************************/ 197 ******************************************************************************/
455 198
456acpi_status 199struct acpi_rsconvert_info acpi_rs_set_vendor[7] = {
457acpi_rs_fixed_memory32_stream(struct acpi_resource *linked_list, 200 /* Default is a small vendor descriptor */
458 u8 ** output_buffer, acpi_size * bytes_consumed)
459{
460 u8 *buffer = *output_buffer;
461 u16 temp16 = 0;
462 u8 temp8 = 0;
463
464 ACPI_FUNCTION_TRACE("rs_fixed_memory32_stream");
465 201
466 /* The descriptor field is static */ 202 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL,
203 sizeof(struct aml_resource_small_header),
204 ACPI_RSC_TABLE_SIZE(acpi_rs_set_vendor)},
467 205
468 *buffer = 0x86; 206 /* Get the length and copy the data */
469 buffer += 1;
470 207
471 /* The length field is static */ 208 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
209 0,
210 0},
472 211
473 temp16 = 0x09; 212 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
213 sizeof(struct aml_resource_small_header),
214 0},
474 215
475 ACPI_MOVE_16_TO_16(buffer, &temp16); 216 /*
476 buffer += 2; 217 * All done if the Vendor byte length is 7 or less, meaning that it will
477 218 * fit within a small descriptor
478 /* Set the Information Byte */ 219 */
479 220 {ACPI_RSC_EXIT_LE, 0, 0, 7},
480 temp8 =
481 (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
482 *buffer = temp8;
483 buffer += 1;
484
485 /* Set the Range base address */
486
487 ACPI_MOVE_32_TO_32(buffer,
488 &linked_list->data.fixed_memory32.
489 range_base_address);
490 buffer += 4;
491 221
492 /* Set the range length */ 222 /* Must create a large vendor descriptor */
493 223
494 ACPI_MOVE_32_TO_32(buffer, 224 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE,
495 &linked_list->data.fixed_memory32.range_length); 225 sizeof(struct aml_resource_large_header),
496 buffer += 4; 226 0},
497 227
498 /* Return the number of bytes consumed in this operation */ 228 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
229 0,
230 0},
499 231
500 *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); 232 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.vendor.byte_data[0]),
501 return_ACPI_STATUS(AE_OK); 233 sizeof(struct aml_resource_large_header),
502} 234 0}
235};