Move trampoline variable initialization to init_trampoline(), like in kernel/bootstrap.c.
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.
Cc: Blue Swirl blauwirbel@gmail.com Signed-off-by: Andreas Färber andreas.faerber@web.de --- Tested this on ppc, sparc32, sparc64 - OpenBIOS still boots up. forth_init() placement in internal.c may not be perfect but it fits its current purpose...
arch/amd64/openbios.c | 1 + arch/ppc/kernel.c | 1 + arch/ppc/qemu/kernel.c | 1 + arch/sparc32/openbios.c | 1 + arch/sparc64/openbios.c | 1 + arch/unix/unix.c | 1 + arch/x86/openbios.c | 1 + include/kernel/kernel.h | 1 + kernel/internal.c | 15 ++++++++++++++- 9 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/arch/amd64/openbios.c b/arch/amd64/openbios.c index df43943..db138ad 100644 --- a/arch/amd64/openbios.c +++ b/arch/amd64/openbios.c @@ -67,6 +67,7 @@ int openbios(void)
load_dictionary((char *)sys_info.dict_start, sys_info.dict_end-sys_info.dict_start); + forth_init();
relocate(&sys_info);
diff --git a/arch/ppc/kernel.c b/arch/ppc/kernel.c index 57efde7..28f2965 100644 --- a/arch/ppc/kernel.c +++ b/arch/ppc/kernel.c @@ -83,6 +83,7 @@ initialize_forth( void ) { dict = malloc(DICTIONARY_SIZE); load_dictionary( forth_dictionary, sizeof(forth_dictionary) ); + forth_init();
PUSH_xt( bind_noname_func(arch_of_init) ); fword("PREPOST-initializer"); diff --git a/arch/ppc/qemu/kernel.c b/arch/ppc/qemu/kernel.c index dbfca57..4cae525 100644 --- a/arch/ppc/qemu/kernel.c +++ b/arch/ppc/qemu/kernel.c @@ -86,6 +86,7 @@ initialize_forth( void ) dictlimit = DICTIONARY_SIZE;
load_dictionary( forth_dictionary, sizeof(forth_dictionary) ); + forth_init();
PUSH_xt( bind_noname_func(arch_of_init) ); fword("PREPOST-initializer"); diff --git a/arch/sparc32/openbios.c b/arch/sparc32/openbios.c index e368d6c..1c86752 100644 --- a/arch/sparc32/openbios.c +++ b/arch/sparc32/openbios.c @@ -970,6 +970,7 @@ int openbios(void) 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"); diff --git a/arch/sparc64/openbios.c b/arch/sparc64/openbios.c index 49bbe27..8c08814 100644 --- a/arch/sparc64/openbios.c +++ b/arch/sparc64/openbios.c @@ -623,6 +623,7 @@ int openbios(void) 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"); diff --git a/arch/unix/unix.c b/arch/unix/unix.c index f1c18df..5e95b69 100644 --- a/arch/unix/unix.c +++ b/arch/unix/unix.c @@ -516,6 +516,7 @@ int main(int argc, char *argv[]) printk("done.\n");
read_dictionary(argv[optind]); + forth_init();
PUSH_xt( bind_noname_func(arch_init) ); fword("PREPOST-initializer"); diff --git a/arch/x86/openbios.c b/arch/x86/openbios.c index 62ef587..24b886d 100644 --- a/arch/x86/openbios.c +++ b/arch/x86/openbios.c @@ -90,6 +90,7 @@ int openbios(void) load_dictionary((char *)sys_info.dict_start, (unsigned long)sys_info.dict_end - (unsigned long)sys_info.dict_start); + forth_init();
relocate(&sys_info);
diff --git a/include/kernel/kernel.h b/include/kernel/kernel.h index 15605b5..87812e9 100644 --- a/include/kernel/kernel.h +++ b/include/kernel/kernel.h @@ -32,6 +32,7 @@ extern void panic(const char *error) __attribute__ ((noreturn));
extern xt_t findword(const char *s1); extern void modules_init( void ); +extern void forth_init(void);
/* arch kernel hooks */ extern void exception(cell no); diff --git a/kernel/internal.c b/kernel/internal.c index 760c66d..0e3794a 100644 --- a/kernel/internal.c +++ b/kernel/internal.c @@ -50,8 +50,21 @@ char xtname[MAXNFALEN]; /* 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; + +static void init_trampoline(void) +{ + trampoline[0] = DOCOL; + trampoline[1] = 0; + trampoline[2] = pointer2cell(&trampoline[3]); + trampoline[3] = 0; +} + +void forth_init(void) +{ + init_trampoline(); +} #endif
#ifndef CONFIG_DEBUG_INTERPRETER
Andreas Färber wrote:
Move trampoline variable initialization to init_trampoline(), like in kernel/bootstrap.c.
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.
Cc: Blue Swirl blauwirbel@gmail.com Signed-off-by: Andreas Färber andreas.faerber@web.de
The basic patch looks fine to me, except that you've missed one of the callers in kernel/bootstrap.c (i.e. I'd rip out the version there and use yours instead).
ATB,
Mark.
Am 09.11.2010 um 11:35 schrieb Mark Cave-Ayland:
Andreas Färber wrote:
Move trampoline variable initialization to init_trampoline(), like in kernel/bootstrap.c. 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. Cc: Blue Swirl blauwirbel@gmail.com Signed-off-by: Andreas Färber andreas.faerber@web.de
The basic patch looks fine to me, except that you've missed one of the callers in kernel/bootstrap.c (i.e. I'd rip out the version there and use yours instead).
Careful, bootstrap.c is initializing a different trampoline. That's why my init_trampoline() needed to be static. Both will need to be initialized.
Andreas