I have read the FAT article on the wiki, and I understand the datastructures of FAT. But my question is, how can I "READ" the root disk ?? I do have a function to switch to 16bit real mode, execute real mode stuff, and return to protected mode; but I think reading the disk through this method would be quite inefficient.
I read about an initrd. What is it ?? how can it help me ??
PS: I don't have paging enabled.
How to "actually" implement the filesystem driver ?
-
- Member
- Posts: 37
- Joined: Sat Apr 11, 2015 9:37 am
Re: How to "actually" implement the filesystem driver ?
Hi,
Cheers,
Brendan
An OS is built in layers. For example, it's reasonable to have the following layers:snasim2002 wrote:I have read the FAT article on the wiki, and I understand the datastructures of FAT. But my question is, how can I "READ" the root disk ?? I do have a function to switch to 16bit real mode, execute real mode stuff, and return to protected mode; but I think reading the disk through this method would be quite inefficient.
I read about an initrd. What is it ?? how can it help me ??
PS: I don't have paging enabled.
- Storage device drivers
- (optional) A layer to map logical disks to physical disks (e.g. software RAID)
- File system/s
- Virtual file system
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: How to "actually" implement the filesystem driver ?
After reading about FAT the next thing you have to read is HDD hardware description (you can start here). It is very useful to understand how it works if you want to write an efficient HDD driver. But performance often isn't the main goal of beginner OSdevers, so your real mode switch can work as magic just because it relieves you from reading about storage hardware. You just should to decide what do you really want - to read from disk quickly (in terms of your time spent) or to read from disk efficiently. First option leads you to the switch and the second introduces you into the world of tricky hardware interfaces.snasim2002 wrote:I have read the FAT article on the wiki, and I understand the datastructures of FAT. But my question is, how can I "READ" the root disk ?? I do have a function to switch to 16bit real mode, execute real mode stuff, and return to protected mode; but I think reading the disk through this method would be quite inefficient.
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability
-
- Member
- Posts: 37
- Joined: Sat Apr 11, 2015 9:37 am
Re: How to "actually" implement the filesystem driver ?
I think you are right. I will concentrate on a disk driver later on, for now, I should just stick to the "switch".
Re: How to "actually" implement the filesystem driver ?
Be sure that when switching to protected mode and back to real mode you preserve everything that will allow the real mode interrupts to run correctly.
It's actually very simple to write a basic IDE disk driver.
It's actually very simple to write a basic IDE disk driver.
Re: How to "actually" implement the filesystem driver ?
It's just as simple to write a driver for a PATA/SATA drive as it is to write a pmode->real mode->pmode switch. After you get done dealing with loading the stub into physical ram at a specific location, handling all the copying (are you going to do one sector, or copy to upper memory, or?), making sure you don't corrupt anything, etc, you could have already finished a real driver and not had to switch back and forth to real mode losing any interrupts in the mean time (you know, like completely halting multitasking while in real mode). I'm not saying it's useless to be able to call the bios, but what does he do once he gets into Long mode? This is one of those that it's just as simple to write properly the first time.
Re: How to "actually" implement the filesystem driver ?
If it's about something efficient then simple part becomes an interesting quest for a beginner. Things like DMA and different storage types can be skipped for some time and high level API to access disk services can be tested and elaborated using simple "switch" based approach.iansjack wrote:It's actually very simple to write a basic IDE disk driver.
But yes, if a person wishes to create a good OS then there's no way without a good driver.
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability
-
- Member
- Posts: 37
- Joined: Sat Apr 11, 2015 9:37 am
Re: How to "actually" implement the filesystem driver ?
And what about a cdrom driver ? Is it easier to implement than SATA ? Also, what FS are available for CDs and DVDs, except ISO 9660 ?
Re: How to "actually" implement the filesystem driver ?
The easiest way to communicate with a hard drive or CD rom drive is through the IDE controller. You will need to learn how to control the IDE controller using IN and OUT commands. Once you have this figured out, you can tell the IDE controller to send ATA commands to the hard drive, and send ATAPI commands to the CD-ROM drive. ATAPI simply allows you to send SCSI commands using the IDE controller.
Most CD-ROM discs use ISO 9660 as a file system, and most DVD and BluRay discs use the UDF file system. Neither of these file systems are particularly difficult to read. They are similar in structure, but not identical.
And, to answer your original question, and "initrd" is a file that is loaded into memory, that can then be used as a RAM disk. This is helpful during boot up because you may not have all of your device drivers loaded.
Most CD-ROM discs use ISO 9660 as a file system, and most DVD and BluRay discs use the UDF file system. Neither of these file systems are particularly difficult to read. They are similar in structure, but not identical.
And, to answer your original question, and "initrd" is a file that is loaded into memory, that can then be used as a RAM disk. This is helpful during boot up because you may not have all of your device drivers loaded.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott