diff options
author | Lv Zheng <lv.zheng@intel.com> | 2013-03-08 04:23:32 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-11 19:45:05 -0400 |
commit | 88fd0ac831095f52691810a3b832e884766c657e (patch) | |
tree | 4fb3b79e8773ecc4f4c012dc09119c9cab92ced4 | |
parent | 96b44cc684b315dbcf77191809df011067f2e206 (diff) |
ACPICA: Return object repair: Add resource template repairs
Fixes several possible problems with resource templates returned
by _CRS/_PRS/_DMA predefined names. Lv Zheng.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/acpica/acnamesp.h | 4 | ||||
-rw-r--r-- | drivers/acpi/acpica/nsconvert.c | 77 | ||||
-rw-r--r-- | drivers/acpi/acpica/nsrepair.c | 18 |
3 files changed, 99 insertions, 0 deletions
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h index b6ee5192f2ae..6475962a7f2d 100644 --- a/drivers/acpi/acpica/acnamesp.h +++ b/drivers/acpi/acpica/acnamesp.h | |||
@@ -185,6 +185,10 @@ acpi_status | |||
185 | acpi_ns_convert_to_unicode(union acpi_operand_object *original_object, | 185 | acpi_ns_convert_to_unicode(union acpi_operand_object *original_object, |
186 | union acpi_operand_object **return_object); | 186 | union acpi_operand_object **return_object); |
187 | 187 | ||
188 | acpi_status | ||
189 | acpi_ns_convert_to_resource(union acpi_operand_object *original_object, | ||
190 | union acpi_operand_object **return_object); | ||
191 | |||
188 | /* | 192 | /* |
189 | * nsdump - Namespace dump/print utilities | 193 | * nsdump - Namespace dump/print utilities |
190 | */ | 194 | */ |
diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c index 84f66994256f..8f79a9d2d50e 100644 --- a/drivers/acpi/acpica/nsconvert.c +++ b/drivers/acpi/acpica/nsconvert.c | |||
@@ -364,3 +364,80 @@ acpi_ns_convert_to_unicode(union acpi_operand_object *original_object, | |||
364 | *return_object = new_object; | 364 | *return_object = new_object; |
365 | return (AE_OK); | 365 | return (AE_OK); |
366 | } | 366 | } |
367 | |||
368 | /******************************************************************************* | ||
369 | * | ||
370 | * FUNCTION: acpi_ns_convert_to_resource | ||
371 | * | ||
372 | * PARAMETERS: original_object - Object to be converted | ||
373 | * return_object - Where the new converted object is returned | ||
374 | * | ||
375 | * RETURN: Status. AE_OK if conversion was successful | ||
376 | * | ||
377 | * DESCRIPTION: Attempt to convert a Integer object to a resource_template | ||
378 | * Buffer. | ||
379 | * | ||
380 | ******************************************************************************/ | ||
381 | |||
382 | acpi_status | ||
383 | acpi_ns_convert_to_resource(union acpi_operand_object *original_object, | ||
384 | union acpi_operand_object **return_object) | ||
385 | { | ||
386 | union acpi_operand_object *new_object; | ||
387 | u8 *buffer; | ||
388 | |||
389 | /* | ||
390 | * We can fix the following cases for an expected resource template: | ||
391 | * 1. No return value (interpreter slack mode is disabled) | ||
392 | * 2. A "Return (Zero)" statement | ||
393 | * 3. A "Return empty buffer" statement | ||
394 | * | ||
395 | * We will return a buffer containing a single end_tag | ||
396 | * resource descriptor. | ||
397 | */ | ||
398 | if (original_object) { | ||
399 | switch (original_object->common.type) { | ||
400 | case ACPI_TYPE_INTEGER: | ||
401 | |||
402 | /* We can only repair an Integer==0 */ | ||
403 | |||
404 | if (original_object->integer.value) { | ||
405 | return (AE_AML_OPERAND_TYPE); | ||
406 | } | ||
407 | break; | ||
408 | |||
409 | case ACPI_TYPE_BUFFER: | ||
410 | |||
411 | if (original_object->buffer.length) { | ||
412 | |||
413 | /* Additional checks can be added in the future */ | ||
414 | |||
415 | *return_object = NULL; | ||
416 | return (AE_OK); | ||
417 | } | ||
418 | break; | ||
419 | |||
420 | case ACPI_TYPE_STRING: | ||
421 | default: | ||
422 | |||
423 | return (AE_AML_OPERAND_TYPE); | ||
424 | } | ||
425 | } | ||
426 | |||
427 | /* Create the new buffer object for the resource descriptor */ | ||
428 | |||
429 | new_object = acpi_ut_create_buffer_object(2); | ||
430 | if (!new_object) { | ||
431 | return (AE_NO_MEMORY); | ||
432 | } | ||
433 | |||
434 | buffer = ACPI_CAST_PTR(u8, new_object->buffer.pointer); | ||
435 | |||
436 | /* Initialize the Buffer with a single end_tag descriptor */ | ||
437 | |||
438 | buffer[0] = (ACPI_RESOURCE_NAME_END_TAG | ASL_RDESC_END_TAG_SIZE); | ||
439 | buffer[1] = 0x00; | ||
440 | |||
441 | *return_object = new_object; | ||
442 | return (AE_OK); | ||
443 | } | ||
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c index a1918fdf92f2..18f02e4ece01 100644 --- a/drivers/acpi/acpica/nsrepair.c +++ b/drivers/acpi/acpica/nsrepair.c | |||
@@ -98,6 +98,24 @@ static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct | |||
98 | * 2nd argument: Unexpected types that can be repaired | 98 | * 2nd argument: Unexpected types that can be repaired |
99 | */ | 99 | */ |
100 | static const struct acpi_simple_repair_info acpi_object_repair_info[] = { | 100 | static const struct acpi_simple_repair_info acpi_object_repair_info[] = { |
101 | /* Resource descriptor conversions */ | ||
102 | |||
103 | {"_CRS", | ||
104 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | | ||
105 | ACPI_RTYPE_NONE, | ||
106 | ACPI_NOT_PACKAGE_ELEMENT, | ||
107 | acpi_ns_convert_to_resource}, | ||
108 | {"_DMA", | ||
109 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | | ||
110 | ACPI_RTYPE_NONE, | ||
111 | ACPI_NOT_PACKAGE_ELEMENT, | ||
112 | acpi_ns_convert_to_resource}, | ||
113 | {"_PRS", | ||
114 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | | ||
115 | ACPI_RTYPE_NONE, | ||
116 | ACPI_NOT_PACKAGE_ELEMENT, | ||
117 | acpi_ns_convert_to_resource}, | ||
118 | |||
101 | /* Unicode conversions */ | 119 | /* Unicode conversions */ |
102 | 120 | ||
103 | {"_MLS", ACPI_RTYPE_STRING, 1, | 121 | {"_MLS", ACPI_RTYPE_STRING, 1, |