diff mbox

[v2,04/11] acpi: add aml_concatenate()

Message ID 1452624610-46945-5-git-send-email-guangrong.xiao@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiao Guangrong Jan. 12, 2016, 6:50 p.m. UTC
It will be used by nvdimm acpi

Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
---
 hw/acpi/aml-build.c         | 14 ++++++++++++++
 include/hw/acpi/aml-build.h |  1 +
 2 files changed, 15 insertions(+)

Comments

Igor Mammedov Feb. 8, 2016, 10:51 a.m. UTC | #1
On Wed, 13 Jan 2016 02:50:03 +0800
Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:

> It will be used by nvdimm acpi
> 
> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> ---
>  hw/acpi/aml-build.c         | 14 ++++++++++++++
>  include/hw/acpi/aml-build.h |  1 +
>  2 files changed, 15 insertions(+)
> 
> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> index 97c9efb..421dd84 100644
> --- a/hw/acpi/aml-build.c
> +++ b/hw/acpi/aml-build.c
> @@ -1440,6 +1440,20 @@ Aml *aml_alias(const char *source_object, const char *alias_object)
>      return var;
>  }
>  
> +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
> +Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
> +{
> +    Aml *var = aml_opcode(0x73 /* ConcatOp */);
> +    aml_append(var, source1);
> +    aml_append(var, source2);
> +
> +    if (target) {
> +        aml_append(var, target);
> +    }
target is not an optional, pls looks at aml_add and use
helper to make patch correct and smaller

> +
> +    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 e1ba534..4a5168a 100644
> --- a/include/hw/acpi/aml-build.h
> +++ b/include/hw/acpi/aml-build.h
> @@ -354,6 +354,7 @@ Aml *aml_touuid(const char *uuid);
>  Aml *aml_unicode(const char *str);
>  Aml *aml_derefof(Aml *arg);
>  Aml *aml_sizeof(Aml *arg);
> +Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target);
>  
>  void
>  build_header(GArray *linker, GArray *table_data,

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xiao Guangrong Feb. 14, 2016, 5:52 a.m. UTC | #2
On 02/08/2016 06:51 PM, Igor Mammedov wrote:
> On Wed, 13 Jan 2016 02:50:03 +0800
> Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:
>
>> It will be used by nvdimm acpi
>>
>> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>> ---
>>   hw/acpi/aml-build.c         | 14 ++++++++++++++
>>   include/hw/acpi/aml-build.h |  1 +
>>   2 files changed, 15 insertions(+)
>>
>> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
>> index 97c9efb..421dd84 100644
>> --- a/hw/acpi/aml-build.c
>> +++ b/hw/acpi/aml-build.c
>> @@ -1440,6 +1440,20 @@ Aml *aml_alias(const char *source_object, const char *alias_object)
>>       return var;
>>   }
>>
>> +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
>> +Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
>> +{
>> +    Aml *var = aml_opcode(0x73 /* ConcatOp */);
>> +    aml_append(var, source1);
>> +    aml_append(var, source2);
>> +
>> +    if (target) {
>> +        aml_append(var, target);
>> +    }
> target is not an optional, pls looks at aml_add and use
> helper to make patch correct and smaller
>

Indeed, i will change it to:

/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
{
     return  build_opcode_2arg_dst(0x73 /* ConcatOp */, arg1, arg2, dst);
}

Thank you, Igor!
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xiao Guangrong Feb. 14, 2016, 5:55 a.m. UTC | #3
On 02/14/2016 01:52 PM, Xiao Guangrong wrote:
>
>
> On 02/08/2016 06:51 PM, Igor Mammedov wrote:
>> On Wed, 13 Jan 2016 02:50:03 +0800
>> Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:
>>
>>> It will be used by nvdimm acpi
>>>
>>> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>>> ---
>>>   hw/acpi/aml-build.c         | 14 ++++++++++++++
>>>   include/hw/acpi/aml-build.h |  1 +
>>>   2 files changed, 15 insertions(+)
>>>
>>> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
>>> index 97c9efb..421dd84 100644
>>> --- a/hw/acpi/aml-build.c
>>> +++ b/hw/acpi/aml-build.c
>>> @@ -1440,6 +1440,20 @@ Aml *aml_alias(const char *source_object, const char *alias_object)
>>>       return var;
>>>   }
>>>
>>> +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
>>> +Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
>>> +{
>>> +    Aml *var = aml_opcode(0x73 /* ConcatOp */);
>>> +    aml_append(var, source1);
>>> +    aml_append(var, source2);
>>> +
>>> +    if (target) {
>>> +        aml_append(var, target);
>>> +    }
>> target is not an optional, pls looks at aml_add and use
>> helper to make patch correct and smaller
>>
>
> Indeed, i will change it to:
>
> /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
> Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
> {
>      return  build_opcode_2arg_dst(0x73 /* ConcatOp */, arg1, arg2, dst);
> }
>

And make a assert for @target to ensure it can not be NULL.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Igor Mammedov Feb. 15, 2016, 9:02 a.m. UTC | #4
On Sun, 14 Feb 2016 13:55:24 +0800
Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:

> On 02/14/2016 01:52 PM, Xiao Guangrong wrote:
> >
> >
> > On 02/08/2016 06:51 PM, Igor Mammedov wrote:  
> >> On Wed, 13 Jan 2016 02:50:03 +0800
> >> Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:
> >>  
> >>> It will be used by nvdimm acpi
> >>>
> >>> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> >>> ---
> >>>   hw/acpi/aml-build.c         | 14 ++++++++++++++
> >>>   include/hw/acpi/aml-build.h |  1 +
> >>>   2 files changed, 15 insertions(+)
> >>>
> >>> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> >>> index 97c9efb..421dd84 100644
> >>> --- a/hw/acpi/aml-build.c
> >>> +++ b/hw/acpi/aml-build.c
> >>> @@ -1440,6 +1440,20 @@ Aml *aml_alias(const char *source_object, const char *alias_object)
> >>>       return var;
> >>>   }
> >>>
> >>> +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
> >>> +Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
> >>> +{
> >>> +    Aml *var = aml_opcode(0x73 /* ConcatOp */);
> >>> +    aml_append(var, source1);
> >>> +    aml_append(var, source2);
> >>> +
> >>> +    if (target) {
> >>> +        aml_append(var, target);
> >>> +    }  
> >> target is not an optional, pls looks at aml_add and use
> >> helper to make patch correct and smaller
> >>  
> >
> > Indeed, i will change it to:
> >
> > /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
> > Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
> > {
> >      return  build_opcode_2arg_dst(0x73 /* ConcatOp */, arg1, arg2, dst);
> > }
> >  
> 
> And make a assert for @target to ensure it can not be NULL.
Don't do that, see build_opcode_2arg_dst(), target can be NULL
that allows to express implicit target like:

  aml_add(a, aml_add(b, c, NULL), NULL)

where one doesn't need an intermediate variable to store result.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xiao Guangrong Feb. 15, 2016, 10:32 a.m. UTC | #5
On 02/15/2016 05:02 PM, Igor Mammedov wrote:
> On Sun, 14 Feb 2016 13:55:24 +0800
> Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:
>
>> On 02/14/2016 01:52 PM, Xiao Guangrong wrote:
>>>
>>>
>>> On 02/08/2016 06:51 PM, Igor Mammedov wrote:
>>>> On Wed, 13 Jan 2016 02:50:03 +0800
>>>> Xiao Guangrong <guangrong.xiao@linux.intel.com> wrote:
>>>>
>>>>> It will be used by nvdimm acpi
>>>>>
>>>>> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>>>>> ---
>>>>>    hw/acpi/aml-build.c         | 14 ++++++++++++++
>>>>>    include/hw/acpi/aml-build.h |  1 +
>>>>>    2 files changed, 15 insertions(+)
>>>>>
>>>>> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
>>>>> index 97c9efb..421dd84 100644
>>>>> --- a/hw/acpi/aml-build.c
>>>>> +++ b/hw/acpi/aml-build.c
>>>>> @@ -1440,6 +1440,20 @@ Aml *aml_alias(const char *source_object, const char *alias_object)
>>>>>        return var;
>>>>>    }
>>>>>
>>>>> +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
>>>>> +Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
>>>>> +{
>>>>> +    Aml *var = aml_opcode(0x73 /* ConcatOp */);
>>>>> +    aml_append(var, source1);
>>>>> +    aml_append(var, source2);
>>>>> +
>>>>> +    if (target) {
>>>>> +        aml_append(var, target);
>>>>> +    }
>>>> target is not an optional, pls looks at aml_add and use
>>>> helper to make patch correct and smaller
>>>>
>>>
>>> Indeed, i will change it to:
>>>
>>> /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
>>> Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
>>> {
>>>       return  build_opcode_2arg_dst(0x73 /* ConcatOp */, arg1, arg2, dst);
>>> }
>>>
>>
>> And make a assert for @target to ensure it can not be NULL.
> Don't do that, see build_opcode_2arg_dst(), target can be NULL
> that allows to express implicit target like:
>
>    aml_add(a, aml_add(b, c, NULL), NULL)
>
> where one doesn't need an intermediate variable to store result.
>

Yes, you are right, i re-checked the spec and it said that "Source2 is
concatenated to Source1 and the result data is optionally stored into Result" so that
@target can be eliminated.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 97c9efb..421dd84 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1440,6 +1440,20 @@  Aml *aml_alias(const char *source_object, const char *alias_object)
     return var;
 }
 
+/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefConcat */
+Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target)
+{
+    Aml *var = aml_opcode(0x73 /* ConcatOp */);
+    aml_append(var, source1);
+    aml_append(var, source2);
+
+    if (target) {
+        aml_append(var, target);
+    }
+
+    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 e1ba534..4a5168a 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -354,6 +354,7 @@  Aml *aml_touuid(const char *uuid);
 Aml *aml_unicode(const char *str);
 Aml *aml_derefof(Aml *arg);
 Aml *aml_sizeof(Aml *arg);
+Aml *aml_concatenate(Aml *source1, Aml *source2, Aml *target);
 
 void
 build_header(GArray *linker, GArray *table_data,