Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 1 | #include <cpu/x86/mtrr.h> |
| 2 | #include <cpu/x86/lapic_def.h> |
Stefan Reinauer | 5f5436f | 2010-04-25 20:42:02 +0000 | [diff] [blame] | 3 | |
Stefan Reinauer | 82ecf4c | 2012-11-15 15:53:30 -0800 | [diff] [blame] | 4 | #if CONFIG_SMP && CONFIG_MAX_CPUS > 1 |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 5 | .text |
Sven Schnelle | 51676b1 | 2012-07-29 19:18:03 +0200 | [diff] [blame] | 6 | .globl _secondary_start, _secondary_start_end |
| 7 | .balign 4096 |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 8 | _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älkki | 63539bb | 2012-07-05 06:31:15 +0300 | [diff] [blame] | 29 | ljmpl $0x10, $__ap_protected_start |
| 30 | |
| 31 | gdtaddr: |
| 32 | .word gdt_limit /* the table limit */ |
| 33 | .long gdt /* we know the offset */ |
| 34 | |
| 35 | _secondary_start_end: |
| 36 | |
| 37 | ap_protected_start: |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 38 | .code32 |
Kyösti Mälkki | 63539bb | 2012-07-05 06:31:15 +0300 | [diff] [blame] | 39 | lgdt gdtaddr |
| 40 | ljmpl $0x10, $__ap_protected_start |
| 41 | |
| 42 | __ap_protected_start: |
| 43 | |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 44 | 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 Biederman | f8a2ddd | 2004-10-30 08:05:41 +0000 | [diff] [blame] | 51 | /* Load the Interrupt descriptor table */ |
| 52 | lidt idtarg |
| 53 | |
Sven Schnelle | 51676b1 | 2012-07-29 19:18:03 +0200 | [diff] [blame] | 54 | /* Set the stack pointer, and flag that we are done */ |
| 55 | xorl %eax, %eax |
| 56 | movl secondary_stack, %esp |
Ronald G. Minnich | 8b93059 | 2012-06-05 14:41:27 -0700 | [diff] [blame] | 57 | movl secondary_cpu_index, %edi |
| 58 | pushl %edi |
Sven Schnelle | 51676b1 | 2012-07-29 19:18:03 +0200 | [diff] [blame] | 59 | movl %eax, secondary_stack |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 60 | |
| 61 | call secondary_cpu_init |
| 62 | 1: hlt |
| 63 | jmp 1b |
| 64 | |
Eric Biederman | fcd5ace | 2004-10-14 19:29:29 +0000 | [diff] [blame] | 65 | .code32 |
Stefan Reinauer | 82ecf4c | 2012-11-15 15:53:30 -0800 | [diff] [blame] | 66 | #endif |