]> begriffs open source - freertos/blob - portable/MPLAB/PIC24_dsPIC/portasm_dsPIC.S
FreeRTOS MPU: Remove MPU region number check (#1261)
[freertos] / portable / MPLAB / PIC24_dsPIC / portasm_dsPIC.S
1 /*
2  * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3  * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy of
8  * this software and associated documentation files (the "Software"), to deal in
9  * the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11  * the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * https://www.FreeRTOS.org
25  * https://github.com/FreeRTOS
26  *
27  */
28
29 #if defined( __dsPIC30F__ ) || defined( __dsPIC33F__ )
30
31         .global _vPortYield
32         .extern _vTaskSwitchContext
33         .extern uxCriticalNesting
34
35 _vPortYield:
36
37         PUSH    SR                      /* Save the SR used by the task.... */
38         PUSH    W0                      /* ....then disable interrupts. */
39         MOV     #32, W0
40         MOV     W0, SR
41         PUSH    W1                      /* Save registers to the stack. */
42         PUSH.D  W2
43         PUSH.D  W4
44         PUSH.D  W6
45         PUSH.D  W8
46         PUSH.D  W10
47         PUSH.D  W12
48         PUSH    W14
49         PUSH    RCOUNT
50         PUSH    TBLPAG
51         PUSH    ACCAL
52         PUSH    ACCAH
53         PUSH    ACCAU
54         PUSH    ACCBL
55         PUSH    ACCBH
56         PUSH    ACCBU
57         PUSH    DCOUNT
58         PUSH    DOSTARTL
59         PUSH    DOSTARTH
60         PUSH    DOENDL
61         PUSH    DOENDH
62
63
64         PUSH    CORCON
65         PUSH    PSVPAG
66         MOV     _uxCriticalNesting, W0      /* Save the critical nesting counter for the task. */
67         PUSH    W0
68         MOV     _pxCurrentTCB, W0           /* Save the new top of stack into the TCB. */
69         MOV     W15, [W0]
70
71         call    _vTaskSwitchContext
72
73         MOV     _pxCurrentTCB, W0           /* Restore the stack pointer for the task. */
74         MOV     [W0], W15
75         POP     W0                          /* Restore the critical nesting counter for the task. */
76         MOV     W0, _uxCriticalNesting
77         POP     PSVPAG
78         POP     CORCON
79         POP     DOENDH
80         POP     DOENDL
81         POP     DOSTARTH
82         POP     DOSTARTL
83         POP     DCOUNT
84         POP     ACCBU
85         POP     ACCBH
86         POP     ACCBL
87         POP     ACCAU
88         POP     ACCAH
89         POP     ACCAL
90         POP     TBLPAG
91         POP     RCOUNT                      /* Restore the registers from the stack. */
92         POP     W14
93         POP.D   W12
94         POP.D   W10
95         POP.D   W8
96         POP.D   W6
97         POP.D   W4
98         POP.D   W2
99         POP.D   W0
100         POP     SR
101
102         return
103
104         .end
105
106 #endif /* defined( __dsPIC30F__ ) || defined( __dsPIC33F__ ) */