* [kernel]which the file define the variable of "phys_base"?
@ 2014-02-24 14:04 lx
2014-02-24 18:33 ` Sunny
0 siblings, 1 reply; 3+ messages in thread
From: lx @ 2014-02-24 14:04 UTC (permalink / raw)
To: kernelnewbies
hi all:
the codes is:
#########################################
#include <linux/module.h> // for printk()
#include <linux/mm.h> // for struct page
#include <asm/page.h> // for struct page
#include <asm/pgtable.h> // for ZERO_PAGE
static int __init init_hello( void )
{
int i;
struct page * zero_page;
printk( "\n Kello, the first! \n\n" );
i = 0x100;
zero_page = ZERO_PAGE(&i);
printk(" the ZERO address is %p", zero_page);
return 0;
}
static void __exit exit_hello( void )
{
printk( "\n Goodbye now... \n\n" );
}
MODULE_LICENSE("GPL");
module_init(init_hello);
module_exit(exit_hello);
#########################################
I complier it. by:
#########################################
make -C /lib/modules/`uname -r`/build M=`pwd`
#########################################
the results is:
#########################################
[root at localhost kernel_test]# make -C /lib/modules/`uname -r`/build M=`pwd`
make: Entering directory `/usr/src/kernels/2.6.18-308.el5-x86_64'
CC [M] /opt/lx/kernel/kernel_test/zero.o
Building modules, stage 2.
MODPOST
*WARNING: "phys_base" [/opt/lx/kernel/kernel_test/zero.ko] undefined!*
LD [M] /opt/lx/kernel/kernel_test/zero.ko
make: Leaving directory `/usr/src/kernels/2.6.18-308.el5-x86_64'
#########################################
I try to find the file which defined the "phys_base", for examples;
phys_baseDefined as a variable in:
- arch/sparc/mm/init.c, line
40<http://lxr.oss.org.cn/source/arch/sparc/mm/init.c?v=2.6.8#L40>
- arch/sparc64/kernel/sparc64_ksyms.c, line
110<http://lxr.oss.org.cn/source/arch/sparc64/kernel/sparc64_ksyms.c?v=2.6.8#L110>
- arch/sparc64/mm/init.c, line
47<http://lxr.oss.org.cn/source/arch/sparc64/mm/init.c?v=2.6.8#L47>
- include/asm-sparc/page.h, line
160<http://lxr.oss.org.cn/source/include/asm-sparc/page.h?v=2.6.8#L160>
- include/asm-sparc/pgtable.h, line
122<http://lxr.oss.org.cn/source/include/asm-sparc/pgtable.h?v=2.6.8#L122>
- include/asm-sparc64/pgtable.h, line
227<http://lxr.oss.org.cn/source/include/asm-sparc64/pgtable.h?v=2.6.8#L227>
But I can't find the file of init.c in my computer. Please tell me some
ways to solve it, thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140224/be096350/attachment.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* [kernel]which the file define the variable of "phys_base"?
2014-02-24 14:04 [kernel]which the file define the variable of "phys_base"? lx
@ 2014-02-24 18:33 ` Sunny
[not found] ` <CA+5jrfmAX7GR=TLD3GHqSnyek56mgZQ9uyw2WirJhEr9om7q_Q@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Sunny @ 2014-02-24 18:33 UTC (permalink / raw)
To: kernelnewbies
Hi,
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?
- Sunny
On Feb 24, 2014, at 9:04 AM, lx <lxlenovostar@gmail.com> wrote:
> hi all:
> the codes is:
> #########################################
> #include <linux/module.h> // for printk()
> #include <linux/mm.h> // for struct page
> #include <asm/page.h> // for struct page
> #include <asm/pgtable.h> // for ZERO_PAGE
>
> static int __init init_hello( void )
> {
> int i;
> struct page * zero_page;
> printk( "\n Kello, the first! \n\n" );
> i = 0x100;
> zero_page = ZERO_PAGE(&i);
> printk(" the ZERO address is %p", zero_page);
> return 0;
> }
>
> static void __exit exit_hello( void )
> {
> printk( "\n Goodbye now... \n\n" );
> }
>
> MODULE_LICENSE("GPL");
> module_init(init_hello);
> module_exit(exit_hello);
> #########################################
>
> I complier it. by:
> #########################################
> make -C /lib/modules/`uname -r`/build M=`pwd`
> #########################################
>
> the results is:
> #########################################
> [root at localhost kernel_test]# make -C /lib/modules/`uname -r`/build M=`pwd`
> make: Entering directory `/usr/src/kernels/2.6.18-308.el5-x86_64'
> CC [M] /opt/lx/kernel/kernel_test/zero.o
> Building modules, stage 2.
> MODPOST
> WARNING: "phys_base" [/opt/lx/kernel/kernel_test/zero.ko] undefined!
> LD [M] /opt/lx/kernel/kernel_test/zero.ko
> make: Leaving directory `/usr/src/kernels/2.6.18-308.el5-x86_64'
> #########################################
>
> I try to find the file which defined the "phys_base", for examples;
> phys_base
>
> Defined as a variable in:
> arch/sparc/mm/init.c, line 40
> arch/sparc64/kernel/sparc64_ksyms.c, line 110
> arch/sparc64/mm/init.c, line 47
> include/asm-sparc/page.h, line 160
> include/asm-sparc/pgtable.h, line 122
> include/asm-sparc64/pgtable.h, line 227
>
> But I can't find the file of init.c in my computer. Please tell me some ways to solve it, thank you.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140224/94dc9261/attachment.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* [kernel]which the file define the variable of "phys_base"?
[not found] ` <CA+5jrfmAX7GR=TLD3GHqSnyek56mgZQ9uyw2WirJhEr9om7q_Q@mail.gmail.com>
@ 2014-02-25 12:54 ` Sunny
0 siblings, 0 replies; 3+ messages in thread
From: Sunny @ 2014-02-25 12:54 UTC (permalink / raw)
To: kernelnewbies
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:
__________________________________________________
Program - lx.c
#include <linux/module.h> // for printk()
#include <linux/mm.h> // for struct page
#include <asm/page.h> // for struct page
#include <asm/pgtable.h> // for ZERO_PAGE
static int __init init_hello( void )
{
int i;
struct page * zero_page;
printk(KERN_ALERT "\n Kello, the first! \n\n" );
i = 0x100;
zero_page = ZERO_PAGE(&i);
printk(KERN_ALERT " the ZERO address is %p", zero_page);
return 0;
}
static void __exit exit_hello( void )
{
printk(KERN_ALERT "\n Goodbye now... \n\n" );
}
MODULE_LICENSE("GPL");
module_init(init_hello);
module_exit(exit_hello);
Makefile
obj-m :=lx.o
KDIR= /lib/modules/$(shell uname -r)/build
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -rf $(wildcard *.o *.ko mo* Mo* *.mod.c)
____________________________________________________
Running make gives me(I?m in a Virtual Machine so the page addresses may be messed up):
sunny at ubuntu: make
make -C /lib/modules/3.11.0-12-generic/build SUBDIRS=/home/sunny/Documents/ modules
make[1]: Entering directory `/usr/src/linux-headers-3.11.0-12-generic'
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/usr/src/linux-headers-3.11.0-12-generic'
sunny at ubuntu: sudo insmod lx.ko
sunny at ubuntu: sudo rmmod lx
sunny at ubuntu: sudo dmesg | tail -6
[48391.359434] Kello, the first!
[48391.359434]
[48320.368773] the ZERO address is ffffea0000079b40
[48391.359439] the ZERO address is ffffea0000079b40<1>[48411.409906]
[48411.409906] Goodbye now...
[48411.409906]
Hope this helps! Don?t forget to ?reply all? so that others in the mailing list could also see your/my problem/solution.
- Sunny
On Feb 24, 2014, at 7:32 PM, lx <lxlenovostar@gmail.com> wrote:
> hi :
> If i command the "insmod zero.ko"; the wrong messages is:
> ##############
> insmod: error inserting 'zero.ko': -1 Unknown symbol in module
> ##############
>
>
> 2014-02-25 2:33 GMT+08:00 Sunny <sundarcs@gwu.edu>:
> Hi,
>
> 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?
>
> - Sunny
>
> On Feb 24, 2014, at 9:04 AM, lx <lxlenovostar@gmail.com> wrote:
>
>> hi all:
>> the codes is:
>> #########################################
>> #include <linux/module.h> // for printk()
>> #include <linux/mm.h> // for struct page
>> #include <asm/page.h> // for struct page
>> #include <asm/pgtable.h> // for ZERO_PAGE
>>
>> static int __init init_hello( void )
>> {
>> int i;
>> struct page * zero_page;
>> printk( "\n Kello, the first! \n\n" );
>> i = 0x100;
>> zero_page = ZERO_PAGE(&i);
>> printk(" the ZERO address is %p", zero_page);
>> return 0;
>> }
>>
>> static void __exit exit_hello( void )
>> {
>> printk( "\n Goodbye now... \n\n" );
>> }
>>
>> MODULE_LICENSE("GPL");
>> module_init(init_hello);
>> module_exit(exit_hello);
>> #########################################
>>
>> I complier it. by:
>> #########################################
>> make -C /lib/modules/`uname -r`/build M=`pwd`
>> #########################################
>>
>> the results is:
>> #########################################
>> [root at localhost kernel_test]# make -C /lib/modules/`uname -r`/build M=`pwd`
>> make: Entering directory `/usr/src/kernels/2.6.18-308.el5-x86_64'
>> CC [M] /opt/lx/kernel/kernel_test/zero.o
>> Building modules, stage 2.
>> MODPOST
>> WARNING: "phys_base" [/opt/lx/kernel/kernel_test/zero.ko] undefined!
>> LD [M] /opt/lx/kernel/kernel_test/zero.ko
>> make: Leaving directory `/usr/src/kernels/2.6.18-308.el5-x86_64'
>> #########################################
>>
>> I try to find the file which defined the "phys_base", for examples;
>> phys_base
>>
>> Defined as a variable in:
>> arch/sparc/mm/init.c, line 40
>> arch/sparc64/kernel/sparc64_ksyms.c, line 110
>> arch/sparc64/mm/init.c, line 47
>> include/asm-sparc/page.h, line 160
>> include/asm-sparc/pgtable.h, line 122
>> include/asm-sparc64/pgtable.h, line 227
>>
>> But I can't find the file of init.c in my computer. Please tell me some ways to solve it, thank you.
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140225/e61aea3f/attachment-0001.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-25 12:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-24 14:04 [kernel]which the file define the variable of "phys_base"? lx
2014-02-24 18:33 ` Sunny
[not found] ` <CA+5jrfmAX7GR=TLD3GHqSnyek56mgZQ9uyw2WirJhEr9om7q_Q@mail.gmail.com>
2014-02-25 12:54 ` Sunny
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.