FAT Questions!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
elderK

FAT Questions!

Post by elderK »

Hey all.

Im just curious,

If I am to use FAT, I have to have the the FAT Structure stuff at the top of the Bootloader, but - the bootloader has to use the FS to load the Kernel, right?

Which brings me to my next question, is it possible to program the Bootloader entirely in C?

Just thinking, it seems like its going to be a ***** to write the File loading stuff in Assembler.

Anyone who has any tips about FAT, id be curious to know your views.

*continues reading Microsoft FAT sheets*

~Zeii
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:FAT Questions!

Post by Candy »

zeii wrote: Which brings me to my next question, is it possible to program the Bootloader entirely in C?
Yes. In theory. But you'll have to find a C compiler that can generate such byte-accurate sequences, 16-bit real mode code and very small. I seriously doubt you will find one. If you're writing one yourself, you might be able to do it - but then I guess it'd be quite a lot easier to write a bootloader in assembly.
Just thinking, it seems like its going to be a ***** to write the File loading stuff in Assembler.

Anyone who has any tips about FAT, id be curious to know your views.
Try the OS FAQ. Reading FAT is pretty easy to do, there are numerous public domain boot sectors that do just that.
JAAman

Re:FAT Questions!

Post by JAAman »

zeii wrote: Hey all.

Im just curious,

If I am to use FAT, I have to have the the FAT Structure stuff at the top of the Bootloader, but - the bootloader has to use the FS to load the Kernel, right?
you can, but dont have to (neither grub nor lilo do), but imho, it is a cleaner, safer, more elegant solution
Which brings me to my next question, is it possible to program the Bootloader entirely in C?
i wouldnt recomend it... because you have tight memory requirements, RMode, and cannot assume much about the operating environment, it would prob be harder than doing it in ASM
Just thinking, it seems like its going to be a ***** to write the File loading stuff in Assembler.
not really... FAT is a very simple FS, basically all you have to do is search the directory (not hard) and get the starting cluster, parse the FAT tables (just follow the chain -- this is the hardest step), and then convert cluster->LBA->CHS (skip the last step for HDDs)
Anyone who has any tips about FAT, id be curious to know your views.
dont read each sector of the FAT each time you need it -- just read the entire FAT table into memory at the begining (only for FAT12/16 -- FAT32 FAT tables are likely to big for RMode)
elderK

Re:FAT Questions!

Post by elderK »

Candy, would we be able to speak in realtime?
Itd be cool to talk to a OS Developer real time, bounce ideas back and fourth.

:) Maybe you have some advice on Microkernels!

This time, Im actually trying to design my OS, rather than haphazardly code it in a fit of passion.

My goal for the next few days is to get a nice, relatively stable bootloader working.

Which will locate the Kernel, and load it into RAM, set all the GDT stuff, enter PM, then jump to the Kernel code.

Seem like a decent little goal for a day or two?

The thing I wonder about is, is it ok to have the Fat12 filesystem stuff in the Kernel, so I can load basic Servers and such when im ready? And, any other Filesystems in the future can be loaded from FAT12 as a Server for the Microkernel?

thanks for the advice!
~Zeii
bluecode

Re:FAT Questions!

Post by bluecode »

zeii wrote:The thing I wonder about is, is it ok to have the Fat12 filesystem stuff in the Kernel, so I can load basic Servers and such when im ready? And, any other Filesystems in the future can be loaded from FAT12 as a Server for the Microkernel?
If you really want a microkernel, then you should not put the fs and floppy/hdd driver in the kernel. I am using grub for this stuff. Grub is quite happy when it can load some servers (they are called modules under grub) and pass the addresses and size to the kernel. Then the kernel can execute them.

btw. there is a small flower under the avatar of candy, whoch will give you his ICQ number ;)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:FAT Questions!

Post by Candy »

bluecode wrote:
zeii wrote:The thing I wonder about is, is it ok to have the Fat12 filesystem stuff in the Kernel, so I can load basic Servers and such when im ready? And, any other Filesystems in the future can be loaded from FAT12 as a Server for the Microkernel?
If you really want a microkernel, then you should not put the fs and floppy/hdd driver in the kernel. I am using grub for this stuff. Grub is quite happy when it can load some servers (they are called modules under grub) and pass the addresses and size to the kernel. Then the kernel can execute them.
The "ideal" design for a kernel is something that is loaded into memory entirely by a boot loader (not sector) that loads everything related to the kernel into the correct places. It then executes the kernel setup code, which frees itself at the end and then sets up the usermode stuff. As soon as that is complete, you can access stuff with all normal drivers.

For a monolithic kernel, this is trivial, since it's monolithic. You load the lump into memory, call init() and be done with it.

For a microkernel, you also need to load all services required to get the system into a state that allows it to load the other services itself. That requires either knowing what devices you'll load from or loading all drivers that might be necessary. The second is ridiculous, the first is a good idea. It is hard to boot from new hardware in that case, so you'll have to find some way of booting a generic system too.

For a modular kernel of any type the same points are valid as for a microkernel. I'm making a modular monolithic kernel that preloads the kernel, kernelsetup and module archive upon bootup, where there are two module archives always available - current system and generic. Haven't decided on how to do this exactly, but I'm still thinking about some details of the OS...
btw. there is a small flower under the avatar of candy, whoch will give you his ICQ number ;)
There's also an MSN notice, plus you have my public email address which both works and is a valid and active Google Talk (Jabber) handle.

Just don't try to email my MSN address, I kind of mucked that up, preventing a lot of spam. The domain doesn't even exist anymore (if that isn't the best way to make sure you don't get spam I don't know what is). The public email address gets the spam though, up to some 75/80 a day now. Don't care though, everybody who would like a chat or so can just pick it up and chat. If you somewhere tell you found my name on Mega-Tokyo I'm usually pretty quick at responding :).

Seriously though, if you use ICQ you can access all mods on this forum (except df, but he's mainly the admin). Using MSN will only let you talk to me. No guarantees on response times, could be up to days or weeks for any of us.
Post Reply