Bootloader refactor

pull/34/head
E. Almqvist 3 years ago
parent 0e6ae465ad
commit 56c8319850
  1. 7
      bootloader/bios.asm
  2. 45
      bootloader/bootloader.asm
  3. 37
      bootloader/pm.asm

@ -1,7 +0,0 @@
; EQUs
%include "bootloader/equ/bios.asm"
; SRs
%include "bootloader/bios/convert.asm"
%include "bootloader/bios/print.asm"
%include "bootloader/bios/disk.asm"

@ -21,8 +21,49 @@
jmp $ ; inf loop
%include "bootloader/equ/ascii.asm"
%include "bootloader/bios.asm"
%include "bootloader/pm.asm"
%include "bootloader/equ/bios.asm"
; BIOS SRs
%include "bootloader/bios/convert.asm"
%include "bootloader/bios/print.asm"
%include "bootloader/bios/disk.asm"
; Protected Mode SRs
%include "bootloader/equ/vga.asm"
%include "bootloader/pm/vga/print.asm"
; GDT & switching to PM
%include "bootloader/pm/gdt.asm" ; GDT defined here
; Switching to PM
[bits 16]
pm_preinit:
cli ; Switch interupts
lgdt [gdt_descriptor] ; Tell the CPU about the GDT
mov eax, cr0 ; Set first bit of the CR0 register
or eax, 0x1 ; to 1
mov cr0, eax ; Update the control register
; Initialize PM
jmp GDT_CODE_SEG:pm_init
[bits 32]
; Init registers & stack when in PM
pm_init:
mov ax, GDT_DATA_SEG ; Point the segment registers to GDT_DATA_SEG
; Segment registers
mov ds, ax
mov ss, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ebp, 0x900000 ; Update the stack pointer
mov esp, ebp
call BEGIN_PM
BEGIN_PM:
; Inform of mode switch

@ -1,37 +0,0 @@
; Utils
%include "bootloader/equ/vga.asm"
%include "bootloader/pm/vga/print.asm"
; GDT & switching to PM
%include "bootloader/pm/gdt.asm" ; GDT defined here
; Switching to PM
[bits 16]
pm_preinit:
cli ; Switch interupts
lgdt [gdt_descriptor] ; Tell the CPU about the GDT
mov eax, cr0 ; Set first bit of the CR0 register
or eax, 0x1 ; to 1
mov cr0, eax ; Update the control register
; Initialize PM
jmp GDT_CODE_SEG:pm_init
[bits 32]
; Init registers & stack when in PM
pm_init:
mov ax, GDT_DATA_SEG ; Point the segment registers to GDT_DATA_SEG
; Segment registers
mov ds, ax
mov ss, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ebp, 0x900000 ; Update the stack pointer
mov esp, ebp
call BEGIN_PM
Loading…
Cancel
Save