Rev 3386 | Rev 4263 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3386 | Rev 4153 | ||
|---|---|---|---|
| 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 58... | Line 63... | ||
| 58 | #include <ddi/irq.h> |
63 | #include <ddi/irq.h> |
| 59 | #include <arch/debugger.h> |
64 | #include <arch/debugger.h> |
| 60 | #include <proc/thread.h> |
65 | #include <proc/thread.h> |
| 61 | #include <syscall/syscall.h> |
66 | #include <syscall/syscall.h> |
| 62 | #include <console/console.h> |
67 | #include <console/console.h> |
| 63 | #include <ddi/device.h> |
68 | #include <sysinfo/sysinfo.h> |
| - | 69 | #include <arch/boot/boot.h> |
|
| 64 | 70 | ||
| 65 | #ifdef CONFIG_SMP |
71 | #ifdef CONFIG_SMP |
| 66 | #include <arch/smp/apic.h> |
72 | #include <arch/smp/apic.h> |
| 67 | #endif |
73 | #endif |
| 68 | 74 | ||
| - | 75 | /** Perform ia32-specific initialization before main_bsp() is called. |
|
| - | 76 | * |
|
| - | 77 | * @param signature Should contain the multiboot signature. |
|
| - | 78 | * @param mi Pointer to the multiboot information structure. |
|
| - | 79 | */ |
|
| - | 80 | void arch_pre_main(uint32_t signature, const multiboot_info_t *mi) |
|
| - | 81 | { |
|
| - | 82 | /* Parse multiboot information obtained from the bootloader. */ |
|
| - | 83 | multiboot_info_parse(signature, mi); |
|
| - | 84 | ||
| - | 85 | #ifdef CONFIG_SMP |
|
| - | 86 | /* Copy AP bootstrap routines below 1 MB. */ |
|
| - | 87 | memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET, |
|
| - | 88 | (size_t) &_hardcoded_unmapped_size); |
|
| - | 89 | #endif |
|
| - | 90 | } |
|
| - | 91 | ||
| 69 | void arch_pre_mm_init(void) |
92 | void arch_pre_mm_init(void) |
| 70 | { |
93 | { |
| 71 | pm_init(); |
94 | pm_init(); |
| 72 | 95 | ||
| 73 | if (config.cpu_active == 1) { |
96 | if (config.cpu_active == 1) { |
| Line 85... | Line 108... | ||
| 85 | /* Initialize IRQ routing */ |
108 | /* Initialize IRQ routing */ |
| 86 | irq_init(IRQ_COUNT, IRQ_COUNT); |
109 | irq_init(IRQ_COUNT, IRQ_COUNT); |
| 87 | 110 | ||
| 88 | /* hard clock */ |
111 | /* hard clock */ |
| 89 | i8254_init(); |
112 | i8254_init(); |
| 90 | 113 | ||
| 91 | #ifdef CONFIG_FB |
114 | #ifdef CONFIG_FB |
| 92 | if (vesa_present()) |
115 | if (vesa_present()) |
| 93 | vesa_init(); |
116 | vesa_init(); |
| 94 | else |
117 | else |
| 95 | #endif |
118 | #endif |
| - | 119 | #ifdef CONFIG_EGA |
|
| 96 | ega_init(); /* video */ |
120 | ega_init(EGA_BASE, EGA_VIDEORAM); /* video */ |
| - | 121 | #else |
|
| - | 122 | {} |
|
| - | 123 | #endif |
|
| 97 | 124 | ||
| 98 | /* Enable debugger */ |
125 | /* Enable debugger */ |
| 99 | debugger_init(); |
126 | debugger_init(); |
| 100 | /* Merge all memory zones to 1 big zone */ |
127 | /* Merge all memory zones to 1 big zone */ |
| 101 | zone_merge_all(); |
128 | zone_merge_all(); |
| Line 121... | Line 148... | ||
| 121 | } |
148 | } |
| 122 | } |
149 | } |
| 123 | 150 | ||
| 124 | void arch_post_smp_init(void) |
151 | void arch_post_smp_init(void) |
| 125 | { |
152 | { |
| - | 153 | #ifdef CONFIG_PC_KBD |
|
| - | 154 | /* |
|
| - | 155 | * Initialize the i8042 controller. Then initialize the keyboard |
|
| - | 156 | * module and connect it to i8042. Enable keyboard interrupts. |
|
| - | 157 | */ |
|
| 126 | devno_t kbd = device_assign_devno(); |
158 | indev_t *kbrdin = i8042_init((i8042_t *) I8042_BASE, IRQ_KBD); |
| - | 159 | if (kbrdin) { |
|
| - | 160 | kbrd_init(kbrdin); |
|
| 127 | devno_t mouse = device_assign_devno(); |
161 | trap_virtual_enable_irqs(1 << IRQ_KBD); |
| - | 162 | } |
|
| - | 163 | ||
| - | 164 | /* |
|
| - | 165 | * This is the necessary evil until the userspace driver is entirely |
|
| 128 | /* keyboard controller */ |
166 | * self-sufficient. |
| - | 167 | */ |
|
| - | 168 | sysinfo_set_item_val("kbd", NULL, true); |
|
| 129 | i8042_init(kbd, IRQ_KBD, mouse, IRQ_MOUSE); |
169 | sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD); |
| - | 170 | sysinfo_set_item_val("kbd.address.physical", NULL, |
|
| - | 171 | (uintptr_t) I8042_BASE); |
|
| - | 172 | sysinfo_set_item_val("kbd.address.kernel", NULL, |
|
| - | 173 | (uintptr_t) I8042_BASE); |
|
| - | 174 | #endif |
|
| 130 | } |
175 | } |
| 131 | 176 | ||
| 132 | void calibrate_delay_loop(void) |
177 | void calibrate_delay_loop(void) |
| 133 | { |
178 | { |
| 134 | i8254_calibrate_delay_loop(); |
179 | i8254_calibrate_delay_loop(); |
| Line 157... | Line 202... | ||
| 157 | /** Acquire console back for kernel |
202 | /** Acquire console back for kernel |
| 158 | * |
203 | * |
| 159 | */ |
204 | */ |
| 160 | void arch_grab_console(void) |
205 | void arch_grab_console(void) |
| 161 | { |
206 | { |
| - | 207 | #ifdef CONFIG_FB |
|
| - | 208 | if (vesa_present()) |
|
| 162 | i8042_grab(); |
209 | vesa_redraw(); |
| - | 210 | else |
|
| - | 211 | #endif |
|
| - | 212 | #ifdef CONFIG_EGA |
|
| - | 213 | ega_redraw(); |
|
| - | 214 | #else |
|
| - | 215 | {} |
|
| - | 216 | #endif |
|
| 163 | } |
217 | } |
| - | 218 | ||
| 164 | /** Return console to userspace |
219 | /** Return console to userspace |
| 165 | * |
220 | * |
| 166 | */ |
221 | */ |
| 167 | void arch_release_console(void) |
222 | void arch_release_console(void) |
| 168 | { |
223 | { |
| - | 224 | } |
|
| - | 225 | ||
| - | 226 | /** Construct function pointer |
|
| - | 227 | * |
|
| - | 228 | * @param fptr function pointer structure |
|
| - | 229 | * @param addr function address |
|
| - | 230 | * @param caller calling function address |
|
| - | 231 | * |
|
| - | 232 | * @return address of the function pointer |
|
| - | 233 | * |
|
| - | 234 | */ |
|
| - | 235 | void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller) |
|
| - | 236 | { |
|
| 169 | i8042_release(); |
237 | return addr; |
| 170 | } |
238 | } |
| 171 | 239 | ||
| 172 | /** @} |
240 | /** @} |
| 173 | */ |
241 | */ |