微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > Arm Linux系统调用流程详细解析

Arm Linux系统调用流程详细解析

时间:11-09 来源:互联网 点击:

r space always put syscall number into scno (r7).*/A710( ldr ip, [lr, #-4] @ get SWI instruction )A710( and ip, ip, #0x0f @ check for SWI )A710( teq ip, #0x0f )A710( bne .Larm710bug )#elif defined(CONFIG_ARM_THUMB)/* Legacy ABI only, possibly thumb mode. */tst r8, #PSR_T_BIT @ this is SPSR from save_user_regsaddne scno, r7, #__NR_SYSCALL_BASE @ put OS number inldreq scno, [lr, #-4]#else/* Legacy ABI only. */ldr scno, [lr, #-4] @ get SWI instructionA710( and ip, scno, #0x0f @ check for SWI )A710( teq ip, #0x0f )A710( bne .Larm710bug )#endif#ifdef CONFIG_ALIGNMENT_TRAPldr ip, __cr_alignmentldr ip, [ip]mcr p15, 0, ip, c1, c0 @ update control register#endifenable_irq

 //tsk 是寄存器r9的别名,在arch/arm/kernel/entry-header.S中定义:// tsk .req r9 @current thread_info

// 获得线程对象的基地址。

get_thread_info tsk

// tbl是r8寄存器的别名,在arch/arm/kernel/entry-header.S中定义:

// tbl .req r8 @syscall table pointer,

// 用来存放系统调用表的指针,系统调用表在后面调用

adr    tbl, sys_call_table        @ load syscall table pointer#if defined(CONFIG_OABI_COMPAT)/** If the swi argument is zero, this is an EABI call and we do nothing.** If this is an old ABI call, get the syscall number into scno and* get the old ABI syscall table address.*/bics    r10, r10, #0xffeorne    scno, r10, #__NR_OABI_SYSCALL_BASEldrne    tbl, =sys_oabi_call_table#elif !defined(CONFIG_AEABI)  // scno是寄存器r7的别名bic    scno, scno, #0xff        @ mask off SWI op-codeeor    scno, scno, #__NR_SYSCALL_BASE    @ check OS number#endifldr    r10, [tsk, #TI_FLAGS]        @ check for syscall tracingstmdb    sp!, {r4, r5}            @ push fifth and sixth args#ifdef CONFIG_SECCOMPtst    r10, #_TIF_SECCOMPbeq    1fmov    r0, scnobl    __secure_computing    add    r0, sp, #S_R0 + S_OFF        @ pointer to regsldmia    r0, {r0 - r3}            @ have to reload r0 - r31:#endiftst    r10, #_TIF_SYSCALL_TRACE        @ are we tracing syscalls?bne    __sys_tracecmp    scno, #NR_syscalls        @ check upper syscall limitadr    lr, BSYM(ret_fast_syscall)    @ return addressldrcc    pc, [tbl, scno, lsl #2]        @ call sys_* routineadd    r1, sp, #S_OFF

// why也是r8寄存器的别名

2: mov why, #0@ no longer a real syscall

cmp    scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE)eor    r0, scno, #__NR_SYSCALL_BASE    @ put OS number backbcs    arm_syscall    b    sys_ni_syscall            @ not private funcENDPROC(vector_swi)/** This is the really slow path.  Were going to be doing* context switches, and waiting for our parent to respond.*/__sys_trace:mov    r2, scnoadd    r1, sp, #S_OFFmov    r0, #0                @ trace entry [IP = 0]bl    syscall_traceadr    lr, BSYM(__sys_trace_return)    @ return addressmov    scno, r0            @ syscall number (possibly new)add    r1, sp, #S_R0 + S_OFF        @ pointer to regscmp    scno, #NR_syscalls        @ check upper syscall limitldmccia    r1, {r0 - r3}            @ have to reload r0 - r3ldrcc    pc, [tbl, scno, lsl #2]        @ call sys_* routineb    2b__sys_trace_return:str    r0, [sp, #S_R0 + S_OFF]!    @ save returned r0mov    r2, scnomov    r1, spmov    r0, #1                @ trace exit [IP = 1]bl    syscall_traceb    ret_slow_syscall.align    5#ifdef CONFIG_ALIGNMENT_TRAP.type    __cr_alignment, #object__cr_alignment:.word    cr_alignment#endif.ltorg/** This is the syscall table declaration for native ABI syscalls.* With EABI a couple syscalls are obsolete and define

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top