LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 01-25-2016, 09:47 PM   #1
zvivered
Member
 
Registered: Sep 2007
Posts: 294

Rep: Reputation: 23
Device driver: read\write multiple words


Hello,

I'm developing a device driver for an FPGA that has dozens of registers. The registers are not address contiguous.

Till now, every register was written with a single IOCtl request.

Is there any alternative ?

I suspect this way is quite slow.

I can map the BARs of the FPGA to user space and write\read by *(long*) from the user space driver.
Is it a wise step ?

Regards,
Z.V
 
Old 01-26-2016, 03:14 AM   #2
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by zvivered View Post
Till now, every register was written with a single IOCtl request.

Is there any alternative ?

I suspect this way is quite slow.
The "slowness" would be due to the overhead of each system call.
You could minimize the overhead by using just one write() syscall, and pass the pointer of an array of the register values.
Use a soft mapping of array elements to FPGA registers.

E.G. The driver would have an array defining the mapping. Each element contains an FPGA register address (in any order you choose).
Code:
map[0] = reg_A
map[1] = reg_D
map[2] = reg_b
map[3] = reg_M
The userspace program would write to the device with an array. The driver copies the array into kernel space, and then in a loop extracts each value from the array and writes to the appropriate register per the map list.
You would need to handle various read/write lengths and maintain a read/write offset, and accept lseek(fd, 0, SEEK_SET) to reset that offset.

Regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] usb drive: cannot remount block device /dev/sdb1 read-write, is write-protected schneidz Linux - Hardware 5 01-06-2015 03:15 PM
[SOLVED] Device driver read/write functions not running for address 0x80000000 shade963 Linux - Kernel 0 09-10-2012 10:27 AM
read/write in block device driver zali Programming 4 05-05-2012 03:14 AM
Linux Driver - how to read/write a block or character device in kernel space (procfs) stybi Linux - Kernel 1 01-27-2011 06:26 AM
How to write a character device driver to read the processor's GDT kiranshadow Linux - General 1 05-10-2008 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 05:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration