summaryrefslogtreecommitdiff
path: root/mp
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2015-05-16 20:42:37 +0200
committerMichal Idziorek <m.i@gmx.at>2015-05-16 20:42:37 +0200
commit3bac6dd02d640923646b8ad988f509f47adab57f (patch)
tree42d91a578fba55f6e0e6e473644aa7941ae1863c /mp
parentec6d07e29d1d55afe9d2c6f7f25e9fed20819af6 (diff)
working on smp support, strange things happening!?
Diffstat (limited to 'mp')
-rw-r--r--mp/mp.asm84
1 files changed, 84 insertions, 0 deletions
diff --git a/mp/mp.asm b/mp/mp.asm
new file mode 100644
index 0000000..740a1a0
--- /dev/null
+++ b/mp/mp.asm
@@ -0,0 +1,84 @@
+; master boot record for application processors
+
+[org 0x7000]
+[bits 16]
+
+
+
+ cli ;switch off interrupts!
+ lgdt [gdt_descriptor] ;load descriptor table!
+
+ ;switch on 32-bit protected mode
+ mov eax, cr0
+ or eax,0x1
+ mov cr0, eax
+
+ jmp 0x8:init_pm
+
+[bits 32]
+
+
+LLOCK: dd 0
+
+init_pm:
+
+ mov ax, 0x10
+ mov ds, ax
+ mov ss, ax
+ mov es, ax
+ mov fs, ax
+ mov gs, ax
+
+ mov ebp, 0x8000
+ mov esp, ebp
+
+ call boot_32_pm ;continue booting in 32-bit protected mode
+
+boot_32_pm:
+
+ mov eax, 1 ; semaphore
+ xchg eax, [LLOCK]
+ cmp eax,1
+ je $
+
+ call [0x8010] ;kernel_ap ;jump into our Kernel!
+ jmp $ ; should never be reached
+
+
+gdt_start:
+
+gdt_null: ;null descriptor (2 x 4 bytes)
+ dd 0x0
+ dd 0x0
+
+gdt_code:
+ ; flags:
+ ; present: 1 / privilege: 00 / type: 1
+ ; code: 1 / conforming: 0 / readable: 1 / accessed: 0
+ ; granularity: 1 / 16-bit default: 1 / 64-bit seg: 0 / AVL: 0
+ dw 0xffff ;limit
+ dw 0x0 ;base
+ db 0x0 ;base
+ db 10011010b ;flags
+ db 11001111b ;flags & seg.limit
+ db 0x0 ;base
+
+gdt_data:
+ ; flags:
+ ; code: 0 / expand down: 0 / writable: 1 / accessed: 0
+ dw 0xffff
+ dw 0x0
+ db 0x0
+ db 10010010b
+ db 11001111b
+ db 0x0
+
+gdt_end:
+
+gdt_descriptor:
+ dw gdt_end-gdt_start-1
+ dd gdt_start
+
+CODE_SEG equ gdt_code - gdt_start
+DATA_SEG equ gdt_data - gdt_start
+