jserv / mini-arm-os

Build a minimal multi-tasking OS kernel for ARM from scratch
Other
1.04k stars 242 forks source link

Should not force LR to specific EXC_RETURN value #28

Closed lecopzer closed 5 years ago

lecopzer commented 5 years ago

We have always set LR to 0xFFFFFFFD at the end of context switch, but this is a redundant or dangerous work.

Exception entry will store EXC_RETURN to LR automatically by hardware according to previous operation mode.

ARM DUI 0533A 2-27: The processor writes an EXC_RETURN value to the LR. This indicates which stack pointer corresponds to the stack frame and what operation mode the processor was in before the entry occurred

It may cause some unpredictable result as someone might intend to utilize other function of EXC_RETURN.

lecopzer commented 5 years ago

OK, I think just keep this for a "minimal" OS. Its may switch to other EXC_RETURN by another create_thread API.