Enabling interupts in longmode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pkd

Enabling interupts in longmode

Post by pkd »

Hi,

Ive recently started programming for the x86_64 and have successfully entered long mode, the problem i am having is with enabling interrupts when using
sti - I am getting a General protection fault.
{works fine in Real & 32PMode}


I was wondering if anyone has come accross this problem and knows how to solve it.

I have googled but am yet to find anything to help.

bye pkd.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Enabling interupts in longmode

Post by Candy »

pkd wrote: Hi,

Ive recently started programming for the x86_64 and have successfully entered long mode, the problem i am having is with enabling interrupts when using
sti - I am getting a General protection fault.
{works fine in Real & 32PMode}


I was wondering if anyone has come accross this problem and knows how to solve it.
My guess is on the interrupt stack mechanism x86_64 introduced. I don't have any experience with interrupts in it, so I can't help you there.
pkd

Re:Enabling interupts in longmode

Post by pkd »

Hi again,

Still havent got it working yet, but am about to compile bochs and hopefully willmget some extended error information, Ill post again if i work it out.

Thanks for your reply.

bye pkd.
pkd

Re:Enabling interupts in longmode

Post by pkd »

hi again,

Ive got it fixed sortof, for some reason the first STI is causing a General protection fault but once ive been through the exception handler once STI works fine

It is a bit of a workaround but at least i can get on with writing now.

By the way it works without the #GP in bochs

To do this ive added the following code.{ rcx points to the return address}
   mov   rcx,Entry
   call   0x11000 ;My current INT/Exception Setup
Entry:
   mov   rsi,EntryMsg
   mov   rdi,0xb8a00
   call   print64

   mov   r15,0x1234567812345678 ;my STI signature
   sti            

END:
   hlt
   jmp   END   ;TEMP MSGLOOP
and this to my exception handler for #GP

Setup ints/Exceptions

mov   rdi,ENTRY ;this just stores the iretq return address
   mov   [rdi],rcx

;-------------------------------------------------
Exc13:
   mov   r14,0x1234567812345678 ;check for STI signature
   cmp   r15,r14
   jnz   Exc13a

         add   rsp,8
         mov   rdi,[ENTRY]
         mov   [rsp],rdi

         iretq

Exc13a:
   mov   rsi,Ex13txt
   jmp   ExcPrint
ok bye
pkd.
Post Reply