]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/CCS/MSP430X/portext.asm
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Source / portable / CCS / MSP430X / portext.asm
1 ;\r
2 ;/*\r
3 ;    FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
4 ;    All rights reserved\r
5 ;\r
6 ;\r
7 ;    ***************************************************************************\r
8 ;     *                                                                       *\r
9 ;     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
10 ;     *    Complete, revised, and edited pdf reference manuals are also       *\r
11 ;     *    available.                                                         *\r
12 ;     *                                                                       *\r
13 ;     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
14 ;     *    ensuring you get running as quickly as possible and with an        *\r
15 ;     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
16 ;     *    the FreeRTOS project to continue with its mission of providing     *\r
17 ;     *    professional grade, cross platform, de facto standard solutions    *\r
18 ;     *    for microcontrollers - completely free of charge!                  *\r
19 ;     *                                                                       *\r
20 ;     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
21 ;     *                                                                       *\r
22 ;     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
23 ;     *                                                                       *\r
24 ;    ***************************************************************************\r
25 ;\r
26 ;\r
27 ;    This file is part of the FreeRTOS distribution.\r
28 ;\r
29 ;    FreeRTOS is free software; you can redistribute it and/or modify it under\r
30 ;    the terms of the GNU General Public License (version 2) as published by the\r
31 ;    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
32 ;    >>>NOTE<<< The modification to the GPL is included to allow you to\r
33 ;    distribute a combined work that includes FreeRTOS without being obliged to\r
34 ;    provide the source code for proprietary components outside of the FreeRTOS\r
35 ;    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
36 ;    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
37 ;    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
38 ;    more details. You should have received a copy of the GNU General Public\r
39 ;    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
40 ;    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
41 ;    by writing to Richard Barry, contact details for whom are available on the\r
42 ;    FreeRTOS WEB site.\r
43 ;\r
44 ;    1 tab == 4 spaces!\r
45 ;\r
46 ;    http://www.FreeRTOS.org - Documentation, latest information, license and\r
47 ;    contact details.\r
48 ;\r
49 ;    http://www.SafeRTOS.com - A version that is certified for use in safety\r
50 ;    critical systems.\r
51 ;\r
52 ;    http://www.OpenRTOS.com - Commercial support, development, porting,\r
53 ;    licensing and training services.\r
54 ;*/\r
55 \r
56 ; * The definition of the "register test" tasks, as described at the top of\r
57 ; * main.c\r
58 \r
59         .include data_model.h\r
60 \r
61         .global xTaskIncrementTick\r
62         .global vTaskSwitchContext\r
63         .global vPortSetupTimerInterrupt\r
64         .global pxCurrentTCB\r
65         .global usCriticalNesting\r
66 \r
67         .def vPortPreemptiveTickISR\r
68         .def vPortCooperativeTickISR\r
69         .def vPortYield\r
70         .def xPortStartScheduler\r
71 \r
72 ;-----------------------------------------------------------\r
73 \r
74 portSAVE_CONTEXT .macro\r
75 \r
76         ;Save the remaining registers.\r
77         pushm_x #12, r15\r
78         mov.w   &usCriticalNesting, r14\r
79         push_x r14\r
80         mov_x   &pxCurrentTCB, r12\r
81         mov_x   sp, 0( r12 )\r
82         .endm\r
83 ;-----------------------------------------------------------\r
84 \r
85 portRESTORE_CONTEXT .macro\r
86 \r
87         mov_x   &pxCurrentTCB, r12\r
88         mov_x   @r12, sp\r
89         pop_x   r15\r
90         mov.w   r15, &usCriticalNesting\r
91         popm_x  #12, r15\r
92         nop\r
93         pop.w   sr\r
94         nop\r
95         ret_x\r
96         .endm\r
97 ;-----------------------------------------------------------\r
98 \r
99 ;*\r
100 ;* The RTOS tick ISR.\r
101 ;*\r
102 ;* If the cooperative scheduler is in use this simply increments the tick\r
103 ;* count.\r
104 ;*\r
105 ;* If the preemptive scheduler is in use a context switch can also occur.\r
106 ;*/\r
107 \r
108         .text\r
109         .align 2\r
110 \r
111 vPortPreemptiveTickISR: .asmfunc\r
112 \r
113         ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs\r
114         ;to save it manually before it gets modified (interrupts get disabled).\r
115         push.w sr\r
116         portSAVE_CONTEXT\r
117 \r
118         call_x  #xTaskIncrementTick\r
119         call_x  #vTaskSwitchContext\r
120 \r
121         portRESTORE_CONTEXT\r
122         .endasmfunc\r
123 ;-----------------------------------------------------------\r
124 \r
125         .align 2\r
126 \r
127 vPortCooperativeTickISR: .asmfunc\r
128 \r
129         ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs\r
130         ;to save it manually before it gets modified (interrupts get disabled).\r
131         push.w sr\r
132         portSAVE_CONTEXT\r
133 \r
134         call_x  #xTaskIncrementTick\r
135 \r
136         portRESTORE_CONTEXT\r
137 \r
138         .endasmfunc\r
139 ;-----------------------------------------------------------\r
140 \r
141 ;\r
142 ; Manual context switch called by the portYIELD() macro.\r
143 ;\r
144 \r
145         .align 2\r
146 \r
147 vPortYield: .asmfunc\r
148 \r
149         ; The sr needs saving before it is modified.\r
150         push.w  sr\r
151 \r
152         ; Now the SR is stacked we can disable interrupts.\r
153         dint\r
154         nop\r
155 \r
156         ; Save the context of the current task.\r
157         portSAVE_CONTEXT\r
158 \r
159         ; Select the next task to run.\r
160         call_x  #vTaskSwitchContext\r
161 \r
162         ; Restore the context of the new task.\r
163         portRESTORE_CONTEXT\r
164         .endasmfunc\r
165 ;-----------------------------------------------------------\r
166 \r
167 \r
168 ;\r
169 ; Start off the scheduler by initialising the RTOS tick timer, then restoring\r
170 ; the context of the first task.\r
171 ;\r
172 \r
173         .align 2\r
174 \r
175 xPortStartScheduler: .asmfunc\r
176 \r
177         ; Setup the hardware to generate the tick.  Interrupts are disabled\r
178         ; when this function is called.\r
179         call_x  #vPortSetupTimerInterrupt\r
180 \r
181         ; Restore the context of the first task that is going to run.\r
182         portRESTORE_CONTEXT\r
183         .endasmfunc\r
184 ;-----------------------------------------------------------\r
185 \r
186         .end\r
187 \r