summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openbios/libopenbios/initprogram.c
blob: 1fa33ba660e0fc9a6fea73955d9bca4f5404163d (plain)
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
/*
 *   Creation Date: <2010/04/02 13:00:00 mcayland>
 *   Time-stamp: <2010/04/02 13:00:00 mcayland>
 *
 *	<initprogram.c>
 *
 *	C implementation of (init-program) word
 *
 *   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"

/* Because the a.out loader requires platform-specific headers */
#ifdef CONFIG_LOADER_AOUT
#include "libopenbios/aout_load.h"
#endif

#include "libopenbios/bootinfo_load.h"
#include "libopenbios/elf_load.h"
#include "libopenbios/fcode_load.h"
#include "libopenbios/forth_load.h"
#include "libopenbios/xcoff_load.h"


void init_program(void)
{
	/* Get the value of load-base and use it to determine the correct loader
           to use */
	ucell addr;

	feval("load-base");
	addr = POP();

#ifdef CONFIG_LOADER_AOUT
	if (is_aout((struct exec *)cell2pointer(addr))) {
		aout_init_program();
		return;
	}
#endif

#ifdef CONFIG_LOADER_BOOTINFO
	if (is_bootinfo((char *)cell2pointer(addr))) {
		bootinfo_init_program();
		return;
	}
#endif

#ifdef CONFIG_LOADER_ELF
	if (is_elf((Elf_ehdr *)cell2pointer(addr))) {
		elf_init_program();
		return;
	}
#endif

#ifdef CONFIG_LOADER_FCODE
	if (is_fcode((unsigned char *)cell2pointer(addr))) {
		fcode_init_program();
		return;
	}
#endif

#ifdef CONFIG_LOADER_FORTH
	if (is_forth((char *)cell2pointer(addr))) {
		forth_init_program();
		return;
	}
#endif

#ifdef CONFIG_LOADER_XCOFF
	if (is_xcoff((COFF_filehdr_t *)cell2pointer(addr))) {
		xcoff_init_program();
		return;
	}
#endif

}