Heads, tracks and sectors? any help please
-
- Member
- Posts: 71
- Joined: Wed May 29, 2013 1:07 pm
Heads, tracks and sectors? any help please
Hi I am implementing FAT16 in my operating system so far all good. But I am having trouble determining what sector, head, track to load from.
I am running the operating system from HDD. Lets say the ROOT directory is at 0x1ea00 how can I divide that down to get the correct sector, track and head
Many thanks
I am running the operating system from HDD. Lets say the ROOT directory is at 0x1ea00 how can I divide that down to get the correct sector, track and head
Many thanks
1100110100010011
Re: Heads, tracks and sectors? any help please
All you need to know may be found here: http://wiki.osdev.org/FAT.
-
- Member
- Posts: 71
- Joined: Wed May 29, 2013 1:07 pm
Re: Heads, tracks and sectors? any help please
That's not what I need I have looked up plenty on FAT I just need to determine how to split an address down into sectors, heads and tracks for example lets not talk about FAT for a second imagine the number 1024 I know that to access data at offset 1024 I would do
Sector = 3
head = 1
Track = 1
I think that's right might be a bit off but that's the general idea
Sector = 3
head = 1
Track = 1
I think that's right might be a bit off but that's the general idea
1100110100010011
Re: Heads, tracks and sectors? any help please
Is there any reason not to use LBA? Then if you want to access data at offset 1024, just send 1024 to the ATA controller as the LBA address.
http://wiki.osdev.org/LBA
If you want to use CHS (not sure why anyone would...), there is a handy code snippet on the page specified above that can convert from LBA to CHS for you.
http://wiki.osdev.org/LBA
If you want to use CHS (not sure why anyone would...), there is a handy code snippet on the page specified above that can convert from LBA to CHS for you.
Currently developing Lithium OS (LiOS).
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
-
- Member
- Posts: 100
- Joined: Wed Mar 13, 2013 2:27 am
Re: Heads, tracks and sectors? any help please
The only real reason to use CHS on a hard drive is if you are using a really old BIOS that doesn't support LBA extensions. In fact doing so will limit you to the first 8GB of the media. Regardless, I will assume you have a good reason.
To find a CHS address you must know some information about the media, such as "sectors per track" and "number of heads". You should also know the number of cylinders so you know when the drive ends. You can find out this information about your drives using INT 0x13 AH=8.
Here's the formulas from the ATA in Real Mode page.
To find a CHS address you must know some information about the media, such as "sectors per track" and "number of heads". You should also know the number of cylinders so you know when the drive ends. You can find out this information about your drives using INT 0x13 AH=8.
Here's the formulas from the ATA in Real Mode page.
Temp = LBA / (Sectors per Track)
Sector = (LBA % (Sectors per Track)) + 1
Head = Temp % (Number of Heads)
Cylinder = Temp / (Number of Heads)
TachyonOS - Violates causality on 95% of attempts. Runs at approximately 1.5c.
Re: Heads, tracks and sectors? any help please
You have to design all the algorithms to use LBA.
For the drives that don't support LBA you need just to implement LBA to CHS translation (as a separate mechanism). But the logic of file system driver needs to stay in LBA.
For the drives that don't support LBA you need just to implement LBA to CHS translation (as a separate mechanism). But the logic of file system driver needs to stay in LBA.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Heads, tracks and sectors? any help please
So a 2-year old BIOS is "really old" because it supports a floppy drive?Prochamber wrote:The only real reason to use CHS on a hard drive is if you are using a really old BIOS that doesn't support LBA extensions.
Re: Heads, tracks and sectors? any help please
A BIOS is really old it it does not support LBA on hard disk drives.Combuster wrote:So a 2-year old BIOS is "really old" because it supports a floppy drive?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Heads, tracks and sectors? any help please
Point was that CHS is still unavoidable for floppies regardless of your computer's relative age...
-
- Member
- Posts: 100
- Joined: Wed Mar 13, 2013 2:27 am
Re: Heads, tracks and sectors? any help please
What are you babbling about?Combuster wrote:So a 2-year old BIOS is "really old" because it supports a floppy drive?Prochamber wrote:The only real reason to use CHS on a hard drive is if you are using a really old BIOS that doesn't support LBA extensions.
TachyonOS - Violates causality on 95% of attempts. Runs at approximately 1.5c.
Re: Heads, tracks and sectors? any help please
The question was specifically about access to a hard disk. Probably best not to wander off topic.Combuster wrote:Point was that CHS is still unavoidable for floppies regardless of your computer's relative age...
-
- Member
- Posts: 71
- Joined: Wed May 29, 2013 1:07 pm
Re: Heads, tracks and sectors? any help please
Thanks for all your responses I did not know about LBA until now how can I access data on a disk without specifying sector, head , track. At the moment I am using int 13 to access the storage device.
Many thanks
Many thanks
1100110100010011
-
- Member
- Posts: 283
- Joined: Mon Jan 03, 2011 6:58 pm
-
- Member
- Posts: 71
- Joined: Wed May 29, 2013 1:07 pm
Re: Heads, tracks and sectors? any help please
Hi Monk, I have found these parameters
AH = 42h
DL = drive number
DS:SI -> disk address packet
for an extended read , LBA ?
the thing I don't understand about this is no value to point to the data is being specified and if the value is DS:SI then where is the value that says where to load it into memory
Many thanks
1100110100010011
Re: Heads, tracks and sectors? any help please
Again, split the task to two independent parts.
The first one - implement FAT16 driver using only the linear numbers of sectors. That sector number is just the LBA sector number.
The second - implement the Int13 BIOS request (if you are using real mode) forming the LBA packet or using LBA number to CHS parameters translation.
The first one - implement FAT16 driver using only the linear numbers of sectors. That sector number is just the LBA sector number.
The second - implement the Int13 BIOS request (if you are using real mode) forming the LBA packet or using LBA number to CHS parameters translation.
Last edited by Yoda on Tue Jun 11, 2013 2:15 pm, edited 1 time in total.