Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / arch / amd64 / openbios.c
1 /* tag: openbios forth environment, executable code
2  *
3  * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer
4  *
5  * See the file "COPYING" for further information about
6  * the copyright and warranty status of this work.
7  */
8
9 #include "config.h"
10 #include "libopenbios/openbios.h"
11 #include "libopenbios/bindings.h"
12 #include "asm/types.h"
13 #include "dict.h"
14 #include "kernel/kernel.h"
15 #include "kernel/stack.h"
16 #include "libopenbios/sys_info.h"
17 #include "openbios.h"
18 #include "relocate.h"
19
20 void boot(void);
21
22 #define DICTIONARY_SIZE (256*1024)      /* 256K for the dictionary   */
23 static char intdict[DICTIONARY_SIZE];
24
25 static void init_memory(void)
26 {
27         /* push start and end of available memory to the stack
28          * so that the forth word QUIT can initialize memory
29          * management. For now we use hardcoded memory between
30          * 0x10000 and 0x9ffff (576k). If we need more memory
31          * than that we have serious bloat.
32          */
33
34         PUSH(0x10000);
35         PUSH(0x9FFFF);
36 }
37
38 static void
39 arch_init( void )
40 {
41         void setup_timers(void);
42
43         openbios_init();
44         modules_init();
45 #ifdef CONFIG_DRIVER_IDE
46         setup_timers();
47         ob_ide_init("/pci/pci-ata", 0x1f0, 0x3f6, 0x170, 0x376);
48 #endif
49         device_end();
50         bind_func("platform-boot", boot );
51 }
52
53 extern struct _console_ops arch_console_ops;
54
55 int openbios(void)
56 {
57 #ifdef CONFIG_DEBUG_CONSOLE
58         init_console(arch_console_ops);
59 #ifdef CONFIG_DEBUG_CONSOLE_SERIAL
60         uart_init(CONFIG_SERIAL_PORT, CONFIG_SERIAL_SPEED);
61 #endif
62         /* Clear the screen.  */
63         cls();
64 #endif
65
66         collect_sys_info(&sys_info);
67
68         dict=intdict;
69         dictlimit = DICTIONARY_SIZE;
70
71         load_dictionary((char *)sys_info.dict_start,
72                         sys_info.dict_end-sys_info.dict_start);
73         forth_init();
74
75         relocate(&sys_info);
76
77 #ifdef CONFIG_DEBUG_CONSOLE
78         video_init();
79 #endif
80 #ifdef CONFIG_DEBUG_BOOT
81         printk("forth started.\n");
82         printk("initializing memory...");
83 #endif
84
85         init_memory();
86
87 #ifdef CONFIG_DEBUG_BOOT
88         printk("done\n");
89 #endif
90
91         PUSH_xt( bind_noname_func(arch_init) );
92         fword("PREPOST-initializer");
93
94         PC = (ucell)findword("initialize-of");
95
96         if (!PC) {
97                 printk("panic: no dictionary entry point.\n");
98                 return -1;
99         }
100 #ifdef CONFIG_DEBUG_DICTIONARY
101         printk("done (%d bytes).\n", dicthead);
102         printk("Jumping to dictionary...\n");
103 #endif
104
105         enterforth((xt_t)PC);
106
107         return 0;
108 }