[whatever-fat12] fat12 bootloader

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
computersandcoffee
Posts: 12
Joined: Sun Apr 16, 2017 1:20 pm
Libera.chat IRC: fdkj83425
Contact:

[whatever-fat12] fat12 bootloader

Post 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
computersandcoffee
Posts: 12
Joined: Sun Apr 16, 2017 1:20 pm
Libera.chat IRC: fdkj83425
Contact:

Re: [whatever-fat12] fat12 bootloader

Post by computersandcoffee »

note: updated readme
Octocontrabass
Member
Member
Posts: 5516
Joined: Mon Mar 25, 2013 7:01 pm

Re: [whatever-fat12] fat12 bootloader

Post 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?
computersandcoffee
Posts: 12
Joined: Sun Apr 16, 2017 1:20 pm
Libera.chat IRC: fdkj83425
Contact:

Re: [whatever-fat12] fat12 bootloader

Post 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 :)
Octocontrabass
Member
Member
Posts: 5516
Joined: Mon Mar 25, 2013 7:01 pm

Re: [whatever-fat12] fat12 bootloader

Post 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...
computersandcoffee
Posts: 12
Joined: Sun Apr 16, 2017 1:20 pm
Libera.chat IRC: fdkj83425
Contact:

Re: [whatever-fat12] fat12 bootloader

Post 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 :?:
Octocontrabass
Member
Member
Posts: 5516
Joined: Mon Mar 25, 2013 7:01 pm

Re: [whatever-fat12] fat12 bootloader

Post 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?
computersandcoffee
Posts: 12
Joined: Sun Apr 16, 2017 1:20 pm
Libera.chat IRC: fdkj83425
Contact:

Re: [whatever-fat12] fat12 bootloader

Post 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:
Octocontrabass
Member
Member
Posts: 5516
Joined: Mon Mar 25, 2013 7:01 pm

Re: [whatever-fat12] fat12 bootloader

Post 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.
computersandcoffee
Posts: 12
Joined: Sun Apr 16, 2017 1:20 pm
Libera.chat IRC: fdkj83425
Contact:

Re: [whatever-fat12] fat12 bootloader

Post 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.
computersandcoffee
Posts: 12
Joined: Sun Apr 16, 2017 1:20 pm
Libera.chat IRC: fdkj83425
Contact:

Re: [whatever-fat12] fat12 bootloader

Post 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
Post Reply