Rev 311 | Rev 334 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 311 | Rev 331 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | #include <debug.h> |
36 | #include <debug.h> |
37 | #include <config.h> |
37 | #include <config.h> |
38 | #include <print.h> |
38 | #include <print.h> |
39 | #include <mm/heap.h> |
39 | #include <mm/heap.h> |
40 | #include <memstr.h> |
40 | #include <memstr.h> |
- | 41 | #include <sort.h> |
|
41 | 42 | ||
42 | struct acpi_madt *acpi_madt = NULL; |
43 | struct acpi_madt *acpi_madt = NULL; |
43 | 44 | ||
44 | #ifdef __SMP__ |
45 | #ifdef __SMP__ |
45 | 46 | ||
46 | static void madt_l_apic_entry(struct madt_l_apic *la, __u32 index); |
47 | static void madt_l_apic_entry(struct madt_l_apic *la, __u32 index); |
47 | static void madt_io_apic_entry(struct madt_io_apic *ioa, __u32 index); |
48 | static void madt_io_apic_entry(struct madt_io_apic *ioa, __u32 index); |
- | 49 | static int madt_cmp(void * a, void * b); |
|
48 | 50 | ||
49 | struct madt_l_apic *madt_l_apic_entries = NULL; |
51 | struct madt_l_apic *madt_l_apic_entries = NULL; |
50 | struct madt_io_apic *madt_io_apic_entries = NULL; |
52 | struct madt_io_apic *madt_io_apic_entries = NULL; |
51 | 53 | ||
52 | __u32 madt_l_apic_entry_index = 0; |
54 | __u32 madt_l_apic_entry_index = 0; |
Line 106... | Line 108... | ||
106 | { |
108 | { |
107 | ASSERT(i < madt_l_apic_entry_cnt); |
109 | ASSERT(i < madt_l_apic_entry_cnt); |
108 | return ((struct madt_l_apic *) madt_entries_index[madt_l_apic_entry_index + i])->apic_id; |
110 | return ((struct madt_l_apic *) madt_entries_index[madt_l_apic_entry_index + i])->apic_id; |
109 | } |
111 | } |
110 | 112 | ||
- | 113 | int madt_cmp(void * a, void * b) |
|
- | 114 | { |
|
- | 115 | return |
|
- | 116 | (((struct madt_apic_header *) a)->type > ((struct madt_apic_header *) b)->type) ? |
|
- | 117 | 1 : |
|
- | 118 | ((((struct madt_apic_header *) a)->type < ((struct madt_apic_header *) b)->type) ? -1 : 0); |
|
- | 119 | } |
|
- | 120 | ||
111 | void acpi_madt_parse(void) |
121 | void acpi_madt_parse(void) |
112 | { |
122 | { |
- | 123 | ||
- | 124 | ||
113 | struct madt_apic_header *end = (struct madt_apic_header *) (((__u8 *) acpi_madt) + acpi_madt->header.length); |
125 | struct madt_apic_header *end = (struct madt_apic_header *) (((__u8 *) acpi_madt) + acpi_madt->header.length); |
114 | struct madt_apic_header *h; |
126 | struct madt_apic_header *h; |
115 | 127 | ||
116 | l_apic = (__u32 *) (__native) acpi_madt->l_apic_address; |
128 | l_apic = (__u32 *) (__native) acpi_madt->l_apic_address; |
117 | 129 | ||
Line 129... | Line 141... | ||
129 | for (h = &acpi_madt->apic_header[0]; h < end; h = (struct madt_apic_header *) (((__u8 *) h) + h->length)) { |
141 | for (h = &acpi_madt->apic_header[0]; h < end; h = (struct madt_apic_header *) (((__u8 *) h) + h->length)) { |
130 | madt_entries_index[index++] = h; |
142 | madt_entries_index[index++] = h; |
131 | } |
143 | } |
132 | 144 | ||
133 | 145 | ||
134 | /* Bublesort madt index. Quicksort later. */ |
146 | /* Quicksort MADT index structure */ |
135 | bool done = false; |
- | |
136 | - | ||
137 | while (!done) { |
- | |
138 | done = true; |
- | |
139 | for (index = 0; index < madt_entries_index_cnt - 1; index++) { |
147 | qsort(madt_entries_index, madt_entries_index_cnt, sizeof(__address), &madt_cmp); |
140 | if (madt_entries_index[index]->type > madt_entries_index[index + 1]->type) { |
- | |
141 | h = madt_entries_index[index]; |
- | |
142 | madt_entries_index[index] = madt_entries_index[index + 1]; |
- | |
143 | madt_entries_index[index + 1] = h; |
- | |
144 | done = false; |
- | |
145 | } |
- | |
146 | } |
- | |
147 | - | ||
148 | } |
- | |
149 | - | ||
150 | 148 | ||
151 | /* Parse MADT entries */ |
149 | /* Parse MADT entries */ |
152 | for (index = 0; index < madt_entries_index_cnt - 1; index++) { |
150 | for (index = 0; index < madt_entries_index_cnt - 1; index++) { |
153 | h = madt_entries_index[index]; |
151 | h = madt_entries_index[index]; |
154 | switch (h->type) { |
152 | switch (h->type) { |