diff options
Diffstat (limited to 'drivers/acpi/resources')
-rw-r--r-- | drivers/acpi/resources/Makefile | 2 | ||||
-rw-r--r-- | drivers/acpi/resources/rsaddr.c | 1132 | ||||
-rw-r--r-- | drivers/acpi/resources/rscalc.c | 282 | ||||
-rw-r--r-- | drivers/acpi/resources/rscreate.c | 59 | ||||
-rw-r--r-- | drivers/acpi/resources/rsdump.c | 313 | ||||
-rw-r--r-- | drivers/acpi/resources/rsinfo.c | 2 | ||||
-rw-r--r-- | drivers/acpi/resources/rsio.c | 451 | ||||
-rw-r--r-- | drivers/acpi/resources/rsirq.c | 494 | ||||
-rw-r--r-- | drivers/acpi/resources/rslist.c | 290 | ||||
-rw-r--r-- | drivers/acpi/resources/rsmemory.c | 472 | ||||
-rw-r--r-- | drivers/acpi/resources/rsmisc.c | 711 | ||||
-rw-r--r-- | drivers/acpi/resources/rsutils.c | 437 | ||||
-rw-r--r-- | drivers/acpi/resources/rsxface.c | 14 |
13 files changed, 1893 insertions, 2766 deletions
diff --git a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile index 2130b74170c3..8de4f69dfa09 100644 --- a/drivers/acpi/resources/Makefile +++ b/drivers/acpi/resources/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for all Linux ACPI interpreter subdirectories | 2 | # Makefile for all Linux ACPI interpreter subdirectories |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := rsaddr.o rscreate.o rsio.o rslist.o rsmisc.o rsxface.o \ | 5 | obj-y := rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \ |
6 | rscalc.o rsirq.o rsmemory.o rsutils.o | 6 | rscalc.o rsirq.o rsmemory.o rsutils.o |
7 | 7 | ||
8 | obj-$(ACPI_FUTURE_USAGE) += rsdump.o | 8 | obj-$(ACPI_FUTURE_USAGE) += rsdump.o |
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c index 798778261fb9..6f48ebf3304e 100644 --- a/drivers/acpi/resources/rsaddr.c +++ b/drivers/acpi/resources/rsaddr.c | |||
@@ -58,12 +58,20 @@ acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags); | |||
58 | 58 | ||
59 | static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource); | 59 | static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource); |
60 | 60 | ||
61 | static void | ||
62 | acpi_rs_set_address_common(union aml_resource *aml, | ||
63 | struct acpi_resource *resource); | ||
64 | |||
65 | static u8 | ||
66 | acpi_rs_get_address_common(struct acpi_resource *resource, | ||
67 | union aml_resource *aml); | ||
68 | |||
61 | /******************************************************************************* | 69 | /******************************************************************************* |
62 | * | 70 | * |
63 | * FUNCTION: acpi_rs_decode_general_flags | 71 | * FUNCTION: acpi_rs_decode_general_flags |
64 | * | 72 | * |
65 | * PARAMETERS: Resource - Address resource data struct | 73 | * PARAMETERS: Resource - Address resource data struct |
66 | * Flags - Actual flag byte | 74 | * Flags - Raw AML flag byte |
67 | * | 75 | * |
68 | * RETURN: Decoded flag bits in resource struct | 76 | * RETURN: Decoded flag bits in resource struct |
69 | * | 77 | * |
@@ -107,27 +115,19 @@ acpi_rs_decode_general_flags(union acpi_resource_data *resource, u8 flags) | |||
107 | 115 | ||
108 | static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) | 116 | static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) |
109 | { | 117 | { |
110 | u8 flags; | ||
111 | |||
112 | ACPI_FUNCTION_ENTRY(); | 118 | ACPI_FUNCTION_ENTRY(); |
113 | 119 | ||
114 | /* Producer / Consumer - flag bit[0] */ | 120 | return ((u8) |
115 | 121 | ||
116 | flags = (u8) (resource->address.producer_consumer & 0x01); | 122 | /* Producer / Consumer - flag bit[0] */ |
117 | 123 | ((resource->address.producer_consumer & 0x01) | | |
118 | /* Decode (_DEC) - flag bit[1] */ | 124 | /* Decode (_DEC) - flag bit[1] */ |
119 | 125 | ((resource->address.decode & 0x01) << 1) | | |
120 | flags |= (u8) ((resource->address.decode & 0x01) << 1); | 126 | /* Min Address Fixed (_MIF) - flag bit[2] */ |
121 | 127 | ((resource->address.min_address_fixed & 0x01) << 2) | | |
122 | /* Min Address Fixed (_MIF) - flag bit[2] */ | 128 | /* Max Address Fixed (_MAF) - flag bit[3] */ |
123 | 129 | ((resource->address.max_address_fixed & 0x01) << 3)) | |
124 | flags |= (u8) ((resource->address.min_address_fixed & 0x01) << 2); | 130 | ); |
125 | |||
126 | /* Max Address Fixed (_MAF) - flag bit[3] */ | ||
127 | |||
128 | flags |= (u8) ((resource->address.max_address_fixed & 0x01) << 3); | ||
129 | |||
130 | return (flags); | ||
131 | } | 131 | } |
132 | 132 | ||
133 | /******************************************************************************* | 133 | /******************************************************************************* |
@@ -135,7 +135,7 @@ static u8 acpi_rs_encode_general_flags(union acpi_resource_data *resource) | |||
135 | * FUNCTION: acpi_rs_decode_specific_flags | 135 | * FUNCTION: acpi_rs_decode_specific_flags |
136 | * | 136 | * |
137 | * PARAMETERS: Resource - Address resource data struct | 137 | * PARAMETERS: Resource - Address resource data struct |
138 | * Flags - Actual flag byte | 138 | * Flags - Raw AML flag byte |
139 | * | 139 | * |
140 | * RETURN: Decoded flag bits in attribute struct | 140 | * RETURN: Decoded flag bits in attribute struct |
141 | * | 141 | * |
@@ -189,921 +189,541 @@ acpi_rs_decode_specific_flags(union acpi_resource_data *resource, u8 flags) | |||
189 | 189 | ||
190 | static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) | 190 | static u8 acpi_rs_encode_specific_flags(union acpi_resource_data *resource) |
191 | { | 191 | { |
192 | u8 flags = 0; | ||
193 | |||
194 | ACPI_FUNCTION_ENTRY(); | 192 | ACPI_FUNCTION_ENTRY(); |
195 | 193 | ||
196 | if (resource->address.resource_type == ACPI_MEMORY_RANGE) { | 194 | if (resource->address.resource_type == ACPI_MEMORY_RANGE) { |
197 | /* Write Status (_RW) - flag bit[0] */ | 195 | return ((u8) |
198 | 196 | ||
199 | flags = (u8) | 197 | /* Write Status (_RW) - flag bit[0] */ |
200 | (resource->address.attribute.memory. | 198 | ((resource->address.attribute.memory. |
201 | read_write_attribute & 0x01); | 199 | read_write_attribute & 0x01) | |
202 | 200 | /* Memory Attributes (_MEM) - flag bits[2:1] */ | |
203 | /* Memory Attributes (_MEM) - flag bits[2:1] */ | 201 | ((resource->address.attribute.memory. |
204 | 202 | cache_attribute & 0x03) << 1))); | |
205 | flags |= (u8) | ||
206 | ((resource->address.attribute.memory. | ||
207 | cache_attribute & 0x03) << 1); | ||
208 | } else if (resource->address.resource_type == ACPI_IO_RANGE) { | 203 | } else if (resource->address.resource_type == ACPI_IO_RANGE) { |
209 | /* Ranges (_RNG) - flag bits[1:0] */ | 204 | return ((u8) |
210 | 205 | ||
211 | flags = (u8) | 206 | /* Ranges (_RNG) - flag bits[1:0] */ |
212 | (resource->address.attribute.io.range_attribute & 0x03); | 207 | ((resource->address.attribute.io. |
213 | 208 | range_attribute & 0x03) | | |
214 | /* Translations (_TTP and _TRS) - flag bits[5:4] */ | 209 | /* Translations (_TTP and _TRS) - flag bits[5:4] */ |
215 | 210 | ((resource->address.attribute.io. | |
216 | flags |= (u8) | 211 | translation_attribute & 0x03) << 4))); |
217 | ((resource->address.attribute.io. | ||
218 | translation_attribute & 0x03) << 4); | ||
219 | } | 212 | } |
220 | 213 | ||
221 | return (flags); | 214 | return (0); |
222 | } | 215 | } |
223 | 216 | ||
224 | /******************************************************************************* | 217 | /******************************************************************************* |
225 | * | 218 | * |
226 | * FUNCTION: acpi_rs_address16_resource | 219 | * FUNCTION: acpi_rs_set_address_common |
227 | * | 220 | * |
228 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 221 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
229 | * stream | 222 | * Resource - Pointer to the internal resource struct |
230 | * bytes_consumed - Pointer to where the number of bytes | ||
231 | * consumed the byte_stream_buffer is | ||
232 | * returned | ||
233 | * output_buffer - Pointer to the return data buffer | ||
234 | * structure_size - Pointer to where the number of bytes | ||
235 | * in the return data struct is returned | ||
236 | * | 223 | * |
237 | * RETURN: Status | 224 | * RETURN: None |
238 | * | 225 | * |
239 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 226 | * DESCRIPTION: Convert common flag fields from a resource descriptor to an |
240 | * structure pointed to by the output_buffer. Return the | 227 | * AML descriptor |
241 | * number of bytes consumed from the byte stream. | ||
242 | * | 228 | * |
243 | ******************************************************************************/ | 229 | ******************************************************************************/ |
244 | 230 | ||
245 | acpi_status | 231 | static void |
246 | acpi_rs_address16_resource(u8 * byte_stream_buffer, | 232 | acpi_rs_set_address_common(union aml_resource *aml, |
247 | acpi_size * bytes_consumed, | 233 | struct acpi_resource *resource) |
248 | u8 ** output_buffer, acpi_size * structure_size) | ||
249 | { | 234 | { |
250 | u32 index; | 235 | ACPI_FUNCTION_ENTRY(); |
251 | u16 temp16; | ||
252 | u8 temp8; | ||
253 | u8 *temp_ptr; | ||
254 | u8 *buffer = byte_stream_buffer; | ||
255 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
256 | acpi_size struct_size = | ||
257 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16); | ||
258 | 236 | ||
259 | ACPI_FUNCTION_TRACE("rs_address16_resource"); | 237 | /* Set the Resource Type (Memory, Io, bus_number, etc.) */ |
260 | 238 | ||
261 | /* Get the Descriptor Length field */ | 239 | aml->address.resource_type = (u8) resource->data.address.resource_type; |
262 | 240 | ||
263 | buffer += 1; | 241 | /* Set the general flags */ |
264 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
265 | 242 | ||
266 | /* Validate minimum descriptor length */ | 243 | aml->address.flags = acpi_rs_encode_general_flags(&resource->data); |
267 | 244 | ||
268 | if (temp16 < 13) { | 245 | /* Set the type-specific flags */ |
269 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | ||
270 | } | ||
271 | 246 | ||
272 | *bytes_consumed = temp16 + 3; | 247 | aml->address.specific_flags = |
273 | output_struct->type = ACPI_RSTYPE_ADDRESS16; | 248 | acpi_rs_encode_specific_flags(&resource->data); |
249 | } | ||
274 | 250 | ||
275 | /* Get the Resource Type (Byte3) */ | 251 | /******************************************************************************* |
252 | * | ||
253 | * FUNCTION: acpi_rs_get_address_common | ||
254 | * | ||
255 | * PARAMETERS: Resource - Pointer to the internal resource struct | ||
256 | * Aml - Pointer to the AML resource descriptor | ||
257 | * | ||
258 | * RETURN: TRUE if the resource_type field is OK, FALSE otherwise | ||
259 | * | ||
260 | * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor | ||
261 | * to an internal resource descriptor | ||
262 | * | ||
263 | ******************************************************************************/ | ||
276 | 264 | ||
277 | buffer += 2; | 265 | static u8 |
278 | temp8 = *buffer; | 266 | acpi_rs_get_address_common(struct acpi_resource *resource, |
267 | union aml_resource *aml) | ||
268 | { | ||
269 | ACPI_FUNCTION_ENTRY(); | ||
279 | 270 | ||
280 | /* Values 0-2 and 0xC0-0xFF are valid */ | 271 | /* Validate resource type */ |
281 | 272 | ||
282 | if ((temp8 > 2) && (temp8 < 0xC0)) { | 273 | if ((aml->address.resource_type > 2) |
283 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | 274 | && (aml->address.resource_type < 0xC0)) { |
275 | return (FALSE); | ||
284 | } | 276 | } |
285 | 277 | ||
286 | output_struct->data.address16.resource_type = temp8; | 278 | /* Get the Resource Type (Memory, Io, bus_number, etc.) */ |
287 | |||
288 | /* Get the General Flags (Byte4) */ | ||
289 | |||
290 | buffer += 1; | ||
291 | acpi_rs_decode_general_flags(&output_struct->data, *buffer); | ||
292 | |||
293 | /* Get the Type Specific Flags (Byte5) */ | ||
294 | |||
295 | buffer += 1; | ||
296 | acpi_rs_decode_specific_flags(&output_struct->data, *buffer); | ||
297 | |||
298 | /* Get Granularity (Bytes 6-7) */ | ||
299 | |||
300 | buffer += 1; | ||
301 | ACPI_MOVE_16_TO_32(&output_struct->data.address16.granularity, buffer); | ||
302 | 279 | ||
303 | /* Get min_address_range (Bytes 8-9) */ | 280 | resource->data.address.resource_type = aml->address.resource_type; |
304 | 281 | ||
305 | buffer += 2; | 282 | /* Get the General Flags */ |
306 | ACPI_MOVE_16_TO_32(&output_struct->data.address16.min_address_range, | ||
307 | buffer); | ||
308 | 283 | ||
309 | /* Get max_address_range (Bytes 10-11) */ | 284 | acpi_rs_decode_general_flags(&resource->data, aml->address.flags); |
310 | 285 | ||
311 | buffer += 2; | 286 | /* Get the Type-Specific Flags */ |
312 | ACPI_MOVE_16_TO_32(&output_struct->data.address16.max_address_range, | ||
313 | buffer); | ||
314 | 287 | ||
315 | /* Get address_translation_offset (Bytes 12-13) */ | 288 | acpi_rs_decode_specific_flags(&resource->data, |
316 | 289 | aml->address.specific_flags); | |
317 | buffer += 2; | 290 | return (TRUE); |
318 | ACPI_MOVE_16_TO_32(&output_struct->data.address16. | 291 | } |
319 | address_translation_offset, buffer); | ||
320 | 292 | ||
321 | /* Get address_length (Bytes 14-15) */ | 293 | /******************************************************************************* |
294 | * | ||
295 | * FUNCTION: acpi_rs_get_address16 | ||
296 | * | ||
297 | * PARAMETERS: Aml - Pointer to the AML resource descriptor | ||
298 | * aml_resource_length - Length of the resource from the AML header | ||
299 | * Resource - Where the internal resource is returned | ||
300 | * | ||
301 | * RETURN: Status | ||
302 | * | ||
303 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding | ||
304 | * internal resource descriptor, simplifying bitflags and handling | ||
305 | * alignment and endian issues if necessary. | ||
306 | * | ||
307 | ******************************************************************************/ | ||
322 | 308 | ||
323 | buffer += 2; | 309 | acpi_status |
324 | ACPI_MOVE_16_TO_32(&output_struct->data.address16.address_length, | 310 | acpi_rs_get_address16(union aml_resource * aml, |
325 | buffer); | 311 | u16 aml_resource_length, struct acpi_resource * resource) |
312 | { | ||
313 | ACPI_FUNCTION_TRACE("rs_get_address16"); | ||
326 | 314 | ||
327 | /* Resource Source Index (if present) */ | 315 | /* Get the Resource Type, general flags, and type-specific flags */ |
328 | 316 | ||
329 | buffer += 2; | 317 | if (!acpi_rs_get_address_common(resource, aml)) { |
318 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | ||
319 | } | ||
330 | 320 | ||
331 | /* | 321 | /* |
332 | * This will leave us pointing to the Resource Source Index | 322 | * Get the following contiguous fields from the AML descriptor: |
333 | * If it is present, then save it off and calculate the | 323 | * Address Granularity |
334 | * pointer to where the null terminated string goes: | 324 | * Address Range Minimum |
335 | * Each Interrupt takes 32-bits + the 5 bytes of the | 325 | * Address Range Maximum |
336 | * stream that are default. | 326 | * Address Translation Offset |
337 | * | 327 | * Address Length |
338 | * Note: Some resource descriptors will have an additional null, so | ||
339 | * we add 1 to the length. | ||
340 | */ | 328 | */ |
341 | if (*bytes_consumed > (16 + 1)) { | 329 | acpi_rs_move_data(&resource->data.address16.granularity, |
342 | /* Dereference the Index */ | 330 | &aml->address16.granularity, 5, |
343 | 331 | ACPI_MOVE_TYPE_16_TO_32); | |
344 | output_struct->data.address16.resource_source.index = | ||
345 | (u32) * buffer; | ||
346 | |||
347 | /* Point to the String */ | ||
348 | 332 | ||
349 | buffer += 1; | 333 | /* Get the optional resource_source (index and string) */ |
350 | 334 | ||
351 | /* Point the String pointer to the end of this structure */ | 335 | resource->length = |
336 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16) + | ||
337 | acpi_rs_get_resource_source(aml_resource_length, | ||
338 | sizeof(struct aml_resource_address16), | ||
339 | &resource->data.address16. | ||
340 | resource_source, aml, NULL); | ||
352 | 341 | ||
353 | output_struct->data.address16.resource_source.string_ptr = | 342 | /* Complete the resource header */ |
354 | (char *)((u8 *) output_struct + struct_size); | ||
355 | 343 | ||
356 | temp_ptr = (u8 *) | 344 | resource->type = ACPI_RESOURCE_TYPE_ADDRESS16; |
357 | output_struct->data.address16.resource_source.string_ptr; | ||
358 | |||
359 | /* Copy the resource_source string into the buffer */ | ||
360 | |||
361 | index = 0; | ||
362 | while (*buffer) { | ||
363 | *temp_ptr = *buffer; | ||
364 | |||
365 | temp_ptr++; | ||
366 | buffer++; | ||
367 | index++; | ||
368 | } | ||
369 | |||
370 | /* Add the terminating null and set the string length */ | ||
371 | |||
372 | *temp_ptr = 0; | ||
373 | output_struct->data.address16.resource_source.string_length = | ||
374 | index + 1; | ||
375 | |||
376 | /* | ||
377 | * In order for the struct_size to fall on a 32-bit boundary, | ||
378 | * calculate the length of the string and expand the | ||
379 | * struct_size to the next 32-bit boundary. | ||
380 | */ | ||
381 | temp8 = (u8) (index + 1); | ||
382 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); | ||
383 | } else { | ||
384 | output_struct->data.address16.resource_source.index = 0; | ||
385 | output_struct->data.address16.resource_source.string_length = 0; | ||
386 | output_struct->data.address16.resource_source.string_ptr = NULL; | ||
387 | } | ||
388 | |||
389 | /* Set the Length parameter */ | ||
390 | |||
391 | output_struct->length = (u32) struct_size; | ||
392 | |||
393 | /* Return the final size of the structure */ | ||
394 | |||
395 | *structure_size = struct_size; | ||
396 | return_ACPI_STATUS(AE_OK); | 345 | return_ACPI_STATUS(AE_OK); |
397 | } | 346 | } |
398 | 347 | ||
399 | /******************************************************************************* | 348 | /******************************************************************************* |
400 | * | 349 | * |
401 | * FUNCTION: acpi_rs_address16_stream | 350 | * FUNCTION: acpi_rs_set_address16 |
402 | * | 351 | * |
403 | * PARAMETERS: Resource - Pointer to the resource linked list | 352 | * PARAMETERS: Resource - Pointer to the resource descriptor |
404 | * output_buffer - Pointer to the user's return buffer | 353 | * Aml - Where the AML descriptor is returned |
405 | * bytes_consumed - Pointer to where the number of bytes | ||
406 | * used in the output_buffer is returned | ||
407 | * | 354 | * |
408 | * RETURN: Status | 355 | * RETURN: Status |
409 | * | 356 | * |
410 | * DESCRIPTION: Take the linked list resource structure and fills in the | 357 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
411 | * the appropriate bytes in a byte stream | 358 | * external AML resource descriptor. |
412 | * | 359 | * |
413 | ******************************************************************************/ | 360 | ******************************************************************************/ |
414 | 361 | ||
415 | acpi_status | 362 | acpi_status |
416 | acpi_rs_address16_stream(struct acpi_resource *resource, | 363 | acpi_rs_set_address16(struct acpi_resource *resource, union aml_resource *aml) |
417 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
418 | { | 364 | { |
419 | u8 *buffer = *output_buffer; | 365 | acpi_size descriptor_length; |
420 | u8 *length_field; | ||
421 | acpi_size actual_bytes; | ||
422 | |||
423 | ACPI_FUNCTION_TRACE("rs_address16_stream"); | ||
424 | |||
425 | /* Set the Descriptor Type field */ | ||
426 | 366 | ||
427 | *buffer = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE; | 367 | ACPI_FUNCTION_TRACE("rs_set_address16"); |
428 | buffer += 1; | ||
429 | 368 | ||
430 | /* Save a pointer to the Length field - to be filled in later */ | 369 | /* Set the Resource Type, General Flags, and Type-Specific Flags */ |
431 | 370 | ||
432 | length_field = buffer; | 371 | acpi_rs_set_address_common(aml, resource); |
433 | buffer += 2; | ||
434 | |||
435 | /* Set the Resource Type (Memory, Io, bus_number) */ | ||
436 | |||
437 | *buffer = (u8) (resource->data.address16.resource_type & 0x03); | ||
438 | buffer += 1; | ||
439 | |||
440 | /* Set the general flags */ | ||
441 | 372 | ||
442 | *buffer = acpi_rs_encode_general_flags(&resource->data); | 373 | /* |
443 | buffer += 1; | 374 | * Set the following contiguous fields in the AML descriptor: |
444 | 375 | * Address Granularity | |
445 | /* Set the type specific flags */ | 376 | * Address Range Minimum |
446 | 377 | * Address Range Maximum | |
447 | *buffer = acpi_rs_encode_specific_flags(&resource->data); | 378 | * Address Translation Offset |
448 | buffer += 1; | 379 | * Address Length |
449 | 380 | */ | |
450 | /* Set the address space granularity */ | 381 | acpi_rs_move_data(&aml->address16.granularity, |
451 | 382 | &resource->data.address16.granularity, 5, | |
452 | ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.granularity); | 383 | ACPI_MOVE_TYPE_32_TO_16); |
453 | buffer += 2; | ||
454 | |||
455 | /* Set the address range minimum */ | ||
456 | |||
457 | ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.min_address_range); | ||
458 | buffer += 2; | ||
459 | |||
460 | /* Set the address range maximum */ | ||
461 | |||
462 | ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.max_address_range); | ||
463 | buffer += 2; | ||
464 | |||
465 | /* Set the address translation offset */ | ||
466 | |||
467 | ACPI_MOVE_32_TO_16(buffer, | ||
468 | &resource->data.address16. | ||
469 | address_translation_offset); | ||
470 | buffer += 2; | ||
471 | |||
472 | /* Set the address length */ | ||
473 | |||
474 | ACPI_MOVE_32_TO_16(buffer, &resource->data.address16.address_length); | ||
475 | buffer += 2; | ||
476 | 384 | ||
477 | /* Resource Source Index and Resource Source are optional */ | 385 | /* Resource Source Index and Resource Source are optional */ |
478 | 386 | ||
479 | if (resource->data.address16.resource_source.string_length) { | 387 | descriptor_length = acpi_rs_set_resource_source(aml, |
480 | *buffer = (u8) resource->data.address16.resource_source.index; | 388 | sizeof(struct |
481 | buffer += 1; | 389 | aml_resource_address16), |
390 | &resource->data. | ||
391 | address16. | ||
392 | resource_source); | ||
482 | 393 | ||
483 | /* Copy the resource_source string */ | 394 | /* Complete the AML descriptor header */ |
484 | 395 | ||
485 | ACPI_STRCPY((char *)buffer, | 396 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS16, |
486 | resource->data.address16.resource_source. | 397 | descriptor_length, aml); |
487 | string_ptr); | ||
488 | |||
489 | /* | ||
490 | * Buffer needs to be set to the length of the string + one for the | ||
491 | * terminating null | ||
492 | */ | ||
493 | buffer += | ||
494 | (acpi_size) (ACPI_STRLEN | ||
495 | (resource->data.address16.resource_source. | ||
496 | string_ptr) + 1); | ||
497 | } | ||
498 | |||
499 | /* Return the number of bytes consumed in this operation */ | ||
500 | |||
501 | actual_bytes = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
502 | *bytes_consumed = actual_bytes; | ||
503 | |||
504 | /* | ||
505 | * Set the length field to the number of bytes consumed | ||
506 | * minus the header size (3 bytes) | ||
507 | */ | ||
508 | actual_bytes -= 3; | ||
509 | ACPI_MOVE_SIZE_TO_16(length_field, &actual_bytes); | ||
510 | return_ACPI_STATUS(AE_OK); | 398 | return_ACPI_STATUS(AE_OK); |
511 | } | 399 | } |
512 | 400 | ||
513 | /******************************************************************************* | 401 | /******************************************************************************* |
514 | * | 402 | * |
515 | * FUNCTION: acpi_rs_address32_resource | 403 | * FUNCTION: acpi_rs_get_address32 |
516 | * | 404 | * |
517 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 405 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
518 | * stream | 406 | * aml_resource_length - Length of the resource from the AML header |
519 | * bytes_consumed - Pointer to where the number of bytes | 407 | * Resource - Where the internal resource is returned |
520 | * consumed the byte_stream_buffer is | ||
521 | * returned | ||
522 | * output_buffer - Pointer to the return data buffer | ||
523 | * structure_size - Pointer to where the number of bytes | ||
524 | * in the return data struct is returned | ||
525 | * | 408 | * |
526 | * RETURN: Status | 409 | * RETURN: Status |
527 | * | 410 | * |
528 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 411 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
529 | * structure pointed to by the output_buffer. Return the | 412 | * internal resource descriptor, simplifying bitflags and handling |
530 | * number of bytes consumed from the byte stream. | 413 | * alignment and endian issues if necessary. |
531 | * | 414 | * |
532 | ******************************************************************************/ | 415 | ******************************************************************************/ |
533 | 416 | ||
534 | acpi_status | 417 | acpi_status |
535 | acpi_rs_address32_resource(u8 * byte_stream_buffer, | 418 | acpi_rs_get_address32(union aml_resource *aml, |
536 | acpi_size * bytes_consumed, | 419 | u16 aml_resource_length, struct acpi_resource *resource) |
537 | u8 ** output_buffer, acpi_size * structure_size) | ||
538 | { | 420 | { |
539 | u16 temp16; | ||
540 | u8 temp8; | ||
541 | u8 *temp_ptr; | ||
542 | u32 index; | ||
543 | u8 *buffer = byte_stream_buffer; | ||
544 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
545 | acpi_size struct_size = | ||
546 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32); | ||
547 | |||
548 | ACPI_FUNCTION_TRACE("rs_address32_resource"); | ||
549 | |||
550 | /* Get the Descriptor Length field */ | ||
551 | |||
552 | buffer += 1; | ||
553 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
554 | 421 | ||
555 | /* Validate minimum descriptor length */ | 422 | ACPI_FUNCTION_TRACE("rs_get_address32"); |
556 | 423 | ||
557 | if (temp16 < 23) { | 424 | /* Get the Resource Type, general flags, and type-specific flags */ |
558 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | ||
559 | } | ||
560 | |||
561 | *bytes_consumed = temp16 + 3; | ||
562 | output_struct->type = ACPI_RSTYPE_ADDRESS32; | ||
563 | |||
564 | /* Get the Resource Type (Byte3) */ | ||
565 | |||
566 | buffer += 2; | ||
567 | temp8 = *buffer; | ||
568 | 425 | ||
569 | /* Values 0-2 and 0xC0-0xFF are valid */ | 426 | if (!acpi_rs_get_address_common(resource, (void *)aml)) { |
570 | |||
571 | if ((temp8 > 2) && (temp8 < 0xC0)) { | ||
572 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | 427 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); |
573 | } | 428 | } |
574 | 429 | ||
575 | output_struct->data.address32.resource_type = temp8; | ||
576 | |||
577 | /* Get the General Flags (Byte4) */ | ||
578 | |||
579 | buffer += 1; | ||
580 | acpi_rs_decode_general_flags(&output_struct->data, *buffer); | ||
581 | |||
582 | /* Get the Type Specific Flags (Byte5) */ | ||
583 | |||
584 | buffer += 1; | ||
585 | acpi_rs_decode_specific_flags(&output_struct->data, *buffer); | ||
586 | |||
587 | /* Get Granularity (Bytes 6-9) */ | ||
588 | |||
589 | buffer += 1; | ||
590 | ACPI_MOVE_32_TO_32(&output_struct->data.address32.granularity, buffer); | ||
591 | |||
592 | /* Get min_address_range (Bytes 10-13) */ | ||
593 | |||
594 | buffer += 4; | ||
595 | ACPI_MOVE_32_TO_32(&output_struct->data.address32.min_address_range, | ||
596 | buffer); | ||
597 | |||
598 | /* Get max_address_range (Bytes 14-17) */ | ||
599 | |||
600 | buffer += 4; | ||
601 | ACPI_MOVE_32_TO_32(&output_struct->data.address32.max_address_range, | ||
602 | buffer); | ||
603 | |||
604 | /* Get address_translation_offset (Bytes 18-21) */ | ||
605 | |||
606 | buffer += 4; | ||
607 | ACPI_MOVE_32_TO_32(&output_struct->data.address32. | ||
608 | address_translation_offset, buffer); | ||
609 | |||
610 | /* Get address_length (Bytes 22-25) */ | ||
611 | |||
612 | buffer += 4; | ||
613 | ACPI_MOVE_32_TO_32(&output_struct->data.address32.address_length, | ||
614 | buffer); | ||
615 | |||
616 | /* Resource Source Index (if present) */ | ||
617 | |||
618 | buffer += 4; | ||
619 | |||
620 | /* | 430 | /* |
621 | * This will leave us pointing to the Resource Source Index | 431 | * Get the following contiguous fields from the AML descriptor: |
622 | * If it is present, then save it off and calculate the | 432 | * Address Granularity |
623 | * pointer to where the null terminated string goes: | 433 | * Address Range Minimum |
624 | * | 434 | * Address Range Maximum |
625 | * Note: Some resource descriptors will have an additional null, so | 435 | * Address Translation Offset |
626 | * we add 1 to the length. | 436 | * Address Length |
627 | */ | 437 | */ |
628 | if (*bytes_consumed > (26 + 1)) { | 438 | acpi_rs_move_data(&resource->data.address32.granularity, |
629 | /* Dereference the Index */ | 439 | &aml->address32.granularity, 5, |
630 | 440 | ACPI_MOVE_TYPE_32_TO_32); | |
631 | output_struct->data.address32.resource_source.index = | ||
632 | (u32) * buffer; | ||
633 | |||
634 | /* Point to the String */ | ||
635 | 441 | ||
636 | buffer += 1; | 442 | /* Get the optional resource_source (index and string) */ |
637 | 443 | ||
638 | /* Point the String pointer to the end of this structure */ | 444 | resource->length = |
445 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32) + | ||
446 | acpi_rs_get_resource_source(aml_resource_length, | ||
447 | sizeof(struct aml_resource_address32), | ||
448 | &resource->data.address32. | ||
449 | resource_source, aml, NULL); | ||
639 | 450 | ||
640 | output_struct->data.address32.resource_source.string_ptr = | 451 | /* Complete the resource header */ |
641 | (char *)((u8 *) output_struct + struct_size); | ||
642 | 452 | ||
643 | temp_ptr = (u8 *) | 453 | resource->type = ACPI_RESOURCE_TYPE_ADDRESS32; |
644 | output_struct->data.address32.resource_source.string_ptr; | ||
645 | |||
646 | /* Copy the resource_source string into the buffer */ | ||
647 | |||
648 | index = 0; | ||
649 | while (*buffer) { | ||
650 | *temp_ptr = *buffer; | ||
651 | |||
652 | temp_ptr++; | ||
653 | buffer++; | ||
654 | index++; | ||
655 | } | ||
656 | |||
657 | /* Add the terminating null and set the string length */ | ||
658 | |||
659 | *temp_ptr = 0; | ||
660 | output_struct->data.address32.resource_source.string_length = | ||
661 | index + 1; | ||
662 | |||
663 | /* | ||
664 | * In order for the struct_size to fall on a 32-bit boundary, | ||
665 | * calculate the length of the string and expand the | ||
666 | * struct_size to the next 32-bit boundary. | ||
667 | */ | ||
668 | temp8 = (u8) (index + 1); | ||
669 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); | ||
670 | } else { | ||
671 | output_struct->data.address32.resource_source.index = 0; | ||
672 | output_struct->data.address32.resource_source.string_length = 0; | ||
673 | output_struct->data.address32.resource_source.string_ptr = NULL; | ||
674 | } | ||
675 | |||
676 | /* Set the Length parameter */ | ||
677 | |||
678 | output_struct->length = (u32) struct_size; | ||
679 | |||
680 | /* Return the final size of the structure */ | ||
681 | |||
682 | *structure_size = struct_size; | ||
683 | return_ACPI_STATUS(AE_OK); | 454 | return_ACPI_STATUS(AE_OK); |
684 | } | 455 | } |
685 | 456 | ||
686 | /******************************************************************************* | 457 | /******************************************************************************* |
687 | * | 458 | * |
688 | * FUNCTION: acpi_rs_address32_stream | 459 | * FUNCTION: acpi_rs_set_address32 |
689 | * | 460 | * |
690 | * PARAMETERS: Resource - Pointer to the resource linked list | 461 | * PARAMETERS: Resource - Pointer to the resource descriptor |
691 | * output_buffer - Pointer to the user's return buffer | 462 | * Aml - Where the AML descriptor is returned |
692 | * bytes_consumed - Pointer to where the number of bytes | ||
693 | * used in the output_buffer is returned | ||
694 | * | 463 | * |
695 | * RETURN: Status | 464 | * RETURN: Status |
696 | * | 465 | * |
697 | * DESCRIPTION: Take the linked list resource structure and fills in the | 466 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
698 | * the appropriate bytes in a byte stream | 467 | * external AML resource descriptor. |
699 | * | 468 | * |
700 | ******************************************************************************/ | 469 | ******************************************************************************/ |
701 | 470 | ||
702 | acpi_status | 471 | acpi_status |
703 | acpi_rs_address32_stream(struct acpi_resource *resource, | 472 | acpi_rs_set_address32(struct acpi_resource *resource, union aml_resource *aml) |
704 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
705 | { | 473 | { |
706 | u8 *buffer; | 474 | acpi_size descriptor_length; |
707 | u16 *length_field; | ||
708 | |||
709 | ACPI_FUNCTION_TRACE("rs_address32_stream"); | ||
710 | |||
711 | buffer = *output_buffer; | ||
712 | 475 | ||
713 | /* Set the Descriptor Type field */ | 476 | ACPI_FUNCTION_TRACE("rs_set_address32"); |
714 | 477 | ||
715 | *buffer = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE; | 478 | /* Set the Resource Type, General Flags, and Type-Specific Flags */ |
716 | buffer += 1; | ||
717 | 479 | ||
718 | /* Save a pointer to the Length field - to be filled in later */ | 480 | acpi_rs_set_address_common(aml, resource); |
719 | 481 | ||
720 | length_field = ACPI_CAST_PTR(u16, buffer); | 482 | /* |
721 | buffer += 2; | 483 | * Set the following contiguous fields in the AML descriptor: |
722 | 484 | * Address Granularity | |
723 | /* Set the Resource Type (Memory, Io, bus_number) */ | 485 | * Address Range Minimum |
724 | 486 | * Address Range Maximum | |
725 | *buffer = (u8) (resource->data.address32.resource_type & 0x03); | 487 | * Address Translation Offset |
726 | buffer += 1; | 488 | * Address Length |
727 | 489 | */ | |
728 | /* Set the general flags */ | 490 | acpi_rs_move_data(&aml->address32.granularity, |
729 | 491 | &resource->data.address32.granularity, 5, | |
730 | *buffer = acpi_rs_encode_general_flags(&resource->data); | 492 | ACPI_MOVE_TYPE_32_TO_32); |
731 | buffer += 1; | ||
732 | |||
733 | /* Set the type specific flags */ | ||
734 | |||
735 | *buffer = acpi_rs_encode_specific_flags(&resource->data); | ||
736 | buffer += 1; | ||
737 | |||
738 | /* Set the address space granularity */ | ||
739 | |||
740 | ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.granularity); | ||
741 | buffer += 4; | ||
742 | |||
743 | /* Set the address range minimum */ | ||
744 | |||
745 | ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.min_address_range); | ||
746 | buffer += 4; | ||
747 | |||
748 | /* Set the address range maximum */ | ||
749 | |||
750 | ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.max_address_range); | ||
751 | buffer += 4; | ||
752 | |||
753 | /* Set the address translation offset */ | ||
754 | |||
755 | ACPI_MOVE_32_TO_32(buffer, | ||
756 | &resource->data.address32. | ||
757 | address_translation_offset); | ||
758 | buffer += 4; | ||
759 | |||
760 | /* Set the address length */ | ||
761 | |||
762 | ACPI_MOVE_32_TO_32(buffer, &resource->data.address32.address_length); | ||
763 | buffer += 4; | ||
764 | 493 | ||
765 | /* Resource Source Index and Resource Source are optional */ | 494 | /* Resource Source Index and Resource Source are optional */ |
766 | 495 | ||
767 | if (resource->data.address32.resource_source.string_length) { | 496 | descriptor_length = acpi_rs_set_resource_source(aml, |
768 | *buffer = (u8) resource->data.address32.resource_source.index; | 497 | sizeof(struct |
769 | buffer += 1; | 498 | aml_resource_address32), |
770 | 499 | &resource->data. | |
771 | /* Copy the resource_source string */ | 500 | address32. |
501 | resource_source); | ||
772 | 502 | ||
773 | ACPI_STRCPY((char *)buffer, | 503 | /* Complete the AML descriptor header */ |
774 | resource->data.address32.resource_source. | ||
775 | string_ptr); | ||
776 | 504 | ||
777 | /* | 505 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS32, |
778 | * Buffer needs to be set to the length of the string + one for the | 506 | descriptor_length, aml); |
779 | * terminating null | ||
780 | */ | ||
781 | buffer += | ||
782 | (acpi_size) (ACPI_STRLEN | ||
783 | (resource->data.address32.resource_source. | ||
784 | string_ptr) + 1); | ||
785 | } | ||
786 | |||
787 | /* Return the number of bytes consumed in this operation */ | ||
788 | |||
789 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
790 | |||
791 | /* | ||
792 | * Set the length field to the number of bytes consumed | ||
793 | * minus the header size (3 bytes) | ||
794 | */ | ||
795 | *length_field = (u16) (*bytes_consumed - 3); | ||
796 | return_ACPI_STATUS(AE_OK); | 507 | return_ACPI_STATUS(AE_OK); |
797 | } | 508 | } |
798 | 509 | ||
799 | /******************************************************************************* | 510 | /******************************************************************************* |
800 | * | 511 | * |
801 | * FUNCTION: acpi_rs_address64_resource | 512 | * FUNCTION: acpi_rs_get_address64 |
802 | * | 513 | * |
803 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 514 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
804 | * stream | 515 | * aml_resource_length - Length of the resource from the AML header |
805 | * bytes_consumed - Pointer to where the number of bytes | 516 | * Resource - Where the internal resource is returned |
806 | * consumed the byte_stream_buffer is | ||
807 | * returned | ||
808 | * output_buffer - Pointer to the return data buffer | ||
809 | * structure_size - Pointer to where the number of bytes | ||
810 | * in the return data struct is returned | ||
811 | * | 517 | * |
812 | * RETURN: Status | 518 | * RETURN: Status |
813 | * | 519 | * |
814 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 520 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
815 | * structure pointed to by the output_buffer. Return the | 521 | * internal resource descriptor, simplifying bitflags and handling |
816 | * number of bytes consumed from the byte stream. | 522 | * alignment and endian issues if necessary. |
817 | * | 523 | * |
818 | ******************************************************************************/ | 524 | ******************************************************************************/ |
819 | 525 | ||
820 | acpi_status | 526 | acpi_status |
821 | acpi_rs_address64_resource(u8 * byte_stream_buffer, | 527 | acpi_rs_get_address64(union aml_resource *aml, |
822 | acpi_size * bytes_consumed, | 528 | u16 aml_resource_length, struct acpi_resource *resource) |
823 | u8 ** output_buffer, acpi_size * structure_size) | ||
824 | { | 529 | { |
825 | u16 temp16; | 530 | ACPI_FUNCTION_TRACE("rs_get_address64"); |
826 | u8 temp8; | ||
827 | u8 resource_type; | ||
828 | u8 *temp_ptr; | ||
829 | u32 index; | ||
830 | u8 *buffer = byte_stream_buffer; | ||
831 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
832 | acpi_size struct_size = | ||
833 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64); | ||
834 | |||
835 | ACPI_FUNCTION_TRACE("rs_address64_resource"); | ||
836 | |||
837 | /* Get the Descriptor Type */ | ||
838 | |||
839 | resource_type = *buffer; | ||
840 | |||
841 | /* Get the Descriptor Length field */ | ||
842 | |||
843 | buffer += 1; | ||
844 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
845 | |||
846 | /* Validate minimum descriptor length */ | ||
847 | |||
848 | if (temp16 < 43) { | ||
849 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | ||
850 | } | ||
851 | |||
852 | *bytes_consumed = temp16 + 3; | ||
853 | output_struct->type = ACPI_RSTYPE_ADDRESS64; | ||
854 | |||
855 | /* Get the Resource Type (Byte3) */ | ||
856 | 531 | ||
857 | buffer += 2; | 532 | /* Get the Resource Type, general Flags, and type-specific Flags */ |
858 | temp8 = *buffer; | ||
859 | 533 | ||
860 | /* Values 0-2 and 0xC0-0xFF are valid */ | 534 | if (!acpi_rs_get_address_common(resource, aml)) { |
861 | |||
862 | if ((temp8 > 2) && (temp8 < 0xC0)) { | ||
863 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | 535 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); |
864 | } | 536 | } |
865 | 537 | ||
866 | output_struct->data.address64.resource_type = temp8; | 538 | /* |
867 | 539 | * Get the following contiguous fields from the AML descriptor: | |
868 | /* Get the General Flags (Byte4) */ | 540 | * Address Granularity |
869 | 541 | * Address Range Minimum | |
870 | buffer += 1; | 542 | * Address Range Maximum |
871 | acpi_rs_decode_general_flags(&output_struct->data, *buffer); | 543 | * Address Translation Offset |
872 | 544 | * Address Length | |
873 | /* Get the Type Specific Flags (Byte5) */ | 545 | */ |
874 | 546 | acpi_rs_move_data(&resource->data.address64.granularity, | |
875 | buffer += 1; | 547 | &aml->address64.granularity, 5, |
876 | acpi_rs_decode_specific_flags(&output_struct->data, *buffer); | 548 | ACPI_MOVE_TYPE_64_TO_64); |
877 | |||
878 | if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { | ||
879 | /* Move past revision_id and Reserved byte */ | ||
880 | |||
881 | buffer += 2; | ||
882 | } | ||
883 | |||
884 | /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */ | ||
885 | |||
886 | buffer += 1; | ||
887 | ACPI_MOVE_64_TO_64(&output_struct->data.address64.granularity, buffer); | ||
888 | |||
889 | /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */ | ||
890 | |||
891 | buffer += 8; | ||
892 | ACPI_MOVE_64_TO_64(&output_struct->data.address64.min_address_range, | ||
893 | buffer); | ||
894 | |||
895 | /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */ | ||
896 | |||
897 | buffer += 8; | ||
898 | ACPI_MOVE_64_TO_64(&output_struct->data.address64.max_address_range, | ||
899 | buffer); | ||
900 | |||
901 | /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */ | ||
902 | |||
903 | buffer += 8; | ||
904 | ACPI_MOVE_64_TO_64(&output_struct->data.address64. | ||
905 | address_translation_offset, buffer); | ||
906 | 549 | ||
907 | /* Get address_length (Bytes 38-45) or (Bytes 40-47) */ | 550 | /* Get the optional resource_source (index and string) */ |
908 | 551 | ||
909 | buffer += 8; | 552 | resource->length = |
910 | ACPI_MOVE_64_TO_64(&output_struct->data.address64.address_length, | 553 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64) + |
911 | buffer); | 554 | acpi_rs_get_resource_source(aml_resource_length, |
555 | sizeof(struct aml_resource_address64), | ||
556 | &resource->data.address64. | ||
557 | resource_source, aml, NULL); | ||
912 | 558 | ||
913 | output_struct->data.address64.resource_source.index = 0; | 559 | /* Complete the resource header */ |
914 | output_struct->data.address64.resource_source.string_length = 0; | ||
915 | output_struct->data.address64.resource_source.string_ptr = NULL; | ||
916 | 560 | ||
917 | if (resource_type == ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE) { | 561 | resource->type = ACPI_RESOURCE_TYPE_ADDRESS64; |
918 | /* Get type_specific_attribute (Bytes 48-55) */ | 562 | return_ACPI_STATUS(AE_OK); |
563 | } | ||
919 | 564 | ||
920 | buffer += 8; | 565 | /******************************************************************************* |
921 | ACPI_MOVE_64_TO_64(&output_struct->data.address64. | 566 | * |
922 | type_specific_attributes, buffer); | 567 | * FUNCTION: acpi_rs_set_address64 |
923 | } else { | 568 | * |
924 | output_struct->data.address64.type_specific_attributes = 0; | 569 | * PARAMETERS: Resource - Pointer to the resource descriptor |
570 | * Aml - Where the AML descriptor is returned | ||
571 | * | ||
572 | * RETURN: Status | ||
573 | * | ||
574 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding | ||
575 | * external AML resource descriptor. | ||
576 | * | ||
577 | ******************************************************************************/ | ||
925 | 578 | ||
926 | /* Resource Source Index (if present) */ | 579 | acpi_status |
580 | acpi_rs_set_address64(struct acpi_resource *resource, union aml_resource *aml) | ||
581 | { | ||
582 | acpi_size descriptor_length; | ||
927 | 583 | ||
928 | buffer += 8; | 584 | ACPI_FUNCTION_TRACE("rs_set_address64"); |
929 | 585 | ||
930 | /* | 586 | /* Set the Resource Type, General Flags, and Type-Specific Flags */ |
931 | * This will leave us pointing to the Resource Source Index | ||
932 | * If it is present, then save it off and calculate the | ||
933 | * pointer to where the null terminated string goes: | ||
934 | * Each Interrupt takes 32-bits + the 5 bytes of the | ||
935 | * stream that are default. | ||
936 | * | ||
937 | * Note: Some resource descriptors will have an additional null, so | ||
938 | * we add 1 to the length. | ||
939 | */ | ||
940 | if (*bytes_consumed > (46 + 1)) { | ||
941 | /* Dereference the Index */ | ||
942 | 587 | ||
943 | output_struct->data.address64.resource_source.index = | 588 | acpi_rs_set_address_common(aml, resource); |
944 | (u32) * buffer; | ||
945 | 589 | ||
946 | /* Point to the String */ | 590 | /* |
591 | * Set the following contiguous fields in the AML descriptor: | ||
592 | * Address Granularity | ||
593 | * Address Range Minimum | ||
594 | * Address Range Maximum | ||
595 | * Address Translation Offset | ||
596 | * Address Length | ||
597 | */ | ||
598 | acpi_rs_move_data(&aml->address64.granularity, | ||
599 | &resource->data.address64.granularity, 5, | ||
600 | ACPI_MOVE_TYPE_64_TO_64); | ||
947 | 601 | ||
948 | buffer += 1; | 602 | /* Resource Source Index and Resource Source are optional */ |
949 | 603 | ||
950 | /* Point the String pointer to the end of this structure */ | 604 | descriptor_length = acpi_rs_set_resource_source(aml, |
605 | sizeof(struct | ||
606 | aml_resource_address64), | ||
607 | &resource->data. | ||
608 | address64. | ||
609 | resource_source); | ||
951 | 610 | ||
952 | output_struct->data.address64.resource_source. | 611 | /* Complete the AML descriptor header */ |
953 | string_ptr = | ||
954 | (char *)((u8 *) output_struct + struct_size); | ||
955 | 612 | ||
956 | temp_ptr = (u8 *) | 613 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_ADDRESS64, |
957 | output_struct->data.address64.resource_source. | 614 | descriptor_length, aml); |
958 | string_ptr; | 615 | return_ACPI_STATUS(AE_OK); |
616 | } | ||
959 | 617 | ||
960 | /* Copy the resource_source string into the buffer */ | 618 | /******************************************************************************* |
619 | * | ||
620 | * FUNCTION: acpi_rs_get_ext_address64 | ||
621 | * | ||
622 | * PARAMETERS: Aml - Pointer to the AML resource descriptor | ||
623 | * aml_resource_length - Length of the resource from the AML header | ||
624 | * Resource - Where the internal resource is returned | ||
625 | * | ||
626 | * RETURN: Status | ||
627 | * | ||
628 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding | ||
629 | * internal resource descriptor, simplifying bitflags and handling | ||
630 | * alignment and endian issues if necessary. | ||
631 | * | ||
632 | ******************************************************************************/ | ||
961 | 633 | ||
962 | index = 0; | 634 | acpi_status |
963 | while (*buffer) { | 635 | acpi_rs_get_ext_address64(union aml_resource *aml, |
964 | *temp_ptr = *buffer; | 636 | u16 aml_resource_length, |
637 | struct acpi_resource *resource) | ||
638 | { | ||
965 | 639 | ||
966 | temp_ptr++; | 640 | ACPI_FUNCTION_TRACE("rs_get_ext_address64"); |
967 | buffer++; | ||
968 | index++; | ||
969 | } | ||
970 | 641 | ||
971 | /* | 642 | /* Get the Resource Type, general flags, and type-specific flags */ |
972 | * Add the terminating null and set the string length | ||
973 | */ | ||
974 | *temp_ptr = 0; | ||
975 | output_struct->data.address64.resource_source. | ||
976 | string_length = index + 1; | ||
977 | 643 | ||
978 | /* | 644 | if (!acpi_rs_get_address_common(resource, aml)) { |
979 | * In order for the struct_size to fall on a 32-bit boundary, | 645 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); |
980 | * calculate the length of the string and expand the | ||
981 | * struct_size to the next 32-bit boundary. | ||
982 | */ | ||
983 | temp8 = (u8) (index + 1); | ||
984 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); | ||
985 | } | ||
986 | } | 646 | } |
987 | 647 | ||
988 | /* Set the Length parameter */ | 648 | /* |
649 | * Get and validate the Revision ID | ||
650 | * Note: Only one revision ID is currently supported | ||
651 | */ | ||
652 | resource->data.ext_address64.revision_iD = | ||
653 | aml->ext_address64.revision_iD; | ||
654 | if (aml->ext_address64.revision_iD != | ||
655 | AML_RESOURCE_EXTENDED_ADDRESS_REVISION) { | ||
656 | return_ACPI_STATUS(AE_SUPPORT); | ||
657 | } | ||
989 | 658 | ||
990 | output_struct->length = (u32) struct_size; | 659 | /* |
660 | * Get the following contiguous fields from the AML descriptor: | ||
661 | * Address Granularity | ||
662 | * Address Range Minimum | ||
663 | * Address Range Maximum | ||
664 | * Address Translation Offset | ||
665 | * Address Length | ||
666 | * Type-Specific Attribute | ||
667 | */ | ||
668 | acpi_rs_move_data(&resource->data.ext_address64.granularity, | ||
669 | &aml->ext_address64.granularity, 6, | ||
670 | ACPI_MOVE_TYPE_64_TO_64); | ||
991 | 671 | ||
992 | /* Return the final size of the structure */ | 672 | /* Complete the resource header */ |
993 | 673 | ||
994 | *structure_size = struct_size; | 674 | resource->type = ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64; |
675 | resource->length = | ||
676 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_address64); | ||
995 | return_ACPI_STATUS(AE_OK); | 677 | return_ACPI_STATUS(AE_OK); |
996 | } | 678 | } |
997 | 679 | ||
998 | /******************************************************************************* | 680 | /******************************************************************************* |
999 | * | 681 | * |
1000 | * FUNCTION: acpi_rs_address64_stream | 682 | * FUNCTION: acpi_rs_set_ext_address64 |
1001 | * | 683 | * |
1002 | * PARAMETERS: Resource - Pointer to the resource linked list | 684 | * PARAMETERS: Resource - Pointer to the resource descriptor |
1003 | * output_buffer - Pointer to the user's return buffer | 685 | * Aml - Where the AML descriptor is returned |
1004 | * bytes_consumed - Pointer to where the number of bytes | ||
1005 | * used in the output_buffer is returned | ||
1006 | * | 686 | * |
1007 | * RETURN: Status | 687 | * RETURN: Status |
1008 | * | 688 | * |
1009 | * DESCRIPTION: Take the linked list resource structure and fills in the | 689 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
1010 | * the appropriate bytes in a byte stream | 690 | * external AML resource descriptor. |
1011 | * | 691 | * |
1012 | ******************************************************************************/ | 692 | ******************************************************************************/ |
1013 | 693 | ||
1014 | acpi_status | 694 | acpi_status |
1015 | acpi_rs_address64_stream(struct acpi_resource *resource, | 695 | acpi_rs_set_ext_address64(struct acpi_resource *resource, |
1016 | u8 ** output_buffer, acpi_size * bytes_consumed) | 696 | union aml_resource *aml) |
1017 | { | 697 | { |
1018 | u8 *buffer; | 698 | ACPI_FUNCTION_TRACE("rs_set_ext_address64"); |
1019 | u16 *length_field; | ||
1020 | |||
1021 | ACPI_FUNCTION_TRACE("rs_address64_stream"); | ||
1022 | |||
1023 | buffer = *output_buffer; | ||
1024 | |||
1025 | /* Set the Descriptor Type field */ | ||
1026 | |||
1027 | *buffer = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE; | ||
1028 | buffer += 1; | ||
1029 | |||
1030 | /* Save a pointer to the Length field - to be filled in later */ | ||
1031 | |||
1032 | length_field = ACPI_CAST_PTR(u16, buffer); | ||
1033 | buffer += 2; | ||
1034 | |||
1035 | /* Set the Resource Type (Memory, Io, bus_number) */ | ||
1036 | |||
1037 | *buffer = (u8) (resource->data.address64.resource_type & 0x03); | ||
1038 | buffer += 1; | ||
1039 | |||
1040 | /* Set the general flags */ | ||
1041 | |||
1042 | *buffer = acpi_rs_encode_general_flags(&resource->data); | ||
1043 | buffer += 1; | ||
1044 | |||
1045 | /* Set the type specific flags */ | ||
1046 | |||
1047 | *buffer = acpi_rs_encode_specific_flags(&resource->data); | ||
1048 | buffer += 1; | ||
1049 | |||
1050 | /* Set the address space granularity */ | ||
1051 | 699 | ||
1052 | ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.granularity); | 700 | /* Set the Resource Type, General Flags, and Type-Specific Flags */ |
1053 | buffer += 8; | ||
1054 | 701 | ||
1055 | /* Set the address range minimum */ | 702 | acpi_rs_set_address_common(aml, resource); |
1056 | 703 | ||
1057 | ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.min_address_range); | 704 | /* Only one Revision ID is currently supported */ |
1058 | buffer += 8; | ||
1059 | 705 | ||
1060 | /* Set the address range maximum */ | 706 | aml->ext_address64.revision_iD = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; |
1061 | 707 | aml->ext_address64.reserved = 0; | |
1062 | ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.max_address_range); | ||
1063 | buffer += 8; | ||
1064 | |||
1065 | /* Set the address translation offset */ | ||
1066 | |||
1067 | ACPI_MOVE_64_TO_64(buffer, | ||
1068 | &resource->data.address64. | ||
1069 | address_translation_offset); | ||
1070 | buffer += 8; | ||
1071 | |||
1072 | /* Set the address length */ | ||
1073 | |||
1074 | ACPI_MOVE_64_TO_64(buffer, &resource->data.address64.address_length); | ||
1075 | buffer += 8; | ||
1076 | |||
1077 | /* Resource Source Index and Resource Source are optional */ | ||
1078 | |||
1079 | if (resource->data.address64.resource_source.string_length) { | ||
1080 | *buffer = (u8) resource->data.address64.resource_source.index; | ||
1081 | buffer += 1; | ||
1082 | |||
1083 | /* Copy the resource_source string */ | ||
1084 | |||
1085 | ACPI_STRCPY((char *)buffer, | ||
1086 | resource->data.address64.resource_source. | ||
1087 | string_ptr); | ||
1088 | |||
1089 | /* | ||
1090 | * Buffer needs to be set to the length of the string + one for the | ||
1091 | * terminating null | ||
1092 | */ | ||
1093 | buffer += | ||
1094 | (acpi_size) (ACPI_STRLEN | ||
1095 | (resource->data.address64.resource_source. | ||
1096 | string_ptr) + 1); | ||
1097 | } | ||
1098 | |||
1099 | /* Return the number of bytes consumed in this operation */ | ||
1100 | |||
1101 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
1102 | 708 | ||
1103 | /* | 709 | /* |
1104 | * Set the length field to the number of bytes consumed | 710 | * Set the following contiguous fields in the AML descriptor: |
1105 | * minus the header size (3 bytes) | 711 | * Address Granularity |
712 | * Address Range Minimum | ||
713 | * Address Range Maximum | ||
714 | * Address Translation Offset | ||
715 | * Address Length | ||
716 | * Type-Specific Attribute | ||
1106 | */ | 717 | */ |
1107 | *length_field = (u16) (*bytes_consumed - 3); | 718 | acpi_rs_move_data(&aml->ext_address64.granularity, |
719 | &resource->data.address64.granularity, 6, | ||
720 | ACPI_MOVE_TYPE_64_TO_64); | ||
721 | |||
722 | /* Complete the AML descriptor header */ | ||
723 | |||
724 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, | ||
725 | sizeof(struct | ||
726 | aml_resource_extended_address64), | ||
727 | aml); | ||
1108 | return_ACPI_STATUS(AE_OK); | 728 | return_ACPI_STATUS(AE_OK); |
1109 | } | 729 | } |
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c index 2da7c6a8182e..d170dee07ce9 100644 --- a/drivers/acpi/resources/rscalc.c +++ b/drivers/acpi/resources/rscalc.c | |||
@@ -44,87 +44,14 @@ | |||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include <acpi/acresrc.h> | 45 | #include <acpi/acresrc.h> |
46 | #include <acpi/amlcode.h> | 46 | #include <acpi/amlcode.h> |
47 | #include <acpi/amlresrc.h> | ||
48 | #include <acpi/acnamesp.h> | 47 | #include <acpi/acnamesp.h> |
49 | 48 | ||
50 | #define _COMPONENT ACPI_RESOURCES | 49 | #define _COMPONENT ACPI_RESOURCES |
51 | ACPI_MODULE_NAME("rscalc") | 50 | ACPI_MODULE_NAME("rscalc") |
52 | 51 | ||
53 | /* | ||
54 | * Base sizes for external resource descriptors, indexed by internal type. | ||
55 | * Includes size of the descriptor header (1 byte for small descriptors, | ||
56 | * 3 bytes for large descriptors) | ||
57 | */ | ||
58 | static u8 acpi_gbl_stream_sizes[] = { | ||
59 | 4, /* ACPI_RSTYPE_IRQ (Byte 3 is optional, but always created) */ | ||
60 | 3, /* ACPI_RSTYPE_DMA */ | ||
61 | 2, /* ACPI_RSTYPE_START_DPF (Byte 1 is optional, but always created) */ | ||
62 | 1, /* ACPI_RSTYPE_END_DPF */ | ||
63 | 8, /* ACPI_RSTYPE_IO */ | ||
64 | 4, /* ACPI_RSTYPE_FIXED_IO */ | ||
65 | 1, /* ACPI_RSTYPE_VENDOR */ | ||
66 | 2, /* ACPI_RSTYPE_END_TAG */ | ||
67 | 12, /* ACPI_RSTYPE_MEM24 */ | ||
68 | 20, /* ACPI_RSTYPE_MEM32 */ | ||
69 | 12, /* ACPI_RSTYPE_FIXED_MEM32 */ | ||
70 | 16, /* ACPI_RSTYPE_ADDRESS16 */ | ||
71 | 26, /* ACPI_RSTYPE_ADDRESS32 */ | ||
72 | 46, /* ACPI_RSTYPE_ADDRESS64 */ | ||
73 | 9, /* ACPI_RSTYPE_EXT_IRQ */ | ||
74 | 15 /* ACPI_RSTYPE_GENERIC_REG */ | ||
75 | }; | ||
76 | |||
77 | /* | ||
78 | * Base sizes of resource descriptors, both the actual AML stream length and | ||
79 | * size of the internal struct representation. | ||
80 | */ | ||
81 | struct acpi_resource_sizes { | ||
82 | u8 minimum_stream_size; | ||
83 | u8 minimum_struct_size; | ||
84 | }; | ||
85 | |||
86 | static struct acpi_resource_sizes acpi_gbl_sm_resource_sizes[] = { | ||
87 | {0, 0}, /* 0x00, Reserved */ | ||
88 | {0, 0}, /* 0x01, Reserved */ | ||
89 | {0, 0}, /* 0x02, Reserved */ | ||
90 | {0, 0}, /* 0x03, Reserved */ | ||
91 | {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq)}, /* ACPI_RDESC_TYPE_IRQ_FORMAT */ | ||
92 | {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma)}, /* ACPI_RDESC_TYPE_DMA_FORMAT */ | ||
93 | {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf)}, /* ACPI_RDESC_TYPE_START_DEPENDENT */ | ||
94 | {1, ACPI_RESOURCE_LENGTH}, /* ACPI_RDESC_TYPE_END_DEPENDENT */ | ||
95 | {8, ACPI_SIZEOF_RESOURCE(struct acpi_resource_io)}, /* ACPI_RDESC_TYPE_IO_PORT */ | ||
96 | {4, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io)}, /* ACPI_RDESC_TYPE_FIXED_IO_PORT */ | ||
97 | {0, 0}, /* 0x0A, Reserved */ | ||
98 | {0, 0}, /* 0x0B, Reserved */ | ||
99 | {0, 0}, /* 0x0C, Reserved */ | ||
100 | {0, 0}, /* 0x0D, Reserved */ | ||
101 | {1, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_SMALL_VENDOR */ | ||
102 | {2, ACPI_RESOURCE_LENGTH}, /* ACPI_RDESC_TYPE_END_TAG */ | ||
103 | }; | ||
104 | |||
105 | static struct acpi_resource_sizes acpi_gbl_lg_resource_sizes[] = { | ||
106 | {0, 0}, /* 0x00, Reserved */ | ||
107 | {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem24)}, /* ACPI_RDESC_TYPE_MEMORY_24 */ | ||
108 | {15, ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg)}, /* ACPI_RDESC_TYPE_GENERIC_REGISTER */ | ||
109 | {0, 0}, /* 0x03, Reserved */ | ||
110 | {3, ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, /* ACPI_RDESC_TYPE_LARGE_VENDOR */ | ||
111 | {20, ACPI_SIZEOF_RESOURCE(struct acpi_resource_mem32)}, /* ACPI_RDESC_TYPE_MEMORY_32 */ | ||
112 | {12, ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_mem32)}, /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */ | ||
113 | {26, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address32)}, /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */ | ||
114 | {16, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address16)}, /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */ | ||
115 | {9, ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq)}, /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */ | ||
116 | {46, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */ | ||
117 | {56, ACPI_SIZEOF_RESOURCE(struct acpi_resource_address64)}, /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */ | ||
118 | }; | ||
119 | |||
120 | /* Local prototypes */ | 52 | /* Local prototypes */ |
121 | |||
122 | static u8 acpi_rs_count_set_bits(u16 bit_field); | 53 | static u8 acpi_rs_count_set_bits(u16 bit_field); |
123 | 54 | ||
124 | static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type); | ||
125 | |||
126 | static u16 acpi_rs_get_resource_length(u8 * resource); | ||
127 | |||
128 | static acpi_size | 55 | static acpi_size |
129 | acpi_rs_struct_option_length(struct acpi_resource_source *resource_source); | 56 | acpi_rs_struct_option_length(struct acpi_resource_source *resource_source); |
130 | 57 | ||
@@ -161,90 +88,6 @@ static u8 acpi_rs_count_set_bits(u16 bit_field) | |||
161 | 88 | ||
162 | /******************************************************************************* | 89 | /******************************************************************************* |
163 | * | 90 | * |
164 | * FUNCTION: acpi_rs_get_resource_sizes | ||
165 | * | ||
166 | * PARAMETERS: resource_type - Byte 0 of a resource descriptor | ||
167 | * | ||
168 | * RETURN: Pointer to the resource conversion handler | ||
169 | * | ||
170 | * DESCRIPTION: Extract the Resource Type/Name from the first byte of | ||
171 | * a resource descriptor. | ||
172 | * | ||
173 | ******************************************************************************/ | ||
174 | |||
175 | static struct acpi_resource_sizes *acpi_rs_get_resource_sizes(u8 resource_type) | ||
176 | { | ||
177 | struct acpi_resource_sizes *size_info; | ||
178 | |||
179 | ACPI_FUNCTION_ENTRY(); | ||
180 | |||
181 | /* Determine if this is a small or large resource */ | ||
182 | |||
183 | if (resource_type & ACPI_RDESC_TYPE_LARGE) { | ||
184 | /* Large Resource Type -- bits 6:0 contain the name */ | ||
185 | |||
186 | if (resource_type > ACPI_RDESC_LARGE_MAX) { | ||
187 | return (NULL); | ||
188 | } | ||
189 | |||
190 | size_info = &acpi_gbl_lg_resource_sizes[(resource_type & | ||
191 | ACPI_RDESC_LARGE_MASK)]; | ||
192 | } else { | ||
193 | /* Small Resource Type -- bits 6:3 contain the name */ | ||
194 | |||
195 | size_info = &acpi_gbl_sm_resource_sizes[((resource_type & | ||
196 | ACPI_RDESC_SMALL_MASK) | ||
197 | >> 3)]; | ||
198 | } | ||
199 | |||
200 | /* Zero entry indicates an invalid resource type */ | ||
201 | |||
202 | if (!size_info->minimum_stream_size) { | ||
203 | return (NULL); | ||
204 | } | ||
205 | |||
206 | return (size_info); | ||
207 | } | ||
208 | |||
209 | /******************************************************************************* | ||
210 | * | ||
211 | * FUNCTION: acpi_rs_get_resource_length | ||
212 | * | ||
213 | * PARAMETERS: Resource - Pointer to the resource descriptor | ||
214 | * | ||
215 | * RETURN: Byte length of the (AML byte stream) descriptor. By definition, | ||
216 | * this does not include the size of the descriptor header and the | ||
217 | * length field itself. | ||
218 | * | ||
219 | * DESCRIPTION: Extract the length of a resource descriptor. | ||
220 | * | ||
221 | ******************************************************************************/ | ||
222 | |||
223 | static u16 acpi_rs_get_resource_length(u8 * resource) | ||
224 | { | ||
225 | u16 resource_length; | ||
226 | |||
227 | ACPI_FUNCTION_ENTRY(); | ||
228 | |||
229 | /* Determine if this is a small or large resource */ | ||
230 | |||
231 | if (*resource & ACPI_RDESC_TYPE_LARGE) { | ||
232 | /* Large Resource type -- length is in bytes 1-2 */ | ||
233 | |||
234 | ACPI_MOVE_16_TO_16(&resource_length, (resource + 1)); | ||
235 | |||
236 | } else { | ||
237 | /* Small Resource Type -- bits 2:0 of byte 0 contain the length */ | ||
238 | |||
239 | resource_length = | ||
240 | (u16) (*resource & ACPI_RDESC_SMALL_LENGTH_MASK); | ||
241 | } | ||
242 | |||
243 | return (resource_length); | ||
244 | } | ||
245 | |||
246 | /******************************************************************************* | ||
247 | * | ||
248 | * FUNCTION: acpi_rs_struct_option_length | 91 | * FUNCTION: acpi_rs_struct_option_length |
249 | * | 92 | * |
250 | * PARAMETERS: resource_source - Pointer to optional descriptor field | 93 | * PARAMETERS: resource_source - Pointer to optional descriptor field |
@@ -291,10 +134,10 @@ acpi_rs_struct_option_length(struct acpi_resource_source *resource_source) | |||
291 | ******************************************************************************/ | 134 | ******************************************************************************/ |
292 | 135 | ||
293 | static u32 | 136 | static u32 |
294 | acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) | 137 | acpi_rs_stream_option_length(u32 resource_length, |
138 | u32 minimum_aml_resource_length) | ||
295 | { | 139 | { |
296 | u32 string_length = 0; | 140 | u32 string_length = 0; |
297 | u32 minimum_resource_length; | ||
298 | 141 | ||
299 | ACPI_FUNCTION_ENTRY(); | 142 | ACPI_FUNCTION_ENTRY(); |
300 | 143 | ||
@@ -303,11 +146,6 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) | |||
303 | * Large-type resource descriptors. | 146 | * Large-type resource descriptors. |
304 | */ | 147 | */ |
305 | 148 | ||
306 | /* Compute minimum size of the data part of the resource descriptor */ | ||
307 | |||
308 | minimum_resource_length = | ||
309 | minimum_total_length - sizeof(struct asl_large_header); | ||
310 | |||
311 | /* | 149 | /* |
312 | * If the length of the actual resource descriptor is greater than the ACPI | 150 | * If the length of the actual resource descriptor is greater than the ACPI |
313 | * spec-defined minimum length, it means that a resource_source_index exists | 151 | * spec-defined minimum length, it means that a resource_source_index exists |
@@ -315,10 +153,11 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) | |||
315 | * (including the null terminator) is the resource length minus the minimum | 153 | * (including the null terminator) is the resource length minus the minimum |
316 | * length, minus one byte for the resource_source_index itself. | 154 | * length, minus one byte for the resource_source_index itself. |
317 | */ | 155 | */ |
318 | if (resource_length > minimum_resource_length) { | 156 | if (resource_length > minimum_aml_resource_length) { |
319 | /* Compute the length of the optional string */ | 157 | /* Compute the length of the optional string */ |
320 | 158 | ||
321 | string_length = resource_length - minimum_resource_length - 1; | 159 | string_length = |
160 | resource_length - minimum_aml_resource_length - 1; | ||
322 | } | 161 | } |
323 | 162 | ||
324 | /* Round up length to 32 bits for internal structure alignment */ | 163 | /* Round up length to 32 bits for internal structure alignment */ |
@@ -328,7 +167,7 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) | |||
328 | 167 | ||
329 | /******************************************************************************* | 168 | /******************************************************************************* |
330 | * | 169 | * |
331 | * FUNCTION: acpi_rs_get_byte_stream_length | 170 | * FUNCTION: acpi_rs_get_aml_length |
332 | * | 171 | * |
333 | * PARAMETERS: Resource - Pointer to the resource linked list | 172 | * PARAMETERS: Resource - Pointer to the resource linked list |
334 | * size_needed - Where the required size is returned | 173 | * size_needed - Where the required size is returned |
@@ -342,62 +181,62 @@ acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length) | |||
342 | ******************************************************************************/ | 181 | ******************************************************************************/ |
343 | 182 | ||
344 | acpi_status | 183 | acpi_status |
345 | acpi_rs_get_byte_stream_length(struct acpi_resource * resource, | 184 | acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) |
346 | acpi_size * size_needed) | ||
347 | { | 185 | { |
348 | acpi_size byte_stream_size_needed = 0; | 186 | acpi_size aml_size_needed = 0; |
349 | acpi_size segment_size; | 187 | acpi_size segment_size; |
350 | 188 | ||
351 | ACPI_FUNCTION_TRACE("rs_get_byte_stream_length"); | 189 | ACPI_FUNCTION_TRACE("rs_get_aml_length"); |
352 | 190 | ||
353 | /* Traverse entire list of internal resource descriptors */ | 191 | /* Traverse entire list of internal resource descriptors */ |
354 | 192 | ||
355 | while (resource) { | 193 | while (resource) { |
356 | /* Validate the descriptor type */ | 194 | /* Validate the descriptor type */ |
357 | 195 | ||
358 | if (resource->type > ACPI_RSTYPE_MAX) { | 196 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { |
359 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | 197 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); |
360 | } | 198 | } |
361 | 199 | ||
362 | /* Get the base size of the (external stream) resource descriptor */ | 200 | /* Get the base size of the (external stream) resource descriptor */ |
363 | 201 | ||
364 | segment_size = acpi_gbl_stream_sizes[resource->type]; | 202 | segment_size = acpi_gbl_aml_resource_sizes[resource->type]; |
365 | 203 | ||
366 | /* | 204 | /* |
367 | * Augment the base size for descriptors with optional and/or | 205 | * Augment the base size for descriptors with optional and/or |
368 | * variable-length fields | 206 | * variable-length fields |
369 | */ | 207 | */ |
370 | switch (resource->type) { | 208 | switch (resource->type) { |
371 | case ACPI_RSTYPE_VENDOR: | 209 | case ACPI_RESOURCE_TYPE_VENDOR: |
372 | /* | 210 | /* |
373 | * Vendor Defined Resource: | 211 | * Vendor Defined Resource: |
374 | * For a Vendor Specific resource, if the Length is between 1 and 7 | 212 | * For a Vendor Specific resource, if the Length is between 1 and 7 |
375 | * it will be created as a Small Resource data type, otherwise it | 213 | * it will be created as a Small Resource data type, otherwise it |
376 | * is a Large Resource data type. | 214 | * is a Large Resource data type. |
377 | */ | 215 | */ |
378 | if (resource->data.vendor_specific.length > 7) { | 216 | if (resource->data.vendor.byte_length > 7) { |
379 | /* Base size of a Large resource descriptor */ | 217 | /* Base size of a Large resource descriptor */ |
380 | 218 | ||
381 | segment_size = 3; | 219 | segment_size = |
220 | sizeof(struct aml_resource_large_header); | ||
382 | } | 221 | } |
383 | 222 | ||
384 | /* Add the size of the vendor-specific data */ | 223 | /* Add the size of the vendor-specific data */ |
385 | 224 | ||
386 | segment_size += resource->data.vendor_specific.length; | 225 | segment_size += resource->data.vendor.byte_length; |
387 | break; | 226 | break; |
388 | 227 | ||
389 | case ACPI_RSTYPE_END_TAG: | 228 | case ACPI_RESOURCE_TYPE_END_TAG: |
390 | /* | 229 | /* |
391 | * End Tag: | 230 | * End Tag: |
392 | * We are done -- return the accumulated total size. | 231 | * We are done -- return the accumulated total size. |
393 | */ | 232 | */ |
394 | *size_needed = byte_stream_size_needed + segment_size; | 233 | *size_needed = aml_size_needed + segment_size; |
395 | 234 | ||
396 | /* Normal exit */ | 235 | /* Normal exit */ |
397 | 236 | ||
398 | return_ACPI_STATUS(AE_OK); | 237 | return_ACPI_STATUS(AE_OK); |
399 | 238 | ||
400 | case ACPI_RSTYPE_ADDRESS16: | 239 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
401 | /* | 240 | /* |
402 | * 16-Bit Address Resource: | 241 | * 16-Bit Address Resource: |
403 | * Add the size of the optional resource_source info | 242 | * Add the size of the optional resource_source info |
@@ -408,7 +247,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, | |||
408 | resource_source); | 247 | resource_source); |
409 | break; | 248 | break; |
410 | 249 | ||
411 | case ACPI_RSTYPE_ADDRESS32: | 250 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
412 | /* | 251 | /* |
413 | * 32-Bit Address Resource: | 252 | * 32-Bit Address Resource: |
414 | * Add the size of the optional resource_source info | 253 | * Add the size of the optional resource_source info |
@@ -419,7 +258,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, | |||
419 | resource_source); | 258 | resource_source); |
420 | break; | 259 | break; |
421 | 260 | ||
422 | case ACPI_RSTYPE_ADDRESS64: | 261 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
423 | /* | 262 | /* |
424 | * 64-Bit Address Resource: | 263 | * 64-Bit Address Resource: |
425 | * Add the size of the optional resource_source info | 264 | * Add the size of the optional resource_source info |
@@ -430,7 +269,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, | |||
430 | resource_source); | 269 | resource_source); |
431 | break; | 270 | break; |
432 | 271 | ||
433 | case ACPI_RSTYPE_EXT_IRQ: | 272 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
434 | /* | 273 | /* |
435 | * Extended IRQ Resource: | 274 | * Extended IRQ Resource: |
436 | * Add the size of each additional optional interrupt beyond the | 275 | * Add the size of each additional optional interrupt beyond the |
@@ -438,7 +277,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, | |||
438 | */ | 277 | */ |
439 | segment_size += (((acpi_size) | 278 | segment_size += (((acpi_size) |
440 | resource->data.extended_irq. | 279 | resource->data.extended_irq. |
441 | number_of_interrupts - 1) * 4); | 280 | interrupt_count - 1) * 4); |
442 | 281 | ||
443 | /* Add the size of the optional resource_source info */ | 282 | /* Add the size of the optional resource_source info */ |
444 | 283 | ||
@@ -454,7 +293,7 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, | |||
454 | 293 | ||
455 | /* Update the total */ | 294 | /* Update the total */ |
456 | 295 | ||
457 | byte_stream_size_needed += segment_size; | 296 | aml_size_needed += segment_size; |
458 | 297 | ||
459 | /* Point to the next object */ | 298 | /* Point to the next object */ |
460 | 299 | ||
@@ -471,9 +310,9 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, | |||
471 | * | 310 | * |
472 | * FUNCTION: acpi_rs_get_list_length | 311 | * FUNCTION: acpi_rs_get_list_length |
473 | * | 312 | * |
474 | * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream | 313 | * PARAMETERS: aml_buffer - Pointer to the resource byte stream |
475 | * byte_stream_buffer_length - Size of byte_stream_buffer | 314 | * aml_buffer_length - Size of aml_buffer |
476 | * size_needed - Where the size needed is returned | 315 | * size_needed - Where the size needed is returned |
477 | * | 316 | * |
478 | * RETURN: Status | 317 | * RETURN: Status |
479 | * | 318 | * |
@@ -484,11 +323,11 @@ acpi_rs_get_byte_stream_length(struct acpi_resource * resource, | |||
484 | ******************************************************************************/ | 323 | ******************************************************************************/ |
485 | 324 | ||
486 | acpi_status | 325 | acpi_status |
487 | acpi_rs_get_list_length(u8 * byte_stream_buffer, | 326 | acpi_rs_get_list_length(u8 * aml_buffer, |
488 | u32 byte_stream_buffer_length, acpi_size * size_needed) | 327 | u32 aml_buffer_length, acpi_size * size_needed) |
489 | { | 328 | { |
490 | u8 *buffer; | 329 | u8 *buffer; |
491 | struct acpi_resource_sizes *resource_info; | 330 | struct acpi_resource_info *resource_info; |
492 | u32 buffer_size = 0; | 331 | u32 buffer_size = 0; |
493 | u32 bytes_parsed = 0; | 332 | u32 bytes_parsed = 0; |
494 | u8 resource_type; | 333 | u8 resource_type; |
@@ -499,14 +338,14 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
499 | 338 | ||
500 | ACPI_FUNCTION_TRACE("rs_get_list_length"); | 339 | ACPI_FUNCTION_TRACE("rs_get_list_length"); |
501 | 340 | ||
502 | while (bytes_parsed < byte_stream_buffer_length) { | 341 | while (bytes_parsed < aml_buffer_length) { |
503 | /* The next byte in the stream is the resource descriptor type */ | 342 | /* The next byte in the stream is the resource descriptor type */ |
504 | 343 | ||
505 | resource_type = acpi_rs_get_resource_type(*byte_stream_buffer); | 344 | resource_type = acpi_rs_get_resource_type(*aml_buffer); |
506 | 345 | ||
507 | /* Get the base stream size and structure sizes for the descriptor */ | 346 | /* Get the base stream size and structure sizes for the descriptor */ |
508 | 347 | ||
509 | resource_info = acpi_rs_get_resource_sizes(resource_type); | 348 | resource_info = acpi_rs_get_resource_info(resource_type); |
510 | if (!resource_info) { | 349 | if (!resource_info) { |
511 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | 350 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); |
512 | } | 351 | } |
@@ -514,43 +353,46 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
514 | /* Get the Length field from the input resource descriptor */ | 353 | /* Get the Length field from the input resource descriptor */ |
515 | 354 | ||
516 | resource_length = | 355 | resource_length = |
517 | acpi_rs_get_resource_length(byte_stream_buffer); | 356 | acpi_rs_get_resource_length(ACPI_CAST_PTR |
357 | (union aml_resource, | ||
358 | aml_buffer)); | ||
518 | 359 | ||
519 | /* Augment the size for descriptors with optional fields */ | 360 | /* Augment the size for descriptors with optional fields */ |
520 | 361 | ||
521 | extra_struct_bytes = 0; | 362 | extra_struct_bytes = 0; |
522 | 363 | ||
523 | if (!(resource_type & ACPI_RDESC_TYPE_LARGE)) { | 364 | if (!(resource_type & ACPI_RESOURCE_NAME_LARGE)) { |
524 | /* | 365 | /* |
525 | * Small resource descriptors | 366 | * Small resource descriptors |
526 | */ | 367 | */ |
527 | header_length = 1; | 368 | header_length = |
528 | buffer = byte_stream_buffer + header_length; | 369 | sizeof(struct aml_resource_small_header); |
370 | buffer = aml_buffer + header_length; | ||
529 | 371 | ||
530 | switch (resource_type) { | 372 | switch (resource_type) { |
531 | case ACPI_RDESC_TYPE_IRQ_FORMAT: | 373 | case ACPI_RESOURCE_NAME_IRQ: |
532 | /* | 374 | /* |
533 | * IRQ Resource: | 375 | * IRQ Resource: |
534 | * Get the number of bits set in the IRQ word | 376 | * Get the number of bits set in the IRQ word |
535 | */ | 377 | */ |
536 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 378 | ACPI_MOVE_16_TO_16(&temp16, buffer); |
537 | |||
538 | extra_struct_bytes = | 379 | extra_struct_bytes = |
539 | (acpi_rs_count_set_bits(temp16) * | 380 | (acpi_rs_count_set_bits(temp16) * |
540 | sizeof(u32)); | 381 | sizeof(u32)); |
541 | break; | 382 | break; |
542 | 383 | ||
543 | case ACPI_RDESC_TYPE_DMA_FORMAT: | 384 | case ACPI_RESOURCE_NAME_DMA: |
544 | /* | 385 | /* |
545 | * DMA Resource: | 386 | * DMA Resource: |
546 | * Get the number of bits set in the DMA channels byte | 387 | * Get the number of bits set in the DMA channels byte |
547 | */ | 388 | */ |
389 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
548 | extra_struct_bytes = | 390 | extra_struct_bytes = |
549 | (acpi_rs_count_set_bits((u16) * buffer) * | 391 | (acpi_rs_count_set_bits(temp16) * |
550 | sizeof(u32)); | 392 | sizeof(u32)); |
551 | break; | 393 | break; |
552 | 394 | ||
553 | case ACPI_RDESC_TYPE_SMALL_VENDOR: | 395 | case ACPI_RESOURCE_NAME_VENDOR_SMALL: |
554 | /* | 396 | /* |
555 | * Vendor Specific Resource: | 397 | * Vendor Specific Resource: |
556 | * Ensure a 32-bit boundary for the structure | 398 | * Ensure a 32-bit boundary for the structure |
@@ -559,12 +401,12 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
559 | ACPI_ROUND_UP_to_32_bITS(resource_length); | 401 | ACPI_ROUND_UP_to_32_bITS(resource_length); |
560 | break; | 402 | break; |
561 | 403 | ||
562 | case ACPI_RDESC_TYPE_END_TAG: | 404 | case ACPI_RESOURCE_NAME_END_TAG: |
563 | /* | 405 | /* |
564 | * End Tag: | 406 | * End Tag: |
565 | * Terminate the loop now | 407 | * Terminate the loop now |
566 | */ | 408 | */ |
567 | byte_stream_buffer_length = bytes_parsed; | 409 | aml_buffer_length = bytes_parsed; |
568 | break; | 410 | break; |
569 | 411 | ||
570 | default: | 412 | default: |
@@ -574,11 +416,12 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
574 | /* | 416 | /* |
575 | * Large resource descriptors | 417 | * Large resource descriptors |
576 | */ | 418 | */ |
577 | header_length = sizeof(struct asl_large_header); | 419 | header_length = |
578 | buffer = byte_stream_buffer + header_length; | 420 | sizeof(struct aml_resource_large_header); |
421 | buffer = aml_buffer + header_length; | ||
579 | 422 | ||
580 | switch (resource_type) { | 423 | switch (resource_type) { |
581 | case ACPI_RDESC_TYPE_LARGE_VENDOR: | 424 | case ACPI_RESOURCE_NAME_VENDOR_LARGE: |
582 | /* | 425 | /* |
583 | * Vendor Defined Resource: | 426 | * Vendor Defined Resource: |
584 | * Add vendor data and ensure a 32-bit boundary for the structure | 427 | * Add vendor data and ensure a 32-bit boundary for the structure |
@@ -587,8 +430,8 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
587 | ACPI_ROUND_UP_to_32_bITS(resource_length); | 430 | ACPI_ROUND_UP_to_32_bITS(resource_length); |
588 | break; | 431 | break; |
589 | 432 | ||
590 | case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: | 433 | case ACPI_RESOURCE_NAME_ADDRESS32: |
591 | case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: | 434 | case ACPI_RESOURCE_NAME_ADDRESS16: |
592 | /* | 435 | /* |
593 | * 32-Bit or 16-bit Address Resource: | 436 | * 32-Bit or 16-bit Address Resource: |
594 | * Add the size of any optional data (resource_source) | 437 | * Add the size of any optional data (resource_source) |
@@ -596,10 +439,11 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
596 | extra_struct_bytes = | 439 | extra_struct_bytes = |
597 | acpi_rs_stream_option_length | 440 | acpi_rs_stream_option_length |
598 | (resource_length, | 441 | (resource_length, |
599 | resource_info->minimum_stream_size); | 442 | resource_info-> |
443 | minimum_aml_resource_length); | ||
600 | break; | 444 | break; |
601 | 445 | ||
602 | case ACPI_RDESC_TYPE_EXTENDED_XRUPT: | 446 | case ACPI_RESOURCE_NAME_EXTENDED_IRQ: |
603 | /* | 447 | /* |
604 | * Extended IRQ: | 448 | * Extended IRQ: |
605 | * Point past the interrupt_vector_flags to get the | 449 | * Point past the interrupt_vector_flags to get the |
@@ -622,10 +466,10 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
622 | - | 466 | - |
623 | extra_struct_bytes, | 467 | extra_struct_bytes, |
624 | resource_info-> | 468 | resource_info-> |
625 | minimum_stream_size); | 469 | minimum_aml_resource_length); |
626 | break; | 470 | break; |
627 | 471 | ||
628 | case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: | 472 | case ACPI_RESOURCE_NAME_ADDRESS64: |
629 | /* | 473 | /* |
630 | * 64-Bit Address Resource: | 474 | * 64-Bit Address Resource: |
631 | * Add the size of any optional data (resource_source) | 475 | * Add the size of any optional data (resource_source) |
@@ -635,7 +479,8 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
635 | ACPI_ROUND_UP_to_64_bITS | 479 | ACPI_ROUND_UP_to_64_bITS |
636 | (acpi_rs_stream_option_length | 480 | (acpi_rs_stream_option_length |
637 | (resource_length, | 481 | (resource_length, |
638 | resource_info->minimum_stream_size)); | 482 | resource_info-> |
483 | minimum_aml_resource_length)); | ||
639 | break; | 484 | break; |
640 | 485 | ||
641 | default: | 486 | default: |
@@ -646,7 +491,7 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
646 | /* Update the required buffer size for the internal descriptor structs */ | 491 | /* Update the required buffer size for the internal descriptor structs */ |
647 | 492 | ||
648 | temp16 = | 493 | temp16 = |
649 | (u16) (resource_info->minimum_struct_size + | 494 | (u16) (resource_info->minimum_internal_struct_length + |
650 | extra_struct_bytes); | 495 | extra_struct_bytes); |
651 | buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); | 496 | buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); |
652 | 497 | ||
@@ -656,7 +501,7 @@ acpi_rs_get_list_length(u8 * byte_stream_buffer, | |||
656 | */ | 501 | */ |
657 | temp16 = (u16) (header_length + resource_length); | 502 | temp16 = (u16) (header_length + resource_length); |
658 | bytes_parsed += temp16; | 503 | bytes_parsed += temp16; |
659 | byte_stream_buffer += temp16; | 504 | aml_buffer += temp16; |
660 | } | 505 | } |
661 | 506 | ||
662 | /* This is the data the caller needs */ | 507 | /* This is the data the caller needs */ |
@@ -758,8 +603,7 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
758 | (*sub_object_list)->string. | 603 | (*sub_object_list)->string. |
759 | length + 1); | 604 | length + 1); |
760 | } else { | 605 | } else { |
761 | temp_size_needed += | 606 | temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node); |
762 | acpi_ns_get_pathname_length((*sub_object_list)->reference.node); | ||
763 | } | 607 | } |
764 | } else { | 608 | } else { |
765 | /* | 609 | /* |
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c index 0911526b7ad8..6c7c6c560635 100644 --- a/drivers/acpi/resources/rscreate.c +++ b/drivers/acpi/resources/rscreate.c | |||
@@ -53,10 +53,10 @@ ACPI_MODULE_NAME("rscreate") | |||
53 | * | 53 | * |
54 | * FUNCTION: acpi_rs_create_resource_list | 54 | * FUNCTION: acpi_rs_create_resource_list |
55 | * | 55 | * |
56 | * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream | 56 | * PARAMETERS: aml_buffer - Pointer to the resource byte stream |
57 | * output_buffer - Pointer to the user's buffer | 57 | * output_buffer - Pointer to the user's buffer |
58 | * | 58 | * |
59 | * RETURN: Status - AE_OK if okay, else a valid acpi_status code | 59 | * RETURN: Status: AE_OK if okay, else a valid acpi_status code |
60 | * If output_buffer is not large enough, output_buffer_length | 60 | * If output_buffer is not large enough, output_buffer_length |
61 | * indicates how large output_buffer should be, else it | 61 | * indicates how large output_buffer should be, else it |
62 | * indicates how may u8 elements of output_buffer are valid. | 62 | * indicates how may u8 elements of output_buffer are valid. |
@@ -67,33 +67,30 @@ ACPI_MODULE_NAME("rscreate") | |||
67 | * | 67 | * |
68 | ******************************************************************************/ | 68 | ******************************************************************************/ |
69 | acpi_status | 69 | acpi_status |
70 | acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, | 70 | acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer, |
71 | struct acpi_buffer *output_buffer) | 71 | struct acpi_buffer *output_buffer) |
72 | { | 72 | { |
73 | 73 | ||
74 | acpi_status status; | 74 | acpi_status status; |
75 | u8 *byte_stream_start; | 75 | u8 *aml_start; |
76 | acpi_size list_size_needed = 0; | 76 | acpi_size list_size_needed = 0; |
77 | u32 byte_stream_buffer_length; | 77 | u32 aml_buffer_length; |
78 | 78 | ||
79 | ACPI_FUNCTION_TRACE("rs_create_resource_list"); | 79 | ACPI_FUNCTION_TRACE("rs_create_resource_list"); |
80 | 80 | ||
81 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_buffer = %p\n", | 81 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_buffer = %p\n", aml_buffer)); |
82 | byte_stream_buffer)); | ||
83 | 82 | ||
84 | /* Params already validated, so we don't re-validate here */ | 83 | /* Params already validated, so we don't re-validate here */ |
85 | 84 | ||
86 | byte_stream_buffer_length = byte_stream_buffer->buffer.length; | 85 | aml_buffer_length = aml_buffer->buffer.length; |
87 | byte_stream_start = byte_stream_buffer->buffer.pointer; | 86 | aml_start = aml_buffer->buffer.pointer; |
88 | 87 | ||
89 | /* | 88 | /* |
90 | * Pass the byte_stream_buffer into a module that can calculate | 89 | * Pass the aml_buffer into a module that can calculate |
91 | * the buffer size needed for the linked list | 90 | * the buffer size needed for the linked list |
92 | */ | 91 | */ |
93 | status = | 92 | status = acpi_rs_get_list_length(aml_start, aml_buffer_length, |
94 | acpi_rs_get_list_length(byte_stream_start, | 93 | &list_size_needed); |
95 | byte_stream_buffer_length, | ||
96 | &list_size_needed); | ||
97 | 94 | ||
98 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", | 95 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Status=%X list_size_needed=%X\n", |
99 | status, (u32) list_size_needed)); | 96 | status, (u32) list_size_needed)); |
@@ -110,10 +107,8 @@ acpi_rs_create_resource_list(union acpi_operand_object *byte_stream_buffer, | |||
110 | 107 | ||
111 | /* Do the conversion */ | 108 | /* Do the conversion */ |
112 | 109 | ||
113 | status = | 110 | status = acpi_rs_convert_aml_to_resources(aml_start, aml_buffer_length, |
114 | acpi_rs_byte_stream_to_list(byte_stream_start, | 111 | output_buffer->pointer); |
115 | byte_stream_buffer_length, | ||
116 | output_buffer->pointer); | ||
117 | if (ACPI_FAILURE(status)) { | 112 | if (ACPI_FAILURE(status)) { |
118 | return_ACPI_STATUS(status); | 113 | return_ACPI_STATUS(status); |
119 | } | 114 | } |
@@ -360,7 +355,7 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
360 | 355 | ||
361 | /******************************************************************************* | 356 | /******************************************************************************* |
362 | * | 357 | * |
363 | * FUNCTION: acpi_rs_create_byte_stream | 358 | * FUNCTION: acpi_rs_create_aml_resources |
364 | * | 359 | * |
365 | * PARAMETERS: linked_list_buffer - Pointer to the resource linked list | 360 | * PARAMETERS: linked_list_buffer - Pointer to the resource linked list |
366 | * output_buffer - Pointer to the user's buffer | 361 | * output_buffer - Pointer to the user's buffer |
@@ -377,13 +372,13 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
377 | ******************************************************************************/ | 372 | ******************************************************************************/ |
378 | 373 | ||
379 | acpi_status | 374 | acpi_status |
380 | acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, | 375 | acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer, |
381 | struct acpi_buffer *output_buffer) | 376 | struct acpi_buffer *output_buffer) |
382 | { | 377 | { |
383 | acpi_status status; | 378 | acpi_status status; |
384 | acpi_size byte_stream_size_needed = 0; | 379 | acpi_size aml_size_needed = 0; |
385 | 380 | ||
386 | ACPI_FUNCTION_TRACE("rs_create_byte_stream"); | 381 | ACPI_FUNCTION_TRACE("rs_create_aml_resources"); |
387 | 382 | ||
388 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", | 383 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "linked_list_buffer = %p\n", |
389 | linked_list_buffer)); | 384 | linked_list_buffer)); |
@@ -394,11 +389,10 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, | |||
394 | * Pass the linked_list_buffer into a module that calculates | 389 | * Pass the linked_list_buffer into a module that calculates |
395 | * the buffer size needed for the byte stream. | 390 | * the buffer size needed for the byte stream. |
396 | */ | 391 | */ |
397 | status = acpi_rs_get_byte_stream_length(linked_list_buffer, | 392 | status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); |
398 | &byte_stream_size_needed); | ||
399 | 393 | ||
400 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "byte_stream_size_needed=%X, %s\n", | 394 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "aml_size_needed=%X, %s\n", |
401 | (u32) byte_stream_size_needed, | 395 | (u32) aml_size_needed, |
402 | acpi_format_exception(status))); | 396 | acpi_format_exception(status))); |
403 | if (ACPI_FAILURE(status)) { | 397 | if (ACPI_FAILURE(status)) { |
404 | return_ACPI_STATUS(status); | 398 | return_ACPI_STATUS(status); |
@@ -406,8 +400,7 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, | |||
406 | 400 | ||
407 | /* Validate/Allocate/Clear caller buffer */ | 401 | /* Validate/Allocate/Clear caller buffer */ |
408 | 402 | ||
409 | status = | 403 | status = acpi_ut_initialize_buffer(output_buffer, aml_size_needed); |
410 | acpi_ut_initialize_buffer(output_buffer, byte_stream_size_needed); | ||
411 | if (ACPI_FAILURE(status)) { | 404 | if (ACPI_FAILURE(status)) { |
412 | return_ACPI_STATUS(status); | 405 | return_ACPI_STATUS(status); |
413 | } | 406 | } |
@@ -415,9 +408,9 @@ acpi_rs_create_byte_stream(struct acpi_resource *linked_list_buffer, | |||
415 | /* Do the conversion */ | 408 | /* Do the conversion */ |
416 | 409 | ||
417 | status = | 410 | status = |
418 | acpi_rs_list_to_byte_stream(linked_list_buffer, | 411 | acpi_rs_convert_resources_to_aml(linked_list_buffer, |
419 | byte_stream_size_needed, | 412 | aml_size_needed, |
420 | output_buffer->pointer); | 413 | output_buffer->pointer); |
421 | if (ACPI_FAILURE(status)) { | 414 | if (ACPI_FAILURE(status)) { |
422 | return_ACPI_STATUS(status); | 415 | return_ACPI_STATUS(status); |
423 | } | 416 | } |
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c index 9d93ee5f0060..2f8990845b2d 100644 --- a/drivers/acpi/resources/rsdump.c +++ b/drivers/acpi/resources/rsdump.c | |||
@@ -49,38 +49,6 @@ ACPI_MODULE_NAME("rsdump") | |||
49 | 49 | ||
50 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) | 50 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) |
51 | /* Local prototypes */ | 51 | /* Local prototypes */ |
52 | static void acpi_rs_dump_irq(union acpi_resource_data *resource); | ||
53 | |||
54 | static void acpi_rs_dump_address16(union acpi_resource_data *resource); | ||
55 | |||
56 | static void acpi_rs_dump_address32(union acpi_resource_data *resource); | ||
57 | |||
58 | static void acpi_rs_dump_address64(union acpi_resource_data *resource); | ||
59 | |||
60 | static void acpi_rs_dump_dma(union acpi_resource_data *resource); | ||
61 | |||
62 | static void acpi_rs_dump_io(union acpi_resource_data *resource); | ||
63 | |||
64 | static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource); | ||
65 | |||
66 | static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource); | ||
67 | |||
68 | static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource); | ||
69 | |||
70 | static void acpi_rs_dump_memory24(union acpi_resource_data *resource); | ||
71 | |||
72 | static void acpi_rs_dump_memory32(union acpi_resource_data *resource); | ||
73 | |||
74 | static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource); | ||
75 | |||
76 | static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource); | ||
77 | |||
78 | static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource); | ||
79 | |||
80 | static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource); | ||
81 | |||
82 | static void acpi_rs_dump_end_tag(union acpi_resource_data *resource); | ||
83 | |||
84 | static void acpi_rs_out_string(char *title, char *value); | 52 | static void acpi_rs_out_string(char *title, char *value); |
85 | 53 | ||
86 | static void acpi_rs_out_integer8(char *title, u8 value); | 54 | static void acpi_rs_out_integer8(char *title, u8 value); |
@@ -104,30 +72,6 @@ acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source); | |||
104 | 72 | ||
105 | static void acpi_rs_dump_address_common(union acpi_resource_data *resource); | 73 | static void acpi_rs_dump_address_common(union acpi_resource_data *resource); |
106 | 74 | ||
107 | /* Dispatch table for resource dump functions */ | ||
108 | |||
109 | typedef | ||
110 | void (*ACPI_DUMP_RESOURCE) (union acpi_resource_data * data); | ||
111 | |||
112 | static ACPI_DUMP_RESOURCE acpi_gbl_dump_resource_dispatch[] = { | ||
113 | acpi_rs_dump_irq, /* ACPI_RSTYPE_IRQ */ | ||
114 | acpi_rs_dump_dma, /* ACPI_RSTYPE_DMA */ | ||
115 | acpi_rs_dump_start_depend_fns, /* ACPI_RSTYPE_START_DPF */ | ||
116 | acpi_rs_dump_end_depend_fns, /* ACPI_RSTYPE_END_DPF */ | ||
117 | acpi_rs_dump_io, /* ACPI_RSTYPE_IO */ | ||
118 | acpi_rs_dump_fixed_io, /* ACPI_RSTYPE_FIXED_IO */ | ||
119 | acpi_rs_dump_vendor_specific, /* ACPI_RSTYPE_VENDOR */ | ||
120 | acpi_rs_dump_end_tag, /* ACPI_RSTYPE_END_TAG */ | ||
121 | acpi_rs_dump_memory24, /* ACPI_RSTYPE_MEM24 */ | ||
122 | acpi_rs_dump_memory32, /* ACPI_RSTYPE_MEM32 */ | ||
123 | acpi_rs_dump_fixed_memory32, /* ACPI_RSTYPE_FIXED_MEM32 */ | ||
124 | acpi_rs_dump_address16, /* ACPI_RSTYPE_ADDRESS16 */ | ||
125 | acpi_rs_dump_address32, /* ACPI_RSTYPE_ADDRESS32 */ | ||
126 | acpi_rs_dump_address64, /* ACPI_RSTYPE_ADDRESS64 */ | ||
127 | acpi_rs_dump_extended_irq, /* ACPI_RSTYPE_EXT_IRQ */ | ||
128 | acpi_rs_dump_generic_reg /* ACPI_RSTYPE_GENERIC_REG */ | ||
129 | }; | ||
130 | |||
131 | /******************************************************************************* | 75 | /******************************************************************************* |
132 | * | 76 | * |
133 | * FUNCTION: acpi_rs_out* | 77 | * FUNCTION: acpi_rs_out* |
@@ -144,32 +88,32 @@ static ACPI_DUMP_RESOURCE acpi_gbl_dump_resource_dispatch[] = { | |||
144 | 88 | ||
145 | static void acpi_rs_out_string(char *title, char *value) | 89 | static void acpi_rs_out_string(char *title, char *value) |
146 | { | 90 | { |
147 | acpi_os_printf("%30s : %s\n", title, value); | 91 | acpi_os_printf("%27s : %s\n", title, value); |
148 | } | 92 | } |
149 | 93 | ||
150 | static void acpi_rs_out_integer8(char *title, u8 value) | 94 | static void acpi_rs_out_integer8(char *title, u8 value) |
151 | { | 95 | { |
152 | acpi_os_printf("%30s : %2.2X\n", title, value); | 96 | acpi_os_printf("%27s : %2.2X\n", title, value); |
153 | } | 97 | } |
154 | 98 | ||
155 | static void acpi_rs_out_integer16(char *title, u16 value) | 99 | static void acpi_rs_out_integer16(char *title, u16 value) |
156 | { | 100 | { |
157 | acpi_os_printf("%30s : %4.4X\n", title, value); | 101 | acpi_os_printf("%27s : %4.4X\n", title, value); |
158 | } | 102 | } |
159 | 103 | ||
160 | static void acpi_rs_out_integer32(char *title, u32 value) | 104 | static void acpi_rs_out_integer32(char *title, u32 value) |
161 | { | 105 | { |
162 | acpi_os_printf("%30s : %8.8X\n", title, value); | 106 | acpi_os_printf("%27s : %8.8X\n", title, value); |
163 | } | 107 | } |
164 | 108 | ||
165 | static void acpi_rs_out_integer64(char *title, u64 value) | 109 | static void acpi_rs_out_integer64(char *title, u64 value) |
166 | { | 110 | { |
167 | acpi_os_printf("%30s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); | 111 | acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value)); |
168 | } | 112 | } |
169 | 113 | ||
170 | static void acpi_rs_out_title(char *title) | 114 | static void acpi_rs_out_title(char *title) |
171 | { | 115 | { |
172 | acpi_os_printf("%30s : ", title); | 116 | acpi_os_printf("%27s : ", title); |
173 | } | 117 | } |
174 | 118 | ||
175 | /******************************************************************************* | 119 | /******************************************************************************* |
@@ -190,7 +134,7 @@ static void acpi_rs_dump_byte_list(u32 length, u8 * data) | |||
190 | u32 i; | 134 | u32 i; |
191 | 135 | ||
192 | for (i = 0; i < length; i++) { | 136 | for (i = 0; i < length; i++) { |
193 | acpi_os_printf("%28s%2.2X : %2.2X\n", "Byte", i, data[i]); | 137 | acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]); |
194 | } | 138 | } |
195 | } | 139 | } |
196 | 140 | ||
@@ -199,7 +143,7 @@ static void acpi_rs_dump_dword_list(u32 length, u32 * data) | |||
199 | u32 i; | 143 | u32 i; |
200 | 144 | ||
201 | for (i = 0; i < length; i++) { | 145 | for (i = 0; i < length; i++) { |
202 | acpi_os_printf("%28s%2.2X : %8.8X\n", "Dword", i, data[i]); | 146 | acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]); |
203 | } | 147 | } |
204 | } | 148 | } |
205 | 149 | ||
@@ -213,6 +157,14 @@ static void acpi_rs_dump_short_byte_list(u32 length, u32 * data) | |||
213 | acpi_os_printf("\n"); | 157 | acpi_os_printf("\n"); |
214 | } | 158 | } |
215 | 159 | ||
160 | static void acpi_rs_dump_memory_attribute(u32 read_write_attribute) | ||
161 | { | ||
162 | |||
163 | acpi_rs_out_string("Read/Write Attribute", | ||
164 | ACPI_READ_WRITE_MEMORY == read_write_attribute ? | ||
165 | "Read/Write" : "Read-Only"); | ||
166 | } | ||
167 | |||
216 | /******************************************************************************* | 168 | /******************************************************************************* |
217 | * | 169 | * |
218 | * FUNCTION: acpi_rs_dump_resource_source | 170 | * FUNCTION: acpi_rs_dump_resource_source |
@@ -229,6 +181,7 @@ static void acpi_rs_dump_short_byte_list(u32 length, u32 * data) | |||
229 | static void | 181 | static void |
230 | acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source) | 182 | acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source) |
231 | { | 183 | { |
184 | ACPI_FUNCTION_ENTRY(); | ||
232 | 185 | ||
233 | if (resource_source->index == 0xFF) { | 186 | if (resource_source->index == 0xFF) { |
234 | return; | 187 | return; |
@@ -290,11 +243,8 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource) | |||
290 | break; | 243 | break; |
291 | } | 244 | } |
292 | 245 | ||
293 | acpi_rs_out_string("Read/Write Attribute", | 246 | acpi_rs_dump_memory_attribute(resource->address.attribute. |
294 | ACPI_READ_WRITE_MEMORY == | 247 | memory.read_write_attribute); |
295 | resource->address.attribute.memory. | ||
296 | read_write_attribute ? "Read/Write" : | ||
297 | "Read Only"); | ||
298 | break; | 248 | break; |
299 | 249 | ||
300 | case ACPI_IO_RANGE: | 250 | case ACPI_IO_RANGE: |
@@ -392,7 +342,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) | |||
392 | 342 | ||
393 | /* Validate Type before dispatch */ | 343 | /* Validate Type before dispatch */ |
394 | 344 | ||
395 | if (resource_list->type > ACPI_RSTYPE_MAX) { | 345 | if (resource_list->type > ACPI_RESOURCE_TYPE_MAX) { |
396 | acpi_os_printf | 346 | acpi_os_printf |
397 | ("Invalid descriptor type (%X) in resource list\n", | 347 | ("Invalid descriptor type (%X) in resource list\n", |
398 | resource_list->type); | 348 | resource_list->type); |
@@ -406,7 +356,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) | |||
406 | 356 | ||
407 | /* Exit on end tag */ | 357 | /* Exit on end tag */ |
408 | 358 | ||
409 | if (resource_list->type == ACPI_RSTYPE_END_TAG) { | 359 | if (resource_list->type == ACPI_RESOURCE_TYPE_END_TAG) { |
410 | return; | 360 | return; |
411 | } | 361 | } |
412 | 362 | ||
@@ -431,7 +381,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) | |||
431 | * | 381 | * |
432 | ******************************************************************************/ | 382 | ******************************************************************************/ |
433 | 383 | ||
434 | static void acpi_rs_dump_irq(union acpi_resource_data *resource) | 384 | void acpi_rs_dump_irq(union acpi_resource_data *resource) |
435 | { | 385 | { |
436 | ACPI_FUNCTION_ENTRY(); | 386 | ACPI_FUNCTION_ENTRY(); |
437 | 387 | ||
@@ -439,22 +389,21 @@ static void acpi_rs_dump_irq(union acpi_resource_data *resource) | |||
439 | 389 | ||
440 | acpi_rs_out_string("Triggering", | 390 | acpi_rs_out_string("Triggering", |
441 | ACPI_LEVEL_SENSITIVE == | 391 | ACPI_LEVEL_SENSITIVE == |
442 | resource->irq.edge_level ? "Level" : "Edge"); | 392 | resource->irq.triggering ? "Level" : "Edge"); |
443 | 393 | ||
444 | acpi_rs_out_string("Active", | 394 | acpi_rs_out_string("Active", |
445 | ACPI_ACTIVE_LOW == | 395 | ACPI_ACTIVE_LOW == |
446 | resource->irq.active_high_low ? "Low" : "High"); | 396 | resource->irq.polarity ? "Low" : "High"); |
447 | 397 | ||
448 | acpi_rs_out_string("Sharing", | 398 | acpi_rs_out_string("Sharing", |
449 | ACPI_SHARED == | 399 | ACPI_SHARED == |
450 | resource->irq. | 400 | resource->irq.sharable ? "Shared" : "Exclusive"); |
451 | shared_exclusive ? "Shared" : "Exclusive"); | ||
452 | 401 | ||
453 | acpi_rs_out_integer8("Interrupt Count", | 402 | acpi_rs_out_integer8("Interrupt Count", |
454 | (u8) resource->irq.number_of_interrupts); | 403 | (u8) resource->irq.interrupt_count); |
455 | 404 | ||
456 | acpi_rs_out_title("Interrupt List"); | 405 | acpi_rs_out_title("Interrupt List"); |
457 | acpi_rs_dump_short_byte_list(resource->irq.number_of_interrupts, | 406 | acpi_rs_dump_short_byte_list(resource->irq.interrupt_count, |
458 | resource->irq.interrupts); | 407 | resource->irq.interrupts); |
459 | } | 408 | } |
460 | 409 | ||
@@ -470,7 +419,7 @@ static void acpi_rs_dump_irq(union acpi_resource_data *resource) | |||
470 | * | 419 | * |
471 | ******************************************************************************/ | 420 | ******************************************************************************/ |
472 | 421 | ||
473 | static void acpi_rs_dump_dma(union acpi_resource_data *resource) | 422 | void acpi_rs_dump_dma(union acpi_resource_data *resource) |
474 | { | 423 | { |
475 | ACPI_FUNCTION_ENTRY(); | 424 | ACPI_FUNCTION_ENTRY(); |
476 | 425 | ||
@@ -523,16 +472,16 @@ static void acpi_rs_dump_dma(union acpi_resource_data *resource) | |||
523 | } | 472 | } |
524 | 473 | ||
525 | acpi_rs_out_integer8("DMA Channel Count", | 474 | acpi_rs_out_integer8("DMA Channel Count", |
526 | (u8) resource->dma.number_of_channels); | 475 | (u8) resource->dma.channel_count); |
527 | 476 | ||
528 | acpi_rs_out_title("Channel List"); | 477 | acpi_rs_out_title("Channel List"); |
529 | acpi_rs_dump_short_byte_list(resource->dma.number_of_channels, | 478 | acpi_rs_dump_short_byte_list(resource->dma.channel_count, |
530 | resource->dma.channels); | 479 | resource->dma.channels); |
531 | } | 480 | } |
532 | 481 | ||
533 | /******************************************************************************* | 482 | /******************************************************************************* |
534 | * | 483 | * |
535 | * FUNCTION: acpi_rs_dump_start_depend_fns | 484 | * FUNCTION: acpi_rs_dump_start_dpf |
536 | * | 485 | * |
537 | * PARAMETERS: Resource - Pointer to an internal resource descriptor | 486 | * PARAMETERS: Resource - Pointer to an internal resource descriptor |
538 | * | 487 | * |
@@ -542,7 +491,7 @@ static void acpi_rs_dump_dma(union acpi_resource_data *resource) | |||
542 | * | 491 | * |
543 | ******************************************************************************/ | 492 | ******************************************************************************/ |
544 | 493 | ||
545 | static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource) | 494 | void acpi_rs_dump_start_dpf(union acpi_resource_data *resource) |
546 | { | 495 | { |
547 | ACPI_FUNCTION_ENTRY(); | 496 | ACPI_FUNCTION_ENTRY(); |
548 | 497 | ||
@@ -600,7 +549,7 @@ static void acpi_rs_dump_start_depend_fns(union acpi_resource_data *resource) | |||
600 | * | 549 | * |
601 | ******************************************************************************/ | 550 | ******************************************************************************/ |
602 | 551 | ||
603 | static void acpi_rs_dump_io(union acpi_resource_data *resource) | 552 | void acpi_rs_dump_io(union acpi_resource_data *resource) |
604 | { | 553 | { |
605 | ACPI_FUNCTION_ENTRY(); | 554 | ACPI_FUNCTION_ENTRY(); |
606 | 555 | ||
@@ -610,15 +559,13 @@ static void acpi_rs_dump_io(union acpi_resource_data *resource) | |||
610 | ACPI_DECODE_16 == | 559 | ACPI_DECODE_16 == |
611 | resource->io.io_decode ? "16-bit" : "10-bit"); | 560 | resource->io.io_decode ? "16-bit" : "10-bit"); |
612 | 561 | ||
613 | acpi_rs_out_integer32("Range Minimum Base", | 562 | acpi_rs_out_integer32("Address Minimum", resource->io.minimum); |
614 | resource->io.min_base_address); | ||
615 | 563 | ||
616 | acpi_rs_out_integer32("Range Maximum Base", | 564 | acpi_rs_out_integer32("Address Maximum", resource->io.maximum); |
617 | resource->io.max_base_address); | ||
618 | 565 | ||
619 | acpi_rs_out_integer32("Alignment", resource->io.alignment); | 566 | acpi_rs_out_integer32("Alignment", resource->io.alignment); |
620 | 567 | ||
621 | acpi_rs_out_integer32("Range Length", resource->io.range_length); | 568 | acpi_rs_out_integer32("Address Length", resource->io.address_length); |
622 | } | 569 | } |
623 | 570 | ||
624 | /******************************************************************************* | 571 | /******************************************************************************* |
@@ -633,21 +580,21 @@ static void acpi_rs_dump_io(union acpi_resource_data *resource) | |||
633 | * | 580 | * |
634 | ******************************************************************************/ | 581 | ******************************************************************************/ |
635 | 582 | ||
636 | static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) | 583 | void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) |
637 | { | 584 | { |
638 | ACPI_FUNCTION_ENTRY(); | 585 | ACPI_FUNCTION_ENTRY(); |
639 | 586 | ||
640 | acpi_os_printf("Fixed I/O Resource\n"); | 587 | acpi_os_printf("Fixed I/O Resource\n"); |
641 | 588 | ||
642 | acpi_rs_out_integer32("Range Base Address", | 589 | acpi_rs_out_integer32("Address", resource->fixed_io.address); |
643 | resource->fixed_io.base_address); | ||
644 | 590 | ||
645 | acpi_rs_out_integer32("Range Length", resource->fixed_io.range_length); | 591 | acpi_rs_out_integer32("Address Length", |
592 | resource->fixed_io.address_length); | ||
646 | } | 593 | } |
647 | 594 | ||
648 | /******************************************************************************* | 595 | /******************************************************************************* |
649 | * | 596 | * |
650 | * FUNCTION: acpi_rs_dump_vendor_specific | 597 | * FUNCTION: acpi_rs_dump_vendor |
651 | * | 598 | * |
652 | * PARAMETERS: Resource - Pointer to an internal resource descriptor | 599 | * PARAMETERS: Resource - Pointer to an internal resource descriptor |
653 | * | 600 | * |
@@ -657,16 +604,16 @@ static void acpi_rs_dump_fixed_io(union acpi_resource_data *resource) | |||
657 | * | 604 | * |
658 | ******************************************************************************/ | 605 | ******************************************************************************/ |
659 | 606 | ||
660 | static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource) | 607 | void acpi_rs_dump_vendor(union acpi_resource_data *resource) |
661 | { | 608 | { |
662 | ACPI_FUNCTION_ENTRY(); | 609 | ACPI_FUNCTION_ENTRY(); |
663 | 610 | ||
664 | acpi_os_printf("Vendor Specific Resource\n"); | 611 | acpi_os_printf("Vendor Specific Resource\n"); |
665 | 612 | ||
666 | acpi_rs_out_integer16("Length", (u16) resource->vendor_specific.length); | 613 | acpi_rs_out_integer16("Length", (u16) resource->vendor.byte_length); |
667 | 614 | ||
668 | acpi_rs_dump_byte_list(resource->vendor_specific.length, | 615 | acpi_rs_dump_byte_list(resource->vendor.byte_length, |
669 | resource->vendor_specific.reserved); | 616 | resource->vendor.byte_data); |
670 | } | 617 | } |
671 | 618 | ||
672 | /******************************************************************************* | 619 | /******************************************************************************* |
@@ -681,27 +628,24 @@ static void acpi_rs_dump_vendor_specific(union acpi_resource_data *resource) | |||
681 | * | 628 | * |
682 | ******************************************************************************/ | 629 | ******************************************************************************/ |
683 | 630 | ||
684 | static void acpi_rs_dump_memory24(union acpi_resource_data *resource) | 631 | void acpi_rs_dump_memory24(union acpi_resource_data *resource) |
685 | { | 632 | { |
686 | ACPI_FUNCTION_ENTRY(); | 633 | ACPI_FUNCTION_ENTRY(); |
687 | 634 | ||
688 | acpi_os_printf("24-Bit Memory Range Resource\n"); | 635 | acpi_os_printf("24-Bit Memory Range Resource\n"); |
689 | 636 | ||
690 | acpi_rs_out_string("Attribute", | 637 | acpi_rs_dump_memory_attribute(resource->memory24.read_write_attribute); |
691 | ACPI_READ_WRITE_MEMORY == | ||
692 | resource->memory24.read_write_attribute ? | ||
693 | "Read/Write" : "Read Only"); | ||
694 | 638 | ||
695 | acpi_rs_out_integer16("Range Minimum Base", | 639 | acpi_rs_out_integer16("Address Minimum", |
696 | (u16) resource->memory24.min_base_address); | 640 | (u16) resource->memory24.minimum); |
697 | 641 | ||
698 | acpi_rs_out_integer16("Range Maximum Base", | 642 | acpi_rs_out_integer16("Address Maximum", |
699 | (u16) resource->memory24.max_base_address); | 643 | (u16) resource->memory24.maximum); |
700 | 644 | ||
701 | acpi_rs_out_integer16("Alignment", (u16) resource->memory24.alignment); | 645 | acpi_rs_out_integer16("Alignment", (u16) resource->memory24.alignment); |
702 | 646 | ||
703 | acpi_rs_out_integer16("Range Length", | 647 | acpi_rs_out_integer16("Address Length", |
704 | (u16) resource->memory24.range_length); | 648 | (u16) resource->memory24.address_length); |
705 | } | 649 | } |
706 | 650 | ||
707 | /******************************************************************************* | 651 | /******************************************************************************* |
@@ -716,26 +660,22 @@ static void acpi_rs_dump_memory24(union acpi_resource_data *resource) | |||
716 | * | 660 | * |
717 | ******************************************************************************/ | 661 | ******************************************************************************/ |
718 | 662 | ||
719 | static void acpi_rs_dump_memory32(union acpi_resource_data *resource) | 663 | void acpi_rs_dump_memory32(union acpi_resource_data *resource) |
720 | { | 664 | { |
721 | ACPI_FUNCTION_ENTRY(); | 665 | ACPI_FUNCTION_ENTRY(); |
722 | 666 | ||
723 | acpi_os_printf("32-Bit Memory Range Resource\n"); | 667 | acpi_os_printf("32-Bit Memory Range Resource\n"); |
724 | 668 | ||
725 | acpi_rs_out_string("Attribute", | 669 | acpi_rs_dump_memory_attribute(resource->memory32.read_write_attribute); |
726 | ACPI_READ_WRITE_MEMORY == | ||
727 | resource->memory32.read_write_attribute ? | ||
728 | "Read/Write" : "Read Only"); | ||
729 | 670 | ||
730 | acpi_rs_out_integer32("Range Minimum Base", | 671 | acpi_rs_out_integer32("Address Minimum", resource->memory32.minimum); |
731 | resource->memory32.min_base_address); | ||
732 | 672 | ||
733 | acpi_rs_out_integer32("Range Maximum Base", | 673 | acpi_rs_out_integer32("Address Maximum", resource->memory32.maximum); |
734 | resource->memory32.max_base_address); | ||
735 | 674 | ||
736 | acpi_rs_out_integer32("Alignment", resource->memory32.alignment); | 675 | acpi_rs_out_integer32("Alignment", resource->memory32.alignment); |
737 | 676 | ||
738 | acpi_rs_out_integer32("Range Length", resource->memory32.range_length); | 677 | acpi_rs_out_integer32("Address Length", |
678 | resource->memory32.address_length); | ||
739 | } | 679 | } |
740 | 680 | ||
741 | /******************************************************************************* | 681 | /******************************************************************************* |
@@ -750,22 +690,19 @@ static void acpi_rs_dump_memory32(union acpi_resource_data *resource) | |||
750 | * | 690 | * |
751 | ******************************************************************************/ | 691 | ******************************************************************************/ |
752 | 692 | ||
753 | static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) | 693 | void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) |
754 | { | 694 | { |
755 | ACPI_FUNCTION_ENTRY(); | 695 | ACPI_FUNCTION_ENTRY(); |
756 | 696 | ||
757 | acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n"); | 697 | acpi_os_printf("32-Bit Fixed Location Memory Range Resource\n"); |
758 | 698 | ||
759 | acpi_rs_out_string("Attribute", | 699 | acpi_rs_dump_memory_attribute(resource->fixed_memory32. |
760 | ACPI_READ_WRITE_MEMORY == | 700 | read_write_attribute); |
761 | resource->fixed_memory32.read_write_attribute ? | ||
762 | "Read/Write" : "Read Only"); | ||
763 | 701 | ||
764 | acpi_rs_out_integer32("Range Base Address", | 702 | acpi_rs_out_integer32("Address", resource->fixed_memory32.address); |
765 | resource->fixed_memory32.range_base_address); | ||
766 | 703 | ||
767 | acpi_rs_out_integer32("Range Length", | 704 | acpi_rs_out_integer32("Address Length", |
768 | resource->fixed_memory32.range_length); | 705 | resource->fixed_memory32.address_length); |
769 | } | 706 | } |
770 | 707 | ||
771 | /******************************************************************************* | 708 | /******************************************************************************* |
@@ -780,26 +717,25 @@ static void acpi_rs_dump_fixed_memory32(union acpi_resource_data *resource) | |||
780 | * | 717 | * |
781 | ******************************************************************************/ | 718 | ******************************************************************************/ |
782 | 719 | ||
783 | static void acpi_rs_dump_address16(union acpi_resource_data *resource) | 720 | void acpi_rs_dump_address16(union acpi_resource_data *resource) |
784 | { | 721 | { |
785 | ACPI_FUNCTION_ENTRY(); | 722 | ACPI_FUNCTION_ENTRY(); |
786 | 723 | ||
787 | acpi_os_printf("16-Bit Address Space Resource\n"); | 724 | acpi_os_printf("16-Bit WORD Address Space Resource\n"); |
788 | 725 | ||
789 | acpi_rs_dump_address_common(resource); | 726 | acpi_rs_dump_address_common(resource); |
790 | 727 | ||
791 | acpi_rs_out_integer16("Granularity", | 728 | acpi_rs_out_integer16("Granularity", |
792 | (u16) resource->address16.granularity); | 729 | (u16) resource->address16.granularity); |
793 | 730 | ||
794 | acpi_rs_out_integer16("Address Range Min", | 731 | acpi_rs_out_integer16("Address Minimum", |
795 | (u16) resource->address16.min_address_range); | 732 | (u16) resource->address16.minimum); |
796 | 733 | ||
797 | acpi_rs_out_integer16("Address Range Max", | 734 | acpi_rs_out_integer16("Address Maximum", |
798 | (u16) resource->address16.max_address_range); | 735 | (u16) resource->address16.maximum); |
799 | 736 | ||
800 | acpi_rs_out_integer16("Address Translation Offset", | 737 | acpi_rs_out_integer16("Translation Offset", |
801 | (u16) resource->address16. | 738 | (u16) resource->address16.translation_offset); |
802 | address_translation_offset); | ||
803 | 739 | ||
804 | acpi_rs_out_integer16("Address Length", | 740 | acpi_rs_out_integer16("Address Length", |
805 | (u16) resource->address16.address_length); | 741 | (u16) resource->address16.address_length); |
@@ -819,24 +755,22 @@ static void acpi_rs_dump_address16(union acpi_resource_data *resource) | |||
819 | * | 755 | * |
820 | ******************************************************************************/ | 756 | ******************************************************************************/ |
821 | 757 | ||
822 | static void acpi_rs_dump_address32(union acpi_resource_data *resource) | 758 | void acpi_rs_dump_address32(union acpi_resource_data *resource) |
823 | { | 759 | { |
824 | ACPI_FUNCTION_ENTRY(); | 760 | ACPI_FUNCTION_ENTRY(); |
825 | 761 | ||
826 | acpi_os_printf("32-Bit Address Space Resource\n"); | 762 | acpi_os_printf("32-Bit DWORD Address Space Resource\n"); |
827 | 763 | ||
828 | acpi_rs_dump_address_common(resource); | 764 | acpi_rs_dump_address_common(resource); |
829 | 765 | ||
830 | acpi_rs_out_integer32("Granularity", resource->address32.granularity); | 766 | acpi_rs_out_integer32("Granularity", resource->address32.granularity); |
831 | 767 | ||
832 | acpi_rs_out_integer32("Address Range Min", | 768 | acpi_rs_out_integer32("Address Minimum", resource->address32.minimum); |
833 | resource->address32.min_address_range); | ||
834 | 769 | ||
835 | acpi_rs_out_integer32("Address Range Max", | 770 | acpi_rs_out_integer32("Address Maximum", resource->address32.maximum); |
836 | resource->address32.max_address_range); | ||
837 | 771 | ||
838 | acpi_rs_out_integer32("Address Translation Offset", | 772 | acpi_rs_out_integer32("Translation Offset", |
839 | resource->address32.address_translation_offset); | 773 | resource->address32.translation_offset); |
840 | 774 | ||
841 | acpi_rs_out_integer32("Address Length", | 775 | acpi_rs_out_integer32("Address Length", |
842 | resource->address32.address_length); | 776 | resource->address32.address_length); |
@@ -856,37 +790,32 @@ static void acpi_rs_dump_address32(union acpi_resource_data *resource) | |||
856 | * | 790 | * |
857 | ******************************************************************************/ | 791 | ******************************************************************************/ |
858 | 792 | ||
859 | static void acpi_rs_dump_address64(union acpi_resource_data *resource) | 793 | void acpi_rs_dump_address64(union acpi_resource_data *resource) |
860 | { | 794 | { |
861 | ACPI_FUNCTION_ENTRY(); | 795 | ACPI_FUNCTION_ENTRY(); |
862 | 796 | ||
863 | acpi_os_printf("64-Bit Address Space Resource\n"); | 797 | acpi_os_printf("64-Bit QWORD Address Space Resource\n"); |
864 | 798 | ||
865 | acpi_rs_dump_address_common(resource); | 799 | acpi_rs_dump_address_common(resource); |
866 | 800 | ||
867 | acpi_rs_out_integer64("Granularity", resource->address64.granularity); | 801 | acpi_rs_out_integer64("Granularity", resource->address64.granularity); |
868 | 802 | ||
869 | acpi_rs_out_integer64("Address Range Min", | 803 | acpi_rs_out_integer64("Address Minimum", resource->address64.minimum); |
870 | resource->address64.min_address_range); | ||
871 | 804 | ||
872 | acpi_rs_out_integer64("Address Range Max", | 805 | acpi_rs_out_integer64("Address Maximum", resource->address64.maximum); |
873 | resource->address64.max_address_range); | ||
874 | 806 | ||
875 | acpi_rs_out_integer64("Address Translation Offset", | 807 | acpi_rs_out_integer64("Translation Offset", |
876 | resource->address64.address_translation_offset); | 808 | resource->address64.translation_offset); |
877 | 809 | ||
878 | acpi_rs_out_integer64("Address Length", | 810 | acpi_rs_out_integer64("Address Length", |
879 | resource->address64.address_length); | 811 | resource->address64.address_length); |
880 | 812 | ||
881 | acpi_rs_out_integer64("Type Specific Attributes", | ||
882 | resource->address64.type_specific_attributes); | ||
883 | |||
884 | acpi_rs_dump_resource_source(&resource->address64.resource_source); | 813 | acpi_rs_dump_resource_source(&resource->address64.resource_source); |
885 | } | 814 | } |
886 | 815 | ||
887 | /******************************************************************************* | 816 | /******************************************************************************* |
888 | * | 817 | * |
889 | * FUNCTION: acpi_rs_dump_extended_irq | 818 | * FUNCTION: acpi_rs_dump_ext_address64 |
890 | * | 819 | * |
891 | * PARAMETERS: Resource - Pointer to an internal resource descriptor | 820 | * PARAMETERS: Resource - Pointer to an internal resource descriptor |
892 | * | 821 | * |
@@ -896,7 +825,46 @@ static void acpi_rs_dump_address64(union acpi_resource_data *resource) | |||
896 | * | 825 | * |
897 | ******************************************************************************/ | 826 | ******************************************************************************/ |
898 | 827 | ||
899 | static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource) | 828 | void acpi_rs_dump_ext_address64(union acpi_resource_data *resource) |
829 | { | ||
830 | ACPI_FUNCTION_ENTRY(); | ||
831 | |||
832 | acpi_os_printf("64-Bit Extended Address Space Resource\n"); | ||
833 | |||
834 | acpi_rs_dump_address_common(resource); | ||
835 | |||
836 | acpi_rs_out_integer64("Granularity", | ||
837 | resource->ext_address64.granularity); | ||
838 | |||
839 | acpi_rs_out_integer64("Address Minimum", | ||
840 | resource->ext_address64.minimum); | ||
841 | |||
842 | acpi_rs_out_integer64("Address Maximum", | ||
843 | resource->ext_address64.maximum); | ||
844 | |||
845 | acpi_rs_out_integer64("Translation Offset", | ||
846 | resource->ext_address64.translation_offset); | ||
847 | |||
848 | acpi_rs_out_integer64("Address Length", | ||
849 | resource->ext_address64.address_length); | ||
850 | |||
851 | acpi_rs_out_integer64("Type-Specific Attribute", | ||
852 | resource->ext_address64.type_specific_attributes); | ||
853 | } | ||
854 | |||
855 | /******************************************************************************* | ||
856 | * | ||
857 | * FUNCTION: acpi_rs_dump_ext_irq | ||
858 | * | ||
859 | * PARAMETERS: Resource - Pointer to an internal resource descriptor | ||
860 | * | ||
861 | * RETURN: None | ||
862 | * | ||
863 | * DESCRIPTION: Dump the field names and values of the resource descriptor | ||
864 | * | ||
865 | ******************************************************************************/ | ||
866 | |||
867 | void acpi_rs_dump_ext_irq(union acpi_resource_data *resource) | ||
900 | { | 868 | { |
901 | ACPI_FUNCTION_ENTRY(); | 869 | ACPI_FUNCTION_ENTRY(); |
902 | 870 | ||
@@ -910,24 +878,22 @@ static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource) | |||
910 | acpi_rs_out_string("Triggering", | 878 | acpi_rs_out_string("Triggering", |
911 | ACPI_LEVEL_SENSITIVE == | 879 | ACPI_LEVEL_SENSITIVE == |
912 | resource->extended_irq. | 880 | resource->extended_irq. |
913 | edge_level ? "Level" : "Edge"); | 881 | triggering ? "Level" : "Edge"); |
914 | 882 | ||
915 | acpi_rs_out_string("Active", | 883 | acpi_rs_out_string("Active", |
916 | ACPI_ACTIVE_LOW == | 884 | ACPI_ACTIVE_LOW == resource->extended_irq.polarity ? |
917 | resource->extended_irq. | 885 | "Low" : "High"); |
918 | active_high_low ? "Low" : "High"); | ||
919 | 886 | ||
920 | acpi_rs_out_string("Sharing", | 887 | acpi_rs_out_string("Sharing", |
921 | ACPI_SHARED == | 888 | ACPI_SHARED == resource->extended_irq.sharable ? |
922 | resource->extended_irq. | 889 | "Shared" : "Exclusive"); |
923 | shared_exclusive ? "Shared" : "Exclusive"); | ||
924 | 890 | ||
925 | acpi_rs_dump_resource_source(&resource->extended_irq.resource_source); | 891 | acpi_rs_dump_resource_source(&resource->extended_irq.resource_source); |
926 | 892 | ||
927 | acpi_rs_out_integer8("Interrupts", | 893 | acpi_rs_out_integer8("Interrupts", |
928 | (u8) resource->extended_irq.number_of_interrupts); | 894 | (u8) resource->extended_irq.interrupt_count); |
929 | 895 | ||
930 | acpi_rs_dump_dword_list(resource->extended_irq.number_of_interrupts, | 896 | acpi_rs_dump_dword_list(resource->extended_irq.interrupt_count, |
931 | resource->extended_irq.interrupts); | 897 | resource->extended_irq.interrupts); |
932 | } | 898 | } |
933 | 899 | ||
@@ -943,9 +909,8 @@ static void acpi_rs_dump_extended_irq(union acpi_resource_data *resource) | |||
943 | * | 909 | * |
944 | ******************************************************************************/ | 910 | ******************************************************************************/ |
945 | 911 | ||
946 | static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) | 912 | void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) |
947 | { | 913 | { |
948 | |||
949 | ACPI_FUNCTION_ENTRY(); | 914 | ACPI_FUNCTION_ENTRY(); |
950 | 915 | ||
951 | acpi_os_printf("Generic Register Resource\n"); | 916 | acpi_os_printf("Generic Register Resource\n"); |
@@ -957,15 +922,15 @@ static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) | |||
957 | acpi_rs_out_integer8("Bit Offset", | 922 | acpi_rs_out_integer8("Bit Offset", |
958 | (u8) resource->generic_reg.bit_offset); | 923 | (u8) resource->generic_reg.bit_offset); |
959 | 924 | ||
960 | acpi_rs_out_integer8("Address Size", | 925 | acpi_rs_out_integer8("Access Size", |
961 | (u8) resource->generic_reg.address_size); | 926 | (u8) resource->generic_reg.access_size); |
962 | 927 | ||
963 | acpi_rs_out_integer64("Address", resource->generic_reg.address); | 928 | acpi_rs_out_integer64("Address", resource->generic_reg.address); |
964 | } | 929 | } |
965 | 930 | ||
966 | /******************************************************************************* | 931 | /******************************************************************************* |
967 | * | 932 | * |
968 | * FUNCTION: acpi_rs_dump_end_depend_fns | 933 | * FUNCTION: acpi_rs_dump_end_dpf |
969 | * | 934 | * |
970 | * PARAMETERS: Resource - Pointer to an internal resource descriptor | 935 | * PARAMETERS: Resource - Pointer to an internal resource descriptor |
971 | * | 936 | * |
@@ -975,7 +940,7 @@ static void acpi_rs_dump_generic_reg(union acpi_resource_data *resource) | |||
975 | * | 940 | * |
976 | ******************************************************************************/ | 941 | ******************************************************************************/ |
977 | 942 | ||
978 | static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource) | 943 | void acpi_rs_dump_end_dpf(union acpi_resource_data *resource) |
979 | { | 944 | { |
980 | ACPI_FUNCTION_ENTRY(); | 945 | ACPI_FUNCTION_ENTRY(); |
981 | 946 | ||
@@ -994,7 +959,7 @@ static void acpi_rs_dump_end_depend_fns(union acpi_resource_data *resource) | |||
994 | * | 959 | * |
995 | ******************************************************************************/ | 960 | ******************************************************************************/ |
996 | 961 | ||
997 | static void acpi_rs_dump_end_tag(union acpi_resource_data *resource) | 962 | void acpi_rs_dump_end_tag(union acpi_resource_data *resource) |
998 | { | 963 | { |
999 | ACPI_FUNCTION_ENTRY(); | 964 | ACPI_FUNCTION_ENTRY(); |
1000 | 965 | ||
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/resources/rsinfo.c index 49a5f81c727b..b31cb33ec565 100644 --- a/drivers/acpi/resources/rsinfo.c +++ b/drivers/acpi/resources/rsinfo.c | |||
@@ -207,7 +207,7 @@ struct acpi_resource_info acpi_gbl_lg_resource_info[] = { | |||
207 | {0, ACPI_RLARGE(struct aml_resource_memory24), | 207 | {0, ACPI_RLARGE(struct aml_resource_memory24), |
208 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)}, | 208 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_memory24)}, |
209 | {0, ACPI_RLARGE(struct aml_resource_generic_register), | 209 | {0, ACPI_RLARGE(struct aml_resource_generic_register), |
210 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_registerister)}, | 210 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register)}, |
211 | {0, 0, 0}, | 211 | {0, 0, 0}, |
212 | {1, ACPI_RLARGE(struct aml_resource_vendor_large), | 212 | {1, ACPI_RLARGE(struct aml_resource_vendor_large), |
213 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, | 213 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor)}, |
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c index 6574e2ae2e52..0dab8cdfa800 100644 --- a/drivers/acpi/resources/rsio.c +++ b/drivers/acpi/resources/rsio.c | |||
@@ -49,426 +49,269 @@ ACPI_MODULE_NAME("rsio") | |||
49 | 49 | ||
50 | /******************************************************************************* | 50 | /******************************************************************************* |
51 | * | 51 | * |
52 | * FUNCTION: acpi_rs_io_resource | 52 | * FUNCTION: acpi_rs_get_io |
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 | ******************************************************************************/ |
70 | acpi_status | 65 | acpi_status |
71 | acpi_rs_io_resource(u8 * byte_stream_buffer, | 66 | acpi_rs_get_io(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_io"); |
76 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
77 | u16 temp16 = 0; | ||
78 | u8 temp8 = 0; | ||
79 | acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); | ||
80 | 70 | ||
81 | ACPI_FUNCTION_TRACE("rs_io_resource"); | 71 | /* Get the Decode flag */ |
82 | 72 | ||
83 | /* The number of bytes consumed are Constant */ | 73 | resource->data.io.io_decode = aml->io.information & 0x01; |
84 | 74 | ||
85 | *bytes_consumed = 8; | 75 | /* |
76 | * Get the following contiguous fields from the AML descriptor: | ||
77 | * Minimum Base Address | ||
78 | * Maximum Base Address | ||
79 | * Address Alignment | ||
80 | * Length | ||
81 | */ | ||
82 | ACPI_MOVE_16_TO_32(&resource->data.io.minimum, &aml->io.minimum); | ||
83 | ACPI_MOVE_16_TO_32(&resource->data.io.maximum, &aml->io.maximum); | ||
84 | resource->data.io.alignment = aml->io.alignment; | ||
85 | resource->data.io.address_length = aml->io.address_length; | ||
86 | 86 | ||
87 | output_struct->type = ACPI_RSTYPE_IO; | 87 | /* Complete the resource header */ |
88 | 88 | ||
89 | /* Check Decode */ | 89 | resource->type = ACPI_RESOURCE_TYPE_IO; |
90 | 90 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_io); | |
91 | buffer += 1; | ||
92 | temp8 = *buffer; | ||
93 | |||
94 | output_struct->data.io.io_decode = temp8 & 0x01; | ||
95 | |||
96 | /* Check min_base Address */ | ||
97 | |||
98 | buffer += 1; | ||
99 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
100 | |||
101 | output_struct->data.io.min_base_address = temp16; | ||
102 | |||
103 | /* Check max_base Address */ | ||
104 | |||
105 | buffer += 2; | ||
106 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
107 | |||
108 | output_struct->data.io.max_base_address = temp16; | ||
109 | |||
110 | /* Check Base alignment */ | ||
111 | |||
112 | buffer += 2; | ||
113 | temp8 = *buffer; | ||
114 | |||
115 | output_struct->data.io.alignment = temp8; | ||
116 | |||
117 | /* Check range_length */ | ||
118 | |||
119 | buffer += 1; | ||
120 | temp8 = *buffer; | ||
121 | |||
122 | output_struct->data.io.range_length = temp8; | ||
123 | |||
124 | /* Set the Length parameter */ | ||
125 | |||
126 | output_struct->length = (u32) struct_size; | ||
127 | |||
128 | /* Return the final size of the structure */ | ||
129 | |||
130 | *structure_size = struct_size; | ||
131 | return_ACPI_STATUS(AE_OK); | 91 | return_ACPI_STATUS(AE_OK); |
132 | } | 92 | } |
133 | 93 | ||
134 | /******************************************************************************* | 94 | /******************************************************************************* |
135 | * | 95 | * |
136 | * FUNCTION: acpi_rs_fixed_io_resource | 96 | * FUNCTION: acpi_rs_set_io |
137 | * | 97 | * |
138 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 98 | * PARAMETERS: Resource - Pointer to the resource descriptor |
139 | * stream | 99 | * Aml - Where the AML descriptor is returned |
140 | * bytes_consumed - Pointer to where the number of bytes | ||
141 | * consumed the byte_stream_buffer is | ||
142 | * returned | ||
143 | * output_buffer - Pointer to the return data buffer | ||
144 | * structure_size - Pointer to where the number of bytes | ||
145 | * in the return data struct is returned | ||
146 | * | 100 | * |
147 | * RETURN: Status | 101 | * RETURN: Status |
148 | * | 102 | * |
149 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 103 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
150 | * structure pointed to by the output_buffer. Return the | 104 | * external AML resource descriptor. |
151 | * number of bytes consumed from the byte stream. | ||
152 | * | 105 | * |
153 | ******************************************************************************/ | 106 | ******************************************************************************/ |
154 | 107 | ||
155 | acpi_status | 108 | acpi_status |
156 | acpi_rs_fixed_io_resource(u8 * byte_stream_buffer, | 109 | acpi_rs_set_io(struct acpi_resource *resource, union aml_resource *aml) |
157 | acpi_size * bytes_consumed, | ||
158 | u8 ** output_buffer, acpi_size * structure_size) | ||
159 | { | 110 | { |
160 | u8 *buffer = byte_stream_buffer; | 111 | ACPI_FUNCTION_TRACE("rs_set_io"); |
161 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
162 | u16 temp16 = 0; | ||
163 | u8 temp8 = 0; | ||
164 | acpi_size struct_size = | ||
165 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); | ||
166 | |||
167 | ACPI_FUNCTION_TRACE("rs_fixed_io_resource"); | ||
168 | 112 | ||
169 | /* The number of bytes consumed are Constant */ | 113 | /* I/O Information Byte */ |
170 | 114 | ||
171 | *bytes_consumed = 4; | 115 | aml->io.information = (u8) (resource->data.io.io_decode & 0x01); |
172 | 116 | ||
173 | output_struct->type = ACPI_RSTYPE_FIXED_IO; | 117 | /* |
118 | * Set the following contiguous fields in the AML descriptor: | ||
119 | * Minimum Base Address | ||
120 | * Maximum Base Address | ||
121 | * Address Alignment | ||
122 | * Length | ||
123 | */ | ||
124 | ACPI_MOVE_32_TO_16(&aml->io.minimum, &resource->data.io.minimum); | ||
125 | ACPI_MOVE_32_TO_16(&aml->io.maximum, &resource->data.io.maximum); | ||
126 | aml->io.alignment = (u8) resource->data.io.alignment; | ||
127 | aml->io.address_length = (u8) resource->data.io.address_length; | ||
174 | 128 | ||
175 | /* Check Range Base Address */ | 129 | /* Complete the AML descriptor header */ |
176 | 130 | ||
177 | buffer += 1; | 131 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IO, |
178 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 132 | sizeof(struct aml_resource_io), aml); |
179 | |||
180 | output_struct->data.fixed_io.base_address = temp16; | ||
181 | |||
182 | /* Check range_length */ | ||
183 | |||
184 | buffer += 2; | ||
185 | temp8 = *buffer; | ||
186 | |||
187 | output_struct->data.fixed_io.range_length = temp8; | ||
188 | |||
189 | /* Set the Length parameter */ | ||
190 | |||
191 | output_struct->length = (u32) struct_size; | ||
192 | |||
193 | /* Return the final size of the structure */ | ||
194 | |||
195 | *structure_size = struct_size; | ||
196 | return_ACPI_STATUS(AE_OK); | 133 | return_ACPI_STATUS(AE_OK); |
197 | } | 134 | } |
198 | 135 | ||
199 | /******************************************************************************* | 136 | /******************************************************************************* |
200 | * | 137 | * |
201 | * FUNCTION: acpi_rs_io_stream | 138 | * FUNCTION: acpi_rs_get_fixed_io |
202 | * | 139 | * |
203 | * PARAMETERS: Resource - Pointer to the resource linked list | 140 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
204 | * output_buffer - Pointer to the user's return buffer | 141 | * aml_resource_length - Length of the resource from the AML header |
205 | * bytes_consumed - Pointer to where the number of bytes | 142 | * Resource - Where the internal resource is returned |
206 | * used in the output_buffer is returned | ||
207 | * | 143 | * |
208 | * RETURN: Status | 144 | * RETURN: Status |
209 | * | 145 | * |
210 | * DESCRIPTION: Take the linked list resource structure and fills in the | 146 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
211 | * the appropriate bytes in a byte stream | 147 | * internal resource descriptor, simplifying bitflags and handling |
148 | * alignment and endian issues if necessary. | ||
212 | * | 149 | * |
213 | ******************************************************************************/ | 150 | ******************************************************************************/ |
214 | 151 | ||
215 | acpi_status | 152 | acpi_status |
216 | acpi_rs_io_stream(struct acpi_resource *resource, | 153 | acpi_rs_get_fixed_io(union aml_resource *aml, |
217 | u8 ** output_buffer, acpi_size * bytes_consumed) | 154 | u16 aml_resource_length, struct acpi_resource *resource) |
218 | { | 155 | { |
219 | u8 *buffer = *output_buffer; | 156 | ACPI_FUNCTION_TRACE("rs_get_fixed_io"); |
220 | u16 temp16 = 0; | ||
221 | u8 temp8 = 0; | ||
222 | |||
223 | ACPI_FUNCTION_TRACE("rs_io_stream"); | ||
224 | |||
225 | /* The Descriptor Type field is static */ | ||
226 | |||
227 | *buffer = ACPI_RDESC_TYPE_IO_PORT | 0x07; | ||
228 | buffer += 1; | ||
229 | |||
230 | /* Io Information Byte */ | ||
231 | |||
232 | temp8 = (u8) (resource->data.io.io_decode & 0x01); | ||
233 | |||
234 | *buffer = temp8; | ||
235 | buffer += 1; | ||
236 | |||
237 | /* Set the Range minimum base address */ | ||
238 | |||
239 | temp16 = (u16) resource->data.io.min_base_address; | ||
240 | |||
241 | ACPI_MOVE_16_TO_16(buffer, &temp16); | ||
242 | buffer += 2; | ||
243 | |||
244 | /* Set the Range maximum base address */ | ||
245 | 157 | ||
246 | temp16 = (u16) resource->data.io.max_base_address; | 158 | /* |
159 | * Get the following contiguous fields from the AML descriptor: | ||
160 | * Base Address | ||
161 | * Length | ||
162 | */ | ||
163 | ACPI_MOVE_16_TO_32(&resource->data.fixed_io.address, | ||
164 | &aml->fixed_io.address); | ||
165 | resource->data.fixed_io.address_length = aml->fixed_io.address_length; | ||
247 | 166 | ||
248 | ACPI_MOVE_16_TO_16(buffer, &temp16); | 167 | /* Complete the resource header */ |
249 | buffer += 2; | ||
250 | 168 | ||
251 | /* Set the base alignment */ | 169 | resource->type = ACPI_RESOURCE_TYPE_FIXED_IO; |
252 | 170 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_fixed_io); | |
253 | temp8 = (u8) resource->data.io.alignment; | ||
254 | |||
255 | *buffer = temp8; | ||
256 | buffer += 1; | ||
257 | |||
258 | /* Set the range length */ | ||
259 | |||
260 | temp8 = (u8) resource->data.io.range_length; | ||
261 | |||
262 | *buffer = temp8; | ||
263 | buffer += 1; | ||
264 | |||
265 | /* Return the number of bytes consumed in this operation */ | ||
266 | |||
267 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
268 | return_ACPI_STATUS(AE_OK); | 171 | return_ACPI_STATUS(AE_OK); |
269 | } | 172 | } |
270 | 173 | ||
271 | /******************************************************************************* | 174 | /******************************************************************************* |
272 | * | 175 | * |
273 | * FUNCTION: acpi_rs_fixed_io_stream | 176 | * FUNCTION: acpi_rs_set_fixed_io |
274 | * | 177 | * |
275 | * PARAMETERS: Resource - Pointer to the resource linked list | 178 | * PARAMETERS: Resource - Pointer to the resource descriptor |
276 | * output_buffer - Pointer to the user's return buffer | 179 | * Aml - Where the AML descriptor is returned |
277 | * bytes_consumed - Pointer to where the number of bytes | ||
278 | * used in the output_buffer is returned | ||
279 | * | 180 | * |
280 | * RETURN: Status | 181 | * RETURN: Status |
281 | * | 182 | * |
282 | * DESCRIPTION: Take the linked list resource structure and fills in the | 183 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
283 | * the appropriate bytes in a byte stream | 184 | * external AML resource descriptor. |
284 | * | 185 | * |
285 | ******************************************************************************/ | 186 | ******************************************************************************/ |
286 | 187 | ||
287 | acpi_status | 188 | acpi_status |
288 | acpi_rs_fixed_io_stream(struct acpi_resource *resource, | 189 | acpi_rs_set_fixed_io(struct acpi_resource *resource, union aml_resource *aml) |
289 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
290 | { | 190 | { |
291 | u8 *buffer = *output_buffer; | 191 | ACPI_FUNCTION_TRACE("rs_set_fixed_io"); |
292 | u16 temp16 = 0; | 192 | |
293 | u8 temp8 = 0; | 193 | /* |
294 | 194 | * Set the following contiguous fields in the AML descriptor: | |
295 | ACPI_FUNCTION_TRACE("rs_fixed_io_stream"); | 195 | * Base Address |
296 | 196 | * Length | |
297 | /* The Descriptor Type field is static */ | 197 | */ |
298 | 198 | ACPI_MOVE_32_TO_16(&aml->fixed_io.address, | |
299 | *buffer = ACPI_RDESC_TYPE_FIXED_IO_PORT | 0x03; | 199 | &resource->data.fixed_io.address); |
300 | buffer += 1; | 200 | aml->fixed_io.address_length = |
301 | 201 | (u8) resource->data.fixed_io.address_length; | |
302 | /* Set the Range base address */ | 202 | |
303 | 203 | /* Complete the AML descriptor header */ | |
304 | temp16 = (u16) resource->data.fixed_io.base_address; | 204 | |
305 | 205 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_FIXED_IO, | |
306 | ACPI_MOVE_16_TO_16(buffer, &temp16); | 206 | sizeof(struct aml_resource_fixed_io), aml); |
307 | buffer += 2; | ||
308 | |||
309 | /* Set the range length */ | ||
310 | |||
311 | temp8 = (u8) resource->data.fixed_io.range_length; | ||
312 | |||
313 | *buffer = temp8; | ||
314 | buffer += 1; | ||
315 | |||
316 | /* Return the number of bytes consumed in this operation */ | ||
317 | |||
318 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
319 | return_ACPI_STATUS(AE_OK); | 207 | return_ACPI_STATUS(AE_OK); |
320 | } | 208 | } |
321 | 209 | ||
322 | /******************************************************************************* | 210 | /******************************************************************************* |
323 | * | 211 | * |
324 | * FUNCTION: acpi_rs_dma_resource | 212 | * FUNCTION: acpi_rs_get_dma |
325 | * | 213 | * |
326 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 214 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
327 | * stream | 215 | * aml_resource_length - Length of the resource from the AML header |
328 | * bytes_consumed - Pointer to where the number of bytes | 216 | * Resource - Where the internal resource is returned |
329 | * consumed the byte_stream_buffer is | ||
330 | * returned | ||
331 | * output_buffer - Pointer to the return data buffer | ||
332 | * structure_size - Pointer to where the number of bytes | ||
333 | * in the return data struct is returned | ||
334 | * | 217 | * |
335 | * RETURN: Status | 218 | * RETURN: Status |
336 | * | 219 | * |
337 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 220 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
338 | * structure pointed to by the output_buffer. Return the | 221 | * internal resource descriptor, simplifying bitflags and handling |
339 | * number of bytes consumed from the byte stream. | 222 | * alignment and endian issues if necessary. |
340 | * | 223 | * |
341 | ******************************************************************************/ | 224 | ******************************************************************************/ |
342 | 225 | ||
343 | acpi_status | 226 | acpi_status |
344 | acpi_rs_dma_resource(u8 * byte_stream_buffer, | 227 | acpi_rs_get_dma(union aml_resource *aml, |
345 | acpi_size * bytes_consumed, | 228 | u16 aml_resource_length, struct acpi_resource *resource) |
346 | u8 ** output_buffer, acpi_size * structure_size) | ||
347 | { | 229 | { |
348 | u8 *buffer = byte_stream_buffer; | 230 | u32 channel_count = 0; |
349 | struct acpi_resource *output_struct = (void *)*output_buffer; | 231 | u32 i; |
350 | u8 temp8 = 0; | 232 | u8 temp8; |
351 | u8 index; | ||
352 | u8 i; | ||
353 | acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); | ||
354 | 233 | ||
355 | ACPI_FUNCTION_TRACE("rs_dma_resource"); | 234 | ACPI_FUNCTION_TRACE("rs_get_dma"); |
356 | |||
357 | /* The number of bytes consumed are Constant */ | ||
358 | |||
359 | *bytes_consumed = 3; | ||
360 | output_struct->type = ACPI_RSTYPE_DMA; | ||
361 | |||
362 | /* Point to the 8-bits of Byte 1 */ | ||
363 | |||
364 | buffer += 1; | ||
365 | temp8 = *buffer; | ||
366 | 235 | ||
367 | /* Decode the DMA channel bits */ | 236 | /* Decode the DMA channel bits */ |
368 | 237 | ||
369 | for (i = 0, index = 0; index < 8; index++) { | 238 | for (i = 0; i < 8; i++) { |
370 | if ((temp8 >> index) & 0x01) { | 239 | if ((aml->dma.dma_channel_mask >> i) & 0x01) { |
371 | output_struct->data.dma.channels[i] = index; | 240 | resource->data.dma.channels[channel_count] = i; |
372 | i++; | 241 | channel_count++; |
373 | } | 242 | } |
374 | } | 243 | } |
375 | 244 | ||
376 | /* Zero DMA channels is valid */ | 245 | resource->length = 0; |
377 | 246 | resource->data.dma.channel_count = channel_count; | |
378 | output_struct->data.dma.number_of_channels = i; | ||
379 | if (i > 0) { | ||
380 | /* Calculate the structure size based upon the number of interrupts */ | ||
381 | 247 | ||
382 | struct_size += ((acpi_size) i - 1) * 4; | 248 | /* |
249 | * Calculate the structure size based upon the number of channels | ||
250 | * Note: Zero DMA channels is valid | ||
251 | */ | ||
252 | if (channel_count > 0) { | ||
253 | resource->length = (u32) (channel_count - 1) * 4; | ||
383 | } | 254 | } |
384 | 255 | ||
385 | /* Point to Byte 2 */ | 256 | /* Get the flags: transfer preference, bus mastering, channel speed */ |
386 | 257 | ||
387 | buffer += 1; | 258 | temp8 = aml->dma.flags; |
388 | temp8 = *buffer; | 259 | resource->data.dma.transfer = temp8 & 0x03; |
260 | resource->data.dma.bus_master = (temp8 >> 2) & 0x01; | ||
261 | resource->data.dma.type = (temp8 >> 5) & 0x03; | ||
389 | 262 | ||
390 | /* Check for transfer preference (Bits[1:0]) */ | 263 | if (resource->data.dma.transfer == 0x03) { |
391 | |||
392 | output_struct->data.dma.transfer = temp8 & 0x03; | ||
393 | |||
394 | if (0x03 == output_struct->data.dma.transfer) { | ||
395 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 264 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
396 | "Invalid DMA.Transfer preference (3)\n")); | 265 | "Invalid DMA.Transfer preference (3)\n")); |
397 | return_ACPI_STATUS(AE_BAD_DATA); | 266 | return_ACPI_STATUS(AE_BAD_DATA); |
398 | } | 267 | } |
399 | 268 | ||
400 | /* Get bus master preference (Bit[2]) */ | 269 | /* Complete the resource header */ |
401 | |||
402 | output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01; | ||
403 | |||
404 | /* Get channel speed support (Bits[6:5]) */ | ||
405 | 270 | ||
406 | output_struct->data.dma.type = (temp8 >> 5) & 0x03; | 271 | resource->type = ACPI_RESOURCE_TYPE_DMA; |
407 | 272 | resource->length += ACPI_SIZEOF_RESOURCE(struct acpi_resource_dma); | |
408 | /* Set the Length parameter */ | ||
409 | |||
410 | output_struct->length = (u32) struct_size; | ||
411 | |||
412 | /* Return the final size of the structure */ | ||
413 | |||
414 | *structure_size = struct_size; | ||
415 | return_ACPI_STATUS(AE_OK); | 273 | return_ACPI_STATUS(AE_OK); |
416 | } | 274 | } |
417 | 275 | ||
418 | /******************************************************************************* | 276 | /******************************************************************************* |
419 | * | 277 | * |
420 | * FUNCTION: acpi_rs_dma_stream | 278 | * FUNCTION: acpi_rs_set_dma |
421 | * | 279 | * |
422 | * PARAMETERS: Resource - Pointer to the resource linked list | 280 | * PARAMETERS: Resource - Pointer to the resource descriptor |
423 | * output_buffer - Pointer to the user's return buffer | 281 | * Aml - Where the AML descriptor is returned |
424 | * bytes_consumed - Pointer to where the number of bytes | ||
425 | * used in the output_buffer is returned | ||
426 | * | 282 | * |
427 | * RETURN: Status | 283 | * RETURN: Status |
428 | * | 284 | * |
429 | * DESCRIPTION: Take the linked list resource structure and fills in the | 285 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
430 | * the appropriate bytes in a byte stream | 286 | * external AML resource descriptor. |
431 | * | 287 | * |
432 | ******************************************************************************/ | 288 | ******************************************************************************/ |
433 | 289 | ||
434 | acpi_status | 290 | acpi_status |
435 | acpi_rs_dma_stream(struct acpi_resource *resource, | 291 | acpi_rs_set_dma(struct acpi_resource *resource, union aml_resource *aml) |
436 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
437 | { | 292 | { |
438 | u8 *buffer = *output_buffer; | 293 | u8 i; |
439 | u16 temp16 = 0; | ||
440 | u8 temp8 = 0; | ||
441 | u8 index; | ||
442 | |||
443 | ACPI_FUNCTION_TRACE("rs_dma_stream"); | ||
444 | |||
445 | /* The Descriptor Type field is static */ | ||
446 | 294 | ||
447 | *buffer = ACPI_RDESC_TYPE_DMA_FORMAT | 0x02; | 295 | ACPI_FUNCTION_TRACE("rs_set_dma"); |
448 | buffer += 1; | ||
449 | temp8 = 0; | ||
450 | 296 | ||
451 | /* Loop through all of the Channels and set the mask bits */ | 297 | /* Convert channel list to 8-bit DMA channel bitmask */ |
452 | 298 | ||
453 | for (index = 0; index < resource->data.dma.number_of_channels; index++) { | 299 | aml->dma.dma_channel_mask = 0; |
454 | temp16 = (u16) resource->data.dma.channels[index]; | 300 | for (i = 0; i < resource->data.dma.channel_count; i++) { |
455 | temp8 |= 0x1 << temp16; | 301 | aml->dma.dma_channel_mask |= |
302 | (1 << resource->data.dma.channels[i]); | ||
456 | } | 303 | } |
457 | 304 | ||
458 | *buffer = temp8; | 305 | /* Set the DMA Flag bits */ |
459 | buffer += 1; | ||
460 | |||
461 | /* Set the DMA Info */ | ||
462 | |||
463 | temp8 = (u8) ((resource->data.dma.type & 0x03) << 5); | ||
464 | temp8 |= ((resource->data.dma.bus_master & 0x01) << 2); | ||
465 | temp8 |= (resource->data.dma.transfer & 0x03); | ||
466 | 306 | ||
467 | *buffer = temp8; | 307 | aml->dma.flags = (u8) |
468 | buffer += 1; | 308 | (((resource->data.dma.type & 0x03) << 5) | |
309 | ((resource->data.dma.bus_master & 0x01) << 2) | | ||
310 | (resource->data.dma.transfer & 0x03)); | ||
469 | 311 | ||
470 | /* Return the number of bytes consumed in this operation */ | 312 | /* Complete the AML descriptor header */ |
471 | 313 | ||
472 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 314 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_DMA, |
315 | sizeof(struct aml_resource_dma), aml); | ||
473 | return_ACPI_STATUS(AE_OK); | 316 | return_ACPI_STATUS(AE_OK); |
474 | } | 317 | } |
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c index 75df962115cc..4e854ba70811 100644 --- a/drivers/acpi/resources/rsirq.c +++ b/drivers/acpi/resources/rsirq.c | |||
@@ -49,93 +49,67 @@ ACPI_MODULE_NAME("rsirq") | |||
49 | 49 | ||
50 | /******************************************************************************* | 50 | /******************************************************************************* |
51 | * | 51 | * |
52 | * FUNCTION: acpi_rs_irq_resource | 52 | * FUNCTION: acpi_rs_get_irq |
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 | ******************************************************************************/ |
70 | acpi_status | 65 | acpi_status |
71 | acpi_rs_irq_resource(u8 * byte_stream_buffer, | 66 | acpi_rs_get_irq(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; | ||
76 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
77 | u16 temp16 = 0; | 69 | u16 temp16 = 0; |
78 | u8 temp8 = 0; | 70 | u32 interrupt_count = 0; |
79 | u8 index; | 71 | u32 i; |
80 | u8 i; | 72 | u32 resource_length; |
81 | acpi_size struct_size = ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq); | ||
82 | |||
83 | ACPI_FUNCTION_TRACE("rs_irq_resource"); | ||
84 | |||
85 | /* | ||
86 | * The number of bytes consumed are contained in the descriptor | ||
87 | * (Bits:0-1) | ||
88 | */ | ||
89 | temp8 = *buffer; | ||
90 | *bytes_consumed = (temp8 & 0x03) + 1; | ||
91 | output_struct->type = ACPI_RSTYPE_IRQ; | ||
92 | 73 | ||
93 | /* Point to the 16-bits of Bytes 1 and 2 */ | 74 | ACPI_FUNCTION_TRACE("rs_get_irq"); |
94 | 75 | ||
95 | buffer += 1; | 76 | /* Get the IRQ mask (bytes 1:2) */ |
96 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
97 | 77 | ||
98 | output_struct->data.irq.number_of_interrupts = 0; | 78 | ACPI_MOVE_16_TO_16(&temp16, &aml->irq.irq_mask); |
99 | 79 | ||
100 | /* Decode the IRQ bits */ | 80 | /* Decode the IRQ bits (up to 16 possible) */ |
101 | 81 | ||
102 | for (i = 0, index = 0; index < 16; index++) { | 82 | for (i = 0; i < 16; i++) { |
103 | if ((temp16 >> index) & 0x01) { | 83 | if ((temp16 >> i) & 0x01) { |
104 | output_struct->data.irq.interrupts[i] = index; | 84 | resource->data.irq.interrupts[interrupt_count] = i; |
105 | i++; | 85 | interrupt_count++; |
106 | } | 86 | } |
107 | } | 87 | } |
108 | 88 | ||
109 | /* Zero interrupts is valid */ | 89 | /* Zero interrupts is valid */ |
110 | 90 | ||
111 | output_struct->data.irq.number_of_interrupts = i; | 91 | resource_length = 0; |
112 | if (i > 0) { | 92 | resource->data.irq.interrupt_count = interrupt_count; |
93 | if (interrupt_count > 0) { | ||
113 | /* Calculate the structure size based upon the number of interrupts */ | 94 | /* Calculate the structure size based upon the number of interrupts */ |
114 | 95 | ||
115 | struct_size += ((acpi_size) i - 1) * 4; | 96 | resource_length = (u32) (interrupt_count - 1) * 4; |
116 | } | 97 | } |
117 | 98 | ||
118 | /* Point to Byte 3 if it is used */ | 99 | /* Get Flags (Byte 3) if it is used */ |
119 | |||
120 | if (4 == *bytes_consumed) { | ||
121 | buffer += 2; | ||
122 | temp8 = *buffer; | ||
123 | 100 | ||
101 | if (aml_resource_length == 3) { | ||
124 | /* Check for HE, LL interrupts */ | 102 | /* Check for HE, LL interrupts */ |
125 | 103 | ||
126 | switch (temp8 & 0x09) { | 104 | switch (aml->irq.flags & 0x09) { |
127 | case 0x01: /* HE */ | 105 | case 0x01: /* HE */ |
128 | output_struct->data.irq.edge_level = | 106 | resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; |
129 | ACPI_EDGE_SENSITIVE; | 107 | resource->data.irq.polarity = ACPI_ACTIVE_HIGH; |
130 | output_struct->data.irq.active_high_low = | ||
131 | ACPI_ACTIVE_HIGH; | ||
132 | break; | 108 | break; |
133 | 109 | ||
134 | case 0x08: /* LL */ | 110 | case 0x08: /* LL */ |
135 | output_struct->data.irq.edge_level = | 111 | resource->data.irq.triggering = ACPI_LEVEL_SENSITIVE; |
136 | ACPI_LEVEL_SENSITIVE; | 112 | resource->data.irq.polarity = ACPI_ACTIVE_LOW; |
137 | output_struct->data.irq.active_high_low = | ||
138 | ACPI_ACTIVE_LOW; | ||
139 | break; | 113 | break; |
140 | 114 | ||
141 | default: | 115 | default: |
@@ -146,170 +120,131 @@ acpi_rs_irq_resource(u8 * byte_stream_buffer, | |||
146 | */ | 120 | */ |
147 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 121 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
148 | "Invalid interrupt polarity/trigger in resource list, %X\n", | 122 | "Invalid interrupt polarity/trigger in resource list, %X\n", |
149 | temp8)); | 123 | aml->irq.flags)); |
150 | return_ACPI_STATUS(AE_BAD_DATA); | 124 | return_ACPI_STATUS(AE_BAD_DATA); |
151 | } | 125 | } |
152 | 126 | ||
153 | /* Check for sharable */ | 127 | /* Get Sharing flag */ |
154 | 128 | ||
155 | output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01; | 129 | resource->data.irq.sharable = (aml->irq.flags >> 3) & 0x01; |
156 | } else { | 130 | } else { |
157 | /* | 131 | /* |
158 | * Assume Edge Sensitive, Active High, Non-Sharable | 132 | * Default configuration: assume Edge Sensitive, Active High, |
159 | * per ACPI Specification | 133 | * Non-Sharable as per the ACPI Specification |
160 | */ | 134 | */ |
161 | output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE; | 135 | resource->data.irq.triggering = ACPI_EDGE_SENSITIVE; |
162 | output_struct->data.irq.active_high_low = ACPI_ACTIVE_HIGH; | 136 | resource->data.irq.polarity = ACPI_ACTIVE_HIGH; |
163 | output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE; | 137 | resource->data.irq.sharable = ACPI_EXCLUSIVE; |
164 | } | 138 | } |
165 | 139 | ||
166 | /* Set the Length parameter */ | 140 | /* Complete the resource header */ |
167 | 141 | ||
168 | output_struct->length = (u32) struct_size; | 142 | resource->type = ACPI_RESOURCE_TYPE_IRQ; |
169 | 143 | resource->length = | |
170 | /* Return the final size of the structure */ | 144 | resource_length + ACPI_SIZEOF_RESOURCE(struct acpi_resource_irq); |
171 | |||
172 | *structure_size = struct_size; | ||
173 | return_ACPI_STATUS(AE_OK); | 145 | return_ACPI_STATUS(AE_OK); |
174 | } | 146 | } |
175 | 147 | ||
176 | /******************************************************************************* | 148 | /******************************************************************************* |
177 | * | 149 | * |
178 | * FUNCTION: acpi_rs_irq_stream | 150 | * FUNCTION: acpi_rs_set_irq |
179 | * | 151 | * |
180 | * PARAMETERS: Resource - Pointer to the resource linked list | 152 | * PARAMETERS: Resource - Pointer to the resource descriptor |
181 | * output_buffer - Pointer to the user's return buffer | 153 | * Aml - Where the AML descriptor is returned |
182 | * bytes_consumed - Pointer to where the number of bytes | ||
183 | * used in the output_buffer is returned | ||
184 | * | 154 | * |
185 | * RETURN: Status | 155 | * RETURN: Status |
186 | * | 156 | * |
187 | * DESCRIPTION: Take the linked list resource structure and fills in the | 157 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
188 | * the appropriate bytes in a byte stream | 158 | * external AML resource descriptor. |
189 | * | 159 | * |
190 | ******************************************************************************/ | 160 | ******************************************************************************/ |
191 | 161 | ||
192 | acpi_status | 162 | acpi_status |
193 | acpi_rs_irq_stream(struct acpi_resource *resource, | 163 | acpi_rs_set_irq(struct acpi_resource *resource, union aml_resource *aml) |
194 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
195 | { | 164 | { |
196 | u8 *buffer = *output_buffer; | 165 | acpi_size descriptor_length; |
197 | u16 temp16 = 0; | 166 | u16 irq_mask; |
198 | u8 temp8 = 0; | 167 | u8 i; |
199 | u8 index; | 168 | |
200 | u8 IRqinfo_byte_needed; | 169 | ACPI_FUNCTION_TRACE("rs_set_irq"); |
201 | 170 | ||
202 | ACPI_FUNCTION_TRACE("rs_irq_stream"); | 171 | /* Convert interrupt list to 16-bit IRQ bitmask */ |
172 | |||
173 | irq_mask = 0; | ||
174 | for (i = 0; i < resource->data.irq.interrupt_count; i++) { | ||
175 | irq_mask |= (1 << resource->data.irq.interrupts[i]); | ||
176 | } | ||
177 | |||
178 | /* Set the interrupt mask */ | ||
179 | |||
180 | ACPI_MOVE_16_TO_16(&aml->irq.irq_mask, &irq_mask); | ||
203 | 181 | ||
204 | /* | 182 | /* |
205 | * The descriptor field is set based upon whether a third byte is | 183 | * The descriptor field is set based upon whether a third byte is |
206 | * needed to contain the IRQ Information. | 184 | * needed to contain the IRQ Information. |
207 | */ | 185 | */ |
208 | if (ACPI_EDGE_SENSITIVE == resource->data.irq.edge_level && | 186 | if ((resource->data.irq.triggering == ACPI_EDGE_SENSITIVE) && |
209 | ACPI_ACTIVE_HIGH == resource->data.irq.active_high_low && | 187 | (resource->data.irq.polarity == ACPI_ACTIVE_HIGH) && |
210 | ACPI_EXCLUSIVE == resource->data.irq.shared_exclusive) { | 188 | (resource->data.irq.sharable == ACPI_EXCLUSIVE)) { |
211 | *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x02; | 189 | /* irq_no_flags() descriptor can be used */ |
212 | IRqinfo_byte_needed = FALSE; | ||
213 | } else { | ||
214 | *buffer = ACPI_RDESC_TYPE_IRQ_FORMAT | 0x03; | ||
215 | IRqinfo_byte_needed = TRUE; | ||
216 | } | ||
217 | |||
218 | buffer += 1; | ||
219 | temp16 = 0; | ||
220 | |||
221 | /* Loop through all of the interrupts and set the mask bits */ | ||
222 | 190 | ||
223 | for (index = 0; | 191 | descriptor_length = sizeof(struct aml_resource_irq_noflags); |
224 | index < resource->data.irq.number_of_interrupts; index++) { | 192 | } else { |
225 | temp8 = (u8) resource->data.irq.interrupts[index]; | 193 | /* Irq() descriptor must be used */ |
226 | temp16 |= 0x1 << temp8; | ||
227 | } | ||
228 | 194 | ||
229 | ACPI_MOVE_16_TO_16(buffer, &temp16); | 195 | descriptor_length = sizeof(struct aml_resource_irq); |
230 | buffer += 2; | ||
231 | 196 | ||
232 | /* Set the IRQ Info byte if needed. */ | 197 | /* Set the IRQ Info byte */ |
233 | 198 | ||
234 | if (IRqinfo_byte_needed) { | 199 | aml->irq.flags = (u8) |
235 | temp8 = 0; | 200 | ((resource->data.irq.sharable & 0x01) << 4); |
236 | temp8 = (u8) ((resource->data.irq.shared_exclusive & | ||
237 | 0x01) << 4); | ||
238 | 201 | ||
239 | if (ACPI_LEVEL_SENSITIVE == resource->data.irq.edge_level && | 202 | if (ACPI_LEVEL_SENSITIVE == resource->data.irq.triggering && |
240 | ACPI_ACTIVE_LOW == resource->data.irq.active_high_low) { | 203 | ACPI_ACTIVE_LOW == resource->data.irq.polarity) { |
241 | temp8 |= 0x08; | 204 | aml->irq.flags |= 0x08; |
242 | } else { | 205 | } else { |
243 | temp8 |= 0x01; | 206 | aml->irq.flags |= 0x01; |
244 | } | 207 | } |
245 | |||
246 | *buffer = temp8; | ||
247 | buffer += 1; | ||
248 | } | 208 | } |
249 | 209 | ||
250 | /* Return the number of bytes consumed in this operation */ | 210 | /* Complete the AML descriptor header */ |
251 | 211 | ||
252 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 212 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_IRQ, descriptor_length, |
213 | aml); | ||
253 | return_ACPI_STATUS(AE_OK); | 214 | return_ACPI_STATUS(AE_OK); |
254 | } | 215 | } |
255 | 216 | ||
256 | /******************************************************************************* | 217 | /******************************************************************************* |
257 | * | 218 | * |
258 | * FUNCTION: acpi_rs_extended_irq_resource | 219 | * FUNCTION: acpi_rs_get_ext_irq |
259 | * | 220 | * |
260 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 221 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
261 | * stream | 222 | * aml_resource_length - Length of the resource from the AML header |
262 | * bytes_consumed - Pointer to where the number of bytes | 223 | * Resource - Where the internal resource is returned |
263 | * consumed the byte_stream_buffer is | ||
264 | * returned | ||
265 | * output_buffer - Pointer to the return data buffer | ||
266 | * structure_size - Pointer to where the number of bytes | ||
267 | * in the return data struct is returned | ||
268 | * | 224 | * |
269 | * RETURN: Status | 225 | * RETURN: Status |
270 | * | 226 | * |
271 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 227 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
272 | * structure pointed to by the output_buffer. Return the | 228 | * internal resource descriptor, simplifying bitflags and handling |
273 | * number of bytes consumed from the byte stream. | 229 | * alignment and endian issues if necessary. |
274 | * | 230 | * |
275 | ******************************************************************************/ | 231 | ******************************************************************************/ |
276 | 232 | ||
277 | acpi_status | 233 | acpi_status |
278 | acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, | 234 | acpi_rs_get_ext_irq(union aml_resource *aml, |
279 | acpi_size * bytes_consumed, | 235 | u16 aml_resource_length, struct acpi_resource *resource) |
280 | u8 ** output_buffer, acpi_size * structure_size) | ||
281 | { | 236 | { |
282 | u8 *buffer = byte_stream_buffer; | 237 | char *out_resource_string; |
283 | struct acpi_resource *output_struct = (void *)*output_buffer; | 238 | u8 temp8; |
284 | u16 temp16 = 0; | ||
285 | u8 temp8 = 0; | ||
286 | u8 *temp_ptr; | ||
287 | u8 index; | ||
288 | acpi_size struct_size = | ||
289 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_ext_irq); | ||
290 | |||
291 | ACPI_FUNCTION_TRACE("rs_extended_irq_resource"); | ||
292 | 239 | ||
293 | /* Get the Descriptor Length field */ | 240 | ACPI_FUNCTION_TRACE("rs_get_ext_irq"); |
294 | 241 | ||
295 | buffer += 1; | 242 | /* Get the flag bits */ |
296 | ACPI_MOVE_16_TO_16(&temp16, buffer); | ||
297 | 243 | ||
298 | /* Validate minimum descriptor length */ | 244 | temp8 = aml->extended_irq.flags; |
299 | 245 | resource->data.extended_irq.producer_consumer = temp8 & 0x01; | |
300 | if (temp16 < 6) { | 246 | resource->data.extended_irq.polarity = (temp8 >> 2) & 0x01; |
301 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | 247 | resource->data.extended_irq.sharable = (temp8 >> 3) & 0x01; |
302 | } | ||
303 | |||
304 | *bytes_consumed = temp16 + 3; | ||
305 | output_struct->type = ACPI_RSTYPE_EXT_IRQ; | ||
306 | |||
307 | /* Point to the Byte3 */ | ||
308 | |||
309 | buffer += 2; | ||
310 | temp8 = *buffer; | ||
311 | |||
312 | output_struct->data.extended_irq.producer_consumer = temp8 & 0x01; | ||
313 | 248 | ||
314 | /* | 249 | /* |
315 | * Check for Interrupt Mode | 250 | * Check for Interrupt Mode |
@@ -319,165 +254,80 @@ acpi_rs_extended_irq_resource(u8 * byte_stream_buffer, | |||
319 | * | 254 | * |
320 | * - Edge/Level are defined opposite in the table vs the headers | 255 | * - Edge/Level are defined opposite in the table vs the headers |
321 | */ | 256 | */ |
322 | output_struct->data.extended_irq.edge_level = | 257 | resource->data.extended_irq.triggering = |
323 | (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; | 258 | (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; |
324 | 259 | ||
325 | /* Check Interrupt Polarity */ | 260 | /* Get the IRQ Table length (Byte4) */ |
326 | |||
327 | output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1; | ||
328 | |||
329 | /* Check for sharable */ | ||
330 | |||
331 | output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01; | ||
332 | |||
333 | /* Point to Byte4 (IRQ Table length) */ | ||
334 | |||
335 | buffer += 1; | ||
336 | temp8 = *buffer; | ||
337 | |||
338 | /* Must have at least one IRQ */ | ||
339 | 261 | ||
262 | temp8 = aml->extended_irq.table_length; | ||
263 | resource->data.extended_irq.interrupt_count = temp8; | ||
340 | if (temp8 < 1) { | 264 | if (temp8 < 1) { |
265 | /* Must have at least one IRQ */ | ||
266 | |||
341 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | 267 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); |
342 | } | 268 | } |
343 | 269 | ||
344 | output_struct->data.extended_irq.number_of_interrupts = temp8; | ||
345 | |||
346 | /* | 270 | /* |
347 | * Add any additional structure size to properly calculate | 271 | * Add any additional structure size to properly calculate |
348 | * the next pointer at the end of this function | 272 | * the next pointer at the end of this function |
349 | */ | 273 | */ |
350 | struct_size += (temp8 - 1) * 4; | 274 | resource->length = (temp8 - 1) * 4; |
275 | out_resource_string = ACPI_CAST_PTR(char, | ||
276 | (&resource->data.extended_irq. | ||
277 | interrupts[0] + temp8)); | ||
351 | 278 | ||
352 | /* Point to Byte5 (First IRQ Number) */ | 279 | /* Get every IRQ in the table, each is 32 bits */ |
353 | 280 | ||
354 | buffer += 1; | 281 | acpi_rs_move_data(resource->data.extended_irq.interrupts, |
282 | aml->extended_irq.interrupt_number, | ||
283 | (u16) temp8, ACPI_MOVE_TYPE_32_TO_32); | ||
355 | 284 | ||
356 | /* Cycle through every IRQ in the table */ | 285 | /* Get the optional resource_source (index and string) */ |
357 | 286 | ||
358 | for (index = 0; index < temp8; index++) { | 287 | resource->length += |
359 | ACPI_MOVE_32_TO_32(&output_struct->data.extended_irq. | 288 | acpi_rs_get_resource_source(aml_resource_length, |
360 | interrupts[index], buffer); | 289 | (acpi_size) resource->length + |
290 | sizeof(struct | ||
291 | aml_resource_extended_irq), | ||
292 | &resource->data.extended_irq. | ||
293 | resource_source, aml, | ||
294 | out_resource_string); | ||
361 | 295 | ||
362 | /* Point to the next IRQ */ | 296 | /* Complete the resource header */ |
363 | 297 | ||
364 | buffer += 4; | 298 | resource->type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; |
365 | } | 299 | resource->length += |
366 | 300 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_extended_irq); | |
367 | /* | ||
368 | * This will leave us pointing to the Resource Source Index | ||
369 | * If it is present, then save it off and calculate the | ||
370 | * pointer to where the null terminated string goes: | ||
371 | * Each Interrupt takes 32-bits + the 5 bytes of the | ||
372 | * stream that are default. | ||
373 | * | ||
374 | * Note: Some resource descriptors will have an additional null, so | ||
375 | * we add 1 to the length. | ||
376 | */ | ||
377 | if (*bytes_consumed > | ||
378 | ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * | ||
379 | 4) + (5 + 1)) { | ||
380 | /* Dereference the Index */ | ||
381 | |||
382 | temp8 = *buffer; | ||
383 | output_struct->data.extended_irq.resource_source.index = | ||
384 | (u32) temp8; | ||
385 | |||
386 | /* Point to the String */ | ||
387 | |||
388 | buffer += 1; | ||
389 | |||
390 | /* Point the String pointer to the end of this structure. */ | ||
391 | |||
392 | output_struct->data.extended_irq.resource_source.string_ptr = | ||
393 | (char *)((char *)output_struct + struct_size); | ||
394 | |||
395 | temp_ptr = (u8 *) | ||
396 | output_struct->data.extended_irq.resource_source.string_ptr; | ||
397 | |||
398 | /* Copy the string into the buffer */ | ||
399 | |||
400 | index = 0; | ||
401 | while (*buffer) { | ||
402 | *temp_ptr = *buffer; | ||
403 | |||
404 | temp_ptr += 1; | ||
405 | buffer += 1; | ||
406 | index += 1; | ||
407 | } | ||
408 | |||
409 | /* Add the terminating null */ | ||
410 | |||
411 | *temp_ptr = 0; | ||
412 | output_struct->data.extended_irq.resource_source.string_length = | ||
413 | index + 1; | ||
414 | |||
415 | /* | ||
416 | * In order for the struct_size to fall on a 32-bit boundary, | ||
417 | * calculate the length of the string and expand the | ||
418 | * struct_size to the next 32-bit boundary. | ||
419 | */ | ||
420 | temp8 = (u8) (index + 1); | ||
421 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp8); | ||
422 | } else { | ||
423 | output_struct->data.extended_irq.resource_source.index = 0; | ||
424 | output_struct->data.extended_irq.resource_source.string_length = | ||
425 | 0; | ||
426 | output_struct->data.extended_irq.resource_source.string_ptr = | ||
427 | NULL; | ||
428 | } | ||
429 | |||
430 | /* Set the Length parameter */ | ||
431 | |||
432 | output_struct->length = (u32) struct_size; | ||
433 | |||
434 | /* Return the final size of the structure */ | ||
435 | |||
436 | *structure_size = struct_size; | ||
437 | return_ACPI_STATUS(AE_OK); | 301 | return_ACPI_STATUS(AE_OK); |
438 | } | 302 | } |
439 | 303 | ||
440 | /******************************************************************************* | 304 | /******************************************************************************* |
441 | * | 305 | * |
442 | * FUNCTION: acpi_rs_extended_irq_stream | 306 | * FUNCTION: acpi_rs_set_ext_irq |
443 | * | 307 | * |
444 | * PARAMETERS: Resource - Pointer to the resource linked list | 308 | * PARAMETERS: Resource - Pointer to the resource descriptor |
445 | * output_buffer - Pointer to the user's return buffer | 309 | * Aml - Where the AML descriptor is returned |
446 | * bytes_consumed - Pointer to where the number of bytes | ||
447 | * used in the output_buffer is returned | ||
448 | * | 310 | * |
449 | * RETURN: Status | 311 | * RETURN: Status |
450 | * | 312 | * |
451 | * DESCRIPTION: Take the linked list resource structure and fills in the | 313 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
452 | * the appropriate bytes in a byte stream | 314 | * external AML resource descriptor. |
453 | * | 315 | * |
454 | ******************************************************************************/ | 316 | ******************************************************************************/ |
455 | 317 | ||
456 | acpi_status | 318 | acpi_status |
457 | acpi_rs_extended_irq_stream(struct acpi_resource *resource, | 319 | acpi_rs_set_ext_irq(struct acpi_resource *resource, union aml_resource *aml) |
458 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
459 | { | 320 | { |
460 | u8 *buffer = *output_buffer; | 321 | acpi_size descriptor_length; |
461 | u16 *length_field; | ||
462 | u8 temp8 = 0; | ||
463 | u8 index; | ||
464 | |||
465 | ACPI_FUNCTION_TRACE("rs_extended_irq_stream"); | ||
466 | |||
467 | /* Set the Descriptor Type field */ | ||
468 | |||
469 | *buffer = ACPI_RDESC_TYPE_EXTENDED_XRUPT; | ||
470 | buffer += 1; | ||
471 | 322 | ||
472 | /* Save a pointer to the Length field - to be filled in later */ | 323 | ACPI_FUNCTION_TRACE("rs_set_ext_irq"); |
473 | |||
474 | length_field = ACPI_CAST_PTR(u16, buffer); | ||
475 | buffer += 2; | ||
476 | 324 | ||
477 | /* Set the Interrupt vector flags */ | 325 | /* Set the Interrupt vector flags */ |
478 | 326 | ||
479 | temp8 = (u8) (resource->data.extended_irq.producer_consumer & 0x01); | 327 | aml->extended_irq.flags = (u8) |
480 | temp8 |= ((resource->data.extended_irq.shared_exclusive & 0x01) << 3); | 328 | ((resource->data.extended_irq.producer_consumer & 0x01) | |
329 | ((resource->data.extended_irq.sharable & 0x01) << 3) | | ||
330 | ((resource->data.extended_irq.polarity & 0x1) << 2)); | ||
481 | 331 | ||
482 | /* | 332 | /* |
483 | * Set the Interrupt Mode | 333 | * Set the Interrupt Mode |
@@ -488,64 +338,36 @@ acpi_rs_extended_irq_stream(struct acpi_resource *resource, | |||
488 | * | 338 | * |
489 | * - Edge/Level are defined opposite in the table vs the headers | 339 | * - Edge/Level are defined opposite in the table vs the headers |
490 | */ | 340 | */ |
491 | if (ACPI_EDGE_SENSITIVE == resource->data.extended_irq.edge_level) { | 341 | if (resource->data.extended_irq.triggering == ACPI_EDGE_SENSITIVE) { |
492 | temp8 |= 0x2; | 342 | aml->extended_irq.flags |= 0x02; |
493 | } | 343 | } |
494 | 344 | ||
495 | /* Set the Interrupt Polarity */ | ||
496 | |||
497 | temp8 |= ((resource->data.extended_irq.active_high_low & 0x1) << 2); | ||
498 | |||
499 | *buffer = temp8; | ||
500 | buffer += 1; | ||
501 | |||
502 | /* Set the Interrupt table length */ | 345 | /* Set the Interrupt table length */ |
503 | 346 | ||
504 | temp8 = (u8) resource->data.extended_irq.number_of_interrupts; | 347 | aml->extended_irq.table_length = (u8) |
505 | 348 | resource->data.extended_irq.interrupt_count; | |
506 | *buffer = temp8; | ||
507 | buffer += 1; | ||
508 | 349 | ||
509 | for (index = 0; | 350 | descriptor_length = (sizeof(struct aml_resource_extended_irq) - 4) + |
510 | index < resource->data.extended_irq.number_of_interrupts; | 351 | ((acpi_size) resource->data.extended_irq.interrupt_count * |
511 | index++) { | 352 | sizeof(u32)); |
512 | ACPI_MOVE_32_TO_32(buffer, | ||
513 | &resource->data.extended_irq. | ||
514 | interrupts[index]); | ||
515 | buffer += 4; | ||
516 | } | ||
517 | |||
518 | /* Resource Source Index and Resource Source are optional */ | ||
519 | 353 | ||
520 | if (0 != resource->data.extended_irq.resource_source.string_length) { | 354 | /* Set each interrupt value */ |
521 | *buffer = | ||
522 | (u8) resource->data.extended_irq.resource_source.index; | ||
523 | buffer += 1; | ||
524 | 355 | ||
525 | /* Copy the string */ | 356 | acpi_rs_move_data(aml->extended_irq.interrupt_number, |
357 | resource->data.extended_irq.interrupts, | ||
358 | (u16) resource->data.extended_irq.interrupt_count, | ||
359 | ACPI_MOVE_TYPE_32_TO_32); | ||
526 | 360 | ||
527 | ACPI_STRCPY((char *)buffer, | 361 | /* Resource Source Index and Resource Source are optional */ |
528 | resource->data.extended_irq.resource_source. | ||
529 | string_ptr); | ||
530 | |||
531 | /* | ||
532 | * Buffer needs to be set to the length of the string + one for the | ||
533 | * terminating null | ||
534 | */ | ||
535 | buffer += | ||
536 | (acpi_size) (ACPI_STRLEN | ||
537 | (resource->data.extended_irq.resource_source. | ||
538 | string_ptr) + 1); | ||
539 | } | ||
540 | 362 | ||
541 | /* Return the number of bytes consumed in this operation */ | 363 | descriptor_length = acpi_rs_set_resource_source(aml, descriptor_length, |
364 | &resource->data. | ||
365 | extended_irq. | ||
366 | resource_source); | ||
542 | 367 | ||
543 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 368 | /* Complete the AML descriptor header */ |
544 | 369 | ||
545 | /* | 370 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_EXTENDED_IRQ, |
546 | * Set the length field to the number of bytes consumed | 371 | descriptor_length, aml); |
547 | * minus the header size (3 bytes) | ||
548 | */ | ||
549 | *length_field = (u16) (*bytes_consumed - 3); | ||
550 | return_ACPI_STATUS(AE_OK); | 372 | return_ACPI_STATUS(AE_OK); |
551 | } | 373 | } |
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c index 87e75349dd0a..f72d42e0927b 100644 --- a/drivers/acpi/resources/rslist.c +++ b/drivers/acpi/resources/rslist.c | |||
@@ -47,106 +47,70 @@ | |||
47 | #define _COMPONENT ACPI_RESOURCES | 47 | #define _COMPONENT ACPI_RESOURCES |
48 | ACPI_MODULE_NAME("rslist") | 48 | ACPI_MODULE_NAME("rslist") |
49 | 49 | ||
50 | /* Dispatch table for convert-to-stream functions */ | ||
51 | typedef | ||
52 | acpi_status(*ACPI_STREAM_HANDLER) (struct acpi_resource * resource, | ||
53 | u8 ** output_buffer, | ||
54 | acpi_size * bytes_consumed); | ||
55 | |||
56 | static ACPI_STREAM_HANDLER acpi_gbl_stream_dispatch[] = { | ||
57 | acpi_rs_irq_stream, /* ACPI_RSTYPE_IRQ */ | ||
58 | acpi_rs_dma_stream, /* ACPI_RSTYPE_DMA */ | ||
59 | acpi_rs_start_depend_fns_stream, /* ACPI_RSTYPE_START_DPF */ | ||
60 | acpi_rs_end_depend_fns_stream, /* ACPI_RSTYPE_END_DPF */ | ||
61 | acpi_rs_io_stream, /* ACPI_RSTYPE_IO */ | ||
62 | acpi_rs_fixed_io_stream, /* ACPI_RSTYPE_FIXED_IO */ | ||
63 | acpi_rs_vendor_stream, /* ACPI_RSTYPE_VENDOR */ | ||
64 | acpi_rs_end_tag_stream, /* ACPI_RSTYPE_END_TAG */ | ||
65 | acpi_rs_memory24_stream, /* ACPI_RSTYPE_MEM24 */ | ||
66 | acpi_rs_memory32_range_stream, /* ACPI_RSTYPE_MEM32 */ | ||
67 | acpi_rs_fixed_memory32_stream, /* ACPI_RSTYPE_FIXED_MEM32 */ | ||
68 | acpi_rs_address16_stream, /* ACPI_RSTYPE_ADDRESS16 */ | ||
69 | acpi_rs_address32_stream, /* ACPI_RSTYPE_ADDRESS32 */ | ||
70 | acpi_rs_address64_stream, /* ACPI_RSTYPE_ADDRESS64 */ | ||
71 | acpi_rs_extended_irq_stream, /* ACPI_RSTYPE_EXT_IRQ */ | ||
72 | acpi_rs_generic_register_stream /* ACPI_RSTYPE_GENERIC_REG */ | ||
73 | }; | ||
74 | |||
75 | /* Dispatch tables for convert-to-resource functions */ | ||
76 | |||
77 | typedef | ||
78 | acpi_status(*ACPI_RESOURCE_HANDLER) (u8 * byte_stream_buffer, | ||
79 | acpi_size * bytes_consumed, | ||
80 | u8 ** output_buffer, | ||
81 | acpi_size * structure_size); | ||
82 | |||
83 | static ACPI_RESOURCE_HANDLER acpi_gbl_sm_resource_dispatch[] = { | ||
84 | NULL, /* 0x00, Reserved */ | ||
85 | NULL, /* 0x01, Reserved */ | ||
86 | NULL, /* 0x02, Reserved */ | ||
87 | NULL, /* 0x03, Reserved */ | ||
88 | acpi_rs_irq_resource, /* ACPI_RDESC_TYPE_IRQ_FORMAT */ | ||
89 | acpi_rs_dma_resource, /* ACPI_RDESC_TYPE_DMA_FORMAT */ | ||
90 | acpi_rs_start_depend_fns_resource, /* ACPI_RDESC_TYPE_START_DEPENDENT */ | ||
91 | acpi_rs_end_depend_fns_resource, /* ACPI_RDESC_TYPE_END_DEPENDENT */ | ||
92 | acpi_rs_io_resource, /* ACPI_RDESC_TYPE_IO_PORT */ | ||
93 | acpi_rs_fixed_io_resource, /* ACPI_RDESC_TYPE_FIXED_IO_PORT */ | ||
94 | NULL, /* 0x0A, Reserved */ | ||
95 | NULL, /* 0x0B, Reserved */ | ||
96 | NULL, /* 0x0C, Reserved */ | ||
97 | NULL, /* 0x0D, Reserved */ | ||
98 | acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_SMALL_VENDOR */ | ||
99 | acpi_rs_end_tag_resource /* ACPI_RDESC_TYPE_END_TAG */ | ||
100 | }; | ||
101 | |||
102 | static ACPI_RESOURCE_HANDLER acpi_gbl_lg_resource_dispatch[] = { | ||
103 | NULL, /* 0x00, Reserved */ | ||
104 | acpi_rs_memory24_resource, /* ACPI_RDESC_TYPE_MEMORY_24 */ | ||
105 | acpi_rs_generic_register_resource, /* ACPI_RDESC_TYPE_GENERIC_REGISTER */ | ||
106 | NULL, /* 0x03, Reserved */ | ||
107 | acpi_rs_vendor_resource, /* ACPI_RDESC_TYPE_LARGE_VENDOR */ | ||
108 | acpi_rs_memory32_range_resource, /* ACPI_RDESC_TYPE_MEMORY_32 */ | ||
109 | acpi_rs_fixed_memory32_resource, /* ACPI_RDESC_TYPE_FIXED_MEMORY_32 */ | ||
110 | acpi_rs_address32_resource, /* ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE */ | ||
111 | acpi_rs_address16_resource, /* ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE */ | ||
112 | acpi_rs_extended_irq_resource, /* ACPI_RDESC_TYPE_EXTENDED_XRUPT */ | ||
113 | acpi_rs_address64_resource, /* ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE */ | ||
114 | acpi_rs_address64_resource /* ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE */ | ||
115 | }; | ||
116 | |||
117 | /* Local prototypes */ | 50 | /* Local prototypes */ |
51 | static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type); | ||
118 | 52 | ||
119 | static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type); | 53 | static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml); |
120 | 54 | ||
121 | /******************************************************************************* | 55 | /******************************************************************************* |
122 | * | 56 | * |
123 | * FUNCTION: acpi_rs_get_resource_type | 57 | * FUNCTION: acpi_rs_validate_resource_length |
124 | * | 58 | * |
125 | * PARAMETERS: resource_type - Byte 0 of a resource descriptor | 59 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
126 | * | 60 | * |
127 | * RETURN: The Resource Type with no extraneous bits (except the large/ | 61 | * RETURN: Status - AE_OK if the resource length appears valid |
128 | * small bit -- left alone) | ||
129 | * | 62 | * |
130 | * DESCRIPTION: Extract the Resource Type/Name from the first byte of | 63 | * DESCRIPTION: Validate the resource_length. Fixed-length descriptors must |
131 | * a resource descriptor. | 64 | * have the exact length; variable-length descriptors must be |
65 | * at least as long as the minimum. Certain Small descriptors | ||
66 | * can vary in size by at most one byte. | ||
132 | * | 67 | * |
133 | ******************************************************************************/ | 68 | ******************************************************************************/ |
134 | 69 | ||
135 | u8 acpi_rs_get_resource_type(u8 resource_type) | 70 | static acpi_status acpi_rs_validate_resource_length(union aml_resource *aml) |
136 | { | 71 | { |
72 | struct acpi_resource_info *resource_info; | ||
73 | u16 minimum_aml_resource_length; | ||
74 | u16 resource_length; | ||
75 | |||
137 | ACPI_FUNCTION_ENTRY(); | 76 | ACPI_FUNCTION_ENTRY(); |
138 | 77 | ||
139 | /* Determine if this is a small or large resource */ | 78 | /* Get the size and type info about this resource descriptor */ |
140 | 79 | ||
141 | if (resource_type & ACPI_RDESC_TYPE_LARGE) { | 80 | resource_info = |
142 | /* Large Resource Type -- bits 6:0 contain the name */ | 81 | acpi_rs_get_resource_info(aml->small_header.descriptor_type); |
82 | if (!resource_info) { | ||
83 | return (AE_AML_INVALID_RESOURCE_TYPE); | ||
84 | } | ||
85 | |||
86 | resource_length = acpi_rs_get_resource_length(aml); | ||
87 | minimum_aml_resource_length = | ||
88 | resource_info->minimum_aml_resource_length; | ||
89 | |||
90 | /* Validate based upon the type of resource, fixed length or variable */ | ||
91 | |||
92 | if (resource_info->length_type == ACPI_FIXED_LENGTH) { | ||
93 | /* Fixed length resource, length must match exactly */ | ||
143 | 94 | ||
144 | return (resource_type); | 95 | if (resource_length != minimum_aml_resource_length) { |
96 | return (AE_AML_BAD_RESOURCE_LENGTH); | ||
97 | } | ||
98 | } else if (resource_info->length_type == ACPI_VARIABLE_LENGTH) { | ||
99 | /* Variable length resource, must be at least the minimum */ | ||
100 | |||
101 | if (resource_length < minimum_aml_resource_length) { | ||
102 | return (AE_AML_BAD_RESOURCE_LENGTH); | ||
103 | } | ||
145 | } else { | 104 | } else { |
146 | /* Small Resource Type -- bits 6:3 contain the name */ | 105 | /* Small variable length resource, allowed to be (Min) or (Min-1) */ |
147 | 106 | ||
148 | return ((u8) (resource_type & ACPI_RDESC_SMALL_MASK)); | 107 | if ((resource_length > minimum_aml_resource_length) || |
108 | (resource_length < (minimum_aml_resource_length - 1))) { | ||
109 | return (AE_AML_BAD_RESOURCE_LENGTH); | ||
110 | } | ||
149 | } | 111 | } |
112 | |||
113 | return (AE_OK); | ||
150 | } | 114 | } |
151 | 115 | ||
152 | /******************************************************************************* | 116 | /******************************************************************************* |
@@ -162,38 +126,38 @@ u8 acpi_rs_get_resource_type(u8 resource_type) | |||
162 | * | 126 | * |
163 | ******************************************************************************/ | 127 | ******************************************************************************/ |
164 | 128 | ||
165 | static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) | 129 | static ACPI_GET_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) |
166 | { | 130 | { |
167 | ACPI_FUNCTION_ENTRY(); | 131 | ACPI_FUNCTION_ENTRY(); |
168 | 132 | ||
169 | /* Determine if this is a small or large resource */ | 133 | /* Determine if this is a small or large resource */ |
170 | 134 | ||
171 | if (resource_type & ACPI_RDESC_TYPE_LARGE) { | 135 | if (resource_type & ACPI_RESOURCE_NAME_LARGE) { |
172 | /* Large Resource Type -- bits 6:0 contain the name */ | 136 | /* Large Resource Type -- bits 6:0 contain the name */ |
173 | 137 | ||
174 | if (resource_type > ACPI_RDESC_LARGE_MAX) { | 138 | if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { |
175 | return (NULL); | 139 | return (NULL); |
176 | } | 140 | } |
177 | 141 | ||
178 | return (acpi_gbl_lg_resource_dispatch[(resource_type & | 142 | return (acpi_gbl_lg_get_resource_dispatch[(resource_type & |
179 | ACPI_RDESC_LARGE_MASK)]); | 143 | ACPI_RESOURCE_NAME_LARGE_MASK)]); |
180 | } else { | 144 | } else { |
181 | /* Small Resource Type -- bits 6:3 contain the name */ | 145 | /* Small Resource Type -- bits 6:3 contain the name */ |
182 | 146 | ||
183 | return (acpi_gbl_sm_resource_dispatch[((resource_type & | 147 | return (acpi_gbl_sm_get_resource_dispatch[((resource_type & |
184 | ACPI_RDESC_SMALL_MASK) | 148 | ACPI_RESOURCE_NAME_SMALL_MASK) |
185 | >> 3)]); | 149 | >> 3)]); |
186 | } | 150 | } |
187 | } | 151 | } |
188 | 152 | ||
189 | /******************************************************************************* | 153 | /******************************************************************************* |
190 | * | 154 | * |
191 | * FUNCTION: acpi_rs_byte_stream_to_list | 155 | * FUNCTION: acpi_rs_convert_aml_to_resources |
192 | * | 156 | * |
193 | * PARAMETERS: byte_stream_buffer - Pointer to the resource byte stream | 157 | * PARAMETERS: aml_buffer - Pointer to the resource byte stream |
194 | * byte_stream_buffer_length - Length of byte_stream_buffer | 158 | * aml_buffer_length - Length of aml_buffer |
195 | * output_buffer - Pointer to the buffer that will | 159 | * output_buffer - Pointer to the buffer that will |
196 | * contain the output structures | 160 | * contain the output structures |
197 | * | 161 | * |
198 | * RETURN: Status | 162 | * RETURN: Status |
199 | * | 163 | * |
@@ -203,37 +167,60 @@ static ACPI_RESOURCE_HANDLER acpi_rs_get_resource_handler(u8 resource_type) | |||
203 | ******************************************************************************/ | 167 | ******************************************************************************/ |
204 | 168 | ||
205 | acpi_status | 169 | acpi_status |
206 | acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, | 170 | acpi_rs_convert_aml_to_resources(u8 * aml_buffer, |
207 | u32 byte_stream_buffer_length, u8 * output_buffer) | 171 | u32 aml_buffer_length, u8 * output_buffer) |
208 | { | 172 | { |
209 | u8 *buffer = output_buffer; | 173 | u8 *buffer = output_buffer; |
210 | acpi_status status; | 174 | acpi_status status; |
211 | acpi_size bytes_parsed = 0; | 175 | acpi_size bytes_parsed = 0; |
212 | acpi_size bytes_consumed = 0; | ||
213 | acpi_size structure_size = 0; | ||
214 | struct acpi_resource *resource; | 176 | struct acpi_resource *resource; |
215 | ACPI_RESOURCE_HANDLER handler; | 177 | u16 resource_length; |
178 | u32 descriptor_length; | ||
179 | ACPI_GET_RESOURCE_HANDLER handler; | ||
216 | 180 | ||
217 | ACPI_FUNCTION_TRACE("rs_byte_stream_to_list"); | 181 | ACPI_FUNCTION_TRACE("rs_convert_aml_to_resources"); |
218 | 182 | ||
219 | /* Loop until end-of-buffer or an end_tag is found */ | 183 | /* Loop until end-of-buffer or an end_tag is found */ |
220 | 184 | ||
221 | while (bytes_parsed < byte_stream_buffer_length) { | 185 | while (bytes_parsed < aml_buffer_length) { |
222 | /* Get the handler associated with this Descriptor Type */ | 186 | /* Get the handler associated with this Descriptor Type */ |
223 | 187 | ||
224 | handler = acpi_rs_get_resource_handler(*byte_stream_buffer); | 188 | handler = acpi_rs_get_resource_handler(*aml_buffer); |
225 | if (handler) { | 189 | if (!handler) { |
226 | /* Convert a byte stream resource to local resource struct */ | 190 | /* No handler indicates invalid resource type */ |
227 | 191 | ||
228 | status = handler(byte_stream_buffer, &bytes_consumed, | 192 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); |
229 | &buffer, &structure_size); | 193 | } |
230 | } else { | ||
231 | /* Invalid resource type */ | ||
232 | 194 | ||
233 | status = AE_AML_INVALID_RESOURCE_TYPE; | 195 | resource_length = |
196 | acpi_rs_get_resource_length(ACPI_CAST_PTR | ||
197 | (union aml_resource, | ||
198 | aml_buffer)); | ||
199 | |||
200 | descriptor_length = | ||
201 | acpi_rs_get_descriptor_length(ACPI_CAST_PTR | ||
202 | (union aml_resource, | ||
203 | aml_buffer)); | ||
204 | |||
205 | /* | ||
206 | * Perform limited validation of the resource length, based upon | ||
207 | * what we know about the resource type | ||
208 | */ | ||
209 | status = | ||
210 | acpi_rs_validate_resource_length(ACPI_CAST_PTR | ||
211 | (union aml_resource, | ||
212 | aml_buffer)); | ||
213 | if (ACPI_FAILURE(status)) { | ||
214 | return_ACPI_STATUS(status); | ||
234 | } | 215 | } |
235 | 216 | ||
217 | /* Convert a byte stream resource to local resource struct */ | ||
218 | |||
219 | status = handler(ACPI_CAST_PTR(union aml_resource, aml_buffer), | ||
220 | resource_length, | ||
221 | ACPI_CAST_PTR(struct acpi_resource, buffer)); | ||
236 | if (ACPI_FAILURE(status)) { | 222 | if (ACPI_FAILURE(status)) { |
223 | ACPI_REPORT_ERROR(("Could not convert AML resource (type %X) to resource, %s\n", *aml_buffer, acpi_format_exception(status))); | ||
237 | return_ACPI_STATUS(status); | 224 | return_ACPI_STATUS(status); |
238 | } | 225 | } |
239 | 226 | ||
@@ -245,19 +232,19 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, | |||
245 | 232 | ||
246 | /* Normal exit on completion of an end_tag resource descriptor */ | 233 | /* Normal exit on completion of an end_tag resource descriptor */ |
247 | 234 | ||
248 | if (acpi_rs_get_resource_type(*byte_stream_buffer) == | 235 | if (acpi_rs_get_resource_type(*aml_buffer) == |
249 | ACPI_RDESC_TYPE_END_TAG) { | 236 | ACPI_RESOURCE_NAME_END_TAG) { |
250 | return_ACPI_STATUS(AE_OK); | 237 | return_ACPI_STATUS(AE_OK); |
251 | } | 238 | } |
252 | 239 | ||
253 | /* Update counter and point to the next input resource */ | 240 | /* Update counter and point to the next input resource */ |
254 | 241 | ||
255 | bytes_parsed += bytes_consumed; | 242 | bytes_parsed += descriptor_length; |
256 | byte_stream_buffer += bytes_consumed; | 243 | aml_buffer += descriptor_length; |
257 | 244 | ||
258 | /* Point to the next structure in the output buffer */ | 245 | /* Point to the next structure in the output buffer */ |
259 | 246 | ||
260 | buffer += ACPI_ALIGN_RESOURCE_SIZE(structure_size); | 247 | buffer += resource->length; |
261 | } | 248 | } |
262 | 249 | ||
263 | /* Completed buffer, but did not find an end_tag resource descriptor */ | 250 | /* Completed buffer, but did not find an end_tag resource descriptor */ |
@@ -267,17 +254,15 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, | |||
267 | 254 | ||
268 | /******************************************************************************* | 255 | /******************************************************************************* |
269 | * | 256 | * |
270 | * FUNCTION: acpi_rs_list_to_byte_stream | 257 | * FUNCTION: acpi_rs_convert_resources_to_aml |
271 | * | 258 | * |
272 | * PARAMETERS: Resource - Pointer to the resource linked list | 259 | * PARAMETERS: Resource - Pointer to the resource linked list |
273 | * byte_steam_size_needed - Calculated size of the byte stream | 260 | * aml_size_needed - Calculated size of the byte stream |
274 | * needed from calling | 261 | * needed from calling acpi_rs_get_aml_length() |
275 | * acpi_rs_get_byte_stream_length() | 262 | * The size of the output_buffer is |
276 | * The size of the output_buffer is | 263 | * guaranteed to be >= aml_size_needed |
277 | * guaranteed to be >= | 264 | * output_buffer - Pointer to the buffer that will |
278 | * byte_stream_size_needed | 265 | * contain the byte stream |
279 | * output_buffer - Pointer to the buffer that will | ||
280 | * contain the byte stream | ||
281 | * | 266 | * |
282 | * RETURN: Status | 267 | * RETURN: Status |
283 | * | 268 | * |
@@ -287,52 +272,69 @@ acpi_rs_byte_stream_to_list(u8 * byte_stream_buffer, | |||
287 | ******************************************************************************/ | 272 | ******************************************************************************/ |
288 | 273 | ||
289 | acpi_status | 274 | acpi_status |
290 | acpi_rs_list_to_byte_stream(struct acpi_resource *resource, | 275 | acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, |
291 | acpi_size byte_stream_size_needed, | 276 | acpi_size aml_size_needed, u8 * output_buffer) |
292 | u8 * output_buffer) | ||
293 | { | 277 | { |
294 | u8 *buffer = output_buffer; | 278 | u8 *aml_buffer = output_buffer; |
295 | acpi_size bytes_consumed = 0; | ||
296 | acpi_status status; | 279 | acpi_status status; |
297 | 280 | ||
298 | ACPI_FUNCTION_TRACE("rs_list_to_byte_stream"); | 281 | ACPI_FUNCTION_TRACE("rs_convert_resources_to_aml"); |
299 | 282 | ||
300 | /* Convert each resource descriptor in the list */ | 283 | /* Convert each resource descriptor in the list */ |
301 | 284 | ||
302 | while (1) { | 285 | while (1) { |
303 | /* Validate Type before dispatch */ | 286 | /* Validate Resource Descriptor Type before dispatch */ |
304 | 287 | ||
305 | if (resource->type > ACPI_RSTYPE_MAX) { | 288 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { |
306 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 289 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
307 | "Invalid descriptor type (%X) in resource list\n", | 290 | "Invalid descriptor type (%X) in resource list\n", |
308 | resource->type)); | 291 | resource->type)); |
309 | return_ACPI_STATUS(AE_BAD_DATA); | 292 | return_ACPI_STATUS(AE_BAD_DATA); |
310 | } | 293 | } |
311 | 294 | ||
312 | /* Perform the conversion, per resource type */ | 295 | /* Perform the conversion per resource type */ |
296 | |||
297 | status = | ||
298 | acpi_gbl_set_resource_dispatch[resource->type] (resource, | ||
299 | ACPI_CAST_PTR | ||
300 | (union | ||
301 | aml_resource, | ||
302 | aml_buffer)); | ||
303 | if (ACPI_FAILURE(status)) { | ||
304 | ACPI_REPORT_ERROR(("Could not convert resource (type %X) to AML, %s\n", resource->type, acpi_format_exception(status))); | ||
305 | return_ACPI_STATUS(status); | ||
306 | } | ||
307 | |||
308 | /* Perform final sanity check on the new AML resource descriptor */ | ||
313 | 309 | ||
314 | status = acpi_gbl_stream_dispatch[resource->type] (resource, | 310 | status = |
315 | &buffer, | 311 | acpi_rs_validate_resource_length(ACPI_CAST_PTR |
316 | &bytes_consumed); | 312 | (union aml_resource, |
313 | aml_buffer)); | ||
317 | if (ACPI_FAILURE(status)) { | 314 | if (ACPI_FAILURE(status)) { |
318 | return_ACPI_STATUS(status); | 315 | return_ACPI_STATUS(status); |
319 | } | 316 | } |
320 | 317 | ||
321 | /* Check for end-of-list */ | 318 | /* Check for end-of-list, normal exit */ |
322 | 319 | ||
323 | if (resource->type == ACPI_RSTYPE_END_TAG) { | 320 | if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) { |
324 | /* An End Tag indicates the end of the Resource Template */ | 321 | /* An End Tag indicates the end of the input Resource Template */ |
325 | 322 | ||
326 | return_ACPI_STATUS(AE_OK); | 323 | return_ACPI_STATUS(AE_OK); |
327 | } | 324 | } |
328 | 325 | ||
329 | /* Set the Buffer to point to the next (output) resource descriptor */ | 326 | /* Extract the total length of the new descriptor */ |
327 | /* Set the aml_buffer to point to the next (output) resource descriptor */ | ||
330 | 328 | ||
331 | buffer += bytes_consumed; | 329 | aml_buffer += |
330 | acpi_rs_get_descriptor_length(ACPI_CAST_PTR | ||
331 | (union aml_resource, | ||
332 | aml_buffer)); | ||
332 | 333 | ||
333 | /* Point to the next input resource object */ | 334 | /* Point to the next input resource descriptor */ |
334 | 335 | ||
335 | resource = ACPI_PTR_ADD(struct acpi_resource, | 336 | resource = |
336 | resource, resource->length); | 337 | ACPI_PTR_ADD(struct acpi_resource, resource, |
338 | resource->length); | ||
337 | } | 339 | } |
338 | } | 340 | } |
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c index 418f1afb10a3..47e979e7ba35 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 | ******************************************************************************/ |
70 | acpi_status | 65 | acpi_status |
71 | acpi_rs_memory24_resource(u8 * byte_stream_buffer, | 66 | acpi_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 | ||
148 | acpi_status | 107 | acpi_status |
149 | acpi_rs_memory24_stream(struct acpi_resource *resource, | 108 | acpi_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 | ||
222 | acpi_status | 151 | acpi_status |
223 | acpi_rs_memory32_range_resource(u8 * byte_stream_buffer, | 152 | acpi_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 | ||
314 | acpi_status | 193 | acpi_status |
315 | acpi_rs_fixed_memory32_resource(u8 * byte_stream_buffer, | 194 | acpi_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 | ||
380 | acpi_status | 237 | acpi_status |
381 | acpi_rs_memory32_range_stream(struct acpi_resource *resource, | 238 | acpi_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 | ||
450 | acpi_status | 281 | acpi_status |
451 | acpi_rs_fixed_memory32_stream(struct acpi_resource *resource, | 282 | acpi_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 | } |
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c index fa7f5a85b61d..337a0f01cb23 100644 --- a/drivers/acpi/resources/rsmisc.c +++ b/drivers/acpi/resources/rsmisc.c | |||
@@ -49,641 +49,432 @@ ACPI_MODULE_NAME("rsmisc") | |||
49 | 49 | ||
50 | /******************************************************************************* | 50 | /******************************************************************************* |
51 | * | 51 | * |
52 | * FUNCTION: acpi_rs_generic_register_resource | 52 | * FUNCTION: acpi_rs_get_generic_reg |
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 | ******************************************************************************/ |
70 | acpi_status | 65 | acpi_status |
71 | acpi_rs_generic_register_resource(u8 * byte_stream_buffer, | 66 | acpi_rs_get_generic_reg(union aml_resource *aml, |
72 | acpi_size * bytes_consumed, | 67 | u16 aml_resource_length, struct acpi_resource *resource) |
73 | u8 ** output_buffer, | ||
74 | acpi_size * structure_size) | ||
75 | { | 68 | { |
76 | u8 *buffer = byte_stream_buffer; | 69 | ACPI_FUNCTION_TRACE("rs_get_generic_reg"); |
77 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
78 | u16 temp16; | ||
79 | u8 temp8; | ||
80 | acpi_size struct_size = | ||
81 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_reg); | ||
82 | 70 | ||
83 | ACPI_FUNCTION_TRACE("rs_generic_register_resource"); | 71 | /* |
84 | 72 | * Get the following fields from the AML descriptor: | |
85 | /* Byte 0 is the Descriptor Type */ | 73 | * Address Space ID |
86 | 74 | * Register Bit Width | |
87 | buffer += 1; | 75 | * Register Bit Offset |
88 | 76 | * Access Size | |
89 | /* Get the Descriptor Length field (Bytes 1-2) */ | 77 | * Register Address |
90 | 78 | */ | |
91 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 79 | resource->data.generic_reg.space_id = aml->generic_reg.address_space_id; |
92 | buffer += 2; | 80 | resource->data.generic_reg.bit_width = aml->generic_reg.bit_width; |
93 | 81 | resource->data.generic_reg.bit_offset = aml->generic_reg.bit_offset; | |
94 | /* Validate the descriptor length */ | 82 | resource->data.generic_reg.access_size = aml->generic_reg.access_size; |
95 | 83 | ACPI_MOVE_64_TO_64(&resource->data.generic_reg.address, | |
96 | if (temp16 != 12) { | 84 | &aml->generic_reg.address); |
97 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | 85 | |
98 | } | 86 | /* Complete the resource header */ |
99 | 87 | ||
100 | /* The number of bytes consumed is fixed (12 + 3) */ | 88 | resource->type = ACPI_RESOURCE_TYPE_GENERIC_REGISTER; |
101 | 89 | resource->length = | |
102 | *bytes_consumed = 15; | 90 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_generic_register); |
103 | |||
104 | /* Fill out the structure */ | ||
105 | |||
106 | output_struct->type = ACPI_RSTYPE_GENERIC_REG; | ||
107 | |||
108 | /* Get space_id (Byte 3) */ | ||
109 | |||
110 | temp8 = *buffer; | ||
111 | output_struct->data.generic_reg.space_id = temp8; | ||
112 | buffer += 1; | ||
113 | |||
114 | /* Get register_bit_width (Byte 4) */ | ||
115 | |||
116 | temp8 = *buffer; | ||
117 | output_struct->data.generic_reg.bit_width = temp8; | ||
118 | buffer += 1; | ||
119 | |||
120 | /* Get register_bit_offset (Byte 5) */ | ||
121 | |||
122 | temp8 = *buffer; | ||
123 | output_struct->data.generic_reg.bit_offset = temp8; | ||
124 | buffer += 1; | ||
125 | |||
126 | /* Get address_size (Byte 6) */ | ||
127 | |||
128 | temp8 = *buffer; | ||
129 | output_struct->data.generic_reg.address_size = temp8; | ||
130 | buffer += 1; | ||
131 | |||
132 | /* Get register_address (Bytes 7-14) */ | ||
133 | |||
134 | ACPI_MOVE_64_TO_64(&output_struct->data.generic_reg.address, buffer); | ||
135 | |||
136 | /* Set the Length parameter */ | ||
137 | |||
138 | output_struct->length = (u32) struct_size; | ||
139 | |||
140 | /* Return the final size of the structure */ | ||
141 | |||
142 | *structure_size = struct_size; | ||
143 | return_ACPI_STATUS(AE_OK); | 91 | return_ACPI_STATUS(AE_OK); |
144 | } | 92 | } |
145 | 93 | ||
146 | /******************************************************************************* | 94 | /******************************************************************************* |
147 | * | 95 | * |
148 | * FUNCTION: acpi_rs_generic_register_stream | 96 | * FUNCTION: acpi_rs_set_generic_reg |
149 | * | 97 | * |
150 | * PARAMETERS: Resource - Pointer to the resource linked list | 98 | * PARAMETERS: Resource - Pointer to the resource descriptor |
151 | * output_buffer - Pointer to the user's return buffer | 99 | * Aml - Where the AML descriptor is returned |
152 | * bytes_consumed - Pointer to where the number of bytes | ||
153 | * used in the output_buffer is returned | ||
154 | * | 100 | * |
155 | * RETURN: Status | 101 | * RETURN: Status |
156 | * | 102 | * |
157 | * DESCRIPTION: Take the linked list resource structure and fills in the | 103 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
158 | * the appropriate bytes in a byte stream | 104 | * external AML resource descriptor. |
159 | * | 105 | * |
160 | ******************************************************************************/ | 106 | ******************************************************************************/ |
161 | 107 | ||
162 | acpi_status | 108 | acpi_status |
163 | acpi_rs_generic_register_stream(struct acpi_resource *resource, | 109 | acpi_rs_set_generic_reg(struct acpi_resource *resource, union aml_resource *aml) |
164 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
165 | { | 110 | { |
166 | u8 *buffer = *output_buffer; | 111 | ACPI_FUNCTION_TRACE("rs_set_generic_reg"); |
167 | u16 temp16; | ||
168 | |||
169 | ACPI_FUNCTION_TRACE("rs_generic_register_stream"); | ||
170 | |||
171 | /* Set the Descriptor Type (Byte 0) */ | ||
172 | |||
173 | *buffer = ACPI_RDESC_TYPE_GENERIC_REGISTER; | ||
174 | buffer += 1; | ||
175 | |||
176 | /* Set the Descriptor Length (Bytes 1-2) */ | ||
177 | |||
178 | temp16 = 12; | ||
179 | ACPI_MOVE_16_TO_16(buffer, &temp16); | ||
180 | buffer += 2; | ||
181 | |||
182 | /* Set space_id (Byte 3) */ | ||
183 | |||
184 | *buffer = (u8) resource->data.generic_reg.space_id; | ||
185 | buffer += 1; | ||
186 | |||
187 | /* Set register_bit_width (Byte 4) */ | ||
188 | |||
189 | *buffer = (u8) resource->data.generic_reg.bit_width; | ||
190 | buffer += 1; | ||
191 | |||
192 | /* Set register_bit_offset (Byte 5) */ | ||
193 | |||
194 | *buffer = (u8) resource->data.generic_reg.bit_offset; | ||
195 | buffer += 1; | ||
196 | |||
197 | /* Set address_size (Byte 6) */ | ||
198 | |||
199 | *buffer = (u8) resource->data.generic_reg.address_size; | ||
200 | buffer += 1; | ||
201 | |||
202 | /* Set register_address (Bytes 7-14) */ | ||
203 | 112 | ||
204 | ACPI_MOVE_64_TO_64(buffer, &resource->data.generic_reg.address); | 113 | /* |
205 | buffer += 8; | 114 | * Set the following fields in the AML descriptor: |
206 | 115 | * Address Space ID | |
207 | /* Return the number of bytes consumed in this operation */ | 116 | * Register Bit Width |
208 | 117 | * Register Bit Offset | |
209 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 118 | * Access Size |
119 | * Register Address | ||
120 | */ | ||
121 | aml->generic_reg.address_space_id = | ||
122 | (u8) resource->data.generic_reg.space_id; | ||
123 | aml->generic_reg.bit_width = (u8) resource->data.generic_reg.bit_width; | ||
124 | aml->generic_reg.bit_offset = | ||
125 | (u8) resource->data.generic_reg.bit_offset; | ||
126 | aml->generic_reg.access_size = | ||
127 | (u8) resource->data.generic_reg.access_size; | ||
128 | ACPI_MOVE_64_TO_64(&aml->generic_reg.address, | ||
129 | &resource->data.generic_reg.address); | ||
130 | |||
131 | /* Complete the AML descriptor header */ | ||
132 | |||
133 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_GENERIC_REGISTER, | ||
134 | sizeof(struct | ||
135 | aml_resource_generic_register), aml); | ||
210 | return_ACPI_STATUS(AE_OK); | 136 | return_ACPI_STATUS(AE_OK); |
211 | } | 137 | } |
212 | 138 | ||
213 | /******************************************************************************* | 139 | /******************************************************************************* |
214 | * | 140 | * |
215 | * FUNCTION: acpi_rs_end_tag_resource | 141 | * FUNCTION: acpi_rs_get_vendor |
216 | * | 142 | * |
217 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 143 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
218 | * stream | 144 | * aml_resource_length - Length of the resource from the AML header |
219 | * bytes_consumed - Pointer to where the number of bytes | 145 | * Resource - Where the internal resource is returned |
220 | * consumed the byte_stream_buffer is | ||
221 | * returned | ||
222 | * output_buffer - Pointer to the return data buffer | ||
223 | * structure_size - Pointer to where the number of bytes | ||
224 | * in the return data struct is returned | ||
225 | * | 146 | * |
226 | * RETURN: Status | 147 | * RETURN: Status |
227 | * | 148 | * |
228 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 149 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
229 | * structure pointed to by the output_buffer. Return the | 150 | * internal resource descriptor, simplifying bitflags and handling |
230 | * number of bytes consumed from the byte stream. | 151 | * alignment and endian issues if necessary. |
231 | * | 152 | * |
232 | ******************************************************************************/ | 153 | ******************************************************************************/ |
233 | 154 | ||
234 | acpi_status | 155 | acpi_status |
235 | acpi_rs_end_tag_resource(u8 * byte_stream_buffer, | 156 | acpi_rs_get_vendor(union aml_resource *aml, |
236 | acpi_size * bytes_consumed, | 157 | u16 aml_resource_length, struct acpi_resource *resource) |
237 | u8 ** output_buffer, acpi_size * structure_size) | ||
238 | { | 158 | { |
239 | struct acpi_resource *output_struct = (void *)*output_buffer; | 159 | u8 *aml_byte_data; |
240 | acpi_size struct_size = ACPI_RESOURCE_LENGTH; | ||
241 | |||
242 | ACPI_FUNCTION_TRACE("rs_end_tag_resource"); | ||
243 | 160 | ||
244 | /* The number of bytes consumed is static */ | 161 | ACPI_FUNCTION_TRACE("rs_get_vendor"); |
245 | 162 | ||
246 | *bytes_consumed = 2; | 163 | /* Determine if this is a large or small vendor specific item */ |
247 | 164 | ||
248 | /* Fill out the structure */ | 165 | if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { |
166 | /* Large item, Point to the first vendor byte */ | ||
249 | 167 | ||
250 | output_struct->type = ACPI_RSTYPE_END_TAG; | 168 | aml_byte_data = |
169 | ((u8 *) aml) + sizeof(struct aml_resource_large_header); | ||
170 | } else { | ||
171 | /* Small item, Point to the first vendor byte */ | ||
251 | 172 | ||
252 | /* Set the Length parameter */ | 173 | aml_byte_data = |
174 | ((u8 *) aml) + sizeof(struct aml_resource_small_header); | ||
175 | } | ||
253 | 176 | ||
254 | output_struct->length = 0; | 177 | /* Copy the vendor-specific bytes */ |
255 | 178 | ||
256 | /* Return the final size of the structure */ | 179 | ACPI_MEMCPY(resource->data.vendor.byte_data, |
180 | aml_byte_data, aml_resource_length); | ||
181 | resource->data.vendor.byte_length = aml_resource_length; | ||
257 | 182 | ||
258 | *structure_size = struct_size; | 183 | /* |
184 | * In order for the struct_size to fall on a 32-bit boundary, | ||
185 | * calculate the length of the vendor string and expand the | ||
186 | * struct_size to the next 32-bit boundary. | ||
187 | */ | ||
188 | resource->type = ACPI_RESOURCE_TYPE_VENDOR; | ||
189 | resource->length = ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor) + | ||
190 | ACPI_ROUND_UP_to_32_bITS(aml_resource_length); | ||
259 | return_ACPI_STATUS(AE_OK); | 191 | return_ACPI_STATUS(AE_OK); |
260 | } | 192 | } |
261 | 193 | ||
262 | /******************************************************************************* | 194 | /******************************************************************************* |
263 | * | 195 | * |
264 | * FUNCTION: acpi_rs_end_tag_stream | 196 | * FUNCTION: acpi_rs_set_vendor |
265 | * | 197 | * |
266 | * PARAMETERS: Resource - Pointer to the resource linked list | 198 | * PARAMETERS: Resource - Pointer to the resource descriptor |
267 | * output_buffer - Pointer to the user's return buffer | 199 | * Aml - Where the AML descriptor is returned |
268 | * bytes_consumed - Pointer to where the number of bytes | ||
269 | * used in the output_buffer is returned | ||
270 | * | 200 | * |
271 | * RETURN: Status | 201 | * RETURN: Status |
272 | * | 202 | * |
273 | * DESCRIPTION: Take the linked list resource structure and fills in the | 203 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
274 | * the appropriate bytes in a byte stream | 204 | * external AML resource descriptor. |
275 | * | 205 | * |
276 | ******************************************************************************/ | 206 | ******************************************************************************/ |
277 | 207 | ||
278 | acpi_status | 208 | acpi_status |
279 | acpi_rs_end_tag_stream(struct acpi_resource *resource, | 209 | acpi_rs_set_vendor(struct acpi_resource *resource, union aml_resource *aml) |
280 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
281 | { | 210 | { |
282 | u8 *buffer = *output_buffer; | 211 | u32 resource_length; |
283 | u8 temp8 = 0; | 212 | u8 *source; |
213 | u8 *destination; | ||
284 | 214 | ||
285 | ACPI_FUNCTION_TRACE("rs_end_tag_stream"); | 215 | ACPI_FUNCTION_TRACE("rs_set_vendor"); |
286 | 216 | ||
287 | /* The Descriptor Type field is static */ | 217 | resource_length = resource->data.vendor.byte_length; |
218 | source = ACPI_CAST_PTR(u8, resource->data.vendor.byte_data); | ||
288 | 219 | ||
289 | *buffer = ACPI_RDESC_TYPE_END_TAG | 0x01; | 220 | /* Length determines if this is a large or small resource */ |
290 | buffer += 1; | ||
291 | 221 | ||
292 | /* | 222 | if (resource_length > 7) { |
293 | * Set the Checksum - zero means that the resource data is treated as if | 223 | /* Large item, get pointer to the data part of the descriptor */ |
294 | * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) | 224 | |
295 | */ | 225 | destination = |
296 | temp8 = 0; | 226 | ((u8 *) aml) + sizeof(struct aml_resource_large_header); |
227 | |||
228 | /* Complete the AML descriptor header */ | ||
229 | |||
230 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_LARGE, | ||
231 | (u32) (resource_length + | ||
232 | sizeof(struct | ||
233 | aml_resource_large_header)), | ||
234 | aml); | ||
235 | } else { | ||
236 | /* Small item, get pointer to the data part of the descriptor */ | ||
297 | 237 | ||
298 | *buffer = temp8; | 238 | destination = |
299 | buffer += 1; | 239 | ((u8 *) aml) + sizeof(struct aml_resource_small_header); |
300 | 240 | ||
301 | /* Return the number of bytes consumed in this operation */ | 241 | /* Complete the AML descriptor header */ |
302 | 242 | ||
303 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 243 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_VENDOR_SMALL, |
244 | (u32) (resource_length + | ||
245 | sizeof(struct | ||
246 | aml_resource_small_header)), | ||
247 | aml); | ||
248 | } | ||
249 | |||
250 | /* Copy the vendor-specific bytes */ | ||
251 | |||
252 | ACPI_MEMCPY(destination, source, resource_length); | ||
304 | return_ACPI_STATUS(AE_OK); | 253 | return_ACPI_STATUS(AE_OK); |
305 | } | 254 | } |
306 | 255 | ||
307 | /******************************************************************************* | 256 | /******************************************************************************* |
308 | * | 257 | * |
309 | * FUNCTION: acpi_rs_vendor_resource | 258 | * FUNCTION: acpi_rs_get_start_dpf |
310 | * | 259 | * |
311 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 260 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
312 | * stream | 261 | * aml_resource_length - Length of the resource from the AML header |
313 | * bytes_consumed - Pointer to where the number of bytes | 262 | * Resource - Where the internal resource is returned |
314 | * consumed the byte_stream_buffer is | ||
315 | * returned | ||
316 | * output_buffer - Pointer to the return data buffer | ||
317 | * structure_size - Pointer to where the number of bytes | ||
318 | * in the return data struct is returned | ||
319 | * | 263 | * |
320 | * RETURN: Status | 264 | * RETURN: Status |
321 | * | 265 | * |
322 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 266 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
323 | * structure pointed to by the output_buffer. Return the | 267 | * internal resource descriptor, simplifying bitflags and handling |
324 | * number of bytes consumed from the byte stream. | 268 | * alignment and endian issues if necessary. |
325 | * | 269 | * |
326 | ******************************************************************************/ | 270 | ******************************************************************************/ |
327 | 271 | ||
328 | acpi_status | 272 | acpi_status |
329 | acpi_rs_vendor_resource(u8 * byte_stream_buffer, | 273 | acpi_rs_get_start_dpf(union aml_resource *aml, |
330 | acpi_size * bytes_consumed, | 274 | u16 aml_resource_length, struct acpi_resource *resource) |
331 | u8 ** output_buffer, acpi_size * structure_size) | ||
332 | { | 275 | { |
333 | u8 *buffer = byte_stream_buffer; | 276 | ACPI_FUNCTION_TRACE("rs_get_start_dpf"); |
334 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
335 | u16 temp16 = 0; | ||
336 | u8 temp8 = 0; | ||
337 | u8 index; | ||
338 | acpi_size struct_size = | ||
339 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_vendor); | ||
340 | |||
341 | ACPI_FUNCTION_TRACE("rs_vendor_resource"); | ||
342 | |||
343 | /* Dereference the Descriptor to find if this is a large or small item. */ | ||
344 | 277 | ||
345 | temp8 = *buffer; | 278 | /* Get the flags byte if present */ |
346 | 279 | ||
347 | if (temp8 & ACPI_RDESC_TYPE_LARGE) { | 280 | if (aml_resource_length == 1) { |
348 | /* Large Item, point to the length field */ | 281 | /* Get the Compatibility priority */ |
349 | 282 | ||
350 | buffer += 1; | 283 | resource->data.start_dpf.compatibility_priority = |
284 | (aml->start_dpf.flags & 0x03); | ||
351 | 285 | ||
352 | /* Dereference */ | 286 | if (resource->data.start_dpf.compatibility_priority >= 3) { |
353 | 287 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); | |
354 | ACPI_MOVE_16_TO_16(&temp16, buffer); | 288 | } |
355 | |||
356 | /* Calculate bytes consumed */ | ||
357 | 289 | ||
358 | *bytes_consumed = (acpi_size) temp16 + 3; | 290 | /* Get the Performance/Robustness preference */ |
359 | 291 | ||
360 | /* Point to the first vendor byte */ | 292 | resource->data.start_dpf.performance_robustness = |
293 | ((aml->start_dpf.flags >> 2) & 0x03); | ||
361 | 294 | ||
362 | buffer += 2; | 295 | if (resource->data.start_dpf.performance_robustness >= 3) { |
296 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); | ||
297 | } | ||
363 | } else { | 298 | } else { |
364 | /* Small Item, dereference the size */ | 299 | /* start_dependent_no_pri(), no flags byte, set defaults */ |
365 | |||
366 | temp16 = (u8) (*buffer & 0x07); | ||
367 | |||
368 | /* Calculate bytes consumed */ | ||
369 | 300 | ||
370 | *bytes_consumed = (acpi_size) temp16 + 1; | 301 | resource->data.start_dpf.compatibility_priority = |
371 | 302 | ACPI_ACCEPTABLE_CONFIGURATION; | |
372 | /* Point to the first vendor byte */ | ||
373 | 303 | ||
374 | buffer += 1; | 304 | resource->data.start_dpf.performance_robustness = |
305 | ACPI_ACCEPTABLE_CONFIGURATION; | ||
375 | } | 306 | } |
376 | 307 | ||
377 | output_struct->type = ACPI_RSTYPE_VENDOR; | 308 | /* Complete the resource header */ |
378 | output_struct->data.vendor_specific.length = temp16; | ||
379 | |||
380 | for (index = 0; index < temp16; index++) { | ||
381 | output_struct->data.vendor_specific.reserved[index] = *buffer; | ||
382 | buffer += 1; | ||
383 | } | ||
384 | 309 | ||
385 | /* | 310 | resource->type = ACPI_RESOURCE_TYPE_START_DEPENDENT; |
386 | * In order for the struct_size to fall on a 32-bit boundary, | 311 | resource->length = |
387 | * calculate the length of the vendor string and expand the | 312 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dependent); |
388 | * struct_size to the next 32-bit boundary. | ||
389 | */ | ||
390 | struct_size += ACPI_ROUND_UP_to_32_bITS(temp16); | ||
391 | |||
392 | /* Set the Length parameter */ | ||
393 | |||
394 | output_struct->length = (u32) struct_size; | ||
395 | |||
396 | /* Return the final size of the structure */ | ||
397 | |||
398 | *structure_size = struct_size; | ||
399 | return_ACPI_STATUS(AE_OK); | 313 | return_ACPI_STATUS(AE_OK); |
400 | } | 314 | } |
401 | 315 | ||
402 | /******************************************************************************* | 316 | /******************************************************************************* |
403 | * | 317 | * |
404 | * FUNCTION: acpi_rs_vendor_stream | 318 | * FUNCTION: acpi_rs_set_start_dpf |
405 | * | 319 | * |
406 | * PARAMETERS: Resource - Pointer to the resource linked list | 320 | * PARAMETERS: Resource - Pointer to the resource descriptor |
407 | * output_buffer - Pointer to the user's return buffer | 321 | * Aml - Where the AML descriptor is returned |
408 | * bytes_consumed - Pointer to where the number of bytes | ||
409 | * used in the output_buffer is returned | ||
410 | * | 322 | * |
411 | * RETURN: Status | 323 | * RETURN: Status |
412 | * | 324 | * |
413 | * DESCRIPTION: Take the linked list resource structure and fills in the | 325 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
414 | * the appropriate bytes in a byte stream | 326 | * external AML resource descriptor. |
415 | * | 327 | * |
416 | ******************************************************************************/ | 328 | ******************************************************************************/ |
417 | 329 | ||
418 | acpi_status | 330 | acpi_status |
419 | acpi_rs_vendor_stream(struct acpi_resource *resource, | 331 | acpi_rs_set_start_dpf(struct acpi_resource *resource, union aml_resource *aml) |
420 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
421 | { | 332 | { |
422 | u8 *buffer = *output_buffer; | 333 | ACPI_FUNCTION_TRACE("rs_set_start_dpf"); |
423 | u16 temp16 = 0; | ||
424 | u8 temp8 = 0; | ||
425 | u8 index; | ||
426 | |||
427 | ACPI_FUNCTION_TRACE("rs_vendor_stream"); | ||
428 | |||
429 | /* Dereference the length to find if this is a large or small item. */ | ||
430 | |||
431 | if (resource->data.vendor_specific.length > 7) { | ||
432 | /* Large Item, Set the descriptor field and length bytes */ | ||
433 | 334 | ||
434 | *buffer = ACPI_RDESC_TYPE_LARGE_VENDOR; | 335 | /* |
435 | buffer += 1; | 336 | * The descriptor type field is set based upon whether a byte is needed |
436 | 337 | * to contain Priority data. | |
437 | temp16 = (u16) resource->data.vendor_specific.length; | 338 | */ |
438 | 339 | if (ACPI_ACCEPTABLE_CONFIGURATION == | |
439 | ACPI_MOVE_16_TO_16(buffer, &temp16); | 340 | resource->data.start_dpf.compatibility_priority && |
440 | buffer += 2; | 341 | ACPI_ACCEPTABLE_CONFIGURATION == |
342 | resource->data.start_dpf.performance_robustness) { | ||
343 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, | ||
344 | sizeof(struct | ||
345 | aml_resource_start_dependent_noprio), | ||
346 | aml); | ||
441 | } else { | 347 | } else { |
442 | /* Small Item, Set the descriptor field */ | 348 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_START_DEPENDENT, |
443 | 349 | sizeof(struct | |
444 | temp8 = ACPI_RDESC_TYPE_SMALL_VENDOR; | 350 | aml_resource_start_dependent), |
445 | temp8 |= (u8) resource->data.vendor_specific.length; | 351 | aml); |
446 | 352 | ||
447 | *buffer = temp8; | 353 | /* Set the Flags byte */ |
448 | buffer += 1; | 354 | |
449 | } | 355 | aml->start_dpf.flags = (u8) |
450 | 356 | (((resource->data.start_dpf. | |
451 | /* Loop through all of the Vendor Specific fields */ | 357 | performance_robustness & 0x03) << 2) | (resource->data. |
452 | 358 | start_dpf. | |
453 | for (index = 0; index < resource->data.vendor_specific.length; index++) { | 359 | compatibility_priority |
454 | temp8 = resource->data.vendor_specific.reserved[index]; | 360 | & 0x03)); |
455 | |||
456 | *buffer = temp8; | ||
457 | buffer += 1; | ||
458 | } | 361 | } |
459 | |||
460 | /* Return the number of bytes consumed in this operation */ | ||
461 | |||
462 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
463 | return_ACPI_STATUS(AE_OK); | 362 | return_ACPI_STATUS(AE_OK); |
464 | } | 363 | } |
465 | 364 | ||
466 | /******************************************************************************* | 365 | /******************************************************************************* |
467 | * | 366 | * |
468 | * FUNCTION: acpi_rs_start_depend_fns_resource | 367 | * FUNCTION: acpi_rs_get_end_dpf |
469 | * | 368 | * |
470 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 369 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
471 | * stream | 370 | * aml_resource_length - Length of the resource from the AML header |
472 | * bytes_consumed - Pointer to where the number of bytes | 371 | * Resource - Where the internal resource is returned |
473 | * consumed the byte_stream_buffer is | ||
474 | * returned | ||
475 | * output_buffer - Pointer to the return data buffer | ||
476 | * structure_size - Pointer to where the number of bytes | ||
477 | * in the return data struct is returned | ||
478 | * | 372 | * |
479 | * RETURN: Status | 373 | * RETURN: Status |
480 | * | 374 | * |
481 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 375 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
482 | * structure pointed to by the output_buffer. Return the | 376 | * internal resource descriptor, simplifying bitflags and handling |
483 | * number of bytes consumed from the byte stream. | 377 | * alignment and endian issues if necessary. |
484 | * | 378 | * |
485 | ******************************************************************************/ | 379 | ******************************************************************************/ |
486 | 380 | ||
487 | acpi_status | 381 | acpi_status |
488 | acpi_rs_start_depend_fns_resource(u8 * byte_stream_buffer, | 382 | acpi_rs_get_end_dpf(union aml_resource *aml, |
489 | acpi_size * bytes_consumed, | 383 | u16 aml_resource_length, struct acpi_resource *resource) |
490 | u8 ** output_buffer, | ||
491 | acpi_size * structure_size) | ||
492 | { | 384 | { |
493 | u8 *buffer = byte_stream_buffer; | 385 | ACPI_FUNCTION_TRACE("rs_get_end_dpf"); |
494 | struct acpi_resource *output_struct = (void *)*output_buffer; | ||
495 | u8 temp8 = 0; | ||
496 | acpi_size struct_size = | ||
497 | ACPI_SIZEOF_RESOURCE(struct acpi_resource_start_dpf); | ||
498 | |||
499 | ACPI_FUNCTION_TRACE("rs_start_depend_fns_resource"); | ||
500 | |||
501 | /* The number of bytes consumed are found in the descriptor (Bits:0-1) */ | ||
502 | |||
503 | temp8 = *buffer; | ||
504 | |||
505 | *bytes_consumed = (temp8 & 0x01) + 1; | ||
506 | |||
507 | output_struct->type = ACPI_RSTYPE_START_DPF; | ||
508 | |||
509 | /* Point to Byte 1 if it is used */ | ||
510 | |||
511 | if (2 == *bytes_consumed) { | ||
512 | buffer += 1; | ||
513 | temp8 = *buffer; | ||
514 | |||
515 | /* Check Compatibility priority */ | ||
516 | |||
517 | output_struct->data.start_dpf.compatibility_priority = | ||
518 | temp8 & 0x03; | ||
519 | |||
520 | if (3 == output_struct->data.start_dpf.compatibility_priority) { | ||
521 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); | ||
522 | } | ||
523 | 386 | ||
524 | /* Check Performance/Robustness preference */ | 387 | /* Complete the resource header */ |
525 | 388 | ||
526 | output_struct->data.start_dpf.performance_robustness = | 389 | resource->type = ACPI_RESOURCE_TYPE_END_DEPENDENT; |
527 | (temp8 >> 2) & 0x03; | 390 | resource->length = (u32) ACPI_RESOURCE_LENGTH; |
528 | |||
529 | if (3 == output_struct->data.start_dpf.performance_robustness) { | ||
530 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_VALUE); | ||
531 | } | ||
532 | } else { | ||
533 | output_struct->data.start_dpf.compatibility_priority = | ||
534 | ACPI_ACCEPTABLE_CONFIGURATION; | ||
535 | |||
536 | output_struct->data.start_dpf.performance_robustness = | ||
537 | ACPI_ACCEPTABLE_CONFIGURATION; | ||
538 | } | ||
539 | |||
540 | /* Set the Length parameter */ | ||
541 | |||
542 | output_struct->length = (u32) struct_size; | ||
543 | |||
544 | /* Return the final size of the structure */ | ||
545 | |||
546 | *structure_size = struct_size; | ||
547 | return_ACPI_STATUS(AE_OK); | 391 | return_ACPI_STATUS(AE_OK); |
548 | } | 392 | } |
549 | 393 | ||
550 | /******************************************************************************* | 394 | /******************************************************************************* |
551 | * | 395 | * |
552 | * FUNCTION: acpi_rs_end_depend_fns_resource | 396 | * FUNCTION: acpi_rs_set_end_dpf |
553 | * | 397 | * |
554 | * PARAMETERS: byte_stream_buffer - Pointer to the resource input byte | 398 | * PARAMETERS: Resource - Pointer to the resource descriptor |
555 | * stream | 399 | * Aml - Where the AML descriptor is returned |
556 | * bytes_consumed - Pointer to where the number of bytes | ||
557 | * consumed the byte_stream_buffer is | ||
558 | * returned | ||
559 | * output_buffer - Pointer to the return data buffer | ||
560 | * structure_size - Pointer to where the number of bytes | ||
561 | * in the return data struct is returned | ||
562 | * | 400 | * |
563 | * RETURN: Status | 401 | * RETURN: Status |
564 | * | 402 | * |
565 | * DESCRIPTION: Take the resource byte stream and fill out the appropriate | 403 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
566 | * structure pointed to by the output_buffer. Return the | 404 | * external AML resource descriptor. |
567 | * number of bytes consumed from the byte stream. | ||
568 | * | 405 | * |
569 | ******************************************************************************/ | 406 | ******************************************************************************/ |
570 | 407 | ||
571 | acpi_status | 408 | acpi_status |
572 | acpi_rs_end_depend_fns_resource(u8 * byte_stream_buffer, | 409 | acpi_rs_set_end_dpf(struct acpi_resource *resource, union aml_resource *aml) |
573 | acpi_size * bytes_consumed, | ||
574 | u8 ** output_buffer, acpi_size * structure_size) | ||
575 | { | 410 | { |
576 | struct acpi_resource *output_struct = (void *)*output_buffer; | 411 | ACPI_FUNCTION_TRACE("rs_set_end_dpf"); |
577 | acpi_size struct_size = ACPI_RESOURCE_LENGTH; | ||
578 | |||
579 | ACPI_FUNCTION_TRACE("rs_end_depend_fns_resource"); | ||
580 | |||
581 | /* The number of bytes consumed is static */ | ||
582 | |||
583 | *bytes_consumed = 1; | ||
584 | 412 | ||
585 | /* Fill out the structure */ | 413 | /* Complete the AML descriptor header */ |
586 | 414 | ||
587 | output_struct->type = ACPI_RSTYPE_END_DPF; | 415 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_DEPENDENT, |
588 | 416 | sizeof(struct aml_resource_end_dependent), | |
589 | /* Set the Length parameter */ | 417 | aml); |
590 | |||
591 | output_struct->length = (u32) struct_size; | ||
592 | |||
593 | /* Return the final size of the structure */ | ||
594 | |||
595 | *structure_size = struct_size; | ||
596 | return_ACPI_STATUS(AE_OK); | 418 | return_ACPI_STATUS(AE_OK); |
597 | } | 419 | } |
598 | 420 | ||
599 | /******************************************************************************* | 421 | /******************************************************************************* |
600 | * | 422 | * |
601 | * FUNCTION: acpi_rs_start_depend_fns_stream | 423 | * FUNCTION: acpi_rs_get_end_tag |
602 | * | 424 | * |
603 | * PARAMETERS: Resource - Pointer to the resource linked list | 425 | * PARAMETERS: Aml - Pointer to the AML resource descriptor |
604 | * output_buffer - Pointer to the user's return buffer | 426 | * aml_resource_length - Length of the resource from the AML header |
605 | * bytes_consumed - u32 pointer that is filled with | 427 | * Resource - Where the internal resource is returned |
606 | * the number of bytes of the | ||
607 | * output_buffer used | ||
608 | * | 428 | * |
609 | * RETURN: Status | 429 | * RETURN: Status |
610 | * | 430 | * |
611 | * DESCRIPTION: Take the linked list resource structure and fills in the | 431 | * DESCRIPTION: Convert a raw AML resource descriptor to the corresponding |
612 | * the appropriate bytes in a byte stream | 432 | * internal resource descriptor, simplifying bitflags and handling |
433 | * alignment and endian issues if necessary. | ||
613 | * | 434 | * |
614 | ******************************************************************************/ | 435 | ******************************************************************************/ |
615 | 436 | ||
616 | acpi_status | 437 | acpi_status |
617 | acpi_rs_start_depend_fns_stream(struct acpi_resource *resource, | 438 | acpi_rs_get_end_tag(union aml_resource *aml, |
618 | u8 ** output_buffer, acpi_size * bytes_consumed) | 439 | u16 aml_resource_length, struct acpi_resource *resource) |
619 | { | 440 | { |
620 | u8 *buffer = *output_buffer; | 441 | ACPI_FUNCTION_TRACE("rs_get_end_tag"); |
621 | u8 temp8 = 0; | ||
622 | |||
623 | ACPI_FUNCTION_TRACE("rs_start_depend_fns_stream"); | ||
624 | 442 | ||
625 | /* | 443 | /* Complete the resource header */ |
626 | * The descriptor type field is set based upon whether a byte is needed | ||
627 | * to contain Priority data. | ||
628 | */ | ||
629 | if (ACPI_ACCEPTABLE_CONFIGURATION == | ||
630 | resource->data.start_dpf.compatibility_priority && | ||
631 | ACPI_ACCEPTABLE_CONFIGURATION == | ||
632 | resource->data.start_dpf.performance_robustness) { | ||
633 | *buffer = ACPI_RDESC_TYPE_START_DEPENDENT; | ||
634 | } else { | ||
635 | *buffer = ACPI_RDESC_TYPE_START_DEPENDENT | 0x01; | ||
636 | buffer += 1; | ||
637 | |||
638 | /* Set the Priority Byte Definition */ | ||
639 | 444 | ||
640 | temp8 = 0; | 445 | resource->type = ACPI_RESOURCE_TYPE_END_TAG; |
641 | temp8 = (u8) ((resource->data.start_dpf.performance_robustness & | 446 | resource->length = ACPI_RESOURCE_LENGTH; |
642 | 0x03) << 2); | ||
643 | temp8 |= (resource->data.start_dpf.compatibility_priority & | ||
644 | 0x03); | ||
645 | *buffer = temp8; | ||
646 | } | ||
647 | |||
648 | buffer += 1; | ||
649 | |||
650 | /* Return the number of bytes consumed in this operation */ | ||
651 | |||
652 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | ||
653 | return_ACPI_STATUS(AE_OK); | 447 | return_ACPI_STATUS(AE_OK); |
654 | } | 448 | } |
655 | 449 | ||
656 | /******************************************************************************* | 450 | /******************************************************************************* |
657 | * | 451 | * |
658 | * FUNCTION: acpi_rs_end_depend_fns_stream | 452 | * FUNCTION: acpi_rs_set_end_tag |
659 | * | 453 | * |
660 | * PARAMETERS: Resource - Pointer to the resource linked list | 454 | * PARAMETERS: Resource - Pointer to the resource descriptor |
661 | * output_buffer - Pointer to the user's return buffer | 455 | * Aml - Where the AML descriptor is returned |
662 | * bytes_consumed - Pointer to where the number of bytes | ||
663 | * used in the output_buffer is returned | ||
664 | * | 456 | * |
665 | * RETURN: Status | 457 | * RETURN: Status |
666 | * | 458 | * |
667 | * DESCRIPTION: Take the linked list resource structure and fills in the | 459 | * DESCRIPTION: Convert an internal resource descriptor to the corresponding |
668 | * the appropriate bytes in a byte stream | 460 | * external AML resource descriptor. |
669 | * | 461 | * |
670 | ******************************************************************************/ | 462 | ******************************************************************************/ |
671 | 463 | ||
672 | acpi_status | 464 | acpi_status |
673 | acpi_rs_end_depend_fns_stream(struct acpi_resource *resource, | 465 | acpi_rs_set_end_tag(struct acpi_resource *resource, union aml_resource *aml) |
674 | u8 ** output_buffer, acpi_size * bytes_consumed) | ||
675 | { | 466 | { |
676 | u8 *buffer = *output_buffer; | 467 | ACPI_FUNCTION_TRACE("rs_set_end_tag"); |
677 | |||
678 | ACPI_FUNCTION_TRACE("rs_end_depend_fns_stream"); | ||
679 | 468 | ||
680 | /* The Descriptor Type field is static */ | 469 | /* |
681 | 470 | * Set the Checksum - zero means that the resource data is treated as if | |
682 | *buffer = ACPI_RDESC_TYPE_END_DEPENDENT; | 471 | * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) |
683 | buffer += 1; | 472 | */ |
473 | aml->end_tag.checksum = 0; | ||
684 | 474 | ||
685 | /* Return the number of bytes consumed in this operation */ | 475 | /* Complete the AML descriptor header */ |
686 | 476 | ||
687 | *bytes_consumed = ACPI_PTR_DIFF(buffer, *output_buffer); | 477 | acpi_rs_set_resource_header(ACPI_RESOURCE_NAME_END_TAG, |
478 | sizeof(struct aml_resource_end_tag), aml); | ||
688 | return_ACPI_STATUS(AE_OK); | 479 | return_ACPI_STATUS(AE_OK); |
689 | } | 480 | } |
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c index 4446778eaf79..9d503de1a349 100644 --- a/drivers/acpi/resources/rsutils.c +++ b/drivers/acpi/resources/rsutils.c | |||
@@ -50,6 +50,438 @@ ACPI_MODULE_NAME("rsutils") | |||
50 | 50 | ||
51 | /******************************************************************************* | 51 | /******************************************************************************* |
52 | * | 52 | * |
53 | * FUNCTION: acpi_rs_move_data | ||
54 | * | ||
55 | * PARAMETERS: Destination - Pointer to the destination descriptor | ||
56 | * Source - Pointer to the source descriptor | ||
57 | * item_count - How many items to move | ||
58 | * move_type - Byte width | ||
59 | * | ||
60 | * RETURN: None | ||
61 | * | ||
62 | * DESCRIPTION: Move multiple data items from one descriptor to another. Handles | ||
63 | * alignment issues and endian issues if necessary, as configured | ||
64 | * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) | ||
65 | * | ||
66 | ******************************************************************************/ | ||
67 | void | ||
68 | acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) | ||
69 | { | ||
70 | acpi_native_uint i; | ||
71 | |||
72 | /* One move per item */ | ||
73 | |||
74 | for (i = 0; i < item_count; i++) { | ||
75 | switch (move_type) { | ||
76 | case ACPI_MOVE_TYPE_16_TO_32: | ||
77 | ACPI_MOVE_16_TO_32(&((u32 *) destination)[i], | ||
78 | &((u16 *) source)[i]); | ||
79 | break; | ||
80 | |||
81 | case ACPI_MOVE_TYPE_32_TO_16: | ||
82 | ACPI_MOVE_32_TO_16(&((u16 *) destination)[i], | ||
83 | &((u32 *) source)[i]); | ||
84 | break; | ||
85 | |||
86 | case ACPI_MOVE_TYPE_32_TO_32: | ||
87 | ACPI_MOVE_32_TO_32(&((u32 *) destination)[i], | ||
88 | &((u32 *) source)[i]); | ||
89 | break; | ||
90 | |||
91 | case ACPI_MOVE_TYPE_64_TO_64: | ||
92 | ACPI_MOVE_64_TO_64(&((u64 *) destination)[i], | ||
93 | &((u64 *) source)[i]); | ||
94 | break; | ||
95 | |||
96 | default: | ||
97 | return; | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | |||
102 | /******************************************************************************* | ||
103 | * | ||
104 | * FUNCTION: acpi_rs_get_resource_info | ||
105 | * | ||
106 | * PARAMETERS: resource_type - Byte 0 of a resource descriptor | ||
107 | * | ||
108 | * RETURN: Pointer to the resource conversion handler | ||
109 | * | ||
110 | * DESCRIPTION: Extract the Resource Type/Name from the first byte of | ||
111 | * a resource descriptor. | ||
112 | * | ||
113 | ******************************************************************************/ | ||
114 | |||
115 | struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type) | ||
116 | { | ||
117 | struct acpi_resource_info *size_info; | ||
118 | |||
119 | ACPI_FUNCTION_ENTRY(); | ||
120 | |||
121 | /* Determine if this is a small or large resource */ | ||
122 | |||
123 | if (resource_type & ACPI_RESOURCE_NAME_LARGE) { | ||
124 | /* Large Resource Type -- bits 6:0 contain the name */ | ||
125 | |||
126 | if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { | ||
127 | return (NULL); | ||
128 | } | ||
129 | |||
130 | size_info = &acpi_gbl_lg_resource_info[(resource_type & | ||
131 | ACPI_RESOURCE_NAME_LARGE_MASK)]; | ||
132 | } else { | ||
133 | /* Small Resource Type -- bits 6:3 contain the name */ | ||
134 | |||
135 | size_info = &acpi_gbl_sm_resource_info[((resource_type & | ||
136 | ACPI_RESOURCE_NAME_SMALL_MASK) | ||
137 | >> 3)]; | ||
138 | } | ||
139 | |||
140 | /* Zero entry indicates an invalid resource type */ | ||
141 | |||
142 | if (!size_info->minimum_internal_struct_length) { | ||
143 | return (NULL); | ||
144 | } | ||
145 | |||
146 | return (size_info); | ||
147 | } | ||
148 | |||
149 | /******************************************************************************* | ||
150 | * | ||
151 | * FUNCTION: acpi_rs_get_resource_length | ||
152 | * | ||
153 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
154 | * | ||
155 | * RETURN: Byte Length | ||
156 | * | ||
157 | * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By | ||
158 | * definition, this does not include the size of the descriptor | ||
159 | * header or the length field itself. | ||
160 | * | ||
161 | ******************************************************************************/ | ||
162 | |||
163 | u16 acpi_rs_get_resource_length(union aml_resource * aml) | ||
164 | { | ||
165 | u16 resource_length; | ||
166 | |||
167 | ACPI_FUNCTION_ENTRY(); | ||
168 | |||
169 | /* Determine if this is a small or large resource */ | ||
170 | |||
171 | if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { | ||
172 | /* Large Resource type -- bytes 1-2 contain the 16-bit length */ | ||
173 | |||
174 | ACPI_MOVE_16_TO_16(&resource_length, | ||
175 | &aml->large_header.resource_length); | ||
176 | |||
177 | } else { | ||
178 | /* Small Resource type -- bits 2:0 of byte 0 contain the length */ | ||
179 | |||
180 | resource_length = (u16) (aml->small_header.descriptor_type & | ||
181 | ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); | ||
182 | } | ||
183 | |||
184 | return (resource_length); | ||
185 | } | ||
186 | |||
187 | /******************************************************************************* | ||
188 | * | ||
189 | * FUNCTION: acpi_rs_get_descriptor_length | ||
190 | * | ||
191 | * PARAMETERS: Aml - Pointer to the raw AML resource descriptor | ||
192 | * | ||
193 | * RETURN: Byte length | ||
194 | * | ||
195 | * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the | ||
196 | * length of the descriptor header and the length field itself. | ||
197 | * Used to walk descriptor lists. | ||
198 | * | ||
199 | ******************************************************************************/ | ||
200 | |||
201 | u32 acpi_rs_get_descriptor_length(union aml_resource * aml) | ||
202 | { | ||
203 | u32 descriptor_length; | ||
204 | |||
205 | ACPI_FUNCTION_ENTRY(); | ||
206 | |||
207 | /* Determine if this is a small or large resource */ | ||
208 | |||
209 | if (aml->large_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { | ||
210 | /* Large Resource type -- bytes 1-2 contain the 16-bit length */ | ||
211 | |||
212 | ACPI_MOVE_16_TO_32(&descriptor_length, | ||
213 | &aml->large_header.resource_length); | ||
214 | descriptor_length += sizeof(struct aml_resource_large_header); | ||
215 | |||
216 | } else { | ||
217 | /* Small Resource type -- bits 2:0 of byte 0 contain the length */ | ||
218 | |||
219 | descriptor_length = (u32) (aml->small_header.descriptor_type & | ||
220 | ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); | ||
221 | descriptor_length += sizeof(struct aml_resource_small_header); | ||
222 | } | ||
223 | |||
224 | return (descriptor_length); | ||
225 | } | ||
226 | |||
227 | /******************************************************************************* | ||
228 | * | ||
229 | * FUNCTION: acpi_rs_set_resource_header | ||
230 | * | ||
231 | * PARAMETERS: descriptor_type - Byte to be inserted as the type | ||
232 | * total_length - Length of the AML descriptor, including | ||
233 | * the header and length fields. | ||
234 | * Aml - Pointer to the raw AML descriptor | ||
235 | * | ||
236 | * RETURN: None | ||
237 | * | ||
238 | * DESCRIPTION: Set the descriptor_type and resource_length fields of an AML | ||
239 | * resource descriptor, both Large and Small descriptors are | ||
240 | * supported automatically | ||
241 | * | ||
242 | ******************************************************************************/ | ||
243 | |||
244 | void | ||
245 | acpi_rs_set_resource_header(u8 descriptor_type, | ||
246 | acpi_size total_length, union aml_resource *aml) | ||
247 | { | ||
248 | u16 resource_length; | ||
249 | |||
250 | ACPI_FUNCTION_ENTRY(); | ||
251 | |||
252 | /* Set the descriptor type */ | ||
253 | |||
254 | aml->small_header.descriptor_type = descriptor_type; | ||
255 | |||
256 | /* Determine if this is a small or large resource */ | ||
257 | |||
258 | if (aml->small_header.descriptor_type & ACPI_RESOURCE_NAME_LARGE) { | ||
259 | /* Large Resource type -- bytes 1-2 contain the 16-bit length */ | ||
260 | |||
261 | resource_length = | ||
262 | (u16) (total_length - | ||
263 | sizeof(struct aml_resource_large_header)); | ||
264 | |||
265 | /* Insert length into the Large descriptor length field */ | ||
266 | |||
267 | ACPI_MOVE_16_TO_16(&aml->large_header.resource_length, | ||
268 | &resource_length); | ||
269 | } else { | ||
270 | /* Small Resource type -- bits 2:0 of byte 0 contain the length */ | ||
271 | |||
272 | resource_length = | ||
273 | (u16) (total_length - | ||
274 | sizeof(struct aml_resource_small_header)); | ||
275 | |||
276 | /* Insert length into the descriptor type byte */ | ||
277 | |||
278 | aml->small_header.descriptor_type |= (u8) resource_length; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | /******************************************************************************* | ||
283 | * | ||
284 | * FUNCTION: acpi_rs_get_resource_type | ||
285 | * | ||
286 | * PARAMETERS: resource_type - Byte 0 of a resource descriptor | ||
287 | * | ||
288 | * RETURN: The Resource Type with no extraneous bits (except the | ||
289 | * Large/Small descriptor bit -- this is left alone) | ||
290 | * | ||
291 | * DESCRIPTION: Extract the Resource Type/Name from the first byte of | ||
292 | * a resource descriptor. | ||
293 | * | ||
294 | ******************************************************************************/ | ||
295 | |||
296 | u8 acpi_rs_get_resource_type(u8 resource_type) | ||
297 | { | ||
298 | ACPI_FUNCTION_ENTRY(); | ||
299 | |||
300 | /* Determine if this is a small or large resource */ | ||
301 | |||
302 | if (resource_type & ACPI_RESOURCE_NAME_LARGE) { | ||
303 | /* Large Resource Type -- bits 6:0 contain the name */ | ||
304 | |||
305 | return (resource_type); | ||
306 | } else { | ||
307 | /* Small Resource Type -- bits 6:3 contain the name */ | ||
308 | |||
309 | return ((u8) (resource_type & ACPI_RESOURCE_NAME_SMALL_MASK)); | ||
310 | } | ||
311 | } | ||
312 | |||
313 | /******************************************************************************* | ||
314 | * | ||
315 | * FUNCTION: acpi_rs_strcpy | ||
316 | * | ||
317 | * PARAMETERS: Destination - Pointer to the destination string | ||
318 | * Source - Pointer to the source string | ||
319 | * | ||
320 | * RETURN: String length, including NULL terminator | ||
321 | * | ||
322 | * DESCRIPTION: Local string copy that returns the string length, saving a | ||
323 | * strcpy followed by a strlen. | ||
324 | * | ||
325 | ******************************************************************************/ | ||
326 | |||
327 | static u16 acpi_rs_strcpy(char *destination, char *source) | ||
328 | { | ||
329 | u16 i; | ||
330 | |||
331 | ACPI_FUNCTION_ENTRY(); | ||
332 | |||
333 | for (i = 0; source[i]; i++) { | ||
334 | destination[i] = source[i]; | ||
335 | } | ||
336 | |||
337 | destination[i] = 0; | ||
338 | |||
339 | /* Return string length including the NULL terminator */ | ||
340 | |||
341 | return ((u16) (i + 1)); | ||
342 | } | ||
343 | |||
344 | /******************************************************************************* | ||
345 | * | ||
346 | * FUNCTION: acpi_rs_get_resource_source | ||
347 | * | ||
348 | * PARAMETERS: resource_length - Length field of the descriptor | ||
349 | * minimum_length - Minimum length of the descriptor (minus | ||
350 | * any optional fields) | ||
351 | * resource_source - Where the resource_source is returned | ||
352 | * Aml - Pointer to the raw AML descriptor | ||
353 | * string_ptr - (optional) where to store the actual | ||
354 | * resource_source string | ||
355 | * | ||
356 | * RETURN: Length of the string plus NULL terminator, rounded up to 32 bit | ||
357 | * | ||
358 | * DESCRIPTION: Copy the optional resource_source data from a raw AML descriptor | ||
359 | * to an internal resource descriptor | ||
360 | * | ||
361 | ******************************************************************************/ | ||
362 | |||
363 | u16 | ||
364 | acpi_rs_get_resource_source(u16 resource_length, | ||
365 | acpi_size minimum_length, | ||
366 | struct acpi_resource_source * resource_source, | ||
367 | union aml_resource * aml, char *string_ptr) | ||
368 | { | ||
369 | acpi_size total_length; | ||
370 | u8 *aml_resource_source; | ||
371 | |||
372 | ACPI_FUNCTION_ENTRY(); | ||
373 | |||
374 | total_length = | ||
375 | resource_length + sizeof(struct aml_resource_large_header); | ||
376 | aml_resource_source = ((u8 *) aml) + minimum_length; | ||
377 | |||
378 | /* | ||
379 | * resource_source is present if the length of the descriptor is longer than | ||
380 | * the minimum length. | ||
381 | * | ||
382 | * Note: Some resource descriptors will have an additional null, so | ||
383 | * we add 1 to the minimum length. | ||
384 | */ | ||
385 | if (total_length > (minimum_length + 1)) { | ||
386 | /* Get the resource_source_index */ | ||
387 | |||
388 | resource_source->index = aml_resource_source[0]; | ||
389 | |||
390 | resource_source->string_ptr = string_ptr; | ||
391 | if (!string_ptr) { | ||
392 | /* | ||
393 | * String destination pointer is not specified; Set the String | ||
394 | * pointer to the end of the current resource_source structure. | ||
395 | */ | ||
396 | resource_source->string_ptr = (char *) | ||
397 | ((u8 *) resource_source) + | ||
398 | sizeof(struct acpi_resource_source); | ||
399 | } | ||
400 | |||
401 | /* Copy the resource_source string to the destination */ | ||
402 | |||
403 | resource_source->string_length = | ||
404 | acpi_rs_strcpy(resource_source->string_ptr, | ||
405 | (char *)&aml_resource_source[1]); | ||
406 | |||
407 | /* | ||
408 | * In order for the struct_size to fall on a 32-bit boundary, | ||
409 | * calculate the length of the string and expand the | ||
410 | * struct_size to the next 32-bit boundary. | ||
411 | */ | ||
412 | return ((u16) | ||
413 | ACPI_ROUND_UP_to_32_bITS(resource_source-> | ||
414 | string_length)); | ||
415 | } else { | ||
416 | /* resource_source is not present */ | ||
417 | |||
418 | resource_source->index = 0; | ||
419 | resource_source->string_length = 0; | ||
420 | resource_source->string_ptr = NULL; | ||
421 | return (0); | ||
422 | } | ||
423 | } | ||
424 | |||
425 | /******************************************************************************* | ||
426 | * | ||
427 | * FUNCTION: acpi_rs_set_resource_source | ||
428 | * | ||
429 | * PARAMETERS: Aml - Pointer to the raw AML descriptor | ||
430 | * minimum_length - Minimum length of the descriptor (minus | ||
431 | * any optional fields) | ||
432 | * resource_source - Internal resource_source | ||
433 | |||
434 | * | ||
435 | * RETURN: Total length of the AML descriptor | ||
436 | * | ||
437 | * DESCRIPTION: Convert an optoinal resource_source from internal format to a | ||
438 | * raw AML resource descriptor | ||
439 | * | ||
440 | ******************************************************************************/ | ||
441 | |||
442 | acpi_size | ||
443 | acpi_rs_set_resource_source(union aml_resource * aml, | ||
444 | acpi_size minimum_length, | ||
445 | struct acpi_resource_source * resource_source) | ||
446 | { | ||
447 | u8 *aml_resource_source; | ||
448 | acpi_size descriptor_length; | ||
449 | |||
450 | ACPI_FUNCTION_ENTRY(); | ||
451 | |||
452 | descriptor_length = minimum_length; | ||
453 | |||
454 | /* Non-zero string length indicates presence of a resource_source */ | ||
455 | |||
456 | if (resource_source->string_length) { | ||
457 | /* Point to the end of the AML descriptor */ | ||
458 | |||
459 | aml_resource_source = ((u8 *) aml) + minimum_length; | ||
460 | |||
461 | /* Copy the resource_source_index */ | ||
462 | |||
463 | aml_resource_source[0] = (u8) resource_source->index; | ||
464 | |||
465 | /* Copy the resource_source string */ | ||
466 | |||
467 | ACPI_STRCPY((char *)&aml_resource_source[1], | ||
468 | resource_source->string_ptr); | ||
469 | |||
470 | /* | ||
471 | * Add the length of the string (+ 1 for null terminator) to the | ||
472 | * final descriptor length | ||
473 | */ | ||
474 | descriptor_length += | ||
475 | ((acpi_size) resource_source->string_length + 1); | ||
476 | } | ||
477 | |||
478 | /* Return the new total length of the AML descriptor */ | ||
479 | |||
480 | return (descriptor_length); | ||
481 | } | ||
482 | |||
483 | /******************************************************************************* | ||
484 | * | ||
53 | * FUNCTION: acpi_rs_get_prt_method_data | 485 | * FUNCTION: acpi_rs_get_prt_method_data |
54 | * | 486 | * |
55 | * PARAMETERS: Handle - a handle to the containing object | 487 | * PARAMETERS: Handle - a handle to the containing object |
@@ -65,8 +497,9 @@ ACPI_MODULE_NAME("rsutils") | |||
65 | * and the contents of the callers buffer is undefined. | 497 | * and the contents of the callers buffer is undefined. |
66 | * | 498 | * |
67 | ******************************************************************************/ | 499 | ******************************************************************************/ |
500 | |||
68 | acpi_status | 501 | acpi_status |
69 | acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) | 502 | acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer) |
70 | { | 503 | { |
71 | union acpi_operand_object *obj_desc; | 504 | union acpi_operand_object *obj_desc; |
72 | acpi_status status; | 505 | acpi_status status; |
@@ -284,7 +717,7 @@ acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer) | |||
284 | * Convert the linked list into a byte stream | 717 | * Convert the linked list into a byte stream |
285 | */ | 718 | */ |
286 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | 719 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; |
287 | status = acpi_rs_create_byte_stream(in_buffer->pointer, &buffer); | 720 | status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer); |
288 | if (ACPI_FAILURE(status)) { | 721 | if (ACPI_FAILURE(status)) { |
289 | return_ACPI_STATUS(status); | 722 | return_ACPI_STATUS(status); |
290 | } | 723 | } |
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c index 1a87c4c7bd97..9d179beb17ae 100644 --- a/drivers/acpi/resources/rsxface.c +++ b/drivers/acpi/resources/rsxface.c | |||
@@ -59,9 +59,9 @@ ACPI_MODULE_NAME("rsxface") | |||
59 | ACPI_COPY_FIELD(out, in, max_address_fixed); \ | 59 | ACPI_COPY_FIELD(out, in, max_address_fixed); \ |
60 | ACPI_COPY_FIELD(out, in, attribute); \ | 60 | ACPI_COPY_FIELD(out, in, attribute); \ |
61 | ACPI_COPY_FIELD(out, in, granularity); \ | 61 | ACPI_COPY_FIELD(out, in, granularity); \ |
62 | ACPI_COPY_FIELD(out, in, min_address_range); \ | 62 | ACPI_COPY_FIELD(out, in, minimum); \ |
63 | ACPI_COPY_FIELD(out, in, max_address_range); \ | 63 | ACPI_COPY_FIELD(out, in, maximum); \ |
64 | ACPI_COPY_FIELD(out, in, address_translation_offset); \ | 64 | ACPI_COPY_FIELD(out, in, translation_offset); \ |
65 | ACPI_COPY_FIELD(out, in, address_length); \ | 65 | ACPI_COPY_FIELD(out, in, address_length); \ |
66 | ACPI_COPY_FIELD(out, in, resource_source); | 66 | ACPI_COPY_FIELD(out, in, resource_source); |
67 | /******************************************************************************* | 67 | /******************************************************************************* |
@@ -269,7 +269,7 @@ acpi_walk_resources(acpi_handle device_handle, | |||
269 | /* Walk the resource list */ | 269 | /* Walk the resource list */ |
270 | 270 | ||
271 | for (;;) { | 271 | for (;;) { |
272 | if (!resource || resource->type == ACPI_RSTYPE_END_TAG) { | 272 | if (!resource || resource->type == ACPI_RESOURCE_TYPE_END_TAG) { |
273 | break; | 273 | break; |
274 | } | 274 | } |
275 | 275 | ||
@@ -382,19 +382,19 @@ acpi_resource_to_address64(struct acpi_resource *resource, | |||
382 | struct acpi_resource_address32 *address32; | 382 | struct acpi_resource_address32 *address32; |
383 | 383 | ||
384 | switch (resource->type) { | 384 | switch (resource->type) { |
385 | case ACPI_RSTYPE_ADDRESS16: | 385 | case ACPI_RESOURCE_TYPE_ADDRESS16: |
386 | 386 | ||
387 | address16 = (struct acpi_resource_address16 *)&resource->data; | 387 | address16 = (struct acpi_resource_address16 *)&resource->data; |
388 | ACPI_COPY_ADDRESS(out, address16); | 388 | ACPI_COPY_ADDRESS(out, address16); |
389 | break; | 389 | break; |
390 | 390 | ||
391 | case ACPI_RSTYPE_ADDRESS32: | 391 | case ACPI_RESOURCE_TYPE_ADDRESS32: |
392 | 392 | ||
393 | address32 = (struct acpi_resource_address32 *)&resource->data; | 393 | address32 = (struct acpi_resource_address32 *)&resource->data; |
394 | ACPI_COPY_ADDRESS(out, address32); | 394 | ACPI_COPY_ADDRESS(out, address32); |
395 | break; | 395 | break; |
396 | 396 | ||
397 | case ACPI_RSTYPE_ADDRESS64: | 397 | case ACPI_RESOURCE_TYPE_ADDRESS64: |
398 | 398 | ||
399 | /* Simple copy for 64 bit source */ | 399 | /* Simple copy for 64 bit source */ |
400 | 400 | ||