The ABI wrapper from r775 made the SHARED definitions obsolete. They're

not that readable anyway, so kill them and use standard definitions
instead.

Introduce EXPORT_SYMBOL for shared symbols. EXPORT_SYMBOL tells the
compiler to use the standard calling conventions for a given symbol and
not to optimize it away.
Benefits:
- We can later use gcc -combine -fwhole-program without problems.
- It's a correctness fix for some optimizations.
- We could check for duplicated exported functions at link time.
- We could check whether exported functions are linked into initram or
stage2 by accident.
- We could generate usage statistics and possibly optimize away unused
shared functions.
- Through the above points, significant side reductions of 10-40%

Build and boot tested on qemu.
Build tested on all targets.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>


git-svn-id: svn://coreboot.org/repository/coreboot-v3@780 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
Carl-Daniel Hailfinger 2008-08-17 21:51:13 +00:00
commit 9342d1be4e
9 changed files with 65 additions and 71 deletions

View file

@ -260,7 +260,7 @@ $(obj)/arch/x86/amd/stage0.o: $(src)/arch/x86/amd/stage0.S
$(obj)/coreboot.initram $(obj)/coreboot.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_SRC)
$(Q)printf " CC $(subst $(shell pwd)/,,$(@)) (XIP)\n"
$(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c -combine $(INITRAM_SRC) -o $(obj)/coreboot.initram_partiallylinked.o
$(Q)$(CC) $(INITCFLAGS) -fPIE -c -combine $(INITRAM_SRC) -o $(obj)/coreboot.initram_partiallylinked.o
$(Q)printf " WRAP $(subst $(shell pwd)/,,$(@)) (PIC->non-PIC)\n"
$(Q)$(NM) --undefined-only $(obj)/coreboot.initram_partiallylinked.o |\
grep -v _GLOBAL_OFFSET_TABLE_ | grep " U " | sed "s/^ *U //" |\

View file

@ -201,8 +201,10 @@ static inline __attribute__((always_inline)) void hlt(void)
__asm__ __volatile__("hlt" : : : "memory");
}
SHARED(bottom_of_stack, void *, void);
SHARED(global_vars, struct global_vars *, void);
void * bottom_of_stack(void);
EXPORT_SYMBOL(bottom_of_stack);
struct global_vars * global_vars(void);
EXPORT_SYMBOL(global_vars);
#ifdef CONFIG_CONSOLE_BUFFER
#define PRINTK_BUF_SIZE_CAR (CONFIG_CARSIZE / 2)
@ -251,9 +253,11 @@ struct rmap {
};
};
SHARED(setup_resource_map_x_offset, void, const struct rmap *rm, u32 max,
void setup_resource_map_x_offset(const struct rmap *rm, u32 max,
u32 offset_dev, u32 offset_pciio,
u32 offset_io);
SHARED(setup_resource_map, void, const struct rmap *rm, u32 max);
EXPORT_SYMBOL(setup_resource_map_x_offset);
void setup_resource_map(const struct rmap *rm, u32 max);
EXPORT_SYMBOL(setup_resource_map);
#endif /* ARCH_X86_CPU_H */

View file

@ -71,10 +71,13 @@ struct global_vars {
#endif
};
SHARED_WITH_ATTRIBUTES(printk, int, __attribute__((format (printf, 2, 3))),
int msg_level, const char *fmt, ...);
SHARED(banner, void, int msg_level, const char *msg);
SHARED(dump_mem_range, void, int msg_level, unsigned char *buf, int size);
SHARED(die, void, const char *msg);
int printk(int msg_level, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
EXPORT_SYMBOL(printk);
void banner(int msg_level, const char *msg);
EXPORT_SYMBOL(banner);
void dump_mem_range(int msg_level, unsigned char *buf, int size);
EXPORT_SYMBOL(dump_mem_range);
void die(const char *msg);
EXPORT_SYMBOL(die);
#endif /* CONSOLE_H */

View file

@ -30,13 +30,21 @@ void pci_write_config8(struct device * dev, unsigned where, u8 val);
void pci_write_config16(struct device * dev, unsigned where, u16 val);
void pci_write_config32(struct device * dev, unsigned where, u32 val);
SHARED(pci_conf1_read_config8, u8, u32 bdf, int where);
SHARED(pci_conf1_read_config16, u16, u32 bdf, int where);
SHARED(pci_conf1_read_config32, u32, u32 bdf, int where);
SHARED(pci_conf1_write_config8, void , u32 bdf, int where, u8 value);
SHARED(pci_conf1_write_config16, void, u32 bdf, int where, u16 value);
SHARED(pci_conf1_write_config32, void, u32 bdf, int where, u32 value);
SHARED(pci_conf1_find_on_bus, int, u16 bus, u16 vid, u16 did, u32 *busdevfn);
SHARED(pci_conf1_find_device, int, u16 vid, u16 did, u32 * dev);
u8 pci_conf1_read_config8(u32 bdf, int where);
EXPORT_SYMBOL(pci_conf1_read_config8);
u16 pci_conf1_read_config16(u32 bdf, int where);
EXPORT_SYMBOL(pci_conf1_read_config16);
u32 pci_conf1_read_config32(u32 bdf, int where);
EXPORT_SYMBOL(pci_conf1_read_config32);
void pci_conf1_write_config8(u32 bdf, int where, u8 value);
EXPORT_SYMBOL(pci_conf1_write_config8);
void pci_conf1_write_config16(u32 bdf, int where, u16 value);
EXPORT_SYMBOL(pci_conf1_write_config16);
void pci_conf1_write_config32(u32 bdf, int where, u32 value);
EXPORT_SYMBOL(pci_conf1_write_config32);
int pci_conf1_find_on_bus(u16 bus, u16 vid, u16 did, u32 *busdevfn);
EXPORT_SYMBOL(pci_conf1_find_on_bus);
int pci_conf1_find_device(u16 vid, u16 did, u32 * dev);
EXPORT_SYMBOL(pci_conf1_find_device);
#endif /* DEVICE_PCI_OPS_H */

View file

@ -94,14 +94,23 @@ struct mem_file {
/* Prototypes. */
/* architecture-defined */
SHARED(init_archive, void, struct mem_file *);
void init_archive(struct mem_file *);
EXPORT_SYMBOL(init_archive);
/* architecture-independent */
SHARED(find_file, int, const struct mem_file *archive, const char *filename, struct mem_file *result);
SHARED(copy_file, int, const struct mem_file *archive, const char *filename, void *where);
SHARED(run_file, int, const struct mem_file *archive, const char *filename, void *where);
SHARED(execute_in_place, int, const struct mem_file *archive, const char *filename);
SHARED(run_address, int, void *f);
SHARED(load_file, void *, const struct mem_file *archive, const char *filename);
SHARED(load_file_segments, void *, const struct mem_file *archive, const char *filename);
SHARED(process_file, int, const struct mem_file *archive, void *where);
int find_file(const struct mem_file *archive, const char *filename, struct mem_file *result);
EXPORT_SYMBOL(find_file);
int copy_file(const struct mem_file *archive, const char *filename, void *where);
EXPORT_SYMBOL(copy_file);
int run_file(const struct mem_file *archive, const char *filename, void *where);
EXPORT_SYMBOL(run_file);
int execute_in_place(const struct mem_file *archive, const char *filename);
EXPORT_SYMBOL(execute_in_place);
int run_address(void *f);
EXPORT_SYMBOL(run_address);
void * load_file(const struct mem_file *archive, const char *filename);
EXPORT_SYMBOL(load_file);
void * load_file_segments(const struct mem_file *archive, const char *filename);
EXPORT_SYMBOL(load_file_segments);
int process_file(const struct mem_file *archive, void *where);
EXPORT_SYMBOL(process_file);
#endif /* LAR_H */

View file

@ -122,7 +122,8 @@ int get_option(void *dest, char *name);
#else
#include <shared.h>
SHARED(get_option, int, void *dest, char *name);
int get_option(void *dest, char *name);
EXPORT_SYMBOL(get_option);
#endif
void rtc_init(int invalid);
int last_boot_normal(void);

View file

@ -24,7 +24,8 @@
#include <types.h>
#include <shared.h>
SHARED(post_code, void, u8 value);
void post_code(u8 value);
EXPORT_SYMBOL(post_code);
/* This is a collection of existing POST values used by post_code().
* port80_post() and Geode specific codes are not (yet?) listed here.

View file

@ -1,8 +1,7 @@
/*
* This file is part of the coreboot project
*
* Copyright(C) 2007 coresystems GmbH
* Written by Stefan Reinauer <stepan@coresystems.de>
* Copyright(C) 2008 Carl-Daniel Hailfinger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,41 +21,6 @@
#ifndef SHARED_H
#define SHARED_H
#define FUNC(func, ret, attr, args...) \
ret func(args) attr
#define EXTERN(func, ret, attr, args...)
/**
* Use the SHARED macro to create a universally usable function
* prototype. This will create a function prototype in stage 0 and
* a function prototype plus a function pointer for all code compiled
* with _SHARED defined (required for XIP code)
*
* @func function name
* @ret return value
* @args function arguments
*/
#define SHARED(func,ret,args...) \
FUNC(func,ret,,##args); \
EXTERN(func,ret,,##args)
/**
* Use the SHARED_WITH_ATTRIBUTES macro to create a universally usable function
* prototype for a function using GCC attributes.
* This macro works identically to SHARED(), but it adds a GCC attribute to the
* function. So far we use this to have printk parameters tested with a
* "format" attribute.
*
* @func function name
* @ret return value
* @attr function attributes
* @args function arguments
*/
#define SHARED_WITH_ATTRIBUTES(func,ret,attr,args...) \
FUNC(func,ret,attr,##args); \
EXTERN(func,ret,attr,##args)
#define EXPORT_SYMBOL(sym) extern typeof(sym) sym __attribute__((externally_visible,used))
#endif /* SHARED_H */

View file

@ -31,10 +31,14 @@ int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, int maxlen);
/* lib/mem.c */
SHARED(memcpy, void *, void *dest, const void *src, size_t len);
SHARED(memmove, void *, void *dest, const void *src, size_t len);
SHARED(memset, void *, void *s, int c, size_t len);
SHARED(memcmp, int , const void *s1, const void *s2, size_t len);
void * memcpy(void *dest, const void *src, size_t len);
EXPORT_SYMBOL(memcpy);
void * memmove(void *dest, const void *src, size_t len);
EXPORT_SYMBOL(memmove);
void * memset(void *s, int c, size_t len);
EXPORT_SYMBOL(memset);
int memcmp(const void *s1, const void *s2, size_t len);
EXPORT_SYMBOL(memcmp);
/* console/vsprintf.c */
int sprintf(char *buf, const char *fmt, ...);