diff options
author | Lv Zheng <lv.zheng@intel.com> | 2013-03-08 04:23:24 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-11 19:45:05 -0400 |
commit | 96b44cc684b315dbcf77191809df011067f2e206 (patch) | |
tree | 1d0059c72652cf50408d2baa04281ef8e38b20d3 /drivers/acpi/acpica | |
parent | 76a6225bf0b64572251a8c27d33e84afac6af713 (diff) |
ACPICA: Return object repair: Add string-to-unicode conversion
Used for the _STR and _MLS 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>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r-- | drivers/acpi/acpica/acnamesp.h | 4 | ||||
-rw-r--r-- | drivers/acpi/acpica/nsconvert.c | 64 | ||||
-rw-r--r-- | drivers/acpi/acpica/nsrepair.c | 7 |
3 files changed, 75 insertions, 0 deletions
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h index 7156bc75ebe0..b6ee5192f2ae 100644 --- a/drivers/acpi/acpica/acnamesp.h +++ b/drivers/acpi/acpica/acnamesp.h | |||
@@ -181,6 +181,10 @@ acpi_status | |||
181 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | 181 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, |
182 | union acpi_operand_object **return_object); | 182 | union acpi_operand_object **return_object); |
183 | 183 | ||
184 | acpi_status | ||
185 | acpi_ns_convert_to_unicode(union acpi_operand_object *original_object, | ||
186 | union acpi_operand_object **return_object); | ||
187 | |||
184 | /* | 188 | /* |
185 | * nsdump - Namespace dump/print utilities | 189 | * nsdump - Namespace dump/print utilities |
186 | */ | 190 | */ |
diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c index fcb7dfb494cd..84f66994256f 100644 --- a/drivers/acpi/acpica/nsconvert.c +++ b/drivers/acpi/acpica/nsconvert.c | |||
@@ -300,3 +300,67 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | |||
300 | *return_object = new_object; | 300 | *return_object = new_object; |
301 | return (AE_OK); | 301 | return (AE_OK); |
302 | } | 302 | } |
303 | |||
304 | /******************************************************************************* | ||
305 | * | ||
306 | * FUNCTION: acpi_ns_convert_to_unicode | ||
307 | * | ||
308 | * PARAMETERS: original_object - ASCII String Object to be converted | ||
309 | * return_object - Where the new converted object is returned | ||
310 | * | ||
311 | * RETURN: Status. AE_OK if conversion was successful. | ||
312 | * | ||
313 | * DESCRIPTION: Attempt to convert a String object to a Unicode string Buffer. | ||
314 | * | ||
315 | ******************************************************************************/ | ||
316 | |||
317 | acpi_status | ||
318 | acpi_ns_convert_to_unicode(union acpi_operand_object *original_object, | ||
319 | union acpi_operand_object **return_object) | ||
320 | { | ||
321 | union acpi_operand_object *new_object; | ||
322 | char *ascii_string; | ||
323 | u16 *unicode_buffer; | ||
324 | u32 unicode_length; | ||
325 | u32 i; | ||
326 | |||
327 | if (!original_object) { | ||
328 | return (AE_OK); | ||
329 | } | ||
330 | |||
331 | /* If a Buffer was returned, it must be at least two bytes long */ | ||
332 | |||
333 | if (original_object->common.type == ACPI_TYPE_BUFFER) { | ||
334 | if (original_object->buffer.length < 2) { | ||
335 | return (AE_AML_OPERAND_VALUE); | ||
336 | } | ||
337 | |||
338 | *return_object = NULL; | ||
339 | return (AE_OK); | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * The original object is an ASCII string. Convert this string to | ||
344 | * a unicode buffer. | ||
345 | */ | ||
346 | ascii_string = original_object->string.pointer; | ||
347 | unicode_length = (original_object->string.length * 2) + 2; | ||
348 | |||
349 | /* Create a new buffer object for the Unicode data */ | ||
350 | |||
351 | new_object = acpi_ut_create_buffer_object(unicode_length); | ||
352 | if (!new_object) { | ||
353 | return (AE_NO_MEMORY); | ||
354 | } | ||
355 | |||
356 | unicode_buffer = ACPI_CAST_PTR(u16, new_object->buffer.pointer); | ||
357 | |||
358 | /* Convert ASCII to Unicode */ | ||
359 | |||
360 | for (i = 0; i < original_object->string.length; i++) { | ||
361 | unicode_buffer[i] = (u16)ascii_string[i]; | ||
362 | } | ||
363 | |||
364 | *return_object = new_object; | ||
365 | return (AE_OK); | ||
366 | } | ||
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c index c5e828f4ed0b..a1918fdf92f2 100644 --- a/drivers/acpi/acpica/nsrepair.c +++ b/drivers/acpi/acpica/nsrepair.c | |||
@@ -98,6 +98,13 @@ 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 | /* Unicode conversions */ | ||
102 | |||
103 | {"_MLS", ACPI_RTYPE_STRING, 1, | ||
104 | acpi_ns_convert_to_unicode}, | ||
105 | {"_STR", ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER, | ||
106 | ACPI_NOT_PACKAGE_ELEMENT, | ||
107 | acpi_ns_convert_to_unicode}, | ||
101 | {{0, 0, 0, 0}, 0, 0, NULL} /* Table terminator */ | 108 | {{0, 0, 0, 0}, 0, 0, NULL} /* Table terminator */ |
102 | }; | 109 | }; |
103 | 110 | ||