2004-10-14 21:29:29 +02:00
|
|
|
#include <cpu/x86/mtrr.h>
|
|
|
|
#include <cpu/x86/lapic_def.h>
|
2010-04-25 22:42:02 +02:00
|
|
|
|
2004-10-14 21:29:29 +02:00
|
|
|
.text
|
2005-12-14 03:39:33 +01:00
|
|
|
.globl _secondary_start, _secondary_start_end
|
2004-10-14 21:29:29 +02:00
|
|
|
.balign 4096
|
|
|
|
_secondary_start:
|
|
|
|
.code16
|
|
|
|
cli
|
|
|
|
xorl %eax, %eax
|
|
|
|
movl %eax, %cr3 /* Invalidate TLB*/
|
|
|
|
|
|
|
|
/* On hyper threaded cpus, invalidating the cache here is
|
|
|
|
* very very bad. Don't.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* setup the data segment */
|
|
|
|
movw %cs, %ax
|
|
|
|
movw %ax, %ds
|
|
|
|
|
|
|
|
data32 lgdt gdtaddr - _secondary_start
|
|
|
|
|
|
|
|
movl %cr0, %eax
|
|
|
|
andl $0x7FFAFFD1, %eax /* PG,AM,WP,NE,TS,EM,MP = 0 */
|
|
|
|
orl $0x60000001, %eax /* CD, NW, PE = 1 */
|
|
|
|
movl %eax, %cr0
|
|
|
|
|
2004-11-04 19:36:06 +01:00
|
|
|
ljmpl $0x10, $1f
|
2010-04-27 08:56:47 +02:00
|
|
|
1:
|
2004-10-14 21:29:29 +02:00
|
|
|
.code32
|
|
|
|
movw $0x18, %ax
|
|
|
|
movw %ax, %ds
|
|
|
|
movw %ax, %es
|
|
|
|
movw %ax, %ss
|
|
|
|
movw %ax, %fs
|
|
|
|
movw %ax, %gs
|
|
|
|
|
2004-10-30 10:05:41 +02:00
|
|
|
/* Load the Interrupt descriptor table */
|
|
|
|
lidt idtarg
|
|
|
|
|
2004-10-14 21:29:29 +02:00
|
|
|
/* Set the stack pointer, and flag that we are done */
|
|
|
|
xorl %eax, %eax
|
|
|
|
movl secondary_stack, %esp
|
|
|
|
movl %eax, secondary_stack
|
|
|
|
|
|
|
|
call secondary_cpu_init
|
|
|
|
1: hlt
|
|
|
|
jmp 1b
|
|
|
|
|
2012-03-07 15:55:47 +01:00
|
|
|
gdtaddr:
|
2005-12-14 03:39:33 +01:00
|
|
|
.word gdt_limit /* the table limit */
|
|
|
|
.long gdt /* we know the offset */
|
2004-10-14 21:29:29 +02:00
|
|
|
|
2005-12-14 03:39:33 +01:00
|
|
|
_secondary_start_end:
|
2004-10-14 21:29:29 +02:00
|
|
|
.code32
|