Jump to test kernel

This commit is contained in:
Robbe Van Herck 2019-12-28 16:44:11 +01:00
parent b09d54a346
commit b308617ac8
No known key found for this signature in database
GPG Key ID: A66F76F7B81BD784
3 changed files with 68 additions and 4 deletions

View File

@ -2,12 +2,13 @@ run_kernel: compile_kernel
qemu-system-i386 -kernel target/kernel.bin
compile_kernel:
nasm -felf32 kernel/boot.asm -o target/boot.o
nasm -f bin kernel/boot.asm -o target/kernel_boot.o
i686-elf-gcc -c kernel/kernel.c -o target/kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra
i686-elf-gcc -T kernel/linker.ld -o target/kernel.bin -ffreestanding -O2 -nostdlib target/boot.o target/kernel.o -lgcc
i686-elf-gcc -T kernel/linker.ld -o target/kernel.bin -ffreestanding -O2 -nostdlib target/kernel_boot.o target/kernel.o -lgcc
compile_bootloader:
rm -rf target/boot.bin
nasm -f bin bootloader/test_kernel.asm -o target/kernel.bin
nasm -f bin -o target/boot.bin bootloader/main.asm
run_bootloader: compile_bootloader

View File

@ -190,17 +190,71 @@ jmp .end
.a20_enabled:
; disable interrupts
cli
; reset ds
xor ax, ax
mov ds, ax
; load the GDT
lgdt [.gdt_desc]
; switch to protected mode
mov eax, cr0
or eax, 1
mov cr0, eax
; jump to 32 bit code
jmp 0x08:.clear_pipe
[BITS 32]
.clear_pipe:
; set Data Segment and Stack segment
mov ax, 10h
mov ds, ax
mov ss, ax
; set up stack
mov esp, 0x090000
jmp 0x08:0x8000
.end:
hlt
jmp .end
.data:
.str_no_A20:
db "A20 not enabled..."
db "A20 not enabled"
db 0
.gdt:
dd 0
dd 0
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
.gdt_end:
.gdt_desc:
dw .gdt_end - .gdt - 1
dd .gdt
; print padding nullbytes
times 510 - ($ - $$) db 0

View File

@ -0,0 +1,9 @@
[bits 32]
mov byte [ds:0B8000h], 0h ; Move the ASCII-code of 'P' into first video memory
mov byte [ds:0B8001h], 0h ; Assign a color code
.loop:
inc byte [ds:0B8000h]
inc byte [ds:0B8001h]
jmp .loop