LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-15-2009, 04:12 AM   #1
beparas
Member
 
Registered: Nov 2006
Location: Pune
Posts: 48

Rep: Reputation: 0
Question Problem on assigning register for Current pointer


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

Last edited by beparas; 05-15-2009 at 04:17 AM.
 
Old 05-18-2009, 12:14 AM   #2
beparas
Member
 
Registered: Nov 2006
Location: Pune
Posts: 48

Original Poster
Rep: Reputation: 0
Smile problem is solve

The problem is solve by some modification in Makefile

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
x86_64 stack pointer and offset register fardad Programming 2 11-21-2008 04:28 PM
why it can access current pointer in timer func? linwenyuan Linux - Kernel 0 02-19-2008 04:58 AM
Assigning Static IP Problem canuck_barlow Linux - Newbie 5 01-06-2006 02:54 PM
assigning memory address to pointer irfanhab Programming 4 04-24-2004 03:35 AM
Assigning a string to a variable (not a pointer, not a array) JStew Programming 3 11-18-2002 08:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration