revert between 56095 -> 55830 in arch
[AROS.git] / arch / i386-pc / kernel / smpbootstrap.s
blob13292b7688d3ab3d624c6abd0c9aacc8992a8025
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 arg4: .long 0
15 pml4: .long 0
16 sp: .long 0
17 ip: .long 0
18 gdt: .short 0
19 .short 0
20 .short 0
21 .short 0
22 .short 0x1000 # 0x08: small CS selector
23 .short 0x0000
24 .short 0x9a00
25 .short 0x0040
26 .short 0x1000 # 0x10: small DS selector
27 .short 0x0000
28 .short 0x9200
29 .short 0x0040
30 .short 0xffff # 0x18: 4GB CS selector
31 .short 0x0000
32 .short 0x9a00
33 .short 0x00cf
34 .short 0xffff # 0x20: 4GB DS selector
35 .short 0x0000
36 .short 0x9200
37 .short 0x00cf
38 gdtr: .short 39
39 .long 0
40 target: .long 0
41 .short 0x18
43 boot16: mov $0, %eax
44 mov %cs, %ax # Find out where the code resides
45 mov %ax, %ds
46 shl $4, %eax
47 leal gdt(%eax), %ebx # Load physical address of 32-bit gdt
48 movl %ebx, gdtr+2 # Set up 32-bit gdt address
49 leal kick(%eax), %ebx # Load physical address of flat-mode code
50 movl %ebx, target # Set up entry address
51 movw %ax, gdt+10 # Set base address of 32-bit code segment (bits 0:15)
52 movw %ax, gdt+18 # Set base address of 32-bit data segment (bits 0:15)
53 shr $16, %eax
54 movb %al, gdt+12 # Set base address of 32-bit code segment (bits 16:23)
55 movb %al, gdt+20 # Set base address of 32-bit data segment (bits 16:23)
56 ADDR32 DATA32 lgdt gdtr # Load gdt
57 movl %cr0, %eax # Enter protected mode
58 orb $1, %al
59 movl %eax, %cr0
60 ljmp $0x8, $boot32 # Please note that the %cs segment selector has to have it's base address properly adjusted
62 .code32
63 boot32: movw $0x10, %ax # Setup the temporary 32-bit data selector
64 movw %ax, %ds
65 movw $0x20, %ax # Set stack to large 32-bit data segment
66 movw %ax, %ss
67 movl sp, %esp # Load stack pointer
68 movl arg4, %ebx # Prepare arguments for the C entry point
69 pushl %ebx
70 movl arg3, %ebx
71 pushl %ebx
72 movl arg2, %ebx
73 pushl %ebx
74 movl arg1, %ebx
75 pushl %ebx
76 movl ip, %ebx # Prepare entry address
77 ljmp *target
79 kick: mov %ax, %ds # Switch to large data segments
80 mov %ax, %es
81 movl $0, %ebp
82 call *%ebx # Jump to the C entry point