diff mbox

[v6,20/22] hw/acpi/aml-build: Add Unicode macro

Message ID 1430990964-10528-21-git-send-email-zhaoshenglong@huawei.com
State New
Headers show

Commit Message

Shannon Zhao May 7, 2015, 9:29 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 hw/acpi/aml-build.c         | 18 ++++++++++++++++++
 include/hw/acpi/aml-build.h |  1 +
 2 files changed, 19 insertions(+)

Comments

Igor Mammedov May 15, 2015, 2:13 p.m. UTC | #1
On Thu, 7 May 2015 17:29:22 +0800
Shannon Zhao <zhaoshenglong@huawei.com> wrote:

> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  hw/acpi/aml-build.c         | 18 ++++++++++++++++++
>  include/hw/acpi/aml-build.h |  1 +
>  2 files changed, 19 insertions(+)
> 
> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> index 67b7719..06f9d37 100644
> --- a/hw/acpi/aml-build.c
> +++ b/hw/acpi/aml-build.c
> @@ -1061,6 +1061,24 @@ Aml *aml_touuid(const char *uuid)
>      return var;
>  }
>  
> +/*
> + * ACPI 2.0b: 16.2.3.6.4.3  Unicode Macro (Convert Ascii String To Unicode)
> + */
> +Aml *aml_unicode(const char *str)
> +{
> +    Aml *var = aml_bundle(0x11 /* BufferOp */, AML_BUFFER);
> +
> +    while (*str != '\0') {
{
> +        build_append_byte(var->buf, 0);
> +        build_append_byte(var->buf, *str);
order seems to be wrong, shouldn't you swap bytes?

> +        str++;
> +    }
} while(*str != '\0');

and drop vvv
> +    build_append_byte(var->buf, 0);
> +    build_append_byte(var->buf, *str);
> +
> +    return var;
> +}
> +
>  void
>  build_header(GArray *linker, GArray *table_data,
>               AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
> diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
> index 5ff9c14..39b44e4 100644
> --- a/include/hw/acpi/aml-build.h
> +++ b/include/hw/acpi/aml-build.h
> @@ -269,6 +269,7 @@ Aml *aml_field(const char *name, AmlFieldFlags flags);
>  Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name);
>  Aml *aml_varpackage(uint32_t num_elements);
>  Aml *aml_touuid(const char *uuid);
> +Aml *aml_unicode(const char *str);
>  
>  void
>  build_header(GArray *linker, GArray *table_data,
Shannon Zhao May 18, 2015, 6:05 a.m. UTC | #2
On 2015/5/15 22:13, Igor Mammedov wrote:
> On Thu, 7 May 2015 17:29:22 +0800
> Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> 
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  hw/acpi/aml-build.c         | 18 ++++++++++++++++++
>>  include/hw/acpi/aml-build.h |  1 +
>>  2 files changed, 19 insertions(+)
>>
>> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
>> index 67b7719..06f9d37 100644
>> --- a/hw/acpi/aml-build.c
>> +++ b/hw/acpi/aml-build.c
>> @@ -1061,6 +1061,24 @@ Aml *aml_touuid(const char *uuid)
>>      return var;
>>  }
>>  
>> +/*
>> + * ACPI 2.0b: 16.2.3.6.4.3  Unicode Macro (Convert Ascii String To Unicode)
>> + */
>> +Aml *aml_unicode(const char *str)
>> +{
>> +    Aml *var = aml_bundle(0x11 /* BufferOp */, AML_BUFFER);
>> +
>> +    while (*str != '\0') {
> {
>> +        build_append_byte(var->buf, 0);
>> +        build_append_byte(var->buf, *str);
> order seems to be wrong, shouldn't you swap bytes?
> 
oops, thanks.

>> +        str++;
>> +    }
> } while(*str != '\0');
> 
> and drop vvv

sorry, you mean drop what here?

>> +    build_append_byte(var->buf, 0);
>> +    build_append_byte(var->buf, *str);
>> +
>> +    return var;
>> +}
>> +
>>  void
>>  build_header(GArray *linker, GArray *table_data,
>>               AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
>> diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
>> index 5ff9c14..39b44e4 100644
>> --- a/include/hw/acpi/aml-build.h
>> +++ b/include/hw/acpi/aml-build.h
>> @@ -269,6 +269,7 @@ Aml *aml_field(const char *name, AmlFieldFlags flags);
>>  Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name);
>>  Aml *aml_varpackage(uint32_t num_elements);
>>  Aml *aml_touuid(const char *uuid);
>> +Aml *aml_unicode(const char *str);
>>  
>>  void
>>  build_header(GArray *linker, GArray *table_data,
> 
> 
> .
>
Igor Mammedov May 19, 2015, 12:19 p.m. UTC | #3
On Mon, 18 May 2015 14:05:01 +0800
Shannon Zhao <zhaoshenglong@huawei.com> wrote:

> On 2015/5/15 22:13, Igor Mammedov wrote:
> > On Thu, 7 May 2015 17:29:22 +0800
> > Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> > 
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> ---
> >>  hw/acpi/aml-build.c         | 18 ++++++++++++++++++
> >>  include/hw/acpi/aml-build.h |  1 +
> >>  2 files changed, 19 insertions(+)
> >>
> >> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> >> index 67b7719..06f9d37 100644
> >> --- a/hw/acpi/aml-build.c
> >> +++ b/hw/acpi/aml-build.c
> >> @@ -1061,6 +1061,24 @@ Aml *aml_touuid(const char *uuid)
> >>      return var;
> >>  }
> >>  
> >> +/*
> >> + * ACPI 2.0b: 16.2.3.6.4.3  Unicode Macro (Convert Ascii String To Unicode)
> >> + */
> >> +Aml *aml_unicode(const char *str)
> >> +{
> >> +    Aml *var = aml_bundle(0x11 /* BufferOp */, AML_BUFFER);
> >> +
> >> +    while (*str != '\0') {
> > {
> >> +        build_append_byte(var->buf, 0);
> >> +        build_append_byte(var->buf, *str);
> > order seems to be wrong, shouldn't you swap bytes?
> > 
> oops, thanks.
> 
> >> +        str++;
> >> +    }
> > } while(*str != '\0');
> > 
> > and drop vvv
> 
> sorry, you mean drop what here?
if you write like:
do {
...
} while (...)

you won't need  this (vvv) 2 lines below
> >> +    build_append_byte(var->buf, 0);
> >> +    build_append_byte(var->buf, *str);
> >> +
> >> +    return var;
> >> +}
> >> +
> >>  void
> >>  build_header(GArray *linker, GArray *table_data,
> >>               AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
> >> diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
> >> index 5ff9c14..39b44e4 100644
> >> --- a/include/hw/acpi/aml-build.h
> >> +++ b/include/hw/acpi/aml-build.h
> >> @@ -269,6 +269,7 @@ Aml *aml_field(const char *name, AmlFieldFlags flags);
> >>  Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name);
> >>  Aml *aml_varpackage(uint32_t num_elements);
> >>  Aml *aml_touuid(const char *uuid);
> >> +Aml *aml_unicode(const char *str);
> >>  
> >>  void
> >>  build_header(GArray *linker, GArray *table_data,
> > 
> > 
> > .
> > 
>
diff mbox

Patch

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 67b7719..06f9d37 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1061,6 +1061,24 @@  Aml *aml_touuid(const char *uuid)
     return var;
 }
 
+/*
+ * ACPI 2.0b: 16.2.3.6.4.3  Unicode Macro (Convert Ascii String To Unicode)
+ */
+Aml *aml_unicode(const char *str)
+{
+    Aml *var = aml_bundle(0x11 /* BufferOp */, AML_BUFFER);
+
+    while (*str != '\0') {
+        build_append_byte(var->buf, 0);
+        build_append_byte(var->buf, *str);
+        str++;
+    }
+    build_append_byte(var->buf, 0);
+    build_append_byte(var->buf, *str);
+
+    return var;
+}
+
 void
 build_header(GArray *linker, GArray *table_data,
              AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 5ff9c14..39b44e4 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -269,6 +269,7 @@  Aml *aml_field(const char *name, AmlFieldFlags flags);
 Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name);
 Aml *aml_varpackage(uint32_t num_elements);
 Aml *aml_touuid(const char *uuid);
+Aml *aml_unicode(const char *str);
 
 void
 build_header(GArray *linker, GArray *table_data,