Rev 4346 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3578 | vana | 1 | /* |
2 | * Copyright (c) 2005 Jakub Vana |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions |
||
7 | * are met: |
||
8 | * |
||
9 | * - Redistributions of source code must retain the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer. |
||
11 | * - Redistributions in binary form must reproduce the above copyright |
||
12 | * notice, this list of conditions and the following disclaimer in the |
||
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 |
||
15 | * derived from this software without specific prior written permission. |
||
16 | * |
||
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 |
||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
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 |
||
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 |
||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | */ |
||
28 | |||
29 | /** @addtogroup ia64 |
||
30 | * @{ |
||
31 | */ |
||
32 | /** @file |
||
33 | */ |
||
34 | |||
35 | #include <arch.h> |
||
4348 | svoboda | 36 | #include <arch/drivers/ski.h> |
3578 | vana | 37 | #include <arch/drivers/it.h> |
38 | #include <arch/interrupt.h> |
||
39 | #include <arch/barrier.h> |
||
40 | #include <arch/asm.h> |
||
41 | #include <arch/register.h> |
||
42 | #include <arch/types.h> |
||
43 | #include <arch/context.h> |
||
44 | #include <arch/stack.h> |
||
45 | #include <arch/mm/page.h> |
||
46 | #include <mm/as.h> |
||
47 | #include <config.h> |
||
48 | #include <userspace.h> |
||
49 | #include <console/console.h> |
||
50 | #include <proc/uarg.h> |
||
51 | #include <syscall/syscall.h> |
||
52 | #include <ddi/irq.h> |
||
53 | #include <ddi/device.h> |
||
54 | #include <arch/bootinfo.h> |
||
55 | #include <smp/smp.h> |
||
56 | #include <smp/ipi.h> |
||
57 | #include <arch/atomic.h> |
||
58 | #include <panic.h> |
||
59 | #include <print.h> |
||
60 | |||
61 | #ifdef CONFIG_SMP |
||
62 | |||
63 | extern char cpu_by_id_eid_list[256][256]; |
||
64 | |||
65 | static void sapic_init(void) |
||
66 | { |
||
4338 | svoboda | 67 | bootinfo->sapic = (unative_t *)(PA2KA((unative_t)(bootinfo->sapic)) | |
68 | FW_OFFSET); |
||
3578 | vana | 69 | } |
70 | |||
4338 | svoboda | 71 | static void ipi_broadcast_arch_all(int ipi) |
3578 | vana | 72 | { |
4338 | svoboda | 73 | int id, eid; |
74 | int myid, myeid; |
||
3578 | vana | 75 | |
4338 | svoboda | 76 | myid = ia64_get_cpu_id(); |
77 | myeid = ia64_get_cpu_eid(); |
||
3578 | vana | 78 | |
4338 | svoboda | 79 | for (id = 0; id < 256; id++) |
80 | for (eid = 0; eid < 256; eid++) |
||
81 | if ((id != myid) || (eid != myeid)) |
||
82 | ipi_send_ipi(id, eid, ipi); |
||
3578 | vana | 83 | } |
84 | |||
85 | void ipi_broadcast_arch(int ipi ) |
||
86 | { |
||
4338 | svoboda | 87 | int id, eid; |
88 | int myid, myeid; |
||
3674 | svoboda | 89 | |
4338 | svoboda | 90 | myid = ia64_get_cpu_id(); |
91 | myeid = ia64_get_cpu_eid(); |
||
3674 | svoboda | 92 | |
4338 | svoboda | 93 | for (id = 0; id < 256; id++) |
94 | for (eid = 0; eid < 256; eid++) |
||
95 | if ((id != myid) || (eid != myeid)) |
||
96 | if (cpu_by_id_eid_list[id][eid]) |
||
97 | ipi_send_ipi(id, eid, ipi); |
||
3578 | vana | 98 | } |
99 | |||
100 | void smp_init(void) |
||
101 | { |
||
4338 | svoboda | 102 | if (!bootinfo->hello_configured) |
103 | return; |
||
3674 | svoboda | 104 | |
4338 | svoboda | 105 | /* |
106 | * If we have not got system prepared by hello, we are not able to start |
||
107 | * AP's. This means we are running on a simulator. |
||
108 | */ |
||
109 | |||
3578 | vana | 110 | sapic_init(); |
111 | ipi_broadcast_arch_all(bootinfo->wakeup_intno); |
||
112 | volatile long long brk; |
||
4338 | svoboda | 113 | for (brk = 0; brk < 100LL * 1024LL * 1024LL; brk++) |
114 | ; /* wait a while before CPUs starts */ |
||
3578 | vana | 115 | |
4338 | svoboda | 116 | config.cpu_count = 0; |
117 | int id, eid; |
||
3578 | vana | 118 | |
4338 | svoboda | 119 | for (id = 0; id < 256; id++) |
120 | for (eid = 0; eid < 256; eid++) |
||
121 | if (cpu_by_id_eid_list[id][eid] == 1) { |
||
3578 | vana | 122 | config.cpu_count++; |
4338 | svoboda | 123 | cpu_by_id_eid_list[id][eid] = 2; |
3578 | vana | 124 | } |
125 | } |
||
126 | |||
127 | void kmp(void *arg __attribute__((unused))) |
||
128 | { |
||
4338 | svoboda | 129 | int id, eid; |
130 | int myid, myeid; |
||
3578 | vana | 131 | |
4338 | svoboda | 132 | myid = ia64_get_cpu_id(); |
133 | myeid = ia64_get_cpu_eid(); |
||
3578 | vana | 134 | |
4338 | svoboda | 135 | for (id = 0; id < 256; id++) |
136 | for (eid = 0; eid < 256; eid++) |
||
137 | if ((id != myid) || (eid != myeid)) |
||
138 | if (cpu_by_id_eid_list[id][eid] != 0) { |
||
139 | if (cpu_by_id_eid_list[id][eid] == 1) { |
||
140 | printf("Found Late CPU ID:%d " |
||
141 | "EDI:%d Not added to " |
||
142 | "system!!!\n", id, eid); |
||
3578 | vana | 143 | continue; |
4338 | svoboda | 144 | } |
145 | cpu_by_id_eid_list[id][eid] = 3; |
||
3578 | vana | 146 | /* |
4338 | svoboda | 147 | * There may be just one AP being |
148 | * initialized at the time. After |
||
149 | * it comes completely up, it is |
||
3578 | vana | 150 | * supposed to wake us up. |
151 | */ |
||
4338 | svoboda | 152 | if (waitq_sleep_timeout( |
153 | &ap_completion_wq, 1000000, |
||
154 | SYNCH_FLAGS_NONE) == |
||
155 | ESYNCH_TIMEOUT) { |
||
156 | printf("%s: waiting for cpu " |
||
157 | "ID:%d EID:%d timed out\n", |
||
158 | __FUNCTION__, id, eid); |
||
159 | } |
||
3578 | vana | 160 | } |
161 | } |
||
162 | |||
163 | #endif |
||
164 | |||
165 | /** @} |
||
166 | */ |
||
167 |