|
@@ -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 ( ®s_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 */
|