[LinuxBIOS] [PATCH] v3: duplicate less code

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Wed Nov 21 15:39:17 CET 2007


Hi,

some time ago, we decided that stage2 should share code with stage0
whenever possible. I have investigated the current situation and we
could do much better.
Example analysis for the qemu target in its current revision follows:

Shared functions/symbols:
die
gdt_limit
gdtptr
get_option_table
post_code
printk
rtc_init
sprintf

Duplicated functions:
size    name
0000001a delay
0000001a mdelay
0000000e udelay
00000027 memcmp
0000000f memcpy
000000d6 memcpy_helper
00000021 memmove
00000013 memset
00000007 rawpnp_enter_ext_func_mode
00000006 rawpnp_exit_ext_func_mode
00000015 rawpnp_set_enable
00000029 rawpnp_set_iobase
00000012 rawpnp_set_logical_device
0000000e rawpnp_write_config

We waste a total of 493 bytes.

Patch for *delay and mem* functions follows, saving 386 bytes.

Regards,
Carl-Daniel

To reduce code duplication, make sure STAGE2_*OBJ does not contain
any object already mentioned in STAGE0_*_OBJ.
Specifically, remove mem.o, delay.o, udelay_io.o from STAGE2_*OBJ.
This saves 386 bytes in stage2 (~240 bytes after LZMA compression).

In the future, automatically removing objects from STAGE2_OBJ which
are already included in STAGE0_OBJ will be the way to go.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

--- 
Index: LinuxBIOSv3/arch/x86/Makefile
===================================================================
--- LinuxBIOSv3/arch/x86/Makefile	(revision 512)
+++ LinuxBIOSv3/arch/x86/Makefile	(working copy)
@@ -167,11 +167,13 @@
 # Where should it be built, maybe in device/?
 #
 # TODO: This should be compressed with the default compressor.
+# To reduce code duplication, always make sure STAGE2_LIB_OBJ does not contain
+# any object already mentioned in STAGE0_LIB_OBJ.
 #
 
-STAGE2_LIB_OBJ       = stage2.o clog2.o mem.o tables.o delay.o compute_ip_checksum.o
+STAGE2_LIB_OBJ       = stage2.o clog2.o tables.o compute_ip_checksum.o
 
-STAGE2_ARCH_X86_OBJ  = archtables.o linuxbios_table.o udelay_io.o
+STAGE2_ARCH_X86_OBJ  = archtables.o linuxbios_table.o
 STAGE2_ARCH_X86_OBJ += pci_ops_auto.o pci_ops_conf1.o pci_ops_conf2.o
 STAGE2_ARCH_X86_OBJ += keyboard.o i8259.o isa-dma.o
 







More information about the coreboot mailing list