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> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@954 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
parent
8a01c240b8
commit
c3b33b6610
|
@ -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);
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ extern void panic(const char *error) __attribute__ ((noreturn));
|
|||
|
||||
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);
|
||||
|
|
|
@ -91,20 +91,6 @@ static const char *wordnames[] = {
|
|||
"$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 @@ int main(int argc, char *argv[])
|
|||
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)
|
||||
|
|
|
@ -50,8 +50,13 @@ 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;
|
||||
|
||||
void forth_init(void)
|
||||
{
|
||||
init_trampoline(trampoline);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DEBUG_INTERPRETER
|
||||
|
@ -67,6 +72,15 @@ static ucell *trampoline = t;
|
|||
#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);
|
||||
|
|
Loading…
Reference in New Issue