[SeaBIOS] [Qemu-devel] [PATCH RFC V2 01/17] acpi: added needed acpi constructs
Marcel Apfelbaum
marcel at redhat.com
Mon Feb 16 10:54:01 CET 2015
Signed-off-by: Marcel Apfelbaum <marcel at redhat.com>
---
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
More information about the SeaBIOS
mailing list