Page 1 of 1
boot without INT
Posted: Sat Feb 19, 2011 3:46 pm
by Teehee
Hi.
How can i make a boot with no INT's instructions?
Im using INT 13h to load my "OS" from a floppy disk (in bochs emu). But i'd like to avoid INTs.
Re: boot without INT
Posted: Sat Feb 19, 2011 3:56 pm
by neon
Hello,
Is there any reason why you want to avoid INTs?
You would have to develop a minidriver for the media you are booting from. This can be very hard, if impossible, within the 512 bytes of the bootsector do to its limited space. However it is possible outside the bootsector, of course.
Re: boot without INT
Posted: Sat Feb 19, 2011 4:10 pm
by Teehee
neon wrote:Is there any reason why you want to avoid INTs?
np.. just for fun & knowledge.
You would have to develop a minidriver for the media you are booting from. This can be very hard, if impossible, within the 512 bytes of the bootsector do to its limited space. However it is possible outside the bootsector, of course.
How can i learn how to develop a driver?
Re: boot without INT
Posted: Sat Feb 19, 2011 6:51 pm
by Chandra
Teehee wrote:neon wrote:Is there any reason why you want to avoid INTs?
np.. just for fun & knowledge.
You would have to develop a minidriver for the media you are booting from. This can be very hard, if impossible, within the 512 bytes of the bootsector do to its limited space. However it is possible outside the bootsector, of course.
How can i learn how to develop a driver?
OSDEV Wiki at your service.
Re: boot without INT
Posted: Sun Feb 20, 2011 4:55 am
by DLBuunk
neon wrote:
You would have to develop a minidriver for the media you are booting from. This can be very hard, if impossible, within the 512 bytes of the bootsector do to its limited space. However it is possible outside the bootsector, of course.
When i was writing my own bootloader i had so much trouble with BIOS int 13h, that i decided to skip it altogether, my bootloader now houses a mini-driver for floppy disks, it loads the next 35 sectors. My mini-driver takes about 400 bytes, 300 for the floppy driver proper, and 100 for PIC/PIT/DMA initialisation code, because bochs BIOS leaves those in a, hmm, rather interesting state.
Of course, i had to make some assumptions, for example, i had to assume there were no bad sectors, and the user would not try to remove the floppy during boot.
As well, a mini-driver that takes away 400 bytes makes it inpossible to do some FAT-like directory parsing in the boot sector.
Re: boot without INT
Posted: Sun Feb 20, 2011 6:10 am
by Chandra
DLBuunk wrote:neon wrote:
You would have to develop a minidriver for the media you are booting from. This can be very hard, if impossible, within the 512 bytes of the bootsector do to its limited space. However it is possible outside the bootsector, of course.
When i was writing my own bootloader i had so much trouble with BIOS int 13h, that i decided to skip it altogether, my bootloader now houses a mini-driver for floppy disks, it loads the next 35 sectors. My mini-driver takes about 400 bytes, 300 for the floppy driver proper, and 100 for PIC/PIT/DMA initialisation code, because bochs BIOS leaves those in a, hmm, rather interesting state.
Of course, i had to make some assumptions, for example, i had to assume there were no bad sectors, and the user would not try to remove the floppy during boot.
As well, a mini-driver that takes away 400 bytes makes it inpossible to do some FAT-like directory parsing in the boot sector.
Exactly! Now you seem to understand why BIOS is unavoidable.
Re: boot without INT
Posted: Sun Feb 20, 2011 7:20 am
by Teehee
i really have trouble to understand these things. IDK why...
i have learned these boot steps:
1. load your boot sector
2. set A20
3. set PM
4. Hi kernel
Is that ok?
But i'd like a step-by-step for each item, using assembly examples. I can't understand that only by osdevwiki
Re: boot without INT
Posted: Sun Feb 20, 2011 8:19 am
by Tosi
There are lots of assembly examples on the wiki. If you can't understand them, you probably don't know English well, in which case I would recommend learning it because it is the
lingua franca of programming. Either that, or you don't meet the required knowledge (check
Getting Started), in which case you should write some user-space programs before trying OS development.
Re: boot without INT
Posted: Sun Feb 20, 2011 8:26 am
by Chandra
Teehee wrote:i really have trouble to understand these things. IDK why...
i have learned these boot steps:
1. load your boot sector
2. set A20
3. set PM
4. Hi kernel
Is that ok?
But i'd like a step-by-step for each item, using assembly examples. I can't understand that only by osdevwiki
Did you check the 'Baby-Step Tutorials'.
Re: boot without INT
Posted: Sun Feb 20, 2011 8:29 am
by Chandra
Teehee wrote:i really have trouble to understand these things. IDK why...
i have learned these boot steps:
1. load your boot sector
2. set A20
3. set PM
4. Hi kernel
Is that ok?
But i'd like a step-by-step for each item, using assembly examples. I can't understand that only by osdevwiki
And how is it related to 'Boot without INT'? You may want to start a new thread.
Re: boot without INT
Posted: Sun Feb 20, 2011 9:02 pm
by DavidCooper
I used to load my OS in using my own device driver in the boot sector (after switching to protected mode so that the same driver could be used for all loads and saves), but mine worked by polling the FDC chip after switching it out of DMA mode, the result being that Bochs couldn't handle it. More importantly, I couldn't boot a machine from a USB floppy drive, and writing a better device driver that uses the DMA and interrupts wouldn't help with that - there's simply no possibility of setting up the machine to use USB with your own code in a boot sector, so the only option is to let the BIOS help you. I've now junked the old boot sector and replaced it with one which uses the BIOS, and I have no desire to go back to the old one. Learn to love the BIOS - it is your friend, and it can do a lot more for you than just load your OS. Aim to write code to jump in and out of real mode from protected mode so that you can use the BIOS at any time. You may think your aim should be to get into protected mode and just stay there, writing all your own code to do all the things that the BIOS does, but internal floppy disk drives are practically extinct in computers now, so you should plan to work with USB floppy drives via the BIOS right from the start. Don't waste your time writing a beautiful boot sector which can only run on computers so old that they belong in a museum.
Re: boot without INT
Posted: Mon Feb 21, 2011 11:14 pm
by DavidCooper
Sorry about the long delay, Berkus, but I've been trying to ensure that the new load/save system is fully reliable (simply by using it a lot, and so far it's worked faultlessly). I've also made numerous other changes which might have destabilised things, but I seem to have got away with the whole lot. There are a couple of new keyboard bugs which appear in Bochs, both to do with key repeats, but the worst that can happen is that a buffer will fill up and the OS will freeze if you hold a key down for too long while running code either through the slow monitor program or where the OS generates its own software key repeats to amplify the speed of the actual keyboard repeats. When that happens, you can reboot in an instant in Bochs and quickly get back to where you were, so it isn't a huge problem. I'll upload the current version as soon as I've tidied up the bit of code I'm currently working on so that it doesn't crash due to incompleteness. I'll announce it in the MSB-OS thread as soon as it's available. My site's been promising the next version by "tomorrow" for the best part of two months (because I haven't had the time to go into it to change it), but this time it really should be tomorrow unless something goes badly wrong.
If the OP wants to look at the original FDC driver (which is extremely compact), it's still in the OS, though it's no longer in the boot sector. Once it's available, he can run it in Bochs and look for the routine called "com" which sends strings of command bytes to the FDC chip. A number of adjacent routines hold the different strings of instructions used to do such things as read, write and seek. The command bytes are passed to com as inline parameters (or at least I think that's what they're called), each terminated by a 254 byte. A delay loop is run after each byte is sent.
[Edit: new version of MSB-OS available now. Click on link below to access it]