Hi Dave,<br><br>Thanks for reply. My English is not very good, and so I want to ask about a term:map. Does map mean that create a relationship between the virtual space and physical memory?<br><br>Thanks again!<br><br><div class="gmail_quote">
在 2012年4月18日 下午4:17,Dave Hylands <span dir="ltr"><<a href="mailto:dhylands@gmail.com">dhylands@gmail.com</a>></span>写道:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi ,<br>
<div><div class="h5"><br>
On Wed, Apr 18, 2012 at 12:44 AM, 夏业添 <<a href="mailto:summerxyt@gmail.com">summerxyt@gmail.com</a>> wrote:<br>
> Hi everyone,<br>
><br>
> there are some functions can alloc memory in kernel, but it seems that I<br>
> cannot use it directly. Here is my code:<br>
><br>
> static int mytest_vm(){<br>
><br>
> struct vm_struct *v_start;<br>
><br>
> v_start=alloc_vm_area(PAGE_SIZE,NULL); //the kernel api has changed,<br>
> I don't understand why there is a second parameter<br>
> if(v_start==NULL){<br>
> printk("cannot alloc page\n");<br>
> return -1;<br>
> }<br>
><br>
> sprintf((char *)v_start->addr,"this is a test.\n");<br>
> printk("after sprintk:%s",(char *)v_start->addr);<br>
><br>
> free_vm_area(v_start);<br>
><br>
> return 0;<br>
> }<br>
> module_init(mytest_vm);<br>
><br>
> but it just got a kernel Oops. Can anyone explain this to me? Thanks very<br>
> much!<br>
<br>
</div></div>If my understanding of things is correct, this just allocates virtual<br>
space. That virtual space isn't backed by any physical pages.<br>
<br>
The normal kernel allocators are things like kmalloc and vmalloc.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Dave Hylands<br>
Shuswap, BC, Canada<br>
<a href="http://www.davehylands.com" target="_blank">http://www.davehylands.com</a><br>
</font></span></blockquote></div><br>