This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

svc_handler

what does this piece of code means in SVC handler and how are the svc number is passed from application to handler ?

SVC_Handler PROC
                       EXPORT SVC_Handler [WEAK]
                       IMPORT SVC_Handler_Main
                       TST lr, #4
                       ITE EQ
                       MRSEQ r0, MSP
                       MRSNE r0, PSP
                       B SVC_Handler_Main
                       ENDP

/*below code is placed in main*/

void SVC_Handler_Main( unsigned int *svc_args )
{
unsigned int svc_number;

svc_number = ( ( char * )svc_args[ 6 ] )[ -2 ] ;
switch( svc_number )
{
case 0: 
break;
case 1:
break;
default: /* unknown SVC */
break;

Parents
  • Hello Teggi,

    Just a quick look into the code in my understand the svc_args[6] points to the return address. An array index "-2" with the pointer typecast to char will points to 2 bytes earlier the LR. That will be the part of SVC number in the previous instruction which is the SVC.

    Chandrasekar

Reply
  • Hello Teggi,

    Just a quick look into the code in my understand the svc_args[6] points to the return address. An array index "-2" with the pointer typecast to char will points to 2 bytes earlier the LR. That will be the part of SVC number in the previous instruction which is the SVC.

    Chandrasekar

Children
No data