From bdda87613640741b9badcafa99a8c87377de8596 Mon Sep 17 00:00:00 2001 From: Lv Zheng Date: Fri, 8 Mar 2013 09:23:24 +0000 Subject: [PATCH] --- yaml --- r: 367575 b: refs/heads/master c: 96b44cc684b315dbcf77191809df011067f2e206 h: refs/heads/master i: 367573: 2c7f50e727346e1768058048dced6d9e09931f43 367571: 80e6a91b250946f2e25ed1cf625bae6ecf9091f3 367567: 1357176b9022dbad9879cf150d5048551ca2c980 v: v3 --- [refs] | 2 +- trunk/drivers/acpi/acpica/acnamesp.h | 4 ++ trunk/drivers/acpi/acpica/nsconvert.c | 64 +++++++++++++++++++++++++++ trunk/drivers/acpi/acpica/nsrepair.c | 7 +++ 4 files changed, 76 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 78e91335636d..a9de945dbb0e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 76a6225bf0b64572251a8c27d33e84afac6af713 +refs/heads/master: 96b44cc684b315dbcf77191809df011067f2e206 diff --git a/trunk/drivers/acpi/acpica/acnamesp.h b/trunk/drivers/acpi/acpica/acnamesp.h index 7156bc75ebe0..b6ee5192f2ae 100644 --- a/trunk/drivers/acpi/acpica/acnamesp.h +++ b/trunk/drivers/acpi/acpica/acnamesp.h @@ -181,6 +181,10 @@ acpi_status acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, union acpi_operand_object **return_object); +acpi_status +acpi_ns_convert_to_unicode(union acpi_operand_object *original_object, + union acpi_operand_object **return_object); + /* * nsdump - Namespace dump/print utilities */ diff --git a/trunk/drivers/acpi/acpica/nsconvert.c b/trunk/drivers/acpi/acpica/nsconvert.c index fcb7dfb494cd..84f66994256f 100644 --- a/trunk/drivers/acpi/acpica/nsconvert.c +++ b/trunk/drivers/acpi/acpica/nsconvert.c @@ -300,3 +300,67 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, *return_object = new_object; return (AE_OK); } + +/******************************************************************************* + * + * FUNCTION: acpi_ns_convert_to_unicode + * + * PARAMETERS: original_object - ASCII String Object to be converted + * return_object - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful. + * + * DESCRIPTION: Attempt to convert a String object to a Unicode string Buffer. + * + ******************************************************************************/ + +acpi_status +acpi_ns_convert_to_unicode(union acpi_operand_object *original_object, + union acpi_operand_object **return_object) +{ + union acpi_operand_object *new_object; + char *ascii_string; + u16 *unicode_buffer; + u32 unicode_length; + u32 i; + + if (!original_object) { + return (AE_OK); + } + + /* If a Buffer was returned, it must be at least two bytes long */ + + if (original_object->common.type == ACPI_TYPE_BUFFER) { + if (original_object->buffer.length < 2) { + return (AE_AML_OPERAND_VALUE); + } + + *return_object = NULL; + return (AE_OK); + } + + /* + * The original object is an ASCII string. Convert this string to + * a unicode buffer. + */ + ascii_string = original_object->string.pointer; + unicode_length = (original_object->string.length * 2) + 2; + + /* Create a new buffer object for the Unicode data */ + + new_object = acpi_ut_create_buffer_object(unicode_length); + if (!new_object) { + return (AE_NO_MEMORY); + } + + unicode_buffer = ACPI_CAST_PTR(u16, new_object->buffer.pointer); + + /* Convert ASCII to Unicode */ + + for (i = 0; i < original_object->string.length; i++) { + unicode_buffer[i] = (u16)ascii_string[i]; + } + + *return_object = new_object; + return (AE_OK); +} diff --git a/trunk/drivers/acpi/acpica/nsrepair.c b/trunk/drivers/acpi/acpica/nsrepair.c index c5e828f4ed0b..a1918fdf92f2 100644 --- a/trunk/drivers/acpi/acpica/nsrepair.c +++ b/trunk/drivers/acpi/acpica/nsrepair.c @@ -98,6 +98,13 @@ static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct * 2nd argument: Unexpected types that can be repaired */ static const struct acpi_simple_repair_info acpi_object_repair_info[] = { + /* Unicode conversions */ + + {"_MLS", ACPI_RTYPE_STRING, 1, + acpi_ns_convert_to_unicode}, + {"_STR", ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER, + ACPI_NOT_PACKAGE_ELEMENT, + acpi_ns_convert_to_unicode}, {{0, 0, 0, 0}, 0, 0, NULL} /* Table terminator */ };