Subversion Repositories HelenOS-historic

Rev

Rev 501 | Rev 532 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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