On Fri, 3 Apr 2015 18:03:46 +0800 Shannon Zhao <zhaoshengl...@huawei.com> wrote:
> From: Shannon Zhao <shannon.z...@linaro.org> > > Add aml_or() term and make aml_and can take three args. > Expose build_append_int_noprefix as it wiil be used by > creating a buffer. > > Signed-off-by: Shannon Zhao <zhaoshengl...@huawei.com> > Signed-off-by: Shannon Zhao <shannon.z...@linaro.org> > --- > hw/acpi/aml-build.c | 24 +++++++++++++++++++++--- > hw/i386/acpi-build.c | 2 +- > include/hw/acpi/aml-build.h | 4 +++- > 3 files changed, 25 insertions(+), 5 deletions(-) > > diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c > index 5a94fc9..312afb6 100644 > --- a/hw/acpi/aml-build.c > +++ b/hw/acpi/aml-build.c > @@ -240,7 +240,7 @@ static void build_extop_package(GArray *package, uint8_t > op) > build_prepend_byte(package, 0x5B); /* ExtOpPrefix */ > } > > -static void build_append_int_noprefix(GArray *table, uint64_t value, int > size) > +void build_append_int_noprefix(GArray *table, uint64_t value, int size) > { > int i; > > @@ -445,12 +445,30 @@ Aml *aml_store(Aml *val, Aml *target) > } > > /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ > -Aml *aml_and(Aml *arg1, Aml *arg2) > +Aml *aml_and(Aml *arg1, Aml *arg2, Aml *arg3) I know that it's possible to Store inside of And(a, b, save_here) ASL op, but could you instead rewrite it to Store(And(a, b), save_here) so it wouldn't clatter trivial And(a,b) uses and drop this hunk. > { > Aml *var = aml_opcode(0x7B /* AndOp */); > aml_append(var, arg1); > aml_append(var, arg2); > - build_append_byte(var->buf, 0x00 /* NullNameOp */); > + if (arg3 == NULL) { > + build_append_byte(var->buf, 0x00 /* NullNameOp */); > + } else { > + aml_append(var, arg3); > + } > + return var; > +} > + > +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */ > +Aml *aml_or(Aml *arg1, Aml *arg2, Aml *arg3) same here for arg3 > +{ > + Aml *var = aml_opcode(0x7D /* OrOp */); > + aml_append(var, arg1); > + aml_append(var, arg2); > + if (arg3 == NULL) { > + build_append_byte(var->buf, 0x00 /* NullNameOp */); > + } else { > + aml_append(var, arg3); > + } > return var; > } > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 7b5210e..133685e 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -452,7 +452,7 @@ static void build_append_pcihp_notify_entry(Aml *method, > int slot) > Aml *if_ctx; > int32_t devfn = PCI_DEVFN(slot, 0); > > - if_ctx = aml_if(aml_and(aml_arg(0), aml_int(0x1U << slot))); > + if_ctx = aml_if(aml_and(aml_arg(0), aml_int(0x1U << slot), NULL)); > aml_append(if_ctx, aml_notify(aml_name("S%.02X", devfn), aml_arg(1))); > aml_append(method, if_ctx); > } > diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h > index 942d986..3473d6e 100644 > --- a/include/hw/acpi/aml-build.h > +++ b/include/hw/acpi/aml-build.h > @@ -156,7 +156,8 @@ Aml *aml_return(Aml *val); > Aml *aml_int(const uint64_t val); > Aml *aml_arg(int pos); > Aml *aml_store(Aml *val, Aml *target); > -Aml *aml_and(Aml *arg1, Aml *arg2); > +Aml *aml_and(Aml *arg1, Aml *arg2, Aml *arg3); > +Aml *aml_or(Aml *arg1, Aml *arg2, Aml *arg3); > Aml *aml_notify(Aml *arg1, Aml *arg2); > Aml *aml_call1(const char *method, Aml *arg1); > Aml *aml_call2(const char *method, Aml *arg1, Aml *arg2); > @@ -211,6 +212,7 @@ Aml *aml_field(const char *name, AmlFieldFlags flags); > Aml *aml_varpackage(uint32_t num_elements); > Aml *aml_touuid(int32_t val1, int16_t val2, int16_t val3, > int16_t val4, int64_t val5); > +void build_append_int_noprefix(GArray *table, uint64_t value, int size); > > void > build_header(GArray *linker, GArray *table_data,