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/
*.bin *.bin
*.o

@ -1,6 +1,16 @@
#!/usr/bin/bash #!/usr/bin/bash
done="[OK]"
fail="[FAIL]"
srcDir=src srcDir=src
binDir=bin 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 [org 0x7c00] ; bootsector
KERNEL_OFFSET equ 0x1000
; Save the boot drive index ; Save the boot drive index
mov [BOOT_DRIVE], dl mov [BOOT_DRIVE], dl
; Move the stack pointer somewhere safe ; Move the stack pointer somewhere safe
mov bp, 0x8000 ; move it to 0x8000 mov bp, 0x9000 ; move it to 0x8000
mov sp, bp mov sp, bp
; Load kernel into memory
mov bx, stat_kernel_load
call println
call load_kernel
; Switching to PM ; Switching to PM
mov bx, stat_pm_init
call println
call pm_preinit call pm_preinit
jmp $ ; inf loop jmp $ ; inf loop
@ -16,12 +25,25 @@
%include "pm.asm" %include "pm.asm"
BEGIN_PM: BEGIN_PM:
mov ebx, welcome_string mov ebx, stat_pm_init
call vga_print call vga_print
jmp $ 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 BOOT_DRIVE: db 0
; Bootsector ; 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
gdt_descriptor: gdt_descriptor:
dw gdt_end - gdt_start - 1 ; Size of GDT is always -1 of actual size (WHY?!?!?!?!??!) dw gdt_end - gdt_start - 1 ; GDT size
dd gdt_start ; Pointer to the GDT dd gdt_start ; GDT pointer
; Lazy constants ; Lazy constants

Loading…
Cancel
Save