]> begriffs open source - freertos/blob - portable/IAR/MSP430/portext.s43
Add SMP in the License Header (#402)
[freertos] / portable / IAR / MSP430 / portext.s43
1 /*
2  * FreeRTOS SMP Kernel V202110.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * https://www.FreeRTOS.org
23  * https://github.com/FreeRTOS
24  *
25  * 1 tab == 4 spaces!
26  */
27 #include "FreeRTOSConfig.h"
28 #include "portasm.h"
29
30         IMPORT xTaskIncrementTick
31         IMPORT vTaskSwitchContext
32         IMPORT vPortSetupTimerInterrupt
33
34         EXPORT vTickISR
35         EXPORT vPortYield
36         EXPORT xPortStartScheduler
37
38         RSEG CODE
39
40 /*
41  * The RTOS tick ISR.
42  *
43  * If the cooperative scheduler is in use this simply increments the tick
44  * count.
45  *
46  * If the preemptive scheduler is in use a context switch can also occur.
47  */
48 vTickISR:
49         portSAVE_CONTEXT
50
51         call    #xTaskIncrementTick
52         cmp.w   #0x0, R12
53     jeq         SkipContextSwitch
54         call    #vTaskSwitchContext
55 SkipContextSwitch:
56
57         portRESTORE_CONTEXT
58 /*-----------------------------------------------------------*/
59
60
61 /*
62  * Manual context switch called by the portYIELD() macro.
63  */
64 vPortYield:
65
66         /* Mimic an interrupt by pushing the SR. */
67         push    SR
68
69         /* Now the SR is stacked we can disable interrupts. */
70         dint
71
72         /* Save the context of the current task. */
73         portSAVE_CONTEXT
74
75         /* Switch to the highest priority task that is ready to run. */
76         call    #vTaskSwitchContext
77
78         /* Restore the context of the new task. */
79         portRESTORE_CONTEXT
80 /*-----------------------------------------------------------*/
81
82
83 /*
84  * Start off the scheduler by initialising the RTOS tick timer, then restoring
85  * the context of the first task.
86  */
87 xPortStartScheduler:
88
89         /* Setup the hardware to generate the tick.  Interrupts are disabled
90         when this function is called. */
91         call    #vPortSetupTimerInterrupt
92
93         /* Restore the context of the first task that is going to run. */
94         portRESTORE_CONTEXT
95 /*-----------------------------------------------------------*/
96
97
98         /* Install vTickISR as the timer A0 interrupt. */
99         ASEG
100         ORG 0xFFE0 + TIMERA0_VECTOR
101
102         _vTickISR_: DC16 vTickISR
103
104
105         END
106