Merge pull request #17 from E-Almqvist/dev

Kernel!
pull/25/head
Elias Almqvist 3 years ago committed by GitHub
commit 9e6484f685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 12
      compile.sh
  3. 28
      src/bootloader.asm
  4. 7
      src/kernel.c
  5. 4
      src/pm/gdt.asm

1
.gitignore vendored

@ -1,2 +1,3 @@
bin/
*.bin
*.o

@ -1,6 +1,16 @@
#!/usr/bin/bash
done="[OK]"
fail="[FAIL]"
srcDir=src
binDir=bin
nasm -f bin $srcDir/bootloader.asm -i $srcDir -o $binDir/bootloader.bin
echo -n "Compiling bootloader... "
nasm -f bin $srcDir/bootloader.asm -i $srcDir -o $binDir/bootloader.bin && echo $done
echo -n "Compiling kernel... "
gcc -ffreestanding -c $srcDir/kernel.c -o $binDir/kernel.o && ld -o $binDir/kernel.bin -Ttext 0x1000 $binDir/kernel.o --oformat binary 2>/dev/null && echo $done
echo -n "Creating kernel image... "
cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image && echo $done

@ -1,12 +1,21 @@
[org 0x7c00] ; bootsector
KERNEL_OFFSET equ 0x1000
; Save the boot drive index
mov [BOOT_DRIVE], dl
; Move the stack pointer somewhere safe
mov bp, 0x8000 ; move it to 0x8000
mov bp, 0x9000 ; move it to 0x8000
mov sp, bp
; Load kernel into memory
mov bx, stat_kernel_load
call println
call load_kernel
; Switching to PM
mov bx, stat_pm_init
call println
call pm_preinit
jmp $ ; inf loop
@ -16,12 +25,25 @@
%include "pm.asm"
BEGIN_PM:
mov ebx, welcome_string
mov ebx, stat_pm_init
call vga_print
jmp $
welcome_string: db "e Operating-System (eOS): Version 2021 0.0", ASCII_END
[bits 16]
load_kernel:
mov bx, KERNEL_OFFSET ; Load kernel at the kernel offset
mov dh, 15 ; Read 15 sectors
mov dl, [BOOT_DRIVE] ; Drive index
call disk_read ; Load the kernel
ret
stat_pm_init: db "Entering 32bit Protected Mode...", ASCII_END
stat_kernel_load: db "Loading kernel into memory...", ASCII_END
stat_boot_success: db "Booting complete!", ASCII_END
BOOT_DRIVE: db 0
; Bootsector

@ -0,0 +1,7 @@
// VGA base address: 0xb8000
// Charpos = 0xb8000 + 2(row*80 + col)
void main() {
char* video_mem = (char*)0xb8000; // VGA Video Memory location
*video_mem = 'X';
}

@ -34,8 +34,8 @@ gdt_end: ; Mark the end so we can get the delta-memory (size of GDT)
; GDT descriptor
gdt_descriptor:
dw gdt_end - gdt_start - 1 ; Size of GDT is always -1 of actual size (WHY?!?!?!?!??!)
dd gdt_start ; Pointer to the GDT
dw gdt_end - gdt_start - 1 ; GDT size
dd gdt_start ; GDT pointer
; Lazy constants

Loading…
Cancel
Save