Problem on assigning register for Current pointer

Submitted by beparas
on May 15, 2009 - 2:15am

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
#include

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
#include

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

register

strcmp
on
May 15, 2009 - 1:19pm

you have to enclose C code in <pre>-tags, your #include statements are mangled. at least proofread what you post and learn html.

read http://en.wikipedia.org/wiki/Processor_register

line 35 is: register struct task_struct *current asm ("r2");

obviously the compiler thinks there is no register 'r2'. are you using the right compiler? is paras a ppc machine or are you cross-compiling?

Problem is solve

beparas
on
May 17, 2009 - 10:11pm

Thank you very much for your support.

The problem is solve by some modification in Makefile

ARCH ?= powerpc
CROSS_COMPILE ?= powerpc-e300c3-linux-gnu-

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.