! Fixed the root Makefile
[lightOS.git] / kernel / x86 / smp.S
blob16ba63ab07e72117aa964f5e054c8a5bfa662e1e
1 ; lightOS kernel
2 ; Copyright (C) 2007-2009 Jörg Pfähler
4 ; This program is free software; you can redistribute it and/or
5 ; modify it under the terms of the GNU General Public License
6 ; as published by the Free Software Foundation; either version 2
7 ; of the License, or (at your option) any later version.
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ; GNU General Public License for more details.
14 ; You should have received a copy of the GNU General Public License
15 ; along with this program; if not, write to the Free Software
16 ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
17 [bits 16]
18 [org 0x7000]
20 smp_entry:
21         ; Load new GDT
22         lgdt [GDTR]
23         
24         ; Set Cr0.PE
25         mov eax, cr0
26         or eax, 0x01
27         mov cr0, eax
28         
29         ; Jump into protected-mode
30         jmp 0x08:pmode
32 [bits 32]
33 pmode:
34         mov ax, 0x10
35         mov ds, ax
36         mov ss, ax
37         
38         ; load page directory
39   ; TODO
40         mov eax, 0x300000
41         mov cr3, eax
42         
43         ; Enable PSE (=Page Size Extension) & VME (Virtual Mode Emulation)
44         mov eax, cr4
45         or eax, 0x11
46         mov cr4, eax
47         
48         ; Enable Paging
49         mov eax, cr0
50         or eax, 0x80000000
51         mov cr0, eax
52         
53         mov eax, [0x7FFC]
54         jmp eax
55 ;##########################################################################
56 ;##### Global descriptor table                                        #####
57 ;##########################################################################
58 GDT:
59         dd 0x00000000
60         dd 0x00000000
61         ; kernel-code
62         dw 0xFFFF
63         dw 0x0000
64         db 0x00
65         db 0x98
66         db 0xCF
67         db 0x00
68         ; kernel-data
69         dw 0xFFFF
70         dw 0x0000
71         db 0x00
72         db 0x92
73         db 0xCF
74         db 0x00
75 ;##########################################################################
76 ;##### Global descriptor table register                               #####
77 ;##########################################################################
78 GDTR:
79         dw 0x18
80         dd GDT