mvduin/py-uio

Suggestion

Closed this issue · 1 comments

I think that we shouldn't have devs developing specific drivers with UIO get access to the registers by submitting a ctype structure.

I think that the UIO library should (try to) dynamically generate an object based off a user request for a memory range.

That way, if you decide you don't like to use the ctypes method, or whatever, it doesn't affect the developers like me who know we'll get an object from the function that allows us to access certain memory ranges regardless of inner mechanics.

The object could allow you to access the memory ranges by offset or by name if some type of dictionary is supplied (think c macro define).

edit: ps, i think uio.map should map all regions by default

The library already generates MemRegion objects out of the available information about a memory range. You still need some mechanism to access it correctly, which is what you pass to .map. You can submit any object or class with a .from_buffer( buffer, offset ) method, although I've not seen any real alternative to using ctypes. There is no way to "access certain memory ranges regardless of inner mechanics".

You can access a single register using something like .map( ctypes.c_uint32, offset ).value although I don't see why you would want to. I'm not really motivated to make this any nicer since I don't want to encourage using uio in such an inefficient way.

I don't understand what you mean by your ps. (I do think that since I've implemented the parent argument there's no longer much reason to use mmap() lazily, so I might move that from .map to the MemRegion constructor.)