OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 9:48 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Disk sector; buffer cache;is my thinking process good at all
PostPosted: Mon May 16, 2022 7:54 am 
Offline
Member
Member

Joined: Fri Apr 08, 2022 3:12 pm
Posts: 54
I'm using int 0x13/AH=48h to get the sector size of the disk I'm reading. I've set a buffer in memory (4096 bytes) to cache data I've read. I didn't want to code around the fact it will be either 512 or 4096 and hence I did figure it out before reading any GPT structures. Now I'll face the same issue when reading ext2 structures. For those common (if not only) sector sizes it's easier to decide where and how should I cache my reads. But it does get more complicated with "wild", not common sector sizes.

My question is: am I maybe over-complicating things? Is this approach of trying to dynamically adjust to a possibly wild sector size common?


Last edited by mtbro on Tue May 17, 2022 1:39 am, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Disk sector; buffer cache; s my thinking process good at
PostPosted: Mon May 16, 2022 10:28 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
INT 0x13 only supports hard disks with 512-byte sectors.


Top
 Profile  
 
 Post subject: Re: Disk sector; buffer cache; s my thinking process good at
PostPosted: Mon May 16, 2022 11:33 am 
Offline
Member
Member
User avatar

Joined: Fri Sep 03, 2021 5:20 pm
Posts: 92
Octocontrabass wrote:
INT 0x13 only supports hard disks with 512-byte sectors.


Documentation on Int 0x13 states that function 0x48 is able to provide a sector size (word starting at offset 0x18). So is it able to report but not use, or not even report and just pretends it does?

_________________
Writing a bootloader in under 15 minutes: https://www.youtube.com/watch?v=0E0FKjvTA0M


Top
 Profile  
 
 Post subject: Re: Disk sector; buffer cache; s my thinking process good at
PostPosted: Mon May 16, 2022 12:35 pm 
Offline
Member
Member

Joined: Fri Apr 08, 2022 3:12 pm
Posts: 54
Octocontrabass wrote:
INT 0x13 only supports hard disks with 512-byte sectors.

That surprised me. I've the same logic as BigBuda, why does then 48h report sector size? Is this true for the whole int 0x13 services or only extended read (42h) ?
If this is true then I guess the whole logic I created to make sure I'm reading just enough sectors is useless. Does this mean I can't BIOS services (or at least those from int 0x13) on 4Kn disk?


Top
 Profile  
 
 Post subject: Re: Disk sector; buffer cache; s my thinking process good at
PostPosted: Mon May 16, 2022 12:41 pm 
Offline
Member
Member
User avatar

Joined: Fri Sep 03, 2021 5:20 pm
Posts: 92
mtbro wrote:
That surprised me. I've the same logic as BigBuda, why does then 48h report sector size? Is this true for the whole int 0x13 services or only extended read (42h) ?
If this is true then I guess the whole logic I created to make sure I'm reading just enough sectors is useless. Does this mean I can't BIOS services (or at least those from int 0x13) on 4Kn disk?


I do remember reading documentation stating that only non-extended Int 0x13 functions assumed 512byte-sectors.

_________________
Writing a bootloader in under 15 minutes: https://www.youtube.com/watch?v=0E0FKjvTA0M


Top
 Profile  
 
 Post subject: Re: Disk sector; buffer cache; s my thinking process good at
PostPosted: Mon May 16, 2022 1:08 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
In theory, BIOS EDD functions can support different sector sizes.

In practice, the BIOS will either not assign a drive number or hang during POST because it assumes hard disks always have 512-byte sectors and can't handle any other sizes.

If you want to boot from a 4kN disk, use UEFI.


Top
 Profile  
 
 Post subject: Re: Disk sector; buffer cache; s my thinking process good at
PostPosted: Mon May 16, 2022 2:51 pm 
Offline
Member
Member

Joined: Fri Apr 08, 2022 3:12 pm
Posts: 54
That means I really over-complicated my approach.
For the time being legacy boot suffice, I'm at the beginning of a steep learning curve.

Thanks.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 31 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