]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/Softune/MB96340/port.c
Update license information text files for the CLI, TCP and UDP products to be correct...
[freertos] / FreeRTOS / Source / portable / Softune / MB96340 / port.c
1 /*\r
2  * FreeRTOS Kernel V10.0.0\r
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software. If you wish to use our Amazon\r
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
15  *\r
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29 #include "FreeRTOS.h"\r
30 #include "task.h"\r
31 \r
32 /*-----------------------------------------------------------\r
33  * Implementation of functions defined in portable.h for the 16FX port.\r
34  *----------------------------------------------------------*/\r
35 \r
36 /* \r
37  * Get current value of DPR and ADB registers \r
38  */\r
39 StackType_t xGet_DPR_ADB_bank( void ); \r
40 \r
41 /* \r
42  * Get current value of DTB and PCB registers \r
43  */\r
44 StackType_t xGet_DTB_PCB_bank( void );\r
45 \r
46 /*\r
47  * Sets up the periodic ISR used for the RTOS tick.  This uses RLT0, but\r
48  * can be done using any given RLT.\r
49  */\r
50 static void prvSetupRLT0Interrupt( void );\r
51 \r
52 /*-----------------------------------------------------------*/\r
53 \r
54 /* \r
55  * We require the address of the pxCurrentTCB variable, but don't want to know\r
56  * any details of its type. \r
57  */\r
58 typedef void TCB_t;\r
59 extern volatile TCB_t * volatile pxCurrentTCB;\r
60 \r
61 /*-----------------------------------------------------------*/\r
62 \r
63 /* \r
64  * Macro to save a task context to the task stack. This macro  copies the \r
65  * saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from  the   system \r
66  * stack to task stack pointed by user stack pointer ( USP  for SMALL and \r
67  * MEDIUM memory model amd USB:USP for COMPACT  and LARGE memory model ),\r
68  * then  it pushes the general purpose registers RW0-RW7  on  to the task \r
69  * stack. Finally the  resultant  stack  pointer  value is saved into the \r
70  * task  control  block  so  it  can  be retrieved the next time the task \r
71  * executes.\r
72  */ \r
73 #if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )\r
74 \r
75         #define portSAVE_CONTEXT()                                                                                      \\r
76                         {       __asm(" POPW  A ");                                                                             \\r
77                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
78                                 __asm(" PUSHW  A ");                                                                    \\r
79                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
80                         __asm(" POPW  A ");                                                                             \\r
81                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
82                                 __asm(" PUSHW  A ");                                                                    \\r
83                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
84                                 __asm(" POPW  A ");                                                                             \\r
85                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
86                                 __asm(" PUSHW  A ");                                                                    \\r
87                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
88                                 __asm(" POPW  A ");                                                                             \\r
89                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
90                                 __asm(" PUSHW  A ");                                                                    \\r
91                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
92                                 __asm(" POPW  A ");                                                                             \\r
93                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
94                                 __asm(" PUSHW  A ");                                                                    \\r
95                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
96                                 __asm(" POPW  A ");                                                                             \\r
97                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
98                                 __asm(" PUSHW  A ");                                                                    \\r
99                                 __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
100                                 __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
101                                 __asm(" MOVW A, SP ");                                                                  \\r
102                                 __asm(" SWAPW ");                                                                               \\r
103                                 __asm(" MOVW @AL, AH ");                                                                \\r
104                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
105                         }\r
106 \r
107 /* \r
108  * Macro to restore a task context from the task stack.  This is effecti-\r
109  * vely the reverse of SAVE_CONTEXT(). First the stack pointer  value\r
110  * (USP for SMALL and MEDIUM memory model amd  USB:USP  for  COMPACT  and \r
111  * LARGE memory model ) is loaded from the task  control block.  Next the \r
112  * value of all the general purpose registers RW0-RW7 is retrieved. Fina-\r
113  * lly it copies of the context ( AH:AL,  DPR:ADB, DTB:PCB, PC and PS) of \r
114  * the task to be executed upon RETI from user stack to system stack.  \r
115  */\r
116  \r
117         #define portRESTORE_CONTEXT()                                                                           \\r
118                         {       __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
119                                 __asm(" MOVW A, @A ");                                                                  \\r
120                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
121                                 __asm(" MOVW SP, A ");                                                                  \\r
122                                 __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
123                                 __asm(" POPW  A ");                                                                             \\r
124                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
125                                 __asm(" PUSHW  A ");                                                                    \\r
126                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
127                                 __asm(" POPW  A ");                                                                             \\r
128                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
129                                 __asm(" PUSHW  A ");                                                                    \\r
130                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
131                                 __asm(" POPW  A ");                                                                             \\r
132                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
133                                 __asm(" PUSHW  A ");                                                                    \\r
134                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
135                                 __asm(" POPW  A ");                                                                             \\r
136                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
137                                 __asm(" PUSHW  A ");                                                                    \\r
138                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
139                                 __asm(" POPW  A ");                                                                             \\r
140                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
141                                 __asm(" PUSHW  A ");                                                                    \\r
142                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
143                                 __asm(" POPW  A ");                                                                             \\r
144                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
145                                 __asm(" PUSHW  A ");                                                                    \\r
146                         }\r
147                 \r
148 #elif( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
149 \r
150         #define portSAVE_CONTEXT()                                                                                      \\r
151                         {       __asm(" POPW  A ");                                                                             \\r
152                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
153                                 __asm(" PUSHW  A ");                                                                    \\r
154                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
155                         __asm(" POPW  A ");                                                                             \\r
156                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
157                                 __asm(" PUSHW  A ");                                                                    \\r
158                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
159                                 __asm(" POPW  A ");                                                                             \\r
160                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
161                                 __asm(" PUSHW  A ");                                                                    \\r
162                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
163                                 __asm(" POPW  A ");                                                                             \\r
164                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
165                                 __asm(" PUSHW  A ");                                                                    \\r
166                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
167                                 __asm(" POPW  A ");                                                                             \\r
168                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
169                                 __asm(" PUSHW  A ");                                                                    \\r
170                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
171                                 __asm(" POPW  A ");                                                                             \\r
172                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
173                                 __asm(" PUSHW  A ");                                                                    \\r
174                                 __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
175                                 __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
176                                 __asm(" MOVL RL2, A ");                                                                 \\r
177                                 __asm(" MOVW A, SP ");                                                                  \\r
178                                 __asm(" MOVW @RL2+0, A ");                                                              \\r
179                                 __asm(" MOV A, USB ");                                                                  \\r
180                                 __asm(" MOV @RL2+2, A ");                                                               \\r
181                         }       \r
182             \r
183         #define portRESTORE_CONTEXT()                                                                           \\r
184                         {       __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
185                                 __asm(" MOVL RL2, A ");                                                                 \\r
186                                 __asm(" MOVW A, @RL2+0 ");                                                              \\r
187                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
188                                 __asm(" MOVW SP, A ");                                                                  \\r
189                                 __asm(" MOV A, @RL2+2 ");                                                               \\r
190                                 __asm(" MOV USB, A ");                                                                  \\r
191                                 __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
192                                 __asm(" POPW  A ");                                                                             \\r
193                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
194                                 __asm(" PUSHW  A ");                                                                    \\r
195                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
196                                 __asm(" POPW  A ");                                                                             \\r
197                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
198                                 __asm(" PUSHW  A ");                                                                    \\r
199                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
200                                 __asm(" POPW  A ");                                                                             \\r
201                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
202                                 __asm(" PUSHW  A ");                                                                    \\r
203                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
204                                 __asm(" POPW  A ");                                                                             \\r
205                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
206                                 __asm(" PUSHW  A ");                                                                    \\r
207                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
208                                 __asm(" POPW  A ");                                                                             \\r
209                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
210                                 __asm(" PUSHW  A ");                                                                    \\r
211                                 __asm(" AND  CCR,#H'DF ");                                                      \\r
212                                 __asm(" POPW  A ");                                                                             \\r
213                                 __asm(" OR   CCR,#H'20 ");                                                              \\r
214                                 __asm(" PUSHW  A ");                                                                    \\r
215                         }\r
216 #endif\r
217 \r
218 /*-----------------------------------------------------------*/ \r
219 \r
220 /* \r
221  * Functions for obtaining the current value  of  DPR:ADB, DTB:PCB bank registers\r
222  */\r
223  \r
224 #pragma asm\r
225 \r
226         .GLOBAL    _xGet_DPR_ADB_bank\r
227         .GLOBAL    _xGet_DTB_PCB_bank\r
228         .SECTION   CODE, CODE, ALIGN=1\r
229 \r
230 _xGet_DPR_ADB_bank:\r
231 \r
232     MOV A, DPR\r
233     SWAP\r
234     MOV A, ADB\r
235     ORW A\r
236         #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
237                 RETP\r
238         #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
239                 RET\r
240         #endif \r
241 \r
242 \r
243 _xGet_DTB_PCB_bank:\r
244 \r
245     MOV A, DTB\r
246     SWAP\r
247     MOV A, PCB\r
248     ORW A\r
249         #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
250                 RETP\r
251         #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
252                 RET\r
253         #endif \r
254 \r
255 #pragma endasm\r
256 /*-----------------------------------------------------------*/\r
257 \r
258 /* \r
259  * Initialise the stack of a task to look exactly as if a call to \r
260  * portSAVE_CONTEXT had been called.\r
261  * \r
262  * See the header file portable.h.\r
263  */\r
264 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )\r
265 {\r
266         /* Place a few bytes of known values on the bottom of the stack. \r
267         This is just useful for debugging. */\r
268         *pxTopOfStack = 0x1111;\r
269         pxTopOfStack--;\r
270         *pxTopOfStack = 0x2222;\r
271         pxTopOfStack--;\r
272         *pxTopOfStack = 0x3333;\r
273         pxTopOfStack--;\r
274 \r
275         /* Once the task is called the task  would  push  the  pointer to the\r
276         parameter onto the stack. Hence here the pointer would be copied to the stack\r
277         first.  When using the COMPACT or LARGE memory model the pointer would be 24 \r
278         bits, and when using the SMALL or MEDIUM memory model the pointer would be 16 \r
279         bits. */ \r
280         #if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
281         {\r
282                 *pxTopOfStack = ( StackType_t ) ( ( uint32_t ) ( pvParameters ) >> 16 );\r
283                 pxTopOfStack--;         \r
284         }\r
285         #endif\r
286 \r
287     *pxTopOfStack = ( StackType_t ) ( pvParameters );\r
288     pxTopOfStack--;                  \r
289     \r
290     /* This is redundant push to the stack. This is required in order to introduce \r
291     an offset so that the task accesses a parameter correctly that is passed on to \r
292     the task stack. */\r
293         #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
294         {\r
295                 *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );      \r
296                 pxTopOfStack--;       \r
297         }\r
298         #endif\r
299 \r
300     /* This is redundant push to the stack. This is required in order to introduce \r
301     an offset so the task correctly accesses the parameter passed on the task stack. */\r
302     *pxTopOfStack = ( StackType_t ) ( pxCode );\r
303     pxTopOfStack--;       \r
304 \r
305     /* PS - User Mode, ILM=7, RB=0, Interrupts enabled,USP */\r
306     *pxTopOfStack = 0xE0C0;                                                     \r
307         pxTopOfStack--; \r
308 \r
309         /* PC */\r
310         *pxTopOfStack = ( StackType_t ) ( pxCode );     \r
311     pxTopOfStack--;      \r
312     \r
313     /* DTB | PCB */\r
314         #if configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT\r
315         {\r
316                 *pxTopOfStack = xGet_DTB_PCB_bank();            \r
317                 pxTopOfStack--;\r
318         }\r
319         #endif\r
320 \r
321         /* DTB | PCB, in case of MEDIUM and LARGE memory models, PCB would be used\r
322         along with PC to indicate the start address of the function. */\r
323         #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
324         {\r
325                 *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( int32_t ) ( pxCode ) >> 16 ) & 0xff );\r
326                 pxTopOfStack--;       \r
327         }\r
328         #endif\r
329 \r
330         /* DPR | ADB  */\r
331         *pxTopOfStack = xGet_DPR_ADB_bank();                            \r
332         pxTopOfStack--;\r
333     \r
334         /* AL */\r
335         *pxTopOfStack = ( StackType_t ) 0x9999;         \r
336         pxTopOfStack--;\r
337 \r
338         /* AH */\r
339         *pxTopOfStack = ( StackType_t ) 0xAAAA;         \r
340         pxTopOfStack--;\r
341         \r
342         /* Next the general purpose registers. */\r
343         *pxTopOfStack = ( StackType_t ) 0x7777; /* RW7 */\r
344         pxTopOfStack--;\r
345         *pxTopOfStack = ( StackType_t ) 0x6666; /* RW6 */\r
346         pxTopOfStack--;\r
347         *pxTopOfStack = ( StackType_t ) 0x5555; /* RW5 */\r
348         pxTopOfStack--;\r
349         *pxTopOfStack = ( StackType_t ) 0x4444; /* RW4 */\r
350         pxTopOfStack--;\r
351         *pxTopOfStack = ( StackType_t ) 0x3333; /* RW3 */\r
352         pxTopOfStack--;\r
353         *pxTopOfStack = ( StackType_t ) 0x2222; /* RW2 */\r
354         pxTopOfStack--;\r
355         *pxTopOfStack = ( StackType_t ) 0x1111; /* RW1 */\r
356         pxTopOfStack--;\r
357         *pxTopOfStack = ( StackType_t ) 0x8888; /* RW0 */\r
358                 \r
359         return pxTopOfStack;\r
360 }\r
361 /*-----------------------------------------------------------*/\r
362 \r
363 static void prvSetupRLT0Interrupt( void )\r
364 {\r
365 /* The peripheral clock divided by 16 is used by the timer. */\r
366 const uint16_t usReloadValue = ( uint16_t ) ( ( ( configCLKP1_CLOCK_HZ / configTICK_RATE_HZ ) / 16UL ) - 1UL );\r
367 \r
368         /* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */\r
369         TMRLR0 = usReloadValue;    \r
370     \r
371     /* prescaler 1:16, reload, interrupt enable, count enable, trigger */\r
372     TMCSR0 = 0x041B;    \r
373 }\r
374 /*-----------------------------------------------------------*/\r
375 \r
376 BaseType_t xPortStartScheduler( void )\r
377 {\r
378         /* Setup the hardware to generate the tick. */\r
379         prvSetupRLT0Interrupt();\r
380         \r
381         /* Restore the context of the first task that is going to run. */\r
382         portRESTORE_CONTEXT();\r
383 \r
384         /* Simulate a function call end as generated by the compiler.  We will now\r
385         jump to the start of the task the context of which we have just restored. */    \r
386         __asm(" reti ");\r
387 \r
388 \r
389         /* Should not get here. */\r
390         return pdTRUE;\r
391 }\r
392 /*-----------------------------------------------------------*/\r
393 \r
394 void vPortEndScheduler( void )\r
395 {\r
396         /* Not implemented - unlikely to ever be required as there is nothing to\r
397         return to. */\r
398 }\r
399 \r
400 /*-----------------------------------------------------------*/\r
401 \r
402 /* \r
403  * The interrupt service routine used depends on whether the pre-emptive\r
404  * scheduler is being used or not.\r
405  */\r
406 \r
407 #if configUSE_PREEMPTION == 1\r
408 \r
409         /* \r
410          * Tick ISR for preemptive scheduler.  We can use a __nosavereg attribute\r
411          * as the context is to be saved by the portSAVE_CONTEXT() macro, not the\r
412          * compiler generated code.  The tick count is incremented after the context \r
413          * is saved. \r
414          */\r
415         __nosavereg __interrupt void prvRLT0_TICKISR( void )\r
416         {\r
417                 /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */\r
418                 __DI();\r
419                 \r
420                 /* Save the context of the interrupted task. */\r
421                 portSAVE_CONTEXT();\r
422                 \r
423                 /* Enable interrupts */\r
424                 __EI();\r
425                 \r
426                 /* Clear RLT0 interrupt flag */\r
427                 TMCSR0_UF = 0;      \r
428                 \r
429                 /* Increment the tick count then switch to the highest priority task\r
430                 that is ready to run. */\r
431                 if( xTaskIncrementTick() != pdFALSE )\r
432                 {\r
433                         vTaskSwitchContext();\r
434                 }\r
435 \r
436                 /* Disable interrupts so that portRESTORE_CONTEXT() is not interrupted */\r
437                 __DI();\r
438                 \r
439                 /* Restore the context of the new task. */\r
440                 portRESTORE_CONTEXT();\r
441                 \r
442                 /* Enable interrupts */\r
443                 __EI();\r
444         }\r
445 \r
446 #else\r
447 \r
448         /*\r
449          * Tick ISR for the cooperative scheduler.  All this does is increment the\r
450          * tick count.  We don't need to switch context, this can only be done by\r
451          * manual calls to taskYIELD();\r
452          */\r
453         __interrupt void prvRLT0_TICKISR( void )\r
454         {\r
455                 /* Clear RLT0 interrupt flag */\r
456                 TMCSR0_UF = 0;  \r
457                 \r
458                 xTaskIncrementTick();\r
459         }\r
460 \r
461 #endif\r
462 \r
463 /*-----------------------------------------------------------*/\r
464 \r
465 /*\r
466  * Manual context switch. We can use a __nosavereg attribute  as the context \r
467  * is to be saved by the portSAVE_CONTEXT() macro, not the compiler generated \r
468  * code.\r
469  */\r
470 __nosavereg __interrupt void vPortYield( void )\r
471 {\r
472         /* Save the context of the interrupted task. */\r
473         portSAVE_CONTEXT();\r
474         \r
475         /* Switch to the highest priority task that is ready to run. */\r
476         vTaskSwitchContext();\r
477         \r
478         /* Restore the context of the new task. */\r
479         portRESTORE_CONTEXT();\r
480 }\r
481 /*-----------------------------------------------------------*/\r
482 \r
483 __nosavereg __interrupt void vPortYieldDelayed( void )\r
484 {    \r
485     /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */      \r
486         __DI();\r
487         \r
488         /* Save the context of the interrupted task. */\r
489         portSAVE_CONTEXT();\r
490         \r
491         /* Enable interrupts */\r
492         __EI();\r
493                                 \r
494         /* Clear delayed interrupt flag */\r
495     __asm (" CLRB  03A4H:0 ");\r
496         \r
497         /* Switch to the highest priority task that is ready to run. */\r
498         vTaskSwitchContext();\r
499         \r
500         /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */   \r
501         __DI();\r
502         \r
503         /* Restore the context of the new task. */\r
504         portRESTORE_CONTEXT();\r
505 \r
506         /* Enable interrupts */\r
507         __EI();\r
508 }       \r
509 /*-----------------------------------------------------------*/\r
510 \r