Subversion Repositories HelenOS

Rev

Rev 34 | Rev 129 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34 Rev 127
Line 28... Line 28...
28
 
28
 
29
#include <arch/types.h>
29
#include <arch/types.h>
30
#include <arch/acpi/acpi.h>
30
#include <arch/acpi/acpi.h>
31
#include <arch/acpi/madt.h>
31
#include <arch/acpi/madt.h>
32
#include <arch/smp/apic.h>
32
#include <arch/smp/apic.h>
-
 
33
#include <mm/page.h>
-
 
34
#include <panic.h>
33
 
35
 
34
struct acpi_madt *acpi_madt = NULL;
36
struct acpi_madt *acpi_madt = NULL;
35
 
37
 
36
#ifdef __SMP__
38
#ifdef __SMP__
37
 
39
 
-
 
40
/*
-
 
41
 * NOTE: it is currently not completely clear to the authors of SPARTAN whether
-
 
42
 * MADT can exist in such a form that entries of the same type are not consecutive.
-
 
43
 * Because of this uncertainity, some entry types are explicitly checked for
-
 
44
 * being consecutive with other entries of the same kind.
-
 
45
 */
-
 
46
 
-
 
47
static void madt_l_apic_entry(struct madt_l_apic *la, __u8 prev_type);
-
 
48
static void madt_io_apic_entry(struct madt_io_apic *ioa, __u8 prev_type);
-
 
49
 
-
 
50
struct madt_l_apic *madt_l_apic_entries = NULL;
-
 
51
struct madt_io_apic *madt_io_apic_entries = NULL;
-
 
52
 
-
 
53
int madt_l_apic_entry_cnt = 0;
-
 
54
int madt_io_apic_entry_cnt = 0;
-
 
55
 
38
char *entry[] = {
56
char *entry[] = {
39
    "L_APIC",
57
    "L_APIC",
40
    "IO_APIC",
58
    "IO_APIC",
41
    "INTR_SRC_OVRD",
59
    "INTR_SRC_OVRD",
42
    "NMI_SRC",
60
    "NMI_SRC",
Line 49... Line 67...
49
 
67
 
50
void acpi_madt_parse(void)
68
void acpi_madt_parse(void)
51
{
69
{
52
    struct madt_apic_header *end = (struct madt_apic_header *) (((__u8 *) acpi_madt) + acpi_madt->header.length);
70
    struct madt_apic_header *end = (struct madt_apic_header *) (((__u8 *) acpi_madt) + acpi_madt->header.length);
53
    struct madt_apic_header *h = &acpi_madt->apic_header[0];
71
    struct madt_apic_header *h = &acpi_madt->apic_header[0];
-
 
72
    __u8 prev_type = 0; /* used to detect incosecutive entries */
-
 
73
 
54
 
74
 
55
    l_apic = (__u32 *) acpi_madt->l_apic_address;
75
    l_apic = (__u32 *) acpi_madt->l_apic_address;
56
 
76
 
57
    while (h < end) {
77
    while (h < end) {
58
        switch (h->type) {
78
        switch (h->type) {
59
            case MADT_L_APIC:
79
            case MADT_L_APIC:
-
 
80
                madt_l_apic_entry((struct madt_l_apic *) h, prev_type);
-
 
81
                break;
60
            case MADT_IO_APIC:
82
            case MADT_IO_APIC:
-
 
83
                madt_io_apic_entry((struct madt_io_apic *) h, prev_type);
-
 
84
                break;
61
            case MADT_INTR_SRC_OVRD:
85
            case MADT_INTR_SRC_OVRD:
62
            case MADT_NMI_SRC:
86
            case MADT_NMI_SRC:
63
            case MADT_L_APIC_NMI:
87
            case MADT_L_APIC_NMI:
64
            case MADT_L_APIC_ADDR_OVRD:
88
            case MADT_L_APIC_ADDR_OVRD:
65
            case MADT_IO_SAPIC:
89
            case MADT_IO_SAPIC:
Line 75... Line 99...
75
                if (h->type >= MADT_RESERVED_OEM_BEGIN) {
99
                if (h->type >= MADT_RESERVED_OEM_BEGIN) {
76
                    printf("MADT: skipping OEM entry (type=%d)\n", h->type);
100
                    printf("MADT: skipping OEM entry (type=%d)\n", h->type);
77
                }
101
                }
78
                break;
102
                break;
79
        }
103
        }
-
 
104
        prev_type = h->type;
80
        h = (struct madt_apic_header *) (((__u8 *) h) + h->length);
105
        h = (struct madt_apic_header *) (((__u8 *) h) + h->length);
81
    }
106
    }
82
 
107
 
83
}
108
}
-
 
109
 
-
 
110
void madt_l_apic_entry(struct madt_l_apic *la, __u8 prev_type)
-
 
111
{
-
 
112
    /* check for consecutiveness */
-
 
113
    if (madt_l_apic_entry_cnt && prev_type != MADT_L_APIC)
-
 
114
    panic("%s entries are not consecuitve\n", entry[MADT_L_APIC]);
-
 
115
 
-
 
116
    if (!madt_l_apic_entry_cnt++)
-
 
117
        madt_l_apic_entries = la;
-
 
118
       
-
 
119
    if (!(la->flags & 0x1)) {
-
 
120
        /* Processor is unusable, skip it. */
-
 
121
        return;
-
 
122
    }
-
 
123
       
-
 
124
    apic_id_mask |= 1<<la->apic_id;
-
 
125
}
-
 
126
 
-
 
127
void madt_io_apic_entry(struct madt_io_apic *ioa, __u8 prev_type)
-
 
128
{
-
 
129
    /* check for consecutiveness */
-
 
130
    if (madt_io_apic_entry_cnt && prev_type != MADT_IO_APIC)
-
 
131
    panic("%s entries are not consecuitve\n", entry[MADT_IO_APIC]);
-
 
132
 
-
 
133
    if (!madt_io_apic_entry_cnt++) {
-
 
134
        madt_io_apic_entries = ioa;
-
 
135
        io_apic = (__u32 *) ioa->io_apic_address;
-
 
136
        map_page_to_frame((__address) io_apic, (__address) io_apic, PAGE_NOT_CACHEABLE, 0);
-
 
137
    }
-
 
138
    else {
-
 
139
        /* currently not supported */
-
 
140
        return;
-
 
141
    }
-
 
142
}
-
 
143
 
84
 
144
 
85
#endif /* __SMP__ */
145
#endif /* __SMP__ */