Subversion Repositories HelenOS-historic

Rev

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

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