OSDev.org
https://forum.osdev.org/

int 0x13, ah=42
https://forum.osdev.org/viewtopic.php?f=1&t=36746
Page 1 of 1

Author:  8infy [ Sun May 10, 2020 11:45 am ]
Post subject:  int 0x13, ah=42

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.

Author:  BenLunt [ Sun May 10, 2020 12:01 pm ]
Post subject:  Re: int 0x13, ah=42

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

Author:  Octocontrabass [ Sun May 10, 2020 12:26 pm ]
Post subject:  Re: int 0x13, ah=42

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

Author:  8infy [ Sun May 10, 2020 2:26 pm ]
Post subject:  Re: int 0x13, ah=42

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.

Author:  8infy [ Sun May 10, 2020 2:28 pm ]
Post subject:  Re: int 0x13, ah=42

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.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/