can't set IDT entry twice!!!

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
J. Weeks

can't set IDT entry twice!!!

Post by J. Weeks »

Okay guys, I really need some help here... this makes
_NO_ sence to me!

I've defined and set a timer interrupt, and then
enabled IRQ 0. This works fine.

Then I disable IRQ 0, which also works fine.

I then re-define the timer interrupt with
another function, and re-enable IRQ 0.

My problem? When the interrupt starts up again,
the function hasn't changed!!! It's still using
the old function!!!

How is that possible!?
My createGate function seems to be able to set an
interrupt _once_, and only once!!! Huh? The same
thing happens with the keyboard interrupt... I tested it
with that one too.

My createGate code is as follows, if it helps:

void createGate(long table, short desc_num, long offset,
short selector, long control) {
Gate *gate ;
gate = (Gate *)(table + desc_num * 8);

gate->offset_low = offset & 0xffff;
gate->selector = selector;
gate->access = control + D_PRESENT;
gate->offset_high = offset >> 16;

return;
}

Any ideas?
J. Weeks

RE:can't set IDT entry twice - strange!

Post by J. Weeks »

Sorry guys, didn't mean to post twice...

Anyway, I found a solution, but it doesn't seem
anywhere near adequate!

After re-loading an idt entry (ie, changing it) I'm forced to
reload the idt. I assume this works by invalidating
some cache memory that's used to hold IDT entries.

So, I'm curious... is this in fact necessary, or
is there another way to invalidate the idt cache.

Also, if this is required, will it also be required
if GDT or LDT entries are changed.

Thanks a ton guys,
J.Weeks
Guest

RE:can't set IDT entry twice!!!

Post by Guest »

>On 2001-08-07 21:16:25, J. Weeks wrote:

>I then re-define the timer interrupt with
>another function, and re-enable IRQ 0.
>
>My problem? When the interrupt starts up again,
>the function hasn't changed!!! It's still using
>the old function!!!

It sounds like these are two different values:
- where you think the IDT is
- where the CPU thinks the IDT is

The code continues to call the old
interrupt function because your changes
to the IDT went off into hyperspace somewhere.

I don't think you need to do LIDT again
after changing the IDT.
J. Weeks

RE:can't set IDT entry twice!!!

Post by J. Weeks »

>It sounds like these are two different values:
>- where you think the IDT is
>- where the CPU thinks the IDT is
>
>The code continues to call the old
>interrupt function because your changes
>to the IDT went off into hyperspace somewhere.

But the IDT code does work correctly, 'cuz it
sets the interrupts up in the first place... int 0
to 18, and 32, and 33 are setup correctly.

However, when I use that same function to overwrite
my int 32 (the timer), it still uses the old function.

>I don't think you need to do LIDT again
>after changing the IDT.

It doesn't seem like you should have to... but for
some reason I do... I think it clears some IDT
cache or something.

Another possible reason: I'm testing my OS using
the VMWare virtual machine... it might have bugs
when emulating an IDT..

In any event, it all works now.
Post Reply