话不多说,直接上code.
CurrentEL & cpacr_el1
unsigned int current_el, cpacr, fpexc32;
__asm volatile ("mrs %0, CurrentEL\n" : "=r"(current_el));
__asm volatile ("mrs %0, cpacr_el1\n" : "=r"(cpacr));
printf("CurrentEL:%x, cpacr_el1:%x.\n",
current_el, cpacr);
fpexc32_el2
unsigned int fpexc32;
__asm volatile ("mrs %0, fpexc32_el2\n" : "=r"(fpexc32));
printf("fpexc32_el2:%x.\n", fpexc32);
使用这个方法获取的前提是
- 当前cpu 处于aarch32 el1 或者 aarch64 except el1.
- CPU 处于特权模式
如果以上两个条件不能满足,就无法获取fpexc32_el2 的值。
详细每个register 操作的条件,可以参考arm A35 的 spec.
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0500e/CIHBGEAB.html