summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openbios/arch/amd64/openbios.c
blob: 15d3b62543f90488950679dfaf9f3720341a01f9 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* tag: openbios forth environment, executable code
 *
 * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer
 *
 * See the file "COPYING" for further information about
 * the copyright and warranty status of this work.
 */

#include "config.h"
#include "libopenbios/openbios.h"
#include "libopenbios/bindings.h"
#include "asm/types.h"
#include "dict.h"
#include "kernel/kernel.h"
#include "kernel/stack.h"
#include "libopenbios/sys_info.h"
#include "openbios.h"
#include "relocate.h"

void boot(void);

#define DICTIONARY_SIZE (256*1024)      /* 256K for the dictionary   */
static char intdict[DICTIONARY_SIZE];

static void init_memory(void)
{
	/* push start and end of available memory to the stack
	 * so that the forth word QUIT can initialize memory
	 * management. For now we use hardcoded memory between
	 * 0x10000 and 0x9ffff (576k). If we need more memory
	 * than that we have serious bloat.
	 */

	PUSH(0x10000);
	PUSH(0x9FFFF);
}

static void
arch_init( void )
{
	void setup_timers(void);

	openbios_init();
	modules_init();
#ifdef CONFIG_DRIVER_IDE
	setup_timers();
	ob_ide_init("/pci/pci-ata", 0x1f0, 0x3f6, 0x170, 0x376);
#endif
	device_end();
	bind_func("platform-boot", boot );
}

extern struct _console_ops arch_console_ops;

int openbios(void)
{
#ifdef CONFIG_DEBUG_CONSOLE
	init_console(arch_console_ops);
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
	uart_init(CONFIG_SERIAL_PORT, CONFIG_SERIAL_SPEED);
#endif
	/* Clear the screen.  */
	cls();
#endif

        collect_sys_info(&sys_info);

	dict=intdict;
	dictlimit = DICTIONARY_SIZE;

	load_dictionary((char *)sys_info.dict_start,
			sys_info.dict_end-sys_info.dict_start);
	forth_init();

	relocate(&sys_info);

#ifdef CONFIG_DEBUG_CONSOLE
	video_init();
#endif
#ifdef CONFIG_DEBUG_BOOT
	printk("forth started.\n");
	printk("initializing memory...");
#endif

	init_memory();

#ifdef CONFIG_DEBUG_BOOT
	printk("done\n");
#endif

	PUSH_xt( bind_noname_func(arch_init) );
	fword("PREPOST-initializer");

	PC = (ucell)findword("initialize-of");

	if (!PC) {
		printk("panic: no dictionary entry point.\n");
		return -1;
	}
#ifdef CONFIG_DEBUG_DICTIONARY
	printk("done (%d bytes).\n", dicthead);
	printk("Jumping to dictionary...\n");
#endif

	enterforth((xt_t)PC);

	return 0;
}