Fix build.
[reactos.git] / hal / halx86 / mp / mpsboot.asm
1 ;
2 ; COPYRIGHT: See COPYING in the top level directory
3 ; PROJECT: ReactOS kernel
4 ; FILE: hal/halx86/mp/mpsboot.c
5 ; PURPOSE: Bootstrap code for application processors
6 ; PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 ; UPDATE HISTORY:
8 ; Created 12/04/2001
9 ;
10
11 ;
12 ; Memory map at this stage is:
13 ; 0x2000 Location of our stack
14 ; 0x3000 Startup code for the APs (this code)
15 ;
16
17 ;
18 ; Magic value to be put in EAX when multiboot.S is called as part of the
19 ; application processor initialization process
20 ;
21 AP_MAGIC equ 12481020h
22
23
24 X86_CR4_PAE equ 00000020h
25
26 ;
27 ; Segment selectors
28 ;
29 %define KERNEL_CS (0x8)
30 %define KERNEL_DS (0x10)
31
32 section .text
33
34 global _APstart
35 global _APend
36
37 ; 16 bit code
38 BITS 16
39
40 _APstart:
41 cli ; Just in case
42
43 xor ax, ax
44 mov ds, ax
45 mov ss, ax
46
47 mov eax, 3000h + APgdt - _APstart
48 lgdt [eax]
49
50 mov eax, [2004h] ; Set the page directory
51 mov cr3, eax
52
53 mov eax, [200ch]
54 cmp eax,0
55 je NoPae
56
57 mov eax,cr4
58 or eax,X86_CR4_PAE
59 mov cr4,eax
60
61 NoPae:
62
63 mov eax, cr0
64 or eax, 80010001h ; Turn on protected mode, paging and write protection
65 mov cr0, eax
66
67 db 0eah
68 dw 3000h + flush - _APstart, KERNEL_CS
69
70 ; 32 bit code
71 BITS 32
72
73 flush:
74 mov ax, KERNEL_DS
75 mov ds, ax
76 mov es, ax
77 mov fs, ax
78 mov gs, ax
79 mov ss, ax
80
81 ; Setup a stack for the AP
82 mov eax, 2000h
83 mov eax, [eax]
84 mov esp, eax
85
86 ; Jump to start of the kernel with AP magic in ecx
87 mov ecx, AP_MAGIC
88 mov eax,[2008h]
89 jmp eax
90
91 ; Never get here
92
93
94 ; Temporary GDT descriptor for the APs
95
96 APgdt:
97 ; Limit
98 dw (3*8)-1
99 ; Base
100 dd 3000h + gdt - _APstart
101
102 gdt:
103 dw 0x0 ; Null descriptor
104 dw 0x0
105 dw 0x0
106 dw 0x0
107
108 dw 0xffff ; Kernel code descriptor
109 dw 0x0000
110 dw 0x9a00
111 dw 0x00cf
112
113 dw 0xffff ; Kernel data descriptor
114 dw 0x0000
115 dw 0x9200
116 dw 0x00cf
117
118 _APend: