Message ID | 20201123131651.33032-17-ovidiu.panait@windriver.com |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show |
Series | Minor board_f/board_r cleanups | expand |
Am Montag, den 23.11.2020, 15:16 +0200 schrieb Ovidiu Panait: > In order to remove the arch-specific ifdefs around initr_trap, introduce > arch_initr_trap weak initcall. Implementations for ppc/m68k/mips have > been moved to arch/<arch>/lib/traps.c > > Default implementation is a nop stub. > > Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> > Reviewed-by: Simon Glass <sjg@chromium.org> > --- > v3 updates: > - none > > v2 updates: > - add reviewed-by tag > > arch/m68k/lib/traps.c | 7 +++++++ > arch/mips/lib/traps.c | 7 +++++++ > arch/powerpc/lib/Makefile | 1 + > arch/powerpc/lib/traps.c | 17 +++++++++++++++++ > common/board_r.c | 16 ++-------------- > include/init.h | 9 +++++++++ > 6 files changed, 43 insertions(+), 14 deletions(-) > create mode 100644 arch/powerpc/lib/traps.c > > diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c > index c49141f376..a9b055cedf 100644 > --- a/arch/m68k/lib/traps.c > +++ b/arch/m68k/lib/traps.c > @@ -59,3 +59,10 @@ void trap_init(ulong value) { > > setvbr(value); /* set vector base register to new table */ > } > + > +int arch_initr_trap(void) > +{ > + trap_init(CONFIG_SYS_SDRAM_BASE); > + > + return 0; > +} > diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c > index df8b63f383..4f2efd6115 100644 > --- a/arch/mips/lib/traps.c > +++ b/arch/mips/lib/traps.c > @@ -131,3 +131,10 @@ void trap_restore(void) > clear_c0_status(ST0_BEV); > execution_hazard_barrier(); > } > + > +int arch_initr_trap(void) > +{ > + trap_init(CONFIG_SYS_SDRAM_BASE); > + > + return 0; > +} > diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile > index f61809ab05..2782740bf5 100644 > --- a/arch/powerpc/lib/Makefile > +++ b/arch/powerpc/lib/Makefile > @@ -40,6 +40,7 @@ obj-y += interrupts.o > obj-$(CONFIG_CMD_KGDB) += kgdb.o > obj-y += stack.o > obj-y += time.o > +obj-y += traps.o > endif # not minimal > > ifdef CONFIG_SPL_BUILD > diff --git a/arch/powerpc/lib/traps.c b/arch/powerpc/lib/traps.c > new file mode 100644 > index 0000000000..80822a006a > --- /dev/null > +++ b/arch/powerpc/lib/traps.c > @@ -0,0 +1,17 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * (C) Copyright 2003 > + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. > + */ > + > +#include <common.h> > +#include <init.h> > + > +DECLARE_GLOBAL_DATA_PTR; > + > +int arch_initr_trap(void) > +{ > + trap_init(gd->relocaddr); > + > + return 0; > +} > diff --git a/common/board_r.c b/common/board_r.c > index c083eb0a03..9fa4d4b42e 100644 > --- a/common/board_r.c > +++ b/common/board_r.c > @@ -182,20 +182,10 @@ static int initr_reloc_global_data(void) > return 0; > } > > -#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS) > -static int initr_trap(void) > +__weak int arch_initr_trap(void) > { > - /* > - * Setup trap handlers > - */ > -#if defined(CONFIG_PPC) > - trap_init(gd->relocaddr); > -#else > - trap_init(CONFIG_SYS_SDRAM_BASE); > -#endif > return 0; > } > -#endif > > #ifdef CONFIG_ADDR_MAP > static int initr_addr_map(void) > @@ -669,9 +659,7 @@ static init_fnc_t init_sequence_r[] = { > #ifdef CONFIG_NEEDS_MANUAL_RELOC > initr_manual_reloc_cmdtable, > #endif > -#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS) > - initr_trap, > -#endif > + arch_initr_trap, > #ifdef CONFIG_ADDR_MAP > initr_addr_map, > #endif > diff --git a/include/init.h b/include/init.h > index dded1cb871..bc1854f0e5 100644 > --- a/include/init.h > +++ b/include/init.h > @@ -300,6 +300,15 @@ int board_early_init_r(void); > /* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */ > void pci_init_board(void); > > +/** > + * arch_initr_trap() - Init traps > + * > + * Arch specific routine for initializing traps. It is called during the > + * generic board init sequence, after relocation. > + * > + * Return: 0 if OK > + */ > +int arch_initr_trap(void); > void trap_init(unsigned long reloc_addr); I suggest to drop the trap_init() declaration and make all arch- specific implementations static. This way the compiler can optimize away the trap_init() symbol and directly generate all code in arch_initr_trap(). Also you're replacing the public interface trap_init() with arch_initr_trap() so there is no need to keep the old interface. > > /**
diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c index c49141f376..a9b055cedf 100644 --- a/arch/m68k/lib/traps.c +++ b/arch/m68k/lib/traps.c @@ -59,3 +59,10 @@ void trap_init(ulong value) { setvbr(value); /* set vector base register to new table */ } + +int arch_initr_trap(void) +{ + trap_init(CONFIG_SYS_SDRAM_BASE); + + return 0; +} diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c index df8b63f383..4f2efd6115 100644 --- a/arch/mips/lib/traps.c +++ b/arch/mips/lib/traps.c @@ -131,3 +131,10 @@ void trap_restore(void) clear_c0_status(ST0_BEV); execution_hazard_barrier(); } + +int arch_initr_trap(void) +{ + trap_init(CONFIG_SYS_SDRAM_BASE); + + return 0; +} diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index f61809ab05..2782740bf5 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@ -40,6 +40,7 @@ obj-y += interrupts.o obj-$(CONFIG_CMD_KGDB) += kgdb.o obj-y += stack.o obj-y += time.o +obj-y += traps.o endif # not minimal ifdef CONFIG_SPL_BUILD diff --git a/arch/powerpc/lib/traps.c b/arch/powerpc/lib/traps.c new file mode 100644 index 0000000000..80822a006a --- /dev/null +++ b/arch/powerpc/lib/traps.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2003 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#include <common.h> +#include <init.h> + +DECLARE_GLOBAL_DATA_PTR; + +int arch_initr_trap(void) +{ + trap_init(gd->relocaddr); + + return 0; +} diff --git a/common/board_r.c b/common/board_r.c index c083eb0a03..9fa4d4b42e 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -182,20 +182,10 @@ static int initr_reloc_global_data(void) return 0; } -#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS) -static int initr_trap(void) +__weak int arch_initr_trap(void) { - /* - * Setup trap handlers - */ -#if defined(CONFIG_PPC) - trap_init(gd->relocaddr); -#else - trap_init(CONFIG_SYS_SDRAM_BASE); -#endif return 0; } -#endif #ifdef CONFIG_ADDR_MAP static int initr_addr_map(void) @@ -669,9 +659,7 @@ static init_fnc_t init_sequence_r[] = { #ifdef CONFIG_NEEDS_MANUAL_RELOC initr_manual_reloc_cmdtable, #endif -#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS) - initr_trap, -#endif + arch_initr_trap, #ifdef CONFIG_ADDR_MAP initr_addr_map, #endif diff --git a/include/init.h b/include/init.h index dded1cb871..bc1854f0e5 100644 --- a/include/init.h +++ b/include/init.h @@ -300,6 +300,15 @@ int board_early_init_r(void); /* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */ void pci_init_board(void); +/** + * arch_initr_trap() - Init traps + * + * Arch specific routine for initializing traps. It is called during the + * generic board init sequence, after relocation. + * + * Return: 0 if OK + */ +int arch_initr_trap(void); void trap_init(unsigned long reloc_addr); /**