Re: cross-bounday memory communication b/w user app and the Kernel.How?
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=P+qK9DEzxg5eXugCrNRaBYBMZYfB6iF/2ftDjSTo9j1ZQkogJ2EPwVd4AU6iVzNRIa4w9NU9dQCbSnnHyKyr/7DlINGS23DKYddz4m+/wvSl5JscLr4M/jJDPRL47XqZQyJWDcwzz6FYvDdSJe86q5vKzJkqplTh02/pI0B5yMo= Hi Michael, Thanks for your suggestion, but i need to tell you two things : 1. I am sure that you did not get my question right. 2. I am totally new to Mac OS X, never worked on it before (neither on linux/unix too). It just two months back, I was given a machine called APPLE :) and had to work on same. But, I do have extensive experience in device drivers especially file system filter drivers on NT based systems. So it is taking me some time to relate things to a tottaly new environment. On the other hand, You guys have been working on these Mac systems from years (infact most of you are developing it ) . This is where the difference lies. I would certainly buy the books suggested by you. These seems quite helpful in understanding the core OS.( especially, Mac OS X Internals, by Mr. Amit singh) You don't. The descriptor refers to the buffer that already exists in the user-space process' address space. You don't need to copy anything. I know that the descriptor refers to the buffer only. But say for example I wish to set this data to all zero's. So in this case: (a) will I give address of the structure OR (b) address of IOMemoryDescriptor,, as the first parameter to memset ? Similarly what if I want to copy the data AGAIN in my driver side ? Do I need to send the address of structure to the memcpy ? Or do i need to pass address of IOMemoryDescriptor as the first parameter to memcpy. I hope I am able to clarify my query. Please comment. Thanks and Regards, Rohit Dhamija On Jun 1, 2006, at 9:06 PM, rohit dhamija wrote:
Thanks a lot for your comments !! Your suggestions are very good and valuable.
B/w i have one query ,
Create the IOMemoryDescriptors directly against the user-space addresses and do your I/O with those.
At this point i have memory of type IOMemoryDescriptor*. But Now I need to copy some information in this memory. So is it fine to copy using memcopy :to copy information in descr (of type IOMemoryDescriptor* ) ?? There is nothing to copy. like
IOMemoryDescriptor * outDescriptor = NULL;
// Get the data into kernel space outDescriptor = IOMemoryDescriptor::withAddress( (vm_address_t)pComm->command_payload, sizeof(command_structure), kIODirectionOut, fClientTask);
now I need to copy some data into
so is it fine to do:
memcpy((void*)&outDescriptor, mydataBuffer, sizeof(MYDATABUFFER));
IF not, then how to copy/fill info in the descriptor ? You don't. The descriptor refers to the buffer that already exists in the user-space process' address space. You don't need to copy anything. I want to ask "don't they teach you anything in school these days?" but perhaps that's a bit harsh. I would suggest that if you plan on doing much more work on device drivers that you should spend a little time reading up on the history and design of operating systems. There are a lot of fundamental things that it would really help you to know. Might I suggest: http://www.osxbook.com/ http://www.amazon.com/gp/product/0201549794/qid=1149228811/sr=1-7/ ref=sr_1_7/104-5530617-5549562?s=books&v=glance&n=283155 http://www.amazon.com/gp/product/0130313580/sr=8-1/qid=1149228772/ ref=pd_bbs_1/104-5530617-5549562?%5Fencoding=UTF8 http://www.amazon.com/gp/product/0131429388/qid=1149228811/sr=1-6/ ref=sr_1_6/104-5530617-5549562?s=books&v=glance&n=283155 http://www.amazon.com/gp/product/0130981389/qid=1149228870/sr=2-1/ ref=pd_bbs_b_2_1/104-5530617-5549562?s=books&v=glance&n=283155 http://www.amazon.com/gp/product/013021034X/qid=1149228906/sr=1-2/ ref=sr_1_2/104-5530617-5549562?s=books&v=glance&n=283155 I'm sure that you can get these books for considerably less elsewhere, it was just convenient to use Amazon to look them up. I'm also sure that other folks on this list will have their own suggestions; the above clearly shows my *nix background. = Mike
-- Rohit Dhamija(M) 9818446545 _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... Regarding my query, On 6/2/06, Michael Smith <drivers@mu.org> wrote: This email sent to site_archiver@lists.apple.com
participants (1)
-
rohit dhamija