linux kernel 对 ARM 未定义指令扩展的例子
2009-03-25 22:17
525 查看
ARM 的工作模式中有一种是未定义指令终止模式UND, 如果运行的程序中有未定义的指令,那么会对 kernel 产生一个 undefine instruction trap 如果程序没有对SIGILL 有任何处理的话,那么程序会被KILL 了。
linux 的kernel 提供一种扩展未定义指令的方法。
例如扩展ARM 指令
linux 的kernel 提供一种扩展未定义指令的方法。
例如扩展ARM 指令
clz,这个指令是用来计算一个一个数字前面有多少个0
register_undef_hook(&clz_hook);
static int clz_trap(struct pt_regs *regs, unsigned int instr) { /* Extract the source register index */ int src = instr & 0xf; /* Extract the destination (result) register index */ int dst = (instr >> 12) & 0xf; /* Extract the conditional code */ int cc = (instr >> 28) & 0xf; /* Test if the conditional code passes */ if (handle_cc(regs, cc)) { /* Implement the instruction */ regs->uregs[dst] = 32 - fls(regs->uregs[src]); } /* Print some stuff for debugging */ printk("emulating clz: %x src=%d (%lx) dst=%d (%lx) @ %p/n", instr, src, regs->uregs[src], dst, regs->uregs[dst], (void*) regs->ARM_pc); /* Increment the PC register */ regs->ARM_pc += 4; return 0; } static struct undef_hook clz_hook = { .instr_mask = 0x0fff0ff0, .instr_val = 0x016f0f10, .cpsr_mask = PSR_T_BIT, .cpsr_val = 0, .fn = clz_trap, };
相关文章推荐
- 错误 78 “Web.NewsDetail”不包含“Label1”的定义,并且找不到可接受类型为“Web.NewsDetail”的第一个参数的扩展方法“Label1”(是否缺少 using 指令或程序
- C# 001 --- 正确的删除一个控件的事件函数 --- 解决错误: “A”不包含“B”的定义,并且找不到可接受类型为“A”的第一个参数的扩展方法“B”(是否缺少 using 指令或程序集引用?)
- ARM汇编指令 具体操作例子
- 错误 X “X1”不包含“XX2”的定义,并且找不到可接受类型为“X1”的第一个参数的扩展方法“XX2”(是否缺少 using 指令或程序集引用?)
- ARM指令例子
- ARM指令中标志位的定义
- ASP.login_aspx”不包含“Button1_Click”的定义,并且找不到可接受类型为“ASP.login_aspx”的第一个参数的扩展方法“Button1_Click”(是否缺少 using 指令或程序集引用?)
- 求助!!!“测试.Form1”不包含“Form1_Load”的定义,并且找不到可接受类型为“测试.Form1”的第一个参数的扩展方法“Form1_Load”(是否缺少 using 指令或程序集引用?)
- 头文件定义和ARM指令
- 不用搭环境的10分钟AngularJS指令简易入门01(含例子)
- 不用搭环境的10分钟AngularJS指令简易入门01(含例子)
- 对照Startup.s学习ARM汇编指令
- 10_ARM汇编自学笔记指令系统之乘法指令与乘加指令
- angularJS扩展指令之-angular-file-upload(整理)
- sencha-touch-1.1中定义selectfield的一个例子
- 《ARM 指令集》IEEE浮点指令
- ARM汇编中的:比较指令--CMN / CMP / TEQ / TST
- 多寄存器寻址指令ldmia/ldmib和ARM存储器访问指令——多寄存器存取
- ARM指令的条件说明
- 多寄存器寻址指令ldmia/ldmib和ARM存储器访问指令——多寄存器存取