BIOS calls and registers
BIOS calls and registers
Hey guys,
I was wondering what registers the BIOS preserves when you call one of its functions?
I.e. What registers can I rely on being the same value as they were before the intN call?
~K
I was wondering what registers the BIOS preserves when you call one of its functions?
I.e. What registers can I rely on being the same value as they were before the intN call?
~K
Re: BIOS calls and registers
It depends on each call to each device.
BIOS is out of date so it's not worth using but it's idea to control a device with a simple set mode, read sector & get key type functions is useful. Amiga and DOS did a similar thing and C worked with them fairly well.
BIOS is out of date so it's not worth using but it's idea to control a device with a simple set mode, read sector & get key type functions is useful. Amiga and DOS did a similar thing and C worked with them fairly well.
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
-
- Member
- Posts: 283
- Joined: Mon Jan 03, 2011 6:58 pm
Re: BIOS calls and registers
Have a look at the RBIL: http://www.cs.cmu.edu/~ralf/files.html
For any interrupt in that list, if it does not specifically say that the register is preserved, you SHOULD assume it gets trashed.
- Monk
For any interrupt in that list, if it does not specifically say that the register is preserved, you SHOULD assume it gets trashed.
- Monk
Re: BIOS calls and registers
b.zaar, that's not useful in the least. Many machines still present the BIOS interface rather than EFI's, even if the BIOS itself is implemented as EFI.
tjmask15, if what you've said is true then I cannot trust that any register will be preserved in pretty much any BIOS call. This includes important registers such as the stack pointer...
tjmask15, if what you've said is true then I cannot trust that any register will be preserved in pretty much any BIOS call. This includes important registers such as the stack pointer...
-
- Member
- Posts: 283
- Joined: Mon Jan 03, 2011 6:58 pm
Re: BIOS calls and registers
tjmonk15*elderK wrote:tjmask15, if what you've said is true then I cannot trust that any register will be preserved in pretty much any BIOS call. This includes important registers such as the stack pointer...
But, yes pretty much. The easiest solution is to use as few registers as possible while you still need to call the BIOS. Then switch to pmode (or long mode) ASAP so you don't have to worry about a horribly buggy BIOS.
- Monk
P.S. In reality, the BIOS SHOULD be saving any register that is not an output, and you can rely on this in DEBUG/TEST code. In Production code, you have to assume worst case
Re: BIOS calls and registers
Not quite so. BIOS does not exist in outer space or vacuum. There's quite a lot of software, mostly DOS itself, programs for DOS, DOS compilers and DOS programs compiled with these compilers, which de facto serve as test code for the BIOS. There must be vendor's BIOS test code in the first place, but it can't be the only BIOS test code. If a commonly used BIOS function is screwed up, many such programs will fail to operate and render this particular BIOS useless. If you didn't know, some PC manufacturers use DOS utilities to update the BIOS and those come on a bootable DOS floppy. The BIOS can't be screwed up too badly because there will be no way to update it.tjmonk15 wrote:But, yes pretty much. The easiest solution is to use as few registers as possible while you still need to call the BIOS. Then switch to pmode (or long mode) ASAP so you don't have to worry about a horribly buggy BIOS.
P.S. In reality, the BIOS SHOULD be saving any register that is not an output, and you can rely on this in DEBUG/TEST code. In Production code, you have to assume worst case
-
- Member
- Posts: 283
- Joined: Mon Jan 03, 2011 6:58 pm
Re: BIOS calls and registers
How many modern BIOS versions do you think include any kind of tests for DOS compatibility? How about EFI hosted BIOS stubs?alexfru wrote:Not quite so. BIOS does not exist in outer space or vacuum. There's quite a lot of software, mostly DOS itself, programs for DOS, DOS compilers and DOS programs compiled with these compilers, which de facto serve as test code for the BIOS. There must be vendor's BIOS test code in the first place, but it can't be the only BIOS test code. If a commonly used BIOS function is screwed up, many such programs will fail to operate and render this particular BIOS useless. If you didn't know, some PC manufacturers use DOS utilities to update the BIOS and those come on a bootable DOS floppy. The BIOS can't be screwed up too badly because there will be no way to update it.tjmonk15 wrote:...
- Monk
P.S. Not meant to be sarcastic or rude (hope it doesn't come across that way)
Re: BIOS calls and registers
They're testing it against something or what is the point of doing a BIOS fix?tjmonk15 wrote: How many modern BIOS versions do you think include any kind of tests for DOS compatibility?
The thing about the BIOS idea is that any OS can use it from the simplest boot loader to a 64 bit OS (with a nasty @$$ hack). Something like CDI, EDI and UDI requires an OS to already be an almost complete system which rules out all basic systems that want to test something higher than how to write a USB device driver.
What if something existed that was protected mode aware but as simple as BIOS to operate? Even if that meant running it in compatibility mode? Maybe there could be 2 entry points, 1 for 32 bit and 1 for 64 bit and the firmware handles the difficult part.
The advantage would be a GRUB multiboot kernel tutorial could say load this module before your kernel, and it will load your kernel and initrd and you can access the HDD, Framebuffer (not vesa) and USB!
Obviously it wouldn't apply to any advanced kernels, they already use CDI/EDI/UDI and share all their common drivers...
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
-
- Member
- Posts: 283
- Joined: Mon Jan 03, 2011 6:58 pm
Re: BIOS calls and registers
I think you missed the point. Pretty much, you can not prove that all BIOS behave correctly, (and there is quite a bit of evidence that many do not behave "correctly") therefore you must (SHOULD) assume there will be problems. *rolls eyes*b.zaar wrote:They're testing it against something or what is the point of doing a BIOS fix?tjmonk15 wrote:...
For hobby projects, testing/debugging, etc. this is not an issue, just use what works with your machines. But if you are aiming at production code, you have to assume someone will install your OS with a bad BIOS.
Beyond that, modern BIOS are tested against Windows (XP+ probably) and MAYBE linux (doubtful). Just look at ACPI (and the almost 100% necessity to use ACPIA) to see how well this works out for OSs in general.
- Monk
Re: BIOS calls and registers
Yeah I can do that...tjmonk15 wrote: I think you missed the point.
DOS is still in use, or this wouldn't exist.tjmonk15 wrote:Beyond that, modern BIOS are tested against Windows (XP+ probably) and MAYBE linux (doubtful).
http://www.freedos.org/wiki/index.php/M ... et_FreeDOS
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
-
- Member
- Posts: 283
- Joined: Mon Jan 03, 2011 6:58 pm
Re: BIOS calls and registers
As much as FreeDOS is like DOS it is not *truly* DOS. There are some differences, specifically at the code level (Not sure if FreeDOS is based off of the old open-source versions of DOS or from-scratch) And out of curiosity, does FreeDOS boot from the BIOS on your current PC? (I don't have a floppy drive to try this with :\)b.zaar wrote:Yeah I can do that...tjmonk15 wrote: I think you missed the point.
DOS is still in use, or this wouldn't exist.tjmonk15 wrote:Beyond that, modern BIOS are tested against Windows (XP+ probably) and MAYBE linux (doubtful).
http://www.freedos.org/wiki/index.php/M ... et_FreeDOS
- Monk
Re: BIOS calls and registers
I didn't read about booting from floppy in that linktjmonk15 wrote:And out of curiosity, does FreeDOS boot from the BIOS on your current PC? (I don't have a floppy drive to try this with :\)
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
-
- Member
- Posts: 283
- Joined: Mon Jan 03, 2011 6:58 pm
Re: BIOS calls and registers
Looks like they don't have a floppy boot download for their "current" version (looks like its from Feb. 2012) but they do have a CD Version which I will have to try out of curiosity. Link is http://www.freedos.org/download/ if you are curious.
- Monk
- Monk
Re: BIOS calls and registers
That is why I do not like the whole project. What is the point of having a DOS system if it is not floppy-installable? I would try it on old hardware if it supported floppy installation.tjmonk15 wrote:they don't have a floppy boot download for their "current" version
Re: BIOS calls and registers
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed