Page 3 of 3

Re: Problem writing interrupts handler?

Posted: Tue Mar 01, 2016 3:00 pm
by chris13524
Could the issue be that I need to switch to protected mode? I'm not sure if QEMU starts us out in 32 bits or not.

From my understanding here: http://wiki.osdev.org/Protected_Mode You set up the GDT and set a control register. I did the same thing, but it didn't fix the issue.

Here's how I do it:

Code: Select all

gdt_flush:
   mov 4(%esp), %eax
   lgdt (%eax)

   mov 0x10, %ax
   mov %ax, %ds
   mov %ax, %es
   mov %ax, %fs
   mov %ax, %gs
   mov %ax, %ss

	mov %cr0, %eax
	or %al, 1     // set PE (Protection Enable) bit in CR0 (Control Register 0)
	mov %eax, %cr0
   ljmp $0x08, $.flush
.flush:
   ret

Re: Problem writing interrupts handler?

Posted: Tue Mar 01, 2016 3:38 pm
by kzinti
Then your first task is to determine if QEmu does start in 32 bits or not =)

Re: Problem writing interrupts handler?

Posted: Tue Mar 01, 2016 4:39 pm
by iansjack
Your multiboot kernel will start in protected mode whether you use grub or load it directly in qemu.

Re: Problem writing interrupts handler?

Posted: Tue Mar 01, 2016 5:56 pm
by SpyderTL
iansjack wrote:Your multiboot kernel will start in protected mode whether you use grub or load it directly in qemu.
But, you should set up your own GDT and IDT, regardless of whether GRUB or QEMU already configured one. There's no way you can rely on their configuration.