Making IO Requests to Device Drivers
Posted: Fri Jun 23, 2006 6:29 pm
I've been working on my kernel again recently, and I seem to have come across a pretty grey area as far as my knowledge is concerned.
Basically, I can't see how IO requests can be easily forwarded from the kernel to a device driver. This is a microkernel-ish system where the drivers would run in user-mode, hence making kernel buffers inaccessible to them.
Say, for example, that an application memory maps a file X to a particular region of address space. It then attempts to read a portion of this file, which results in a page fault. By my current design, my memory manager would detect that the attempted address is part of the region mapping file X, and it would scan the page cache for this part of the file. Having not found the page in the page cache, it would allocate a fresh page, and somehow issue a request to the file system in user-mode to read from the file into that particular physical page. This is the part I am having trouble understanding.
The only solution I can think of is to have the kernel call the read handler in the user-mode driver, then have the user mode driver 'request' the physical memory it needs to satisfy the request from the kernel. The kernel, somehow noticing that the driver is requesting memory for that particular IO operation involving file X, returns the physical page which was previously allocated for it. The driver would then initiate a DMA read into that page.
The thing is, I don't know if that would be possible, because the block size of the device might be bigger than the page size. Does that mean I will need more than one physical page for the transfer?
I'll be very grateful for any comments/help on this subject. I'm also willing to answer any questions you may have on my design and implementation, so fire away!
Cheers,
The Senaus
Basically, I can't see how IO requests can be easily forwarded from the kernel to a device driver. This is a microkernel-ish system where the drivers would run in user-mode, hence making kernel buffers inaccessible to them.
Say, for example, that an application memory maps a file X to a particular region of address space. It then attempts to read a portion of this file, which results in a page fault. By my current design, my memory manager would detect that the attempted address is part of the region mapping file X, and it would scan the page cache for this part of the file. Having not found the page in the page cache, it would allocate a fresh page, and somehow issue a request to the file system in user-mode to read from the file into that particular physical page. This is the part I am having trouble understanding.
The only solution I can think of is to have the kernel call the read handler in the user-mode driver, then have the user mode driver 'request' the physical memory it needs to satisfy the request from the kernel. The kernel, somehow noticing that the driver is requesting memory for that particular IO operation involving file X, returns the physical page which was previously allocated for it. The driver would then initiate a DMA read into that page.
The thing is, I don't know if that would be possible, because the block size of the device might be bigger than the page size. Does that mean I will need more than one physical page for the transfer?
I'll be very grateful for any comments/help on this subject. I'm also willing to answer any questions you may have on my design and implementation, so fire away!
Cheers,
The Senaus