kernel space

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

tsurrel
Posts: 1
Joined: Mon May 09, 2005 6:28 pm

kernel space

Mon May 09, 2005 6:38 pm

Hi,

I'm having problems trying to figure out how to use the linux drivers. For example, i'd like to access the spi bus. The 2.4.27 kernel linux provides a module that export three functions : spi_access, spi_transfer and spi_release, and i'd like to use them to access another chip. The thing is that i don't know how to access these functions from the user space. I have written a module that i load in kernel space, and that solution works fine. But then i am limited by the kernel space bounds : no libc (and i really would need it for the rest of my development) and little memory space !

Any help on that point ? Thanks in advance !

Thomas
Alexander Saers
Contact:
Posts: 9
Joined: Tue Dec 21, 2004 3:29 pm

Re: kernel space

Wed Jul 06, 2005 12:04 am

tsurrel wrote:Hi,

I'm having problems trying to figure out how to use the linux drivers. For example, i'd like to access the spi bus. The 2.4.27 kernel linux provides a module that export three functions : spi_access, spi_transfer and spi_release, and i'd like to use them to access another chip. The thing is that i don't know how to access these functions from the user space. I have written a module that i load in kernel space, and that solution works fine. But then i am limited by the kernel space bounds : no libc (and i really would need it for the rest of my development) and little memory space !

Any help on that point ? Thanks in advance !

Thomas
Simply create a driver that utilize the spi_* commands and shuffels data to userspace and an application that utilize the driver. This will let you use libc
Onitake
Location: Switzerland
Posts: 18
Joined: Fri Mar 11, 2005 2:46 pm

Wed Jul 20, 2005 4:06 pm

you'd do that by hooking up a device major and minor in your kernel module and by implementing read/write/ioctl handlers.
then, you can open() the device from userspace and access the spi bus through read(), write() and ioctl(), respectively. if you need fast access to large chunks of data, you can also allow user space to mmap() the device. this would enable virtual memory access by means of simple pointers.
i don't know the correct functions, but it shouldn't be too difficult to find in the kernel docs.
you can also call certain functions to advertise the major/minor combination to devfs/udev. this way, you won't have to create the /dev entry by hand (using mknod).
awm129
Location: Herndon, VA
Posts: 6
Joined: Tue Aug 09, 2005 3:06 pm

Tue Aug 09, 2005 3:51 pm

read up on linux device drivers. A great reference can be found here: http://www.xml.com/ldd/chapter/book/

There are several ways to transfer the data you need into user space, check out the above link for details.

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 2 guests