首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

分析ARM linux系统调用的实现原理 02

分析ARM linux系统调用的实现原理 02

//执行sys_open函数
  ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
  add r1, sp, #S_OFF
  2: mov why, #0 @ no longer a real syscall
  cmp scno, #armSWI_OFFSET
  eor r0, scno, #OS_NUMBER 《 20 @ put OS number back
  bcs SYMBOL_NAME(arm_syscall)
  b SYMBOL_NAME(sys_ni_syscall) @ not private func
  /*
  * This is the really slow path. We're going to be doing
  * context switches, and waiting for our parent to respond.
  */
  __sys_trace:
  add r1, sp, #S_OFF
  mov r0, #0 @ trace entry [IP = 0]
  bl SYMBOL_NAME(syscall_trace)
  /*
  //2007-07-01 gliethttp [entry-header.S]
  //Like adr, but force SVC mode (if required)
  .macro adrsvc, cond, reg, label
  adrcond reg, label
  .endm
  //对应反汇编:
  //add lr, pc, #16 ; lr = __sys_trace_return
  */
  adrsvc al, lr, __sys_trace_return @ return address
  add r1, sp, #S_R0 + S_OFF @ pointer to regs
  cmp scno, #NR_syscalls @ check upper syscall limit
  ldmccia r1, {r0 - r3} @ have to reload r0 - r3
  ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
  b 2b
  __sys_trace_return:
  str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
  mov r1, sp
  mov r0, #1 @ trace exit [IP = 1]
  bl SYMBOL_NAME(syscall_trace)
  b ret_disable_irq
  .align 5
  #ifdef CONFIG_ALIGNMENT_TRAP
  .type __cr_alignment, #object
  __cr_alignment:
  .word SYMBOL_NAME(cr_alignment)
  #endif
  .type sys_call_table, #object
  ENTRY(sys_call_table)
  #include "calls.S"
返回列表