[coreboot-gerrit] Patch set updated for coreboot: arch/x86/acpigen: Add generic way of writing dsm

Naresh Solanki (naresh.solanki@intel.com) gerrit at coreboot.org
Tue Nov 15 15:52:47 CET 2016


Naresh Solanki (naresh.solanki at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17424

-gerrit

commit 9f714ca1f5320815645b0ab91908d5803d5a8438
Author: Naresh G Solanki <naresh.solanki at intel.com>
Date:   Tue Nov 15 10:13:15 2016 +0530

    arch/x86/acpigen: Add generic way of writing dsm
    
    Enabling generic way of writing dsm which can handle multiple uuid's
    
    Change-Id: Ic1fbdc0647e8fdc50ffa407887feb19a63cb48e4
    Signed-off-by: Naresh G Solanki <naresh.solanki at intel.com>
---
 src/arch/x86/acpigen.c              | 72 ++++++++++++++++++++++++++++++++++++-
 src/arch/x86/include/arch/acpigen.h | 17 +++++++++
 2 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c
index 0c5a10c..3a404ae 100644
--- a/src/arch/x86/acpigen.c
+++ b/src/arch/x86/acpigen.c
@@ -15,7 +15,7 @@
  */
 
 /* How much nesting do we support? */
-#define ACPIGEN_LENSTACK_SIZE 10
+#define ACPIGEN_LENSTACK_SIZE 100
 
 /*
  * If you need to change this, change acpigen_write_len_f and
@@ -1162,6 +1162,18 @@ void acpigen_write_return_byte(uint8_t arg)
 	acpigen_write_byte(arg);
 }
 
+void acpigen_write_return_integer(uint32_t arg)
+{
+	acpigen_emit_byte(RETURN_OP);
+	acpigen_write_integer(arg);
+}
+
+void acpigen_write_return_string(char *arg)
+{
+	acpigen_emit_byte(RETURN_OP);
+	acpigen_write_string(arg);
+}
+
 /*
  * Generate ACPI AML code for _DSM method.
  * This function takes as input uuid for the device, set of callbacks and
@@ -1248,6 +1260,64 @@ void acpigen_write_dsm(const char *uuid, void (*callbacks[])(void *),
 	acpigen_pop_len();	/* Method _DSM */
 }
 
+static void acpigen_write_inside_dsm(const char *uuid,
+			void (*callbacks[])(void *), size_t count, void *arg)
+{
+	size_t i;
+
+	/* If (LEqual (Local0, ToUUID(uuid))) */
+	acpigen_write_if();
+	acpigen_emit_byte(LEQUAL_OP);
+	acpigen_emit_byte(LOCAL0_OP);
+	acpigen_write_uuid(uuid);
+
+	/*   ToInteger (Arg2, Local1) */
+	acpigen_write_to_integer(ARG2_OP, LOCAL1_OP);
+	acpigen_write_debug_op(LOCAL1_OP);
+
+	for (i = 0; i < count; i++) {
+		acpigen_write_if();
+		acpigen_emit_byte(LEQUAL_OP);
+		acpigen_emit_byte(LOCAL1_OP);
+		acpigen_write_integer(i);
+
+		/*     Callback to write if handler. */
+		if (callbacks[i])
+			callbacks[i](arg);
+
+		acpigen_pop_len();	/* If */
+
+
+	}
+
+	/*   Default case: Return (Buffer (One) { 0x0 }) */
+	acpigen_write_return_singleton_buffer(0x0);
+
+	acpigen_pop_len();	/* If (LEqual (Local0, ToUUID(uuid))) */
+
+}
+
+/* dsm method to include multiple uuids */
+void acpigen_write_dsm_multiple_uuid(struct dsm_uuid *ids, size_t count)
+{
+	size_t i;
+
+	/* Method (_DSM, 4, Serialized) */
+	acpigen_write_method_serialized("_DSM", 0x4);
+
+	/* ToBuffer (Arg0, Local0) */
+	acpigen_write_to_buffer(ARG0_OP, LOCAL0_OP);
+
+	for (i = 0; i < count; i++)
+		acpigen_write_inside_dsm(ids[i].uuid, ids[i].callbacks,
+						ids[i].count, ids[i].arg);
+
+	/*   Return (Buffer (One) { 0x0 }) */
+	acpigen_write_return_singleton_buffer(0x0);
+
+	acpigen_pop_len();	/* Method _DSM */
+}
+
 /* Soc-implemented functions -- weak definitions. */
 int __attribute__((weak)) acpigen_soc_read_rx_gpio(unsigned int gpio_num)
 {
diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h
index 4169fdf..e6521d9 100644
--- a/src/arch/x86/include/arch/acpigen.h
+++ b/src/arch/x86/include/arch/acpigen.h
@@ -144,6 +144,23 @@ struct opregion {
 	unsigned long regionlen;
 };
 
+#define DSM_UUID(DSM_UUID, DSM_CALLBACKS, DSM_COUNT, DSM_ARG) \
+						{ .uuid = DSM_UUID, \
+						.callbacks = DSM_CALLBACKS, \
+						.count = DSM_COUNT, \
+						.arg = DSM_ARG, \
+						}
+
+
+struct dsm_uuid {
+	const char *uuid;
+	void (**callbacks)(void *);
+	size_t count;
+	void *arg;
+};
+void acpigen_write_dsm_multiple_uuid(struct dsm_uuid *ids, size_t count);
+void acpigen_write_return_integer(uint32_t arg);
+void acpigen_write_return_string(char *arg);
 void acpigen_write_len_f(void);
 void acpigen_pop_len(void);
 void acpigen_set_current(char *curr);



More information about the coreboot-gerrit mailing list