|
|
1.1 root 1: /*
2: * Creation Date: <2010/04/02 13:00:00 mcayland>
3: * Time-stamp: <2010/04/02 13:00:00 mcayland>
4: *
5: * <initprogram.c>
6: *
7: * C implementation of (init-program) word
8: *
9: * Copyright (C) 2010 Mark Cave-Ayland ([email protected])
10: *
11: * This program is free software; you can redistribute it and/or
12: * modify it under the terms of the GNU General Public License
13: * version 2
14: *
15: */
16:
17: #include "config.h"
18: #include "kernel/kernel.h"
19: #include "libopenbios/bindings.h"
20: #include "libopenbios/initprogram.h"
21:
22: /* Because the a.out loader requires platform-specific headers */
23: #ifdef CONFIG_LOADER_AOUT
24: #include "libopenbios/aout_load.h"
25: #endif
26:
27: #include "libopenbios/bootinfo_load.h"
28: #include "libopenbios/elf_load.h"
29: #include "libopenbios/fcode_load.h"
30: #include "libopenbios/forth_load.h"
31: #include "libopenbios/xcoff_load.h"
32:
33:
34: void init_program(void)
35: {
36: /* Get the value of load-base and use it to determine the correct loader
37: to use */
38: ucell addr;
39:
40: feval("load-base");
41: addr = POP();
42:
43: #ifdef CONFIG_LOADER_AOUT
44: if (is_aout((struct exec *)cell2pointer(addr))) {
45: aout_init_program();
46: return;
47: }
48: #endif
49:
50: #ifdef CONFIG_LOADER_BOOTINFO
51: if (is_bootinfo((char *)cell2pointer(addr))) {
52: bootinfo_init_program();
53: return;
54: }
55: #endif
56:
57: #ifdef CONFIG_LOADER_ELF
58: if (is_elf((Elf_ehdr *)cell2pointer(addr))) {
59: elf_init_program();
60: return;
61: }
62: #endif
63:
64: #ifdef CONFIG_LOADER_FCODE
65: if (is_fcode((unsigned char *)cell2pointer(addr))) {
66: fcode_init_program();
67: return;
68: }
69: #endif
70:
71: #ifdef CONFIG_LOADER_FORTH
72: if (is_forth((char *)cell2pointer(addr))) {
73: forth_init_program();
74: return;
75: }
76: #endif
77:
78: #ifdef CONFIG_LOADER_XCOFF
79: if (is_xcoff((COFF_filehdr_t *)cell2pointer(addr))) {
80: xcoff_init_program();
81: return;
82: }
83: #endif
84:
85: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.