Rev 3674 | Rev 4344 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3674 | Rev 4338 | ||
---|---|---|---|
Line 59... | Line 59... | ||
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 | - | ||
90 | 81 | ||
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 | - | ||
105 | //printf("Sending ipi %d on %d\n",ipi,CPU->id); |
- | |
106 | for(id=0;id<256;id++) |
- | |
107 | for(eid=0;eid<256;eid++) |
- | |
108 | if((id!=myid) || (eid!=myeid)) |
- | |
109 | if(cpu_by_id_eid_list[id][eid]) |
- | |
110 | ipi_send_ipi(id,eid,ipi); |
- | |
111 | 95 | ||
- | 96 | for (id = 0; id < 256; id++) |
|
- | 97 | for (eid = 0; eid < 256; eid++) |
|
- | 98 | if ((id != myid) || (eid != myeid)) |
|
- | 99 | if (cpu_by_id_eid_list[id][eid]) |
|
- | 100 | ipi_send_ipi(id, eid, ipi); |
|
112 | } |
101 | } |
113 | 102 | ||
114 | - | ||
115 | void smp_init(void) |
103 | void smp_init(void) |
116 | { |
104 | { |
117 | if(!bootinfo->hello_configured) return; |
105 | if (!bootinfo->hello_configured) |
- | 106 | return; |
|
- | 107 | ||
- | 108 | /* |
|
118 | //If we have not system prepared by hello, we are not able to start AP's |
109 | * If we have not got system prepared by hello, we are not able to start |
119 | //this means we are running on simulator |
110 | * AP's. This means we are running on a simulator. |
- | 111 | */ |
|
120 | 112 | ||
121 | sapic_init(); |
113 | sapic_init(); |
122 | ipi_broadcast_arch_all(bootinfo->wakeup_intno); |
114 | ipi_broadcast_arch_all(bootinfo->wakeup_intno); |
123 | volatile long long brk; |
115 | volatile long long brk; |
124 | 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 */ |
|
125 | 118 | ||
126 | config.cpu_count=0; |
119 | config.cpu_count = 0; |
127 | int id,eid; |
120 | int id, eid; |
128 | 121 | ||
129 | for(id=0;id<256;id++) |
122 | for (id = 0; id < 256; id++) |
130 | for(eid=0;eid<256;eid++) |
123 | for (eid = 0; eid < 256; eid++) |
131 | if(cpu_by_id_eid_list[id][eid]==1){ |
124 | if (cpu_by_id_eid_list[id][eid] == 1) { |
132 | config.cpu_count++; |
125 | config.cpu_count++; |
133 | cpu_by_id_eid_list[id][eid]=2; |
126 | cpu_by_id_eid_list[id][eid] = 2; |
134 | - | ||
135 | } |
127 | } |
136 | } |
128 | } |
137 | 129 | ||
138 | - | ||
139 | void kmp(void *arg __attribute__((unused))) |
130 | void kmp(void *arg __attribute__((unused))) |
140 | { |
131 | { |
141 | int id,eid; |
132 | int id, eid; |
142 | int myid,myeid; |
133 | int myid, myeid; |
143 | 134 | ||
144 | myid=ia64_get_cpu_id(); |
135 | myid = ia64_get_cpu_id(); |
145 | myeid=ia64_get_cpu_eid(); |
136 | myeid = ia64_get_cpu_eid(); |
146 | 137 | ||
147 | for(id=0;id<256;id++) |
138 | for (id = 0; id < 256; id++) |
148 | for(eid=0;eid<256;eid++) |
139 | for (eid = 0; eid < 256; eid++) |
149 | if((id!=myid) || (eid!=myeid)) |
140 | if ((id != myid) || (eid != myeid)) |
150 | if(cpu_by_id_eid_list[id][eid]!=0){ |
141 | if (cpu_by_id_eid_list[id][eid] != 0) { |
151 | if(cpu_by_id_eid_list[id][eid]==1){ |
142 | if (cpu_by_id_eid_list[id][eid] == 1) { |
152 | - | ||
153 | //config.cpu_count++; |
143 | printf("Found Late CPU ID:%d " |
154 | //cpu_by_id_eid_list[id][eid]=2; |
144 | "EDI:%d Not added to " |
155 | printf("Found Late CPU ID:%d EDI:%d Not added to system!!!\n",id,eid); |
145 | "system!!!\n", id, eid); |
156 | continue; |
146 | continue; |
157 | } |
147 | } |
158 | cpu_by_id_eid_list[id][eid]=3; |
148 | cpu_by_id_eid_list[id][eid] = 3; |
159 | /* |
149 | /* |
160 | * There may be just one AP being initialized at |
150 | * There may be just one AP being |
- | 151 | * initialized at the time. After |
|
161 | * the time. After it comes completely up, it is |
152 | * it comes completely up, it is |
162 | * supposed to wake us up. |
153 | * supposed to wake us up. |
163 | */ |
154 | */ |
- | 155 | if (waitq_sleep_timeout( |
|
164 | if (waitq_sleep_timeout(&ap_completion_wq, 1000000, |
156 | &ap_completion_wq, 1000000, |
165 | SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) { |
157 | SYNCH_FLAGS_NONE) == |
- | 158 | ESYNCH_TIMEOUT) { |
|
166 | printf("%s: waiting for cpu ID:%d EID:%d" |
159 | printf("%s: waiting for cpu " |
167 | "timed out\n", __FUNCTION__, |
160 | "ID:%d EID:%d timed out\n", |
168 | id, eid); |
161 | __FUNCTION__, id, eid); |
169 | } |
162 | } |
170 | - | ||
171 | } |
163 | } |
172 | } |
164 | } |
173 | #endif |
- | |
174 | - | ||
175 | - | ||
176 | /*This is just a hack for linking with assembler - may be removed in future*/ |
- | |
177 | #ifndef CONFIG_SMP |
- | |
178 | void main_ap(void); |
- | |
179 | void main_ap(void) |
- | |
180 | { |
- | |
181 | while(1); |
- | |
182 | } |
- | |
183 | 165 | ||
184 | #endif |
166 | #endif |
185 | 167 | ||
186 | /** @} |
168 | /** @} |
187 | */ |
169 | */ |