Rev 1766 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1766 | Rev 1780 | ||
---|---|---|---|
Line 59... | Line 59... | ||
59 | 59 | ||
60 | static struct smp_config_operations *ops = NULL; |
60 | static struct smp_config_operations *ops = NULL; |
61 | 61 | ||
62 | void smp_init(void) |
62 | void smp_init(void) |
63 | { |
63 | { |
64 | __address l_apic_address, io_apic_address; |
64 | uintptr_t l_apic_address, io_apic_address; |
65 | 65 | ||
66 | if (acpi_madt) { |
66 | if (acpi_madt) { |
67 | acpi_madt_parse(); |
67 | acpi_madt_parse(); |
68 | ops = &madt_config_operations; |
68 | ops = &madt_config_operations; |
69 | } |
69 | } |
70 | if (config.cpu_count == 1) { |
70 | if (config.cpu_count == 1) { |
71 | mps_init(); |
71 | mps_init(); |
72 | ops = &mps_config_operations; |
72 | ops = &mps_config_operations; |
73 | } |
73 | } |
74 | 74 | ||
75 | l_apic_address = (__address) frame_alloc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA); |
75 | l_apic_address = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA); |
76 | if (!l_apic_address) |
76 | if (!l_apic_address) |
77 | panic("cannot allocate address for l_apic\n"); |
77 | panic("cannot allocate address for l_apic\n"); |
78 | 78 | ||
79 | io_apic_address = (__address) frame_alloc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA); |
79 | io_apic_address = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_ATOMIC | FRAME_KA); |
80 | if (!io_apic_address) |
80 | if (!io_apic_address) |
81 | panic("cannot allocate address for io_apic\n"); |
81 | panic("cannot allocate address for io_apic\n"); |
82 | 82 | ||
83 | if (config.cpu_count > 1) { |
83 | if (config.cpu_count > 1) { |
84 | page_mapping_insert(AS_KERNEL, l_apic_address, (__address) l_apic, |
84 | page_mapping_insert(AS_KERNEL, l_apic_address, (uintptr_t) l_apic, |
85 | PAGE_NOT_CACHEABLE); |
85 | PAGE_NOT_CACHEABLE); |
86 | page_mapping_insert(AS_KERNEL, io_apic_address, (__address) io_apic, |
86 | page_mapping_insert(AS_KERNEL, io_apic_address, (uintptr_t) io_apic, |
87 | PAGE_NOT_CACHEABLE); |
87 | PAGE_NOT_CACHEABLE); |
88 | 88 | ||
89 | l_apic = (__u32 *) l_apic_address; |
89 | l_apic = (uint32_t *) l_apic_address; |
90 | io_apic = (__u32 *) io_apic_address; |
90 | io_apic = (uint32_t *) io_apic_address; |
91 | } |
91 | } |
92 | } |
92 | } |
93 | 93 | ||
94 | /* |
94 | /* |
95 | * Kernel thread for bringing up application processors. It becomes clear |
95 | * Kernel thread for bringing up application processors. It becomes clear |
Line 112... | Line 112... | ||
112 | */ |
112 | */ |
113 | 113 | ||
114 | /* |
114 | /* |
115 | * Set the warm-reset vector to the real-mode address of 4K-aligned ap_boot() |
115 | * Set the warm-reset vector to the real-mode address of 4K-aligned ap_boot() |
116 | */ |
116 | */ |
117 | *((__u16 *) (PA2KA(0x467+0))) = ((__address) ap_boot) >> 4; /* segment */ |
117 | *((uint16_t *) (PA2KA(0x467+0))) = ((uintptr_t) ap_boot) >> 4; /* segment */ |
118 | *((__u16 *) (PA2KA(0x467+2))) = 0; /* offset */ |
118 | *((uint16_t *) (PA2KA(0x467+2))) = 0; /* offset */ |
119 | 119 | ||
120 | /* |
120 | /* |
121 | * Save 0xa to address 0xf of the CMOS RAM. |
121 | * Save 0xa to address 0xf of the CMOS RAM. |
122 | * BIOS will not do the POST after the INIT signal. |
122 | * BIOS will not do the POST after the INIT signal. |
123 | */ |
123 | */ |
Line 152... | Line 152... | ||
152 | */ |
152 | */ |
153 | if (!(gdt_new = (struct descriptor *) malloc(GDT_ITEMS*sizeof(struct descriptor), FRAME_ATOMIC))) |
153 | if (!(gdt_new = (struct descriptor *) malloc(GDT_ITEMS*sizeof(struct descriptor), FRAME_ATOMIC))) |
154 | panic("couldn't allocate memory for GDT\n"); |
154 | panic("couldn't allocate memory for GDT\n"); |
155 | 155 | ||
156 | memcpy(gdt_new, gdt, GDT_ITEMS * sizeof(struct descriptor)); |
156 | memcpy(gdt_new, gdt, GDT_ITEMS * sizeof(struct descriptor)); |
157 | memsetb((__address)(&gdt_new[TSS_DES]), sizeof(struct descriptor), 0); |
157 | memsetb((uintptr_t)(&gdt_new[TSS_DES]), sizeof(struct descriptor), 0); |
158 | protected_ap_gdtr.limit = GDT_ITEMS * sizeof(struct descriptor); |
158 | protected_ap_gdtr.limit = GDT_ITEMS * sizeof(struct descriptor); |
159 | protected_ap_gdtr.base = KA2PA((__address) gdt_new); |
159 | protected_ap_gdtr.base = KA2PA((uintptr_t) gdt_new); |
160 | gdtr.base = (__address) gdt_new; |
160 | gdtr.base = (uintptr_t) gdt_new; |
161 | 161 | ||
162 | if (l_apic_send_init_ipi(ops->cpu_apic_id(i))) { |
162 | if (l_apic_send_init_ipi(ops->cpu_apic_id(i))) { |
163 | /* |
163 | /* |
164 | * There may be just one AP being initialized at |
164 | * There may be just one AP being initialized at |
165 | * the time. After it comes completely up, it is |
165 | * the time. After it comes completely up, it is |