blob: 2e0620e2da7d96a64ebb168030e50405e1f81077 [file] [log] [blame]
Eric Biedermanfcd5ace2004-10-14 19:29:29 +00001#include <cpu/x86/mtrr.h>
2#include <cpu/x86/lapic_def.h>
Stefan Reinauer5f5436f2010-04-25 20:42:02 +00003
Stefan Reinauer82ecf4c2012-11-15 15:53:30 -08004#if CONFIG_SMP && CONFIG_MAX_CPUS > 1
Eric Biedermanfcd5ace2004-10-14 19:29:29 +00005 .text
Sven Schnelle51676b12012-07-29 19:18:03 +02006 .globl _secondary_start, _secondary_start_end
7 .balign 4096
Eric Biedermanfcd5ace2004-10-14 19:29:29 +00008_secondary_start:
9 .code16
10 cli
11 xorl %eax, %eax
12 movl %eax, %cr3 /* Invalidate TLB*/
13
14 /* On hyper threaded cpus, invalidating the cache here is
15 * very very bad. Don't.
16 */
17
18 /* setup the data segment */
19 movw %cs, %ax
20 movw %ax, %ds
21
22 data32 lgdt gdtaddr - _secondary_start
23
24 movl %cr0, %eax
25 andl $0x7FFAFFD1, %eax /* PG,AM,WP,NE,TS,EM,MP = 0 */
26 orl $0x60000001, %eax /* CD, NW, PE = 1 */
27 movl %eax, %cr0
28
Kyösti Mälkki63539bb2012-07-05 06:31:15 +030029 ljmpl $0x10, $__ap_protected_start
30
31gdtaddr:
32 .word gdt_limit /* the table limit */
33 .long gdt /* we know the offset */
34
35_secondary_start_end:
36
37ap_protected_start:
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000038 .code32
Kyösti Mälkki63539bb2012-07-05 06:31:15 +030039 lgdt gdtaddr
40 ljmpl $0x10, $__ap_protected_start
41
42__ap_protected_start:
43
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000044 movw $0x18, %ax
45 movw %ax, %ds
46 movw %ax, %es
47 movw %ax, %ss
48 movw %ax, %fs
49 movw %ax, %gs
50
Eric Biedermanf8a2ddd2004-10-30 08:05:41 +000051 /* Load the Interrupt descriptor table */
52 lidt idtarg
53
Sven Schnelle51676b12012-07-29 19:18:03 +020054 /* Set the stack pointer, and flag that we are done */
55 xorl %eax, %eax
56 movl secondary_stack, %esp
Ronald G. Minnich8b930592012-06-05 14:41:27 -070057 movl secondary_cpu_index, %edi
58 pushl %edi
Sven Schnelle51676b12012-07-29 19:18:03 +020059 movl %eax, secondary_stack
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000060
61 call secondary_cpu_init
621: hlt
63 jmp 1b
64
Eric Biedermanfcd5ace2004-10-14 19:29:29 +000065.code32
Stefan Reinauer82ecf4c2012-11-15 15:53:30 -080066#endif