diff mbox

[v2,22/47] acpi: add acpi_io() helper

Message ID 1421938231-25698-23-git-send-email-imammedo@redhat.com
State New
Headers show

Commit Message

Igor Mammedov Jan. 22, 2015, 2:50 p.m. UTC
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/acpi-build-utils.c         | 19 +++++++++++++++++++
 include/hw/acpi/acpi-build-utils.h |  7 +++++++
 2 files changed, 26 insertions(+)

Comments

Marcel Apfelbaum Feb. 5, 2015, 3:19 p.m. UTC | #1
On 01/22/2015 04:50 PM, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>   hw/acpi/acpi-build-utils.c         | 19 +++++++++++++++++++
>   include/hw/acpi/acpi-build-utils.h |  7 +++++++
>   2 files changed, 26 insertions(+)
>
> diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
> index 32a4377..56b237a 100644
> --- a/hw/acpi/acpi-build-utils.c
> +++ b/hw/acpi/acpi-build-utils.c
> @@ -454,6 +454,25 @@ AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
>       return var;
>   }
>
> +/*
> + * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro)
> + *           6.4.2 Small Resource Data Type
> +*/
> +AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
> +                uint8_t aln, uint8_t len)
> +{
> +    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
> +    build_append_byte(var.buf, 0x47); /* IO port descriptor */
> +    build_append_byte(var.buf, dec);
> +    build_append_byte(var.buf, min_base & 0xff);
> +    build_append_byte(var.buf, (min_base >> 8) & 0xff);
> +    build_append_byte(var.buf, max_base & 0xff);
> +    build_append_byte(var.buf, (max_base >> 8) & 0xff);
> +    build_append_byte(var.buf, aln);
> +    build_append_byte(var.buf, len);
> +    return var;
> +}
> +
>   /* ACPI 5.0: 20.2.5.3 Type 1 Opcodes Encoding: DefIfElse */
>   AcpiAml acpi_if(AcpiAml predicate)
>   {
> diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h
> index 594fae7..91575f1 100644
> --- a/include/hw/acpi/acpi-build-utils.h
> +++ b/include/hw/acpi/acpi-build-utils.h
> @@ -19,6 +19,11 @@ typedef struct AcpiAml {
>       AcpiBlockFlags block_flags;
>   } AcpiAml;
>
> +typedef enum {
> +    acpi_decode10 = 0,
> +    acpi_decode16 = 1,
> +} acpiIODecode;
A really small comment, you mean AcpiIODecode and not acpiIODecode, right?

Thanks,
Marcel

> +
>   void aml_append(AcpiAml *parent_ctx, AcpiAml child);
>
>   /* non block ASL object primitives */
> @@ -39,6 +44,8 @@ AcpiAml acpi_call3(const char *method, AcpiAml arg1, AcpiAml arg2,
>                      AcpiAml arg3);
>   AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
>                      AcpiAml arg3, AcpiAml arg4);
> +AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
> +                uint8_t aln, uint8_t len);
>
>   /* Block ASL object primitives */
>   AcpiAml acpi_if(AcpiAml predicate);
>
Igor Mammedov Feb. 5, 2015, 5:56 p.m. UTC | #2
On Thu, 05 Feb 2015 17:19:39 +0200
Marcel Apfelbaum <marcel@redhat.com> wrote:

> On 01/22/2015 04:50 PM, Igor Mammedov wrote:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >   hw/acpi/acpi-build-utils.c         | 19 +++++++++++++++++++
> >   include/hw/acpi/acpi-build-utils.h |  7 +++++++
> >   2 files changed, 26 insertions(+)
> >
> > diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
> > index 32a4377..56b237a 100644
> > --- a/hw/acpi/acpi-build-utils.c
> > +++ b/hw/acpi/acpi-build-utils.c
> > @@ -454,6 +454,25 @@ AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
> >       return var;
> >   }
> >
> > +/*
> > + * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro)
> > + *           6.4.2 Small Resource Data Type
> > +*/
> > +AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
> > +                uint8_t aln, uint8_t len)
> > +{
> > +    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
> > +    build_append_byte(var.buf, 0x47); /* IO port descriptor */
> > +    build_append_byte(var.buf, dec);
> > +    build_append_byte(var.buf, min_base & 0xff);
> > +    build_append_byte(var.buf, (min_base >> 8) & 0xff);
> > +    build_append_byte(var.buf, max_base & 0xff);
> > +    build_append_byte(var.buf, (max_base >> 8) & 0xff);
> > +    build_append_byte(var.buf, aln);
> > +    build_append_byte(var.buf, len);
> > +    return var;
> > +}
> > +
> >   /* ACPI 5.0: 20.2.5.3 Type 1 Opcodes Encoding: DefIfElse */
> >   AcpiAml acpi_if(AcpiAml predicate)
> >   {
> > diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h
> > index 594fae7..91575f1 100644
> > --- a/include/hw/acpi/acpi-build-utils.h
> > +++ b/include/hw/acpi/acpi-build-utils.h
> > @@ -19,6 +19,11 @@ typedef struct AcpiAml {
> >       AcpiBlockFlags block_flags;
> >   } AcpiAml;
> >
> > +typedef enum {
> > +    acpi_decode10 = 0,
> > +    acpi_decode16 = 1,
> > +} acpiIODecode;
> A really small comment, you mean AcpiIODecode and not acpiIODecode, right?
Yep, it is renamed to AmlIODecode in coming v3.
You can see intermediate result on github.

> 
> Thanks,
> Marcel
> 
> > +
> >   void aml_append(AcpiAml *parent_ctx, AcpiAml child);
> >
> >   /* non block ASL object primitives */
> > @@ -39,6 +44,8 @@ AcpiAml acpi_call3(const char *method, AcpiAml arg1, AcpiAml arg2,
> >                      AcpiAml arg3);
> >   AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
> >                      AcpiAml arg3, AcpiAml arg4);
> > +AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
> > +                uint8_t aln, uint8_t len);
> >
> >   /* Block ASL object primitives */
> >   AcpiAml acpi_if(AcpiAml predicate);
> >
>
diff mbox

Patch

diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
index 32a4377..56b237a 100644
--- a/hw/acpi/acpi-build-utils.c
+++ b/hw/acpi/acpi-build-utils.c
@@ -454,6 +454,25 @@  AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
     return var;
 }
 
+/*
+ * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro)
+ *           6.4.2 Small Resource Data Type
+*/
+AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
+                uint8_t aln, uint8_t len)
+{
+    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+    build_append_byte(var.buf, 0x47); /* IO port descriptor */
+    build_append_byte(var.buf, dec);
+    build_append_byte(var.buf, min_base & 0xff);
+    build_append_byte(var.buf, (min_base >> 8) & 0xff);
+    build_append_byte(var.buf, max_base & 0xff);
+    build_append_byte(var.buf, (max_base >> 8) & 0xff);
+    build_append_byte(var.buf, aln);
+    build_append_byte(var.buf, len);
+    return var;
+}
+
 /* ACPI 5.0: 20.2.5.3 Type 1 Opcodes Encoding: DefIfElse */
 AcpiAml acpi_if(AcpiAml predicate)
 {
diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h
index 594fae7..91575f1 100644
--- a/include/hw/acpi/acpi-build-utils.h
+++ b/include/hw/acpi/acpi-build-utils.h
@@ -19,6 +19,11 @@  typedef struct AcpiAml {
     AcpiBlockFlags block_flags;
 } AcpiAml;
 
+typedef enum {
+    acpi_decode10 = 0,
+    acpi_decode16 = 1,
+} acpiIODecode;
+
 void aml_append(AcpiAml *parent_ctx, AcpiAml child);
 
 /* non block ASL object primitives */
@@ -39,6 +44,8 @@  AcpiAml acpi_call3(const char *method, AcpiAml arg1, AcpiAml arg2,
                    AcpiAml arg3);
 AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2,
                    AcpiAml arg3, AcpiAml arg4);
+AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
+                uint8_t aln, uint8_t len);
 
 /* Block ASL object primitives */
 AcpiAml acpi_if(AcpiAml predicate);