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 .host_ranges = {
34 { .type = IO_SPACE, .parentaddr = 0, .childaddr = 0x1000, .len = 0 },
35 { .type = 0, .parentaddr = 0, .childaddr = 0, .len = 0 }
36 }
37 };
38 #endif
39
init_memory(void)40 static void init_memory(void)
41 {
42 /* push start and end of available memory to the stack
43 * so that the forth word QUIT can initialize memory
44 * management. For now we use hardcoded memory between
45 * 0x10000 and 0x9ffff (576k). If we need more memory
46 * than that we have serious bloat.
47 */
48
49 PUSH(0x10000);
50 PUSH(0x9FFFF);
51 }
52
53 static void
arch_init(void)54 arch_init( void )
55 {
56 openbios_init();
57 modules_init();
58 #ifdef CONFIG_DRIVER_PCI
59 arch = &default_pci_host;
60
61 push_str("/");
62 fword("find-device");
63 feval("\" /\" open-dev to my-self");
64
65 ob_pci_init();
66
67 feval("0 to my-self");
68 #endif
69 #ifdef CONFIG_DRIVER_IDE
70 setup_timers();
71 ob_ide_init("/pci/isa", 0x1f0, 0x3f6, 0x170, 0x376);
72 #endif
73 #ifdef CONFIG_DRIVER_FLOPPY
74 ob_floppy_init("/isa", "floppy0", 0x3f0, 0);
75 #endif
76 #ifdef CONFIG_XBOX
77 setup_video();
78
79 /* Force video to 32-bit depth */
80 VIDEO_DICT_VALUE(video.depth) = 32;
81
82 init_video();
83 node_methods_init();
84 #endif
85 device_end();
86 bind_func("platform-boot", boot );
87 }
88
89 extern struct _console_ops arch_console_ops;
90
openbios(void)91 int openbios(void)
92 {
93 #ifdef CONFIG_DEBUG_CONSOLE
94 init_console(arch_console_ops);
95 #ifdef CONFIG_DEBUG_CONSOLE_SERIAL
96 uart_init(CONFIG_SERIAL_PORT, CONFIG_SERIAL_SPEED);
97 #endif
98 /* Clear the screen. */
99 cls();
100 #endif
101
102 collect_sys_info(&sys_info);
103
104 dict = (unsigned char *)sys_info.dict_start;
105 dicthead = (cell)sys_info.dict_end;
106 last = sys_info.dict_last;
107 dictlimit = sys_info.dict_limit;
108
109 forth_init();
110
111 relocate(&sys_info);
112
113 #ifdef CONFIG_DEBUG_CONSOLE_VGA
114 video_init();
115 #endif
116 #ifdef CONFIG_DEBUG_BOOT
117 printk("forth started.\n");
118 printk("initializing memory...");
119 #endif
120
121 init_memory();
122
123 #ifdef CONFIG_DEBUG_BOOT
124 printk("done\n");
125 #endif
126
127 PUSH_xt( bind_noname_func(arch_init) );
128 fword("PREPOST-initializer");
129
130 PC = (ucell)findword("initialize-of");
131
132 if (!PC) {
133 printk("panic: no dictionary entry point.\n");
134 return -1;
135 }
136 #ifdef CONFIG_DEBUG_DICTIONARY
137 printk("done (%d bytes).\n", dicthead);
138 printk("Jumping to dictionary...\n");
139 #endif
140
141 enterforth((xt_t)PC);
142
143 return 0;
144 }
145