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