pull/15/head
E. Almqvist 3 years ago
parent 5c9ae46217
commit 8325d90e9b
  1. 10
      src/bootloader.asm
  2. 9
      src/pm.asm
  3. 22
      src/pm/gdt.asm

@ -11,9 +11,9 @@
call println
; Read second sector (outside bootsector)
mov bx, 0x9000 ; LOAD LOCATION
mov dh, 2 ; SECTOR-COUNT
mov dl, [BOOT_DRIVE] ; DISK-INDEX
mov bx, 0x9000 ; LOAD LOCATION
mov dh, 2 ; SECTOR-COUNT
mov dl, [BOOT_DRIVE] ; DISK-INDEX
call disk_read
@ -31,12 +31,12 @@
%include "equ/ascii.asm"
%include "bios.asm"
%include "pm.asm"
; Data
welcome_string: db "e Operating-System (eOS)", ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, "Version 2021 0.0", ASCII_END
BOOT_DRIVE: db 0
%include "pm.asm"
; Bootsector
times 510-($-$$) db 0
dw 0xaa55 ; magic BIOS numbers

@ -3,4 +3,11 @@
%include "pm/vga/print.asm"
; GDT & switching to PM
%include "pm/gdt.asm" ; GDT
%include "pm/gdt.asm" ; GDT defined here
; Switching to PM
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

@ -12,30 +12,30 @@ gdt_code: ; Code SD
; Type: 1010b (code:conforming:readable:accessed)
; Flags2: 1100b (granularity:32bit default:64bit seg:AVL)
dw 0xffff ; Limit (bits 0-15)
dw 0x0 ; Base (bits 0-15)
db 0x0 ; Base (bits 16-23)
dw 0xffff ; Limit (bits 0-15)
dw 0x0 ; Base (bits 0-15)
db 0x0 ; Base (bits 16-23)
db 10011010b ; Flags1 : Type
db 11001111b ; Flags2 : Limit (16-19)
db 0x0 ; Base (bits 24-31)
db 0x0 ; Base (bits 24-31)
gdt_data: ; Data SD
gdt_data: ; Data SD
; Same flags as gdt_code but different type flags
; Type: 0010b (code:expand dowm:writable:accessed)
dw 0xffff ; Limit (bits 0-15)
dw 0x0 ; Base (bits 0-15)
db 0x0 ; Base (bits 16-23)
dw 0xffff ; Limit (bits 0-15)
dw 0x0 ; Base (bits 0-15)
db 0x0 ; Base (bits 16-23)
db 10010010b ; Flags1 : Type
db 11001111b ; Flags2 : Limit (16-19)
db 0x0 ; Base (bits 24-31)
db 0x0 ; Base (bits 24-31)
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 ; Size of GDT is always -1 of actual size (WHY?!?!?!?!??!)
dd gdt_start ; Pointer to the GDT
; Lazy constants

Loading…
Cancel
Save