__syscall_start:

。..

.long SYMBOL_NAME(sys_open) //第5个

。..

将sys_call_table[5]中内容传给pc,系统进入sys_open函数,处理实质的open动作

注:用到的一些函数数据所在文件,如下所示

arch/arm/kernel/calls.S声明了系统调用函数

include/asm-arm/unistd.h定义了系统调用的调用号规则

vector_swi定义在arch/arm/kernel/entry-common.S

vector_IRQ定义在arch/arm/kernel/entry-armv.S

vector_FIQ定义在arch/arm/kernel/entry-armv.S

arch/arm/kernel/entry-common.S中对sys_call_table进行了定义:

.type sys_call_table, #object

ENTRY(sys_call_table)

#include “calls.S” //将calls.S中的内容顺序链接到这里

源程序:

ENTRY(vector_swi)

save_user_regs

zero_fp

get_scno //将[lr,#-4]中的中断号转储到scno(r7)

arm710_bug_check scno, ip

#ifdef CONFIG_ALIGNMENT_TRAP

ldr ip, __cr_alignment

ldr ip, [ip]

mcr p15, 0, ip, c1, c0 @ update control register

#endif

enable_irq ip

str r4, [sp, #-S_OFF]! @ push fifth arg

get_current_task tsk

ldr ip, [tsk, #TSK_PTRACE] @ check for syscall tracing

bic scno, scno, #0xff000000 @ mask off SWI op-code

//#define OS_NUMBER 9[entry-header.S]

//所以对于上面示例中open系统调用号scno=0x900005

//eor scno,scno,#0x900000

//之后scno=0x05

eor scno, scno, #OS_NUMBER 《《 20 @ check OS number

//sys_call_table项为calls.S的内容

adr tbl, sys_call_table @ load syscall table pointer

tst ip, #PT_TRACESYS @ are we tracing syscalls?

bne __sys_trace

adrsvc al, lr, ret_fast_syscall @ return address

cmp scno, #NR_syscalls @ check upper syscall limit

//执行sys_open函数

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