OSDev.org
https://forum.osdev.org/

[whatever-fat12] fat12 bootloader
https://forum.osdev.org/viewtopic.php?f=2&t=32104
Page 1 of 1

Author:  computersandcoffee [ Sat Jun 10, 2017 12:30 pm ]
Post subject:  [whatever-fat12] fat12 bootloader

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

Author:  computersandcoffee [ Sat Jun 10, 2017 12:40 pm ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

note: updated readme

Author:  Octocontrabass [ Sat Jun 10, 2017 1:34 pm ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

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?

Author:  computersandcoffee [ Sat Jun 10, 2017 1:57 pm ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

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 :)

Author:  Octocontrabass [ Sat Jun 10, 2017 2:24 pm ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

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...

Author:  computersandcoffee [ Sat Jun 10, 2017 2:41 pm ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

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 :?:

Author:  Octocontrabass [ Sat Jun 10, 2017 3:26 pm ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

Only 64 bytes? That's still tiny! Why not set SP to something like 0x7C00 and have plenty of room for your stack?

Author:  computersandcoffee [ Sat Jun 10, 2017 3:30 pm ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

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:

Author:  Octocontrabass [ Sun Jun 11, 2017 6:53 am ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

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.

Author:  computersandcoffee [ Sun Jun 11, 2017 10:13 am ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

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.

Author:  computersandcoffee [ Sat Jun 17, 2017 3:17 pm ]
Post subject:  Re: [whatever-fat12] fat12 bootloader

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

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/