mirror of
https://github.com/xcat2/xNBA.git
synced 2024-12-14 15:21:32 +00:00
hooks.o is now a single object, rather than having separate hooks.o and
hooks_rm.o
This commit is contained in:
parent
04a99841e6
commit
dfb9c44994
@ -21,11 +21,6 @@ CFLAGS_setup16 = -DCODE16
|
||||
OBJS_unnrv2b = unnrv2b unnrv2b16
|
||||
CFLAGS_unnrv2b16 = -DCODE16
|
||||
|
||||
# hooks.c is used to generate hooks.o and hooks_rm.o
|
||||
#
|
||||
OBJS_hooks = hooks hooks_rm
|
||||
CFLAGS_hooks_rm = -DREALMODE
|
||||
|
||||
# We need to undefine the default macro "i386" when compiling .S
|
||||
# files, otherwise ".arch i386" translates to ".arch 1"...
|
||||
#
|
||||
|
@ -5,9 +5,8 @@
|
||||
#include "hooks.h"
|
||||
#include "init.h"
|
||||
#include "main.h"
|
||||
#ifdef REALMODE
|
||||
#include "realmode.h"
|
||||
#endif
|
||||
#include "relocate.h"
|
||||
#include "etherboot.h"
|
||||
|
||||
/* Symbols defined by the linker */
|
||||
extern char _bss[], _ebss[];
|
||||
@ -16,78 +15,71 @@ extern char _bss[], _ebss[];
|
||||
* This file provides the basic entry points from assembly code. See
|
||||
* README.i386 for a description of the entry code path.
|
||||
*
|
||||
* This file is compiled to two different object files: hooks.o and
|
||||
* hooks_rm.o. REALMODE is defined when compiling hooks_rm.o
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* arch_initialise(): perform any required initialisation such as
|
||||
* setting up the console device and relocating to high memory. Note
|
||||
* that if we relocate to high memory and the prefix is in base
|
||||
* memory, then we will need to install a copy of librm in base memory
|
||||
* and adjust retaddr so that we return to the installed copy.
|
||||
* memory, then we will need to install a copy of librm in base
|
||||
* memory. librm's reset function takes care of this.
|
||||
*
|
||||
*/
|
||||
#ifdef REALMODE
|
||||
void arch_rm_initialise ( struct i386_all_regs *regs,
|
||||
void (*retaddr) (void) )
|
||||
#else /* REALMODE */
|
||||
void arch_initialise ( struct i386_all_regs *regs,
|
||||
void (*retaddr) (void) __unused )
|
||||
#endif /* REALMODE */
|
||||
{
|
||||
|
||||
#include "librm.h"
|
||||
|
||||
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 ();
|
||||
|
||||
/* Relocate to high memory. (This is a no-op under
|
||||
* -DKEEP_IT_REAL.)
|
||||
*/
|
||||
relocate();
|
||||
|
||||
/* Call all registered reset functions. Note that if librm is
|
||||
* included, it is the reset function that will install a
|
||||
* fresh copy of librm in base memory. It follows from this
|
||||
* that (a) librm must be first in the reset list and (b) you
|
||||
* cannot call console output functions between relocate() and
|
||||
* call_reset_fns(), because real-mode calls will crash the
|
||||
* machine.
|
||||
*/
|
||||
call_reset_fns();
|
||||
|
||||
printf ( "init finished\n" );
|
||||
|
||||
regs->es = virt_to_phys ( installed_librm ) >> 4;
|
||||
|
||||
__asm__ ( "xchgw %bx, %bx" );
|
||||
}
|
||||
|
||||
#ifdef REALMODE
|
||||
|
||||
/*
|
||||
* arch_rm_main() : call main() and then exit via whatever exit mechanism
|
||||
* arch_main() : call main() and then exit via whatever exit mechanism
|
||||
* the prefix requested.
|
||||
*
|
||||
*/
|
||||
void arch_rm_main ( struct i386_all_regs *regs ) {
|
||||
struct i386_all_regs regs_copy;
|
||||
void (*exit_fn) ( struct i386_all_regs *regs );
|
||||
void arch_main ( struct i386_all_regs *regs ) {
|
||||
void (*exit_path) ( struct i386_all_regs *regs );
|
||||
|
||||
/* Take a copy of the registers, because the memory holding
|
||||
* them will probably be trashed by the time main() returns.
|
||||
*/
|
||||
regs_copy = *regs;
|
||||
exit_fn = ( typeof ( exit_fn ) ) regs_copy.eax;
|
||||
/* Determine exit path requested by prefix */
|
||||
exit_path = ( typeof ( exit_path ) ) regs->eax;
|
||||
|
||||
/* Call to main() */
|
||||
regs_copy.eax = main();
|
||||
|
||||
/* Call registered per-object exit functions */
|
||||
call_exit_fns ();
|
||||
|
||||
if ( exit_fn ) {
|
||||
/* Prefix requested that we use a particular function
|
||||
* as the exit path, so we call this function, which
|
||||
* must not return.
|
||||
*/
|
||||
exit_fn ( ®s_copy );
|
||||
}
|
||||
}
|
||||
|
||||
#else /* REALMODE */
|
||||
|
||||
/*
|
||||
* arch_main() : call main() and return
|
||||
*
|
||||
*/
|
||||
void arch_main ( struct i386_all_regs *regs ) {
|
||||
regs->eax = main();
|
||||
|
||||
/* Call registered per-object exit functions */
|
||||
call_exit_fns ();
|
||||
};
|
||||
|
||||
#endif /* REALMODE */
|
||||
if ( exit_path ) {
|
||||
/* Prefix requested that we use a particular function
|
||||
* as the exit path, so we call this function, which
|
||||
* must not return.
|
||||
*/
|
||||
exit_path ( regs );
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,7 @@
|
||||
#ifndef HOOKS_H
|
||||
#define HOOKS_H
|
||||
|
||||
/* in hooks.o */
|
||||
extern void arch_initialise ( struct i386_all_regs *regs,
|
||||
void (*retaddr) (void) );
|
||||
extern void arch_initialise ( struct i386_all_regs *regs );
|
||||
extern void arch_main ( struct i386_all_regs *regs );
|
||||
|
||||
/* in hooks_rm.o */
|
||||
extern void arch_rm_initialise ( struct i386_all_regs *regs,
|
||||
void (*retaddr) (void) );
|
||||
extern void arch_rm_main ( struct i386_all_regs *regs );
|
||||
|
||||
#endif /* HOOKS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user