aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2009-07-04 13:46:33 -0400
committerKevin O'Connor <kevin@koconnor.net>2009-07-04 13:46:33 -0400
commit523e5a995e1502deebd94efba44a1b5cb0007794 (patch)
treec3fdb8f37722b1737c4a83ea02f7a5542549410e
parentd282af77b61af2172608b893a7a31fb686ec4643 (diff)
downloadseabios-523e5a995e1502deebd94efba44a1b5cb0007794.tar.gz
Use "p->sum -= checksum()" style for setting checksums.
Some code cleared the original checksum and then calculated a new one, others manipulated the checksum range to not include the old checksum. However, this was error prone - use the "-=" syntax consistently to reduce possible errors.
-rw-r--r--src/acpi.c4
-rw-r--r--src/ata.c3
-rw-r--r--src/coreboot.c3
-rw-r--r--src/mptable.c4
-rw-r--r--src/pirtable.c2
-rw-r--r--src/pnpbios.c2
-rw-r--r--src/post.c2
-rw-r--r--src/smbios.c7
8 files changed, 11 insertions, 16 deletions
diff --git a/src/acpi.c b/src/acpi.c
index f140f1ac..72977b12 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -236,7 +236,7 @@ static void acpi_build_table_header(struct acpi_table_header *h,
memcpy(h->oem_table_id + 4, (void*)&sig, 4);
h->oem_revision = cpu_to_le32(1);
h->asl_compiler_revision = cpu_to_le32(1);
- h->checksum = -checksum(h, len);
+ h->checksum -= checksum(h, len);
}
#define SSDT_SIGNATURE 0x54445353// SSDT
@@ -369,7 +369,7 @@ void acpi_bios_init(void)
rsdp->signature = RSDP_SIGNATURE;
memcpy(rsdp->oem_id, CONFIG_APPNAME6, 6);
rsdp->rsdt_physical_address = cpu_to_le32(rsdt_addr);
- rsdp->checksum = -checksum(rsdp, 20);
+ rsdp->checksum -= checksum(rsdp, 20);
RsdpAddr = rsdp;
/* RSDT */
diff --git a/src/ata.c b/src/ata.c
index 3b609c5b..699eecd4 100644
--- a/src/ata.c
+++ b/src/ata.c
@@ -951,8 +951,7 @@ fill_fdpt(int driveid)
fdpt->a0h_signature = 0xa0;
// Checksum structure.
- u8 sum = checksum(fdpt, sizeof(*fdpt)-1);
- fdpt->checksum = -sum;
+ fdpt->checksum -= checksum(fdpt, sizeof(*fdpt));
}
// Map a drive (that was registered via add_bcv_hd)
diff --git a/src/coreboot.c b/src/coreboot.c
index 859928f9..b8479c5b 100644
--- a/src/coreboot.c
+++ b/src/coreboot.c
@@ -62,8 +62,7 @@ copy_mptable(void *pos)
memcpy((void*)bios_table_cur_addr, pos, length);
struct mptable_floating_s *newp = (void*)bios_table_cur_addr;
newp->physaddr = bios_table_cur_addr + length;
- newp->checksum = 0;
- newp->checksum = -checksum(newp, sizeof(*newp));
+ newp->checksum -= checksum(newp, sizeof(*newp));
memcpy((void*)bios_table_cur_addr + length, (void*)p->physaddr, mpclength);
bios_table_cur_addr += length + mpclength;
}
diff --git a/src/mptable.c b/src/mptable.c
index 47aee24b..e81bd62c 100644
--- a/src/mptable.c
+++ b/src/mptable.c
@@ -44,7 +44,7 @@ mptable_init(void)
floating->physaddr = (u32)config;
floating->length = 1;
floating->spec_rev = 4;
- floating->checksum = -checksum(floating, sizeof(*floating));
+ floating->checksum -= checksum(floating, sizeof(*floating));
// Config structure.
memset(config, 0, sizeof(*config));
@@ -106,7 +106,7 @@ mptable_init(void)
}
// Set checksum.
- config->checksum = -checksum(config, config->length);
+ config->checksum -= checksum(config, config->length);
dprintf(1, "MP table addr=0x%x MPC table addr=0x%x size=0x%x\n",
(u32)floating, (u32)config, length);
diff --git a/src/pirtable.c b/src/pirtable.c
index a96ffbc6..a83d4f7e 100644
--- a/src/pirtable.c
+++ b/src/pirtable.c
@@ -100,6 +100,6 @@ create_pirtable()
dprintf(3, "init PIR table\n");
PIR_TABLE.pir.signature = PIR_SIGNATURE;
- PIR_TABLE.pir.checksum = -checksum(&PIR_TABLE, sizeof(PIR_TABLE));
+ PIR_TABLE.pir.checksum -= checksum(&PIR_TABLE, sizeof(PIR_TABLE));
PirOffset = (u32)&PIR_TABLE.pir - BUILD_BIOS_ADDR;
}
diff --git a/src/pnpbios.c b/src/pnpbios.c
index cf78f007..7d9ece50 100644
--- a/src/pnpbios.c
+++ b/src/pnpbios.c
@@ -99,5 +99,5 @@ pnp_setup()
PNPHEADER.real_ip = (u32)entry_pnp_real - BUILD_BIOS_ADDR;
PNPHEADER.prot_ip = (u32)entry_pnp_prot - BUILD_BIOS_ADDR;
- PNPHEADER.checksum = -checksum(&PNPHEADER, sizeof(PNPHEADER));
+ PNPHEADER.checksum -= checksum(&PNPHEADER, sizeof(PNPHEADER));
}
diff --git a/src/post.c b/src/post.c
index 638f95a8..b0189356 100644
--- a/src/post.c
+++ b/src/post.c
@@ -209,7 +209,7 @@ _start()
boot_prep();
// Setup bios checksum.
- BiosChecksum = -checksum((u8*)BUILD_BIOS_ADDR, BUILD_BIOS_SIZE - 1);
+ BiosChecksum -= checksum((u8*)BUILD_BIOS_ADDR, BUILD_BIOS_SIZE);
// Prep for boot process.
make_bios_readonly();
diff --git a/src/smbios.c b/src/smbios.c
index 40812e3b..e9a4b31b 100644
--- a/src/smbios.c
+++ b/src/smbios.c
@@ -244,12 +244,9 @@ smbios_entry_point_init(void *start,
ep->number_of_structures = number_of_structures;
ep->smbios_bcd_revision = 0x24;
- ep->checksum = 0;
- ep->intermediate_checksum = 0;
+ ep->checksum -= checksum(start, 0x10);
- ep->checksum = -checksum(start, 0x10);
-
- ep->intermediate_checksum = -checksum(start + 0x10, ep->length - 0x10);
+ ep->intermediate_checksum -= checksum(start + 0x10, ep->length - 0x10);
}
/* Type 0 -- BIOS Information */