From 87508aa0b2e0fea5d4dea8d732150bd2fdbbb9f8 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 10 Apr 2005 18:30:34 +0000 Subject: [PATCH] arch_initialise() is now sufficiently generic that we may as well just call it initialise() and place it in main.c. :) --- src/arch/i386/core/hooks.c | 21 --------------------- src/arch/i386/core/setup.S | 12 ++++++------ src/arch/i386/include/hooks.h | 1 - src/arch/i386/transitions/librm_mgmt.c | 6 +++--- src/core/main.c | 21 +++++++++++++++++++++ 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/arch/i386/core/hooks.c b/src/arch/i386/core/hooks.c index 75066691..230cc401 100644 --- a/src/arch/i386/core/hooks.c +++ b/src/arch/i386/core/hooks.c @@ -1,8 +1,4 @@ -#include "stdint.h" -#include "stddef.h" #include "registers.h" -#include "string.h" -#include "init.h" #include "main.h" #include "etherboot.h" #include "hooks.h" @@ -16,20 +12,6 @@ extern char _bss[], _ebss[]; * */ -/* - * arch_initialise(): perform any required initialisation such as - * setting up the console device and relocating to high memory. - * - */ -void arch_initialise ( struct i386_all_regs *regs __unused ) { - /* Zero the BSS */ - memset ( _bss, 0, _ebss - _bss ); - - /* Call all registered initialisation functions. - */ - call_init_fns (); -} - /* * arch_main() : call main() and then exit via whatever exit mechanism * the prefix requested. @@ -44,9 +26,6 @@ void arch_main ( struct i386_all_regs *regs ) { /* Call to main() */ regs->eax = main(); - /* Call registered per-object exit functions */ - call_exit_fns (); - if ( exit_path ) { /* Prefix requested that we use a particular function * as the exit path, so we call this function, which diff --git a/src/arch/i386/core/setup.S b/src/arch/i386/core/setup.S index 26aa2320..11b28880 100644 --- a/src/arch/i386/core/setup.S +++ b/src/arch/i386/core/setup.S @@ -40,7 +40,7 @@ #define RETURN_TO_EXTERNAL call kir_to_ext #define ENTRY_POINT kir_call #define ENTRY_POINT_REGISTER di -#define INIT_FUNC arch_initialise +#define INIT_FUNC initialise #else /* KEEP_IT_REAL */ @@ -53,7 +53,7 @@ .code16 #define ENTRY_POINT _prot_call /* _prot_call = OFFSET ( prot_call ) in librm */ #define ENTRY_POINT_REGISTER di -#define INIT_FUNC librm_arch_initialise +#define INIT_FUNC initialise_via_librm #endif /* KEEP_IT_REAL */ @@ -78,7 +78,7 @@ setup16: #define RETURN_TO_EXTERNAL call int_to_ext #define ENTRY_POINT int_call #define ENTRY_POINT_REGISTER edi -#define INIT_FUNC arch_initialise +#define INIT_FUNC initialise .section ".text" .code32 @@ -142,11 +142,11 @@ setup: pop %es mov $ENTRY_POINT, %ENTRY_POINT_REGISTER - /* Far call to arch_initialise via the entry-point function. - * arch_initialise() (or the entry-point function itself) may + /* Far call to initialise via the entry-point function. + * initialise() (or the entry-point function itself) may * update %es:[e]di to point to a new entry-point function for * subsequent calls. librm will use this facility, since - * arch_initialise() causes librm to be relocated. + * initialise() causes librm to be relocated. */ pushl $INIT_FUNC push %cs /* lcall %es:[x]di == %cs:[x]di */ diff --git a/src/arch/i386/include/hooks.h b/src/arch/i386/include/hooks.h index 879148e4..95b9aaa3 100644 --- a/src/arch/i386/include/hooks.h +++ b/src/arch/i386/include/hooks.h @@ -1,7 +1,6 @@ #ifndef HOOKS_H #define HOOKS_H -extern void arch_initialise ( struct i386_all_regs *regs ); extern void arch_main ( struct i386_all_regs *regs ); #endif /* HOOKS_H */ diff --git a/src/arch/i386/transitions/librm_mgmt.c b/src/arch/i386/transitions/librm_mgmt.c index c8455cba..f59941b2 100644 --- a/src/arch/i386/transitions/librm_mgmt.c +++ b/src/arch/i386/transitions/librm_mgmt.c @@ -126,16 +126,16 @@ INIT_FN ( INIT_LIBRM, librm_init, NULL, uninstall_librm ); POST_RELOC_FN ( POST_RELOC_LIBRM, librm_post_reloc ); /* - * Wrapper for arch_initialise() when librm is being used. We have to + * Wrapper for initialise() when librm is being used. We have to * install a copy of librm to allocated base memory and return the * pointer to this new librm's entry point via es:di. * */ -void librm_arch_initialise ( struct i386_all_regs *regs ) { +void initialise_via_librm ( struct i386_all_regs *regs ) { char *new_librm; /* Hand off to arch_initialise() */ - arch_initialise ( regs ); + initialise ( regs ); /* Uninstall current librm (i.e. the one that's part of the * original, pre-relocation Etherboot image). diff --git a/src/core/main.c b/src/core/main.c index c95f0ae2..ef8b67bb 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -138,6 +138,23 @@ static int exit_status; static int initialized; +/************************************************************************** + * initialise() - perform any C-level initialisation + * + * This does not include initialising the NIC, but it does include + * e.g. getting the memory map, relocating to high memory, + * initialising the console, etc. + ************************************************************************** + */ +void initialise ( void ) { + /* Zero the BSS */ + memset ( _bss, 0, _ebss - _bss ); + + /* Call all registered initialisation functions. + */ + call_init_fns (); +} + /************************************************************************** MAIN - Kick off routine **************************************************************************/ @@ -164,6 +181,10 @@ int main ( void ) { state = main_loop(state); } /* arch_on_exit(exit_status) */ + + /* Call registered per-object exit functions */ + call_exit_fns (); + return exit_status; }