]> git.sur5r.net Git - freertos/blob - Source/portable/Softune/MB96340/port.c
Update version number.
[freertos] / Source / portable / Softune / MB96340 / port.c
1 /*\r
2         FreeRTOS.org V5.4.0 - Copyright (C) 2003-2009 Richard Barry.\r
3 \r
4         This file is part of the FreeRTOS.org distribution.\r
5 \r
6         FreeRTOS.org is free software; you can redistribute it and/or modify it\r
7         under the terms of the GNU General Public License (version 2) as published\r
8         by the Free Software Foundation and modified by the FreeRTOS exception.\r
9         **NOTE** The exception to the GPL is included to allow you to distribute a\r
10         combined work that includes FreeRTOS.org without being obliged to provide\r
11         the source code for any proprietary components.  Alternative commercial\r
12         license and support terms are also available upon request.  See the \r
13         licensing section of http://www.FreeRTOS.org for full details.\r
14 \r
15         FreeRTOS.org is distributed in the hope that it will be useful, but WITHOUT\r
16         ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
17         FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
18         more details.\r
19 \r
20         You should have received a copy of the GNU General Public License along\r
21         with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59\r
22         Temple Place, Suite 330, Boston, MA  02111-1307  USA.\r
23 \r
24 \r
25         ***************************************************************************\r
26         *                                                                         *\r
27         * Get the FreeRTOS eBook!  See http://www.FreeRTOS.org/Documentation      *\r
28         *                                                                         *\r
29         * This is a concise, step by step, 'hands on' guide that describes both   *\r
30         * general multitasking concepts and FreeRTOS specifics. It presents and   *\r
31         * explains numerous examples that are written using the FreeRTOS API.     *\r
32         * Full source code for all the examples is provided in an accompanying    *\r
33         * .zip file.                                                              *\r
34         *                                                                         *\r
35         ***************************************************************************\r
36 \r
37         1 tab == 4 spaces!\r
38 \r
39         Please ensure to read the configuration and relevant port sections of the\r
40         online documentation.\r
41 \r
42         http://www.FreeRTOS.org - Documentation, latest information, license and\r
43         contact details.\r
44 \r
45         http://www.SafeRTOS.com - A version that is certified for use in safety\r
46         critical systems.\r
47 \r
48         http://www.OpenRTOS.com - Commercial support, development, porting,\r
49         licensing and training services.\r
50 */\r
51 \r
52 #include "FreeRTOS.h"\r
53 #include "task.h"\r
54 \r
55 /*-----------------------------------------------------------\r
56  * Implementation of functions defined in portable.h for the 16FX port.\r
57  *----------------------------------------------------------*/\r
58 \r
59 /* \r
60  * Get current value of DPR and ADB registers \r
61  */\r
62 portSTACK_TYPE xGet_DPR_ADB_bank( void ); \r
63 \r
64 /* \r
65  * Get current value of DTB and PCB registers \r
66  */\r
67 portSTACK_TYPE xGet_DTB_PCB_bank( void );\r
68 \r
69 /*\r
70  * Sets up the periodic ISR used for the RTOS tick.  This uses RLT0, but\r
71  * can be done using any given RLT.\r
72  */\r
73 static void prvSetupRLT0Interrupt( void );\r
74 \r
75 /*-----------------------------------------------------------*/\r
76 \r
77 /* \r
78  * We require the address of the pxCurrentTCB variable, but don't want to know\r
79  * any details of its type. \r
80  */\r
81 typedef void tskTCB;\r
82 extern volatile tskTCB * volatile pxCurrentTCB;\r
83 \r
84 /*-----------------------------------------------------------*/\r
85 \r
86 /* \r
87  * Macro to save a task context to the task stack. This macro  copies the \r
88  * saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from  the   system \r
89  * stack to task stack pointed by user stack pointer ( USP  for SMALL and \r
90  * MEDIUM memory model amd USB:USP for COMPACT  and LARGE memory model ),\r
91  * then  it pushes the general purpose registers RW0-RW7  on  to the task \r
92  * stack. Finally the  resultant  stack  pointer  value is saved into the \r
93  * task  control  block  so  it  can  be retrieved the next time the task \r
94  * executes.\r
95  */ \r
96 #if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )\r
97 \r
98         #define portSAVE_CONTEXT()                                                                                      \\r
99                         {       __asm(" POPW  A ");                                                                             \\r
100                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
101                                 __asm(" PUSHW  A ");                                                                    \\r
102                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
103                         __asm(" POPW  A ");                                                                             \\r
104                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
105                                 __asm(" PUSHW  A ");                                                                    \\r
106                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
107                                 __asm(" POPW  A ");                                                                             \\r
108                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
109                                 __asm(" PUSHW  A ");                                                                    \\r
110                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
111                                 __asm(" POPW  A ");                                                                             \\r
112                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
113                                 __asm(" PUSHW  A ");                                                                    \\r
114                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
115                                 __asm(" POPW  A ");                                                                             \\r
116                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
117                                 __asm(" PUSHW  A ");                                                                    \\r
118                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
119                                 __asm(" POPW  A ");                                                                             \\r
120                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
121                                 __asm(" PUSHW  A ");                                                                    \\r
122                                 __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
123                                 __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
124                                 __asm(" MOVW A, SP ");                                                                  \\r
125                                 __asm(" SWAPW ");                                                                               \\r
126                                 __asm(" MOVW @AL, AH ");                                                                \\r
127                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
128                         }\r
129 \r
130 /* \r
131  * Macro to restore a task context from the task stack.  This is effecti-\r
132  * vely the reverse of SAVE_CONTEXT(). First the stack pointer  value\r
133  * (USP for SMALL and MEDIUM memory model amd  USB:USP  for  COMPACT  and \r
134  * LARGE memory model ) is loaded from the task  control block.  Next the \r
135  * value of all the general purpose registers RW0-RW7 is retrieved. Fina-\r
136  * lly it copies of the context ( AH:AL,  DPR:ADB, DTB:PCB, PC and PS) of \r
137  * the task to be executed upon RETI from user stack to system stack.  \r
138  */\r
139  \r
140         #define portRESTORE_CONTEXT()                                                                           \\r
141                         {       __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
142                                 __asm(" MOVW A, @A ");                                                                  \\r
143                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
144                                 __asm(" MOVW SP, A ");                                                                  \\r
145                                 __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
146                                 __asm(" POPW  A ");                                                                             \\r
147                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
148                                 __asm(" PUSHW  A ");                                                                    \\r
149                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
150                                 __asm(" POPW  A ");                                                                             \\r
151                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
152                                 __asm(" PUSHW  A ");                                                                    \\r
153                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
154                                 __asm(" POPW  A ");                                                                             \\r
155                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
156                                 __asm(" PUSHW  A ");                                                                    \\r
157                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
158                                 __asm(" POPW  A ");                                                                             \\r
159                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
160                                 __asm(" PUSHW  A ");                                                                    \\r
161                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
162                                 __asm(" POPW  A ");                                                                             \\r
163                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
164                                 __asm(" PUSHW  A ");                                                                    \\r
165                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
166                                 __asm(" POPW  A ");                                                                             \\r
167                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
168                                 __asm(" PUSHW  A ");                                                                    \\r
169                         }\r
170                 \r
171 #elif( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
172 \r
173         #define portSAVE_CONTEXT()                                                                                      \\r
174                         {       __asm(" POPW  A ");                                                                             \\r
175                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
176                                 __asm(" PUSHW  A ");                                                                    \\r
177                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
178                         __asm(" POPW  A ");                                                                             \\r
179                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
180                                 __asm(" PUSHW  A ");                                                                    \\r
181                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
182                                 __asm(" POPW  A ");                                                                             \\r
183                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
184                                 __asm(" PUSHW  A ");                                                                    \\r
185                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
186                                 __asm(" POPW  A ");                                                                             \\r
187                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
188                                 __asm(" PUSHW  A ");                                                                    \\r
189                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
190                                 __asm(" POPW  A ");                                                                             \\r
191                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
192                                 __asm(" PUSHW  A ");                                                                    \\r
193                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
194                                 __asm(" POPW  A ");                                                                             \\r
195                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
196                                 __asm(" PUSHW  A ");                                                                    \\r
197                                 __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
198                                 __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
199                                 __asm(" MOVL RL2, A ");                                                                 \\r
200                                 __asm(" MOVW A, SP ");                                                                  \\r
201                                 __asm(" MOVW @RL2+0, A ");                                                              \\r
202                                 __asm(" MOV A, USB ");                                                                  \\r
203                                 __asm(" MOV @RL2+2, A ");                                                               \\r
204                         }       \r
205             \r
206         #define portRESTORE_CONTEXT()                                                                           \\r
207                         {       __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
208                                 __asm(" MOVL RL2, A ");                                                                 \\r
209                                 __asm(" MOVW A, @RL2+0 ");                                                              \\r
210                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
211                                 __asm(" MOVW SP, A ");                                                                  \\r
212                                 __asm(" MOV A, @RL2+2 ");                                                               \\r
213                                 __asm(" MOV USB, A ");                                                                  \\r
214                                 __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
215                                 __asm(" POPW  A ");                                                                             \\r
216                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
217                                 __asm(" PUSHW  A ");                                                                    \\r
218                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
219                                 __asm(" POPW  A ");                                                                             \\r
220                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
221                                 __asm(" PUSHW  A ");                                                                    \\r
222                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
223                                 __asm(" POPW  A ");                                                                             \\r
224                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
225                                 __asm(" PUSHW  A ");                                                                    \\r
226                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
227                                 __asm(" POPW  A ");                                                                             \\r
228                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
229                                 __asm(" PUSHW  A ");                                                                    \\r
230                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
231                                 __asm(" POPW  A ");                                                                             \\r
232                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
233                                 __asm(" PUSHW  A ");                                                                    \\r
234                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
235                                 __asm(" POPW  A ");                                                                             \\r
236                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
237                                 __asm(" PUSHW  A ");                                                                    \\r
238                         }\r
239 #endif\r
240 \r
241 /*-----------------------------------------------------------*/ \r
242 \r
243 /* \r
244  * Functions for obtaining the current value  of  DPR:ADB, DTB:PCB bank registers\r
245  */\r
246  \r
247 #pragma asm\r
248 \r
249         .GLOBAL    _xGet_DPR_ADB_bank\r
250         .GLOBAL    _xGet_DTB_PCB_bank\r
251         .SECTION   CODE, CODE, ALIGN=1\r
252 \r
253 _xGet_DPR_ADB_bank:\r
254 \r
255     MOV A, DPR\r
256     SWAP\r
257     MOV A, ADB\r
258     ORW A\r
259         #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
260                 RETP\r
261         #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
262                 RET\r
263         #endif \r
264 \r
265 \r
266 _xGet_DTB_PCB_bank:\r
267 \r
268     MOV A, DTB\r
269     SWAP\r
270     MOV A, PCB\r
271     ORW A\r
272         #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
273                 RETP\r
274         #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
275                 RET\r
276         #endif \r
277 \r
278 #pragma endasm\r
279 /*-----------------------------------------------------------*/\r
280 \r
281 /* \r
282  * Initialise the stack of a task to look exactly as if a call to \r
283  * portSAVE_CONTEXT had been called.\r
284  * \r
285  * See the header file portable.h.\r
286  */\r
287 portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
288 {\r
289         /* Place a few bytes of known values on the bottom of the stack. \r
290         This is just useful for debugging. */\r
291         *pxTopOfStack = 0x1111;\r
292         pxTopOfStack--;\r
293         *pxTopOfStack = 0x2222;\r
294         pxTopOfStack--;\r
295         *pxTopOfStack = 0x3333;\r
296         pxTopOfStack--;\r
297 \r
298         /* Once the task is called the task  would  push  the  pointer to the\r
299         parameter onto the stack. Hence here the pointer would be copied to the stack\r
300         first.  When using the COMPACT or LARGE memory model the pointer would be 24 \r
301         bits, and when using the SMALL or MEDIUM memory model the pointer would be 16 \r
302         bits. */ \r
303         #if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
304         {\r
305                 *pxTopOfStack = ( portSTACK_TYPE ) ( ( unsigned portLONG ) ( pvParameters ) >> 16 );\r
306                 pxTopOfStack--;         \r
307         }\r
308         #endif\r
309 \r
310     *pxTopOfStack = ( portSTACK_TYPE ) ( pvParameters );\r
311     pxTopOfStack--;                  \r
312     \r
313     /* This is redundant push to the stack. This is required in order to introduce \r
314     an offset so that the task accesses a parameter correctly that is passed on to \r
315     the task stack. */\r
316         #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
317         {\r
318                 *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( portLONG ) ( pxCode ) >> 16 ) & 0xff );      \r
319                 pxTopOfStack--;       \r
320         }\r
321         #endif\r
322 \r
323     /* This is redundant push to the stack. This is required in order to introduce \r
324     an offset so the task correctly accesses the parameter passed on the task stack. */\r
325     *pxTopOfStack = ( portSTACK_TYPE ) ( pxCode );\r
326     pxTopOfStack--;       \r
327 \r
328     /* PS - User Mode, ILM=7, RB=0, Interrupts enabled,USP */\r
329     *pxTopOfStack = 0xE0C0;                                                     \r
330         pxTopOfStack--; \r
331 \r
332         /* PC */\r
333         *pxTopOfStack = ( portSTACK_TYPE ) ( pxCode );     \r
334     pxTopOfStack--;      \r
335     \r
336     /* DTB | PCB */\r
337         #if configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT\r
338         {\r
339                 *pxTopOfStack = xGet_DTB_PCB_bank();            \r
340                 pxTopOfStack--;\r
341         }\r
342         #endif\r
343 \r
344         /* DTB | PCB, in case of MEDIUM and LARGE memory models, PCB would be used\r
345         along with PC to indicate the start address of the function. */\r
346         #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
347         {\r
348                 *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( portLONG ) ( pxCode ) >> 16 ) & 0xff );\r
349                 pxTopOfStack--;       \r
350         }\r
351         #endif\r
352 \r
353         /* DPR | ADB  */\r
354         *pxTopOfStack = xGet_DPR_ADB_bank();                            \r
355         pxTopOfStack--;\r
356     \r
357         /* AL */\r
358         *pxTopOfStack = ( portSTACK_TYPE ) 0x9999;              \r
359         pxTopOfStack--;\r
360 \r
361         /* AH */\r
362         *pxTopOfStack = ( portSTACK_TYPE ) 0xAAAA;              \r
363         pxTopOfStack--;\r
364         \r
365         /* Next the general purpose registers. */\r
366         *pxTopOfStack = ( portSTACK_TYPE ) 0x7777;      /* RW7 */\r
367         pxTopOfStack--;\r
368         *pxTopOfStack = ( portSTACK_TYPE ) 0x6666;      /* RW6 */\r
369         pxTopOfStack--;\r
370         *pxTopOfStack = ( portSTACK_TYPE ) 0x5555;      /* RW5 */\r
371         pxTopOfStack--;\r
372         *pxTopOfStack = ( portSTACK_TYPE ) 0x4444;      /* RW4 */\r
373         pxTopOfStack--;\r
374         *pxTopOfStack = ( portSTACK_TYPE ) 0x3333;      /* RW3 */\r
375         pxTopOfStack--;\r
376         *pxTopOfStack = ( portSTACK_TYPE ) 0x2222;      /* RW2 */\r
377         pxTopOfStack--;\r
378         *pxTopOfStack = ( portSTACK_TYPE ) 0x1111;      /* RW1 */\r
379         pxTopOfStack--;\r
380         *pxTopOfStack = ( portSTACK_TYPE ) 0x8888;      /* RW0 */\r
381                 \r
382         return pxTopOfStack;\r
383 }\r
384 /*-----------------------------------------------------------*/\r
385 \r
386 static void prvSetupRLT0Interrupt( void )\r
387 {\r
388 /* The peripheral clock divided by 16 is used by the timer. */\r
389 const unsigned portSHORT usReloadValue = ( unsigned portSHORT ) ( ( ( configCLKP1_CLOCK_HZ / configTICK_RATE_HZ ) / 16UL ) - 1UL );\r
390 \r
391         /* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */\r
392         TMRLR0 = usReloadValue;    \r
393     \r
394     /* prescaler 1:16, reload, interrupt enable, count enable, trigger */\r
395     TMCSR0 = 0x041B;    \r
396 }\r
397 /*-----------------------------------------------------------*/\r
398 \r
399 portBASE_TYPE xPortStartScheduler( void )\r
400 {\r
401         /* Setup the hardware to generate the tick. */\r
402         prvSetupRLT0Interrupt();\r
403         \r
404         /* Restore the context of the first task that is going to run. */\r
405         portRESTORE_CONTEXT();\r
406 \r
407         /* Simulate a function call end as generated by the compiler.  We will now\r
408         jump to the start of the task the context of which we have just restored. */    \r
409         __asm(" reti ");\r
410 \r
411 \r
412         /* Should not get here. */\r
413         return pdTRUE;\r
414 }\r
415 /*-----------------------------------------------------------*/\r
416 \r
417 void vPortEndScheduler( void )\r
418 {\r
419         /* Not implemented - unlikely to ever be required as there is nothing to\r
420         return to. */\r
421 }\r
422 \r
423 /*-----------------------------------------------------------*/\r
424 \r
425 /* \r
426  * The interrupt service routine used depends on whether the pre-emptive\r
427  * scheduler is being used or not.\r
428  */\r
429 \r
430 #if configUSE_PREEMPTION == 1\r
431 \r
432         /* \r
433          * Tick ISR for preemptive scheduler.  We can use a __nosavereg attribute\r
434          * as the context is to be saved by the portSAVE_CONTEXT() macro, not the\r
435          * compiler generated code.  The tick count is incremented after the context \r
436          * is saved. \r
437          */\r
438         __nosavereg __interrupt void prvRLT0_TICKISR( void )\r
439         {\r
440                 /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */\r
441                 __DI();\r
442                 \r
443                 /* Save the context of the interrupted task. */\r
444                 portSAVE_CONTEXT();\r
445                 \r
446                 /* Enable interrupts */\r
447                 __EI();\r
448                 \r
449                 /* Clear RLT0 interrupt flag */\r
450                 TMCSR0_UF = 0;      \r
451                 \r
452                 /* Increment the tick count then switch to the highest priority task\r
453                 that is ready to run. */\r
454                 vTaskIncrementTick();\r
455                 vTaskSwitchContext();\r
456 \r
457                 /* Disable interrupts so that portRESTORE_CONTEXT() is not interrupted */\r
458                 __DI();\r
459                 \r
460                 /* Restore the context of the new task. */\r
461                 portRESTORE_CONTEXT();\r
462                 \r
463                 /* Enable interrupts */\r
464                 __EI();\r
465         }\r
466 \r
467 #else\r
468 \r
469         /*\r
470          * Tick ISR for the cooperative scheduler.  All this does is increment the\r
471          * tick count.  We don't need to switch context, this can only be done by\r
472          * manual calls to taskYIELD();\r
473          */\r
474         __interrupt void prvRLT0_TICKISR( void )\r
475         {\r
476                 /* Clear RLT0 interrupt flag */\r
477                 TMCSR0_UF = 0;  \r
478                 \r
479                 vTaskIncrementTick();\r
480         }\r
481 \r
482 #endif\r
483 \r
484 /*-----------------------------------------------------------*/\r
485 \r
486 /*\r
487  * Manual context switch. We can use a __nosavereg attribute  as the context \r
488  * is to be saved by the portSAVE_CONTEXT() macro, not the compiler generated \r
489  * code.\r
490  */\r
491 __nosavereg __interrupt void vPortYield( void )\r
492 {\r
493         /* Save the context of the interrupted task. */\r
494         portSAVE_CONTEXT();\r
495         \r
496         /* Switch to the highest priority task that is ready to run. */\r
497         vTaskSwitchContext();\r
498         \r
499         /* Restore the context of the new task. */\r
500         portRESTORE_CONTEXT();\r
501 }\r
502 /*-----------------------------------------------------------*/\r
503 \r
504 __nosavereg __interrupt void vPortYieldDelayed( void )\r
505 {    \r
506     /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */      \r
507         __DI();\r
508         \r
509         /* Save the context of the interrupted task. */\r
510         portSAVE_CONTEXT();\r
511         \r
512         /* Enable interrupts */\r
513         __EI();\r
514                                 \r
515         /* Clear delayed interrupt flag */\r
516     __asm (" CLRB  03A4H:0 ");\r
517         \r
518         /* Switch to the highest priority task that is ready to run. */\r
519         vTaskSwitchContext();\r
520         \r
521         /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */   \r
522         __DI();\r
523         \r
524         /* Restore the context of the new task. */\r
525         portRESTORE_CONTEXT();\r
526 \r
527         /* Enable interrupts */\r
528         __EI();\r
529 }       \r
530 /*-----------------------------------------------------------*/\r
531 \r