<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">It didn’t show me anything like that. It worked well. Here is what I have - note that I changed couple of things in printk statement but that shouldn’t affect your errors:<div><br></div><div>__________________________________________________</div><div style="font-size: 16px;"><b>Program - lx.c</b></div><div><br></div><div><div>#include <linux/module.h> // for printk()</div><div>#include <linux/mm.h> // for struct page</div><div>#include <asm/page.h> // for struct page</div><div>#include <asm/pgtable.h> // for ZERO_PAGE</div><div><br></div><div>static int __init init_hello( void )</div><div>{</div><div> int i;</div><div> struct page * zero_page;</div><div> printk(KERN_ALERT "\n Kello, the first! \n\n" );</div><div> i = 0x100;</div><div> zero_page = ZERO_PAGE(&i);</div><div> printk(KERN_ALERT " the ZERO address is %p", zero_page);</div><div> return 0;</div><div>}</div><div><br></div><div>static void __exit exit_hello( void )</div><div>{</div><div> printk(KERN_ALERT "\n Goodbye now... \n\n" );</div><div>}</div><div><br></div><div>MODULE_LICENSE("GPL");</div><div>module_init(init_hello);</div><div>module_exit(exit_hello);</div><div><br></div><div style="font-size: 16px;"><b>Makefile</b></div><div><br></div><div><div>obj-m :=lx.o</div><div><br></div><div><br></div><div>KDIR= /lib/modules/$(shell uname -r)/build</div><div><br></div><div>all:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules</div><div><br></div><div>clean:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>rm -rf $(wildcard *.o *.ko mo* Mo* *.mod.c)</div></div><div><br></div><div>____________________________________________________</div><div><br></div><div>Running make gives me(I’m in a Virtual Machine so the page addresses may be messed up):</div><div><br></div><div><div><b>sunny@ubuntu:</b> make</div><div>make -C /lib/modules/3.11.0-12-generic/build SUBDIRS=/home/sunny/Documents/ modules</div><div>make[1]: Entering directory `/usr/src/linux-headers-3.11.0-12-generic'</div><div> Building modules, stage 2.</div><div> MODPOST 1 modules</div><div>make[1]: Leaving directory `/usr/src/linux-headers-3.11.0-12-generic'</div></div><div><br></div><div><b>sunny@ubuntu:</b> sudo insmod lx.ko</div><div><b>sunny@ubuntu:</b> sudo rmmod lx</div><div><div><b>sunny@ubuntu:</b> sudo dmesg | tail -6</div><div>[48391.359434] Kello, the first! </div><div>[48391.359434] </div><div>[48320.368773] the ZERO address is ffffea0000079b40</div><div>[48391.359439] the ZERO address is ffffea0000079b40<1>[48411.409906] </div><div>[48411.409906] Goodbye now... </div><div>[48411.409906] </div></div><div><br></div><div>Hope this helps! Don’t forget to ‘reply all’ so that others in the mailing list could also see your/my problem/solution.</div><div><br></div><div>- Sunny</div><div><br><div><div>On Feb 24, 2014, at 7:32 PM, lx <<a href="mailto:lxlenovostar@gmail.com">lxlenovostar@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">hi :<div> If i command the "insmod zero.ko"; the wrong messages is:</div><div>##############</div><div>insmod: error inserting 'zero.ko': -1 Unknown symbol in module<br></div><div>##############</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-25 2:33 GMT+08:00 Sunny <span dir="ltr"><<a href="mailto:sundarcs@gwu.edu" target="_blank">sundarcs@gwu.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Hi,<div><br></div><div>I’m not sure about the “pays_base” warning, but your code runs fine in my machine. What happens if you ignore the warning and load the module anyway?</div><div><br>
</div><div>- Sunny</div><div><br><div><div><div class="h5"><div>On Feb 24, 2014, at 9:04 AM, lx <<a href="mailto:lxlenovostar@gmail.com" target="_blank">lxlenovostar@gmail.com</a>> wrote:</div><br></div></div><blockquote type="cite">
<div><div class="h5"><div dir="ltr">hi all:<div> the codes is:</div><div>#########################################</div><div><div>#include <linux/module.h> // for printk()</div><div>#include <linux/mm.h> // for struct page</div>
<div>#include <asm/page.h> // for struct page</div><div>#include <asm/pgtable.h> // for ZERO_PAGE</div><div><br></div><div>static int __init init_hello( void )</div><div>{</div><div>
int i;</div><div> struct page * zero_page;</div><div> printk( "\n Kello, the first! \n\n" );</div><div> i = 0x100;</div><div> zero_page = ZERO_PAGE(&i);</div><div> printk(" the ZERO address is %p", zero_page);</div>
<div> return 0;</div><div>}</div><div><br></div><div>static void __exit exit_hello( void )</div><div>{</div><div> printk( "\n Goodbye now... \n\n" );</div><div>}</div><div><br></div><div>MODULE_LICENSE("GPL");</div>
<div>module_init(init_hello);</div><div>module_exit(exit_hello);</div></div><div>#########################################</div><div><br></div><div>I complier it. by:</div><div>#########################################</div>
<div>make -C /lib/modules/`uname -r`/build M=`pwd`<br></div><div>#########################################</div><div><br></div><div>the results is:</div><div>#########################################</div><div><div>[root@localhost kernel_test]# make -C /lib/modules/`uname -r`/build M=`pwd`</div>
<div>make: Entering directory `/usr/src/kernels/2.6.18-308.el5-x86_64'</div><div> CC [M] /opt/lx/kernel/kernel_test/zero.o</div><div> Building modules, stage 2.</div><div> MODPOST</div><div><span style=""><b><font color="#ff0000">WARNING: "phys_base" [/opt/lx/kernel/kernel_test/zero.ko] undefined!</font></b></span></div>
<div> LD [M] /opt/lx/kernel/kernel_test/zero.ko</div><div>make: Leaving directory `/usr/src/kernels/2.6.18-308.el5-x86_64'</div></div><div>#########################################</div><div><br></div><div>I try to find the file which defined the "phys_base", for examples;</div>
<div><h1 style="font-family:'Trebuchet MS','Lucida Grande',Verdana,Arial,sans-serif;font-size:1.3em">phys_base</h1><span style="color:rgb(120,120,120);font-family:'Lucida Grande',Verdana,Arial,sans-serif;font-size:14px;background-color:rgb(51,51,51)">Defined as a variable in:</span><ul style="margin-top:0.5em;color:rgb(120,120,120);font-family:'Lucida Grande',Verdana,Arial,sans-serif;font-size:14px">
<li style="margin-top:0.35em"><a href="http://lxr.oss.org.cn/source/arch/sparc/mm/init.c?v=2.6.8#L40" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white;background-image:none;background-color:rgb(51,51,51)" target="_blank">arch/sparc/mm/init.c, line 40</a></li>
<li style="margin-top:0.35em"><a href="http://lxr.oss.org.cn/source/arch/sparc64/kernel/sparc64_ksyms.c?v=2.6.8#L110" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white;background-color:rgb(51,51,51)" target="_blank">arch/sparc64/kernel/sparc64_ksyms.c, line 110</a></li>
<li style="margin-top:0.35em"><a href="http://lxr.oss.org.cn/source/arch/sparc64/mm/init.c?v=2.6.8#L47" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white;background-color:rgb(51,51,51)" target="_blank">arch/sparc64/mm/init.c, line 47</a></li>
<li style="margin-top:0.35em"><a href="http://lxr.oss.org.cn/source/include/asm-sparc/page.h?v=2.6.8#L160" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white;background-color:rgb(51,51,51)" target="_blank">include/asm-sparc/page.h, line 160</a></li>
<li style="margin-top:0.35em"><a href="http://lxr.oss.org.cn/source/include/asm-sparc/pgtable.h?v=2.6.8#L122" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white;background-color:rgb(51,51,51)" target="_blank">include/asm-sparc/pgtable.h, line 122</a></li>
<li style="margin-top:0.35em"><a href="http://lxr.oss.org.cn/source/include/asm-sparc64/pgtable.h?v=2.6.8#L227" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white;background-color:rgb(51,51,51)" target="_blank">include/asm-sparc64/pgtable.h, line 227</a></li>
</ul></div><div><br></div><div>But I can't find the file of init.c in my computer. Please tell me some ways to solve it, thank you.</div><div><br></div></div></div></div>
_______________________________________________<br>Kernelnewbies mailing list<br><a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br><a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div><br></div></div></blockquote></div><br></div>
</blockquote></div><br></div></div></body></html>