From 9f95ff5b6ba01db09552b84a0ab79607060a2666 Mon Sep 17 00:00:00 2001 From: Ali Labbene Date: Wed, 11 Dec 2019 08:59:21 +0100 Subject: Official ARM version: v5.4.0 Add CMSIS V5.4.0, please refer to index.html available under \docs folder. Note: content of \CMSIS\Core\Include has been copied under \Include to keep the same structure used in existing projects, and thus avoid projects mass update Note: the following components have been removed from ARM original delivery (as not used in ST packages) - CMSIS_EW2018.pdf - .gitattributes - .gitignore - \Device - \CMSIS - \CoreValidation - \DAP - \Documentation - \DoxyGen - \Driver - \Pack - \RTOS\CMSIS_RTOS_Tutorial.pdf - \RTOS\RTX - \RTOS\Template - \RTOS2\RTX - \Utilities - All ARM/GCC projects files are deleted from \DSP, \RTOS and \RTOS2 Change-Id: Ia026c3f0f0d016627a4fb5a9032852c33d24b4d3 --- docs/RTOS/html/svcFunctions.html | 167 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 docs/RTOS/html/svcFunctions.html (limited to 'docs/RTOS/html/svcFunctions.html') diff --git a/docs/RTOS/html/svcFunctions.html b/docs/RTOS/html/svcFunctions.html new file mode 100644 index 0000000..612e401 --- /dev/null +++ b/docs/RTOS/html/svcFunctions.html @@ -0,0 +1,167 @@ + + + + + +SVC Functions +CMSIS-RTOS: SVC Functions + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
CMSIS-RTOS +  Version 1.03 +
+
Real-Time Operating System: API and RTX Reference Implementation.
+
+
+ +
+
    + +
+
+ + + +
+
+ +
+
+
+ +
+ + + + +
+ +
+ +
+
+
SVC Functions
+
+
+

Supervisor Calls (SVC) are exceptions targeted at software and operating systems for generating system function calls. They are sometimes called software interrupts. For example, instead of allowing user programs to directly access hardware, an operating system may provide access to hardware through an SVC. So when a user program wants to use certain hardware, it generates the SVC exception using SVC instructions, and then the software exception handler in the operating system is executed and provides the requested service to the user application. In this way, access to hardware is under the control of the OS, which can provide a more robust system by preventing the user applications from directly accessing the hardware.

+

SVC can also make software more portable because the user application does not need to know the programming details of the underlying hardware. The user program will only need to know the application programming interface (API) function ID and parameters; the actual hardware-level programming is handled by device drivers.

+

SVCs run in Privileged Handler mode of the Cortex-M core. SVC functions accept arguments and can return values. The functions are used in the same way as other functions; however, differences are hidden to the user. The ARMCC handles the differences and generates code instructions to call SVC functions. SVC functions are called by executing the SVC instruction. When executing SVC instructions, the controller changes to the Privileged Handler Mode.

+

Interrupts are not disabled in this mode. To protect SVC function from interrupts, you need to include the disable/enable intrinsic functions __disable_irq() and __enable_irq() in your code.

+

You can use SVC functions to access protected peripherals, for example, to configure NVIC and interrupts. This is required if you run tasks in unprivileged (protected) mode and you need to change interrupts from the task.

+

To implement SVC functions in your CMSIS-RTOS RTX kernel project, you need to:

+
    +
  1. Copy the file SVC_Table.s to your project folder and include it into your project. This file is available as a source code template.
  2. +
  3. Declare a function with a __svc(x) attribute. Use the first SVC number, starting from 1, that is free.
    void __svc(1) inc_5bit (U32 *cp);
    +
  4. +
  5. Write a function implementation and convert the function name into a __SVC_x function name. Later, this name is referenced by the linker from the SVC_Table.s module. You also need to disable/enable interrupts.
    void __SVC_1 (U32 *cp) {
    +
    // A protected function to increment a 5-bit counter.
    +
    __disable_irq();
    +
    cp = (*cp + 1) & 0x1F;
    +
    __enable_irq();
    +
    }
    +
  6. +
  7. Add the function __SVC_x to the SVC function table in the SVC_Table.s module. First import it from other modules:
    ; Import user SVC functions here.
    +
    IMPORT __SVC_1
    +
    Then, add a reference to it into the table:
    ; Insert user SVC functions here. SVC 0 used by RTL Kernel.
    +
    DCD __SVC_1 ; user SVC function
    +
  8. +
  9. Your SVC function should now look like this:
    void __svc(1) inc_5bit (U32 *cp);
    +
    void __SVC_1 (U32 *cp) {
    +
    // A protected function to increment a 5-bit counter.
    +
    __disable_irq();
    +
    cp = (*cp + 1) & 0x1F;
    +
    __enable_irq();
    +
    }
    +
  10. +
+
Note
    +
  • SVC function 0 is reserved for the CMSIS-RTOS RTX kernel.
  • +
  • Do not leave gaps when numbering SVC functions. They must occupy a continuous range of numbers starting from 1.
  • +
  • SVC functions can still be interrupted.
  • +
  • CMSIS-RTOS RTX must not be called before the main() function.
  • +
+
+
+
+ + + + -- cgit