Calling API's
Calling API's
With my newfound success with my OS, I think I'm ready to expand my kernel a bit. I'm going to add FAT file system support by myself, but one other function I want to add is the ability to call my API's. I've searched through the forums and on google and have found close to no documentation on the calling of API's. If anyone could help me in writing this code it would be very helpful.
xOS info:
real mode
made in FASM
xOS info:
real mode
made in FASM
Re: Calling API's
In the real mode dos world they tended to be called tsr's Terminate and Stay Resident programs. A program would be loaded to a high spot in memory, the high mem would be adjusted, An int would be redirected to that program..... If you didn't like the way bios or dos did something you could redirect one of their int's or you could hunt down one not in use. Haven't done any in probably 15 years now, but there is a ton of info about them around.me239 wrote:no documentation on the calling of API's.
xOS info:
real mode
made in FASM
Re: Calling API's
Could you give me any advice on how to set the IRV and handler? BTW I've also heard about Call Gates. Can you give me any examples of making call gates?roboman wrote:In the real mode dos world they tended to be called tsr's Terminate and Stay Resident programs. A program would be loaded to a high spot in memory, the high mem would be adjusted, An int would be redirected to that program..... If you didn't like the way bios or dos did something you could redirect one of their int's or you could hunt down one not in use. Haven't done any in probably 15 years now, but there is a ton of info about them around.me239 wrote:no documentation on the calling of API's.
xOS info:
real mode
made in FASM
Thanks
-
- Member
- Posts: 50
- Joined: Sun Sep 20, 2009 4:03 pm
Re: Calling API's
I used a far-call API in this small OS demo.
http://forum.osdev.org/viewtopic.php?f=2&t=21464
Also see how i remapped int 20h to my own routine...
http://forum.osdev.org/viewtopic.php?f=2&t=21464
Also see how i remapped int 20h to my own routine...
Re: Calling API's
I looked at your OS and I didn't see anything about interrupts. All I saw was I boot loader capable of booting a com or exe file.bitshifter wrote:I used a far-call API in this small OS demo.
http://forum.osdev.org/viewtopic.php?f=2&t=21464
Also see how i remapped int 20h to my own routine...
Re: Calling API's
Call Gates, as in playing with privilege level, Sorry no, if my programs can't access the entire system and touch any piece of hardware they want, well then where is the fun in that. So I never played with that stuff and leave the entire system open. That's why I'm doing this and not writing Droid programs or Windows games. IRV? as in Reference Version stuff for large group projects? No history with that.me239 wrote:Could you give me any advice on how to set the IRV and handler? BTW I've also heard about Call Gates. Can you give me any examples of making call gates?
Thanks
Re: Calling API's
Basically, you set an IDT in protected mode or IVT in real mode, and basically both are the some thing.
When you code "int 10", the CPU is interrupting all what it does, and go to the code who pointed in the entry in the IDT/IVT number 10 in the case. Then execute the code of you API.When your API should terminate and return the instruction pointer to the previously executed program, you code "iret".
This is the normal way to implement an API. Its just like serving an interrupt from the keyboard, but this time is an interrupt originated inside you code.
cheers!
niki
When you code "int 10", the CPU is interrupting all what it does, and go to the code who pointed in the entry in the IDT/IVT number 10 in the case. Then execute the code of you API.When your API should terminate and return the instruction pointer to the previously executed program, you code "iret".
This is the normal way to implement an API. Its just like serving an interrupt from the keyboard, but this time is an interrupt originated inside you code.
This is what I am doing right now. All SO work in level 0. This is done this way, because this will be an OS not for the common user thus there will never be mall ware. Wrong code? - no, once debuged.Call Gates, as in playing with privilege level, Sorry no, if my programs can't access the entire system and touch any piece of hardware they want, well then where is the fun in that. So I never played with that stuff and leave the entire system open. That's why I'm doing this and not writing Droid programs or Windows games. IRV? as in Reference Version stuff for large group projects? No history with that.
cheers!
niki
-
- Member
- Posts: 50
- Joined: Sun Sep 20, 2009 4:03 pm
Re: Calling API's
If you look in SYSTEM.ASM you will find that i remapped int 20h
so it uses my own routine (so programs can ask to be terminated)
Its quite easy, just write CS:IP into desired table entry.
Also they can be chained as to just monitor its activity.
Just be sure to disable interrupts before changing them...
so it uses my own routine (so programs can ask to be terminated)
Its quite easy, just write CS:IP into desired table entry.
Also they can be chained as to just monitor its activity.
Just be sure to disable interrupts before changing them...
Re: Calling API's
I didn't see any files named system.asm just fat12.asm and fat16.asm. If somebody give me code here in the forum that can directly change the ivt.bitshifter wrote:If you look in SYSTEM.ASM you will find that i remapped int 20h
so it uses my own routine (so programs can ask to be terminated)
Its quite easy, just write CS:IP into desired table entry.
Also they can be chained as to just monitor its activity.
Just be sure to disable interrupts before changing them...
Re: Calling API's
Code: Select all
xor ax,ax
mov ds,ax
cli
mov [20h*4],_offset
mov [20h*4+2],_segment
sti
If you have seen bad English in my words, tell me what's wrong, please.
-
- Member
- Posts: 50
- Joined: Sun Sep 20, 2009 4:03 pm
Re: Calling API's
I have uploaded attachment of that OS demo for you to try...
It sounds like you have the BOOTPROG tools but not the OS code...
It sounds like you have the BOOTPROG tools but not the OS code...
- Attachments
-
- x3dos.zip
- (18.75 KiB) Downloaded 49 times
Re: Calling API's
Thanks man. It's not an interrupt, but it's actually what I was orginally looking forbitshifter wrote:I have uploaded attachment of that OS demo for you to try...
It sounds like you have the BOOTPROG tools but not the OS code...