Rev 2089 | Rev 3071 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2089 | Rev 2101 | ||
|---|---|---|---|
| Line 67... | Line 67... | ||
| 67 | count_t madt_l_apic_entry_cnt = 0; |
67 | count_t madt_l_apic_entry_cnt = 0; |
| 68 | count_t madt_io_apic_entry_cnt = 0; |
68 | count_t madt_io_apic_entry_cnt = 0; |
| 69 | count_t cpu_count = 0; |
69 | count_t cpu_count = 0; |
| 70 | 70 | ||
| 71 | struct madt_apic_header * * madt_entries_index = NULL; |
71 | struct madt_apic_header * * madt_entries_index = NULL; |
| 72 | int madt_entries_index_cnt = 0; |
72 | unsigned int madt_entries_index_cnt = 0; |
| 73 | 73 | ||
| 74 | char *entry[] = { |
74 | char *entry[] = { |
| 75 | "L_APIC", |
75 | "L_APIC", |
| 76 | "IO_APIC", |
76 | "IO_APIC", |
| 77 | "INTR_SRC_OVRD", |
77 | "INTR_SRC_OVRD", |
| Line 88... | Line 88... | ||
| 88 | */ |
88 | */ |
| 89 | static count_t madt_cpu_count(void); |
89 | static count_t madt_cpu_count(void); |
| 90 | static bool madt_cpu_enabled(index_t i); |
90 | static bool madt_cpu_enabled(index_t i); |
| 91 | static bool madt_cpu_bootstrap(index_t i); |
91 | static bool madt_cpu_bootstrap(index_t i); |
| 92 | static uint8_t madt_cpu_apic_id(index_t i); |
92 | static uint8_t madt_cpu_apic_id(index_t i); |
| 93 | static int madt_irq_to_pin(int irq); |
93 | static int madt_irq_to_pin(unsigned int irq); |
| 94 | 94 | ||
| 95 | struct smp_config_operations madt_config_operations = { |
95 | struct smp_config_operations madt_config_operations = { |
| 96 | .cpu_count = madt_cpu_count, |
96 | .cpu_count = madt_cpu_count, |
| 97 | .cpu_enabled = madt_cpu_enabled, |
97 | .cpu_enabled = madt_cpu_enabled, |
| 98 | .cpu_bootstrap = madt_cpu_bootstrap, |
98 | .cpu_bootstrap = madt_cpu_bootstrap, |
| Line 122... | Line 122... | ||
| 122 | { |
122 | { |
| 123 | ASSERT(i < madt_l_apic_entry_cnt); |
123 | ASSERT(i < madt_l_apic_entry_cnt); |
| 124 | return ((struct madt_l_apic *) madt_entries_index[madt_l_apic_entry_index + i])->apic_id; |
124 | return ((struct madt_l_apic *) madt_entries_index[madt_l_apic_entry_index + i])->apic_id; |
| 125 | } |
125 | } |
| 126 | 126 | ||
| 127 | int madt_irq_to_pin(int irq) |
127 | int madt_irq_to_pin(unsigned int irq) |
| 128 | { |
128 | { |
| 129 | ASSERT(irq < sizeof(isa_irq_map)/sizeof(int)); |
129 | ASSERT(irq < sizeof(isa_irq_map)/sizeof(int)); |
| 130 | return isa_irq_map[irq]; |
130 | return isa_irq_map[irq]; |
| 131 | } |
131 | } |
| 132 | 132 | ||
| Line 141... | Line 141... | ||
| 141 | void acpi_madt_parse(void) |
141 | void acpi_madt_parse(void) |
| 142 | { |
142 | { |
| 143 | struct madt_apic_header *end = (struct madt_apic_header *) (((uint8_t *) acpi_madt) + acpi_madt->header.length); |
143 | struct madt_apic_header *end = (struct madt_apic_header *) (((uint8_t *) acpi_madt) + acpi_madt->header.length); |
| 144 | struct madt_apic_header *h; |
144 | struct madt_apic_header *h; |
| 145 | 145 | ||
| 146 | l_apic = (uint32_t *) (unative_t) acpi_madt->l_apic_address; |
146 | l_apic = (uint32_t *) (unative_t) acpi_madt->l_apic_address; |
| 147 | 147 | ||
| 148 | /* calculate madt entries */ |
148 | /* calculate madt entries */ |
| 149 | for (h = &acpi_madt->apic_header[0]; h < end; h = (struct madt_apic_header *) (((uint8_t *) h) + h->length)) { |
149 | for (h = &acpi_madt->apic_header[0]; h < end; h = (struct madt_apic_header *) (((uint8_t *) h) + h->length)) { |
| 150 | madt_entries_index_cnt++; |
150 | madt_entries_index_cnt++; |
| 151 | } |
151 | } |
| Line 162... | Line 162... | ||
| 162 | } |
162 | } |
| 163 | 163 | ||
| 164 | /* Quicksort MADT index structure */ |
164 | /* Quicksort MADT index structure */ |
| 165 | qsort(madt_entries_index, madt_entries_index_cnt, sizeof(uintptr_t), &madt_cmp); |
165 | qsort(madt_entries_index, madt_entries_index_cnt, sizeof(uintptr_t), &madt_cmp); |
| 166 | 166 | ||
| 167 | /* Parse MADT entries */ |
167 | /* Parse MADT entries */ |
| - | 168 | if (madt_entries_index_cnt > 0) { |
|
| 168 | for (index = 0; index < madt_entries_index_cnt - 1; index++) { |
169 | for (index = 0; index < madt_entries_index_cnt - 1; index++) { |
| 169 | h = madt_entries_index[index]; |
170 | h = madt_entries_index[index]; |
| 170 | switch (h->type) { |
171 | switch (h->type) { |
| 171 | case MADT_L_APIC: |
172 | case MADT_L_APIC: |
| 172 | madt_l_apic_entry((struct madt_l_apic *) h, index); |
173 | madt_l_apic_entry((struct madt_l_apic *) h, index); |
| 173 | break; |
174 | break; |
| 174 | case MADT_IO_APIC: |
175 | case MADT_IO_APIC: |
| 175 | madt_io_apic_entry((struct madt_io_apic *) h, index); |
176 | madt_io_apic_entry((struct madt_io_apic *) h, index); |
| 176 | break; |
177 | break; |
| 177 | case MADT_INTR_SRC_OVRD: |
178 | case MADT_INTR_SRC_OVRD: |
| 178 | madt_intr_src_ovrd_entry((struct madt_intr_src_ovrd *) h, index); |
179 | madt_intr_src_ovrd_entry((struct madt_intr_src_ovrd *) h, index); |
| 179 | break; |
180 | break; |
| 180 | case MADT_NMI_SRC: |
181 | case MADT_NMI_SRC: |
| 181 | case MADT_L_APIC_NMI: |
182 | case MADT_L_APIC_NMI: |
| 182 | case MADT_L_APIC_ADDR_OVRD: |
183 | case MADT_L_APIC_ADDR_OVRD: |
| 183 | case MADT_IO_SAPIC: |
184 | case MADT_IO_SAPIC: |
| 184 | case MADT_L_SAPIC: |
185 | case MADT_L_SAPIC: |
| 185 | case MADT_PLATFORM_INTR_SRC: |
186 | case MADT_PLATFORM_INTR_SRC: |
| 186 | printf("MADT: skipping %s entry (type=%zd)\n", entry[h->type], h->type); |
187 | printf("MADT: skipping %s entry (type=%zd)\n", entry[h->type], h->type); |
| 187 | break; |
- | |
| 188 | - | ||
| 189 | default: |
- | |
| 190 | if (h->type >= MADT_RESERVED_SKIP_BEGIN && h->type <= MADT_RESERVED_SKIP_END) { |
- | |
| 191 | printf("MADT: skipping reserved entry (type=%zd)\n", h->type); |
- | |
| 192 | } |
- | |
| 193 | if (h->type >= MADT_RESERVED_OEM_BEGIN) { |
- | |
| 194 | printf("MADT: skipping OEM entry (type=%zd)\n", h->type); |
- | |
| 195 | } |
- | |
| 196 | break; |
188 | break; |
| 197 | } |
- | |
| 198 | - | ||
| 199 | 189 | ||
| - | 190 | default: |
|
| - | 191 | if (h->type >= MADT_RESERVED_SKIP_BEGIN && h->type <= MADT_RESERVED_SKIP_END) { |
|
| - | 192 | printf("MADT: skipping reserved entry (type=%zd)\n", h->type); |
|
| - | 193 | } |
|
| - | 194 | if (h->type >= MADT_RESERVED_OEM_BEGIN) { |
|
| - | 195 | printf("MADT: skipping OEM entry (type=%zd)\n", h->type); |
|
| - | 196 | } |
|
| - | 197 | break; |
|
| - | 198 | } |
|
| - | 199 | } |
|
| 200 | } |
200 | } |
| 201 | - | ||
| 202 | 201 | ||
| 203 | if (cpu_count) |
202 | if (cpu_count) |
| 204 | config.cpu_count = cpu_count; |
203 | config.cpu_count = cpu_count; |
| 205 | } |
204 | } |
| 206 | 205 | ||