Hi Igor,
Thanks for your ideas.
As far as I understand it...
extern "C" void SVC_Handler(int R0)
{
printf("SVC handler called with R0=%d\n", R0);
}
is just the external declaration, and i have already defined my handler in this way. What makes you think think this is enough to have it copied into the vector table as well.???
I think you are write about the enabling though, SVC should always be active and I will remove the line
NVIC_EnableIRQ(SVCall_IRQn); and see what happens.
This is my handler
void __svc(SVC_00) svc_zero(const char *string);
void __svc(SVC_01) svc_one(const char *string);
extern "C" void SVCHandler_main(unsigned int * svc_args)
{
unsigned int svc_number;
/*
* Stack contains:
* r0, r1, r2, r3, r12, r14, the return address and xPSR
* First argument (r0) is svc_args[0]
*/
svc_number = ((char *)svc_args[6])[-2];
switch(svc_number)
{
case SVC_00:
/* Handle SVC 00 */
break;
case SVC_01:
/* Handle SVC 01 */
break;
default:
/* Unknown SVC */
break;
}
}
and this is my assembler wrapper which has to be installed in the vector table.
AREA |.text|, CODE, READONLY
ENTRY
EXPORT SVCHandler
SVCHandler
IMPORT SVCHandler_main
TST lr, #4
MRSEQ r0, MSP
MRSNE r0, PSP
B SVCHandler_main
END
I still suspect that mbed is using the SVC vector....
nick
I have been trying to implement an SVC call handler with a view to creating a SW trapped interface to a controlled environment which I can use as the API to a RTOs. I am following the route according to Arm application note 178. I have placed the assembler in a separate .s file. Yes I know its not officially supported. Everything compiles and links OK. The only problem I had was finding the correct DEFINE for the SVC IRQ number I eventually settled for SVCCall_IRQn - Can you confirm this is corrrect.
I installled the handler like this.
NVIC_SetVector(SVCall_IRQn, (uint32_t)&SVCHandler);
NVIC_EnableIRQ(SVCall_IRQn);
needless to say it crashes after executing this step.
I started to think maybe the SVC call is already being used by the Mbed library as an API system. So my main question is whether or not the SVC is available to use on Mbed, or whether it is already in use - explaining the problems I am having.
best regards
Nick