Patrick Georgi ([email protected]) just uploaded a new patch set to 
gerrit, which you can find at http://review.coreboot.org/2487

-gerrit

commit 7520e4a6f817f15af9e5e942e2f15dd8ceffdbb5
Author: Patrick Georgi <[email protected]>
Date:   Fri Feb 22 20:19:20 2013 +0100

    */acpi_tables.c: Use ALIGN macro
    
    At the request of Paul Menzel, I reran an
    old classic of a coccinelle script:
      @@
      expression E;
      @@
      -(E + 7) & -8
      +ALIGN(E, 8)
    
      @@
      expression E;
      @@
      -(E + 15) & -16
      +ALIGN(E, 16)
    
    Change-Id: I01da31b241585e361380f75aacf3deddb13d11c3
    Signed-off-by: Patrick Georgi <[email protected]>
---
 src/mainboard/amd/parmer/acpi_tables.c       | 24 ++++++++++++------------
 src/mainboard/amd/thatcher/acpi_tables.c     | 24 ++++++++++++------------
 src/mainboard/google/butterfly/acpi_tables.c |  2 +-
 src/mainboard/google/parrot/acpi_tables.c    |  2 +-
 src/mainboard/supermicro/h8scm/acpi_tables.c | 16 ++++++++--------
 src/mainboard/tyan/s8226/acpi_tables.c       | 16 ++++++++--------
 6 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/src/mainboard/amd/parmer/acpi_tables.c 
b/src/mainboard/amd/parmer/acpi_tables.c
index 0cdea2d..550d477 100644
--- a/src/mainboard/amd/parmer/acpi_tables.c
+++ b/src/mainboard/amd/parmer/acpi_tables.c
@@ -155,7 +155,7 @@ unsigned long write_acpi_tables(unsigned long start)
        get_bus_conf(); /* it will get sblk, pci1234, hcdn, and sbdn */
 
        /* Align ACPI tables to 16 bytes */
-       start = (start + 0x0f) & -0x10;
+       start = ALIGN(start, 16);
        current = start;
 
        printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx...\n", start);
@@ -173,7 +173,7 @@ unsigned long write_acpi_tables(unsigned long start)
        acpi_write_rsdt(rsdt);
 
        /* DSDT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * DSDT at %lx\n", current);
        dsdt = (acpi_header_t *)current; /* it will used by fadt */
        memcpy(dsdt, &AmlCode, sizeof(acpi_header_t));
@@ -182,14 +182,14 @@ unsigned long write_acpi_tables(unsigned long start)
        printk(BIOS_DEBUG, "ACPI:    * DSDT @ %p Length 
%x\n",dsdt,dsdt->length);
 
        /* FACS */ /* it needs 64 bit alignment */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI: * FACS at %lx\n", current);
        facs = (acpi_facs_t *) current; /* it will be used by fadt */
        current += sizeof(acpi_facs_t);
        acpi_create_facs(facs);
 
        /* FADT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:  * FADT at %lx\n", current);
        fadt = (acpi_fadt_t *) current;
        current += sizeof(acpi_fadt_t);
@@ -200,7 +200,7 @@ unsigned long write_acpi_tables(unsigned long start)
        /*
         * We explicitly add these tables later on:
         */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:  * HPET at %lx\n", current);
        hpet = (acpi_hpet_t *) current;
        current += sizeof(acpi_hpet_t);
@@ -208,7 +208,7 @@ unsigned long write_acpi_tables(unsigned long start)
        acpi_add_table(rsdp, hpet);
 
        /* If we want to use HPET Timers Linux wants an MADT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:  * MADT at %lx\n",current);
        madt = (acpi_madt_t *) current;
        acpi_create_madt(madt);
@@ -216,13 +216,13 @@ unsigned long write_acpi_tables(unsigned long start)
        acpi_add_table(rsdp, madt);
 
        /* HEST */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        hest = (acpi_hest_t *)current;
        acpi_write_hest((void *)current);
        acpi_add_table(rsdp, (void *)current);
        current += ((acpi_header_t *)current)->length;
 
-       current   = (current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * IVRS at %lx\n", current);
        ivrs = agesawrapper_getlateinitptr(PICK_IVRS);
        if (ivrs != NULL) {
@@ -235,7 +235,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* SRAT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * SRAT at %lx\n", current);
        srat = (acpi_srat_t *) agesawrapper_getlateinitptr (PICK_SRAT);
        if (srat != NULL) {
@@ -248,7 +248,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* SLIT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:   * SLIT at %lx\n", current);
        slit = (acpi_slit_t *) agesawrapper_getlateinitptr (PICK_SLIT);
        if (slit != NULL) {
@@ -261,7 +261,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* ALIB */
-       current = (current + 0x0f) & -0x10;
+       current = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:  * AGESA ALIB SSDT at %lx\n", current);
        alib = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_ALIB);
        if (alib != NULL) {
@@ -276,7 +276,7 @@ unsigned long write_acpi_tables(unsigned long start)
 
        /* this pstate ssdt may cause Blue Screen: Fixed: Keep this comment for 
a while. */
        /* SSDT */
-       current   = ( current + 0x0f) & -0x10;
+       current   = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:    * SSDT at %lx\n", current);
        ssdt = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_PSTATE);
        if (ssdt != NULL) {
diff --git a/src/mainboard/amd/thatcher/acpi_tables.c 
b/src/mainboard/amd/thatcher/acpi_tables.c
index 0cdea2d..550d477 100644
--- a/src/mainboard/amd/thatcher/acpi_tables.c
+++ b/src/mainboard/amd/thatcher/acpi_tables.c
@@ -155,7 +155,7 @@ unsigned long write_acpi_tables(unsigned long start)
        get_bus_conf(); /* it will get sblk, pci1234, hcdn, and sbdn */
 
        /* Align ACPI tables to 16 bytes */
-       start = (start + 0x0f) & -0x10;
+       start = ALIGN(start, 16);
        current = start;
 
        printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx...\n", start);
@@ -173,7 +173,7 @@ unsigned long write_acpi_tables(unsigned long start)
        acpi_write_rsdt(rsdt);
 
        /* DSDT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * DSDT at %lx\n", current);
        dsdt = (acpi_header_t *)current; /* it will used by fadt */
        memcpy(dsdt, &AmlCode, sizeof(acpi_header_t));
@@ -182,14 +182,14 @@ unsigned long write_acpi_tables(unsigned long start)
        printk(BIOS_DEBUG, "ACPI:    * DSDT @ %p Length 
%x\n",dsdt,dsdt->length);
 
        /* FACS */ /* it needs 64 bit alignment */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI: * FACS at %lx\n", current);
        facs = (acpi_facs_t *) current; /* it will be used by fadt */
        current += sizeof(acpi_facs_t);
        acpi_create_facs(facs);
 
        /* FADT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:  * FADT at %lx\n", current);
        fadt = (acpi_fadt_t *) current;
        current += sizeof(acpi_fadt_t);
@@ -200,7 +200,7 @@ unsigned long write_acpi_tables(unsigned long start)
        /*
         * We explicitly add these tables later on:
         */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:  * HPET at %lx\n", current);
        hpet = (acpi_hpet_t *) current;
        current += sizeof(acpi_hpet_t);
@@ -208,7 +208,7 @@ unsigned long write_acpi_tables(unsigned long start)
        acpi_add_table(rsdp, hpet);
 
        /* If we want to use HPET Timers Linux wants an MADT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:  * MADT at %lx\n",current);
        madt = (acpi_madt_t *) current;
        acpi_create_madt(madt);
@@ -216,13 +216,13 @@ unsigned long write_acpi_tables(unsigned long start)
        acpi_add_table(rsdp, madt);
 
        /* HEST */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        hest = (acpi_hest_t *)current;
        acpi_write_hest((void *)current);
        acpi_add_table(rsdp, (void *)current);
        current += ((acpi_header_t *)current)->length;
 
-       current   = (current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * IVRS at %lx\n", current);
        ivrs = agesawrapper_getlateinitptr(PICK_IVRS);
        if (ivrs != NULL) {
@@ -235,7 +235,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* SRAT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * SRAT at %lx\n", current);
        srat = (acpi_srat_t *) agesawrapper_getlateinitptr (PICK_SRAT);
        if (srat != NULL) {
@@ -248,7 +248,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* SLIT */
-       current = (current + 0x07) & -0x08;
+       current = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:   * SLIT at %lx\n", current);
        slit = (acpi_slit_t *) agesawrapper_getlateinitptr (PICK_SLIT);
        if (slit != NULL) {
@@ -261,7 +261,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* ALIB */
-       current = (current + 0x0f) & -0x10;
+       current = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:  * AGESA ALIB SSDT at %lx\n", current);
        alib = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_ALIB);
        if (alib != NULL) {
@@ -276,7 +276,7 @@ unsigned long write_acpi_tables(unsigned long start)
 
        /* this pstate ssdt may cause Blue Screen: Fixed: Keep this comment for 
a while. */
        /* SSDT */
-       current   = ( current + 0x0f) & -0x10;
+       current   = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:    * SSDT at %lx\n", current);
        ssdt = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_PSTATE);
        if (ssdt != NULL) {
diff --git a/src/mainboard/google/butterfly/acpi_tables.c 
b/src/mainboard/google/butterfly/acpi_tables.c
index ca4f949..95b45db 100644
--- a/src/mainboard/google/butterfly/acpi_tables.c
+++ b/src/mainboard/google/butterfly/acpi_tables.c
@@ -130,7 +130,7 @@ unsigned long acpi_fill_srat(unsigned long current)
        return current;
 }
 
-#define ALIGN_CURRENT current = ((current + 0x0f) & -0x10)
+#define ALIGN_CURRENT current = (ALIGN(current, 16))
 unsigned long write_acpi_tables(unsigned long start)
 {
        unsigned long current;
diff --git a/src/mainboard/google/parrot/acpi_tables.c 
b/src/mainboard/google/parrot/acpi_tables.c
index 8308c01..45a9948 100644
--- a/src/mainboard/google/parrot/acpi_tables.c
+++ b/src/mainboard/google/parrot/acpi_tables.c
@@ -127,7 +127,7 @@ unsigned long acpi_fill_srat(unsigned long current)
        return current;
 }
 
-#define ALIGN_CURRENT current = ((current + 0x0f) & -0x10)
+#define ALIGN_CURRENT current = (ALIGN(current, 16))
 unsigned long write_acpi_tables(unsigned long start)
 {
        unsigned long current;
diff --git a/src/mainboard/supermicro/h8scm/acpi_tables.c 
b/src/mainboard/supermicro/h8scm/acpi_tables.c
index 6f10a00..7a1dd58 100644
--- a/src/mainboard/supermicro/h8scm/acpi_tables.c
+++ b/src/mainboard/supermicro/h8scm/acpi_tables.c
@@ -176,7 +176,7 @@ unsigned long write_acpi_tables(unsigned long start)
        get_bus_conf(); /* it will get sblk, pci1234, hcdn, and sbdn */
 
        /* Align ACPI tables to 16 bytes */
-       start = (start + 0x0f) & -0x10;
+       start = ALIGN(start, 16);
        current = start;
 
        printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx...\n", start);
@@ -218,7 +218,7 @@ unsigned long write_acpi_tables(unsigned long start)
         * We explicitly add these tables later on:
         */
 #ifdef UNUSED_CODE // Don't need HPET table. we have one in dsdt
-       current   = ( current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * HPET at %lx\n", current);
        hpet = (acpi_hpet_t *) current;
        current += sizeof(acpi_hpet_t);
@@ -227,7 +227,7 @@ unsigned long write_acpi_tables(unsigned long start)
 #endif
 
        /* If we want to use HPET Timers Linux wants an MADT */
-       current   = ( current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * MADT at %lx\n",current);
        madt = (acpi_madt_t *) current;
        acpi_create_madt(madt);
@@ -235,7 +235,7 @@ unsigned long write_acpi_tables(unsigned long start)
        acpi_add_table(rsdp, madt);
 
        /* SRAT */
-       current   = ( current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * SRAT at %lx\n", current);
        srat = (acpi_srat_t *) agesawrapper_getlateinitptr (PICK_SRAT);
        if (srat != NULL) {
@@ -247,7 +247,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* SLIT */
-       current   = ( current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:   * SLIT at %lx\n", current);
        slit = (acpi_slit_t *) agesawrapper_getlateinitptr (PICK_SLIT);
        if (slit != NULL) {
@@ -259,7 +259,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* SSDT */
-       current  = (current + 0x0f) & -0x10;
+       current  = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:  * AGESA ALIB SSDT at %lx\n", current);
        alib = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_ALIB);
        if (alib != NULL) {
@@ -272,7 +272,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* The DSDT needs additional work for the AGESA SSDT Pstate table */
-       current  = ( current + 0x0f) & -0x10;
+       current  = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:  * AGESA SSDT Pstate at %lx\n", current);
        ssdt = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_PSTATE);
        if (ssdt != NULL) {
@@ -284,7 +284,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
        acpi_add_table(rsdp,ssdt);
 
-       current  = ( current + 0x0f) & -0x10;
+       current  = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:  * coreboot TOM SSDT2 at %lx\n", current);
        ssdt2 = (acpi_header_t *) current;
        acpi_create_ssdt_generator(ssdt2, ACPI_TABLE_CREATOR);
diff --git a/src/mainboard/tyan/s8226/acpi_tables.c 
b/src/mainboard/tyan/s8226/acpi_tables.c
index 3e8f014..4b97844 100644
--- a/src/mainboard/tyan/s8226/acpi_tables.c
+++ b/src/mainboard/tyan/s8226/acpi_tables.c
@@ -176,7 +176,7 @@ unsigned long write_acpi_tables(unsigned long start)
        get_bus_conf(); /* it will get sblk, pci1234, hcdn, and sbdn */
 
        /* Align ACPI tables to 16 bytes */
-       start = (start + 0x0f) & -0x10;
+       start = ALIGN(start, 16);
        current = start;
 
        printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx...\n", start);
@@ -218,7 +218,7 @@ unsigned long write_acpi_tables(unsigned long start)
         * We explicitly add these tables later on:
         */
 #ifdef UNUSED_CODE // Don't need HPET table. we have one in dsdt
-       current   = ( current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * HPET at %lx\n", current);
        hpet = (acpi_hpet_t *) current;
        current += sizeof(acpi_hpet_t);
@@ -227,7 +227,7 @@ unsigned long write_acpi_tables(unsigned long start)
 #endif
 
        /* If we want to use HPET Timers Linux wants an MADT */
-       current   = ( current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * MADT at %lx\n",current);
        madt = (acpi_madt_t *) current;
        acpi_create_madt(madt);
@@ -235,7 +235,7 @@ unsigned long write_acpi_tables(unsigned long start)
        acpi_add_table(rsdp, madt);
 
        /* SRAT */
-       current   = ( current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:    * SRAT at %lx\n", current);
        srat = (acpi_srat_t *) agesawrapper_getlateinitptr (PICK_SRAT);
        if (srat != NULL) {
@@ -247,7 +247,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* SLIT */
-       current   = ( current + 0x07) & -0x08;
+       current   = ALIGN(current, 8);
        printk(BIOS_DEBUG, "ACPI:   * SLIT at %lx\n", current);
        slit = (acpi_slit_t *) agesawrapper_getlateinitptr (PICK_SLIT);
        if (slit != NULL) {
@@ -259,7 +259,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* SSDT */
-       current  = (current + 0x0f) & -0x10;
+       current  = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:  * AGESA ALIB SSDT at %lx\n", current);
        alib = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_ALIB);
        if (alib != NULL) {
@@ -272,7 +272,7 @@ unsigned long write_acpi_tables(unsigned long start)
        }
 
        /* The DSDT needs additional work for the AGESA SSDT Pstate table */
-       current  = ( current + 0x0f) & -0x10;
+       current  = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:  * AGESA SSDT Pstate at %lx\n", current);
        ssdt = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_PSTATE);
        if (ssdt != NULL) {
@@ -284,7 +284,7 @@ unsigned long write_acpi_tables(unsigned long start)
                printk(BIOS_DEBUG, "  AGESA SSDT table NULL. Skipping.\n");
        }
 
-       current  = ( current + 0x0f) & -0x10;
+       current  = ALIGN(current, 16);
        printk(BIOS_DEBUG, "ACPI:  * coreboot TOM SSDT2 at %lx\n", current);
        ssdt2 = (acpi_header_t *) current;
        acpi_create_ssdt_generator(ssdt2, ACPI_TABLE_CREATOR);

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to