]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
hooks.o is now a single object, rather than having separate hooks.o and
authorMichael Brown <mcb30@etherboot.org>
Sun, 10 Apr 2005 16:44:29 +0000 (16:44 +0000)
committerMichael Brown <mcb30@etherboot.org>
Sun, 10 Apr 2005 16:44:29 +0000 (16:44 +0000)
hooks_rm.o

src/arch/i386/Makefile
src/arch/i386/core/hooks.c
src/arch/i386/include/hooks.h

index a4139e74b6bf04e4a8ca2f7f10008daa49240204..2a51165ed41fac4349644e46827494b8dfb9eec6 100644 (file)
@@ -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"...
 #
index 32a137b1c70f037a8755f1be3a8b9e028d088ac8..b17722a60282a23afc2e55b332c992a2af0766a4 100644 (file)
@@ -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 ();
-}
 
-#ifdef REALMODE
+       /* 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" );
+}
 
 /*
- * 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();
+       regs->eax = main();
 
        /* Call registered per-object exit functions */
        call_exit_fns ();
 
-       if ( exit_fn ) {
+       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_fn ( &regs_copy );
+               exit_path ( regs );
        }
 }
-
-#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 */
index a4e4b397e126488c884ba1c2145e4ffcb4b7299b..879148e46956035e12f917f36ddf032779154dbd 100644 (file)
@@ -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 */