8种机械键盘轴体对比
本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?
内核版本:2.6.38
平台:ambarella
代码查看current_thread_info()的代码查看:
current_thread_info()函数定义在arch/asm/include/asm/thread_info.h中,因为被头文件定义成一个内联函数,编译时不会产生这个函数符号而是将它嵌入在调用这个函数的函数体中,因此在system.map中没有这个符号可以看,就要找调用这个函数的函数,这里选择arch/asm/kenerl/process.c中void flush_thread(void)函数,因为函数一开始就调用了这个内联函数,经过反汇编的代码位置比较好找。
[arch/asm/include/asm/thread_info.h]
static inline struct thread_info *(void) __attribute_const__;
static inline struct thread_info *current_thread_info(void)
{
register unsigned long sp asm ("sp");
return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
}
[arch/asm/kenerl/process.c]
void flush_thread(void)
{
struct thread_info *thread = current_thread_info();
struct task_struct *tsk = current;
flush_ptrace_hw_breakpoint(tsk);
memset(thread->used_cp, 0, sizeof(thread->used_cp));
memset(&tsk->thread.debug, 0, sizeof(struct debug_info));
memset(&thread->fpstate, 0, sizeof(union fp_state));
thread_notify(THREAD_NOTIFY_FLUSH, thread);
}
反汇编反汇编后:c002eb64 :
c002eb64: e1a0c00d mov ip, sp //将堆栈指针sp放入零时寄存器ip中
c002eb68: e92dd830 push {r4, r5, fp, ip, lr, pc} //入栈保护
c002eb6c: e24cb004 sub fp, ip, #4 //ip-4的内容放入浮点寄存器fp
c002eb70: e1a0300d mov r3, sp
c002eb74: e3c34d7f bic r4, r3, #8128 ; 0x1fc0
c002eb78: e3c4403f bic r4, r4, #63 ; 0x3f
c002eb7c: e2840050 add r0, r4, #80 ; 0x50
c002eb80: e594500c ldr r5, [r4, #12]
c002eb84: e3a01010 mov r1, #16
c002eb88: eb081c14 bl c0235be0 <__memzero>
c002eb8c: e2850f77 add r0, r5, #476 ; 0x1dc
c002eb90: e3a01014 mov r1, #20
c002eb94: eb081c11 bl c0235be0 <__memzero>
c002eb98: e2840e12 add r0, r4, #288 ; 0x120
c002eb9c: e3a0108c mov r1, #140 ; 0x8c
c002eba0: eb081c0e bl c0235be0 <__memzero>
c002eba4: e1a02004 mov r2, r4
c002eba8: e3a01000 mov r1, #0
c002ebac: e59f0004 ldr r0, [pc, #4] ; c002ebb8
c002ebb0: eb00f7a2 bl c006ca40
c002ebb4: e89da830 ldm sp, {r4, r5, fp, sp, pc}
c002ebb8: c045e64c subgt lr, r5, ip, asr #12
debug模式的反汇编用gcc -g加入debug模式的反汇编结果:void flush_thread(void)
{
c002eb64: e1a0c00d mov ip, sp
c002eb68: e92dd830 push {r4, r5, fp, ip, lr, pc}
c002eb6c: e24cb004 sub fp, ip, #4
current_thread_info():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/include/asm/thread_info.h:97
c002eb70: e1a0300d mov r3, sp
c002eb74: e3c34d7f bic r4, r3, #8128 ; 0x1fc0
c002eb78: e3c4403f bic r4, r4, #63 ; 0x3f
flush_thread():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/kernel/process.c:421
struct thread_info *thread = current_thread_info();
struct task_struct *tsk = current;
flush_ptrace_hw_breakpoint(tsk);
memset(thread->used_cp, 0, sizeof(thread->used_cp));
c002eb7c: e2840050 add r0, r4, #80 ; 0x50
get_current():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/include/asm/current.h:10
c002eb80: e594500c ldr r5, [r4, #12]
flush_thread():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/kernel/process.c:421
c002eb84: e3a01010 mov r1, #16
c002eb88: eb081c14 bl c0235be0 <__memzero>
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/kernel/process.c:422
memset(&tsk->thread.debug, 0, sizeof(struct debug_info));
c002eb8c: e2850f77 add r0, r5, #476 ; 0x1dc
c002eb90: e3a01014 mov r1, #20
c002eb94: eb081c11 bl c0235be0 <__memzero>
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/kernel/process.c:423
memset(&thread->fpstate, 0, sizeof(union fp_state));
c002eb98: e2840e12 add r0, r4, #288 ; 0x120
c002eb9c: e3a0108c mov r1, #140 ; 0x8c
c002eba0: eb081c0e bl c0235be0 <__memzero>
thread_notify():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/include/asm/thread_notify.h:35current_thread_info()的反汇编结果:
current_thread_info():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/include/asm/thread_info.h:97
c002eb70: e1a0300d mov r3, sp
c002eb74: e3c34d7f bic r4, r3, #8128 ; 0x1fc0
c002eb78: e3c4403f bic r4, r4, #63 ; 0x3f
THREAD_SIZE = 8192
return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
c002eb70: 堆栈sp放入r3
c002eb74: r3&(~8128)的值放入r4 => r4=r3&(~0x1fc0) => r4=r3&1110000000111111
c002eb78: r4&(~63)的值放入r4 => r4=r4&(~0x3f) => r4=r3&1111111111000000
static inline struct thread_info *current_thread_info(void)
{
register unsigned long sp asm ("sp");
return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
c0008b7c: e1a0300d mov r3, sp
c0008b80: e3c33d7f bic r3, r3, #8128 ; 0x1fc0
c0008b84: e3c3303f bic r3, r3, #63 ; 0x3f
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/init/main.c:610
/*
* Disable preemption - early bootup scheduling is extremely
* fragile until we cpu_idle() for the first time.
*/
preempt_disable();
c0008b88: e1a02003 mov r2, r3
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/include/asm/thread_info.h:97
c0008b8c: e1a0300d mov r3, sp
c0008b90: e3c33d7f bic r3, r3, #8128 ; 0x1fc0
c0008b94: e3c3303f bic r3, r3, #63 ; 0x3f
start_kernel():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/init/main.c:610
c0008b98: e5933004 ldr r3, [r3, #4]
c0008b9c: e2833001 add r3, r3, #1
c0008ba0: e5823004 str r3, [r2, #4]
arch_local_save_flags():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/include/asm/irqflags.h:131
* Save the current interrupt enable state.
*/
static inline unsigned long arch_local_save_flags(void)
{
unsigned long flags;
asm volatile(
c0008ba4: e10f3000 mrs r3, CPSR
c0008ba8: e50b301c str r3, [fp, #-28]
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/include/asm/irqflags.h:134
" mrs %0, cpsr @ local_save_flags"
: "=r" (flags) : : "memory", "cc");
return flags;
c0008bac: e51b301c ldr r3, [fp, #-28]
start_kernel():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/init/main.c:611
if (!irqs_disabled()) {
c0008bb0: e50b302c str r3, [fp, #-44] ; 0x2c
c0008bb4: e51b302c ldr r3, [fp, #-44] ; 0x2c
c0008bb8: e50b3018 str r3, [fp, #-24]
arch_irqs_disabled_flags():
/VMShare_Amb_fc15/Ambarella/a5s_linux_sdk3.2/a5s_linux_sdk/ambarella/kernel/linux-2.6.38/arch/arm/include/asm/irqflags.h:151
: "memory", "cc");
}