您的位置:首页 > 编程语言

Mac操作系统XNU内核(九)系统调用过程代码某些细节:系统调用BSD和mach

2015-04-03 15:02 218 查看
众所周知,BSD系统调用号,都是正值;mach系统调用号,都是负值。

在这里判断(汇编代码osfmk/x86_64/idt64.s):

/* Syscall dispatch routines! */

/*
*
* 32bit Tasks
* System call entries via INTR_GATE or sysenter:
*
*    r15     x86_saved_state32_t
*    rsp     kernel stack
*
*    both rsp and r15 are 16-byte aligned
*    interrupts disabled
*    direction flag cleared
*/

Entry(hndl_sysenter)
/*
* We can be here either for a mach syscall or a unix syscall,
* as indicated by the sign of the code:
*/
movl    R32_EAX(%r15),%eax
testl    %eax,%eax
js    EXT(hndl_mach_scall)        /* < 0 => mach */
         /* > 0 => unix */


指令test1判断寄存器EAX的值,如果正,就继续执行到hndl_unix_scall;如果负,就跳到hndl_mach_scall。

说明:上述逻辑仅限于32位时,64位有其他逻辑(在上一篇中)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: