Subject: Re: user mapping pci memory
To: Matthias Drochner <>
From: Chris G. Demetriou <>
List: tech-kern
Date: 03/11/1997 11:39:56
> There is another problem with the mmap() return value which
> is hurting me from time to time: (on i386)
> I have a PCI device with a 2k region which I'd like to access from
> user space. Sometimes this area is physically mapped 4k-aligned,
> sometimes not, depending on BIOS version and resource usage in
> the machine. There is no way to tell the user application the actual
> base address (I use an additional ioctl which is ugly).

This is not "a problem with the mmap return value."  mmap maps
page-sized physical regions to virtual pages.  It does not map areas
smaller than full pages to anything, and can't be used for that
without 'special help.'  That's not a bug in the mmap design, it's a
necessary side effect of having to map things in units of pages.

It's worth noting that I do actually intend to deal with this in a
user-land bus_space_* implementation.  However, the way it'll work
will involve some ioctl to find out what spaces the device exports.

> Further, the mmap() interface is not very satisfying when mapping
> registers have to be allocated for the mapped region. It would be useful
> to get an information about the whole mapped range when it is mapped,
> and it would be even nicer to know when it is unmapped.

People have discussed changes like the former.  They have potentially
interesting problems, however.  (e.g. say you mmap a region, and it
ends up being two or more physically discontiguous regions.  How do
you communicate that?)  They're problems that can be solved, but
they're annoying.

As for notification when unmapping is done, I don't recall anybody
having discussed that in the context of NetBSD before...