gdt and idt ???

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.
Locked
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

gdt and idt ???

Post by Sam111 »

interrupt ?
I am wondering when I create an interrupt route must it have void parameters and return void. Or can you pass parameters and get return values from an interrupt routine.

The other problem I am running into is when to use an interrupt or a regular function.
The system reserves the first 32 interrupt entries for internal hardware interrupts cause by the cpu, their are then 16 irq hardware interrupts that are triggered when hardware other then the cpu causes the interrupt such as a harddrive , keyboard , mouse , sound card ,...etc
What my problem is if I use the 16 irq which I think have to return void and take void parameters.... then how do I write a sector to my harddrive (cann't use interrupts because I cann't pass the data to it.) And I don't really want to start using a global array to do.

I just don't see the point of interrupts only for maybe keyboard/mouse , timer that's it.

And if I create user defined interrupts these seem to be useless since you cann't pass/return stuff to them only call them. So they are only useful if you put stuff globally which is in general not a good programming practice.

gdt ?
I have a few entries in the gdt table one for null entry , kernel data , kernel code , user mode data , user mode code. Why is their so many possible entries that can be put into a gdt (8192
entries) and also the possiblity of using LDT entries to extend this.
I would think an OS would only typically every use a hand full of entries in the gdt.

Curious what linux, windows xp , and mac osx use???
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: gdt and idt ???

Post by NickJohnson »

If you don't know whether to use an interrupt or a function call, you clearly don't grasp the concept of an interrupt. You _really_ need to go and (re)read a tutorial or the wiki article about interrupts.
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: gdt and idt ???

Post by Sam111 »

well , heres the thing.
Correct me if I am wrong interrupts function have to return void and have void parameters.

I am wondering where I should put my driver code for my harddrive.
I would think it would be better to have it in an interrupt but if I do that I have to pass the sector data in a global variable.

If I just don't use interrupt and use regular functions am I going to run into the problem of 2 programs calling my harddrive driver at the same time.

Because in a multitasking environment problems may arise correct?

I just don't see the point of interrupts in protected mode other then pit , timer , keyboard ,...etc stuff .

When would you every want a user defined interrupt ?

Thats all.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: gdt and idt ???

Post by gerryg400 »

Sam111, I'm going to take a risk here and try and help you. Please don't ask any more questions.

Read the articles on the wiki about interrupts (http://wiki.osdev.org/Interrupts and http://wiki.osdev.org/Interrupt_Service_Routines). Also follow the links at the end of the second page and read the stuff there. Post back when you're done.
If a trainstation is where trains stop, what is a workstation ?
User avatar
hailstorm
Member
Member
Posts: 110
Joined: Wed Nov 02, 2005 12:00 am
Location: The Netherlands

Re: gdt and idt ???

Post by hailstorm »

You don't call interrupts by yourself, do you? Interrupts are system-generated events. The device that generates the interrupts is programmed by you to generate these interrupts whenever it finishes a request or doing something else. For example
- Initialize the harddrive to generate an interrupt after a read or write
- Execute a read or write request to the harddrive with the parameters you want to pass
- Wait for the irq to be fired
Are you misinterpreting interrupts with calling the bios using an int 10 command? They are not exactly the same...
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: gdt and idt ???

Post by JamesM »

The next retarded question will get you a forum warning.

* The topic title is not in any way related to the actual question.
* The question is trivially basic (what are interrupts used for?) and shows a lack of understanding of the most basic reading materials.
* Come back when you've read up on the subject matter.

Thread locked.

James
Locked