Page 1 of 1

[whatever-fat12] fat12 bootloader

Posted: Sat Jun 10, 2017 12:30 pm
by computersandcoffee
I made a one-stage fat12 bootloader

https://github.com/gituser2194/whatever-fat12

Testing done:

- successfully loaded lone 512-byte image
- successfully loaded 512-byte image with another file "dummy.txt" in the root directory
- successfully loaded 4096-byte image with another file "dummy.txt" in the root directory
- experimented with other sizes for "dummy.txt" to make sure lba-chs conversion worked properly

Re: [whatever-fat12] fat12 bootloader

Posted: Sat Jun 10, 2017 12:40 pm
by computersandcoffee
note: updated readme

Re: [whatever-fat12] fat12 bootloader

Posted: Sat Jun 10, 2017 1:34 pm
by Octocontrabass
computersandcoffee wrote:- successfully loaded 4096-byte image with another file "dummy.txt" in the root directory
Does it also work correctly when your image is fragmented? (For example, write a 512-byte image, add a dummy file, then overwrite the image with a 4096-byte image.)
computersandcoffee wrote:- experimented with other sizes for "dummy.txt" to make sure lba-chs conversion worked properly
Does it also work correctly when you write a 200kB dummy file to the disk first, followed by your image?

Re: [whatever-fat12] fat12 bootloader

Posted: Sat Jun 10, 2017 1:57 pm
by computersandcoffee
Octocontrabass wrote:
computersandcoffee wrote:- successfully loaded 4096-byte image with another file "dummy.txt" in the root directory
Does it also work correctly when your image is fragmented? (For example, write a 512-byte image, add a dummy file, then overwrite the image with a 4096-byte image.)
computersandcoffee wrote:- experimented with other sizes for "dummy.txt" to make sure lba-chs conversion worked properly
Does it also work correctly when you write a 200kB dummy file to the disk first, followed by your image?
For number one, I didn't test it after finding out from your post because I know the answer is no. I will add it to the limitations and to the "going to fix" area in the readme.

For number two, I cp'd a 200 KiB file in first and then my kernel.bin and it worked as normal. So yes.

Thank you :)

Re: [whatever-fat12] fat12 bootloader

Posted: Sat Jun 10, 2017 2:24 pm
by Octocontrabass
computersandcoffee wrote:For number two, I cp'd a 200 KiB file in first and then my kernel.bin and it worked as normal. So yes.
Whoops, I just re-checked my math and it was 2MB. I don't think you'll have to worry about that on a 1.44MB floppy disk. :wink:

One other thing just caught my eye: your stack is only 32 bytes. That's awfully small...

Re: [whatever-fat12] fat12 bootloader

Posted: Sat Jun 10, 2017 2:41 pm
by computersandcoffee
Octocontrabass wrote:
computersandcoffee wrote:For number two, I cp'd a 200 KiB file in first and then my kernel.bin and it worked as normal. So yes.
Whoops, I just re-checked my math and it was 2MB. I don't think you'll have to worry about that on a 1.44MB floppy disk. :wink:

One other thing just caught my eye: your stack is only 32 bytes. That's awfully small...
I changed it so the stack is 64 bytes and also added support for booting off of drives other than fda that are supported by the bios emulation

Just out of curiosity, what kind of problem would i encounter with the dummy file being 2MB :?:

Re: [whatever-fat12] fat12 bootloader

Posted: Sat Jun 10, 2017 3:26 pm
by Octocontrabass
Only 64 bytes? That's still tiny! Why not set SP to something like 0x7C00 and have plenty of room for your stack?

Re: [whatever-fat12] fat12 bootloader

Posted: Sat Jun 10, 2017 3:30 pm
by computersandcoffee
I just set the SP to 0x7c00 and put in a thank you comment

I didn't do that because I was told one time that the stack needed to be labeled in the code for it to be "correct"

That also frees up more space for actual code :mrgreen:

Re: [whatever-fat12] fat12 bootloader

Posted: Sun Jun 11, 2017 6:53 am
by Octocontrabass
computersandcoffee wrote:Just out of curiosity, what kind of problem would i encounter with the dummy file being 2MB :?:
Aside from not being able to fit it on the disk? That's about the point where chs_convert breaks down with floppy disk geometry. If you decide to adapt it to work on other types of disks, the limit will be different (up to about 8MB).

Speaking of chs_convert, is there any particular reason you decided to use so many conditional jumps? That seems like a great way to hide subtle off-by-one bugs.
computersandcoffee wrote:I didn't do that because I was told one time that the stack needed to be labeled in the code for it to be "correct"
If you really want to have a label for it, consider that 0x7C00 is also the address where the first byte of your bootloader is located.

Re: [whatever-fat12] fat12 bootloader

Posted: Sun Jun 11, 2017 10:13 am
by computersandcoffee
The conditional jumps are a by-product of my thought process. When I wrote that code, I didn't have a mathematical formula in my head - I just remembered that after 18 sectors, the head increases, and after another 18 sectors, the cylinder increases and the head goes back down to 0, and then repeat. It translated into assembly code containing a lot of conditional jumps.

Re: [whatever-fat12] fat12 bootloader

Posted: Sat Jun 17, 2017 3:17 pm
by computersandcoffee
Hi. :)

I don't have time to maintain this project, sadly. :(
I will leave the GitHub repository up just in case someone wants it though. Honestly, though, you're probably better off with another solution. :mrgreen:

I'm highly unlikely to start another OSDEV-related project, but if I do, I will make sure that I have the resources, etc. to maintain it. :D