From 39166e7863e32e4ef763d2a1b6fdcd6f616c1312 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Fri, 6 Aug 2021 23:05:28 +0200 Subject: [PATCH] Switching to PM --- src/pm.asm | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/pm.asm b/src/pm.asm index 4a0a2f0..b74f3a4 100644 --- a/src/pm.asm +++ b/src/pm.asm @@ -6,8 +6,29 @@ %include "pm/gdt.asm" ; GDT defined here ; Switching to PM -lgdt [gdt_descriptor] ; Tell the CPU about the GDT +[bits 16] +switch_to_pm: + 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 + +[bits 32] +; Init registers & stack when in PM +init_pm: + 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 -mov eax, cr0 ; Set first bit of the CR0 register -or eax, 0x1 ; to 1 -mov cr0, eax ; Update the control register