[coreboot-gerrit] New patch to review for coreboot: acpigen: Add helpers for word/dword output

Duncan Laurie (dlaurie@google.com) gerrit at coreboot.org
Thu May 12 22:40:49 CEST 2016


Duncan Laurie (dlaurie at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14792

-gerrit

commit 6a15df61510535a8d621dd44505b1722de5b6836
Author: Duncan Laurie <dlaurie at chromium.org>
Date:   Mon May 9 07:43:19 2016 -0700

    acpigen: Add helpers for word/dword output
    
    Add helpers for writing word and dword values in acpigen and use them
    throughout the file to clean things up:
    
    acpigen_emit_word - write raw word
    acpigen_emit_dword - write raw dword
    acpigen_write_word - write word opcode and value
    
    Change-Id: Ia758d4dd25d0ae5b31be7d51b33866dddd96a473
    Signed-off-by: Duncan Laurie <dlaurie at chromium.org>
---
 src/arch/x86/acpigen.c              | 64 ++++++++++++++++++-------------------
 src/arch/x86/include/arch/acpigen.h |  3 ++
 2 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c
index 1a23bdc..55a6fd0 100644
--- a/src/arch/x86/acpigen.c
+++ b/src/arch/x86/acpigen.c
@@ -72,6 +72,20 @@ void acpigen_emit_byte(unsigned char b)
 	(*gencurrent++) = b;
 }
 
+void acpigen_emit_word(unsigned int data)
+{
+	acpigen_emit_byte(data & 0xff);
+	acpigen_emit_byte((data >> 8) & 0xff);
+}
+
+void acpigen_emit_dword(unsigned int data)
+{
+	acpigen_emit_byte(data & 0xff);
+	acpigen_emit_byte((data >> 8) & 0xff);
+	acpigen_emit_byte((data >> 16) & 0xff);
+	acpigen_emit_byte((data >> 24) & 0xff);
+}
+
 void acpigen_write_package(int nr_el)
 {
 	/* package op */
@@ -87,28 +101,27 @@ void acpigen_write_byte(unsigned int data)
 	acpigen_emit_byte(data & 0xff);
 }
 
+void acpigen_write_word(unsigned int data)
+{
+	/* word op */
+	acpigen_emit_byte(0xb);
+	acpigen_emit_byte(data & 0xff);
+	acpigen_emit_byte((data >> 8) & 0xff);
+}
+
 void acpigen_write_dword(unsigned int data)
 {
 	/* dword op */
 	acpigen_emit_byte(0xc);
-	acpigen_emit_byte(data & 0xff);
-	acpigen_emit_byte((data >> 8) & 0xff);
-	acpigen_emit_byte((data >> 16) & 0xff);
-	acpigen_emit_byte((data >> 24) & 0xff);
+	acpigen_emit_dword(data);
 }
 
 void acpigen_write_qword(uint64_t data)
 {
 	/* qword op */
 	acpigen_emit_byte(0xe);
-	acpigen_emit_byte(data & 0xff);
-	acpigen_emit_byte((data >> 8) & 0xff);
-	acpigen_emit_byte((data >> 16) & 0xff);
-	acpigen_emit_byte((data >> 24) & 0xff);
-	acpigen_emit_byte((data >> 32) & 0xff);
-	acpigen_emit_byte((data >> 40) & 0xff);
-	acpigen_emit_byte((data >> 48) & 0xff);
-	acpigen_emit_byte((data >> 56) & 0xff);
+	acpigen_emit_dword(data & 0xffffffff);
+	acpigen_emit_dword((data >> 32) & 0xffffffff);
 }
 
 void acpigen_write_name_byte(const char *name, uint8_t val)
@@ -261,10 +274,7 @@ void acpigen_write_processor(u8 cpuindex, u32 pblock_addr, u8 pblock_len)
 		 "\\_PR.CP%02d", (unsigned int) cpuindex);
 	acpigen_emit_namestring(pscope);
 	acpigen_emit_byte(cpuindex);
-	acpigen_emit_byte(pblock_addr & 0xff);
-	acpigen_emit_byte((pblock_addr >> 8) & 0xff);
-	acpigen_emit_byte((pblock_addr >> 16) & 0xff);
-	acpigen_emit_byte((pblock_addr >> 24) & 0xff);
+	acpigen_emit_dword(pblock_addr);
 	acpigen_emit_byte(pblock_len);
 }
 
@@ -366,7 +376,7 @@ void acpigen_write_method(const char *name, int nargs)
 
 void acpigen_write_device(const char *name)
 {
-	/* method op */
+	/* device op */
 	acpigen_emit_byte(0x5b);
 	acpigen_emit_byte(0x82);
 	acpigen_write_len_f();
@@ -557,14 +567,8 @@ void acpigen_write_mem32fixed(int readwrite, u32 base, u32 size)
 	acpigen_emit_byte(0x00);
 	/* bit1-7 are ignored */
 	acpigen_emit_byte(readwrite ? 0x01 : 0x00);
-	acpigen_emit_byte(base & 0xff);
-	acpigen_emit_byte((base >> 8) & 0xff);
-	acpigen_emit_byte((base >> 16) & 0xff);
-	acpigen_emit_byte((base >> 24) & 0xff);
-	acpigen_emit_byte(size & 0xff);
-	acpigen_emit_byte((size >> 8) & 0xff);
-	acpigen_emit_byte((size >> 16) & 0xff);
-	acpigen_emit_byte((size >> 24) & 0xff);
+	acpigen_emit_dword(base);
+	acpigen_emit_dword(size);
 }
 
 void acpigen_write_register(acpi_addr_t *addr)
@@ -576,14 +580,8 @@ void acpigen_write_register(acpi_addr_t *addr)
 	acpigen_emit_byte(addr->bit_width);	/* Register Bit Width */
 	acpigen_emit_byte(addr->bit_offset);	/* Register Bit Offset */
 	acpigen_emit_byte(addr->resv);		/* Register Access Size */
-	acpigen_emit_byte(addr->addrl & 0xff);	/* Register Address Low */
-	acpigen_emit_byte((addr->addrl >> 8) & 0xff);
-	acpigen_emit_byte((addr->addrl >> 16) & 0xff);
-	acpigen_emit_byte((addr->addrl >> 24) & 0xff);
-	acpigen_emit_byte(addr->addrh & 0xff);	/* Register Address High */
-	acpigen_emit_byte((addr->addrh >> 8) & 0xff);
-	acpigen_emit_byte((addr->addrh >> 16) & 0xff);
-	acpigen_emit_byte((addr->addrh >> 24) & 0xff);
+	acpigen_emit_dword(addr->addrl);	/* Register Address Low */
+	acpigen_emit_dword(addr->addrh);	/* Register Address High */
 }
 
 void acpigen_write_irq(u16 mask)
diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h
index 1ad021a..9323475 100644
--- a/src/arch/x86/include/arch/acpigen.h
+++ b/src/arch/x86/include/arch/acpigen.h
@@ -29,9 +29,12 @@ char *acpigen_get_current(void);
 void acpigen_write_package(int nr_el);
 void acpigen_write_byte(unsigned int data);
 void acpigen_emit_byte(unsigned char data);
+void acpigen_emit_word(unsigned int data);
+void acpigen_emit_dword(unsigned int data);
 void acpigen_emit_stream(const char *data, int size);
 void acpigen_emit_namestring(const char *namepath);
 void acpigen_emit_eisaid(const char *eisaid);
+void acpigen_write_word(unsigned int data);
 void acpigen_write_dword(unsigned int data);
 void acpigen_write_qword(uint64_t data);
 void acpigen_write_name(const char *name);



More information about the coreboot-gerrit mailing list