]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/CCS/MSP430X/portext.asm
Change version numbers ready for V8.0.0 release candidate 1 tag.
[freertos] / FreeRTOS / Source / portable / CCS / MSP430X / portext.asm
1 ;\r
2 ;/*\r
3 ;    FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 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         pop.w   sr\r
93         ret_x\r
94         .endm\r
95 ;-----------------------------------------------------------\r
96 \r
97 ;*\r
98 ;* The RTOS tick ISR.\r
99 ;*\r
100 ;* If the cooperative scheduler is in use this simply increments the tick\r
101 ;* count.\r
102 ;*\r
103 ;* If the preemptive scheduler is in use a context switch can also occur.\r
104 ;*/\r
105 \r
106         .text\r
107         .align 2\r
108 \r
109 vPortPreemptiveTickISR: .asmfunc\r
110 \r
111         ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs\r
112         ;to save it manually before it gets modified (interrupts get disabled).\r
113         push.w sr\r
114         portSAVE_CONTEXT\r
115 \r
116         call_x  #xTaskIncrementTick\r
117         call_x  #vTaskSwitchContext\r
118 \r
119         portRESTORE_CONTEXT\r
120         .endasmfunc\r
121 ;-----------------------------------------------------------\r
122 \r
123         .align 2\r
124 \r
125 vPortCooperativeTickISR: .asmfunc\r
126 \r
127         ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs\r
128         ;to save it manually before it gets modified (interrupts get disabled).\r
129         push.w sr\r
130         portSAVE_CONTEXT\r
131 \r
132         call_x  #xTaskIncrementTick\r
133 \r
134         portRESTORE_CONTEXT\r
135 \r
136         .endasmfunc\r
137 ;-----------------------------------------------------------\r
138 \r
139 ;\r
140 ; Manual context switch called by the portYIELD() macro.\r
141 ;\r
142 \r
143         .align 2\r
144 \r
145 vPortYield: .asmfunc\r
146 \r
147         ; The sr needs saving before it is modified.\r
148         push.w  sr\r
149 \r
150         ; Now the SR is stacked we can disable interrupts.\r
151         dint\r
152         nop\r
153 \r
154         ; Save the context of the current task.\r
155         portSAVE_CONTEXT\r
156 \r
157         ; Select the next task to run.\r
158         call_x  #vTaskSwitchContext\r
159 \r
160         ; Restore the context of the new task.\r
161         portRESTORE_CONTEXT\r
162         .endasmfunc\r
163 ;-----------------------------------------------------------\r
164 \r
165 \r
166 ;\r
167 ; Start off the scheduler by initialising the RTOS tick timer, then restoring\r
168 ; the context of the first task.\r
169 ;\r
170 \r
171         .align 2\r
172 \r
173 xPortStartScheduler: .asmfunc\r
174 \r
175         ; Setup the hardware to generate the tick.  Interrupts are disabled\r
176         ; when this function is called.\r
177         call_x  #vPortSetupTimerInterrupt\r
178 \r
179         ; Restore the context of the first task that is going to run.\r
180         portRESTORE_CONTEXT\r
181         .endasmfunc\r
182 ;-----------------------------------------------------------\r
183 \r
184         .end\r
185 \r