Currently I'm trying to write several system control registers with EL3 privilege for my AArch64 development board.
I put my code in the trusted firmware boot loader (BL31).
Here is my code that I put in the bl31_main
of arm-trusted-firmware-source-code:
asm("MRS %x[result], SCR_EL3"
: [result] "=r" (scr)
);
asm("MSR SCR_EL3, %x[value]"
:
: [value] "r" (scr)
);
I can read the values of these registers correctly so I assume my code running with EL3 privilege.
However, for several registers I tested, every time after I write new values to them, their values don't even change.
I cannot come up with what might cause this problem. Any suggestion is welcomed!
Thank you in advanced.
Simon
If you really insist here is a compromise...OUTSIDE of any functions, NOT within a function but in a C file.
asm(".globl read_SCR_EL3; read_SCR_EL3: mrs x0,SCR_EL3; ret\n");
...
unsigned int read_SCR_EL3 ( void );
...
value=read_SCR_EL3();
which is just another way of doing real assembly.
If you want to do inline, AFTER you have real assembly working then figure out how to get that inline like you were trying to do. Figure out what/if you were doing wrong (which I would have hoped someone here would or will help) (I will add an assembly tag even though this is C/compiler language stuff).
do it inside a simple function that wraps the inline asm and say returns the value from the read. DISASSEMBLE (vs -S output) the binary, find that function and inspect what the compiler produced and if it would/should work or not...Optimized it should somewhat exactly resemble the simple mrs x0,registername/ret code, maybe do something like add one to the value before returning but after reading to see that it is using/manipulating the right register...