Author: afaerber Date: Sat Nov 13 14:04:34 2010 New Revision: 954 URL: http://tracker.coreboot.org/trac/openbios/changeset/954
Log: Introduce forth_init() for trampoline initialization
Use init_trampoline() for trampoline variable initialization.
Add calls to a new forth_init() function for each architecture to invoke it. Idea courtesy of Blue.
This fixes ppc64 compilation by avoiding a casted self-reference.
v2: * Share init_trampoline() with kernel/bootstrap.c, suggested by Mark. * Adopt QEMU coding style for new functions.
Cc: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk Signed-off-by: Andreas Färber andreas.faerber@web.de Acked-by: Blue Swirl blauwirbel@gmail.com
Modified: trunk/openbios-devel/arch/amd64/openbios.c trunk/openbios-devel/arch/ppc/kernel.c trunk/openbios-devel/arch/ppc/qemu/kernel.c trunk/openbios-devel/arch/sparc32/openbios.c trunk/openbios-devel/arch/sparc64/openbios.c trunk/openbios-devel/arch/unix/unix.c trunk/openbios-devel/arch/x86/openbios.c trunk/openbios-devel/include/kernel/kernel.h trunk/openbios-devel/kernel/bootstrap.c trunk/openbios-devel/kernel/internal.c
Modified: trunk/openbios-devel/arch/amd64/openbios.c ============================================================================== --- trunk/openbios-devel/arch/amd64/openbios.c Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/arch/amd64/openbios.c Sat Nov 13 14:04:34 2010 (r954) @@ -67,6 +67,7 @@
load_dictionary((char *)sys_info.dict_start, sys_info.dict_end-sys_info.dict_start); + forth_init();
relocate(&sys_info);
Modified: trunk/openbios-devel/arch/ppc/kernel.c ============================================================================== --- trunk/openbios-devel/arch/ppc/kernel.c Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/arch/ppc/kernel.c Sat Nov 13 14:04:34 2010 (r954) @@ -83,6 +83,7 @@ { dict = malloc(DICTIONARY_SIZE); load_dictionary( forth_dictionary, sizeof(forth_dictionary) ); + forth_init();
PUSH_xt( bind_noname_func(arch_of_init) ); fword("PREPOST-initializer");
Modified: trunk/openbios-devel/arch/ppc/qemu/kernel.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/kernel.c Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/arch/ppc/qemu/kernel.c Sat Nov 13 14:04:34 2010 (r954) @@ -86,6 +86,7 @@ dictlimit = DICTIONARY_SIZE;
load_dictionary( forth_dictionary, sizeof(forth_dictionary) ); + forth_init();
PUSH_xt( bind_noname_func(arch_of_init) ); fword("PREPOST-initializer");
Modified: trunk/openbios-devel/arch/sparc32/openbios.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/openbios.c Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/arch/sparc32/openbios.c Sat Nov 13 14:04:34 2010 (r954) @@ -970,6 +970,7 @@ load_dictionary((char *)sys_info.dict_start, (unsigned long)sys_info.dict_end - (unsigned long)sys_info.dict_start); + forth_init();
#ifdef CONFIG_DEBUG_BOOT printk("forth started.\n");
Modified: trunk/openbios-devel/arch/sparc64/openbios.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/openbios.c Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/arch/sparc64/openbios.c Sat Nov 13 14:04:34 2010 (r954) @@ -623,6 +623,7 @@ load_dictionary((char *)sys_info.dict_start, (unsigned long)sys_info.dict_end - (unsigned long)sys_info.dict_start); + forth_init();
#ifdef CONFIG_DEBUG_BOOT printk("forth started.\n");
Modified: trunk/openbios-devel/arch/unix/unix.c ============================================================================== --- trunk/openbios-devel/arch/unix/unix.c Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/arch/unix/unix.c Sat Nov 13 14:04:34 2010 (r954) @@ -516,6 +516,7 @@ printk("done.\n");
read_dictionary(argv[optind]); + forth_init();
PUSH_xt( bind_noname_func(arch_init) ); fword("PREPOST-initializer");
Modified: trunk/openbios-devel/arch/x86/openbios.c ============================================================================== --- trunk/openbios-devel/arch/x86/openbios.c Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/arch/x86/openbios.c Sat Nov 13 14:04:34 2010 (r954) @@ -90,6 +90,7 @@ load_dictionary((char *)sys_info.dict_start, (unsigned long)sys_info.dict_end - (unsigned long)sys_info.dict_start); + forth_init();
relocate(&sys_info);
Modified: trunk/openbios-devel/include/kernel/kernel.h ============================================================================== --- trunk/openbios-devel/include/kernel/kernel.h Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/include/kernel/kernel.h Sat Nov 13 14:04:34 2010 (r954) @@ -32,6 +32,8 @@
extern xt_t findword(const char *s1); extern void modules_init( void ); +extern void init_trampoline(ucell *t); +extern void forth_init(void);
/* arch kernel hooks */ extern void exception(cell no);
Modified: trunk/openbios-devel/kernel/bootstrap.c ============================================================================== --- trunk/openbios-devel/kernel/bootstrap.c Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/kernel/bootstrap.c Sat Nov 13 14:04:34 2010 (r954) @@ -91,20 +91,6 @@ "$include", "$encode-file", "(debug", "(debug-off)" };
-static void init_trampoline(void) -{ - if (!trampoline) { - /* We're using side effects which is to some extent nasty */ - printf("WARNING: no trampoline!\n"); - return; - } - - trampoline[0]=DOCOL; - trampoline[1]=0; - trampoline[2]=target_ucell(pointer2cell(trampoline)+3*sizeof(ucell)); - trampoline[3]=0; -} - /* * dictionary related functions. */ @@ -1180,7 +1166,12 @@ TRAMPOLINE_SIZE); #endif
- init_trampoline(); + if (trampoline == NULL) { + /* We're using side effects which is to some extent nasty */ + printf("WARNING: no trampoline!\n"); + } else { + init_trampoline(trampoline); + }
if (!segfault) { if (verbose)
Modified: trunk/openbios-devel/kernel/internal.c ============================================================================== --- trunk/openbios-devel/kernel/internal.c Sat Nov 13 11:56:45 2010 (r953) +++ trunk/openbios-devel/kernel/internal.c Sat Nov 13 14:04:34 2010 (r954) @@ -50,8 +50,13 @@ /* instead of pointing to an explicit 0 variable we * point behind the pointer. */ -static ucell t[] = { DOCOL, 0, (ucell)(t+3), 0 }; +static ucell t[] = { 0, 0, 0, 0 }; static ucell *trampoline = t; + +void forth_init(void) +{ + init_trampoline(trampoline); +} #endif
#ifndef CONFIG_DEBUG_INTERPRETER @@ -67,6 +72,15 @@ #endif
+void init_trampoline(ucell *tramp) +{ + tramp[0] = DOCOL; + tramp[1] = 0; + tramp[2] = target_ucell(pointer2cell(tramp) + 3 * sizeof(ucell)); + tramp[3] = 0; +} + + static inline void processxt(ucell xt) { void (*tokenp) (void);