[coreboot-gerrit] Change in coreboot[master]: x86/acpigen: Fix acpigen_write_field

Patrick Rudolph (Code Review) gerrit at coreboot.org
Mon Apr 24 19:42:35 CEST 2017


Patrick Rudolph has uploaded a new change for review. ( https://review.coreboot.org/19435 )

Change subject: x86/acpigen: Fix acpigen_write_field
......................................................................

x86/acpigen: Fix acpigen_write_field

The current code doesn't work for field with size > 0x3f.
Fix that by using the correct syntax, reverse engineered using
iasl.
Tested on GNU Linux 4.9 and iasl.

Change-Id: Iac3600f184e6bd36a2bcb85753110692fbcbe4b6
Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
M src/arch/x86/acpigen.c
1 file changed, 27 insertions(+), 2 deletions(-)


  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/35/19435/1

diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c
index 59bfee3..d335599 100644
--- a/src/arch/x86/acpigen.c
+++ b/src/arch/x86/acpigen.c
@@ -414,6 +414,32 @@
 		acpigen_emit_byte(emit[j]);
 }
 
+static void acpigen_write_field_name(const char *name,
+				     uint32_t size)
+{
+	uint8_t i, j;
+	uint8_t emit[4];
+
+	i = 1;
+	if (size < 0x40) {
+		emit[0] = size & 0x3F;
+	} else {
+		emit[0] = size & 0xF;
+		size >>= 4;
+		while (size) {
+			emit[i] = size & 0xFF;
+			i++;
+			size >>= 8;
+		}
+	}
+	/* Update bit 7:6 : Number of bytes followed by emit[0] */
+	emit[0] |= (i - 1) << 6;
+
+	acpigen_emit_simple_namestring(name);
+	for (j = 0; j < i; j++)
+		acpigen_emit_byte(emit[j]);
+}
+
 /*
  * Generate ACPI AML code for Field
  * Arg0: region name
@@ -452,8 +478,7 @@
 	for (i = 0; i < count; i++) {
 		switch (l[i].type) {
 		case NAME_STRING:
-			acpigen_emit_simple_namestring(l[i].name);
-			acpigen_emit_byte(l[i].bits);
+			acpigen_write_field_name(l[i].name, l[i].bits);
 			current_bit_pos += l[i].bits;
 			break;
 		case OFFSET:

-- 
To view, visit https://review.coreboot.org/19435
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iac3600f184e6bd36a2bcb85753110692fbcbe4b6
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Patrick Rudolph <siro at das-labor.org>



More information about the coreboot-gerrit mailing list