Rev 3763 | Rev 3782 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3763 | Rev 3766 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2005 Jakub Vana |
2 | * Copyright (c) 2005 Jakub Vana |
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 ia64 |
29 | /** @addtogroup ia64 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #include <arch.h> |
35 | #include <arch.h> |
36 | #include <arch/ski/ski.h> |
36 | #include <arch/ski/ski.h> |
37 | #include <arch/drivers/it.h> |
37 | #include <arch/drivers/it.h> |
38 | #include <arch/interrupt.h> |
38 | #include <arch/interrupt.h> |
39 | #include <arch/barrier.h> |
39 | #include <arch/barrier.h> |
40 | #include <arch/asm.h> |
40 | #include <arch/asm.h> |
41 | #include <arch/register.h> |
41 | #include <arch/register.h> |
42 | #include <arch/types.h> |
42 | #include <arch/types.h> |
43 | #include <arch/context.h> |
43 | #include <arch/context.h> |
44 | #include <arch/stack.h> |
44 | #include <arch/stack.h> |
45 | #include <arch/mm/page.h> |
45 | #include <arch/mm/page.h> |
46 | #include <mm/as.h> |
46 | #include <mm/as.h> |
47 | #include <config.h> |
47 | #include <config.h> |
48 | #include <userspace.h> |
48 | #include <userspace.h> |
49 | #include <console/console.h> |
49 | #include <console/console.h> |
50 | #include <proc/uarg.h> |
50 | #include <proc/uarg.h> |
51 | #include <syscall/syscall.h> |
51 | #include <syscall/syscall.h> |
52 | #include <ddi/irq.h> |
52 | #include <ddi/irq.h> |
53 | #include <ddi/device.h> |
53 | #include <ddi/device.h> |
54 | #include <arch/drivers/ega.h> |
54 | #include <arch/drivers/ega.h> |
55 | #include <arch/bootinfo.h> |
55 | #include <arch/bootinfo.h> |
56 | #include <genarch/kbd/i8042.h> |
56 | #include <genarch/kbd/i8042.h> |
57 | #include <genarch/kbd/ns16550.h> |
57 | #include <genarch/kbd/ns16550.h> |
58 | #include <smp/smp.h> |
58 | #include <smp/smp.h> |
59 | #include <smp/ipi.h> |
59 | #include <smp/ipi.h> |
60 | #include <arch/atomic.h> |
60 | #include <arch/atomic.h> |
61 | #include <panic.h> |
61 | #include <panic.h> |
62 | #include <print.h> |
62 | #include <print.h> |
63 | 63 | ||
64 | - | ||
65 | - | ||
66 | - | ||
67 | - | ||
68 | - | ||
69 | #ifdef CONFIG_SMP |
64 | #ifdef CONFIG_SMP |
70 | 65 | ||
71 | - | ||
72 | extern char cpu_by_id_eid_list[256][256]; |
66 | extern char cpu_by_id_eid_list[256][256]; |
73 | 67 | ||
74 | - | ||
75 | static void sapic_init(void) |
68 | static void sapic_init(void) |
76 | { |
69 | { |
77 | bootinfo->sapic=(unative_t *)(PA2KA((unative_t)(bootinfo->sapic))|FW_OFFSET); |
70 | bootinfo->sapic = (unative_t *)(PA2KA((unative_t)(bootinfo->sapic)) | |
- | 71 | FW_OFFSET); |
|
78 | } |
72 | } |
79 | 73 | ||
80 | - | ||
81 | - | ||
82 | static void ipi_broadcast_arch_all(int ipi ) |
74 | static void ipi_broadcast_arch_all(int ipi) |
83 | { |
75 | { |
84 | int id,eid; |
76 | int id,eid; |
85 | int myid,myeid; |
77 | int myid, myeid; |
86 | 78 | ||
87 | myid=ia64_get_cpu_id(); |
79 | myid = ia64_get_cpu_id(); |
88 | myeid=ia64_get_cpu_eid(); |
80 | myeid = ia64_get_cpu_eid(); |
89 | 81 | ||
90 | - | ||
91 | for(id=0;id<256;id++) |
82 | for (id = 0; id < 256; id++) |
92 | for(eid=0;eid<256;eid++) |
83 | for (eid = 0; eid < 256; eid++) |
93 | if((id!=myid) || (eid!=myeid)) |
84 | if ((id != myid) || (eid != myeid)) |
94 | ipi_send_ipi(id,eid,ipi); |
85 | ipi_send_ipi(id, eid, ipi); |
95 | } |
86 | } |
96 | 87 | ||
97 | void ipi_broadcast_arch(int ipi ) |
88 | void ipi_broadcast_arch(int ipi ) |
98 | { |
89 | { |
99 | int id,eid; |
90 | int id,eid; |
100 | int myid,myeid; |
91 | int myid,myeid; |
101 | 92 | ||
102 | myid=ia64_get_cpu_id(); |
93 | myid = ia64_get_cpu_id(); |
103 | myeid=ia64_get_cpu_eid(); |
94 | myeid = ia64_get_cpu_eid(); |
104 | 95 | ||
105 | for(id=0;id<256;id++) |
96 | for (id = 0; id < 256; id++) |
106 | for(eid=0;eid<256;eid++) |
97 | for (eid = 0; eid < 256; eid++) |
107 | if((id!=myid) || (eid!=myeid)) |
98 | if ((id != myid) || (eid != myeid)) |
108 | if(cpu_by_id_eid_list[id][eid]) |
99 | if (cpu_by_id_eid_list[id][eid]) |
109 | ipi_send_ipi(id,eid,ipi); |
100 | ipi_send_ipi(id, eid, ipi); |
110 | - | ||
111 | } |
101 | } |
112 | 102 | ||
113 | - | ||
114 | void smp_init(void) |
103 | void smp_init(void) |
115 | { |
104 | { |
116 | if(!bootinfo->hello_configured) return; |
105 | if (!bootinfo->hello_configured) |
- | 106 | return; |
|
- | 107 | ||
- | 108 | /* |
|
117 | //If we have not system prepared by hello, we are not able to start AP's |
109 | * If we have not system prepared by hello, we are not able to start |
118 | //this means we are running on simulator |
110 | * AP's. This means we are running on a simulator. |
- | 111 | */ |
|
119 | 112 | ||
120 | sapic_init(); |
113 | sapic_init(); |
121 | ipi_broadcast_arch_all(bootinfo->wakeup_intno); |
114 | ipi_broadcast_arch_all(bootinfo->wakeup_intno); |
122 | volatile long long brk; |
115 | volatile long long brk; |
123 | for(brk=0;brk<100LL*1024LL*1024LL;brk++); //wait a while before CPUs starts |
116 | for (brk = 0; brk < 100LL * 1024LL * 1024LL; brk++) |
- | 117 | ; /* wait a while before CPUs starts */ |
|
124 | 118 | ||
125 | config.cpu_count=0; |
119 | config.cpu_count = 0; |
126 | int id,eid; |
120 | int id, eid; |
127 | 121 | ||
128 | for(id=0;id<256;id++) |
122 | for (id = 0; id < 256; id++) |
129 | for(eid=0;eid<256;eid++) |
123 | for (eid = 0; eid < 256; eid++) |
130 | if(cpu_by_id_eid_list[id][eid]==1){ |
124 | if (cpu_by_id_eid_list[id][eid] == 1) { |
131 | config.cpu_count++; |
125 | config.cpu_count++; |
132 | cpu_by_id_eid_list[id][eid]=2; |
126 | cpu_by_id_eid_list[id][eid] = 2; |
133 | - | ||
134 | } |
127 | } |
135 | } |
128 | } |
136 | 129 | ||
137 | - | ||
138 | void kmp(void *arg __attribute__((unused))) |
130 | void kmp(void *arg __attribute__((unused))) |
139 | { |
131 | { |
140 | int id,eid; |
132 | int id,eid; |
141 | int myid,myeid; |
133 | int myid, myeid; |
142 | 134 | ||
143 | myid=ia64_get_cpu_id(); |
135 | myid = ia64_get_cpu_id(); |
144 | myeid=ia64_get_cpu_eid(); |
136 | myeid = ia64_get_cpu_eid(); |
145 | 137 | ||
146 | for(id=0;id<256;id++) |
138 | for (id = 0; id < 256; id++) |
147 | for(eid=0;eid<256;eid++) |
139 | for (eid = 0; eid < 256; eid++) |
148 | if((id!=myid) || (eid!=myeid)) |
140 | if ((id != myid) || (eid != myeid)) |
149 | if(cpu_by_id_eid_list[id][eid]!=0){ |
141 | if (cpu_by_id_eid_list[id][eid] != 0) { |
150 | if(cpu_by_id_eid_list[id][eid]==1){ |
142 | if (cpu_by_id_eid_list[id][eid] == 1) { |
151 | printf("Found Late CPU ID:%d EDI:%d Not added to system!!!\n",id,eid); |
143 | printf("Found Late CPU ID:%d " |
- | 144 | "EDI:%d Not added to " |
|
- | 145 | "system!!!\n", id, eid); |
|
152 | continue; |
146 | continue; |
153 | } |
147 | } |
154 | cpu_by_id_eid_list[id][eid]=3; |
148 | cpu_by_id_eid_list[id][eid] = 3; |
155 | /* |
149 | /* |
156 | * There may be just one AP being initialized at |
150 | * There may be just one AP being |
- | 151 | * initialized at the time. After |
|
157 | * the time. After it comes completely up, it is |
152 | * it comes completely up, it is |
158 | * supposed to wake us up. |
153 | * supposed to wake us up. |
159 | */ |
154 | */ |
- | 155 | if (waitq_sleep_timeout( |
|
160 | if (waitq_sleep_timeout(&ap_completion_wq, 1000000, |
156 | &ap_completion_wq, 1000000, |
161 | SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) { |
157 | SYNCH_FLAGS_NONE) == |
- | 158 | ESYNCH_TIMEOUT) { |
|
162 | printf("%s: waiting for cpu ID:%d EID:%d" |
159 | printf("%s: waiting for cpu " |
163 | "timed out\n", __FUNCTION__, |
160 | "ID:%d EID:%d timed out\n", |
164 | id, eid); |
161 | __FUNCTION__, id, eid); |
165 | } |
162 | } |
166 | - | ||
167 | } |
163 | } |
168 | } |
164 | } |
- | 165 | ||
169 | #endif |
166 | #endif |
170 | 167 | ||
171 | 168 | ||
172 | /*This is just a hack for linking with assembler - may be removed in future*/ |
- | |
173 | #ifndef CONFIG_SMP |
169 | #ifndef CONFIG_SMP |
- | 170 | ||
- | 171 | /* This is just a hack for linking with assembler - may be removed in future. */ |
|
174 | void main_ap(void); |
172 | void main_ap(void); |
175 | void main_ap(void) |
173 | void main_ap(void) |
176 | { |
174 | { |
177 | while(1); |
175 | while(1) |
- | 176 | ; |
|
178 | } |
177 | } |
179 | 178 | ||
180 | #endif |
179 | #endif |
181 | 180 | ||
182 | /** @} |
181 | /** @} |
183 | */ |
182 | */ |
184 | 183 | ||
185 | 184 |