Add a system call instance in Linux

Source: Internet
Author: User

 

1. objective to create and use a new system call on ARM-Linux 2. experiment content and principles (required) 1. Modify system call related files, compile the kernel 2, write the Test Program 3, download the file to the target machine for testing 3. Main Instrument and Equipment microcomputer (host machine) S3C2440 target board (target machine) iv. Operation Method and experiment step 1. Modify the file related to system calls. There is a general portal for system calls in arm-Linux. Then, the operands of SWI commands are treated as the specific system call numbers, find the corresponding function. To add a new system call, you must add it to the original system call set. The steps are as follows: (1) create a new file mysyscall. C under the arch/ARM/kernel/directory. The content in mysyscall. C is simple hello World.

(1) add your own system call in arch/ARM/kernel/call. S. The new system call number is 0x900000 + 319.

(2) modify the MAKEFILE file in the arch/ARM/kernel/directory and add mysyscall. O to OBJ-y.

Re-compile the kernel to provide a new mysyscall system call. Download the new kernel to the target machine and overwrite the original kernel. Arm-Linux on the target board supports new system calls.

Make

Make uimage

1. Compile the test program

Write a test program to use the new system call.

Then execute

# GCC test. C-o Test

Generate Test. O test program

1. download the file to the target machine for testing.

Start the Development Board and download test. O to the file system directory of the Development Board through the zmodem protocol.

The result of running the test program on the Board is as follows:

The above program is called directly by using the system through Assembly, rather than using libc, because the test application uses the newly added system call, And libc does not, so it can only be called directly. Next, create a system call with parameters. Create a new mysyscall2.c file under the arch/ARM/kernel/directory.

In ARCH/ARM/kernel/call. s to add your own system calls. The new system call number is 0x900000 + 227. Then, modify the MAKEFILE file in the arch/ARM/kernel/directory and add mysyscall2.o after obj-y.

Rewrite test. C with a new system call, compile and generate the test. o file, download test. O to the target board again, and run test to get the following result.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.