This could actually be very interesting.  mmap() really does all of the work.  But notice that mmap() it is not passed any address information (other than a "suggested" mapped, user-space address).  It also received an instance of the file descriptor of the driver.

The Linux file_operations structure is here: https://elixir.bootlin.com/linux/latest/source/include/linux/fs.h#L1983

Notice that there is a mmap method in the file operations.  So, mmap(), it seems, calls the mmap method on the driver which performs the user spacemapping of the device resource, much as you suggested in your original email.  The mmap() offset field specifies which device resource to map.

That actually sounds very elegant to me and meets all of my concerns:

 * The application cannot map any arbitrary kernel address to user
   space so the implementation is secure.
 * It uses the standard POSIX mmap() to accomplish the mapping.


On 3/28/2024 3:01 PM, Gregory Nutt wrote:

I found this document which describes the use cases for UIO in Linux: https://www.kernel.org/doc/html/v4.13/driver-api/uio-howto.html . They use mmap() to addess device memory: "|/dev/uioX| is used to access the address space of the card. Just use |mmap()| to access registers or RAM locations of your card."

There is a paragraph with a little more info: https://www.kernel.org/doc/html/v4.13/driver-api/uio-howto.html#mmap-device-memory

My only concerns here are:  (1) We use POSIX/Linux compatibility in interface definitions and (2) We assure security of kernel resources.  I am not sure how mmap() knows which kernel mappings are secure and which are insecure.  But we would need to address that.  If secure, standard interfaces are used, then I am supportive (and you can ignore many of my other comments which were just me fumbling to understand the proposal).


On 3/28/2024 12:25 PM, Gregory Nutt wrote:

A more interesting task would be to port NxLib to run on top of the existing NuttX NX Windows System:

  * https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629474
  * https://cwiki.apache.org/confluence/display/NUTTX/NX+Graphics+Subsystem

That would not be particularly easier, however.  The NX Window System is purely a windowing system and does not provide any significant graphics support.  X11, by comparison, is a complete graphics system and user libraries are really only needed to simplify the interfaces and to extend the graphics capabilities.

You would have to come up with some way to provide the graphics capability in Nano-X not included in NX Windows.

In the NX Windows world, graphics was intended to be provided by NxWidgets.  That, however, is a work that was never really completed to production quality.  There are also several window managers that use NX Windows and NxWidgets:  NX and Twm4Nx.  The latter is a TWM inspired window manager (but a unique C++ development).

Reply via email to