From b0a9c5ccf31514630755e9a5d15204a55a47740f Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Fri, 7 Oct 2011 23:01:55 +0200 Subject: mptable: Refactor mptable generation some more The last couple of lines of every mptable function were mostly identical. Refactor into common code, a new function mptable_finalize. Coccinelle script: @@ identifier mc; @@ ( -mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); -mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); -printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", mc, smp_next_mpe_entry(mc)); -return smp_next_mpe_entry(mc); +return mptable_finalize(mc); | -mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); -mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); -return smp_next_mpe_entry(mc); +return mptable_finalize(mc); ) Change-Id: Ib2270d800bdd486c5eb49b328544d36bd2298c9e Signed-off-by: Patrick Georgi Reviewed-on: http://review.coreboot.org/246 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones --- src/arch/x86/boot/mpspec.c | 9 ++++++++- src/arch/x86/include/arch/smp/mpspec.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/boot/mpspec.c b/src/arch/x86/boot/mpspec.c index 604f1918e2..209e0bbdbd 100644 --- a/src/arch/x86/boot/mpspec.c +++ b/src/arch/x86/boot/mpspec.c @@ -40,7 +40,7 @@ void mptable_init(struct mp_config_table *mc, u32 lapic_addr) mc->mpc_productid[i] = ' '; } -unsigned char smp_compute_checksum(void *v, int len) +static unsigned char smp_compute_checksum(void *v, int len) { unsigned char *bytes; unsigned char checksum; @@ -396,3 +396,10 @@ void mptable_write_buses(struct mp_config_table *mc, int *max_pci_bus, int *isa_ smp_write_bus(mc, *isa_bus, "ISA "); } +void *mptable_finalize(struct mp_config_table *mc) +{ + mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length); + mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length); + printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n", mc, smp_next_mpe_entry(mc)); + return smp_next_mpe_entry(mc); +} diff --git a/src/arch/x86/include/arch/smp/mpspec.h b/src/arch/x86/include/arch/smp/mpspec.h index e9a20c387f..2eb18138a6 100644 --- a/src/arch/x86/include/arch/smp/mpspec.h +++ b/src/arch/x86/include/arch/smp/mpspec.h @@ -267,13 +267,13 @@ void smp_write_bus_hierarchy(struct mp_config_table *mc, void smp_write_compatibility_address_space(struct mp_config_table *mc, unsigned char busid, unsigned char address_modifier, unsigned int range_list); -unsigned char smp_compute_checksum(void *v, int len); void *smp_write_floating_table(unsigned long addr, unsigned int virtualwire); unsigned long write_smp_table(unsigned long addr); void mptable_lintsrc(struct mp_config_table *mc, unsigned long bus_isa); void mptable_add_isa_interrupts(struct mp_config_table *mc, unsigned long bus_isa, unsigned long apicid, int external); void mptable_write_buses(struct mp_config_table *mc, int *max_pci_bus, int *isa_bus); +void *mptable_finalize(struct mp_config_table *mc); #endif -- cgit v1.2.3