From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,d2a100b5deab7d49 X-Google-Attributes: gid1164f8,public X-Google-Thread: fee84,d2a100b5deab7d49 X-Google-Attributes: gidfee84,public From: Monty Brandenberg Subject: Re: DEC Unix and memory mapped IO Date: 1997/12/18 Message-ID: <3499A44F.2F1D1B80@eng.pko.dec.com>#1/1 X-Deja-AN: 299465852 Content-Transfer-Encoding: 7bit References: <678cg0$b9v@rzunews.unizh.ch> To: Rob Carter Content-Type: text/plain; charset=big5 Organization: Digital Equipment Corporation Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1,comp.sys.dec Rob Carter wrote: > > Now comes the question. We also have an Alpha Station 200 running > Digital Unix. Is it also possible to use the same techniques to access > card registers? We have the full DEC OSF/1 documentation set and I > have had a look through the Device Driver manuals, but I have not found > any examples of how to do this. I have found the documentation on the > mmap() function but am not sure if this is the way to proceed. If > anyone has done this succesfully I would appreciate any hints they > could give. > Broadly, there are two ways to go about this: 1. Use devsw.mmap() as you've discovered. In Digital Unix, the mmap syscall creates the requested process virtual address range managed by a mach memory object which is backed by information associating it with your device driver (via major/minor ids on the file descriptor). The pages are not valid, however. Later, as your process touches those pages, the system fields the resulting address translation traps and this code invokes your driver's mmap interface to translate an offset into a physical page number (or -1 if you want to raise an error). The ppn is used to construct a suitable pte for the faulting instruction which is then restarted. This happens once per page per process. 2. Use devsw.ioctl(). Create your own private interface to perform device mappings. The downside is that not all of the interesting interfaces are documented yet (vm_map_region, some others). The plus side is that it allows an opportunity to do further optimizations such as using 'BigPage' hints in the Alpha architecture to map huge chunks of address space with a single pte. Demand support! In all cases keep in mind: 1. The docs formally declare mmap 'unsupported on some hardware' so there's the disclaimer. 2. Deal with security issues such as authentication and authorization and identifying what device structures are suitable for a process and which are not (clue: dma registers are not). 3. Handle process exit. devsw.close() is invoked only on last close. So process info can become stale. 4. Understand the architecture. On alpha, this means sparse and dense address space mappings for I/O devices (pre-ev6). Also understand the data synchronization requirements in the Alpha arch manual. This is a *very* good section to read. m -- Monty Brandenberg Consulting for: MCB, Inc. Digital Equipment Corp. 45 Putnam Avenue mcbinc@world.std.com montyb@eng.pko.dec.com Cambridge, MA 02139 617.864.6907 508.493.2702