Kaynağa Gözat

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

hooks_rm.o
tags/v0.9.3
Michael Brown 19 yıl önce
ebeveyn
işleme
dfb9c44994

+ 0
- 5
src/arch/i386/Makefile Dosyayı Görüntüle

21
 OBJS_unnrv2b		= unnrv2b unnrv2b16
21
 OBJS_unnrv2b		= unnrv2b unnrv2b16
22
 CFLAGS_unnrv2b16	= -DCODE16
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
 # We need to undefine the default macro "i386" when compiling .S
24
 # We need to undefine the default macro "i386" when compiling .S
30
 # files, otherwise ".arch i386" translates to ".arch 1"...
25
 # files, otherwise ".arch i386" translates to ".arch 1"...
31
 #
26
 #

+ 37
- 45
src/arch/i386/core/hooks.c Dosyayı Görüntüle

5
 #include "hooks.h"
5
 #include "hooks.h"
6
 #include "init.h"
6
 #include "init.h"
7
 #include "main.h"
7
 #include "main.h"
8
-#ifdef REALMODE
9
-#include "realmode.h"
10
-#endif
8
+#include "relocate.h"
9
+#include "etherboot.h"
11
 
10
 
12
 /* Symbols defined by the linker */
11
 /* Symbols defined by the linker */
13
 extern char _bss[], _ebss[];
12
 extern char _bss[], _ebss[];
16
  * This file provides the basic entry points from assembly code.  See
15
  * This file provides the basic entry points from assembly code.  See
17
  * README.i386 for a description of the entry code path.
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
  * arch_initialise(): perform any required initialisation such as
21
  * arch_initialise(): perform any required initialisation such as
26
  * setting up the console device and relocating to high memory.  Note
22
  * setting up the console device and relocating to high memory.  Note
27
  * that if we relocate to high memory and the prefix is in base
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
 	/* Zero the BSS */
32
 	/* Zero the BSS */
41
 	memset ( _bss, 0, _ebss - _bss );
33
 	memset ( _bss, 0, _ebss - _bss );
42
 
34
 
43
 	/* Call all registered initialisation functions.
35
 	/* Call all registered initialisation functions.
44
 	 */
36
 	 */
45
 	call_init_fns ();
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
  * the prefix requested.
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
 	/* Call to main() */
72
 	/* Call to main() */
66
-	regs_copy.eax = main();
73
+	regs->eax = main();
67
 
74
 
68
 	/* Call registered per-object exit functions */
75
 	/* Call registered per-object exit functions */
69
 	call_exit_fns ();
76
 	call_exit_fns ();
70
 
77
 
71
-	if ( exit_fn ) {
78
+	if ( exit_path ) {
72
 		/* Prefix requested that we use a particular function
79
 		/* Prefix requested that we use a particular function
73
 		 * as the exit path, so we call this function, which
80
 		 * as the exit path, so we call this function, which
74
 		 * must not return.
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 Dosyayı Görüntüle

1
 #ifndef HOOKS_H
1
 #ifndef HOOKS_H
2
 #define HOOKS_H
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
 extern void arch_main ( struct i386_all_regs *regs );
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
 #endif /* HOOKS_H */
7
 #endif /* HOOKS_H */

Loading…
İptal
Kaydet