LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-31-2012, 03:22 AM   #1
dgashu
Member
 
Registered: Apr 2010
Location: Banglore
Distribution: fedora , rhel,Ubuntu
Posts: 61

Rep: Reputation: 1
HOW to do BUFFER COPY in LINUX KERNEL


Hi all ,

I am working for an DMA driver on LINUX 2.6.32.

I having having the DMA data from the device in BUFFER A[using dma_alloc_coherent] such that

char *dmasrcptr =dma_alloc_coherent(NULL,GLOBAL_BUFFER_SIZE,&dmadest,0);


Now from user space i am getting an structure which has the buffer on which need to do copy this buffer.


typedef struct {
unsigned int value;
unsigned char charbuf[GLOBAL_BUFFER_SIZE];
}driver_struct;


At present i am doing an copy to user_buffer[in structure] using an for loop.

like :-
a. I am assigning an local char pointer.
b. This pointer i am initializing to BUFFER of user structure.
c. Then using FOR loop i am acessing data from DMA buffer and storing it in user buffer [in structure] using for loop.

Can any one please let me know if there is any better method or an optimized function call.{ like MEMCPY }



Thanks
Ashish Mishra
 
Old 11-01-2012, 07:28 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
This might go down better at http://kernelnewbies.org/

There are definitely functions for copying between kernel and user space. The fastest tip may be to look at an existing driver.

Last edited by linosaurusroot; 11-01-2012 at 07:30 AM.
 
Old 11-01-2012, 02:22 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 11-02-2012, 11:29 AM   #4
dgashu
Member
 
Registered: Apr 2010
Location: Banglore
Distribution: fedora , rhel,Ubuntu
Posts: 61

Original Poster
Rep: Reputation: 1
Hi all ,

#include <linux/string.h>
memmove did the work for me !!!!
 
  


Reply



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
Copy ALSA buffer to the buffer allocated in my driver. yethish Programming 1 08-04-2011 11:27 AM
Doing a zero-copy move of data from a kernel buffer to hard disk. neeraj.kumar01 Linux - Kernel 1 12-17-2010 06:48 PM
mouse copy buffer adamruss Programming 0 07-26-2007 12:57 PM
Copy output of Terminal Buffer tryangle Debian 2 08-08-2005 04:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:53 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