Page 1 of 2
INT 13h, AH=42h - extended read sectors
Posted: Fri Mar 09, 2012 12:12 pm
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?
Re: INT 13h, AH=42h - extended read sectors
Posted: Fri Mar 09, 2012 11:27 pm
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.
Re: INT 13h, AH=42h - extended read sectors
Posted: Sat Mar 10, 2012 5:18 am
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?
Re: INT 13h, AH=42h - extended read sectors
Posted: Sat Mar 10, 2012 5:27 am
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.
Re: INT 13h, AH=42h - extended read sectors
Posted: Sat Mar 10, 2012 5:59 am
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!
Re: INT 13h, AH=42h - extended read sectors
Posted: Sat Mar 10, 2012 10:15 am
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.
Re: INT 13h, AH=42h - extended read sectors
Posted: Tue Apr 03, 2012 2:58 pm
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!
Re: INT 13h, AH=42h - extended read sectors
Posted: Wed Apr 04, 2012 12:57 am
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.
Re: INT 13h, AH=42h - extended read sectors
Posted: Wed Apr 04, 2012 1:02 am
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.
Re: INT 13h, AH=42h - extended read sectors
Posted: Fri Apr 27, 2012 9:30 am
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.
Re: INT 13h, AH=42h - extended read sectors
Posted: Fri Apr 27, 2012 1:12 pm
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
Re: INT 13h, AH=42h - extended read sectors
Posted: Fri Apr 27, 2012 1:58 pm
by egos
Large disks emulate 512-byte sectors. Just align partitions/clusters on 4 kb boundaries (8 sectors) for good performance.
Re: INT 13h, AH=42h - extended read sectors
Posted: Sat Apr 28, 2012 6:45 am
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.
Re: INT 13h, AH=42h - extended read sectors
Posted: Sat Apr 28, 2012 8:53 am
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.
Re: INT 13h, AH=42h - extended read sectors
Posted: Sat Apr 28, 2012 10:23 am
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