Disk sector; buffer cache;is my thinking process good at all

Programming, for all ages and all languages.
Post Reply
mtbro
Member
Member
Posts: 54
Joined: Fri Apr 08, 2022 3:12 pm

Disk sector; buffer cache;is my thinking process good at all

Post by mtbro »

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.
Octocontrabass
Member
Member
Posts: 5515
Joined: Mon Mar 25, 2013 7:01 pm

Re: Disk sector; buffer cache; s my thinking process good at

Post by Octocontrabass »

INT 0x13 only supports hard disks with 512-byte sectors.
User avatar
BigBuda
Member
Member
Posts: 104
Joined: Fri Sep 03, 2021 5:20 pm

Re: Disk sector; buffer cache; s my thinking process good at

Post by BigBuda »

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
mtbro
Member
Member
Posts: 54
Joined: Fri Apr 08, 2022 3:12 pm

Re: Disk sector; buffer cache; s my thinking process good at

Post by mtbro »

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?
User avatar
BigBuda
Member
Member
Posts: 104
Joined: Fri Sep 03, 2021 5:20 pm

Re: Disk sector; buffer cache; s my thinking process good at

Post by BigBuda »

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
Octocontrabass
Member
Member
Posts: 5515
Joined: Mon Mar 25, 2013 7:01 pm

Re: Disk sector; buffer cache; s my thinking process good at

Post by Octocontrabass »

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.
mtbro
Member
Member
Posts: 54
Joined: Fri Apr 08, 2022 3:12 pm

Re: Disk sector; buffer cache; s my thinking process good at

Post by mtbro »

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.
Post Reply