qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH v2 04/11] hw/acpi/acpi-build-utils: Add acpi_mem


From: Shannon Zhao
Subject: [Qemu-devel] [RFC PATCH v2 04/11] hw/acpi/acpi-build-utils: Add acpi_memory32_fixed() and acpi_interrupt()
Date: Thu, 29 Jan 2015 16:37:06 +0800

Add acpi_memory32_fixed() for describing device mmio region in resource 
template.
Add acpi_interrupt() for describing device interrupt in resource template.
These can be used to generating DSDT table for ACPI on ARM.

Signed-off-by: Shannon Zhao <address@hidden>
---
 hw/acpi/acpi-build-utils.c         |   40 ++++++++++++++++++++++++++++++++++++
 include/hw/acpi/acpi-build-utils.h |    2 +
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
index aa32fe4..60cce5d 100644
--- a/hw/acpi/acpi-build-utils.c
+++ b/hw/acpi/acpi-build-utils.c
@@ -493,6 +493,46 @@ AcpiAml acpi_call4(const char *method, AcpiAml arg1, 
AcpiAml arg2,
 }
 
 /*
+ * ACPI 1.0: 6.4.3.4 Memory32Fixed (Memory Resource Descriptor Macro)
+ */
+AcpiAml acpi_memory32_fixed(uint64_t addr, uint64_t size, uint8_t rw_flag)
+{
+    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+    build_append_byte(var.buf, 0x86); /* Memory32Fixed Resource Descriptor */
+    build_append_byte(var.buf, 9); /* Length, bits[7:0] value = 9 */
+    build_append_byte(var.buf, 0); /* Length, bits[15:8] value = 0 */
+    build_append_byte(var.buf, rw_flag); /* Write status, 1 rw 0 ro */
+    build_append_byte(var.buf, addr & 0xff); /* Range base address bits[7:0] */
+    build_append_byte(var.buf, (addr >> 8) & 0xff); /* Range base address 
bits[15:8] */
+    build_append_byte(var.buf, (addr >> 16) & 0xff); /* Range base address 
bits[23:16] */
+    build_append_byte(var.buf, (addr >> 24) & 0xff); /* Range base address 
bits[31:24] */
+
+    build_append_byte(var.buf, size & 0xff); /* Range length bits[7:0] */
+    build_append_byte(var.buf, (size >> 8) & 0xff); /* Range length bits[15:8] 
*/
+    build_append_byte(var.buf, (size >> 16) & 0xff); /* Range length 
bits[23:16] */
+    build_append_byte(var.buf, (size >> 24) & 0xff); /* Range length 
bits[31:24] */
+    return var;
+}
+
+/*
+ * ACPI 1.0: 6.4.3.6 Interrupt (Interrupt Resource Descriptor Macro)
+ */
+AcpiAml acpi_interrupt(uint8_t irq_flags, int irq)
+{
+    AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+    build_append_byte(var.buf, 0x89); /* Extended irq descriptor */
+    build_append_byte(var.buf, 6); /* Length, bits[7:0] minimum value = 6 */
+    build_append_byte(var.buf, 0); /* Length, bits[15:8] minimum value = 0 */
+    build_append_byte(var.buf, irq_flags); /* Interrupt Vector Information. */
+    build_append_byte(var.buf, 0x01); /* Interrupt table length = 1 */
+    build_append_byte(var.buf, irq & 0xff); /* Interrupt Number bits[7:0] */
+    build_append_byte(var.buf, (irq >> 8) & 0xff); /* Interrupt Number 
bits[15:8] */
+    build_append_byte(var.buf, (irq >> 16) & 0xff); /* Interrupt Number 
bits[23:16] */
+    build_append_byte(var.buf, (irq >> 24) & 0xff); /* Interrupt Number 
bits[31:24] */
+    return var;
+}
+
+/*
  * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro)
  *           6.4.2 Small Resource Data Type
 */
diff --git a/include/hw/acpi/acpi-build-utils.h 
b/include/hw/acpi/acpi-build-utils.h
index b504c3a..0b0ced7 100644
--- a/include/hw/acpi/acpi-build-utils.h
+++ b/include/hw/acpi/acpi-build-utils.h
@@ -127,6 +127,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_memory32_fixed(uint64_t addr, uint64_t size, uint8_t rw_flag);
+AcpiAml acpi_interrupt(uint8_t irq_flags, int irq);
 AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base,
                 uint8_t aln, uint8_t len);
 AcpiAml acpi_iqr_no_flags(uint8_t irq);
-- 
1.7.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]