Hi,
I am trying to implement a FAT32 file system into my OS, but have a few questions on how to implement it.
How do I write to my hard drive and how do I find out where on the hard drive the filesystem goes? Is there a way by using the grub mbi specificatons?
Thanks.
How do I write to hard disk?
Re: How do I write to hard disk?
That's a big question.
If you are using a VM, rather than a real computer, you might like to look here: https://wiki.osdev.org/ATA_PIO_Mode It's fairly simple to write a basic ATA driver to read and write sectors on a hard disk. The filesystem goes on a partition on the disk; the partition table in sector 0 of the disk lists partitions and where to find them on the disk. It's easier, at fist, to use your host operating system to create the partition and filesystem on your disk rather than writing the code for yourself.
If you are using a VM, rather than a real computer, you might like to look here: https://wiki.osdev.org/ATA_PIO_Mode It's fairly simple to write a basic ATA driver to read and write sectors on a hard disk. The filesystem goes on a partition on the disk; the partition table in sector 0 of the disk lists partitions and where to find them on the disk. It's easier, at fist, to use your host operating system to create the partition and filesystem on your disk rather than writing the code for yourself.
Re: How do I write to hard disk?
Thanks! I'll check out the page.iansjack wrote:That's a big question.
If you are using a VM, rather than a real computer, you might like to look here: https://wiki.osdev.org/ATA_PIO_Mode It's fairly simple to write a basic ATA driver to read and write sectors on a hard disk. The filesystem goes on a partition on the disk; the partition table in sector 0 of the disk lists partitions and where to find them on the disk. It's easier, at fist, to use your host operating system to create the partition and filesystem on your disk rather than writing the code for yourself.
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How do I write to hard disk?
Multiboot can tell you which partition your kernel was loaded from. You'll have to parse the partition tables yourself, though.
Multiboot can't tell you exactly which device it loaded your kernel from. The best it can give you is the BIOS device number, and you're on your own to figure out how that translates into an actual storage device. Any reasonably modern PC supports EDD 3.0, which is the most accurate way to identify the device, but it's a BIOS call that requires you to either switch back to real mode or implement virtual 8086 mode.
Multiboot can't tell you exactly which device it loaded your kernel from. The best it can give you is the BIOS device number, and you're on your own to figure out how that translates into an actual storage device. Any reasonably modern PC supports EDD 3.0, which is the most accurate way to identify the device, but it's a BIOS call that requires you to either switch back to real mode or implement virtual 8086 mode.
Re: How do I write to hard disk?
Thanks!Octocontrabass wrote:Multiboot can tell you which partition your kernel was loaded from. You'll have to parse the partition tables yourself, though.
Multiboot can't tell you exactly which device it loaded your kernel from. The best it can give you is the BIOS device number, and you're on your own to figure out how that translates into an actual storage device. Any reasonably modern PC supports EDD 3.0, which is the most accurate way to identify the device, but it's a BIOS call that requires you to either switch back to real mode or implement virtual 8086 mode.