[Linux kernel] Arm-linux system Call

Source: Internet
Author: User

1, the concept of system invocation:

Is the only means of user space access to the kernel, system calls rely on software interrupt implementation, each system call is given a system call number to indicate which system call to execute.


2, the implementation of the system call:
The system call is implemented through the soft mid-end (SWI),
SWI directive
The format of the SWI directive is:
swi{condition} 24-bit immediate number
The SWI directive is used to generate software interrupts so that the user program can invoke the system routines of the operating system. The operating system provides the appropriate system service in the exception handler for the SWI, the 24-bit immediate number in the instruction specifies the type of the user program to invoke the system routine, the correlation parameter is passed through the general register, and when the 24-bit immediate number in the instruction is ignored, the type of the user program call system routine is determined by the contents of the , the parameters are passed through other general registers.
instruction Example:
SWI 0x02; This directive invokes the system routine of the operating system number bit 02
The way Linux 2.6.16 is used later:
The 24-bit immediate number in the instruction is ignored, the service type requested by the user is determined by the value of the register R7, and the parameters are passed through the other general registers. For example:
MOV R7, #12
SWI 0


Each system call has a unique system call function number Alps\kernel\arch\arm\include\asm\unistd.h
System call list, when the system call is executed, the kernel indexes the system invocation list according to the system call number, finds the entry function and runs it. The corresponding file is Alps\kernel\arch\arm\kernel \entry-common. S
and Alps\kernel\arch\arm\kernel\calls. S
Interface design related macro alps\kernel\include\linux\syscalls.h
Search the arm Linux system for a specific implementation of a function's system call in the kernel ~ General search Sys_name or Syscall_definen (name_ ...


Implementation of Bionic C library system call on 3,android
Process: \bionic\libc\syscalls. TXT----"\bionic\libc\tools\gensyscalls.py-----" \bionic\libc\tools\arch-arm\syscall\*.s----"SWI soft mid-end


4, how to add system calls
(1) \bionic\libc\syscalls. Add an interface in TXT syscall_for_test arm_syscall_for_test
(2) Running bionic\libc\tools\gensyscalls.py:
(3) Adding kernel\arch\arm\kernel\sys_syscall_for_test.c files, adding syscall_for_test processing:
(4) Kernel\arch\arm\kernel\calls. Add Syscall_for_test in S
(5) Modify Kernel\arch\arm\kernel\makefile
(6) Add the processing of arm_syscall_for_test in the Arm_syscall of kernel\arch\arm\kernel\ TRAPS.C:
(7) Add bionic\libc\include\syscall_for_test.h file

[Linux kernel] Arm-linux system Call

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.