cleanup debug
[AROS.git] / arch / i386-pc / kernel / smpbootstrap.s
blob86db9e0ffdaf113a3a2cc49cf26fdf858f6680cc
1 # smpbootstrap.c
3 # Created on: Nov 19, 2009
4 # Author: misc
6 .code16
7 cli
8 jmp boot16
10 .align 4 # The config variables are passed here...
11 arg1: .long 0
12 arg2: .long 0
13 arg3: .long 0
14 sp: .long 0
15 ip: .long 0
16 gdt: .short 0
17 .short 0
18 .short 0
19 .short 0
20 .short 0x1000 # 0x08: small CS selector
21 .short 0x0000
22 .short 0x9a00
23 .short 0x0040
24 .short 0x1000 # 0x10: small DS selector
25 .short 0x0000
26 .short 0x9200
27 .short 0x0040
28 .short 0xffff # 0x18: 4GB CS selector
29 .short 0x0000
30 .short 0x9a00
31 .short 0x00cf
32 .short 0xffff # 0x20: 4GB DS selector
33 .short 0x0000
34 .short 0x9200
35 .short 0x00cf
36 gdtr: .short 39
37 .long 0
38 target: .long 0
39 .short 0x18
41 boot16: mov $0, %eax
42 mov %cs, %ax # Find out where the code resides
43 mov %ax, %ds
44 shl $4, %eax
45 leal gdt(%eax), %ebx # Load physical address of 32-bit gdt
46 movl %ebx, gdtr+2 # Set up 32-bit gdt address
47 leal kick(%eax), %ebx # Load physical address of flat-mode code
48 movl %ebx, target # Set up entry address
49 movw %ax, gdt+10 # Set base address of 32-bit code segment (bits 0:15)
50 movw %ax, gdt+18 # Set base address of 32-bit data segment (bits 0:15)
51 shr $16, %eax
52 movb %al, gdt+12 # Set base address of 32-bit code segment (bits 16:23)
53 movb %al, gdt+20 # Set base address of 32-bit data segment (bits 16:23)
54 ADDR32 DATA32 lgdt gdtr # Load gdt
55 movl %cr0, %eax # Enter protected mode
56 orb $1, %al
57 movl %eax, %cr0
58 ljmp $0x8, $boot32 # Please note that the %cs segment selector has to have it's base address properly adjusted
60 .code32
61 boot32: movw $0x10, %ax # Setup the temporary 32-bit data selector
62 movw %ax, %ds
63 movw $0x20, %ax # Set stack to large 32-bit data segment
64 movw %ax, %ss
65 movl sp, %esp # Load stack pointer
66 movl arg3, %ebx # Prepare arguments for the C entry point
67 pushl %ebx
68 movl arg2, %ebx
69 pushl %ebx
70 movl arg1, %ebx
71 pushl %ebx
72 movl ip, %ebx # Prepare entry address
73 ljmp *target
75 kick: mov %ax, %ds # Switch to large data segments
76 mov %ax, %es
77 movl $0, %ebp
78 call *%ebx # Jump to the C entry point