int 0x13, ah=42

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
8infy
Member
Member
Posts: 185
Joined: Sun Apr 05, 2020 1:01 pm

int 0x13, ah=42

Post by 8infy »

Hey everyone, as the title says, im trying to use the extended read function in my VBR code, but i'm having a trouble understanding the sector count field of the DAP packet.
Every VM I've tried fails at different block counts,iirc VMWare fails at 128, VirtualBox fails at 129, QEMU fails at 129, Bochs fails at 255. My disk is 64mb in size,
and is ~130k sectors. I know I could just read like 127 blocks at once and do it multiple times, not that my kernel loader is that big anyways. I'm just trying to understand
whether i'm doing something wrong or maybe thats just the limit. If its the latter, how can Bochs allow to read over 65536 bytes in 16 bit addressing? And why is that
field even 2 bytes in size if you can't read more than 128 blocks at a time?

Thanks.
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: int 0x13, ah=42

Post by BenLunt »

One of the major BIOS manufacturers had a limit of 0x7F (127d) sectors per transfer. Most other manufacturers followed suite.

To be 100% accurate, you need to do two things when using this function, not counting checking to see if it is available.

- Do not transfer more than 127 sectors at a time.
- Do not cross a 64k boundary with your buffer.

In other words, if you need to transfer more than 127 sectors, you need to call this function multiple times, as well as the buffer used must not have the read cross a 64k boundary.

Ben
- http://www.fysnet.net/osdesign_book_series.htm
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: int 0x13, ah=42

Post by Octocontrabass »

8infy wrote:If its the latter, how can Bochs allow to read over 65536 bytes in 16 bit addressing?
Bochs is most likely playing with the segment registers to address more than 64kB at a time.
8infy wrote:And why is that field even 2 bytes in size if you can't read more than 128 blocks at a time?
Who says it's two bytes? According to the specification, it's only one byte, and the maximum allowed value is 127 (0x7F). (A later version of the specification also allows 0xFF for extended functionality, but I don't think support for this version is very common.)
8infy
Member
Member
Posts: 185
Joined: Sun Apr 05, 2020 1:01 pm

Re: int 0x13, ah=42

Post by 8infy »

Octocontrabass wrote:
8infy wrote:If its the latter, how can Bochs allow to read over 65536 bytes in 16 bit addressing?
Bochs is most likely playing with the segment registers to address more than 64kB at a time.
8infy wrote:And why is that field even 2 bytes in size if you can't read more than 128 blocks at a time?
Who says it's two bytes? According to the specification, it's only one byte, and the maximum allowed value is 127 (0x7F). (A later version of the specification also allows 0xFF for extended functionality, but I don't think support for this version is very common.)
Interesting, on wikipedia it says 2 bytes. 1 byte makes more sense, thanks.
8infy
Member
Member
Posts: 185
Joined: Sun Apr 05, 2020 1:01 pm

Re: int 0x13, ah=42

Post by 8infy »

BenLunt wrote:One of the major BIOS manufacturers had a limit of 0x7F (127d) sectors per transfer. Most other manufacturers followed suite.

To be 100% accurate, you need to do two things when using this function, not counting checking to see if it is available.

- Do not transfer more than 127 sectors at a time.
- Do not cross a 64k boundary with your buffer.

In other words, if you need to transfer more than 127 sectors, you need to call this function multiple times, as well as the buffer used must not have the read cross a 64k boundary.

Ben
- http://www.fysnet.net/osdesign_book_series.htm
Thanks! So to fill up an entire segment I would have to read 127, and then read 1 more? so that it's exactly 2^16 bytes.
Post Reply