OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 20, 2024 9:56 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Emulate 4KB sector disk
PostPosted: Wed May 10, 2017 7:53 pm 
Offline

Joined: Wed May 10, 2017 7:00 pm
Posts: 9
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?


Top
 Profile  
 
 Post subject: Re: Emulate 4KB sector disk
PostPosted: Wed May 10, 2017 10:07 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
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

_________________
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.


Top
 Profile  
 
 Post subject: Re: Emulate 4KB sector disk
PostPosted: Thu May 11, 2017 7:27 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
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.

_________________
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html


Top
 Profile  
 
 Post subject: Re: Emulate 4KB sector disk
PostPosted: Fri May 12, 2017 1:20 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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.)

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 64 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group