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