OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:23 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: CanI use int 13h function 42h to read more than 1mb of disk
PostPosted: Fri May 19, 2017 10:31 am 
Offline
User avatar

Joined: Sat May 06, 2017 11:35 am
Posts: 10
theoretically you can specify the number of sectors you want to read from 0 - 65535 but how many can you actually read at once ? does this interrup is limited to only addressing memory that it's linear loc is no bigger than 1mb ( 2 ^ 20 default real mode maximum memory size) or does it using unreal mode or something like that and can read even 65535 sectors (16mb to the ram) sorry for my english.

_________________
Restart any PC in the easy way around:

mov eax,cr0
xor al,1
mov cr0,eax
lidt [illegal_idtr]
jmp 0:$

; done:)


Top
 Profile  
 
 Post subject: Re: CanI use int 13h function 42h to read more than 1mb of d
PostPosted: Fri May 19, 2017 11:28 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
Theoretically, you can read up to 65535 sectors using this function, as the sectors count fields in the disk address packet structure is 16 bits wide. However, in practice, the majority of BIOSes, including Bochs, QEMU and one of my real PCs, don't allow you to cross a segment boundary. This depends on your segment:offset combinations. Assuming you're using a specific segment with offset 0, the maximum value is 127 sectors for most BIOSes. For compatibility's sake, you should split up large accesses into smaller accesses, each 127 sectors (or less) in size.

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: CanI use int 13h function 42h to read more than 1mb of d
PostPosted: Fri May 19, 2017 11:36 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

EladAshkcenazi335 wrote:
theoretically you can specify the number of sectors you want to read from 0 - 65535 but how many can you actually read at once ? does this interrup is limited to only addressing memory that it's linear loc is no bigger than 1mb ( 2 ^ 20 default real mode maximum memory size) or does it using unreal mode or something like that and can read even 65535 sectors (16mb to the ram) sorry for my english.


The maximum you can read at once depends on multiple things (which firmware, which device, etc). If you look at the Enhanced Disk Drive Specifications (at least up to version 3.0) you'll find that the "number of blocks to transfer" field is a 1 byte field (followed by a reserved byte that must be zero), and the specification will say:

    "Number of blocks to transfer. This field has a maximum value of 127 (7Fh). If a value greater than 127 is supplied the request is rejected with CF=1 and AH=01. A block count of 0 means no data will be transferred."

Some implementations might not comply with the EDD specifications, and might allow more than 127 blocks to be transferred (by failing to reject the request with CF=1), and some might allow more than 255 blocks to be transferred (by failing to treat the reserved/"must be zero" byte as reserved).

For "absolute theoretical maximum", if you can invent/create a device where each sector is 4 GiB and find a computer where EDD is "very broken", you could load 262140 GiB.

Also note that I'd expect the firmware to use the controller's DMA/bus mastering to load data directly into the physical address you requested without using the CPU (and without needing unreal mode or protected mode); but there's no guarantee that the BIOS will do that, and there's no guarantee that the BIOS won't (e.g.) switch to protected mode or long mode (and do the transfer with PIO) and switch back to real mode after.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


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

All times are UTC - 6 hours


Who is online

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