interrupt numbers ?

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

interrupt numbers ?

Post by Sam111 »

I am curious if anybody knows where i can get a list of all the valid interrupts numbers I can use in Os's like dos , windows , linux , and mac.

From what I know is linux just has int 80h
Windows int 2Eh
Dos int 21h
not sure about mac but since it is bsd-based I would assume same as linux.

I got a list of all vaild options for int 21h
http://spike.scu.edu.au/~barry/interrupts.html

But is those just the 3 possible valid int numbers that one could use in a user spaces / under and os that is in 32 bit or 64 modes.

I know if you are in real/16 bit mode you also have the bios interrupts and one can get a complete list by Ralph Brown's interrupt list.

But my main problem is figuring out all the valid int numbers available for my program in user space linux , windows , dos , or mac .

I know if I was creating my own OS from scratch in 16 bit mode all I would have is the bios/video,...etc commands. When switching to 32 and above you lose this and have to either right a driver or switch between 16 /above modes.

Anybody know for sure I am getting alot of mix answers on some IRC chats.
Basically I guess I am only interested in what int commands numbers are use-able in the user mode ring.
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re: interrupt numbers ?

Post by bubach »

Ralf Browns list actually contains some information on Linux and Windows too. Check this for an overview based on interrupt number:
http://www.ctyme.com/intr/int.htm

Also, DOS isn't just 21h, it also uses 20h for a "shortcut" way of terminating the current program for example. Not exactly sure what you mean by your question, do you want to make sure that you don't use any "taken" interrupt number? Going to set up user-space interrupts in some existing OS? For your own 32-bit OS there's no need to worry about what other OS's uses - and you can use several interrupts if you'd like.
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: interrupt numbers ?

Post by Sam111 »

Well, thanks and I have used your link in the passed.

But my real reason is I am curious what all the available int Xh commands I have available in user mode under windows and linux based Operating systems.

I know when I create my own I can define my own int commands when setting up my gdt,idt's stuff.

But I was more interested how the windows and linux os's have done it. I have only seen people using in their asm code int 2eh and int 80h when I google online.

So I am interested in if their is any more that are available for use. I know they want you to use their api's so your program will be more portable but I am curious what int commands for these OS are available.

Curious also if anybody knows where I can view the function that gets called by int 80h in linux's source code.

when I issue int 80h what function/where is the next place the code goes to.
Looking thru this gives me an idea on what int 2eh does http://shift32.wordpress.com/2011/10/14 ... emservice/
But I am still unsure of when you issue int 2eh where it jmps to first. ( would it go directly to the idt table or would this only be true in kernel mode)
Probably it goes to the idt 2eh entry and sets up some trap frame. But I am unsure if executing an int interrupt in user mode with the appropriated permission still has the same function stack frame as if you executed it in kernel mode....

Basically I have create my own os interrupts when createing my own toy os.
And when ever I issued my int xh command it would go to the function with address at the idt entry for that interrupt.
So when I issued int xh I would go to that function directly.
Or I could call that function directly by its name in kernel mode.
But in user mode the flow of things could be maybe different don't know fully if microsoft or linux os's some how patch it to a function that takes in all user land interrupts then does some things like set up trap frames ,..etc then call the real int interrupt.
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: interrupt numbers ?

Post by gravaera »

Yo:

The problem is that I'm having trouble figuring out what your real question is since you ramble a lot.

It seems apparent that you know that most kernels use SWI to allow userspace processes to enter kernel space. It seems like you already know the vectors used by Linux and Windows (though I haven't confirmed the vector for Windows myself). You've stated that you know that you can use whatever vector you like personally for your own kernel. The name of the topic is "interrupt numbers", and you have repeatedly spoken about "interrupt vector numbers" as "interrupt numbers", so it seems like that is what you mean by "interrupt numbers", but there isn't anything that can be answered about them since you seem to already know what needs to be known.

What is your question? Do you want to know what every single kernel in existence uses as its x86 SWI vector? Are you asking how kernels du jour allow multiple different functions to be facilitated through the same SWI vector?
...
But in user mode the flow of things could be maybe different don't know fully if microsoft or linux os's some how patch it to a function that takes in all user land interrupts then does some things like set up trap frames ,..etc then call the real int interrupt.
This is not a question :)

--Peace out
gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: interrupt numbers ?

Post by Sam111 »

It seems apparent that you know that most kernels use SWI to allow userspace processes to enter kernel space
Yes if by SWI you mean software interrupts , but I am confused about the difference when you call an interrupt in kernel mode as opposed to in user land mode.

For instance is int 80h equivalent to just saving some registers like flags reg ,...etc on the stack and then doing a call to syscall? In kernel mode int 80h would go to the function with the address in the idt automatically. If I issue int 80h in linux user space would it be doing the same thing as kernel mode issuing it. Or is their some in between functions and stuff on the call function stack?

I am unsure of the actions and flow of control when issuing an int command in user land under and os like linux or microsoft ...etc (never got that far in coding an os only worked in kernel land when coding duno if changing the CPL will change the flow of the interrupt call)

I hope you understand what I am getting at.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: interrupt numbers ?

Post by turdus »

Sam111 wrote:I am unsure of the actions and flow of control when issuing an int command in user land under and os like linux or microsoft ...etc (never got that far in coding an os only worked in kernel land when coding duno if changing the CPL will change the flow of the interrupt call)

I hope you understand what I am getting at.
We have a saying: After all ways you could figure out failed, read the fine manual. Intel documentation is your friend.

In protected mode, if an interrupt happens in userspace the segment selector is pushed onto the stack (CPL changed), opposite to in kernelspace only pointer pushed (CPL unchanged). This could be pain to handle, so in long mode segment selectors pushed unconditionally if IST method used.
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: interrupt numbers ?

Post by Sam111 »

In protected mode, if an interrupt happens in userspace the segment selector is pushed onto the stack (CPL changed), opposite to in kernelspace only pointer pushed (CPL unchanged). This could be pain to handle, so in long mode segment selectors pushed unconditionally if IST method used.

Sorry I am not understanding your abbr. what do you mean by IST ?

Also my understanding how an interrupt int command works is
1) pushes flags register on the stack
2) pushes return address on the stack (both cs code segment register and offset 32bit address) same as a far call with the addition of pushing the flag register on the stack as well.
3) jmps to address in the interrupt description table of the given function associated with the give interrupt number.

So I don't understand what you are getting at when you say
an interrupt happens in userspace the segment selector is pushed onto the stack (CPL changed), opposite to in kernelspace only pointer pushed (CPL unchanged).
using int in user space or kernel space still pushes the segment selector on the stack .... are you just saying in user space executing an int command modifies the CPL in the flags register in some way... I am confused now a little by you
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: interrupt numbers ?

Post by Combuster »

You really have guts to keep ignoring all RTFMs. Even after 5 bans :roll:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: interrupt numbers ?

Post by turdus »

As suggested, RTFM.
AMD64 vol2:
8.9.4 Interrupt-Stack Table
In long mode, a new interrupt-stack table (IST) mechanism is introduced as an alternative to the modified legacy stack-switch mechanism described above. The IST mechanism provides a method for specific interrupts, such as NMI, double-fault, and machine-check, to always execute on a known- good stack. In legacy mode, interrupts can use the hardware task-switch mechanism to set up a known- good stack by accessing the interrupt service routine through a task gate located in the IDT. However, the hardware task-switch mechanism is not supported in long mode.
When enabled, the IST mechanism unconditionally switches stacks.
Post Reply