話不多說,直接上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