新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > Android arm linux 系統(tǒng)調(diào)用實現(xiàn)

Android arm linux 系統(tǒng)調(diào)用實現(xiàn)

作者: 時間:2016-11-09 來源:網(wǎng)絡(luò) 收藏
In this article we will dive into system call interface implementation in arm linux(with gnu eabi).我們將從bionic中的open函數(shù)開始追溯arm linux的系統(tǒng)調(diào)用實現(xiàn)(使用gnu eabi)。

Linux的應(yīng)用程序要想訪問內(nèi)核必須使用系統(tǒng)調(diào)用從而實現(xiàn)從usr模式轉(zhuǎn)到svc模式。在arm中,這個過程是通過swi(或者和它等價的指令)來實現(xiàn)模式轉(zhuǎn)換的。

本文引用地址:http://butianyuan.cn/article/201611/318011.htm

從bionic libc中的open函數(shù)追溯系統(tǒng)調(diào)用實現(xiàn)

相關(guān)文件:

  • 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

相關(guān)調(diào)用過程:

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

  • __openbionic/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_swilinux/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系統(tǒng)調(diào)用跳轉(zhuǎn)表,里面保存了各個系統(tǒng)調(diào)用實現(xiàn)的地址。

    .type sys_call_table, #object

    ENTRY(sys_call_table)

    #include "calls.S"



評論


技術(shù)專區(qū)

關(guān)閉