Rev 34 | Rev 129 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
33 | jermar | 1 | /* |
2 | * Copyright (C) 2005 Jakub Jermar |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions |
||
7 | * are met: |
||
8 | * |
||
9 | * - Redistributions of source code must retain the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer. |
||
11 | * - Redistributions in binary form must reproduce the above copyright |
||
12 | * notice, this list of conditions and the following disclaimer in the |
||
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 |
||
15 | * derived from this software without specific prior written permission. |
||
16 | * |
||
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 |
||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
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 |
||
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 |
||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | */ |
||
28 | |||
34 | jermar | 29 | #include <arch/types.h> |
33 | jermar | 30 | #include <arch/acpi/acpi.h> |
31 | #include <arch/acpi/madt.h> |
||
34 | jermar | 32 | #include <arch/smp/apic.h> |
127 | jermar | 33 | #include <mm/page.h> |
34 | #include <panic.h> |
||
33 | jermar | 35 | |
36 | struct acpi_madt *acpi_madt = NULL; |
||
34 | jermar | 37 | |
38 | #ifdef __SMP__ |
||
39 | |||
127 | jermar | 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 | |||
34 | jermar | 56 | char *entry[] = { |
57 | "L_APIC", |
||
58 | "IO_APIC", |
||
59 | "INTR_SRC_OVRD", |
||
60 | "NMI_SRC", |
||
61 | "L_APIC_NMI", |
||
62 | "L_APIC_ADDR_OVRD", |
||
63 | "IO_SAPIC", |
||
64 | "L_SAPIC", |
||
65 | "PLATFORM_INTR_SRC" |
||
66 | }; |
||
67 | |||
68 | void acpi_madt_parse(void) |
||
69 | { |
||
70 | struct madt_apic_header *end = (struct madt_apic_header *) (((__u8 *) acpi_madt) + acpi_madt->header.length); |
||
71 | struct madt_apic_header *h = &acpi_madt->apic_header[0]; |
||
127 | jermar | 72 | __u8 prev_type = 0; /* used to detect incosecutive entries */ |
34 | jermar | 73 | |
127 | jermar | 74 | |
34 | jermar | 75 | l_apic = (__u32 *) acpi_madt->l_apic_address; |
76 | |||
77 | while (h < end) { |
||
78 | switch (h->type) { |
||
79 | case MADT_L_APIC: |
||
127 | jermar | 80 | madt_l_apic_entry((struct madt_l_apic *) h, prev_type); |
81 | break; |
||
34 | jermar | 82 | case MADT_IO_APIC: |
127 | jermar | 83 | madt_io_apic_entry((struct madt_io_apic *) h, prev_type); |
84 | break; |
||
34 | jermar | 85 | case MADT_INTR_SRC_OVRD: |
86 | case MADT_NMI_SRC: |
||
87 | case MADT_L_APIC_NMI: |
||
88 | case MADT_L_APIC_ADDR_OVRD: |
||
89 | case MADT_IO_SAPIC: |
||
90 | case MADT_L_SAPIC: |
||
91 | case MADT_PLATFORM_INTR_SRC: |
||
92 | printf("MADT: skipping %s entry (type=%d)\n", entry[h->type], h->type); |
||
93 | break; |
||
94 | |||
95 | default: |
||
96 | if (h->type >= MADT_RESERVED_SKIP_BEGIN && h->type <= MADT_RESERVED_SKIP_END) { |
||
97 | printf("MADT: skipping reserved entry (type=%d)\n", h->type); |
||
98 | } |
||
99 | if (h->type >= MADT_RESERVED_OEM_BEGIN) { |
||
100 | printf("MADT: skipping OEM entry (type=%d)\n", h->type); |
||
101 | } |
||
102 | break; |
||
103 | } |
||
127 | jermar | 104 | prev_type = h->type; |
34 | jermar | 105 | h = (struct madt_apic_header *) (((__u8 *) h) + h->length); |
106 | } |
||
107 | |||
108 | } |
||
127 | jermar | 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]); |
||
34 | jermar | 115 | |
127 | jermar | 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 | |||
144 | |||
34 | jermar | 145 | #endif /* __SMP__ */ |