From 2d0245a85deb62cbed66c053f80f339e0d97ed70 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 29 Sep 2024 08:47:28 -0400 Subject: [PATCH] user mode: fix segments --- Makefile | 2 +- idt.cpp | 12 ++++++++++++ idt.hpp | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 284f931..cb08991 100644 --- a/Makefile +++ b/Makefile @@ -39,5 +39,5 @@ clean: run: myos.iso @echo " QEMU" - @qemu-system-i386 -drive file=$<,index=2,media=cdrom -monitor stdio -no-reboot -s -S #-d int + @qemu-system-i386 -drive file=$<,index=2,media=cdrom -monitor stdio -no-reboot #-s -S #-d int diff --git a/idt.cpp b/idt.cpp index c889c14..de15ec9 100644 --- a/idt.cpp +++ b/idt.cpp @@ -62,10 +62,22 @@ struct StubEntry asm volatile(R"( pusha + mov %%ds, %%ax + push %%ax + mov $0x10, %%ax + mov %%ax, %%ds + mov %%ax, %%es + mov %%ax, %%fs + mov %%ax, %%gs push %0 cld call interruptGeneralHandler pop %%eax + pop %%ax + mov %%ax, %%ds + mov %%ax, %%es + mov %%ax, %%fs + mov %%ax, %%gs popa add $0x4, %%esp iret diff --git a/idt.hpp b/idt.hpp index c9092dd..c5e7e47 100644 --- a/idt.hpp +++ b/idt.hpp @@ -7,6 +7,7 @@ struct Registers { std::uint32_t inum; + std::uint32_t ds; std::uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; std::uint32_t error; std::uint32_t eip, cs, eflags;