Page 1 of 1

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

Posted: Mon May 16, 2022 7:54 am
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?

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

Posted: Mon May 16, 2022 10:28 am
by Octocontrabass
INT 0x13 only supports hard disks with 512-byte sectors.

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

Posted: Mon May 16, 2022 11:33 am
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?

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

Posted: Mon May 16, 2022 12:35 pm
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?

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

Posted: Mon May 16, 2022 12:41 pm
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.

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

Posted: Mon May 16, 2022 1:08 pm
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.

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

Posted: Mon May 16, 2022 2:51 pm
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.