سؤال

I'm writing bare metal code (no OS), for an ARM Cortex A9 processor.

I need to read a register which is only accessible on supervisor mode (the multiprocessor affinity register, MPIDR).

When I'm in user mode and try to execute the following instruction (to enter supervisor mode) step by step with a debugger nothing happens.

MSR CPSR_C, #0x13

And my program goes to undefined mode, if I try to read the MPIDR register

Please do you know what i'm missing?

When i use the debugger windows, and force the five first bits of CPSR register to b10011, it works, I go to supervisor.

هل كانت مفيدة؟

المحلول

You can't change between modes using instructions which directly write to the CPSR mode bits in User mode. Proper way is to use a svc (supervisor call) and execute necessary instruction requested.

نصائح أخرى

Use cps instruction, e.g.

# Disable ABT, IRQ, FIQ and set SVC mode
cpsid aif, #0x13
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top