rickm@IGOR.TAMRI.COM (Rick marsh) (02/15/91)
Some questions that relate to a device driver that I need to write. It will run initially on a Personal Iris. 1. We need to translate virtual addresses to physical addresses, in order to do dma transfers. The only routine that appears to do this is kvtophys(), this translates kernel virtual addresses to physical addresses. Is there a routine that translates user virtual addresses to physical addresses ? 2. If there is not, and we are forced to use kvtophys(), is there a routine that maps user virtual memory to kernel virtual memory ? It appears that physio() does this but we don't want to call physio() because it does several other things that we do not need (We don't want to do the dma transfer at the time that we do the virtual to physical translation). 3. mpin() locks pages into physical memory, is it at all possible that a page, once locked, would be moved around in memory? We intend to do the dma transfer some time after doing the virtual to physical translation and moving pages would be a disaster. Any advice will be appreciated. Rick Marsh Toshiba America MRI Inc. (415) 872-2722 ext. 2226 rickm@tamri.com
bpoelli@RELAY.NSWC.NAVY.MIL (02/16/91)
olson@anchor.esd.sgi.com (Dave Olson) (02/16/91)
In <9102142334.AA03699@igor.tamri.com> rickm@IGOR.TAMRI.COM (Rick marsh) writes: | Some questions that relate to a device driver that I need to write. It | will run initially on a Personal Iris. | | 1. We need to translate virtual addresses to physical addresses, in order | to do dma transfers. The only routine that appears to do this is kvtophys(), | this translates kernel virtual addresses to physical addresses. Is there a | routine that translates user virtual addresses to physical addresses ? kvtophys is pretty much it, although there are some special cases. | 2. If there is not, and we are forced to use kvtophys(), is there a routine | that maps user virtual memory to kernel virtual memory ? It appears that | physio() does this but we don't want to call physio() because it does | several other things that we do not need (We don't want to do the dma transfer | at the time that we do the virtual to physical translation). If you don't do it at the time of the copy/io, then the physical address could be different by the time you actually wanted to do the i/o, unless you lock the pages down. | 3. mpin() locks pages into physical memory, is it at all possible that a page, | once locked, would be moved around in memory? We intend to do the dma transfer | some time after doing the virtual to physical translation and moving pages | would be a disaster. As I recall, the answer is no, but what is your objection to doing the address translation at the time of the DMA? It isn't all that expensive to do it, and locking down lots of memory can be pretty anti-social. For more detailed answers to these questions, and device drivers in general, get the following document: SGI Document #007-0911-010 Writing Device Drivers for Silicon Graphics Computer Systems -- Dave Olson Life would be so much easier if we could just look at the source code.