]> begriffs open source - freertos/blob - portable/CodeWarrior/ColdFire_V2/portasm.S
[AUTO][RELEASE]: Bump file header version to "11.2.0"
[freertos] / portable / CodeWarrior / ColdFire_V2 / portasm.S
1 /*
2  * FreeRTOS Kernel V11.2.0
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 /*
30  * Purpose: Lowest level routines for all ColdFire processors.
31  *
32  * Notes:
33  *
34  * ulPortSetIPL() and mcf5xxx_wr_cacr() copied with permission from FreeScale
35  * supplied source files.
36  */
37
38     .global ulPortSetIPL
39     .global _ulPortSetIPL
40     .global mcf5xxx_wr_cacrx
41     .global _mcf5xxx_wr_cacrx
42     .global vPortYieldISR
43     .global _vPortYieldISR
44     .global vPortStartFirstTask
45     .global _vPortStartFirstTask
46     .extern _pxCurrentTCB
47     .extern _vPortYieldHandler
48
49     .text
50
51 .macro portSAVE_CONTEXT
52
53     lea.l       (-60, sp), sp
54     movem.l     d0-a6, (sp)
55     move.l      _pxCurrentTCB, a0
56     move.l      sp, (a0)
57
58     .endm
59
60 .macro portRESTORE_CONTEXT
61
62     move.l      _pxCurrentTCB, a0
63     move.l      (a0), sp
64     movem.l     (sp), d0-a6
65     lea.l       (60, sp), sp
66     rte
67
68     .endm
69
70 /********************************************************************/
71 /*
72  * This routines changes the IPL to the value passed into the routine.
73  * It also returns the old IPL value back.
74  * Calling convention from C:
75  *   old_ipl = asm_set_ipl(new_ipl);
76  * For the Diab Data C compiler, it passes return value thru D0.
77  * Note that only the least significant three bits of the passed
78  * value are used.
79  */
80
81 ulPortSetIPL:
82 _ulPortSetIPL:
83     link    A6,#-8
84     movem.l D6-D7,(SP)
85
86     move.w  SR,D7       /* current sr    */
87
88     move.l  D7,D0       /* prepare return value  */
89     andi.l  #0x0700,D0  /* mask out IPL  */
90     lsr.l   #8,D0       /* IPL   */
91
92     move.l  8(A6),D6    /* get argument  */
93     andi.l  #0x07,D6    /* least significant three bits  */
94     lsl.l   #8,D6       /* move over to make mask    */
95
96     andi.l  #0x0000F8FF,D7  /* zero out current IPL  */
97     or.l    D6,D7           /* place new IPL in sr   */
98     move.w  D7,SR
99
100     movem.l (SP),D6-D7
101     lea     8(SP),SP
102     unlk    A6
103     rts
104 /********************************************************************/
105
106 mcf5xxx_wr_cacrx:
107 _mcf5xxx_wr_cacrx:
108     move.l  4(sp),d0
109     .long   0x4e7b0002  /* movec d0,cacr   */
110     nop
111     rts
112
113 /********************************************************************/
114
115 /* Yield interrupt. */
116 _vPortYieldISR:
117 vPortYieldISR:
118     portSAVE_CONTEXT
119     jsr _vPortYieldHandler
120     portRESTORE_CONTEXT
121
122 /********************************************************************/
123
124
125 vPortStartFirstTask:
126 _vPortStartFirstTask:
127     portRESTORE_CONTEXT
128
129     .end