Hello all,
 
I just joined this list and I look forward to learning a lot of  introductory 
information about linux kernel programming. If my post does not  follow 
proper posting form please inform me of the way things should be done. I  was 
not 
able to locate anything on the website under mailing lists to explain  it. :)
 
A little bit about myself: I am a first year graduate student  taking an 
Operating System class and we are focusing on the linux kernel for our  lab 
assignments. This is a new area for me so I require some extra assistance in  
answering some questions, and fixing some problems :) I do not expect anyone to 
 do 
my work for me.
 
I am using Fedora Core 6 with the kernel version of 2.6.22 on an  i386 
machine.
I am to implement a simple system call that will use printk to  display some 
text (the time, in nanoseconds) to the screen.
Here are the steps that I am performing in order to implement this  system 
call:
 
1.) I went into  /linux/arch/i386/kernel/syscall_table.S and I  added an 
entry at the very end with the value of: ".long sys_my_xtime"
2.) I  went into /linux/include/asm-i386/unistd.h and I added #define 
__NR_my_xtime 324  after 323.
3.) I incremented #define NR_syscalls 324 to #define NR_syscalls  325
4.) I went into /linux/include/linux/syscalls.h and added asmlinkage long  
sys_my_xtime(struct timespec __user *current_time)
5.) I then placed the  following function into /linux/kernel/time.c:
asmlinkage long  sys_my_xtime(struct timespec __user *current_time)
{
 
  //code here to check writable
 
  //TEST! display to console - send the worst type so it  is easier
printfk(KERN_EMERG "This is a test\n");  

return 0;
}
6.) I then go to the  shell and type the following commands:
make bzImage
make  modules_install [I do not do make modules anymore since I've already 
made  them]
make install
7.) I reboot.
8.) I select my kernel to boot  up.
9.) I wrote my test program, with the macro:
 
#define __NR_my_xtime  324 
#define  _syscall1(type,name,type1,arg1) \
long my_xtime(struct timespec *  current_time) \
{ \
long __res; \
__asm__ volatile  ("int $0x80" \
: "=a"  (__res) \
: "0"  (__NR_my_xtime),"b" ((long)(current_time))); \
if (__res >= 0)  \
return (type) __res;  \
errno = -__res; \
return -1; \
}
 
Then in my main function:
_syscall1(long, my_xtime, struct  timespec *, mytimespec); 
 
When I run my program, I do not receive any messages and it does not appear  
to work. I also cannot use the macro I have defined in such a way to return a  
value, as it gives compile errors. I have also tried to set __res to a global 
 value in my user program, to see if the macro is working properly. That does 
not  work. Additionally, I can put the incorrect function name in the marco 
call and  it will compile and 'run just fine'.
 
I'm not sure what I am missing here, I used the guide 
 _http://tldp.org/HOWTO/html_single/Implement-Sys-Call-Linux-2.6-i386/#AEN89_ 
(http://tldp.org/HOWTO/html_single/Implement-Sys-Call-Linux-2.6-i386/#AEN89) 
and that does not work either (I get compile errors for the header file and  
thus cannot complete it). It says you can place the new function anywhere, so  
the steps are the same for placing the information for the new call.
 
I am doing this on another machine so let me know if you need any more  
information regarding this (as I suspect you will).
 
Thanks
 





************************************** See what's new at http://www.aol.com

Reply via email to