Rev 1901 | Rev 1993 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1901 | Rev 1928 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2005 Martin Decky |
2 | * Copyright (C) 2005 Martin Decky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup ppc32 |
29 | /** @addtogroup ppc32 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #include <arch.h> |
35 | #include <arch.h> |
36 | #include <arch/boot/boot.h> |
36 | #include <arch/boot/boot.h> |
37 | #include <arch/drivers/cuda.h> |
37 | #include <arch/drivers/cuda.h> |
38 | #include <arch/mm/memory_init.h> |
38 | #include <arch/mm/memory_init.h> |
39 | #include <arch/interrupt.h> |
39 | #include <arch/interrupt.h> |
40 | #include <genarch/fb/fb.h> |
40 | #include <genarch/fb/fb.h> |
41 | #include <userspace.h> |
41 | #include <userspace.h> |
42 | #include <proc/uarg.h> |
42 | #include <proc/uarg.h> |
43 | #include <console/console.h> |
43 | #include <console/console.h> |
- | 44 | #include <ddi/device.h> |
|
- | 45 | #include <ddi/irq.h> |
|
44 | #include <arch/drivers/pic.h> |
46 | #include <arch/drivers/pic.h> |
45 | 47 | ||
- | 48 | #define IRQ_COUNT 64 |
|
- | 49 | ||
46 | bootinfo_t bootinfo; |
50 | bootinfo_t bootinfo; |
47 | 51 | ||
48 | void arch_pre_main(void) |
52 | void arch_pre_main(void) |
49 | { |
53 | { |
50 | /* Setup usermode */ |
54 | /* Setup usermode */ |
51 | init.cnt = bootinfo.taskmap.count; |
55 | init.cnt = bootinfo.taskmap.count; |
52 | 56 | ||
53 | uint32_t i; |
57 | uint32_t i; |
54 | 58 | ||
55 | for (i = 0; i < bootinfo.taskmap.count; i++) { |
59 | for (i = 0; i < bootinfo.taskmap.count; i++) { |
56 | init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr); |
60 | init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr); |
57 | init.tasks[i].size = bootinfo.taskmap.tasks[i].size; |
61 | init.tasks[i].size = bootinfo.taskmap.tasks[i].size; |
58 | } |
62 | } |
59 | } |
63 | } |
60 | 64 | ||
61 | void arch_pre_mm_init(void) |
65 | void arch_pre_mm_init(void) |
62 | { |
66 | { |
63 | /* Initialize dispatch table */ |
67 | /* Initialize dispatch table */ |
64 | interrupt_init(); |
68 | interrupt_init(); |
65 | 69 | ||
66 | /* Start decrementer */ |
70 | /* Start decrementer */ |
67 | start_decrementer(); |
71 | start_decrementer(); |
68 | } |
72 | } |
69 | 73 | ||
70 | void arch_post_mm_init(void) |
74 | void arch_post_mm_init(void) |
71 | { |
75 | { |
72 | if (config.cpu_active == 1) { |
76 | if (config.cpu_active == 1) { |
- | 77 | /* Initialize framebuffer */ |
|
73 | fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline, false); |
78 | fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline, false); |
- | 79 | ||
- | 80 | /* Initialize IRQ routing */ |
|
- | 81 | irq_init(IRQ_COUNT, IRQ_COUNT); |
|
74 | 82 | ||
75 | /* Initialize PIC */ |
83 | /* Initialize PIC */ |
76 | pic_init(bootinfo.keyboard.addr, PAGE_SIZE); |
84 | pic_init(bootinfo.keyboard.addr, PAGE_SIZE); |
77 | 85 | ||
- | 86 | /* Initialize I/O controller */ |
|
78 | cuda_init(bootinfo.keyboard.addr + 0x16000, 2 * PAGE_SIZE); |
87 | cuda_init(device_assign_devno(), bootinfo.keyboard.addr + 0x16000, 2 * PAGE_SIZE); |
79 | 88 | ||
80 | /* Merge all zones to 1 big zone */ |
89 | /* Merge all zones to 1 big zone */ |
81 | zone_merge_all(); |
90 | zone_merge_all(); |
82 | } |
91 | } |
83 | } |
92 | } |
84 | 93 | ||
85 | void arch_post_cpu_init(void) |
94 | void arch_post_cpu_init(void) |
86 | { |
95 | { |
87 | } |
96 | } |
88 | 97 | ||
89 | void arch_pre_smp_init(void) |
98 | void arch_pre_smp_init(void) |
90 | { |
99 | { |
91 | memory_print_map(); |
100 | memory_print_map(); |
92 | } |
101 | } |
93 | 102 | ||
94 | void arch_post_smp_init(void) |
103 | void arch_post_smp_init(void) |
95 | { |
104 | { |
96 | } |
105 | } |
97 | 106 | ||
98 | void calibrate_delay_loop(void) |
107 | void calibrate_delay_loop(void) |
99 | { |
108 | { |
100 | } |
109 | } |
101 | 110 | ||
102 | void userspace(uspace_arg_t *kernel_uarg) |
111 | void userspace(uspace_arg_t *kernel_uarg) |
103 | { |
112 | { |
104 | 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); |
113 | 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); |
105 | 114 | ||
106 | /* Unreachable */ |
115 | /* Unreachable */ |
107 | for (;;) |
116 | for (;;) |
108 | ; |
117 | ; |
109 | } |
118 | } |
110 | 119 | ||
111 | /** Acquire console back for kernel |
120 | /** Acquire console back for kernel |
112 | * |
121 | * |
113 | */ |
122 | */ |
114 | void arch_grab_console(void) |
123 | void arch_grab_console(void) |
115 | { |
124 | { |
116 | cuda_grab(); |
125 | cuda_grab(); |
117 | } |
126 | } |
118 | 127 | ||
119 | /** Return console to userspace |
128 | /** Return console to userspace |
120 | * |
129 | * |
121 | */ |
130 | */ |
122 | void arch_release_console(void) |
131 | void arch_release_console(void) |
123 | { |
132 | { |
124 | cuda_release(); |
133 | cuda_release(); |
125 | } |
134 | } |
126 | 135 | ||
127 | /** @} |
136 | /** @} |
128 | */ |
137 | */ |
129 | 138 |