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 40... | Line 40... | ||
40 | #include <genarch/fb/fb.h> |
40 | #include <genarch/fb/fb.h> |
41 | #include <genarch/fb/visuals.h> |
41 | #include <genarch/fb/visuals.h> |
42 | #include <userspace.h> |
42 | #include <userspace.h> |
43 | #include <proc/uarg.h> |
43 | #include <proc/uarg.h> |
44 | #include <console/console.h> |
44 | #include <console/console.h> |
45 | #include <ddi/device.h> |
- | |
46 | #include <ddi/irq.h> |
45 | #include <ddi/irq.h> |
47 | #include <arch/drivers/pic.h> |
46 | #include <arch/drivers/pic.h> |
- | 47 | #include <macros.h> |
|
- | 48 | #include <string.h> |
|
48 | 49 | ||
49 | #define IRQ_COUNT 64 |
50 | #define IRQ_COUNT 64 |
50 | 51 | ||
51 | bootinfo_t bootinfo; |
52 | bootinfo_t bootinfo; |
52 | 53 | ||
- | 54 | /** Performs ppc32-specific initialization before main_bsp() is called. */ |
|
53 | void arch_pre_main(void) |
55 | void arch_pre_main(void) |
54 | { |
56 | { |
55 | /* Setup usermode */ |
- | |
56 | init.cnt = bootinfo.taskmap.count; |
57 | init.cnt = bootinfo.taskmap.count; |
57 | 58 | ||
58 | uint32_t i; |
59 | uint32_t i; |
59 | 60 | ||
60 | for (i = 0; i < bootinfo.taskmap.count; i++) { |
61 | for (i = 0; i < min3(bootinfo.taskmap.count, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) { |
61 | init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr); |
62 | init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr); |
62 | init.tasks[i].size = bootinfo.taskmap.tasks[i].size; |
63 | init.tasks[i].size = bootinfo.taskmap.tasks[i].size; |
- | 64 | strncpy(init.tasks[i].name, bootinfo.taskmap.tasks[i].name, |
|
- | 65 | CONFIG_TASK_NAME_BUFLEN); |
|
63 | } |
66 | } |
64 | } |
67 | } |
65 | 68 | ||
66 | void arch_pre_mm_init(void) |
69 | void arch_pre_mm_init(void) |
67 | { |
70 | { |
Line 73... | Line 76... | ||
73 | } |
76 | } |
74 | 77 | ||
75 | void arch_post_mm_init(void) |
78 | void arch_post_mm_init(void) |
76 | { |
79 | { |
77 | if (config.cpu_active == 1) { |
80 | if (config.cpu_active == 1) { |
- | 81 | ||
- | 82 | #ifdef CONFIG_FB |
|
78 | /* Initialize framebuffer */ |
83 | /* Initialize framebuffer */ |
- | 84 | if (bootinfo.screen.addr) { |
|
79 | unsigned int visual; |
85 | unsigned int visual; |
80 | 86 | ||
81 | switch (bootinfo.screen.bpp) { |
87 | switch (bootinfo.screen.bpp) { |
82 | case 8: |
88 | case 8: |
83 | visual = VISUAL_INDIRECT_8; |
89 | visual = VISUAL_INDIRECT_8; |
84 | break; |
90 | break; |
85 | case 16: |
91 | case 16: |
86 | visual = VISUAL_RGB_5_5_5; |
92 | visual = VISUAL_RGB_5_5_5; |
87 | break; |
93 | break; |
88 | case 24: |
94 | case 24: |
89 | visual = VISUAL_RGB_8_8_8; |
95 | visual = VISUAL_RGB_8_8_8; |
90 | break; |
96 | break; |
91 | case 32: |
97 | case 32: |
92 | visual = VISUAL_RGB_0_8_8_8; |
98 | visual = VISUAL_RGB_0_8_8_8; |
93 | break; |
99 | break; |
94 | default: |
100 | default: |
95 | panic("Unsupported bits per pixel"); |
101 | panic("Unsupported bits per pixel."); |
- | 102 | } |
|
- | 103 | fb_properties_t prop = { |
|
- | 104 | .addr = bootinfo.screen.addr, |
|
- | 105 | .offset = 0, |
|
- | 106 | .x = bootinfo.screen.width, |
|
- | 107 | .y = bootinfo.screen.height, |
|
- | 108 | .scan = bootinfo.screen.scanline, |
|
- | 109 | .visual = visual, |
|
- | 110 | }; |
|
- | 111 | fb_init(&prop); |
|
96 | } |
112 | } |
97 | fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.scanline, visual); |
- | |
- | 113 | #endif |
|
98 | 114 | ||
99 | /* Initialize IRQ routing */ |
115 | /* Initialize IRQ routing */ |
100 | irq_init(IRQ_COUNT, IRQ_COUNT); |
116 | irq_init(IRQ_COUNT, IRQ_COUNT); |
101 | - | ||
102 | /* Initialize PIC */ |
- | |
103 | pic_init(bootinfo.keyboard.addr, PAGE_SIZE); |
- | |
104 | 117 | ||
- | 118 | if (bootinfo.macio.addr) { |
|
- | 119 | /* Initialize PIC */ |
|
- | 120 | pic_init(bootinfo.macio.addr, PAGE_SIZE); |
|
- | 121 | ||
105 | /* Initialize I/O controller */ |
122 | /* Initialize I/O controller */ |
106 | cuda_init(device_assign_devno(), bootinfo.keyboard.addr + 0x16000, 2 * PAGE_SIZE); |
123 | cuda_init(bootinfo.macio.addr + 0x16000, 2 * PAGE_SIZE); |
- | 124 | } |
|
107 | 125 | ||
108 | /* Merge all zones to 1 big zone */ |
126 | /* Merge all zones to 1 big zone */ |
109 | zone_merge_all(); |
127 | zone_merge_all(); |
110 | } |
128 | } |
111 | } |
129 | } |
Line 126... | Line 144... | ||
126 | { |
144 | { |
127 | } |
145 | } |
128 | 146 | ||
129 | void userspace(uspace_arg_t *kernel_uarg) |
147 | void userspace(uspace_arg_t *kernel_uarg) |
130 | { |
148 | { |
131 | userspace_asm((uintptr_t) kernel_uarg->uspace_uarg, (uintptr_t) kernel_uarg->uspace_stack + THREAD_STACK_SIZE - SP_DELTA, (uintptr_t) kernel_uarg->uspace_entry); |
149 | userspace_asm((uintptr_t) kernel_uarg->uspace_uarg, |
- | 150 | (uintptr_t) kernel_uarg->uspace_stack + |
|
- | 151 | THREAD_STACK_SIZE - SP_DELTA, |
|
- | 152 | (uintptr_t) kernel_uarg->uspace_entry); |
|
132 | 153 | ||
133 | /* Unreachable */ |
154 | /* Unreachable */ |
134 | for (;;) |
155 | while (true); |
135 | ; |
- | |
136 | } |
156 | } |
137 | 157 | ||
138 | /** Acquire console back for kernel |
158 | /** Acquire console back for kernel |
139 | * |
159 | * |
140 | */ |
160 | */ |
141 | void arch_grab_console(void) |
161 | void arch_grab_console(void) |
142 | { |
162 | { |
- | 163 | #ifdef CONFIG_FB |
|
143 | cuda_grab(); |
164 | fb_redraw(); |
- | 165 | #endif |
|
144 | } |
166 | } |
145 | 167 | ||
146 | /** Return console to userspace |
168 | /** Return console to userspace |
147 | * |
169 | * |
148 | */ |
170 | */ |
149 | void arch_release_console(void) |
171 | void arch_release_console(void) |
150 | { |
172 | { |
- | 173 | } |
|
- | 174 | ||
- | 175 | /** Construct function pointer |
|
- | 176 | * |
|
- | 177 | * @param fptr function pointer structure |
|
- | 178 | * @param addr function address |
|
- | 179 | * @param caller calling function address |
|
- | 180 | * |
|
- | 181 | * @return address of the function pointer |
|
- | 182 | * |
|
- | 183 | */ |
|
- | 184 | void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller) |
|
- | 185 | { |
|
151 | cuda_release(); |
186 | return addr; |
152 | } |
187 | } |
153 | 188 | ||
154 | /** @} |
189 | /** @} |
155 | */ |
190 | */ |