Solved

Adding syscall to embedded Linux

Posted on 2014-01-27
7
309 Views
Last Modified: 2014-02-15
I'm trying to a new system call to my embedded system, but for some reason I cannot get it to compile.  The new <sys/my_time.h> is always not found.

Essentially I am trying to create a function that will pass back the number of jiffies from the kernel.  I have looked at several post on google, but they do not help to resolve the compilation issue I am having.

My system:
Linux 2.4-8 using uCLibc-0.9.8.

This system is quite particular, so it may be difficult to provide much assistance.  But I have already performed the following steps.  If there is anything that I am missing, please let me know.

1. Added "sys_my_time" to "call.S" (hosting the syscall table).
2. Added "__NR_my_time 257" to unistd.h.
3. Added function implementation to sys.c. (where "times()" has been implemented)
4. Added "my_time.h" file to uclibc/include/sys" directory. (same as "times.h").
5. Added "my_time.c" file to uclibc/libc/sysdeps/linux/common" directory. (same as "times.c")

Thank you.
0
Comment
Question by:sctccomm
7 Comments
 
LVL 32

Expert Comment

by:sarabande
ID: 39817085
2. Added "__NR_my_time 257" to unistd.h
generally it is a bad idea to changing system headers. for the the unistd.h it is worse cause the header was include by all library functions of all system and subsystem libraries your compiler provides. you would need to rebuild all these libraries to make sure that your new code could work.

also changes to sys.c  would require to rebuild the system libraries and rebuild the kernel. any update of the system in future would spoil all your work.

Sara
0
 
LVL 86

Expert Comment

by:jkr
ID: 39819844
Apart from different opinions, I'd like to assure you that altering kernel sources for your purpose is absolutely on point (wth the described impact, though), that's what they're meant for, sice you are building your very own kernel. What are the problems you are running into?
0
 

Author Comment

by:sctccomm
ID: 39822047
I have a file that is going to use my new system call, my_time().

But when I include the header file, "#include <sys/my_time.h>", I always get a compilation error saying that my_time.h is not found.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 12

Expert Comment

by:stefan73
ID: 39847263
Hmm, this could also be a permission issue. Did you check these?
0
 
LVL 32

Expert Comment

by:sarabande
ID: 39848150
when I include the header file, "#include <sys/my_time.h>", I always get a compilation error
if the compiler says file not found, it is true.  you may look for the following reasons:

- the 'sys' folder is not available at all

try to include <sys/time.h> instead of <sys/my_time.h>. if the time.h was not found either, the compiler does not have access to its own include folders. check the environment variable 'include'. probably you have to reinstall the compiler such that the system headers could be found.

- you have duplicate include folders

if the time.h was found, but not my_time.h, the sys folder was duplicated somehow and the compiler currently accesses the wrong one. you may search your disks and check environment variables 'include' and 'lib' for wrong paths.

Sara
0
 

Accepted Solution

by:
sctccomm earned 0 total points
ID: 39848193
There is not permission issue.

Also, <sys/times.h>, was included originally and so it does recognize the 'sys' directory.

I have discovered that the my <sys/my_times.h> will most likely never get recognized because it is not a standard file that exists in libc.  Thus, in the file in which I would like <sys/my_times.h> to be included get compiled, <sys/my_times.h> will not get recognized.

The only way for this to work would be to call the syscall() directly using the syscall_table ID.
0
 

Author Closing Comment

by:sctccomm
ID: 39861154
There is no good solution for this issue.  Only to force the system call.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now