Rev 4342 | Rev 4345 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4342 | Rev 4343 | ||
|---|---|---|---|
| Line 31... | Line 31... | ||
| 31 | */ |
31 | */ |
| 32 | /** @file |
32 | /** @file |
| 33 | */ |
33 | */ |
| 34 | 34 | ||
| 35 | #include <arch.h> |
35 | #include <arch.h> |
| 36 | #include <arch/boot.h> |
- | |
| 37 | #include <arch/cp0.h> |
36 | #include <arch/cp0.h> |
| 38 | #include <arch/exception.h> |
37 | #include <arch/exception.h> |
| 39 | #include <mm/as.h> |
38 | #include <mm/as.h> |
| 40 | 39 | ||
| 41 | #include <userspace.h> |
40 | #include <userspace.h> |
| Line 56... | Line 55... | ||
| 56 | #include <macros.h> |
55 | #include <macros.h> |
| 57 | #include <ddi/device.h> |
56 | #include <ddi/device.h> |
| 58 | 57 | ||
| 59 | #include <arch/asm/regname.h> |
58 | #include <arch/asm/regname.h> |
| 60 | 59 | ||
| 61 | /* Size of the code jumping to the exception handler code |
60 | /* Size of the code jumping to the exception handler code |
| 62 | * - J+NOP |
61 | * - J+NOP |
| 63 | */ |
62 | */ |
| 64 | #define EXCEPTION_JUMP_SIZE 8 |
63 | #define EXCEPTION_JUMP_SIZE 8 |
| 65 | 64 | ||
| 66 | #define TLB_EXC ((char *) 0x80000000) |
65 | #define TLB_EXC ((char *) 0x80000000) |
| 67 | #define NORM_EXC ((char *) 0x80000180) |
66 | #define NORM_EXC ((char *) 0x80000180) |
| 68 | #define CACHE_EXC ((char *) 0x80000100) |
67 | #define CACHE_EXC ((char *) 0x80000100) |
| 69 | 68 | ||
| 70 | 69 | ||
| 71 | /* Why the linker moves the variable 64K away in assembler |
70 | /* Why the linker moves the variable 64K away in assembler |
| 72 | * when not in .text section ???????? |
71 | * when not in .text section? |
| 73 | */ |
72 | */ |
| 74 | uintptr_t supervisor_sp __attribute__ ((section (".text"))); |
- | |
| - | 73 | ||
| 75 | /* Stack pointer saved when entering user mode */ |
74 | /* Stack pointer saved when entering user mode */ |
| 76 | /* TODO: How do we do it on SMP system???? */ |
- | |
| 77 | bootinfo_t bootinfo __attribute__ ((section (".text"))); |
75 | uintptr_t supervisor_sp __attribute__ ((section (".text"))); |
| - | 76 | ||
| - | 77 | count_t cpu_count = 0; |
|
| 78 | 78 | ||
| 79 | void arch_pre_main(void) |
79 | void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo) |
| 80 | { |
80 | { |
| 81 | /* Setup usermode */ |
81 | /* Setup usermode */ |
| 82 | init.cnt = bootinfo.cnt; |
82 | init.cnt = bootinfo->cnt; |
| 83 | 83 | ||
| 84 | uint32_t i; |
84 | count_t i; |
| - | 85 | for (i = 0; i < min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) { |
|
| - | 86 | init.tasks[i].addr = bootinfo->tasks[i].addr; |
|
| - | 87 | init.tasks[i].size = bootinfo->tasks[i].size; |
|
| - | 88 | } |
|
| 85 | 89 | ||
| 86 | for (i = 0; i < bootinfo.cnt; i++) { |
90 | for (i = 0; i < CPUMAP_MAX_RECORDS; i++) { |
| 87 | init.tasks[i].addr = bootinfo.tasks[i].addr; |
91 | if ((bootinfo->cpumap & (1 << i)) != 0) |
| 88 | init.tasks[i].size = bootinfo.tasks[i].size; |
92 | cpu_count++; |
| 89 | } |
93 | } |
| 90 | } |
94 | } |
| 91 | 95 | ||
| 92 | void arch_pre_mm_init(void) |
96 | void arch_pre_mm_init(void) |
| 93 | { |
97 | { |
| Line 135... | Line 139... | ||
| 135 | .visual = VISUAL_BGR_8_8_8, |
139 | .visual = VISUAL_BGR_8_8_8, |
| 136 | }; |
140 | }; |
| 137 | fb_init(&gxemul_prop); |
141 | fb_init(&gxemul_prop); |
| 138 | #endif |
142 | #endif |
| 139 | 143 | ||
| 140 | #ifdef msim |
144 | #ifdef MACHINE_msim |
| 141 | sysinfo_set_item_val("machine.msim", NULL, 1); |
145 | sysinfo_set_item_val("machine.msim", NULL, 1); |
| 142 | #endif |
146 | #endif |
| 143 | 147 | ||
| 144 | #ifdef simics |
148 | #ifdef MACHINE_simics |
| 145 | sysinfo_set_item_val("machine.simics", NULL, 1); |
149 | sysinfo_set_item_val("machine.simics", NULL, 1); |
| 146 | #endif |
150 | #endif |
| 147 | 151 | ||
| 148 | #ifdef bgxemul |
152 | #ifdef MACHINE_bgxemul |
| 149 | sysinfo_set_item_val("machine.bgxemul", NULL, 1); |
153 | sysinfo_set_item_val("machine.bgxemul", NULL, 1); |
| 150 | #endif |
154 | #endif |
| 151 | 155 | ||
| 152 | #ifdef lgxemul |
156 | #ifdef MACHINE_lgxemul |
| 153 | sysinfo_set_item_val("machine.lgxemul", NULL, 1); |
157 | sysinfo_set_item_val("machine.lgxemul", NULL, 1); |
| 154 | #endif |
158 | #endif |
| 155 | } |
159 | } |
| 156 | 160 | ||
| 157 | void arch_post_cpu_init(void) |
161 | void arch_post_cpu_init(void) |
| Line 164... | Line 168... | ||
| 164 | 168 | ||
| 165 | void arch_post_smp_init(void) |
169 | void arch_post_smp_init(void) |
| 166 | { |
170 | { |
| 167 | } |
171 | } |
| 168 | 172 | ||
| - | 173 | void calibrate_delay_loop(void) |
|
| - | 174 | { |
|
| - | 175 | } |
|
| - | 176 | ||
| 169 | void userspace(uspace_arg_t *kernel_uarg) |
177 | void userspace(uspace_arg_t *kernel_uarg) |
| 170 | { |
178 | { |
| 171 | /* EXL = 1, UM = 1, IE = 1 */ |
179 | /* EXL = 1, UM = 1, IE = 1 */ |
| 172 | cp0_status_write(cp0_status_read() | (cp0_status_exl_exception_bit | |
180 | cp0_status_write(cp0_status_read() | (cp0_status_exl_exception_bit | |
| 173 | cp0_status_um_bit | cp0_status_ie_enabled_bit)); |
181 | cp0_status_um_bit | cp0_status_ie_enabled_bit)); |