[Country EMBED strategy] [109] [Linux system calls]

Source: Internet
Author: User

System calls

The function implementation body in kernel space, provided to the application to use, is a system call.

Work flow

1. Switch from user space to kernel space via soft interrupt (Swi). Entry-common. The entry (VECTOR_SWI) in S is used to handle soft interrupts. System calls typically remove the system call number from the R7 register.

2. Find the calling system call function from the system call table by the system call number. is also a calls. s file to find the function that corresponds to the system call number.

Implementing system Calls

1. Open .../kernel/printk.c, add system call function

void Sys_iprint () {

PRINTK ("This is a new system call!\n");

}

2. Open .../arch/arm/kernel/calls. S, add system call entry

Call (Sys_iprint)

3. Open .../arch/arm/include/asm/unistd.h, conditional system call number

#define __NR_IPRINT (__nr_syscall_base+365)

4. Recompile the kernel

Make clean

Make Uimage arch=arm cross_compile=arm-liunx-

5. Writing the application

//System Call Interfacevoidipirnt () {__asm__ ("Ldr R7, =365\n"        "swi\n"        :        :        :"Memory"    );}intMainintargcChar**argv)        {ipirnt (); return 0;}

6. Compiling the application

Arc-linux-gcc–static Syscall.c–o Syscall

[Country EMBED strategy] [109] [Linux system calls]

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.