Rev 128 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 128 | Rev 131 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2001-2005 Jakub Jermar |
2 | * Copyright (C) 2001-2005 Jakub Jermar |
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 | #ifdef __SMP__ |
29 | #ifdef __SMP__ |
30 | 30 | ||
31 | #include <config.h> |
31 | #include <config.h> |
32 | #include <print.h> |
32 | #include <print.h> |
33 | #include <debug.h> |
33 | #include <debug.h> |
34 | #include <arch/smp/mps.h> |
34 | #include <arch/smp/mps.h> |
35 | #include <arch/smp/apic.h> |
35 | #include <arch/smp/apic.h> |
36 | #include <arch/smp/smp.h> |
36 | #include <arch/smp/smp.h> |
37 | #include <func.h> |
37 | #include <func.h> |
38 | #include <arch/types.h> |
38 | #include <arch/types.h> |
39 | #include <typedefs.h> |
39 | #include <typedefs.h> |
40 | #include <mm/page.h> |
- | |
41 | #include <cpu.h> |
40 | #include <cpu.h> |
42 | #include <arch/asm.h> |
41 | #include <arch/asm.h> |
43 | #include <arch/bios/bios.h> |
42 | #include <arch/bios/bios.h> |
44 | 43 | ||
45 | /* |
44 | /* |
46 | * MultiProcessor Specification detection code. |
45 | * MultiProcessor Specification detection code. |
47 | */ |
46 | */ |
48 | 47 | ||
49 | #define FS_SIGNATURE 0x5f504d5f |
48 | #define FS_SIGNATURE 0x5f504d5f |
50 | #define CT_SIGNATURE 0x504d4350 |
49 | #define CT_SIGNATURE 0x504d4350 |
51 | 50 | ||
52 | int mps_fs_check(__u8 *base); |
51 | int mps_fs_check(__u8 *base); |
53 | int mps_ct_check(void); |
52 | int mps_ct_check(void); |
54 | 53 | ||
55 | int configure_via_ct(void); |
54 | int configure_via_ct(void); |
56 | int configure_via_default(__u8 n); |
55 | int configure_via_default(__u8 n); |
57 | 56 | ||
58 | int ct_processor_entry(struct __processor_entry *pr); |
57 | int ct_processor_entry(struct __processor_entry *pr); |
59 | void ct_bus_entry(struct __bus_entry *bus); |
58 | void ct_bus_entry(struct __bus_entry *bus); |
60 | void ct_io_apic_entry(struct __io_apic_entry *ioa); |
59 | void ct_io_apic_entry(struct __io_apic_entry *ioa); |
61 | void ct_io_intr_entry(struct __io_intr_entry *iointr); |
60 | void ct_io_intr_entry(struct __io_intr_entry *iointr); |
62 | void ct_l_intr_entry(struct __l_intr_entry *lintr); |
61 | void ct_l_intr_entry(struct __l_intr_entry *lintr); |
63 | 62 | ||
64 | void ct_extended_entries(void); |
63 | void ct_extended_entries(void); |
65 | 64 | ||
66 | static struct mps_fs *fs; |
65 | static struct mps_fs *fs; |
67 | static struct mps_ct *ct; |
66 | static struct mps_ct *ct; |
68 | 67 | ||
69 | struct __processor_entry *processor_entries = NULL; |
68 | struct __processor_entry *processor_entries = NULL; |
70 | struct __bus_entry *bus_entries = NULL; |
69 | struct __bus_entry *bus_entries = NULL; |
71 | struct __io_apic_entry *io_apic_entries = NULL; |
70 | struct __io_apic_entry *io_apic_entries = NULL; |
72 | struct __io_intr_entry *io_intr_entries = NULL; |
71 | struct __io_intr_entry *io_intr_entries = NULL; |
73 | struct __l_intr_entry *l_intr_entries = NULL; |
72 | struct __l_intr_entry *l_intr_entries = NULL; |
74 | 73 | ||
75 | int processor_entry_cnt = 0; |
74 | int processor_entry_cnt = 0; |
76 | int bus_entry_cnt = 0; |
75 | int bus_entry_cnt = 0; |
77 | int io_apic_entry_cnt = 0; |
76 | int io_apic_entry_cnt = 0; |
78 | int io_intr_entry_cnt = 0; |
77 | int io_intr_entry_cnt = 0; |
79 | int l_intr_entry_cnt = 0; |
78 | int l_intr_entry_cnt = 0; |
80 | 79 | ||
81 | waitq_t ap_completion_wq; |
80 | waitq_t ap_completion_wq; |
82 | waitq_t kmp_completion_wq; |
81 | waitq_t kmp_completion_wq; |
83 | 82 | ||
84 | 83 | ||
85 | /* |
84 | /* |
86 | * Implementation of IA-32 SMP configuration interface. |
85 | * Implementation of IA-32 SMP configuration interface. |
87 | */ |
86 | */ |
88 | static count_t get_cpu_count(void); |
87 | static count_t get_cpu_count(void); |
89 | static bool is_cpu_enabled(index_t i); |
88 | static bool is_cpu_enabled(index_t i); |
90 | static bool is_bsp(index_t i); |
89 | static bool is_bsp(index_t i); |
91 | static __u8 get_cpu_apic_id(index_t i); |
90 | static __u8 get_cpu_apic_id(index_t i); |
92 | 91 | ||
93 | struct smp_config_operations mps_config_operations = { |
92 | struct smp_config_operations mps_config_operations = { |
94 | .cpu_count = get_cpu_count, |
93 | .cpu_count = get_cpu_count, |
95 | .cpu_enabled = is_cpu_enabled, |
94 | .cpu_enabled = is_cpu_enabled, |
96 | .cpu_bootstrap = is_bsp, |
95 | .cpu_bootstrap = is_bsp, |
97 | .cpu_apic_id = get_cpu_apic_id |
96 | .cpu_apic_id = get_cpu_apic_id |
98 | }; |
97 | }; |
99 | 98 | ||
100 | count_t get_cpu_count(void) |
99 | count_t get_cpu_count(void) |
101 | { |
100 | { |
102 | return processor_entry_cnt; |
101 | return processor_entry_cnt; |
103 | } |
102 | } |
104 | 103 | ||
105 | bool is_cpu_enabled(index_t i) |
104 | bool is_cpu_enabled(index_t i) |
106 | { |
105 | { |
107 | ASSERT(i < processor_entry_cnt); |
106 | ASSERT(i < processor_entry_cnt); |
108 | return processor_entries[i].cpu_flags & 0x1; |
107 | return processor_entries[i].cpu_flags & 0x1; |
109 | } |
108 | } |
110 | 109 | ||
111 | bool is_bsp(index_t i) |
110 | bool is_bsp(index_t i) |
112 | { |
111 | { |
113 | ASSERT(i < processor_entry_cnt); |
112 | ASSERT(i < processor_entry_cnt); |
114 | return processor_entries[i].cpu_flags & 0x2; |
113 | return processor_entries[i].cpu_flags & 0x2; |
115 | } |
114 | } |
116 | 115 | ||
117 | __u8 get_cpu_apic_id(index_t i) |
116 | __u8 get_cpu_apic_id(index_t i) |
118 | { |
117 | { |
119 | ASSERT(i < processor_entry_cnt); |
118 | ASSERT(i < processor_entry_cnt); |
120 | return processor_entries[i].l_apic_id; |
119 | return processor_entries[i].l_apic_id; |
121 | } |
120 | } |
122 | 121 | ||
123 | 122 | ||
124 | /* |
123 | /* |
125 | * Used to check the integrity of the MP Floating Structure. |
124 | * Used to check the integrity of the MP Floating Structure. |
126 | */ |
125 | */ |
127 | int mps_fs_check(__u8 *base) |
126 | int mps_fs_check(__u8 *base) |
128 | { |
127 | { |
129 | int i; |
128 | int i; |
130 | __u8 sum; |
129 | __u8 sum; |
131 | 130 | ||
132 | for (i = 0, sum = 0; i < 16; i++) |
131 | for (i = 0, sum = 0; i < 16; i++) |
133 | sum += base[i]; |
132 | sum += base[i]; |
134 | 133 | ||
135 | return !sum; |
134 | return !sum; |
136 | } |
135 | } |
137 | 136 | ||
138 | /* |
137 | /* |
139 | * Used to check the integrity of the MP Configuration Table. |
138 | * Used to check the integrity of the MP Configuration Table. |
140 | */ |
139 | */ |
141 | int mps_ct_check(void) |
140 | int mps_ct_check(void) |
142 | { |
141 | { |
143 | __u8 *base = (__u8 *) ct; |
142 | __u8 *base = (__u8 *) ct; |
144 | __u8 *ext = base + ct->base_table_length; |
143 | __u8 *ext = base + ct->base_table_length; |
145 | __u8 sum; |
144 | __u8 sum; |
146 | int i; |
145 | int i; |
147 | 146 | ||
148 | /* count the checksum for the base table */ |
147 | /* count the checksum for the base table */ |
149 | for (i=0,sum=0; i < ct->base_table_length; i++) |
148 | for (i=0,sum=0; i < ct->base_table_length; i++) |
150 | sum += base[i]; |
149 | sum += base[i]; |
151 | 150 | ||
152 | if (sum) |
151 | if (sum) |
153 | return 0; |
152 | return 0; |
154 | 153 | ||
155 | /* count the checksum for the extended table */ |
154 | /* count the checksum for the extended table */ |
156 | for (i=0,sum=0; i < ct->ext_table_length; i++) |
155 | for (i=0,sum=0; i < ct->ext_table_length; i++) |
157 | sum += ext[i]; |
156 | sum += ext[i]; |
158 | 157 | ||
159 | return sum == ct->ext_table_checksum; |
158 | return sum == ct->ext_table_checksum; |
160 | } |
159 | } |
161 | 160 | ||
162 | void mps_init(void) |
161 | void mps_init(void) |
163 | { |
162 | { |
164 | __u8 *addr[2] = { NULL, (__u8 *) 0xf0000 }; |
163 | __u8 *addr[2] = { NULL, (__u8 *) 0xf0000 }; |
165 | int i, j, length[2] = { 1024, 64*1024 }; |
164 | int i, j, length[2] = { 1024, 64*1024 }; |
166 | 165 | ||
167 | 166 | ||
168 | /* |
167 | /* |
169 | * Find MP Floating Pointer Structure |
168 | * Find MP Floating Pointer Structure |
170 | * 1a. search first 1K of EBDA |
169 | * 1a. search first 1K of EBDA |
171 | * 1b. if EBDA is undefined, search last 1K of base memory |
170 | * 1b. if EBDA is undefined, search last 1K of base memory |
172 | * 2. search 64K starting at 0xf0000 |
171 | * 2. search 64K starting at 0xf0000 |
173 | */ |
172 | */ |
174 | 173 | ||
175 | addr[0] = (__u8 *) (ebda ? ebda : 639 * 1024); |
174 | addr[0] = (__u8 *) (ebda ? ebda : 639 * 1024); |
176 | for (i = 0; i < 2; i++) { |
175 | for (i = 0; i < 2; i++) { |
177 | for (j = 0; j < length[i]; j += 16) { |
176 | for (j = 0; j < length[i]; j += 16) { |
178 | if (*((__u32 *) &addr[i][j]) == FS_SIGNATURE && mps_fs_check(&addr[i][j])) { |
177 | if (*((__u32 *) &addr[i][j]) == FS_SIGNATURE && mps_fs_check(&addr[i][j])) { |
179 | fs = (struct mps_fs *) &addr[i][j]; |
178 | fs = (struct mps_fs *) &addr[i][j]; |
180 | goto fs_found; |
179 | goto fs_found; |
181 | } |
180 | } |
182 | } |
181 | } |
183 | } |
182 | } |
184 | 183 | ||
185 | return; |
184 | return; |
186 | 185 | ||
187 | fs_found: |
186 | fs_found: |
188 | printf("%L: MPS Floating Pointer Structure\n", fs); |
187 | printf("%L: MPS Floating Pointer Structure\n", fs); |
189 | 188 | ||
190 | frame_not_free((__address) fs); |
189 | frame_not_free((__address) fs); |
191 | 190 | ||
192 | if (fs->config_type == 0 && fs->configuration_table) { |
191 | if (fs->config_type == 0 && fs->configuration_table) { |
193 | if (fs->mpfib2 >> 7) { |
192 | if (fs->mpfib2 >> 7) { |
194 | printf("%s: PIC mode not supported\n", __FUNCTION__); |
193 | printf("%s: PIC mode not supported\n", __FUNCTION__); |
195 | return; |
194 | return; |
196 | } |
195 | } |
197 | 196 | ||
198 | ct = fs->configuration_table; |
197 | ct = fs->configuration_table; |
199 | frame_not_free((__address) ct); |
198 | frame_not_free((__address) ct); |
200 | config.cpu_count = configure_via_ct(); |
199 | config.cpu_count = configure_via_ct(); |
201 | } |
200 | } |
202 | else |
201 | else |
203 | config.cpu_count = configure_via_default(fs->config_type); |
202 | config.cpu_count = configure_via_default(fs->config_type); |
204 | 203 | ||
205 | if (config.cpu_count > 1) { |
- | |
206 | map_page_to_frame((__address) l_apic, (__address) l_apic, PAGE_NOT_CACHEABLE, 0); |
- | |
207 | } |
- | |
208 | - | ||
209 | - | ||
210 | /* |
- | |
211 | * Must be initialized outside the kmp thread, since it is waited |
- | |
212 | * on before the kmp thread is created. |
- | |
213 | */ |
- | |
214 | waitq_initialize(&kmp_completion_wq); |
- | |
215 | return; |
204 | return; |
216 | } |
205 | } |
217 | 206 | ||
218 | int configure_via_ct(void) |
207 | int configure_via_ct(void) |
219 | { |
208 | { |
220 | __u8 *cur; |
209 | __u8 *cur; |
221 | int i, cnt; |
210 | int i, cnt; |
222 | 211 | ||
223 | if (ct->signature != CT_SIGNATURE) { |
212 | if (ct->signature != CT_SIGNATURE) { |
224 | printf("%s: bad ct->signature\n", __FUNCTION__); |
213 | printf("%s: bad ct->signature\n", __FUNCTION__); |
225 | return 1; |
214 | return 1; |
226 | } |
215 | } |
227 | if (!mps_ct_check()) { |
216 | if (!mps_ct_check()) { |
228 | printf("%s: bad ct checksum\n", __FUNCTION__); |
217 | printf("%s: bad ct checksum\n", __FUNCTION__); |
229 | return 1; |
218 | return 1; |
230 | } |
219 | } |
231 | if (ct->oem_table) { |
220 | if (ct->oem_table) { |
232 | printf("%s: ct->oem_table not supported\n", __FUNCTION__); |
221 | printf("%s: ct->oem_table not supported\n", __FUNCTION__); |
233 | return 1; |
222 | return 1; |
234 | } |
223 | } |
235 | 224 | ||
236 | l_apic = ct->l_apic; |
225 | l_apic = ct->l_apic; |
237 | 226 | ||
238 | cnt = 0; |
227 | cnt = 0; |
239 | cur = &ct->base_table[0]; |
228 | cur = &ct->base_table[0]; |
240 | for (i=0; i < ct->entry_count; i++) { |
229 | for (i=0; i < ct->entry_count; i++) { |
241 | switch (*cur) { |
230 | switch (*cur) { |
242 | /* Processor entry */ |
231 | /* Processor entry */ |
243 | case 0: |
232 | case 0: |
244 | processor_entries = processor_entries ? processor_entries : (struct __processor_entry *) cur; |
233 | processor_entries = processor_entries ? processor_entries : (struct __processor_entry *) cur; |
245 | processor_entry_cnt++; |
234 | processor_entry_cnt++; |
246 | cnt += ct_processor_entry((struct __processor_entry *) cur); |
235 | cnt += ct_processor_entry((struct __processor_entry *) cur); |
247 | cur += 20; |
236 | cur += 20; |
248 | break; |
237 | break; |
249 | 238 | ||
250 | /* Bus entry */ |
239 | /* Bus entry */ |
251 | case 1: |
240 | case 1: |
252 | bus_entries = bus_entries ? bus_entries : (struct __bus_entry *) cur; |
241 | bus_entries = bus_entries ? bus_entries : (struct __bus_entry *) cur; |
253 | bus_entry_cnt++; |
242 | bus_entry_cnt++; |
254 | ct_bus_entry((struct __bus_entry *) cur); |
243 | ct_bus_entry((struct __bus_entry *) cur); |
255 | cur += 8; |
244 | cur += 8; |
256 | break; |
245 | break; |
257 | 246 | ||
258 | /* I/O Apic */ |
247 | /* I/O Apic */ |
259 | case 2: |
248 | case 2: |
260 | io_apic_entries = io_apic_entries ? io_apic_entries : (struct __io_apic_entry *) cur; |
249 | io_apic_entries = io_apic_entries ? io_apic_entries : (struct __io_apic_entry *) cur; |
261 | io_apic_entry_cnt++; |
250 | io_apic_entry_cnt++; |
262 | ct_io_apic_entry((struct __io_apic_entry *) cur); |
251 | ct_io_apic_entry((struct __io_apic_entry *) cur); |
263 | cur += 8; |
252 | cur += 8; |
264 | break; |
253 | break; |
265 | 254 | ||
266 | /* I/O Interrupt Assignment */ |
255 | /* I/O Interrupt Assignment */ |
267 | case 3: |
256 | case 3: |
268 | io_intr_entries = io_intr_entries ? io_intr_entries : (struct __io_intr_entry *) cur; |
257 | io_intr_entries = io_intr_entries ? io_intr_entries : (struct __io_intr_entry *) cur; |
269 | io_intr_entry_cnt++; |
258 | io_intr_entry_cnt++; |
270 | ct_io_intr_entry((struct __io_intr_entry *) cur); |
259 | ct_io_intr_entry((struct __io_intr_entry *) cur); |
271 | cur += 8; |
260 | cur += 8; |
272 | break; |
261 | break; |
273 | 262 | ||
274 | /* Local Interrupt Assignment */ |
263 | /* Local Interrupt Assignment */ |
275 | case 4: |
264 | case 4: |
276 | l_intr_entries = l_intr_entries ? l_intr_entries : (struct __l_intr_entry *) cur; |
265 | l_intr_entries = l_intr_entries ? l_intr_entries : (struct __l_intr_entry *) cur; |
277 | l_intr_entry_cnt++; |
266 | l_intr_entry_cnt++; |
278 | ct_l_intr_entry((struct __l_intr_entry *) cur); |
267 | ct_l_intr_entry((struct __l_intr_entry *) cur); |
279 | cur += 8; |
268 | cur += 8; |
280 | break; |
269 | break; |
281 | 270 | ||
282 | default: |
271 | default: |
283 | /* |
272 | /* |
284 | * Something is wrong. Fallback to UP mode. |
273 | * Something is wrong. Fallback to UP mode. |
285 | */ |
274 | */ |
286 | 275 | ||
287 | printf("%s: ct badness\n", __FUNCTION__); |
276 | printf("%s: ct badness\n", __FUNCTION__); |
288 | return 1; |
277 | return 1; |
289 | } |
278 | } |
290 | } |
279 | } |
291 | 280 | ||
292 | /* |
281 | /* |
293 | * Process extended entries. |
282 | * Process extended entries. |
294 | */ |
283 | */ |
295 | ct_extended_entries(); |
284 | ct_extended_entries(); |
296 | return cnt; |
285 | return cnt; |
297 | } |
286 | } |
298 | 287 | ||
299 | int configure_via_default(__u8 n) |
288 | int configure_via_default(__u8 n) |
300 | { |
289 | { |
301 | /* |
290 | /* |
302 | * Not yet implemented. |
291 | * Not yet implemented. |
303 | */ |
292 | */ |
304 | printf("%s: not supported\n", __FUNCTION__); |
293 | printf("%s: not supported\n", __FUNCTION__); |
305 | return 1; |
294 | return 1; |
306 | } |
295 | } |
307 | 296 | ||
308 | 297 | ||
309 | int ct_processor_entry(struct __processor_entry *pr) |
298 | int ct_processor_entry(struct __processor_entry *pr) |
310 | { |
299 | { |
311 | /* |
300 | /* |
312 | * Ignore processors which are not marked enabled. |
301 | * Ignore processors which are not marked enabled. |
313 | */ |
302 | */ |
314 | if ((pr->cpu_flags & (1<<0)) == 0) |
303 | if ((pr->cpu_flags & (1<<0)) == 0) |
315 | return 0; |
304 | return 0; |
316 | 305 | ||
317 | apic_id_mask |= (1<<pr->l_apic_id); |
306 | apic_id_mask |= (1<<pr->l_apic_id); |
318 | return 1; |
307 | return 1; |
319 | } |
308 | } |
320 | 309 | ||
321 | void ct_bus_entry(struct __bus_entry *bus) |
310 | void ct_bus_entry(struct __bus_entry *bus) |
322 | { |
311 | { |
323 | #ifdef MPSCT_VERBOSE |
312 | #ifdef MPSCT_VERBOSE |
324 | char buf[7]; |
313 | char buf[7]; |
325 | memcopy((__address) bus->bus_type, (__address) buf, 6); |
314 | memcopy((__address) bus->bus_type, (__address) buf, 6); |
326 | buf[6] = 0; |
315 | buf[6] = 0; |
327 | printf("bus%d: %s\n", bus->bus_id, buf); |
316 | printf("bus%d: %s\n", bus->bus_id, buf); |
328 | #endif |
317 | #endif |
329 | } |
318 | } |
330 | 319 | ||
331 | void ct_io_apic_entry(struct __io_apic_entry *ioa) |
320 | void ct_io_apic_entry(struct __io_apic_entry *ioa) |
332 | { |
321 | { |
333 | static int io_apic_count = 0; |
322 | static int io_apic_count = 0; |
334 | 323 | ||
335 | /* this ioapic is marked unusable */ |
324 | /* this ioapic is marked unusable */ |
336 | if (ioa->io_apic_flags & 1 == 0) |
325 | if (ioa->io_apic_flags & 1 == 0) |
337 | return; |
326 | return; |
338 | 327 | ||
339 | if (io_apic_count++ > 0) { |
328 | if (io_apic_count++ > 0) { |
340 | /* |
329 | /* |
341 | * Multiple IO APIC's are currently not supported. |
330 | * Multiple IO APIC's are currently not supported. |
342 | */ |
331 | */ |
343 | return; |
332 | return; |
344 | } |
333 | } |
345 | 334 | ||
346 | map_page_to_frame((__address) ioa->io_apic, (__address) ioa->io_apic, PAGE_NOT_CACHEABLE, 0); |
- | |
347 | - | ||
348 | io_apic = ioa->io_apic; |
335 | io_apic = ioa->io_apic; |
349 | } |
336 | } |
350 | 337 | ||
351 | //#define MPSCT_VERBOSE |
338 | //#define MPSCT_VERBOSE |
352 | void ct_io_intr_entry(struct __io_intr_entry *iointr) |
339 | void ct_io_intr_entry(struct __io_intr_entry *iointr) |
353 | { |
340 | { |
354 | #ifdef MPSCT_VERBOSE |
341 | #ifdef MPSCT_VERBOSE |
355 | switch (iointr->intr_type) { |
342 | switch (iointr->intr_type) { |
356 | case 0: printf("INT"); break; |
343 | case 0: printf("INT"); break; |
357 | case 1: printf("NMI"); break; |
344 | case 1: printf("NMI"); break; |
358 | case 2: printf("SMI"); break; |
345 | case 2: printf("SMI"); break; |
359 | case 3: printf("ExtINT"); break; |
346 | case 3: printf("ExtINT"); break; |
360 | } |
347 | } |
361 | putchar(','); |
348 | putchar(','); |
362 | switch (iointr->poel&3) { |
349 | switch (iointr->poel&3) { |
363 | case 0: printf("bus-like"); break; |
350 | case 0: printf("bus-like"); break; |
364 | case 1: printf("active high"); break; |
351 | case 1: printf("active high"); break; |
365 | case 2: printf("reserved"); break; |
352 | case 2: printf("reserved"); break; |
366 | case 3: printf("active low"); break; |
353 | case 3: printf("active low"); break; |
367 | } |
354 | } |
368 | putchar(','); |
355 | putchar(','); |
369 | switch ((iointr->poel>>2)&3) { |
356 | switch ((iointr->poel>>2)&3) { |
370 | case 0: printf("bus-like"); break; |
357 | case 0: printf("bus-like"); break; |
371 | case 1: printf("edge-triggered"); break; |
358 | case 1: printf("edge-triggered"); break; |
372 | case 2: printf("reserved"); break; |
359 | case 2: printf("reserved"); break; |
373 | case 3: printf("level-triggered"); break; |
360 | case 3: printf("level-triggered"); break; |
374 | } |
361 | } |
375 | putchar(','); |
362 | putchar(','); |
376 | printf("bus%d,irq%d", iointr->src_bus_id, iointr->src_bus_irq); |
363 | printf("bus%d,irq%d", iointr->src_bus_id, iointr->src_bus_irq); |
377 | putchar(','); |
364 | putchar(','); |
378 | printf("io_apic%d,pin%d", iointr->dst_io_apic_id, iointr->dst_io_apic_pin); |
365 | printf("io_apic%d,pin%d", iointr->dst_io_apic_id, iointr->dst_io_apic_pin); |
379 | putchar('\n'); |
366 | putchar('\n'); |
380 | #endif |
367 | #endif |
381 | } |
368 | } |
382 | 369 | ||
383 | void ct_l_intr_entry(struct __l_intr_entry *lintr) |
370 | void ct_l_intr_entry(struct __l_intr_entry *lintr) |
384 | { |
371 | { |
385 | #ifdef MPSCT_VERBOSE |
372 | #ifdef MPSCT_VERBOSE |
386 | switch (lintr->intr_type) { |
373 | switch (lintr->intr_type) { |
387 | case 0: printf("INT"); break; |
374 | case 0: printf("INT"); break; |
388 | case 1: printf("NMI"); break; |
375 | case 1: printf("NMI"); break; |
389 | case 2: printf("SMI"); break; |
376 | case 2: printf("SMI"); break; |
390 | case 3: printf("ExtINT"); break; |
377 | case 3: printf("ExtINT"); break; |
391 | } |
378 | } |
392 | putchar(','); |
379 | putchar(','); |
393 | switch (lintr->poel&3) { |
380 | switch (lintr->poel&3) { |
394 | case 0: printf("bus-like"); break; |
381 | case 0: printf("bus-like"); break; |
395 | case 1: printf("active high"); break; |
382 | case 1: printf("active high"); break; |
396 | case 2: printf("reserved"); break; |
383 | case 2: printf("reserved"); break; |
397 | case 3: printf("active low"); break; |
384 | case 3: printf("active low"); break; |
398 | } |
385 | } |
399 | putchar(','); |
386 | putchar(','); |
400 | switch ((lintr->poel>>2)&3) { |
387 | switch ((lintr->poel>>2)&3) { |
401 | case 0: printf("bus-like"); break; |
388 | case 0: printf("bus-like"); break; |
402 | case 1: printf("edge-triggered"); break; |
389 | case 1: printf("edge-triggered"); break; |
403 | case 2: printf("reserved"); break; |
390 | case 2: printf("reserved"); break; |
404 | case 3: printf("level-triggered"); break; |
391 | case 3: printf("level-triggered"); break; |
405 | } |
392 | } |
406 | putchar(','); |
393 | putchar(','); |
407 | printf("bus%d,irq%d", lintr->src_bus_id, lintr->src_bus_irq); |
394 | printf("bus%d,irq%d", lintr->src_bus_id, lintr->src_bus_irq); |
408 | putchar(','); |
395 | putchar(','); |
409 | printf("l_apic%d,pin%d", lintr->dst_l_apic_id, lintr->dst_l_apic_pin); |
396 | printf("l_apic%d,pin%d", lintr->dst_l_apic_id, lintr->dst_l_apic_pin); |
410 | putchar('\n'); |
397 | putchar('\n'); |
411 | #endif |
398 | #endif |
412 | } |
399 | } |
413 | 400 | ||
414 | void ct_extended_entries(void) |
401 | void ct_extended_entries(void) |
415 | { |
402 | { |
416 | __u8 *ext = (__u8 *) ct + ct->base_table_length; |
403 | __u8 *ext = (__u8 *) ct + ct->base_table_length; |
417 | __u8 *cur; |
404 | __u8 *cur; |
418 | 405 | ||
419 | for (cur = ext; cur < ext + ct->ext_table_length; cur += cur[CT_EXT_ENTRY_LEN]) { |
406 | for (cur = ext; cur < ext + ct->ext_table_length; cur += cur[CT_EXT_ENTRY_LEN]) { |
420 | switch (cur[CT_EXT_ENTRY_TYPE]) { |
407 | switch (cur[CT_EXT_ENTRY_TYPE]) { |
421 | default: |
408 | default: |
422 | printf("%L: skipping MP Configuration Table extended entry type %d\n", cur, cur[CT_EXT_ENTRY_TYPE]); |
409 | printf("%L: skipping MP Configuration Table extended entry type %d\n", cur, cur[CT_EXT_ENTRY_TYPE]); |
423 | break; |
410 | break; |
424 | } |
411 | } |
425 | } |
412 | } |
426 | } |
413 | } |
427 | 414 | ||
428 | int mps_irq_to_pin(int irq) |
415 | int mps_irq_to_pin(int irq) |
429 | { |
416 | { |
430 | int i; |
417 | int i; |
431 | 418 | ||
432 | for(i=0;i<io_intr_entry_cnt;i++) { |
419 | for(i=0;i<io_intr_entry_cnt;i++) { |
433 | if (io_intr_entries[i].src_bus_irq == irq && io_intr_entries[i].intr_type == 0) |
420 | if (io_intr_entries[i].src_bus_irq == irq && io_intr_entries[i].intr_type == 0) |
434 | return io_intr_entries[i].dst_io_apic_pin; |
421 | return io_intr_entries[i].dst_io_apic_pin; |
435 | } |
422 | } |
436 | 423 | ||
437 | return -1; |
424 | return -1; |
438 | } |
425 | } |
439 | 426 | ||
440 | #endif /* __SMP__ */ |
427 | #endif /* __SMP__ */ |
441 | 428 |