当前位置: 技术问答>linux和unix
“标号__kuser_helper_start和__kuser_helper_end之间的代码”是干什么的?
来源: 互联网 发布时间:2016-07-25
本文导语: “标号__kuser_helper_start和__kuser_helper_end之间的代码”是干什么的? 南方大哥 , 请问arch/arm/kernel/entry-armv.S文件中的“标号__kuser_helper_start和__kuser_helper_end之间的代码”是干什么的? 多谢! 代码如下: .align 5 .globl __k...
“标号__kuser_helper_start和__kuser_helper_end之间的代码”是干什么的?
南方大哥 ,
请问arch/arm/kernel/entry-armv.S文件中的“标号__kuser_helper_start和__kuser_helper_end之间的代码”是干什么的?
多谢!
代码如下:
.align 5
.globl __kuser_helper_start
__kuser_helper_start:
/*
* Reference prototype:
*
* int __kernel_cmpxchg(int oldval, int newval, int *ptr)
*
* Input:
*
* r0 = oldval
* r1 = newval
* r2 = ptr
* lr = return address
*
* Output:
*
* r0 = returned value (zero or non-zero)
* C flag = set if r0 == 0, clear if r0 != 0
*
* Clobbered:
*
* r3, ip, flags
*
* Definition and user space usage example:
*
* typedef int (__kernel_cmpxchg_t)(int oldval, int newval, int *ptr);
* #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
*
* Atomically store newval in *ptr if *ptr is equal to oldval for user space.
* Return zero if *ptr was changed or non-zero if no exchange happened.
* The C flag is also set if *ptr was changed to allow for assembly
* optimization in the calling code.
*
* For example, a user space atomic_add implementation could look like this:
*
* #define atomic_add(ptr, val)
* ({ register unsigned int *__ptr asm("r2") = (ptr);
* register unsigned int __result asm("r1");
* asm volatile (
* "1: @ atomic_addnt"
* "ldr r0, [r2]nt"
* "mov r3, #0xffff0fffnt"
* "add lr, pc, #4nt"
* "add r1, r0, %2nt"
* "add pc, r3, #(0xffff0fc0 - 0xffff0fff)nt"
* "bcc 1b"
* : "=&r" (__result)
* : "r" (__ptr), "rIL" (val)
* : "r0","r3","ip","lr","cc","memory" );
* __result; })
*/
__kuser_cmpxchg: @ 0xffff0fc0
#if defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
/*
* Poor you. No fast solution possible...
* The kernel itself must perform the operation.
* A special ghost syscall is used for that (see traps.c).
*/
swi #0x9ffff0
mov pc, lr
#elif __LINUX_ARM_ARCH__ > 5)
.globl __kuser_helper_end
__kuser_helper_end:
南方大哥 ,
请问arch/arm/kernel/entry-armv.S文件中的“标号__kuser_helper_start和__kuser_helper_end之间的代码”是干什么的?
多谢!
代码如下:
.align 5
.globl __kuser_helper_start
__kuser_helper_start:
/*
* Reference prototype:
*
* int __kernel_cmpxchg(int oldval, int newval, int *ptr)
*
* Input:
*
* r0 = oldval
* r1 = newval
* r2 = ptr
* lr = return address
*
* Output:
*
* r0 = returned value (zero or non-zero)
* C flag = set if r0 == 0, clear if r0 != 0
*
* Clobbered:
*
* r3, ip, flags
*
* Definition and user space usage example:
*
* typedef int (__kernel_cmpxchg_t)(int oldval, int newval, int *ptr);
* #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
*
* Atomically store newval in *ptr if *ptr is equal to oldval for user space.
* Return zero if *ptr was changed or non-zero if no exchange happened.
* The C flag is also set if *ptr was changed to allow for assembly
* optimization in the calling code.
*
* For example, a user space atomic_add implementation could look like this:
*
* #define atomic_add(ptr, val)
* ({ register unsigned int *__ptr asm("r2") = (ptr);
* register unsigned int __result asm("r1");
* asm volatile (
* "1: @ atomic_addnt"
* "ldr r0, [r2]nt"
* "mov r3, #0xffff0fffnt"
* "add lr, pc, #4nt"
* "add r1, r0, %2nt"
* "add pc, r3, #(0xffff0fc0 - 0xffff0fff)nt"
* "bcc 1b"
* : "=&r" (__result)
* : "r" (__ptr), "rIL" (val)
* : "r0","r3","ip","lr","cc","memory" );
* __result; })
*/
__kuser_cmpxchg: @ 0xffff0fc0
#if defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
/*
* Poor you. No fast solution possible...
* The kernel itself must perform the operation.
* A special ghost syscall is used for that (see traps.c).
*/
swi #0x9ffff0
mov pc, lr
#elif __LINUX_ARM_ARCH__ > 5)
.globl __kuser_helper_end
__kuser_helper_end:
|
up
|
我大概看了一下,注释部分为C代码,而真正执行的是C代码的汇编代码。也就是是对汇编的注释
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。