Hi all,
I am working on MPC8313erdb board, PowerPC, having linux-2.6.23.
I wrote simple hello_world module. At the time of compilation kernel generate error: "include/asm/current.h:35: error: invalid register name for ‘current’"
I can't understand the manning of this.
Code of hello_world module is given below
--------------- hello_world.c -------------------------------------------
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
MODULE_LICENSE("GPL");
------------------------------END -------------------------------------
--------------------------- Makefile -----------------------------------
obj-m += hello.o
all:
make -C /usr/local/mpc8313/linux-2.6.23 M=$(PWD) modules
clean:
make -C /usr/local/mpc8313/linux-2.6.23 M=$(PWD) clean
------------------------------------------------------------------------
---------------------------- Error Log --------------------------------
[root@paras hello_world]# make
make -C /usr/local/mpc8313/linux-2.6.23 M=/opt/test/module/hello_world modules
make[1]: Entering directory `/usr/local/mpc8313/linux-2.6.23'
CC [M] /opt/test/module/hello_world/hello.o
In file included from include/linux/capability.h:48,
from include/linux/sched.h:50,
from include/asm/elf.h:6,
from include/linux/elf.h:8,
from include/linux/module.h:15,
from /opt/test/module/hello_world/hello.c:5:
include/asm/current.h:35: error: invalid register name for ‘current’
make[2]: *** [/opt/test/module/hello_world/hello.o] Error 1
make[1]: *** [_module_/opt/test/module/hello_world] Error 2
make[1]: Leaving directory `/usr/local/mpc8313/linux-2.6.23'
make: *** [all] Error 2
-------------------------- END ----------------------------------------
------------------------ Current.h ------------------------------------
#ifndef _ASM_POWERPC_CURRENT_H
#define _ASM_POWERPC_CURRENT_H
#ifdef __KERNEL__
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
struct task_struct;
#ifdef __powerpc64__
#include <linux/stddef.h>
#include <asm/paca.h>
static inline struct task_struct *get_current(void)
{
struct task_struct *task;
__asm__ __volatile__("ld %0,%1(13)"
: "=r" (task)
: "i" (offsetof(struct paca_struct, __current)));
return task;
}
#define current get_current()
#else
/*
* We keep `current' in r2 for speed.
*/
register struct task_struct *current asm ("r2");
#endif
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_CURRENT_H */
--------------------------------- END --------------------------------
Thanks in advance