Variable sector size and INT 13/AH=02h calls

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.
User avatar
TightCoderEx
Member
Member
Posts: 90
Joined: Sun Jan 13, 2013 6:24 pm
Location: Grande Prairie AB

Re: Variable sector size and INT 13/AH=02h calls

Post by TightCoderEx »

iansjack wrote: Most computers nowadays don't even support this outdated technology.
Would you agree that statement should be qualified with, most do not support FDC or IDE for that matter in the conventional sense. My development system has a Z87-K motherboard, but I can still boot using floppy disks, albeit via USB.
iansjack wrote:You have the boot partition for your os on your development machine. It's not rocket science.
There are a plethora development paradigms, but other than using Boch's, there is no way I'd use my development machine for experimentation. Then again, for those that have moved past what I consider the most vulnerable, being media drivers the risk is not that great.

My methodology is very similar to @onlyonemac because it is efficient and most important, convenient. Frequent testing on real hardware does yield insight a lot of times.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Variable sector size and INT 13/AH=02h calls

Post by iansjack »

You are certainly correct that modern computers can boot off a USB floppy drive, or other device. But USB is relatively difficult to implement.

My philosophy is that, unless you are content not to read off storage after booting or are going to go through contortions to continue using the BIOS, an operating system that is going to do anything useful has to be able to read from an IDE or SATA device. Drivers are simple to implement, as is parsing a partition table and selecting a particular partition to use. On the other hand, floppies - whether old fashioned or USB - are far more difficult to write reliable drivers for.

Relying on the BIOS is a crutch that seems to hold back many an aspiring OS developer. Don't waste time with floppies; you're almost certainly going to have to support a hard disk at a very early stage so you might as well do it from the start.

And, yes - I use my development machine as my test machine also. (But it's not my main computer and, of course, I have good, regular backups of the development machine.) If you don't want to, transferring the boot files to a second computer is a trivial operation.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Variable sector size and INT 13/AH=02h calls

Post by Brendan »

Hi,
onlyonemac wrote:For your information, I do use an emulator as well. But I've seen far too many hobby OSes that *only* work on emulators because the developer didn't do enough testing on real hardware.
The single best method is booting from network. It's a little harder to setup (e.g. DHCP and TFTP server on your development machine, so your build utility/scripts can copy the files into the TFTP server's directory), but after it's setup testing real machines just means turning them on or resetting them.
iansjack wrote:You are certainly correct that modern computers can boot off a USB floppy drive, or other device. But USB is relatively difficult to implement.

My philosophy is that, unless you are content not to read off storage after booting or are going to go through contortions to continue using the BIOS, an operating system that is going to do anything useful has to be able to read from an IDE or SATA device. Drivers are simple to implement, as is parsing a partition table and selecting a particular partition to use. On the other hand, floppies - whether old fashioned or USB - are far more difficult to write reliable drivers for.
Most people load a "file containing many files" (initial RAM disk or something) very early during boot (when firmware is usable); and have no reason to care what the boot device was after this (unless the OS reinstalls/updates itself after boot). Maybe half way through boot, an OS might need to access its root file system (which might not be the boot device); but it can take several years (implementing boot code, memory management, scheduler, PCI enumeration, ACPI, etc) before an OS reaches that point.

For my project specifically, I'm going to cheat and shove everything into that "file containing many files that's loaded very early during boot" so I can get things like GUI working before I bother with networking, disk IO or file systems. Then I'll probably only do floppy disk and FAT (the bare minimum needed to get persistent storage and support a "not secure" file system that other OSs can read) so I can start writing an IDE.


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.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Variable sector size and INT 13/AH=02h calls

Post by onlyonemac »

Brendan wrote:For my project specifically, I'm going to cheat and shove everything into that "file containing many files that's loaded very early during boot" so I can get things like GUI working before I bother with networking, disk IO or file systems. Then I'll probably only do floppy disk and FAT (the bare minimum needed to get persistent storage and support a "not secure" file system that other OSs can read) so I can start writing an IDE.
That's exactly what I'm going to do, except that in my case the "file containing many files" retains its importance throughout my operating system's lifetime, as ultimately that will be developed into an initrd-style ramdisk that contains drivers and scripts to mount a persistent filesystem and load the rest of the system from there.
Brendan wrote:The single best method is booting from network. It's a little harder to setup (e.g. DHCP and TFTP server on your development machine, so your build utility/scripts can copy the files into the TFTP server's directory), but after it's setup testing real machines just means turning them on or resetting them.
That would require writing a PXE-compatible bootloader (and network card drivers to go alongside) to load my operating system; currently my operating system is not multiboot compatible and I don't intend on making it such soon as that is not a goal of my project and multiboot doesn't exactly reflect the structure of my operating system (I figure it should be relatively easy to produce a multiboot version at a later time, should I want to).
iansjack wrote:On the other hand, floppies - whether old fashioned or USB - are far more difficult to write reliable drivers for.
*Reliable* drivers is not the goal here; I already have a bare-minimum floppy driver that can read any sector from a floppy disk into any memory location below 1MB (or is it 16MB?) which I wrote for my previous (abandoned) operating system project, and it should be fairly easy to amend it for my current project if/when I need to (which will probably be further into the future than I hope, as currently my operating system has no support for any filesystems beyond the ramdisk format that it uses - the first persistent storage is probably going to be loading and saving RAM images).
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Variable sector size and INT 13/AH=02h calls

Post by iansjack »

I'll certainly concede that if you do not wish to support persistent storage,and your complete OS, data, and user programs total less than 1.44MB, a simple floppy driver will suffice. I suspect that many have greater ambitions for their OS than that. I certainly wouldn't be satisfied with an OS that didn't let me save data.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Variable sector size and INT 13/AH=02h calls

Post by onlyonemac »

iansjack wrote:I'll certainly concede that if you do not wish to support persistent storage,and your complete OS, data, and user programs total less than 1.44MB, a simple floppy driver will suffice. I suspect that many have greater ambitions for their OS than that. I certainly wouldn't be satisfied with an OS that didn't let me save data.
I never said that I plan to end with just floppy disks; I said that floppy disks are a good place to start because of their convenience, thus writing support for floppy disks (including a driver) is not a waste of time.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Octocontrabass
Member
Member
Posts: 5588
Joined: Mon Mar 25, 2013 7:01 pm

Re: Variable sector size and INT 13/AH=02h calls

Post by Octocontrabass »

0b00000000 wrote:On how much hardware can we assumer a sector to be of size 512 bytes for INT 13/AH=02h calls?
Other than floppy disks, I think all devices you can read with that function will have 512B sectors.

CDs and DVDs have 2kB sectors, but you can't read them with that function.

Some hard disks have 4kB sectors, but (as far as I know) you can't read them with that function.

Most PC-compatible floppy disks will have 512B sectors. Some don't, but those are very uncommon, so you probably won't need to worry about them.
Post Reply