Hi all,I am trying to access the system control register in my ARM C program. The code (with heading 64 bit) I used is presented below. However I got the following error message during compilation.
/tmp/cc7Dc236.s: Assembler messages:/tmp/cc7Dc236.s:31: Error: selected processor does not support requested special purpose register -- `mrs r3,SCTLR_EL1'
I am using ARM cortex-a53 processor.I felt like the system was probably running in 32 bit mode instead of 64 bit and hence the error and tried the code below (with heading 32 bit). The compilation was successful, however at runtime i saw the Illegal instruction error.
Is it possible by the programmer to actually query the system controller register. I am particularly interested to know the contents of the A bit in the SCTRL_EL1 or EL0 registers.
#include <stdio.h> unsigned int A_bit() { unsigned int res = 0; __asm volatile ( "MRS %[result], SCTLR_EL1": [result] "=r" (res) ); return res; } int main(void) { unsigned int sys_reg = 0; sys_reg = A_bit(); printf("system register value is %d \n", sys_reg); }
#include <stdio.h> unsigned int A_bit() { unsigned int res = 0; __asm volatile ( "MRC p15, 0, %[result], c1, c0, 0": [result] "=r" (res) ); return res; } int main(void) { unsigned int sys_reg = 0; sys_reg = A_bit(); printf("system register value is %d \n", sys_reg); }
CA53 can run in AArch64 and AArch32 mode. And you have to compile the code respectively.
There is no SCTLR_EL0. Again, please read the ARMv8-A reference manual. It explains a lot.