旧式x86平台上的系统调用由int 0x80中断实现,后来对于新式CPU,Linux使用了
sysenter方式。
在ARM平台上,使用了swi中断来实现系统调用的跳转。
swi指令用于产生软件中断,从而实现从用户模式变换到管理模式,CPSR(Current Program Status Register,程序状态寄存器,包含了条件标志位、中断禁止位、当前处理器模式标志以及其他的一些控制和状态位)保存到管理模式的SPSR(Saved Program Status Register,程序状态保存寄存器,用于保存CPSR的状态,以便异常返回后恢复异常发生时的工作状态),执行转移到SWI向量,在其他模式下也可使用SWI指令,处理器同样地切换到管理模式。
指令格式如下:
SWI {cond} immed_24
其中:
immed_24 24位立即数,值为从0——16777215之间的整数。
使用SWI指令时,通常使用一下两种方法进行参数传递,SWI异常处理程序可以提供相关的服务,这两种方法均是用户软件协定。SWI异常中断处理程序要通过读取引起软件中断的SWI指令,以取得24为立即数。
1)指令中24位的立即数指定了用户请求的服务类型,参数通过通用寄存器传递。如:
MOV R0,#34
SWI 12
2)指令中的24位立即数被忽略,用户请求的服务类型有寄存器R0的只决定,参数通过其他的通用寄存器传递。如:
MOV R0, #12
MOV R1, #34
SWI 0
在SWI异常处理程序中,去除SWI立即数的步骤为:首先确定一起软中断的SWI指令时ARM指令还是Thumb指令,这可通过对SPSR访问得到;然后取得该SWI指令的地址,这可通过访问LR寄存器得到;接着读出指令,分解出立即数(低24位)。
在arch/arm/include/asm 目录下unistd.h文件中,在Linux内核中,每个系统调用都具有唯一的一个系统调用功能号,这些功能号的定义就在此文件中,在这文件可以看到很多类似这样的定义:
#define __NR_write (__NR_SYSCALL_BASE+ 4)
这是系统调用write的定义,功能号是__NR_SYSCALL_BASE +4,定义为符号__NR_write。
由于采用了不同的二进制接口,所以 __NR_SYSCALL_BASE +4的定义会有所不同,在文件中可以找到定义:
注意那个EABI, EABI是什么东西呢?ABI,Application Binary Interface,应用二进制接口。在较新的EABI规范中,是将系统调用号压入寄存器r7中,而在老的OABI中则是执行的swi 中断号的方式,也就是说原来的调用方式(Old ABI)是通过跟随在swi指令中的调用号来进行的。
这里主要是对调用号的索取定义了不同的方式。
而这些系统调用号所对应的系统调用列表,定义在arch/arm/kernel目录下的calls.S。
在源码中,我们可以找到诸如sys_write的函数声明:
asmlinkage long sys_write (unsigned int fd, const char __user *buf,size_t count);
asmlinkage是gcc标签,表明函数读取传递而来的参数位于栈中,具体的作用可以参考链接: http://blog.chinaunix.net/uid-20585891-id-1919646.html
但具体的实现代码则用宏来定义。
Linux已经为每一个系统调用都设定了唯一的一个系统调用功能号,当执行系统调用时,会按照系统调用号来索引系统调用,用的是几个带参数的宏来实现,位于syscalls.h文件中,可以看到:
这里DEFINEn表示的是参数的个数,有参数的系统调用最终都是指向这么一个宏:
翻看__SYSCALL_DEFINEx的定义:
翻查代码,可以找到:
展开此宏,便可以得到“
asmlinkage long sys_write (unsigned int fd, const char __user *buf,size_t count);”的声明形式。
PS:~~不明白为何要使用这样的形式来说明定义,不明意图郁闷ing~~
PS:__SC_DECLX的宏定义如下(/include/linux/syscalls.h),__VA_ARGS__是个可变参数宏:
那么系统是如何找到该函数的。
前面提交到系统调用号,这是一个偏移量,来匹配系统调用表的各项入口,在calls.S文件中有对各项入口的声明,而对于系统调用表的定义,在文件arch/arm/kernel/entry-armv.S中。
还有
sys_call_table 在内核中是个跳转表,这个表中存储的是一系列的函数指针,这些指针就是系统调用函数的指针,如(sys_open)。内核是根据一个系统调用号(对于EABI来说为系统调用表的索引)找到实际该调用内核哪个函数,然后通过运行该函数完成系统调用的。
对于old ABI,内核给出的处理是为它建立一个单独的system call table,叫sys_oabi_call_table。这样,兼容方式下就会有两个system call table, 以old ABI方式的系统调用会执行old_syscall_table表中的系统调用函数,EABI方式的系统调用会用sys_call_table中的函数指针。
配置无外乎以下4中:
第一、两个宏都配置行为就是上面说的那样。
第二、只配置CONFIG_OABI_COMPAT,那么以oldABI方式调用的会用sys_oabi_call_table,以EABI方式调用的用sys_call_table,和1实质上是相同的。只是情况1更加明确。
第三、只配置CONFIG_AEABI系统中不存在sys_oabi_call_table,对old ABI方式调用不兼容。只能 以EABI方式调用,用sys_call_table。
第四、两个都没有配置,系统默认会只允许old ABI方式,但是不存在old_syscall_table,最终会通过sys_call_table 完成函数调用。
paging_init函数中调用传递的参数是:early_trap_init((void *)CONFIG_VECTORS_BASE);
early_trap_init主要完成将中断向量表(__vectors_start, __vectors_end)和中断入口函数表(__stubs_start, __stubs_end)的相关代码copy到内存0xffff0000或者0x00000000处。
这个函数把定义在 arch/arm/kernel/entry-armv.S 中的异常向量表和异常处理程序的 stub 进行
重定位:异常向量表拷贝到 0xFFFF_0000,异常向量处理程序的 stub 拷贝到 0xFFFF_0200。
然后调用 modify_domain()修改了异常向量表所占据的页面的访问权限,这使得用户态无法
访问该页,只有核心态才可以访问。
异常向量表,在文件arch/arm/kernel/entry-armv.S 中 :
填充后,向量表如下:
虚拟地址 异常 处理代码
0xffff0000 reset swi SYS_ERROR0
0xffff0004 undefined b __real_stubs_start + (vector_undefinstr - __stubs_start)
0xffff0008 软件中断 ldr pc, __real_stubs_start + (.LCvswi - __stubs_start)
0xffff000c 取指令异常 b __real_stubs_start + (vector_prefetch - __stubs_start)
0xffff0010 数据异常 b __real_stubs_start + (vector_data - __stubs_start)
0xffff0014 reserved b __real_stubs_start + (vector_addrexcptn - __stubs_start)
0xffff0018 irq b __real_stubs_start + (vector_IRQ - __stubs_start)
0xffff001c fiq b __real_stubs_start + (vector_FIQ - __stubs_start)
发生软中断swi时,会跳到.LCvswi + stubs_offset处执行, LCvswi定义如下:
最终会执行例程vector_swi来完成对系统调用的处理,翻看/arch/arm/kernel/entry-common.S下vector_swi的定义。
在ARM平台上,使用了swi中断来实现系统调用的跳转。
swi指令用于产生软件中断,从而实现从用户模式变换到管理模式,CPSR(Current Program Status Register,程序状态寄存器,包含了条件标志位、中断禁止位、当前处理器模式标志以及其他的一些控制和状态位)保存到管理模式的SPSR(Saved Program Status Register,程序状态保存寄存器,用于保存CPSR的状态,以便异常返回后恢复异常发生时的工作状态),执行转移到SWI向量,在其他模式下也可使用SWI指令,处理器同样地切换到管理模式。
指令格式如下:
SWI {cond} immed_24
其中:
immed_24 24位立即数,值为从0——16777215之间的整数。
使用SWI指令时,通常使用一下两种方法进行参数传递,SWI异常处理程序可以提供相关的服务,这两种方法均是用户软件协定。SWI异常中断处理程序要通过读取引起软件中断的SWI指令,以取得24为立即数。
1)指令中24位的立即数指定了用户请求的服务类型,参数通过通用寄存器传递。如:
MOV R0,#34
SWI 12
2)指令中的24位立即数被忽略,用户请求的服务类型有寄存器R0的只决定,参数通过其他的通用寄存器传递。如:
MOV R0, #12
MOV R1, #34
SWI 0
在SWI异常处理程序中,去除SWI立即数的步骤为:首先确定一起软中断的SWI指令时ARM指令还是Thumb指令,这可通过对SPSR访问得到;然后取得该SWI指令的地址,这可通过访问LR寄存器得到;接着读出指令,分解出立即数(低24位)。
在arch/arm/include/asm 目录下unistd.h文件中,在Linux内核中,每个系统调用都具有唯一的一个系统调用功能号,这些功能号的定义就在此文件中,在这文件可以看到很多类似这样的定义:
#define __NR_write (__NR_SYSCALL_BASE+ 4)
这是系统调用write的定义,功能号是__NR_SYSCALL_BASE +4,定义为符号__NR_write。
由于采用了不同的二进制接口,所以 __NR_SYSCALL_BASE +4的定义会有所不同,在文件中可以找到定义:
01 | #ifndef __ASM_ARM_UNISTD_H |
02 | #define __ASM_ARM_UNISTD_H |
03 |
04 | #define __NR_OABI_SYSCALL_BASE 0x900000 |
05 |
06 | #if defined(__thumb__) || defined(__ARM_EABI__) |
07 | #define __NR_SYSCALL_BASE 0 |
08 | #else |
09 | #define __NR_SYSCALL_BASE __NR_OABI_SYSCALL_BASE |
10 | #endif |
这里主要是对调用号的索取定义了不同的方式。
而这些系统调用号所对应的系统调用列表,定义在arch/arm/kernel目录下的calls.S。
01 | /* 0 */ CALL(sys_restart_syscall) |
02 | CALL(sys_exit) |
03 | CALL(sys_fork_wrapper) |
04 | CALL(sys_read) |
05 | CALL(sys_write) |
06 | /* 5 */ CALL(sys_open) |
07 | CALL(sys_close) |
08 | CALL(sys_ni_syscall) /* was sys_waitpid */ |
09 | CALL(sys_creat) |
10 | CALL(sys_link) |
11 | /*………省略……….*/ |
asmlinkage long sys_write (unsigned int fd, const char __user *buf,size_t count);
asmlinkage是gcc标签,表明函数读取传递而来的参数位于栈中,具体的作用可以参考链接: http://blog.chinaunix.net/uid-20585891-id-1919646.html
但具体的实现代码则用宏来定义。
Linux已经为每一个系统调用都设定了唯一的一个系统调用功能号,当执行系统调用时,会按照系统调用号来索引系统调用,用的是几个带参数的宏来实现,位于syscalls.h文件中,可以看到:
1 | #define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void) |
2 | #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__) |
3 | #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) |
4 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__) |
5 | #define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__) |
6 | #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__) |
7 | #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) |
1 | #define SYSCALL_DEFINEx(x, sname, ...) __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) |
1 | #define __SYSCALL_DEFINEx(x, name, ...) \ |
2 | asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)) |
1 | SYSCALL_DEFINE3(write, unsigned int, fd, const char __user *, buf, |
2 | size_t, count) |
PS:~~不明白为何要使用这样的形式来说明定义,不明意图郁闷ing~~
PS:__SC_DECLX的宏定义如下(/include/linux/syscalls.h),__VA_ARGS__是个可变参数宏:
1 | #define __SC_DECL1(t1, a1) t1 a1 |
2 | #define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__) |
3 | #define __SC_DECL3(t3, a3, ...) t3 a3, __SC_DECL2(__VA_ARGS__) |
4 | #define __SC_DECL4(t4, a4, ...) t4 a4, __SC_DECL3(__VA_ARGS__) |
5 | #define __SC_DECL5(t5, a5, ...) t5 a5, __SC_DECL4(__VA_ARGS__) |
6 | #define __SC_DECL6(t6, a6, ...) t6 a6, __SC_DECL5(__VA_ARGS__) |
前面提交到系统调用号,这是一个偏移量,来匹配系统调用表的各项入口,在calls.S文件中有对各项入口的声明,而对于系统调用表的定义,在文件arch/arm/kernel/entry-armv.S中。
01 | /* |
02 | * This is the syscall table declaration for native ABI syscalls. |
03 | * With EABI a couple syscalls are obsolete and defined as sys_ni_syscall. |
04 | */ |
05 | #define ABI(native, compat) native |
06 | #ifdef CONFIG_AEABI |
07 | #define OBSOLETE(syscall) sys_ni_syscall |
08 | #else |
09 | #define OBSOLETE(syscall) syscall |
10 | #endif |
11 |
12 | .type sys_call_table, #object |
13 | ENTRY(sys_call_table) |
14 | #include "calls.S" |
15 | #undef ABI |
16 | #undef OBSOLETE |
01 | /* |
02 | * Let's declare a second syscall table for old ABI binaries |
03 | * using the compatibility syscall entries. |
04 | */ |
05 | #define ABI(native, compat) compat |
06 | #define OBSOLETE(syscall) syscall |
07 |
08 | .type sys_oabi_call_table, #object |
09 | ENTRY(sys_oabi_call_table) |
10 | #include "calls.S" |
11 | #undef ABI |
12 | #undef OBSOLETE |
对于old ABI,内核给出的处理是为它建立一个单独的system call table,叫sys_oabi_call_table。这样,兼容方式下就会有两个system call table, 以old ABI方式的系统调用会执行old_syscall_table表中的系统调用函数,EABI方式的系统调用会用sys_call_table中的函数指针。
配置无外乎以下4中:
第一、两个宏都配置行为就是上面说的那样。
第二、只配置CONFIG_OABI_COMPAT,那么以oldABI方式调用的会用sys_oabi_call_table,以EABI方式调用的用sys_call_table,和1实质上是相同的。只是情况1更加明确。
第三、只配置CONFIG_AEABI系统中不存在sys_oabi_call_table,对old ABI方式调用不兼容。只能 以EABI方式调用,用sys_call_table。
第四、两个都没有配置,系统默认会只允许old ABI方式,但是不存在old_syscall_table,最终会通过sys_call_table 完成函数调用。
系统会根据ABI的不同而将相应的系统调用表的基地址加载进tbl寄存器。
接下来查找的过程。
ARM-Linux内核启动时,通过start_kernel(/init/main.c)->setup_arch(/arch/arm/kernel/setup.c)->paging_init(/arch/arm/mm/nommu.c)->early_trap_init(/arch/arm/kernel/traps.c),初始化中断异常向量表:
01 | void __init early_trap_init(void *vectors_base) |
02 | { |
03 | unsigned long vectors = (unsigned long)vectors_base; |
04 | extern char __stubs_start[], __stubs_end[]; |
05 | extern char __vectors_start[], __vectors_end[]; |
06 | extern char __kuser_helper_start[], __kuser_helper_end[]; |
07 | int kuser_sz = __kuser_helper_end - __kuser_helper_start; |
08 |
09 | vectors_page = vectors_base; |
10 |
11 | /* |
12 | * Copy the vectors, stubs and kuser helpers (in entry-armv.S) |
13 | * into the vector page, mapped at 0xffff0000, and ensure these |
14 | * are visible to the instruction stream. |
15 | */ |
16 | memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start); |
17 | memcpy((void *)vectors + 0x200, __stubs_start, __stubs_end - __stubs_start); |
18 | memcpy((void *)vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz); |
19 |
20 | /* |
21 | * Do processor specific fixups for the kuser helpers |
22 | */ |
23 | kuser_get_tls_init(vectors); |
24 |
25 | /* |
26 | * Copy signal return handlers into the vector page, and |
27 | * set sigreturn to be a pointer to these. |
28 | */ |
29 | memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE), |
30 | sigreturn_codes, sizeof(sigreturn_codes)); |
31 | memcpy((void *)(vectors + KERN_RESTART_CODE - CONFIG_VECTORS_BASE), |
32 | syscall_restart_code, sizeof(syscall_restart_code)); |
33 |
34 | flush_icache_range(vectors, vectors + PAGE_SIZE); |
35 | modify_domain(DOMAIN_USER, DOMAIN_CLIENT); |
36 | } |
early_trap_init主要完成将中断向量表(__vectors_start, __vectors_end)和中断入口函数表(__stubs_start, __stubs_end)的相关代码copy到内存0xffff0000或者0x00000000处。
这个函数把定义在 arch/arm/kernel/entry-armv.S 中的异常向量表和异常处理程序的 stub 进行
重定位:异常向量表拷贝到 0xFFFF_0000,异常向量处理程序的 stub 拷贝到 0xFFFF_0200。
然后调用 modify_domain()修改了异常向量表所占据的页面的访问权限,这使得用户态无法
访问该页,只有核心态才可以访问。
异常向量表,在文件arch/arm/kernel/entry-armv.S 中 :
01 | __vectors_start: |
02 | ARM( swi SYS_ERROR0 ) |
03 | THUMB( svc #0 ) |
04 | THUMB( nop ) |
05 | W(b) vector_und + stubs_offset |
06 | W(ldr) pc, .LCvswi + stubs_offset |
07 | W(b) vector_pabt + stubs_offset |
08 | W(b) vector_dabt + stubs_offset |
09 | W(b) vector_addrexcptn + stubs_offset |
10 | W(b) vector_irq + stubs_offset |
11 | W(b) vector_fiq + stubs_offset |
12 | .globl __vectors_end |
13 | __vectors_end: |
虚拟地址 异常 处理代码
0xffff0000 reset swi SYS_ERROR0
0xffff0004 undefined b __real_stubs_start + (vector_undefinstr - __stubs_start)
0xffff0008 软件中断 ldr pc, __real_stubs_start + (.LCvswi - __stubs_start)
0xffff000c 取指令异常 b __real_stubs_start + (vector_prefetch - __stubs_start)
0xffff0010 数据异常 b __real_stubs_start + (vector_data - __stubs_start)
0xffff0014 reserved b __real_stubs_start + (vector_addrexcptn - __stubs_start)
0xffff0018 irq b __real_stubs_start + (vector_IRQ - __stubs_start)
0xffff001c fiq b __real_stubs_start + (vector_FIQ - __stubs_start)
发生软中断swi时,会跳到.LCvswi + stubs_offset处执行, LCvswi定义如下:
1 | .LCvswi: |
2 | .word vector_swi |
001 | ENTRY(vector_swi) |
002 | sub sp, sp, #S_FRAME_SIZE |
003 | stmia sp, {r0 - r12} @ Calling r0 - r12 |
004 | ARM( add r8, sp, #S_PC ) |
005 | ARM( stmdb r8, {sp, lr}^ ) @ Calling sp, lr |
006 | THUMB( mov r8, sp ) |
007 | THUMB( store_user_sp_lr r8, r10, S_SP ) @ calling sp, lr |
008 | mrs r8, spsr @ called from non-FIQ mode, so ok. |
009 | str lr, [sp, #S_PC] @ Save calling PC |
010 | str r8, [sp, #S_PSR] @ Save CPSR |
011 | str r0, [sp, #S_OLD_R0] @ Save OLD_R0 |
012 | zero_fp |
013 |
014 | /* |
015 | * Get the system call number. |
016 | */ |
017 |
018 | #if defined(CONFIG_OABI_COMPAT) |
019 | /* |
020 | * If we have CONFIG_OABI_COMPAT then we need to look at the swi |
021 | * value to determine if it is an EABI or an old ABI call. |
022 | */ |
023 | #ifdef CONFIG_ARM_THUMB |
024 | tst r8, #PSR_T_BIT |
025 | movne r10, #0 @ no thumb OABI emulation |
026 | ldreq r10, [lr, #-4] @ get SWI instruction |
027 | #else |
028 | ldr r10, [lr, #-4] @ get SWI instruction |
029 | A710( and ip, r10, #0x0f000000 @ check for SWI ) |
030 | A710( teq ip, #0x0f000000 ) |
031 | A710( bne .Larm710bug ) |
032 | #endif //endif "CONFIG_ARM_THUMB<span></span>" |
033 |
034 | #ifdef CONFIG_CPU_ENDIAN_BE8 |
035 | rev r10, r10 @ little endian instruction |
036 | #endif //endif "CONFIG_CPU_ENDIAN_BE8" |
037 |
038 | #elif defined(CONFIG_AEABI) |
039 |
040 | /* |
041 | * Pure EABI user space always put syscall number into scno (r7). |
042 | */ |
043 | A710( ldr ip, [lr, #-4] @ get SWI instruction ) |
044 | A710( and ip, ip, #0x0f000000 @ check for SWI ) |
045 | A710( teq ip, #0x0f000000 ) |
046 | A710( bne .Larm710bug ) |
047 |
048 | #elif defined(CONFIG_ARM_THUMB) |
049 |
050 | /* Legacy ABI only, possibly thumb mode. */ |
051 | tst r8, #PSR_T_BIT @ this is SPSR from save_user_regs |
052 | addne scno, r7, #__NR_SYSCALL_BASE @ put OS number in |
053 | ldreq scno, [lr, #-4] |
054 |
055 | #else |
056 |
057 | /* Legacy ABI only. */ |
058 | ldr scno, [lr, #-4] @ get SWI instruction |
059 | A710( and ip, scno, #0x0f000000 @ check for SWI ) |
060 | A710( teq ip, #0x0f000000 ) |
061 | A710( bne .Larm710bug ) |
062 |
063 | #endif //endif "CONFIG_OABI_COMPAT" |
064 |
065 | #ifdef CONFIG_ALIGNMENT_TRAP |
066 | ldr ip, __cr_alignment |
067 | ldr ip, [ip] |
068 | mcr p15, 0, ip, c1, c0 @ update control register |
069 | #endif |
070 | enable_irq |
071 |
072 | get_thread_info tsk |
073 | //tbl是r8寄存器的别名,在arch/arm/kernel/entry-header.S中定义: |
074 | // tbl .req r8 @syscall table pointer, |
075 | // 用来存放系统调用表的指针,系统调用表在后面调用 |
076 | adr tbl, sys_call_table @ load syscall table pointer |
077 |
078 | #if defined(CONFIG_OABI_COMP<span></span>AT) |
079 | /* |
080 | * If the swi argument is zero, this is an EABI call and we do nothing. |
081 | * |
082 | * If this is an old ABI call, get the syscall number into scno and |
083 | * get the old ABI syscall table address. |
084 | */ |
085 | bics r10, r10, #0xff000000 |
086 | eorne scno, r10, #__NR_OABI_SYSCALL_BASE |
087 | ldrne tbl, =sys_oabi_call_table |
088 | #elif !defined(CONFIG_AEABI) |
089 | // scno是寄存器r7的别名 |
090 | bic scno, scno, #0xff000000 @ mask off SWI op-code |
091 | eor scno, scno, #__NR_SYSCALL_BASE @ check OS number |
092 | #endif |
093 |
094 | ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing |
095 | stmdb sp!, {r4, r5} @ push fifth and sixth args |
096 |
097 | #ifdef CONFIG_SECCOMP |
098 | tst r10, #_TIF_SECCOMP |
099 | beq 1f |
100 | mov r0, scno |
101 | bl __secure_computing |
102 | add r0, sp, #S_R0 + S_OFF @ pointer to regs |
103 | ldmia r0, {r0 - r3} @ have to reload r0 - r3 |
104 | 1: |
105 | #endif |
106 |
107 | tst r10, #_TIF_SYSCALL_WORK @ are we tracing syscalls? |
108 | bne __sys_trace |
109 |
110 | cmp scno, #NR_syscalls @ check upper syscall limit |
111 | adr lr, BSYM(ret_fast_syscall) @ return address |
112 | //转入到实现函数 |
113 | ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine |
114 |
115 | add r1, sp, #S_OFF |
116 | // why是r8寄存器的别名 |
117 | 2: mov why, #0 @ no longer a real syscall |
118 | cmp scno, #(__ARM_NR_BASE - __NR_SYSCALL_BASE) |
119 | eor r0, scno, #__NR_SYSCALL_BASE @ put OS number back |
120 | bcs arm_syscall |
121 | b sys_ni_syscall @ not private func |
122 | ENDPROC(vector_swi) |
然后转入到函数入口,执行系统调用。
参考总结于:http://blog.youkuaiyun.com/xiyangfan/article/details/5701673
http://blog.youkuaiyun.com/hongjiujing/article/details/6831192
http://blog.chinaunix.net/uid-26316047-id-3402198.html
668

被折叠的 条评论
为什么被折叠?



