|
@@ -2,6 +2,7 @@
|
2
|
2
|
#include "memsizes.h"
|
3
|
3
|
#include "osdep.h"
|
4
|
4
|
#include "etherboot.h"
|
|
5
|
+#include "init.h"
|
5
|
6
|
#include "relocate.h"
|
6
|
7
|
|
7
|
8
|
#ifndef KEEP_IT_REAL
|
|
@@ -38,6 +39,8 @@ extern char _max_align[];
|
38
|
39
|
/* Linker symbols */
|
39
|
40
|
extern char _text[];
|
40
|
41
|
extern char _end[];
|
|
42
|
+extern struct post_reloc_fn post_reloc_fns[];
|
|
43
|
+extern struct post_reloc_fn post_reloc_fns_end[];
|
41
|
44
|
|
42
|
45
|
#undef DBG
|
43
|
46
|
#ifdef DEBUG_RELOCATE
|
|
@@ -46,9 +49,10 @@ extern char _end[];
|
46
|
49
|
#define DBG(...)
|
47
|
50
|
#endif
|
48
|
51
|
|
49
|
|
-void relocate ( void ) {
|
|
52
|
+static void relocate ( void ) {
|
50
|
53
|
unsigned long addr, eaddr, size;
|
51
|
54
|
unsigned i;
|
|
55
|
+ struct post_reloc_fn *post_reloc_fn;
|
52
|
56
|
|
53
|
57
|
/* Walk through the memory map and find the highest address
|
54
|
58
|
* below 4GB that etherboot will fit into. Ensure etherboot
|
|
@@ -186,12 +190,23 @@ void relocate ( void ) {
|
186
|
190
|
|
187
|
191
|
relocate_to ( addr );
|
188
|
192
|
/* Note that we cannot make real-mode calls
|
189
|
|
- * (e.g. printf) at this point, because the pointer
|
190
|
|
- * installed_librm uses a virtual address (in order
|
191
|
|
- * that it can have a valid initialiser) and so is
|
192
|
|
- * currently invalid.
|
|
193
|
+ * (e.g. printf) at this point, because librm has just
|
|
194
|
+ * been moved to high memory.
|
193
|
195
|
*/
|
|
196
|
+
|
|
197
|
+ /* Call any registered post-relocation functions.
|
|
198
|
+ * librm has a post-relocation function to install a
|
|
199
|
+ * new librm into base memory.
|
|
200
|
+ */
|
|
201
|
+ for ( post_reloc_fn = post_reloc_fns;
|
|
202
|
+ post_reloc_fn < post_reloc_fns_end ; post_reloc_fn++ ) {
|
|
203
|
+ if ( post_reloc_fn->post_reloc )
|
|
204
|
+ post_reloc_fn->post_reloc ();
|
|
205
|
+ }
|
|
206
|
+
|
194
|
207
|
}
|
195
|
208
|
}
|
196
|
209
|
|
|
210
|
+INIT_FN ( INIT_RELOCATE, relocate, NULL, NULL );
|
|
211
|
+
|
197
|
212
|
#endif /* ! KEEP_IT_REAL */
|