1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
/*
* Creation Date: <2010/06/25 20:00:00 mcayland>
* Time-stamp: <2010/06/25 20:00:00 mcayland>
*
* <load.c>
*
* C implementation of load
*
* Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2
*
*/
#include "config.h"
#include "kernel/kernel.h"
#include "libopenbios/bindings.h"
#include "libopenbios/initprogram.h"
#include "libopenbios/sys_info.h"
#include "libopenbios/load.h"
#ifdef CONFIG_LOADER_ELF
#include "libopenbios/elf_load.h"
#endif
#ifdef CONFIG_LOADER_AOUT
#include "libopenbios/aout_load.h"
#endif
#ifdef CONFIG_LOADER_FCODE
#include "libopenbios/fcode_load.h"
#endif
#ifdef CONFIG_LOADER_FORTH
#include "libopenbios/forth_load.h"
#endif
#ifdef CONFIG_LOADER_XCOFF
#include "libopenbios/xcoff_load.h"
#endif
#ifdef CONFIG_LOADER_BOOTCODE
#include "libopenbios/bootcode_load.h"
#endif
#ifdef CONFIG_LOADER_PREP
#include "libopenbios/prep_load.h"
#endif
struct sys_info sys_info;
void *elf_boot_notes = NULL;
/* ( addr -- size ) */
void load(ihandle_t dev)
{
/* Invoke the loaders on the specified device */
char *param;
/* TODO: Currently the internal loader APIs use load-base directly, so
drop the address */
POP();
#ifdef CONFIG_LOADER_ELF
/* Grab the boot arguments */
push_str("bootargs");
push_str("/chosen");
fword("(find-dev)");
POP();
fword("get-package-property");
POP();
param = pop_fstr_copy();
if (elf_load(&sys_info, dev, param, &elf_boot_notes) != LOADER_NOT_SUPPORT) {
feval("load-state >ls.file-size @");
return;
}
#endif
#ifdef CONFIG_LOADER_AOUT
if (aout_load(&sys_info, dev) != LOADER_NOT_SUPPORT) {
feval("load-state >ls.file-size @");
return;
}
#endif
#ifdef CONFIG_LOADER_FCODE
if (fcode_load(dev) != LOADER_NOT_SUPPORT) {
feval("load-state >ls.file-size @");
return;
}
#endif
#ifdef CONFIG_LOADER_FORTH
if (forth_load(dev) != LOADER_NOT_SUPPORT) {
feval("load-state >ls.file-size @");
return;
}
#endif
#ifdef CONFIG_LOADER_XCOFF
if (xcoff_load(dev) != LOADER_NOT_SUPPORT) {
feval("load-state >ls.file-size @");
return;
}
#endif
#ifdef CONFIG_LOADER_BOOTCODE
/* Check for a "raw" %BOOT bootcode payload */
if (bootcode_load(dev) != LOADER_NOT_SUPPORT) {
feval("load-state >ls.file-size @");
return;
}
#endif
#ifdef CONFIG_LOADER_PREP
if (prep_load(dev) != LOADER_NOT_SUPPORT) {
feval("load-state >ls.file-size @");
return;
}
#endif
/* Didn't load anything, so return zero size */
PUSH(0);
}
|