]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_dsPIC.S
Update to MIT licensed FreeRTOS V10.0.0 - see https://www.freertos.org/History.txt
[freertos] / FreeRTOS / Source / portable / MPLAB / PIC24_dsPIC / portasm_dsPIC.S
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 #if defined( __dsPIC30F__ ) || defined( __dsPIC33F__ )\r
30 \r
31         .global _vPortYield\r
32                 .extern _vTaskSwitchContext\r
33                 .extern uxCriticalNesting\r
34 \r
35 _vPortYield:\r
36 \r
37                 PUSH    SR                                              /* Save the SR used by the task.... */\r
38                 PUSH    W0                                              /* ....then disable interrupts. */\r
39                 MOV             #32, W0\r
40                 MOV             W0, SR\r
41                 PUSH    W1                                              /* Save registers to the stack. */\r
42                 PUSH.D  W2\r
43                 PUSH.D  W4\r
44                 PUSH.D  W6\r
45                 PUSH.D  W8\r
46                 PUSH.D  W10\r
47                 PUSH.D  W12\r
48                 PUSH    W14\r
49                 PUSH    RCOUNT\r
50                 PUSH    TBLPAG\r
51                 PUSH    ACCAL\r
52                 PUSH    ACCAH\r
53                 PUSH    ACCAU\r
54                 PUSH    ACCBL\r
55                 PUSH    ACCBH\r
56                 PUSH    ACCBU\r
57                 PUSH    DCOUNT\r
58                 PUSH    DOSTARTL\r
59                 PUSH    DOSTARTH\r
60                 PUSH    DOENDL\r
61                 PUSH    DOENDH\r
62 \r
63 \r
64                 PUSH    CORCON\r
65                 PUSH    PSVPAG\r
66                 MOV             _uxCriticalNesting, W0          /* Save the critical nesting counter for the task. */\r
67                 PUSH    W0\r
68                 MOV             _pxCurrentTCB, W0                       /* Save the new top of stack into the TCB. */\r
69                 MOV             W15, [W0]\r
70 \r
71                 call    _vTaskSwitchContext\r
72 \r
73                 MOV             _pxCurrentTCB, W0                       /* Restore the stack pointer for the task. */\r
74                 MOV             [W0], W15\r
75                 POP             W0                                                      /* Restore the critical nesting counter for the task. */\r
76                 MOV             W0, _uxCriticalNesting\r
77                 POP             PSVPAG\r
78                 POP             CORCON\r
79                 POP             DOENDH\r
80                 POP             DOENDL\r
81                 POP             DOSTARTH\r
82                 POP             DOSTARTL\r
83                 POP             DCOUNT\r
84                 POP             ACCBU\r
85                 POP             ACCBH\r
86                 POP             ACCBL\r
87                 POP             ACCAU\r
88                 POP             ACCAH\r
89                 POP             ACCAL\r
90                 POP             TBLPAG\r
91                 POP             RCOUNT                                          /* Restore the registers from the stack. */\r
92                 POP             W14\r
93                 POP.D   W12\r
94                 POP.D   W10\r
95                 POP.D   W8\r
96                 POP.D   W6\r
97                 POP.D   W4\r
98                 POP.D   W2\r
99                 POP.D   W0\r
100                 POP             SR\r
101 \r
102         return\r
103 \r
104         .end\r
105 \r
106 #endif /* defined( __dsPIC30F__ ) || defined( __dsPIC33F__ ) */\r
107 \r