[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [Qemu-devel] [PATCH RFC 01/17] acpi: added needed acpi constr
From: |
Marcel Apfelbaum |
Subject: |
[Qemu-ppc] [Qemu-devel] [PATCH RFC 01/17] acpi: added needed acpi constructs |
Date: |
Thu, 22 Jan 2015 21:52:27 +0200 |
Signed-off-by: Marcel Apfelbaum <address@hidden>
---
hw/acpi/acpi-build-utils.c | 107 +++++++++++++++++++++++++++++++++++--
include/hw/acpi/acpi-build-utils.h | 12 +++++
2 files changed, 116 insertions(+), 3 deletions(-)
diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
index 58f88cd..19cd146 100644
--- a/hw/acpi/acpi-build-utils.c
+++ b/hw/acpi/acpi-build-utils.c
@@ -439,6 +439,26 @@ AcpiAml acpi_and(AcpiAml arg1, AcpiAml arg2)
return var;
}
+AcpiAml acpi_or(AcpiAml arg1, AcpiAml arg2)
+{
+ AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+ build_append_byte(var.buf, 0x7D); /* AndOp */
+ aml_append(&var, arg1);
+ aml_append(&var, arg2);
+ build_append_int(var.buf, 0x00); /* NullNameOp */
+ return var;
+}
+
+AcpiAml acpi_add(AcpiAml arg1, AcpiAml arg2)
+{
+ AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+ build_append_byte(var.buf, 0x72); /* AddOp */
+ aml_append(&var, arg1);
+ aml_append(&var, arg2);
+ build_append_int(var.buf, 0x00); /* NullNameOp */
+ return var;
+}
+
/* ACPI 5.0: 20.2.5.3 Type 1 Opcodes Encoding: DefNotify */
AcpiAml acpi_notify(AcpiAml arg1, AcpiAml arg2)
{
@@ -518,6 +538,53 @@ AcpiAml acpi_equal(AcpiAml arg1, AcpiAml arg2)
build_append_byte(var.buf, 0x93); /* LequalOp */
aml_append(&var, arg1);
aml_append(&var, arg2);
+ return var;
+}
+
+AcpiAml acpi_increment(AcpiAml arg1)
+{
+ AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+ build_append_byte(var.buf, 0x75); /* LequalOp */
+ aml_append(&var, arg1);
+ return var;
+}
+
+AcpiAml acpi_lless(AcpiAml arg1, AcpiAml arg2)
+{
+ AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+ build_append_byte(var.buf, 0x95); /* LequalOp */
+ aml_append(&var, arg1);
+ aml_append(&var, arg2);
+// build_append_int(var.buf, 0x00); /* NullNameOp */
+ return var;
+}
+
+AcpiAml acpi_shiftright(AcpiAml arg1, int count)
+{
+ AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+ build_append_byte(var.buf, 0x7A); /* RightShiftOp */
+ aml_append(&var, arg1);
+ aml_append(&var, acpi_int(count));
+ build_append_int(var.buf, 0x00); /* NullNameOp */
+ return var;
+}
+
+AcpiAml acpi_shiftleft(AcpiAml arg1, int count)
+{
+ AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+ build_append_byte(var.buf, 0x79); /* RightLeftOp */
+ aml_append(&var, arg1);
+ aml_append(&var, acpi_int(count));
+ build_append_int(var.buf, 0x00); /* NullNameOp */
+ return var;
+}
+
+AcpiAml acpi_index(AcpiAml arg1, AcpiAml idx)
+{
+ AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
+ build_append_byte(var.buf, 0x88); /* IndexOp */
+ aml_append(&var, arg1);
+ aml_append(&var, idx);
build_append_int(var.buf, 0x00); /* NullNameOp */
return var;
}
@@ -530,6 +597,13 @@ AcpiAml acpi_if(AcpiAml predicate)
return var;
}
+AcpiAml acpi_while(AcpiAml predicate)
+{
+ AcpiAml var = aml_allocate_internal(0xA2 /* WhileOp */, PACKAGE);
+ aml_append(&var, predicate);
+ return var;
+}
+
/* ACPI 5.0: 20.2.5.2 Named Objects Encoding: DefMethod */
AcpiAml acpi_method(const char *name, int arg_count)
{
@@ -652,14 +726,41 @@ AcpiAml GCC_FMT_ATTR(1, 2) acpi_string(const char
*name_format, ...)
return var;
}
-/* ACPI 5.0: 20.2.6.2 Local Objects Encoding: Local0Op */
-AcpiAml acpi_local0(void)
+/* ACPI 5.0: 20.2.6.2 Local Objects Encoding: LocalXOp */
+static AcpiAml acpi_local(uint8_t index)
{
AcpiAml var = aml_allocate_internal(0, NON_BLOCK);
- build_append_byte(var.buf, 0x60); /* Local0Op */
+
+ assert(index < 8);
+ build_append_byte(var.buf, 0x60 + index); /* Local0Op */
return var;
}
+AcpiAml acpi_local0(void)
+{
+ return acpi_local(0);
+}
+
+AcpiAml acpi_local1(void)
+{
+ return acpi_local(1);
+}
+
+AcpiAml acpi_local2(void)
+{
+ return acpi_local(2);
+}
+
+AcpiAml acpi_local3(void)
+{
+ return acpi_local(3);
+}
+
+AcpiAml acpi_local4(void)
+{
+ return acpi_local(4);
+}
+
/* ACPI 5.0: 20.2.5.4 Type 2 Opcodes Encoding: DefVarPackage */
AcpiAml acpi_varpackage(uint32_t num_elements)
{
diff --git a/include/hw/acpi/acpi-build-utils.h
b/include/hw/acpi/acpi-build-utils.h
index 868d439..e39a82d 100644
--- a/include/hw/acpi/acpi-build-utils.h
+++ b/include/hw/acpi/acpi-build-utils.h
@@ -108,6 +108,8 @@ AcpiAml acpi_arg2(void);
AcpiAml acpi_arg3(void);
AcpiAml acpi_store(AcpiAml val, AcpiAml target);
AcpiAml acpi_and(AcpiAml arg1, AcpiAml arg2);
+AcpiAml acpi_or(AcpiAml arg1, AcpiAml arg2);
+AcpiAml acpi_add(AcpiAml arg1, AcpiAml arg2);
AcpiAml acpi_notify(AcpiAml arg1, AcpiAml arg2);
AcpiAml acpi_call1(const char *method, AcpiAml arg1);
AcpiAml acpi_call2(const char *method, AcpiAml arg1, AcpiAml arg2);
@@ -123,7 +125,16 @@ AcpiAml acpi_named_field(const char *name, unsigned
length);
AcpiAml acpi_reserved_field(unsigned length);
AcpiAml GCC_FMT_ATTR(1, 2) acpi_string(const char *name_format, ...);
AcpiAml acpi_local0(void);
+AcpiAml acpi_local1(void);
+AcpiAml acpi_local2(void);
+AcpiAml acpi_local3(void);
+AcpiAml acpi_local4(void);
+AcpiAml acpi_increment(AcpiAml arg1);
AcpiAml acpi_equal(AcpiAml arg1, AcpiAml arg2);
+AcpiAml acpi_lless(AcpiAml arg1, AcpiAml arg2);
+AcpiAml acpi_index(AcpiAml arg1, AcpiAml idx);
+AcpiAml acpi_shiftright(AcpiAml arg1, int count);
+AcpiAml acpi_shiftleft(AcpiAml arg1, int count);
AcpiAml GCC_FMT_ATTR(4, 5)
acpi_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len,
const char *name_format, ...);
@@ -155,6 +166,7 @@ AcpiAml acpi_def_block(const char *signature, uint8_t
revision,
const char *oem_id, const char *oem_table_id,
uint32_t oem_revision);
AcpiAml acpi_if(AcpiAml predicate);
+AcpiAml acpi_while(AcpiAml predicate);
AcpiAml acpi_method(const char *name, int arg_count);
AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...);
AcpiAml GCC_FMT_ATTR(1, 2) acpi_device(const char *name_format, ...);
--
2.1.0
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 00/17] implement multiple primary busses for pc machines, Marcel Apfelbaum, 2015/01/22
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 02/17] hw/acpi: add support for multiple root busses, Marcel Apfelbaum, 2015/01/22
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 01/17] acpi: added needed acpi constructs,
Marcel Apfelbaum <=
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 03/17] hw/apci: add _PRT method for extra root busses, Marcel Apfelbaum, 2015/01/22
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 04/17] hw/acpi: add _CRS method for extra root busses, Marcel Apfelbaum, 2015/01/22
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 05/17] hw/acpi: remove from root bus 0 the crs resources used by other busses., Marcel Apfelbaum, 2015/01/22
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 07/17] hw/pci: made pci_bus_is_root a PCIBusClass method, Marcel Apfelbaum, 2015/01/22
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 09/17] hw/pci: introduce TYPE_PCI_MAIN_HOST_BRIDGE interface, Marcel Apfelbaum, 2015/01/22
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 10/17] hw/pci: removed 'rootbus nr is 0' assumption from qmp_pci_query, Marcel Apfelbaum, 2015/01/22
- [Qemu-ppc] [Qemu-devel] [PATCH RFC 08/17] hw/pci: made pci_bus_num a PCIBusClass method, Marcel Apfelbaum, 2015/01/22