Page 1 of 1
Emulate 4KB sector disk
Posted: Wed May 10, 2017 7:53 pm
by zq
I'm doing something about disk reading under real mode and I wanna my program to be more compatible, that is, consider 4KB(or any size other than conventional 512Bytes ).
However trouble came when I deal with qemu, even I've set those properties such like physical and logical block size in command line, but my program detect that by BIOS int 13h,ah 0x42, still it return a value with sector size 512.
I don't know if my command is wrong, can anyone tell m3 the right solution.
OR Does it means in bios sector size is ALWAYS logical 512B?
Re: Emulate 4KB sector disk
Posted: Wed May 10, 2017 10:07 pm
by Brendan
Hi,
zq wrote:I'm doing something about disk reading under real mode and I wanna my program to be more compatible, that is, consider 4KB(or any size other than conventional 512Bytes ).
However trouble came when I deal with qemu, even I've set those properties such like physical and logical block size in command line, but my program detect that by BIOS int 13h,ah 0x42, still it return a value with sector size 512.
I don't know if my command is wrong, can anyone tell m3 the right solution.
OR Does it means in bios sector size is ALWAYS logical 512B?
For backward compatibility for hard drives with 4 KiB sectors:
- most hard drives emulate 512-byte sectors in their default mode, so that the BIOS and/or old software doesn't break
- for hard disks that don't emulate 512-byte sectors, the BIOS has to support "4 KiB native" and the BIOS emulates 512-byte sectors
To avoid the performance costs (without writing your own device driver that puts the drive into "native mode") you can just read/write "groups of eight 512-byte pretend sectors that are aligned on an 8 pretend sector boundary".
Cheers,
Brendan
Re: Emulate 4KB sector disk
Posted: Thu May 11, 2017 7:27 am
by Geri
hard drives on the market will give 512 byte blocks for you. only older special non-standard hardware will give different sector size, but you will not met any of such on the market. so the vaules you got are correct.
Re: Emulate 4KB sector disk
Posted: Fri May 12, 2017 1:20 am
by Kevin
zq wrote:Does it means in bios sector size is ALWAYS logical 512B?
Yes, that's how the BIOS interfaces are defined. If you want to use a 4k native disk to boot from, you need something else, like UEFI. (As Brendan says, the BIOS could emulate 512b sectors on a 4k disk, but that would be slow, not 100% correct and in practice I haven't seen a BIOS that supports it.)