INT 13h, AH=42h - extended read sectors

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
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

INT 13h, AH=42h - extended read sectors

Post by Yoda »

I have a question about subj function of BIOS. In LBA packet for BIOS call there is a place for 64-bit number of sector to read. Do modern BIOSes will actually read sectors beyond 2Tb (32-bit number) limit? Did anybody try this?
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
User avatar
Minoto
Member
Member
Posts: 89
Joined: Thu May 12, 2011 7:24 pm

Re: INT 13h, AH=42h - extended read sectors

Post by Minoto »

I think you've misinterpreted the last 8 bytes of the disk address packet...take a look at http://en.wikipedia.org/wiki/INT_13H#IN ... From_Drive, and note that the number of sectors to read is contained in a word at offset 2, while bytes 8-15 contain the LBA of the sector where the read should begin.
Those who understand Unix are doomed to copy it, poorly.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: INT 13h, AH=42h - extended read sectors

Post by Yoda »

This Wikipedia link is almost my Prayer book :). I didn't get what do you mean under misinterpretation. I need to check if the FULL 64-bit value in bytes 8-15 (start sector to read) works OK. In all code samples that I found high part of start sector is just zeroed and unused. I need to know if it really works if I try to read sectors beyond 2Tb.
Nobody knows?
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: INT 13h, AH=42h - extended read sectors

Post by bluemoon »

The specification say that accept 64-bit sector index, so it is 64-bit.

I guess very few OS developer actually used BIOS to load disk sectors, except at early boot stages; and since it's not something people do often, very few people would actually test it on many machines for non-trivial case like >2TB.

So, if that BIOS call failed(you need to check the return code!) and the user(if any) complain on that, you just blame the BIOS, and replace that piece of boot code with more widely tested GRUB.

To summarize, the BIOS should take 64-bit LBA as parameter, it also have total right to reject the call and return fail.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: INT 13h, AH=42h - extended read sectors

Post by Yoda »

bluemoon wrote:To summarize, the BIOS should take 64-bit LBA as parameter, it also have total right to reject the call and return fail.
Hope you are right!
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
User avatar
Minoto
Member
Member
Posts: 89
Joined: Thu May 12, 2011 7:24 pm

Re: INT 13h, AH=42h - extended read sectors

Post by Minoto »

Yoda wrote:This Wikipedia link is almost my Prayer book :). I didn't get what do you mean under misinterpretation. I need to check if the FULL 64-bit value in bytes 8-15 (start sector to read) works OK. In all code samples that I found high part of start sector is just zeroed and unused. I need to know if it really works if I try to read sectors beyond 2Tb.
Nobody knows?
Sorry, I misunderstood your question -- I thought you were viewing bytes 8-15 as the number of sectors to read, not the starting point for the read. I see that bluemoon has already answered what you were really asking.
Those who understand Unix are doomed to copy it, poorly.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: INT 13h, AH=42h - extended read sectors

Post by Yoda »

Soon a 3TB HDD will be available for me for a couple of days to play with it! I'll check accessing it through BIOS int 13h beyond 2TB limit and report here for your interest!
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: INT 13h, AH=42h - extended read sectors

Post by turdus »

Most BIOS use only 48 bits out of 64 (bochs as well). Since it's still several terrabytes and extended BIOS read only used in early stages (real mode!) I don't think it's a real limitation.
Rudster816
Member
Member
Posts: 141
Joined: Thu Jun 17, 2010 2:36 am

Re: INT 13h, AH=42h - extended read sectors

Post by Rudster816 »

BIOS support for addressing the upper portions of > 2TB HDD's is dodgy at best. My motherboard (Evga E760, X58 chipset for those interested) took at least a dozen BIOS updates to fully support it despite being released in March of 2009. Any BIOS will still support accessing the lower ~2TB though. For sanity's sake, I would ensure that any data that needs to be accessed through the BIOS INT13h interface reside below the ~2TB threshold.

Also keep in mind a lot of 3TB drives use 4KB sectors, so the whole drive might be accessible even with an older BIOS. You can't really rely on this though, because my 4KB sector drive has a jumper that emulates 512 byte sectors on it, so that can change even if the drive doesn't.

@Turdus

ATA\AHCI controllers only support 48 Bit LBA's. The extra 2 bytes in the address packet were for future proofing.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: INT 13h, AH=42h - extended read sectors

Post by Yoda »

My report.
Most BIOSes don't support LBA48 access on INT13. They just ignore the contents of higher 32 bit half. But I found one BIOS on a modern mainboard that really works with LBA48.
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
User avatar
pauldinhqd
Member
Member
Posts: 37
Joined: Tue Jul 12, 2011 9:14 am
Location: Hanoi
Contact:

Re: INT 13h, AH=42h - extended read sectors

Post by pauldinhqd »

Rudster816 wrote: Also keep in mind a lot of 3TB drives use 4KB sectors, so the whole drive might be accessible even with an older BIOS. You can't really rely on this though, because my 4KB sector drive has a jumper that emulates 512 byte sectors on it, so that can change even if the drive doesn't.
is it true that 3TB drives use 4KB sectors instead of 512bytes?
MBR is 4KB also? where's the source about this new standard for sector?
http://www.tomshardware.com/reviews/adv ... ,2759.html

i have to re-engineer the whole code written for my os #-o
AMD Sempron 140
nVidia GTS 450
Transcend DDR2 2x1
LG Flatron L1742SE
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: INT 13h, AH=42h - extended read sectors

Post by egos »

Large disks emulate 512-byte sectors. Just align partitions/clusters on 4 kb boundaries (8 sectors) for good performance.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: INT 13h, AH=42h - extended read sectors

Post by Yoda »

pauldinhqd wrote:is it true that 3TB drives use 4KB sectors instead of 512bytes?
Not necessarily. Only those series that are specially designed as 4k physical sectors, but they are not necessarily so huge. For example, WD EARS series use 4k sectors. But all these drives emulate logical 512 sectors. So you don't need to take special measures. The only thing is that the performance highly degrades on writing data chunks not divisible by 4k or data misaligned on 4k boundary since it reads 4k sector then updates it and writes it back. W7 creates partitions and formats them taking that into account. You also should make filesystems on that drives so that cluster size is at least 4k, data clusters are aligned on 4k boundary and all (or most) write operations are in 4k chunks. That's all you need.
pauldinhqd wrote:MBR is 4KB also?
No. MBR and all other structures are the same.
pauldinhqd wrote:where's the source about this new standard for sector?
I tried before to find an official documentation on 4k sectors but it seems that these docs are only HDD manufacturers specific, not OS developers.
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
Rudster816
Member
Member
Posts: 141
Joined: Thu Jun 17, 2010 2:36 am

Re: INT 13h, AH=42h - extended read sectors

Post by Rudster816 »

The BIOS may decide to emulate 512 Byte sectors, but you have to use a jumper on the drive (which isn't on by default) to emulate 512 Byte sectors for buggy\legacy OS's in hardware. I'd venture to guess that most BIOS's probably end up loading all 4KB at 0x7C00 in these drives, might be interesting to check. I'm not sure if they just read one sector straight to 0x7C00, or to an internal buffer first. In any case, you couldn't exploit it anyways, unless you want to have zero portability.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: INT 13h, AH=42h - extended read sectors

Post by Brynet-Inc »

A few drives are presenting a 4K logical sector size to the OS now. Here are a couple USB devices connected to OpenBSD systems.
umass0 at uhub3 port 1 configuration 1 interface 0 "Iomega eGo USB" rev 2.10/0.00 addr 3
umass0: using SCSI over Bulk-Only
scsibus3 at umass0: 2 targets, initiator 0
sd1 at scsibus3 targ 1 lun 0: <OEM, Ext Hard Disk, 0000> SCSI3 0/direct fixed
sd1: 953169MB, 4096 bytes/sector, 244011446 sectors
..
umass1 at uhub1 port 4 configuration 1 interface 0 "Apple Inc. iPod" rev 2.00/0.01 addr 2
umass1: using SCSI over Bulk-Only
scsibus4 at umass1: 2 targets, initiator 0
sd1 at scsibus4 targ 1 lun 0: <Apple, iPod, 1.62> SCSI0 0/direct removable
sd1: 7583MB, 4096 bytes/sector, 1941441 sectors
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Post Reply