Message ID | 1421938231-25698-3-git-send-email-imammedo@redhat.com |
---|---|
State | New |
Headers | show |
On Thu, Jan 22, 2015 at 02:49:46PM +0000, Igor Mammedov wrote: > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > --- > hw/acpi/acpi-build-utils.c | 18 ++++++++++++++++++ > include/hw/acpi/acpi-build-utils.h | 4 ++++ > 2 files changed, 22 insertions(+) > > diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c > index 547ecaa..e13d748 100644 > --- a/hw/acpi/acpi-build-utils.c > +++ b/hw/acpi/acpi-build-utils.c > @@ -306,3 +306,21 @@ void aml_append(AcpiAml *parent_ctx, AcpiAml child) > build_append_array(parent_ctx->buf, child.buf); > build_free_array(child.buf); > } > + > +static AcpiAml aml_allocate_internal(uint8_t op, AcpiBlockFlags flags) > +{ > + AcpiAml var = { .op = op, .block_flags = flags }; > + var.buf = build_alloc_array(); > + return var; > +} > + Is there also allocate_external? If not - static is enough to know it's not an API function. > +/* ACPI 5.0: 20.2.5.1 Namespace Modifier Objects Encoding: DefScope */ > +AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...) > +{ > + va_list ap; > + AcpiAml var = aml_allocate_internal(0x10 /* ScopeOp */, PACKAGE); > + va_start(ap, name_format); > + build_append_namestringv(var.buf, name_format, ap); > + va_end(ap); > + return var; > +} > diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h > index 64e7ec3..bbb786b 100644 > --- a/include/hw/acpi/acpi-build-utils.h > +++ b/include/hw/acpi/acpi-build-utils.h > @@ -21,6 +21,10 @@ typedef struct AcpiAml { > > void aml_append(AcpiAml *parent_ctx, AcpiAml child); > > +/* Block ASL object primitives */ > +AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...); > + > +/* other helpers */ > GArray *build_alloc_array(void); > void build_free_array(GArray *array); > void build_prepend_byte(GArray *array, uint8_t val); > -- > 1.8.3.1
On Fri, 23 Jan 2015 10:02:54 +0200 "Michael S. Tsirkin" <mst@redhat.com> wrote: > On Thu, Jan 22, 2015 at 02:49:46PM +0000, Igor Mammedov wrote: > > Signed-off-by: Igor Mammedov <imammedo@redhat.com> > > --- > > hw/acpi/acpi-build-utils.c | 18 ++++++++++++++++++ > > include/hw/acpi/acpi-build-utils.h | 4 ++++ > > 2 files changed, 22 insertions(+) > > > > diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c > > index 547ecaa..e13d748 100644 > > --- a/hw/acpi/acpi-build-utils.c > > +++ b/hw/acpi/acpi-build-utils.c > > @@ -306,3 +306,21 @@ void aml_append(AcpiAml *parent_ctx, AcpiAml child) > > build_append_array(parent_ctx->buf, child.buf); > > build_free_array(child.buf); > > } > > + > > +static AcpiAml aml_allocate_internal(uint8_t op, AcpiBlockFlags flags) > > +{ > > + AcpiAml var = { .op = op, .block_flags = flags }; > > + var.buf = build_alloc_array(); > > + return var; > > +} > > + > > Is there also allocate_external? If not - static is enough to > know it's not an API function. There isn't, I'll fix it up. > > > +/* ACPI 5.0: 20.2.5.1 Namespace Modifier Objects Encoding: DefScope */ > > +AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...) > > +{ > > + va_list ap; > > + AcpiAml var = aml_allocate_internal(0x10 /* ScopeOp */, PACKAGE); > > + va_start(ap, name_format); > > + build_append_namestringv(var.buf, name_format, ap); > > + va_end(ap); > > + return var; > > +} > > diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h > > index 64e7ec3..bbb786b 100644 > > --- a/include/hw/acpi/acpi-build-utils.h > > +++ b/include/hw/acpi/acpi-build-utils.h > > @@ -21,6 +21,10 @@ typedef struct AcpiAml { > > > > void aml_append(AcpiAml *parent_ctx, AcpiAml child); > > > > +/* Block ASL object primitives */ > > +AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...); > > + > > +/* other helpers */ > > GArray *build_alloc_array(void); > > void build_free_array(GArray *array); > > void build_prepend_byte(GArray *array, uint8_t val); > > -- > > 1.8.3.1 >
diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c index 547ecaa..e13d748 100644 --- a/hw/acpi/acpi-build-utils.c +++ b/hw/acpi/acpi-build-utils.c @@ -306,3 +306,21 @@ void aml_append(AcpiAml *parent_ctx, AcpiAml child) build_append_array(parent_ctx->buf, child.buf); build_free_array(child.buf); } + +static AcpiAml aml_allocate_internal(uint8_t op, AcpiBlockFlags flags) +{ + AcpiAml var = { .op = op, .block_flags = flags }; + var.buf = build_alloc_array(); + return var; +} + +/* ACPI 5.0: 20.2.5.1 Namespace Modifier Objects Encoding: DefScope */ +AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...) +{ + va_list ap; + AcpiAml var = aml_allocate_internal(0x10 /* ScopeOp */, PACKAGE); + va_start(ap, name_format); + build_append_namestringv(var.buf, name_format, ap); + va_end(ap); + return var; +} diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h index 64e7ec3..bbb786b 100644 --- a/include/hw/acpi/acpi-build-utils.h +++ b/include/hw/acpi/acpi-build-utils.h @@ -21,6 +21,10 @@ typedef struct AcpiAml { void aml_append(AcpiAml *parent_ctx, AcpiAml child); +/* Block ASL object primitives */ +AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...); + +/* other helpers */ GArray *build_alloc_array(void); void build_free_array(GArray *array); void build_prepend_byte(GArray *array, uint8_t val);
Signed-off-by: Igor Mammedov <imammedo@redhat.com> --- hw/acpi/acpi-build-utils.c | 18 ++++++++++++++++++ include/hw/acpi/acpi-build-utils.h | 4 ++++ 2 files changed, 22 insertions(+)