flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
f0dder 16 Dec 2012, 17:01
"The best file system" depends on your needs. FAT32 is supported pretty much everywhere, so if ubiquity is your goal, then it's probably "the best". It has a number of limitations, though, and it's not very resilient against errors. NTFS is a lot better in a lot of ways(TM), but if you head outside Windows, there's other alternatives that might be better - XFS, Ext3/Ext4, btrfs, ZFS are all pretty interesting! (and then there's ReiserFS - but it had problems even before it's author was convicted of murder :/).
For hobbyist osdev, you will probably want to focus on fat(32) - it's simple, there's a lot of material available, lots of tools, and it's easy to deal with. IMHO the filesystem is relatively irrelevant for hobbyist osdev - there's so many other parts that's more interesting to program for, so you should rather do a simple filesystem initially, once you have the other parts in place you can look at more interesting FS. |
|||
![]() |
|
A$M 16 Dec 2012, 17:17
So, I will choose FAT32. And now: how to boot from a FAT32 HD? What errors FAT32 can present? And last, but not less important: how to access the HDD from the Protected Mode (32 bit)?
|
|||
![]() |
|
cod3b453 16 Dec 2012, 19:30
At boot, the BIOS loads the first sector of the HDD and runs it (assuming it has the expected signature). This is the same for all disks and doesn't matter what file system your disk is formatted with - the file system tables begin somewhere after the boot sector, according to the specification.
Your boot sector will need to load the next stage boot loader and a driver for the disk you are booting from. You have the option of either starting to use the file system here or allocating a predefined region of disk; personally, I recommend the second option because it minimises the amount of work that needs to be done in 16bit and in very little space*. For drivers, the simplest is ATA PIO, which can be easily copied to make 16/32/64bit versions; this covers PATA and/or legacy mapped SATA drives (up to 4). There are two modes - LBA28 and LBA48 - which are almost the same, so it only matters how much disk space you want to address. With this up and running, you can use what ever FS you like - it'll probably be harder to make the disk image than to use it! FAT32 is fairly simple, most of the complexity is the cluster map and long file names, so these are the most likely places for errors. *HD boot sectors typically have the MBR at the end, which defines partitions (or EFI/GPT support) which leaves about 400 bytes for code. |
|||
![]() |
|
egos 17 Dec 2012, 07:55
MBR is HD boot sector. The table at the end of MBR is named Partition Table (PT). It's possible to use current MBR boot loader and to write FAT32 boot loader for your OS. There're advanced MBR boot loaders. One of them I had written recently (it's experimental version). It allows to use dual booting, so you can keep booting your current OS and to boot your hobby OS as well. If your current OS uses traditional MBR boot loader, just replace it by the my one. You can use rescue CD to test it first.
To access to HDD in modern computers you should write PCI IDE-driver and probably AHCI-driver. |
|||
![]() |
|
A$M 17 Dec 2012, 17:50
I had seen something about "ATA PIO" on page http://wiki.osdev.org/ATA_PIO_Mode . Can anybody explain it right or show me a tutorial or something?
Thank you! |
|||
![]() |
|
cod3b453 21 Dec 2012, 18:49
That link has some explanation/examples already - what do you want to know more about?
|
|||
![]() |
|
A$M 22 Dec 2012, 12:41
Is there anything that this page does not deal? If so, please explain. (That's the right question, sorry
![]() EDIT: I let the laziness aside and I read about ATA PIO Mode in OSDev. I managed to do this code: Code: format binary as 'img' use16 org 7c00h ;DATAPORT = 0x1F0 ;ERROR = 0x1F1 ;SECTORCNT = 0x1F2 ;LBA_LOW = 0x1F3 ;LBA_MED = 0x1F4 ;LBA_HIGH = 0x1F5 ;DRIVE = 0x1F6 ;COMMAND = 0x1F7 NULL = 0 INREG = "INREG" macro inb port { if port <> "INREG" mov dx, port end if in al, dx } macro outb port, value { if port <> "INREG" mov dx, port end if mov al, value out dx, al } boot: cli display "Este código foi feito por A$M." ;On Brazilian Portuguese
|
|||||||||||
![]() |
|
cod3b453 06 Jan 2013, 02:09
That covers basic read/write/identify, which is almost everything you'd normally need but the ATA specification has many more commands that cover power management, device status and reset/flushing. ATA also covers CD drives, so it has the abilty to check/lock/eject etc as well.
|
|||
![]() |
|
A$M 11 Jan 2013, 13:06
cod3b453 wrote: That covers basic read/write/identify, which is almost everything you'd normally need but the ATA specification has many more commands that cover power management, device status and reset/flushing. ATA also covers CD drives, so it has the abilty to check/lock/eject etc as well. cod3b453, this is something very simple, but enough for a bootloader. ![]() |
|||
![]() |
|
egos 11 Jan 2013, 18:33
Nobody uses this in boot loader
![]() |
|||
![]() |
|
baldr 11 Jan 2013, 22:08
egos,
Yep, bootloader can't be too generic. Hell, I often ask myself why they do use partitions' table/BPB/whatever to read the rest of bootstrap code while it can be hardcoded by FDISK/SYS/whatever. |
|||
![]() |
|
egos 12 Jan 2013, 12:17
I prefer to use PT/BPB+/whatever
![]() I even had modified GRUB for this purpose. |
|||
![]() |
|
A$M 12 Jan 2013, 12:22
egos wrote: Nobody uses this in boot loader Whoa! Thank you! You made me realize my distraction. I can use the BIOS interrupts... lol ![]() |
|||
![]() |
|
egos 14 Jan 2013, 13:30
Why not. Do you know about ATA native mode, about AHCI-mode? What about initialization, detection? Don't forget about USB pen/hard drives and so on.
|
|||
![]() |
|
c.j.gowett 16 Jan 2014, 20:23
You could try to implement your own file system, but it won't be readable to windows or other operating systems but your own. This is what I am doing. If you want to put in the work, maybe I can help you on it. Something I would do if you are using BIOS interrupts before you switch into protected mode is to load your entire OS into memory with int 10h. I am still trying to figure out how to write to the disk in protected mode, but I can help you out with it when I do grasp it.
|
|||
![]() |
|
sid123 17 Jan 2014, 07:09
Quote: You could try to implement your own file system, but it won't be readable to windows or other operating systems but your own Write a driver for your FS. ![]() _________________ "Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X XD |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.