Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / arch / x86 / 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 "libopenbios/console.h"
13 #include "asm/types.h"
14 #include "dict.h"
15 #include "kernel/kernel.h"
16 #include "kernel/stack.h"
17 #include "drivers/drivers.h"
18 #include "drivers/pci.h"
19 #include "libopenbios/sys_info.h"
20 #include "libopenbios/video.h"
21 #include "openbios.h"
22 #include "relocate.h"
23 #include "boot.h"
24
25 void collect_sys_info(struct sys_info *info);
26
27 #ifdef CONFIG_DRIVER_PCI
28 static const pci_arch_t default_pci_host = {
29     .name = "Intel,i440FX",
30     .vendor_id = PCI_VENDOR_ID_INTEL,
31     .device_id = PCI_DEVICE_ID_INTEL_82441,
32     .io_base = 0x1000,
33 };
34 #endif
35
36 static void init_memory(void)
37 {
38         /* push start and end of available memory to the stack
39          * so that the forth word QUIT can initialize memory
40          * management. For now we use hardcoded memory between
41          * 0x10000 and 0x9ffff (576k). If we need more memory
42          * than that we have serious bloat.
43          */
44
45         PUSH(0x10000);
46         PUSH(0x9FFFF);
47 }
48
49 static void
50 arch_init( void )
51 {
52         openbios_init();
53         modules_init();
54 #ifdef CONFIG_DRIVER_PCI
55         arch = &default_pci_host;
56         ob_pci_init();
57 #endif
58 #ifdef CONFIG_DRIVER_IDE
59         setup_timers();
60         ob_ide_init("/pci/isa", 0x1f0, 0x3f6, 0x170, 0x376);
61 #endif
62 #ifdef CONFIG_DRIVER_FLOPPY
63         ob_floppy_init("/isa", "floppy0", 0x3f0, 0);
64 #endif
65 #ifdef CONFIG_XBOX
66         setup_video();
67
68         /* Force video to 32-bit depth */
69         VIDEO_DICT_VALUE(video.depth) = 32;
70
71         init_video();
72         node_methods_init();
73 #endif
74         device_end();
75         bind_func("platform-boot", boot );
76         bind_func("(go)", go );
77 }
78
79 extern struct _console_ops arch_console_ops;
80
81 int openbios(void)
82 {
83 #ifdef CONFIG_DEBUG_CONSOLE
84         init_console(arch_console_ops);
85 #ifdef CONFIG_DEBUG_CONSOLE_SERIAL
86         uart_init(CONFIG_SERIAL_PORT, CONFIG_SERIAL_SPEED);
87 #endif
88         /* Clear the screen.  */
89         cls();
90 #endif
91
92         collect_sys_info(&sys_info);
93
94         dict = (unsigned char *)sys_info.dict_start;
95         dicthead = (cell)sys_info.dict_end;
96         last = sys_info.dict_last;
97         dictlimit = sys_info.dict_limit;
98
99         forth_init();
100
101         relocate(&sys_info);
102
103 #ifdef CONFIG_DEBUG_CONSOLE_VGA
104         video_init();
105 #endif
106 #ifdef CONFIG_DEBUG_BOOT
107         printk("forth started.\n");
108         printk("initializing memory...");
109 #endif
110
111         init_memory();
112
113 #ifdef CONFIG_DEBUG_BOOT
114         printk("done\n");
115 #endif
116
117         PUSH_xt( bind_noname_func(arch_init) );
118         fword("PREPOST-initializer");
119
120         PC = (ucell)findword("initialize-of");
121
122         if (!PC) {
123                 printk("panic: no dictionary entry point.\n");
124                 return -1;
125         }
126 #ifdef CONFIG_DEBUG_DICTIONARY
127         printk("done (%d bytes).\n", dicthead);
128         printk("Jumping to dictionary...\n");
129 #endif
130
131         enterforth((xt_t)PC);
132
133         return 0;
134 }