Rev 3431 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3431 | Rev 4377 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * Copyright (c) 2001-2004 Jakub Jermar |
2 | * Copyright (c) 2001-2004 Jakub Jermar |
- | 3 | * Copyright (c) 2009 Jiri Svoboda |
|
- | 4 | * Copyright (c) 2009 Martin Decky |
|
3 | * All rights reserved. |
5 | * All rights reserved. |
4 | * |
6 | * |
5 | * Redistribution and use in source and binary forms, with or without |
7 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
8 | * modification, are permitted provided that the following conditions |
7 | * are met: |
9 | * are met: |
Line 36... | Line 38... | ||
36 | 38 | ||
37 | #include <arch/types.h> |
39 | #include <arch/types.h> |
38 | 40 | ||
39 | #include <arch/pm.h> |
41 | #include <arch/pm.h> |
40 | 42 | ||
- | 43 | #include <genarch/multiboot/multiboot.h> |
|
- | 44 | #include <genarch/drivers/legacy/ia32/io.h> |
|
41 | #include <arch/drivers/ega.h> |
45 | #include <genarch/drivers/ega/ega.h> |
42 | #include <arch/drivers/vesa.h> |
46 | #include <arch/drivers/vesa.h> |
- | 47 | #include <genarch/drivers/i8042/i8042.h> |
|
43 | #include <genarch/kbd/i8042.h> |
48 | #include <genarch/kbrd/kbrd.h> |
44 | #include <arch/drivers/i8254.h> |
49 | #include <arch/drivers/i8254.h> |
45 | #include <arch/drivers/i8259.h> |
50 | #include <arch/drivers/i8259.h> |
46 | 51 | ||
47 | #include <arch/context.h> |
52 | #include <arch/context.h> |
48 | 53 | ||
Line 59... | Line 64... | ||
59 | #include <arch/debugger.h> |
64 | #include <arch/debugger.h> |
60 | #include <arch/breakpoint.h> |
65 | #include <arch/breakpoint.h> |
61 | #include <proc/thread.h> |
66 | #include <proc/thread.h> |
62 | #include <syscall/syscall.h> |
67 | #include <syscall/syscall.h> |
63 | #include <console/console.h> |
68 | #include <console/console.h> |
64 | #include <ddi/device.h> |
69 | #include <sysinfo/sysinfo.h> |
- | 70 | #include <arch/boot/boot.h> |
|
65 | 71 | ||
66 | #ifdef CONFIG_SMP |
72 | #ifdef CONFIG_SMP |
67 | #include <arch/smp/apic.h> |
73 | #include <arch/smp/apic.h> |
68 | #endif |
74 | #endif |
69 | 75 | ||
- | 76 | /** Perform ia32-specific initialization before main_bsp() is called. |
|
- | 77 | * |
|
- | 78 | * @param signature Should contain the multiboot signature. |
|
- | 79 | * @param mi Pointer to the multiboot information structure. |
|
- | 80 | */ |
|
- | 81 | void arch_pre_main(uint32_t signature, const multiboot_info_t *mi) |
|
- | 82 | { |
|
- | 83 | /* Parse multiboot information obtained from the bootloader. */ |
|
- | 84 | multiboot_info_parse(signature, mi); |
|
- | 85 | ||
- | 86 | #ifdef CONFIG_SMP |
|
- | 87 | /* Copy AP bootstrap routines below 1 MB. */ |
|
- | 88 | memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, |
|
- | 89 | (size_t) &_hardcoded_unmapped_size); |
|
- | 90 | #endif |
|
- | 91 | } |
|
- | 92 | ||
70 | void arch_pre_mm_init(void) |
93 | void arch_pre_mm_init(void) |
71 | { |
94 | { |
72 | pm_init(); |
95 | pm_init(); |
73 | 96 | ||
74 | if (config.cpu_active == 1) { |
97 | if (config.cpu_active == 1) { |
Line 86... | Line 109... | ||
86 | /* Initialize IRQ routing */ |
109 | /* Initialize IRQ routing */ |
87 | irq_init(IRQ_COUNT, IRQ_COUNT); |
110 | irq_init(IRQ_COUNT, IRQ_COUNT); |
88 | 111 | ||
89 | /* hard clock */ |
112 | /* hard clock */ |
90 | i8254_init(); |
113 | i8254_init(); |
91 | 114 | ||
92 | #ifdef CONFIG_FB |
115 | #ifdef CONFIG_FB |
93 | if (vesa_present()) |
116 | if (vesa_present()) |
94 | vesa_init(); |
117 | vesa_init(); |
95 | else |
118 | else |
96 | #endif |
119 | #endif |
- | 120 | #ifdef CONFIG_EGA |
|
97 | ega_init(); /* video */ |
121 | ega_init(EGA_BASE, EGA_VIDEORAM); /* video */ |
- | 122 | #else |
|
- | 123 | {} |
|
- | 124 | #endif |
|
98 | 125 | ||
99 | /* Enable debugger */ |
126 | /* Enable debugger */ |
100 | debugger_init(); |
127 | debugger_init(); |
101 | 128 | ||
102 | #ifdef CONFIG_UDEBUG |
129 | #ifdef CONFIG_UDEBUG |
Line 127... | Line 154... | ||
127 | } |
154 | } |
128 | } |
155 | } |
129 | 156 | ||
130 | void arch_post_smp_init(void) |
157 | void arch_post_smp_init(void) |
131 | { |
158 | { |
- | 159 | #ifdef CONFIG_PC_KBD |
|
- | 160 | /* |
|
- | 161 | * Initialize the i8042 controller. Then initialize the keyboard |
|
- | 162 | * module and connect it to i8042. Enable keyboard interrupts. |
|
- | 163 | */ |
|
- | 164 | i8042_instance_t *i8042_instance = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); |
|
- | 165 | if (i8042_instance) { |
|
132 | devno_t kbd = device_assign_devno(); |
166 | kbrd_instance_t *kbrd_instance = kbrd_init(); |
- | 167 | if (kbrd_instance) { |
|
133 | devno_t mouse = device_assign_devno(); |
168 | indev_t *sink = stdin_wire(); |
- | 169 | indev_t *kbrd = kbrd_wire(kbrd_instance, sink); |
|
- | 170 | i8042_wire(i8042_instance, kbrd); |
|
- | 171 | trap_virtual_enable_irqs(1 << IRQ_KBD); |
|
- | 172 | } |
|
- | 173 | } |
|
- | 174 | ||
- | 175 | /* |
|
- | 176 | * This is the necessary evil until the userspace driver is entirely |
|
134 | /* keyboard controller */ |
177 | * self-sufficient. |
- | 178 | */ |
|
- | 179 | sysinfo_set_item_val("kbd", NULL, true); |
|
135 | i8042_init(kbd, IRQ_KBD, mouse, IRQ_MOUSE); |
180 | sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD); |
- | 181 | sysinfo_set_item_val("kbd.address.physical", NULL, |
|
- | 182 | (uintptr_t) I8042_BASE); |
|
- | 183 | sysinfo_set_item_val("kbd.address.kernel", NULL, |
|
- | 184 | (uintptr_t) I8042_BASE); |
|
- | 185 | #endif |
|
136 | } |
186 | } |
137 | 187 | ||
138 | void calibrate_delay_loop(void) |
188 | void calibrate_delay_loop(void) |
139 | { |
189 | { |
140 | i8254_calibrate_delay_loop(); |
190 | i8254_calibrate_delay_loop(); |
Line 163... | Line 213... | ||
163 | /** Acquire console back for kernel |
213 | /** Acquire console back for kernel |
164 | * |
214 | * |
165 | */ |
215 | */ |
166 | void arch_grab_console(void) |
216 | void arch_grab_console(void) |
167 | { |
217 | { |
- | 218 | #ifdef CONFIG_FB |
|
- | 219 | if (vesa_present()) |
|
168 | i8042_grab(); |
220 | vesa_redraw(); |
- | 221 | else |
|
- | 222 | #endif |
|
- | 223 | #ifdef CONFIG_EGA |
|
- | 224 | ega_redraw(); |
|
- | 225 | #else |
|
- | 226 | {} |
|
- | 227 | #endif |
|
169 | } |
228 | } |
- | 229 | ||
170 | /** Return console to userspace |
230 | /** Return console to userspace |
171 | * |
231 | * |
172 | */ |
232 | */ |
173 | void arch_release_console(void) |
233 | void arch_release_console(void) |
174 | { |
234 | { |
- | 235 | } |
|
- | 236 | ||
- | 237 | /** Construct function pointer |
|
- | 238 | * |
|
- | 239 | * @param fptr function pointer structure |
|
- | 240 | * @param addr function address |
|
- | 241 | * @param caller calling function address |
|
- | 242 | * |
|
- | 243 | * @return address of the function pointer |
|
- | 244 | * |
|
- | 245 | */ |
|
- | 246 | void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller) |
|
- | 247 | { |
|
175 | i8042_release(); |
248 | return addr; |
- | 249 | } |
|
- | 250 | ||
- | 251 | void arch_reboot(void) |
|
- | 252 | { |
|
- | 253 | #ifdef CONFIG_PC_KBD |
|
- | 254 | i8042_cpu_reset((i8042_t *) I8042_BASE); |
|
- | 255 | #endif |
|
176 | } |
256 | } |
177 | 257 | ||
178 | /** @} |
258 | /** @} |
179 | */ |
259 | */ |