Rev 33 | Rev 68 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 33 | Rev 34 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * Copyright (C) 2001-2004 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: |
Line 30... | Line 30... | ||
30 | 30 | ||
31 | #include <arch/pm.h> |
31 | #include <arch/pm.h> |
32 | #include <config.h> |
32 | #include <config.h> |
33 | #include <print.h> |
33 | #include <print.h> |
34 | #include <panic.h> |
34 | #include <panic.h> |
35 | #include <arch/smp/mp.h> |
35 | #include <arch/smp/mps.h> |
36 | #include <arch/smp/ap.h> |
36 | #include <arch/smp/ap.h> |
37 | #include <arch/smp/apic.h> |
37 | #include <arch/smp/apic.h> |
38 | #include <func.h> |
38 | #include <func.h> |
39 | #include <arch/types.h> |
39 | #include <arch/types.h> |
40 | #include <typedefs.h> |
40 | #include <typedefs.h> |
Line 48... | Line 48... | ||
48 | #include <arch/asm.h> |
48 | #include <arch/asm.h> |
49 | #include <arch/bios/bios.h> |
49 | #include <arch/bios/bios.h> |
50 | #include <arch/acpi/madt.h> |
50 | #include <arch/acpi/madt.h> |
51 | 51 | ||
52 | /* |
52 | /* |
53 | * Multi-Processor Specification detection code. |
53 | * MultiProcessor Specification detection code. |
54 | */ |
54 | */ |
55 | 55 | ||
56 | #define FS_SIGNATURE 0x5f504d5f |
56 | #define FS_SIGNATURE 0x5f504d5f |
57 | #define CT_SIGNATURE 0x504d4350 |
57 | #define CT_SIGNATURE 0x504d4350 |
58 | 58 | ||
59 | int mp_fs_check(__u8 *base); |
59 | int mps_fs_check(__u8 *base); |
60 | int mp_ct_check(void); |
60 | int mps_ct_check(void); |
61 | 61 | ||
62 | int configure_via_ct(void); |
62 | int configure_via_ct(void); |
63 | int configure_via_default(__u8 n); |
63 | int configure_via_default(__u8 n); |
64 | 64 | ||
65 | int ct_processor_entry(struct __processor_entry *pr); |
65 | int ct_processor_entry(struct __processor_entry *pr); |
Line 68... | Line 68... | ||
68 | void ct_io_intr_entry(struct __io_intr_entry *iointr); |
68 | void ct_io_intr_entry(struct __io_intr_entry *iointr); |
69 | void ct_l_intr_entry(struct __l_intr_entry *lintr); |
69 | void ct_l_intr_entry(struct __l_intr_entry *lintr); |
70 | 70 | ||
71 | void ct_extended_entries(void); |
71 | void ct_extended_entries(void); |
72 | 72 | ||
73 | static struct __mpfs *fs; |
73 | static struct mps_fs *fs; |
74 | static struct __mpct *ct; |
74 | static struct mps_ct *ct; |
75 | 75 | ||
76 | struct __processor_entry *processor_entries = NULL; |
76 | struct __processor_entry *processor_entries = NULL; |
77 | struct __bus_entry *bus_entries = NULL; |
77 | struct __bus_entry *bus_entries = NULL; |
78 | struct __io_apic_entry *io_apic_entries = NULL; |
78 | struct __io_apic_entry *io_apic_entries = NULL; |
79 | struct __io_intr_entry *io_intr_entries = NULL; |
79 | struct __io_intr_entry *io_intr_entries = NULL; |
Line 89... | Line 89... | ||
89 | waitq_t kmp_completion_wq; |
89 | waitq_t kmp_completion_wq; |
90 | 90 | ||
91 | /* |
91 | /* |
92 | * Used to check the integrity of the MP Floating Structure. |
92 | * Used to check the integrity of the MP Floating Structure. |
93 | */ |
93 | */ |
94 | int mp_fs_check(__u8 *base) |
94 | int mps_fs_check(__u8 *base) |
95 | { |
95 | { |
96 | int i; |
96 | int i; |
97 | __u8 sum; |
97 | __u8 sum; |
98 | 98 | ||
99 | for (i = 0, sum = 0; i < 16; i++) |
99 | for (i = 0, sum = 0; i < 16; i++) |
Line 103... | Line 103... | ||
103 | } |
103 | } |
104 | 104 | ||
105 | /* |
105 | /* |
106 | * Used to check the integrity of the MP Configuration Table. |
106 | * Used to check the integrity of the MP Configuration Table. |
107 | */ |
107 | */ |
108 | int mp_ct_check(void) |
108 | int mps_ct_check(void) |
109 | { |
109 | { |
110 | __u8 *base = (__u8 *) ct; |
110 | __u8 *base = (__u8 *) ct; |
111 | __u8 *ext = base + ct->base_table_length; |
111 | __u8 *ext = base + ct->base_table_length; |
112 | __u8 sum; |
112 | __u8 sum; |
113 | int i; |
113 | int i; |
Line 124... | Line 124... | ||
124 | sum += ext[i]; |
124 | sum += ext[i]; |
125 | 125 | ||
126 | return sum == ct->ext_table_checksum; |
126 | return sum == ct->ext_table_checksum; |
127 | } |
127 | } |
128 | 128 | ||
129 | void mp_init(void) |
129 | void mps_init(void) |
130 | { |
130 | { |
131 | __u8 *addr[2] = { NULL, (__u8 *) 0xf0000 }; |
131 | __u8 *addr[2] = { NULL, (__u8 *) 0xf0000 }; |
132 | int i, j, length[2] = { 1024, 64*1024 }; |
132 | int i, j, length[2] = { 1024, 64*1024 }; |
133 | 133 | ||
134 | 134 | ||
Line 140... | Line 140... | ||
140 | */ |
140 | */ |
141 | 141 | ||
142 | addr[0] = (__u8 *) (ebda ? ebda : 639 * 1024); |
142 | addr[0] = (__u8 *) (ebda ? ebda : 639 * 1024); |
143 | for (i = 0; i < 2; i++) { |
143 | for (i = 0; i < 2; i++) { |
144 | for (j = 0; j < length[i]; j += 16) { |
144 | for (j = 0; j < length[i]; j += 16) { |
145 | if (*((__u32 *) &addr[i][j]) == FS_SIGNATURE && mp_fs_check(&addr[i][j])) { |
145 | if (*((__u32 *) &addr[i][j]) == FS_SIGNATURE && mps_fs_check(&addr[i][j])) { |
146 | fs = (struct __mpfs *) &addr[i][j]; |
146 | fs = (struct mps_fs *) &addr[i][j]; |
147 | goto fs_found; |
147 | goto fs_found; |
148 | } |
148 | } |
149 | } |
149 | } |
150 | } |
150 | } |
151 | 151 | ||
152 | return; |
152 | return; |
153 | 153 | ||
154 | fs_found: |
154 | fs_found: |
155 | printf("%L: MP Floating Pointer Structure\n", fs); |
155 | printf("%L: MPS Floating Pointer Structure\n", fs); |
156 | 156 | ||
157 | frame_not_free((__address) fs); |
157 | frame_not_free((__address) fs); |
158 | 158 | ||
159 | if (fs->config_type == 0 && fs->configuration_table) { |
159 | if (fs->config_type == 0 && fs->configuration_table) { |
160 | if (fs->mpfib2 >> 7) { |
160 | if (fs->mpfib2 >> 7) { |
161 | printf("mp_init: PIC mode not supported\n"); |
161 | printf("mps_init: PIC mode not supported\n"); |
162 | return; |
162 | return; |
163 | } |
163 | } |
164 | 164 | ||
165 | ct = fs->configuration_table; |
165 | ct = fs->configuration_table; |
166 | frame_not_free((__address) ct); |
166 | frame_not_free((__address) ct); |
Line 189... | Line 189... | ||
189 | 189 | ||
190 | if (ct->signature != CT_SIGNATURE) { |
190 | if (ct->signature != CT_SIGNATURE) { |
191 | printf("configure_via_ct: bad ct->signature\n"); |
191 | printf("configure_via_ct: bad ct->signature\n"); |
192 | return 1; |
192 | return 1; |
193 | } |
193 | } |
194 | if (!mp_ct_check()) { |
194 | if (!mps_ct_check()) { |
195 | printf("configure_via_ct: bad ct checksum\n"); |
195 | printf("configure_via_ct: bad ct checksum\n"); |
196 | return 1; |
196 | return 1; |
197 | } |
197 | } |
198 | if (ct->oem_table) { |
198 | if (ct->oem_table) { |
199 | printf("configure_via_ct: ct->oem_table not supported\n"); |
199 | printf("configure_via_ct: ct->oem_table not supported\n"); |
Line 285... | Line 285... | ||
285 | return 1; |
285 | return 1; |
286 | } |
286 | } |
287 | 287 | ||
288 | void ct_bus_entry(struct __bus_entry *bus) |
288 | void ct_bus_entry(struct __bus_entry *bus) |
289 | { |
289 | { |
290 | #ifdef MPCT_VERBOSE |
290 | #ifdef MPSCT_VERBOSE |
291 | char buf[7]; |
291 | char buf[7]; |
292 | memcopy((__address) bus->bus_type, (__address) buf,6); |
292 | memcopy((__address) bus->bus_type, (__address) buf,6); |
293 | buf[6] = 0; |
293 | buf[6] = 0; |
294 | printf("bus%d: %s\n", bus->bus_id, buf); |
294 | printf("bus%d: %s\n", bus->bus_id, buf); |
295 | #endif |
295 | #endif |
Line 313... | Line 313... | ||
313 | map_page_to_frame((__address) ioa->io_apic, (__address) ioa->io_apic, PAGE_NOT_CACHEABLE, 0); |
313 | map_page_to_frame((__address) ioa->io_apic, (__address) ioa->io_apic, PAGE_NOT_CACHEABLE, 0); |
314 | 314 | ||
315 | io_apic = ioa->io_apic; |
315 | io_apic = ioa->io_apic; |
316 | } |
316 | } |
317 | 317 | ||
318 | //#define MPCT_VERBOSE |
318 | //#define MPSCT_VERBOSE |
319 | void ct_io_intr_entry(struct __io_intr_entry *iointr) |
319 | void ct_io_intr_entry(struct __io_intr_entry *iointr) |
320 | { |
320 | { |
321 | #ifdef MPCT_VERBOSE |
321 | #ifdef MPSCT_VERBOSE |
322 | switch (iointr->intr_type) { |
322 | switch (iointr->intr_type) { |
323 | case 0: printf("INT"); break; |
323 | case 0: printf("INT"); break; |
324 | case 1: printf("NMI"); break; |
324 | case 1: printf("NMI"); break; |
325 | case 2: printf("SMI"); break; |
325 | case 2: printf("SMI"); break; |
326 | case 3: printf("ExtINT"); break; |
326 | case 3: printf("ExtINT"); break; |
Line 347... | Line 347... | ||
347 | #endif |
347 | #endif |
348 | } |
348 | } |
349 | 349 | ||
350 | void ct_l_intr_entry(struct __l_intr_entry *lintr) |
350 | void ct_l_intr_entry(struct __l_intr_entry *lintr) |
351 | { |
351 | { |
352 | #ifdef MPCT_VERBOSE |
352 | #ifdef MPSCT_VERBOSE |
353 | switch (lintr->intr_type) { |
353 | switch (lintr->intr_type) { |
354 | case 0: printf("INT"); break; |
354 | case 0: printf("INT"); break; |
355 | case 1: printf("NMI"); break; |
355 | case 1: printf("NMI"); break; |
356 | case 2: printf("SMI"); break; |
356 | case 2: printf("SMI"); break; |
357 | case 3: printf("ExtINT"); break; |
357 | case 3: printf("ExtINT"); break; |
Line 493... | Line 493... | ||
493 | * system initialization can go on. |
493 | * system initialization can go on. |
494 | */ |
494 | */ |
495 | waitq_wakeup(&kmp_completion_wq, WAKEUP_FIRST); |
495 | waitq_wakeup(&kmp_completion_wq, WAKEUP_FIRST); |
496 | } |
496 | } |
497 | 497 | ||
498 | int mp_irq_to_pin(int irq) |
498 | int mps_irq_to_pin(int irq) |
499 | { |
499 | { |
500 | int i; |
500 | int i; |
501 | 501 | ||
502 | for(i=0;i<io_intr_entry_cnt;i++) { |
502 | for(i=0;i<io_intr_entry_cnt;i++) { |
503 | if (io_intr_entries[i].src_bus_irq == irq && io_intr_entries[i].intr_type == 0) |
503 | if (io_intr_entries[i].src_bus_irq == irq && io_intr_entries[i].intr_type == 0) |