summaryrefslogtreecommitdiff
path: root/src/boot.asm
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2020-09-06 00:48:07 -0400
committerBenji Dial <benji6283@gmail.com>2020-09-06 00:48:07 -0400
commite8c6577617bffa4402c07c7aa20e3c24f03c1c20 (patch)
tree2fb9230b62d2344a44453117de9e656892219788 /src/boot.asm
parent7ff724fe8f709440da9c730fdb8dcbaa4f989ed5 (diff)
downloadportland-os-e8c6577617bffa4402c07c7aa20e3c24f03c1c20.tar.gz
program loading, others
big kernel additions: paging, elf loading, separate kernel and user page allocation it now properly loads and runs sd0:bin/init.elf still need to determine which disk was booted from, and start the init on that disk
Diffstat (limited to 'src/boot.asm')
-rw-r--r--src/boot.asm49
1 files changed, 39 insertions, 10 deletions
diff --git a/src/boot.asm b/src/boot.asm
index c74145c..28d1a89 100644
--- a/src/boot.asm
+++ b/src/boot.asm
@@ -10,6 +10,7 @@ pci_ver equ 0x4002
last_pci_bus equ 0x4004
pci_support equ 0x80
+pae_support equ 0x40
in al, 0x92
or al, 0x02
@@ -46,6 +47,34 @@ pci_support equ 0x80
mov byte [last_pci_bus], cl
no_pci:
+ mov eax, 1
+ cpuid
+
+ test dl, 0x40
+ jz no_pae
+
+ or byte [support_flags], pae_support
+
+no_pae:
+ mov ax, 0x1000
+ mov es, ax
+ xor di, di
+
+ mov edx, 0x534d4150
+ xor ebx, ebx
+
+mmap_loop:
+ mov eax, 0xe820
+ mov ecx, 24
+ int 0x15
+
+ jc mmap_end
+ add di, 24
+ test ebx, ebx
+ jnz mmap_loop
+mmap_end:
+ mov word [0x4006], di
+
cli
lgdt [gdt]
@@ -54,36 +83,36 @@ no_pci:
or al, 0x01
mov cr0, eax
- jmp 0x08:pmode
+ jmp 0x10:pmode
bits 32
pmode:
- mov ax, 0x10
+ mov ax, 0x18
mov ds, ax
mov ss, ax
mov esp, 0x00040000
xor ebp, ebp
+
call kernel_segment * 16
halt:
hlt
jmp halt
-times $$ + 0x018a - $ db 0
+times $$ + 510 - 0x3e - $ - (gdt.e - gdt) db 0
-;0x7dc8
gdt:
dw .e - .t
dd .t
.t:
- dq 0x0000_0000_0000_0000
- dq 0x00c0_9a00_0000_0037
- dq 0x00c1_9200_0000_ffff
- dq 0x0000_0000_0000_0000;TODO: task
- dq 0x0000_0000_0000_0000
- dq 0x0000_0000_0000_0000
+ dq 0x0000_0000_0000_0000;0x00: null
+ dq 0x0040_8900_4f98_0068;0x08: tss, 0x4f98
+ dq 0x00cf_9a00_0000_ffff;0x10: kernel code
+ dq 0x00cf_9200_0000_ffff;0x18: kernel data
+ dq 0x00cf_fa00_0000_ffff;0x20: user code
+ dq 0x00cf_f200_0000_ffff;0x28: user data
.e:
dw 0xaa55 \ No newline at end of file