OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:27 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: [whatever-fat12] fat12 bootloader
PostPosted: Sat Jun 10, 2017 12:30 pm 
Offline

Joined: Sun Apr 16, 2017 1:20 pm
Posts: 12
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


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sat Jun 10, 2017 12:40 pm 
Offline

Joined: Sun Apr 16, 2017 1:20 pm
Posts: 12
note: updated readme


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sat Jun 10, 2017 1:34 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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?


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sat Jun 10, 2017 1:57 pm 
Offline

Joined: Sun Apr 16, 2017 1:20 pm
Posts: 12
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 :)


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sat Jun 10, 2017 2:24 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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...


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sat Jun 10, 2017 2:41 pm 
Offline

Joined: Sun Apr 16, 2017 1:20 pm
Posts: 12
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 :?:


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sat Jun 10, 2017 3:26 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
Only 64 bytes? That's still tiny! Why not set SP to something like 0x7C00 and have plenty of room for your stack?


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sat Jun 10, 2017 3:30 pm 
Offline

Joined: Sun Apr 16, 2017 1:20 pm
Posts: 12
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:


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sun Jun 11, 2017 6:53 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sun Jun 11, 2017 10:13 am 
Offline

Joined: Sun Apr 16, 2017 1:20 pm
Posts: 12
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.


Top
 Profile  
 
 Post subject: Re: [whatever-fat12] fat12 bootloader
PostPosted: Sat Jun 17, 2017 3:17 pm 
Offline

Joined: Sun Apr 16, 2017 1:20 pm
Posts: 12
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 24 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group