rtel wrote on Sunday, February 08, 2015:
Unfortunately I’m not familiar with how the MPU works on the Microblaze,
so will give a generic reply.
‘Standard’ (non MPU) ports work by linking the FreeRTOS API functions
directly into the application code. That is the best/most efficient way
if memory protection or security are not a concern.
If memory protect or security are a concern then you will want to run
some user tasks with a low privilege levels, while leaving the RTOS code
running with a high privilege level. You then need a method of
switching from the low privilege task code to the high privilege RTOS
code when an API function is called. That is normally done by creating
a software interrupt - interrupts always running at a high privilege level.
Traditionally, in MPU restricted applications, API functions are called
by pushing the function’s parameters onto the stack, then calling a
software interrupt generating instruction with a parameter. For
example, in old DOS systems, the instruction was “INT” and you would
pass a parameter that would identify the function being called, so you
might call “INT #16”.
The software interrupt handler then looks at the parameter (that can be
tricky as it is often encoded as part of the assembly instruction) to
see which function to call. Once it knows which function to call it
knows the number of parameters to pop off the stack.
However, FreeRTOS does not normally go that far, and instead uses a
simpler but method that is fine provided for systems that only run code
of known providence. In the FreeRTOS scheme it wraps each API function
in an version that uses a software interrupt to raise the CPU privilege,
calls the API function, then sets the privilege back to whatever it was
when the special version started running. It does that uses macros (you
will find a file called mpu_wrappers.h) so is somewhat transparent to