[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] Petalinux kernel space vs user space



Hi,

A. Bose wrote:

I am a device driver that calls registers in my EDK design. I can access the registers in user space, so should I make it a user space driver as oppose to a kernel space one?

This would make things easier as there would be no kernel space debugging and no ioctl to create.

Are there any special convention that should be followed within petalinux?

On uClinux with noMMU, there's no physical prevention of accessing the hardware directly. However, you have to be very careful because if you have e.g. two instances of your program running, you will get conflicts and un-debuggable errors.

Also, you cannot write interrupt handlers in userspace.

For this reason, I typically recommend writing a proper driver. It also means that your driver will work if you decide you want to use the MMU. direct access to HW from userspace requires some special tricks when the MMU is enabled.

As of 2.6.23 (or thereabouts) there is a new UIO (userspace IO) framework in the kernel. Google for linux uio to read about it.

You create a very lightweight kernel driver that detects the device and registers the IO ports used (the register map), as well as specifiying an interrupt handler. You then hook into this from userspace to write your driver.

I recently backported thisinto PetaLinux 2.6.20, and it seems to be working well (with some changes required for !MMU operation). I will fold this into the next petalinux release. If you are keen to try it let me know and I'll pull out a patch.

Regards,

John









___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/