]> begriffs open source - freertos/blob - Source/portable/IAR/MSP430X/portext.s43
Update headers for Version 7.0.0 release.
[freertos] / Source / portable / IAR / MSP430X / portext.s43
1 /*\r
2     FreeRTOS V7.0.0 - Copyright (C) 2011 Real Time Engineers Ltd.\r
3         \r
4 \r
5     ***************************************************************************\r
6      *                                                                       *\r
7      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
8      *    Complete, revised, and edited pdf reference manuals are also       *\r
9      *    available.                                                         *\r
10      *                                                                       *\r
11      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
12      *    ensuring you get running as quickly as possible and with an        *\r
13      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
14      *    the FreeRTOS project to continue with its mission of providing     *\r
15      *    professional grade, cross platform, de facto standard solutions    *\r
16      *    for microcontrollers - completely free of charge!                  *\r
17      *                                                                       *\r
18      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
19      *                                                                       *\r
20      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
21      *                                                                       *\r
22     ***************************************************************************\r
23 \r
24 \r
25     This file is part of the FreeRTOS distribution.\r
26 \r
27     FreeRTOS is free software; you can redistribute it and/or modify it under\r
28     the terms of the GNU General Public License (version 2) as published by the\r
29     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
30     >>>NOTE<<< The modification to the GPL is included to allow you to\r
31     distribute a combined work that includes FreeRTOS without being obliged to\r
32     provide the source code for proprietary components outside of the FreeRTOS\r
33     kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
34     WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
35     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
36     more details. You should have received a copy of the GNU General Public\r
37     License and the FreeRTOS license exception along with FreeRTOS; if not it\r
38     can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
39     by writing to Richard Barry, contact details for whom are available on the\r
40     FreeRTOS WEB site.\r
41 \r
42     1 tab == 4 spaces!\r
43 \r
44     http://www.FreeRTOS.org - Documentation, latest information, license and\r
45     contact details.\r
46 \r
47     http://www.SafeRTOS.com - A version that is certified for use in safety\r
48     critical systems.\r
49 \r
50     http://www.OpenRTOS.com - Commercial support, development, porting,\r
51     licensing and training services.\r
52 */\r
53 #include "msp430.h"\r
54 #include "FreeRTOSConfig.h"\r
55 #include "data_model.h"\r
56 \r
57         IMPORT vTaskIncrementTick\r
58         IMPORT vTaskSwitchContext\r
59         IMPORT vPortSetupTimerInterrupt\r
60         IMPORT pxCurrentTCB\r
61         IMPORT usCriticalNesting\r
62 \r
63         EXPORT vPortTickISR\r
64         EXPORT vPortYield\r
65         EXPORT xPortStartScheduler\r
66 \r
67 portSAVE_CONTEXT macro\r
68 \r
69         /* Save the remaining registers. */\r
70         pushm_x #12, r15\r
71         mov.w   &usCriticalNesting, r14\r
72         push_x r14\r
73         mov_x   &pxCurrentTCB, r12\r
74         mov_x   sp, 0( r12 )\r
75         endm\r
76 /*-----------------------------------------------------------*/\r
77                 \r
78 portRESTORE_CONTEXT macro\r
79 \r
80         mov_x   &pxCurrentTCB, r12\r
81         mov_x   @r12, sp\r
82         pop_x   r15\r
83         mov.w   r15, &usCriticalNesting\r
84         popm_x  #12, r15\r
85                 \r
86         /* The last thing on the stack will be the status register.\r
87         Ensure the power down bits are clear ready for the next\r
88         time this power down register is popped from the stack. */\r
89         bic.w   #0xf0, 0( sp )\r
90                 \r
91         pop.w   sr\r
92         reta\r
93         endm\r
94 /*-----------------------------------------------------------*/\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         RSEG CODE\r
107         EVEN\r
108         \r
109 vPortTickISR:\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         calla   #vTaskIncrementTick\r
117 \r
118         #if configUSE_PREEMPTION == 1\r
119                 calla   #vTaskSwitchContext\r
120         #endif\r
121                 \r
122         portRESTORE_CONTEXT\r
123 /*-----------------------------------------------------------*/\r
124 \r
125 /*\r
126  * Manual context switch called by the portYIELD() macro.\r
127  */\r
128         EVEN\r
129         \r
130 vPortYield:\r
131 \r
132         /* The sr needs saving before it is modified. */\r
133         push.w  sr\r
134         \r
135         /* Now the SR is stacked we can disable interrupts. */\r
136         dint    \r
137         nop\r
138                                 \r
139         /* Save the context of the current task. */\r
140         portSAVE_CONTEXT                        \r
141 \r
142         /* Select the next task to run. */\r
143         calla   #vTaskSwitchContext             \r
144 \r
145         /* Restore the context of the new task. */\r
146         portRESTORE_CONTEXT\r
147 /*-----------------------------------------------------------*/\r
148 \r
149 \r
150 /*\r
151  * Start off the scheduler by initialising the RTOS tick timer, then restoring\r
152  * the context of the first task.\r
153  */\r
154         EVEN\r
155         \r
156 xPortStartScheduler:\r
157 \r
158         /* Setup the hardware to generate the tick.  Interrupts are disabled\r
159         when this function is called. */\r
160         calla   #vPortSetupTimerInterrupt\r
161 \r
162         /* Restore the context of the first task that is going to run. */\r
163         portRESTORE_CONTEXT\r
164 /*-----------------------------------------------------------*/\r
165                 \r
166         END\r
167                 \r