FreeRTOS Cortex M3
In order to make one of the demo-projects in FreeRTOS run on qemu "lm3s811evb" board, I had to write these two patches.
The first patch, MSR, is quite obvious, since we want to store a value from registers into a system register, and not the other way around.
The second patch however, I'm not 100% sure about, but I see a issue each time the FreeRTOS wants to do a task-switch, the PC/regs[15] is off by one byte compared to what qemu internals expect. The patch provided makes everything work with the image I have.
Stian Skjelstad
Servo Electronics
Norway
target-arm/translate.c +1 -1
@@ -6435,8 +6435,8 @@switch (op) {case 0 :/* msr cpsr. */ if (IS_M (env)) { +gen_movl_T0_reg (s, rn);gen_op_v7m_msr_T0 (insn &0xff ); -gen_movl_reg_T0 (s, rn);gen_lookup_tb (s);break ; }
target-arm/helper.c +3 -1
@@ -562,6 +562,8 @@ env->regs[12 ] =v7m_pop (env); env->regs[14 ] =v7m_pop (env); env->regs[15 ] =v7m_pop (env); + env->thumb = env->regs[15 ] &1 ; + env->regs[15 ] &= ~1 ; xpsr =v7m_pop (env);xpsr_write (env, xpsr,0xfffffdff );/* Undo stack alignment. */
@@ -634,7 +636,7 @@ }/* Switch to the hander mode. */ v7m_push (env, xpsr); -v7m_push (env, env->regs[15 ]); +v7m_push (env, env->regs[15 ] | (env->thumb?1 :0 ));v7m_push (env, env->regs[14 ]);v7m_push (env, env->regs[12 ]);v7m_push (env, env->regs[3 ]);