Browse Source

hooks.o is now a single object, rather than having separate hooks.o and

hooks_rm.o
tags/v0.9.3
Michael Brown 19 years ago
parent
commit
dfb9c44994
3 changed files with 38 additions and 58 deletions
  1. 0
    5
      src/arch/i386/Makefile
  2. 37
    45
      src/arch/i386/core/hooks.c
  3. 1
    8
      src/arch/i386/include/hooks.h

+ 0
- 5
src/arch/i386/Makefile View File

@@ -21,11 +21,6 @@ CFLAGS_setup16		= -DCODE16
21 21
 OBJS_unnrv2b		= unnrv2b unnrv2b16
22 22
 CFLAGS_unnrv2b16	= -DCODE16
23 23
 
24
-# hooks.c is used to generate hooks.o and hooks_rm.o
25
-#
26
-OBJS_hooks		= hooks hooks_rm
27
-CFLAGS_hooks_rm		= -DREALMODE
28
-
29 24
 # We need to undefine the default macro "i386" when compiling .S
30 25
 # files, otherwise ".arch i386" translates to ".arch 1"...
31 26
 #

+ 37
- 45
src/arch/i386/core/hooks.c View File

@@ -5,9 +5,8 @@
5 5
 #include "hooks.h"
6 6
 #include "init.h"
7 7
 #include "main.h"
8
-#ifdef REALMODE
9
-#include "realmode.h"
10
-#endif
8
+#include "relocate.h"
9
+#include "etherboot.h"
11 10
 
12 11
 /* Symbols defined by the linker */
13 12
 extern char _bss[], _ebss[];
@@ -16,78 +15,71 @@ extern char _bss[], _ebss[];
16 15
  * This file provides the basic entry points from assembly code.  See
17 16
  * README.i386 for a description of the entry code path.
18 17
  *
19
- * This file is compiled to two different object files: hooks.o and
20
- * hooks_rm.o.  REALMODE is defined when compiling hooks_rm.o
21
- *
22 18
  */
23 19
 
24 20
 /*
25 21
  * arch_initialise(): perform any required initialisation such as
26 22
  * setting up the console device and relocating to high memory.  Note
27 23
  * that if we relocate to high memory and the prefix is in base
28
- * memory, then we will need to install a copy of librm in base memory
29
- * and adjust retaddr so that we return to the installed copy.
24
+ * memory, then we will need to install a copy of librm in base
25
+ * memory.  librm's reset function takes care of this.
30 26
  *
31 27
  */
32
-#ifdef REALMODE
33
-void arch_rm_initialise ( struct i386_all_regs *regs,
34
-			  void (*retaddr) (void) )
35
-#else /* REALMODE */
36
-void arch_initialise ( struct i386_all_regs *regs,
37
-		       void (*retaddr) (void) __unused )
38
-#endif /* REALMODE */
39
-{
28
+
29
+#include "librm.h"
30
+
31
+void arch_initialise ( struct i386_all_regs *regs __unused ) {
40 32
 	/* Zero the BSS */
41 33
 	memset ( _bss, 0, _ebss - _bss );
42 34
 
43 35
 	/* Call all registered initialisation functions.
44 36
 	 */
45 37
 	call_init_fns ();
46
-}
47 38
 
48
-#ifdef REALMODE
39
+	/* Relocate to high memory.  (This is a no-op under
40
+	 * -DKEEP_IT_REAL.)
41
+	 */
42
+	relocate();
43
+
44
+	/* Call all registered reset functions.  Note that if librm is
45
+	 * included, it is the reset function that will install a
46
+	 * fresh copy of librm in base memory.  It follows from this
47
+	 * that (a) librm must be first in the reset list and (b) you
48
+	 * cannot call console output functions between relocate() and
49
+	 * call_reset_fns(), because real-mode calls will crash the
50
+	 * machine.
51
+	 */
52
+	call_reset_fns();
53
+
54
+	printf ( "init finished\n" );
55
+
56
+	regs->es = virt_to_phys ( installed_librm ) >> 4;
57
+
58
+	__asm__ ( "xchgw %bx, %bx" );
59
+}
49 60
 
50 61
 /*
51
- * arch_rm_main() : call main() and then exit via whatever exit mechanism
62
+ * arch_main() : call main() and then exit via whatever exit mechanism
52 63
  * the prefix requested.
53 64
  *
54 65
  */
55
-void arch_rm_main ( struct i386_all_regs *regs ) {
56
-	struct i386_all_regs regs_copy;
57
-	void (*exit_fn) ( struct i386_all_regs *regs );
66
+void arch_main ( struct i386_all_regs *regs ) {
67
+	void (*exit_path) ( struct i386_all_regs *regs );
58 68
 
59
-	/* Take a copy of the registers, because the memory holding
60
-	 * them will probably be trashed by the time main() returns.
61
-	 */
62
-	regs_copy = *regs;
63
-	exit_fn = ( typeof ( exit_fn ) ) regs_copy.eax;
69
+	/* Determine exit path requested by prefix */
70
+	exit_path = ( typeof ( exit_path ) ) regs->eax;
64 71
 
65 72
 	/* Call to main() */
66
-	regs_copy.eax = main();
73
+	regs->eax = main();
67 74
 
68 75
 	/* Call registered per-object exit functions */
69 76
 	call_exit_fns ();
70 77
 
71
-	if ( exit_fn ) {
78
+	if ( exit_path ) {
72 79
 		/* Prefix requested that we use a particular function
73 80
 		 * as the exit path, so we call this function, which
74 81
 		 * must not return.
75 82
 		 */
76
-		exit_fn ( &regs_copy );
83
+		exit_path ( regs );
77 84
 	}
78 85
 }
79
-
80
-#else /* REALMODE */
81
-
82
-/*
83
- * arch_main() : call main() and return
84
- *
85
- */
86
-void arch_main ( struct i386_all_regs *regs ) {
87
-	regs->eax = main();
88
-
89
-	/* Call registered per-object exit functions */
90
-	call_exit_fns ();
91
-};
92
-
93
-#endif /* REALMODE */

+ 1
- 8
src/arch/i386/include/hooks.h View File

@@ -1,14 +1,7 @@
1 1
 #ifndef HOOKS_H
2 2
 #define HOOKS_H
3 3
 
4
-/* in hooks.o */
5
-extern void arch_initialise ( struct i386_all_regs *regs,
6
-			      void (*retaddr) (void) );
4
+extern void arch_initialise ( struct i386_all_regs *regs );
7 5
 extern void arch_main ( struct i386_all_regs *regs );
8 6
 
9
-/* in hooks_rm.o */
10
-extern void arch_rm_initialise ( struct i386_all_regs *regs,
11
-				 void (*retaddr) (void) );
12
-extern void arch_rm_main ( struct i386_all_regs *regs );
13
-
14 7
 #endif /* HOOKS_H */

Loading…
Cancel
Save