The MCAL_ENABLE_USER_MODE_SUPPORT is a symbol defined in the "C/C++ compiler" options of the project.
To implement the clean option :
- In the exceptions.c file (Platform RTD), add a case 4 in the SVCHandler main function as follow :
void SVCHandler_main(uint32 * svc_args)
{
uint32 svc_number; /* Stack contains: * r0, r1, r2, r3, r12, r14, the return address and xPSR */
/* First argument (r0) is svc_args[0] */
/* svc_args[6] = SP + 0x18 PC(r15) */
/* ((char *)svc_args[6])[-2]; = first two bytes, lsb, of the instruction which caused the SVC */
/* this will nto work if optimization compiler options are changed*/
svc_number = ((uint8 *)svc_args[6])[-2];
switch(svc_number)
{
case 1:
/* Handle SVC 01*/
ASM_KEYWORD("mov r0, #0x1"); /* Set User mode for Thread mode */
ASM_KEYWORD("msr CONTROL, r0");
break;
case 0:
/* Handle SVC 00*/
ASM_KEYWORD("mov r0, #0x0"); /* Set Supervisor mode for Thread mode */
ASM_KEYWORD("msr CONTROL, r0");
break;
case 2:
/* Handle SVC 02*/
Resume_Interrupts(); /* Resume all interrupts */
break;
case 3:
/* Handle SVC 03*/
Suspend_Interrupts(); /* Suspend all interrupts */
break;
case 4:
/* Handle SVC 04*/
vPortSVCHandler(); /* Suspend all interrupts */
break;
default:
/* Unknown SVC*/
break;
}
}
- At the beggining of the exceptions.c file (Platform RTD), add the prototype of vPortSVCHandler() as follow :
#ifdef MCAL_ENABLE_USER_MODE_SUPPORT
void SVCHandler_main(uint32 * svc_args);
extern void vPortSVCHandle (void);
void Suspend_Interrupts(void);
void Resume_Interrupts(void);
#endif
Then replace the "svc 0" line of the vPortStartFirstTask function of the portasm.s file by "svc 4".