Subversion Repositories HelenOS-historic

Rev

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

Rev 34 Rev 127
1
/*
1
/*
2
 * Copyright (C) 2005 Jakub Jermar
2
 * Copyright (C) 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
#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",
43
    "L_APIC_NMI",
61
    "L_APIC_NMI",
44
    "L_APIC_ADDR_OVRD",
62
    "L_APIC_ADDR_OVRD",
45
    "IO_SAPIC",
63
    "IO_SAPIC",
46
    "L_SAPIC",
64
    "L_SAPIC",
47
    "PLATFORM_INTR_SRC"
65
    "PLATFORM_INTR_SRC"
48
};
66
};
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:
66
            case MADT_L_SAPIC:
90
            case MADT_L_SAPIC:
67
            case MADT_PLATFORM_INTR_SRC:
91
            case MADT_PLATFORM_INTR_SRC:
68
                printf("MADT: skipping %s entry (type=%d)\n", entry[h->type], h->type);
92
                printf("MADT: skipping %s entry (type=%d)\n", entry[h->type], h->type);
69
                break;
93
                break;
70
 
94
 
71
            default:
95
            default:
72
                if (h->type >= MADT_RESERVED_SKIP_BEGIN && h->type <= MADT_RESERVED_SKIP_END) {
96
                if (h->type >= MADT_RESERVED_SKIP_BEGIN && h->type <= MADT_RESERVED_SKIP_END) {
73
                    printf("MADT: skipping reserved entry (type=%d)\n", h->type);
97
                    printf("MADT: skipping reserved entry (type=%d)\n", h->type);
74
                }
98
                }
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__ */
86
 
146