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