Added post-relocation function table.
This commit is contained in:
parent
9abceef561
commit
f06e8c9707
|
@ -2,6 +2,7 @@
|
||||||
#include "memsizes.h"
|
#include "memsizes.h"
|
||||||
#include "osdep.h"
|
#include "osdep.h"
|
||||||
#include "etherboot.h"
|
#include "etherboot.h"
|
||||||
|
#include "init.h"
|
||||||
#include "relocate.h"
|
#include "relocate.h"
|
||||||
|
|
||||||
#ifndef KEEP_IT_REAL
|
#ifndef KEEP_IT_REAL
|
||||||
|
@ -38,6 +39,8 @@ extern char _max_align[];
|
||||||
/* Linker symbols */
|
/* Linker symbols */
|
||||||
extern char _text[];
|
extern char _text[];
|
||||||
extern char _end[];
|
extern char _end[];
|
||||||
|
extern struct post_reloc_fn post_reloc_fns[];
|
||||||
|
extern struct post_reloc_fn post_reloc_fns_end[];
|
||||||
|
|
||||||
#undef DBG
|
#undef DBG
|
||||||
#ifdef DEBUG_RELOCATE
|
#ifdef DEBUG_RELOCATE
|
||||||
|
@ -46,9 +49,10 @@ extern char _end[];
|
||||||
#define DBG(...)
|
#define DBG(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void relocate ( void ) {
|
static void relocate ( void ) {
|
||||||
unsigned long addr, eaddr, size;
|
unsigned long addr, eaddr, size;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
struct post_reloc_fn *post_reloc_fn;
|
||||||
|
|
||||||
/* Walk through the memory map and find the highest address
|
/* Walk through the memory map and find the highest address
|
||||||
* below 4GB that etherboot will fit into. Ensure etherboot
|
* below 4GB that etherboot will fit into. Ensure etherboot
|
||||||
|
@ -186,12 +190,23 @@ void relocate ( void ) {
|
||||||
|
|
||||||
relocate_to ( addr );
|
relocate_to ( addr );
|
||||||
/* Note that we cannot make real-mode calls
|
/* Note that we cannot make real-mode calls
|
||||||
* (e.g. printf) at this point, because the pointer
|
* (e.g. printf) at this point, because librm has just
|
||||||
* installed_librm uses a virtual address (in order
|
* been moved to high memory.
|
||||||
* that it can have a valid initialiser) and so is
|
|
||||||
* currently invalid.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Call any registered post-relocation functions.
|
||||||
|
* librm has a post-relocation function to install a
|
||||||
|
* new librm into base memory.
|
||||||
|
*/
|
||||||
|
for ( post_reloc_fn = post_reloc_fns;
|
||||||
|
post_reloc_fn < post_reloc_fns_end ; post_reloc_fn++ ) {
|
||||||
|
if ( post_reloc_fn->post_reloc )
|
||||||
|
post_reloc_fn->post_reloc ();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INIT_FN ( INIT_RELOCATE, relocate, NULL, NULL );
|
||||||
|
|
||||||
#endif /* ! KEEP_IT_REAL */
|
#endif /* ! KEEP_IT_REAL */
|
||||||
|
|
|
@ -1,14 +1,24 @@
|
||||||
#ifndef RELOCATE_H
|
#ifndef RELOCATE_H
|
||||||
#define RELOCATE_H
|
#define RELOCATE_H
|
||||||
|
|
||||||
#ifdef KEEP_IT_REAL
|
|
||||||
|
|
||||||
/* relocate() is conceptually impossible with KEEP_IT_REAL */
|
/* relocate() is conceptually impossible with KEEP_IT_REAL */
|
||||||
#define relocate()
|
#ifndef KEEP_IT_REAL
|
||||||
|
|
||||||
#else
|
/* An entry in the post-relocation function table */
|
||||||
|
struct post_reloc_fn {
|
||||||
|
void ( *post_reloc ) ( void );
|
||||||
|
};
|
||||||
|
|
||||||
extern void relocate ( void );
|
/* Use double digits to avoid problems with "10" < "9" on alphabetic sort */
|
||||||
|
#define POST_RELOC_LIBRM "00"
|
||||||
|
|
||||||
|
/* Macro for creating a post-relocation function table entry */
|
||||||
|
#define POST_RELOC_FN( post_reloc_order, post_reloc_func ) \
|
||||||
|
static struct post_reloc_fn post_reloc_functions \
|
||||||
|
__attribute__ (( used, __section__( ".post_reloc_fns." \
|
||||||
|
post_reloc_order ) )) = { \
|
||||||
|
.post_reloc = post_reloc_func, \
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,8 @@ SECTIONS {
|
||||||
__data = .;
|
__data = .;
|
||||||
*(.data)
|
*(.data)
|
||||||
*(.data.*)
|
*(.data.*)
|
||||||
|
|
||||||
|
/* Various tables */
|
||||||
pci_drivers = .;
|
pci_drivers = .;
|
||||||
*(.drivers.pci)
|
*(.drivers.pci)
|
||||||
pci_drivers_end = .;
|
pci_drivers_end = .;
|
||||||
|
@ -149,6 +151,9 @@ SECTIONS {
|
||||||
console_drivers = .;
|
console_drivers = .;
|
||||||
*(.drivers.console)
|
*(.drivers.console)
|
||||||
console_drivers_end = .;
|
console_drivers_end = .;
|
||||||
|
post_reloc_fns = .;
|
||||||
|
*(SORT(.post_reloc_fns.*))
|
||||||
|
post_reloc_fns_end = .;
|
||||||
init_fns = .;
|
init_fns = .;
|
||||||
*(SORT(.init_fns.*))
|
*(SORT(.init_fns.*))
|
||||||
init_fns_end = .;
|
init_fns_end = .;
|
||||||
|
|
Reference in New Issue