LIDT in VC++ ??

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
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

LIDT in VC++ ??

Post by LordMage »

okay, I am still looking online but can't find anything so far. I know to load the IDT you simply call

lidt [idt_pointer]

but I can't stick my variable in VC++'s inline assembler. I get 'Improper Operand Type' as an error. here is what I have tried and the deffinition of my idt_pointer

Okay, I have tried both:

Code: Select all

_asm {
     lidt idt_desc
}
and...

Code: Select all

_asm {
     lidt [idt_desc]
}
neither work. same error.

here is the code defining my pointer

Code: Select all


struct
{
	unsigned short size;
	unsigned long offset;
} idt_desc;

idt_desc.size=(256*8)-1;
idt_desc.offset=(unsigned long )idt;

_asm
 {
	lidt idt_desc
}

I have also tried making the offset a pointer and have tried to directly make idt_desc a pointer, none of them work and usually cause more errors.

any suggestions would be great.
Getting back in the game.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post by neon »

Code: Select all

_asm {
     lidt [idt_desc]
} 
Hm...This should work... You do do this inside of a function, correct? (i.e, not globally as shown in your example code?) If so, then it should work just fine...

If you like, try this (From my MSVC++ kernel):

Code: Select all

// load interrupt descriptor table
#define lidt(idt) \
	_asm cli \
	_asm lidt [idt]
To use it, just call it like this:

Code: Select all

lidt (idt_desc);
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

Post by LordMage »

Yes, they are being called from inside of Interrupt::Interrupt() I think I will try the define method and see if that works, thanks for the suggestion
Getting back in the game.
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

Post by LordMage »

Okay, that looks better but I am still getting the same error. I sure wish I knew what I was doing haha! again, I am open to any suggestions that anyone might have.
Getting back in the game.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post by neon »

Okay, that looks better but I am still getting the same error. I sure wish I knew what I was doing haha! again, I am open to any suggestions that anyone might have.
I kind of expected that. What complier do you have?

I am using MSVC++ 2005, which is the code I posted.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

Post by LordMage »

I am using the exact same development enviroment you are, that is why I was using your tutorials to get started. you just haven't covered this part in detail yet.

I did get it working. I was thinking about what you said about the global vs. local, everything except for the struct definition was local operation inside a funciton. I double checked and the struct was defined as a part of the class. I moved it to inside the constructor and now it is working. :D Next step keyboard map thanks for the help
Getting back in the game.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post by neon »

I'm glad you got it working :D
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply