From 8325d90e9b7a8293e52874b64abea28879d0c39a Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Fri, 6 Aug 2021 22:55:57 +0200 Subject: [PATCH] Indent fix --- src/bootloader.asm | 10 +++++----- src/pm.asm | 9 ++++++++- src/pm/gdt.asm | 22 +++++++++++----------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/bootloader.asm b/src/bootloader.asm index e54643c..6c91be3 100644 --- a/src/bootloader.asm +++ b/src/bootloader.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 diff --git a/src/pm.asm b/src/pm.asm index 58f5ade..4a0a2f0 100644 --- a/src/pm.asm +++ b/src/pm.asm @@ -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 diff --git a/src/pm/gdt.asm b/src/pm/gdt.asm index c092d3e..4023658 100644 --- a/src/pm/gdt.asm +++ b/src/pm/gdt.asm @@ -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