arm linux 系统调用实现

vmlinz posted @ Thu, 19 May 2011 18:17:35 +0800 in Linux with tags ARM linux , 5893 readers

arm linux 系统调用实现

In this article we will dive into system call interface implementation in arm linux(with gnu eabi).我们将从bionic中的open函数开始追溯arm linux的系统调用实现(使用gnu eabi)。

Linux的应用程序要想访问内核必须使用系统调用从而实现从usr模式转到svc模式。在arm中,这个过程是通过swi(或者和它等价的指令)来实现模式转换的。

从bionic libc中的open函数追溯系统调用实现

相关文件:

  • bionic/libc/unistd/open.c

  • bionic/libc/arch-arm/syscalls/__open.S

  • linux/arch/arm/kernel/entry-common.S

  • linux/arch/arm/kernel/entry-armv.S

  • linux/arch/arm/kernel/entry-header.S

相关调用过程:

  • int open(const char *pathname, int flags, ...); bionic/libc/unistd/open.c

  • __open bionic/libc/arch-arm/syscalls/__open.S

    __open:

    .save {r4, r7}

    stmfd sp!, {r4, r7}

    ldr r7, =__NR_open

    swi #0

    ldmfd sp!, {r4, r7}

    movs r0, r0

    bxpl lr

    b __set_syscall_errno

  • vector_swi linux/arch/arm/kernel/entry-common.S

    adr tbl, sys_call_table @ load syscall table pointer

    cmp scno, #NR_syscalls @ check upper syscall limit

    adr lr, BSYM(ret_fast_syscall) @ return address

    ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine

  • sys_call_table 系统调用跳转表,里面保存了各个系统调用实现的地址。

    .type sys_call_table, #object

    ENTRY(sys_call_table)

    #include "calls.S"

资源和链接

TODOS

  • 找出eabi中寄存器使用和参数传递的规则
  • 了解swi跳转的更多详细知识,比如如何跳转到一个固定位置的
  • arm系统的中断系统
  • 熟悉常用的arm指令和gnu 汇编器指令
Avatar_small
unifoxz said:
Tue, 27 Sep 2011 22:17:29 +0800

请问 bionic/libc/arch-arm/syscalls/__open.S 中的 .save {r4, r7} 和 stmfd sp!, {r4, r7} 有什么区别?
另外,为什么 r4 在系统调用中也被收存?
谢谢!

Avatar_small
grademiners.com said:
Tue, 14 May 2019 16:30:46 +0800

Here we will dive into system call interface implementation in arm linux (with gnu eabi). We will trace the arm linux system call implementation (using gnu eabi) from the open function in bionic. You can try grademiners.com in the school. Linux applications that want to access the kernel must use system calls to move from usr mode to svc mode.

Avatar_small
vijaytimesepaper.com said:
Mon, 20 May 2019 14:24:49 +0800

Linux apps that need to gain access to the kernel must utilize system calls to move from user mode to svc mode. In arm, this procedure is applied by swim (or equivalent to its instructions). Have you browsed at vijaytimesepaper.com? Users can get to more about it by visiting this site or try it on some other site.

Avatar_small
AAA said:
Tue, 22 Feb 2022 04:26:56 +0800

i like the role of Anthony Hopkins in the movie Silence of The Lambs. this guy is simply amazing., How to Become a Credit Card Processor

 

======================================================

 

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. ISO merchant services

 

======================================================

 

I love blogging and i can say that you also love blogging . how to start a payment processing company


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter