We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi Experts,
The RTX code contains SVC handlers named with different names. How this can be best made use of ?
Why the option to select numbering of different svc handlers like _svc(0) .... __svc(n) ?
Regards,
Techguyz
I can't answer your question about RTX, but I can answer the part regarding svc numbering.
The numbers would be useful, in case you need more than one functionality.
For instance, consider you're running your program in user mode, and you need to change a pin of a GPIO port.
You've decided that svc(3) changes your favourite GPIO-port.
But you also need the ability to read a sector from a SD-card. For that purpose, you've chosen svc(17)
...etc.
You have 256 different immediate values you can use for this purpose. But in case you need more than that, you could make sub-function numbers.
Eg. svc(2) might examine what's in r0, and use r0 as a function selector.
So basically, you have a single handler, which examines the parameters for SVC and uses the parameter as a function selector.
You could use this to implement system function calls, such as malloc, free, fopen, fseek, fread, fwrite, fclose, etc, etc...
Hi Jensbauer,
Thanks for the reply.
So you mean the jump from user mode to supervisor mode is performed through this numbering ?
Is it similar to how system call implemented in the OS including all OS functionalities and task switching operations ?
The number is just a parameter that the handler can investigate.
Normally, the parameter is used for identifying which function you want to use.
-But the parameter can be anything the designer of the handler wants.
When the SVC instruction is executed, it triggers an interrupt (software interrupt), thus a handler is needed.
The handler is executed in supervisor mode, but as soon as the handler returns, your code continues in user mode.
Some operating systems would use the SVC handler as the interface to system functions.
Other operating systems would load linkable files and use the resolved symbols to call functions; such functions could make use of the SVC instruction to execute code in privileged mode.