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

@ -3,4 +3,11 @@
%include "pm/vga/print.asm" %include "pm/vga/print.asm"
; GDT & switching to PM ; 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) ; Type: 1010b (code:conforming:readable:accessed)
; Flags2: 1100b (granularity:32bit default:64bit seg:AVL) ; Flags2: 1100b (granularity:32bit default:64bit seg:AVL)
dw 0xffff ; Limit (bits 0-15) dw 0xffff ; Limit (bits 0-15)
dw 0x0 ; Base (bits 0-15) dw 0x0 ; Base (bits 0-15)
db 0x0 ; Base (bits 16-23) db 0x0 ; Base (bits 16-23)
db 10011010b ; Flags1 : Type db 10011010b ; Flags1 : Type
db 11001111b ; Flags2 : Limit (16-19) 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 ; Same flags as gdt_code but different type flags
; Type: 0010b (code:expand dowm:writable:accessed) ; Type: 0010b (code:expand dowm:writable:accessed)
dw 0xffff ; Limit (bits 0-15) dw 0xffff ; Limit (bits 0-15)
dw 0x0 ; Base (bits 0-15) dw 0x0 ; Base (bits 0-15)
db 0x0 ; Base (bits 16-23) db 0x0 ; Base (bits 16-23)
db 10010010b ; Flags1 : Type db 10010010b ; Flags1 : Type
db 11001111b ; Flags2 : Limit (16-19) 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_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 ; Size of GDT is always -1 of actual size (WHY?!?!?!?!??!)
dd gdt_start ; Pointer to the GDT dd gdt_start ; Pointer to the GDT
; Lazy constants ; Lazy constants

Loading…
Cancel
Save