Subversion Repositories HelenOS-historic

Rev

Rev 1702 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1702 Rev 1780
Line 53... Line 53...
53
 */
53
 */
54
 
54
 
55
#define FS_SIGNATURE    0x5f504d5f
55
#define FS_SIGNATURE    0x5f504d5f
56
#define CT_SIGNATURE    0x504d4350
56
#define CT_SIGNATURE    0x504d4350
57
 
57
 
58
int mps_fs_check(__u8 *base);
58
int mps_fs_check(uint8_t *base);
59
int mps_ct_check(void);
59
int mps_ct_check(void);
60
 
60
 
61
int configure_via_ct(void);
61
int configure_via_ct(void);
62
int configure_via_default(__u8 n);
62
int configure_via_default(uint8_t n);
63
 
63
 
64
int ct_processor_entry(struct __processor_entry *pr);
64
int ct_processor_entry(struct __processor_entry *pr);
65
void ct_bus_entry(struct __bus_entry *bus);
65
void ct_bus_entry(struct __bus_entry *bus);
66
void ct_io_apic_entry(struct __io_apic_entry *ioa);
66
void ct_io_apic_entry(struct __io_apic_entry *ioa);
67
void ct_io_intr_entry(struct __io_intr_entry *iointr);
67
void ct_io_intr_entry(struct __io_intr_entry *iointr);
Line 90... Line 90...
90
 * Implementation of IA-32 SMP configuration interface.
90
 * Implementation of IA-32 SMP configuration interface.
91
 */
91
 */
92
static count_t get_cpu_count(void);
92
static count_t get_cpu_count(void);
93
static bool is_cpu_enabled(index_t i);
93
static bool is_cpu_enabled(index_t i);
94
static bool is_bsp(index_t i);
94
static bool is_bsp(index_t i);
95
static __u8 get_cpu_apic_id(index_t i);
95
static uint8_t get_cpu_apic_id(index_t i);
96
static int mps_irq_to_pin(int irq);
96
static int mps_irq_to_pin(int irq);
97
 
97
 
98
struct smp_config_operations mps_config_operations = {
98
struct smp_config_operations mps_config_operations = {
99
    .cpu_count = get_cpu_count,
99
    .cpu_count = get_cpu_count,
100
    .cpu_enabled = is_cpu_enabled,
100
    .cpu_enabled = is_cpu_enabled,
Line 118... Line 118...
118
{
118
{
119
    ASSERT(i < processor_entry_cnt);
119
    ASSERT(i < processor_entry_cnt);
120
    return processor_entries[i].cpu_flags & 0x2;
120
    return processor_entries[i].cpu_flags & 0x2;
121
}
121
}
122
 
122
 
123
__u8 get_cpu_apic_id(index_t i)
123
uint8_t get_cpu_apic_id(index_t i)
124
{
124
{
125
    ASSERT(i < processor_entry_cnt);
125
    ASSERT(i < processor_entry_cnt);
126
    return processor_entries[i].l_apic_id;
126
    return processor_entries[i].l_apic_id;
127
}
127
}
128
 
128
 
129
 
129
 
130
/*
130
/*
131
 * Used to check the integrity of the MP Floating Structure.
131
 * Used to check the integrity of the MP Floating Structure.
132
 */
132
 */
133
int mps_fs_check(__u8 *base)
133
int mps_fs_check(uint8_t *base)
134
{
134
{
135
    int i;
135
    int i;
136
    __u8 sum;
136
    uint8_t sum;
137
   
137
   
138
    for (i = 0, sum = 0; i < 16; i++)
138
    for (i = 0, sum = 0; i < 16; i++)
139
        sum += base[i];
139
        sum += base[i];
140
   
140
   
141
    return !sum;
141
    return !sum;
Line 144... Line 144...
144
/*
144
/*
145
 * Used to check the integrity of the MP Configuration Table.
145
 * Used to check the integrity of the MP Configuration Table.
146
 */
146
 */
147
int mps_ct_check(void)
147
int mps_ct_check(void)
148
{
148
{
149
    __u8 *base = (__u8 *) ct;
149
    uint8_t *base = (uint8_t *) ct;
150
    __u8 *ext = base + ct->base_table_length;
150
    uint8_t *ext = base + ct->base_table_length;
151
    __u8 sum;
151
    uint8_t sum;
152
    int i; 
152
    int i; 
153
   
153
   
154
    /* count the checksum for the base table */
154
    /* count the checksum for the base table */
155
    for (i=0,sum=0; i < ct->base_table_length; i++)
155
    for (i=0,sum=0; i < ct->base_table_length; i++)
156
        sum += base[i];
156
        sum += base[i];
Line 165... Line 165...
165
    return sum == ct->ext_table_checksum;
165
    return sum == ct->ext_table_checksum;
166
}
166
}
167
 
167
 
168
void mps_init(void)
168
void mps_init(void)
169
{
169
{
170
    __u8 *addr[2] = { NULL, (__u8 *) PA2KA(0xf0000) };
170
    uint8_t *addr[2] = { NULL, (uint8_t *) PA2KA(0xf0000) };
171
    int i, j, length[2] = { 1024, 64*1024 };
171
    int i, j, length[2] = { 1024, 64*1024 };
172
   
172
   
173
 
173
 
174
    /*
174
    /*
175
     * Find MP Floating Pointer Structure
175
     * Find MP Floating Pointer Structure
176
     * 1a. search first 1K of EBDA
176
     * 1a. search first 1K of EBDA
177
     * 1b. if EBDA is undefined, search last 1K of base memory
177
     * 1b. if EBDA is undefined, search last 1K of base memory
178
     *  2. search 64K starting at 0xf0000
178
     *  2. search 64K starting at 0xf0000
179
     */
179
     */
180
 
180
 
181
    addr[0] = (__u8 *) PA2KA(ebda ? ebda : 639 * 1024);
181
    addr[0] = (uint8_t *) PA2KA(ebda ? ebda : 639 * 1024);
182
    for (i = 0; i < 2; i++) {
182
    for (i = 0; i < 2; i++) {
183
        for (j = 0; j < length[i]; j += 16) {
183
        for (j = 0; j < length[i]; j += 16) {
184
            if (*((__u32 *) &addr[i][j]) == FS_SIGNATURE && mps_fs_check(&addr[i][j])) {
184
            if (*((uint32_t *) &addr[i][j]) == FS_SIGNATURE && mps_fs_check(&addr[i][j])) {
185
                fs = (struct mps_fs *) &addr[i][j];
185
                fs = (struct mps_fs *) &addr[i][j];
186
                goto fs_found;
186
                goto fs_found;
187
            }
187
            }
188
        }
188
        }
189
    }
189
    }
Line 197... Line 197...
197
        if (fs->mpfib2 >> 7) {
197
        if (fs->mpfib2 >> 7) {
198
            printf("%s: PIC mode not supported\n", __FUNCTION__);
198
            printf("%s: PIC mode not supported\n", __FUNCTION__);
199
            return;
199
            return;
200
        }
200
        }
201
 
201
 
202
        ct = (struct mps_ct *)PA2KA((__address)fs->configuration_table);
202
        ct = (struct mps_ct *)PA2KA((uintptr_t)fs->configuration_table);
203
        config.cpu_count = configure_via_ct();
203
        config.cpu_count = configure_via_ct();
204
    }
204
    }
205
    else
205
    else
206
        config.cpu_count = configure_via_default(fs->config_type);
206
        config.cpu_count = configure_via_default(fs->config_type);
207
 
207
 
208
    return;
208
    return;
209
}
209
}
210
 
210
 
211
int configure_via_ct(void)
211
int configure_via_ct(void)
212
{
212
{
213
    __u8 *cur;
213
    uint8_t *cur;
214
    int i, cnt;
214
    int i, cnt;
215
       
215
       
216
    if (ct->signature != CT_SIGNATURE) {
216
    if (ct->signature != CT_SIGNATURE) {
217
        printf("%s: bad ct->signature\n", __FUNCTION__);
217
        printf("%s: bad ct->signature\n", __FUNCTION__);
218
        return 1;
218
        return 1;
Line 224... Line 224...
224
    if (ct->oem_table) {
224
    if (ct->oem_table) {
225
        printf("%s: ct->oem_table not supported\n", __FUNCTION__);
225
        printf("%s: ct->oem_table not supported\n", __FUNCTION__);
226
        return 1;
226
        return 1;
227
    }
227
    }
228
   
228
   
229
    l_apic = (__u32 *)(__address)ct->l_apic;
229
    l_apic = (uint32_t *)(uintptr_t)ct->l_apic;
230
 
230
 
231
    cnt = 0;
231
    cnt = 0;
232
    cur = &ct->base_table[0];
232
    cur = &ct->base_table[0];
233
    for (i=0; i < ct->entry_count; i++) {
233
    for (i=0; i < ct->entry_count; i++) {
234
        switch (*cur) {
234
        switch (*cur) {
Line 287... Line 287...
287
     */
287
     */
288
    ct_extended_entries();
288
    ct_extended_entries();
289
    return cnt;
289
    return cnt;
290
}
290
}
291
 
291
 
292
int configure_via_default(__u8 n)
292
int configure_via_default(uint8_t n)
293
{
293
{
294
    /*
294
    /*
295
     * Not yet implemented.
295
     * Not yet implemented.
296
     */
296
     */
297
    printf("%s: not supported\n", __FUNCTION__);
297
    printf("%s: not supported\n", __FUNCTION__);
Line 334... Line 334...
334
         * Multiple IO APIC's are currently not supported.
334
         * Multiple IO APIC's are currently not supported.
335
         */
335
         */
336
        return;
336
        return;
337
    }
337
    }
338
   
338
   
339
    io_apic = (__u32 *)(__address)ioa->io_apic;
339
    io_apic = (uint32_t *)(uintptr_t)ioa->io_apic;
340
}
340
}
341
 
341
 
342
//#define MPSCT_VERBOSE
342
//#define MPSCT_VERBOSE
343
void ct_io_intr_entry(struct __io_intr_entry *iointr)
343
void ct_io_intr_entry(struct __io_intr_entry *iointr)
344
{
344
{
Line 402... Line 402...
402
#endif
402
#endif
403
}
403
}
404
 
404
 
405
void ct_extended_entries(void)
405
void ct_extended_entries(void)
406
{
406
{
407
    __u8 *ext = (__u8 *) ct + ct->base_table_length;
407
    uint8_t *ext = (uint8_t *) ct + ct->base_table_length;
408
    __u8 *cur;
408
    uint8_t *cur;
409
 
409
 
410
    for (cur = ext; cur < ext + ct->ext_table_length; cur += cur[CT_EXT_ENTRY_LEN]) {
410
    for (cur = ext; cur < ext + ct->ext_table_length; cur += cur[CT_EXT_ENTRY_LEN]) {
411
        switch (cur[CT_EXT_ENTRY_TYPE]) {
411
        switch (cur[CT_EXT_ENTRY_TYPE]) {
412
            default:
412
            default:
413
                printf("%p: skipping MP Configuration Table extended entry type %d\n", cur, cur[CT_EXT_ENTRY_TYPE]);
413
                printf("%p: skipping MP Configuration Table extended entry type %d\n", cur, cur[CT_EXT_ENTRY_TYPE]);