]> begriffs open source - freertos/blob - portable/CodeWarrior/ColdFire_V1/portasm.S
SMP version (#401)
[freertos] / portable / CodeWarrior / ColdFire_V1 / portasm.S
1 /*
2  * FreeRTOS Kernel V202110.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * https://www.FreeRTOS.org
23  * https://github.com/FreeRTOS
24  *
25  * 1 tab == 4 spaces!
26  */
27
28 /*
29  * Purpose: Lowest level routines for all ColdFire processors.
30  *
31  * Notes:
32  * 
33  * ulPortSetIPL() and mcf5xxx_wr_cacr() copied with permission from FreeScale
34  * supplied source files.
35  */
36
37     .global ulPortSetIPL
38     .global _ulPortSetIPL
39     .global mcf5xxx_wr_cacrx
40     .global _mcf5xxx_wr_cacrx
41     .global vPortYieldISR
42     .global _vPortYieldISR
43     .global vPortStartFirstTask
44     .global _vPortStartFirstTask
45     .extern _pxCurrentTCB
46     .extern _vPortYieldHandler
47
48     .text
49
50 .macro portSAVE_CONTEXT
51
52         lea.l           (-60, sp), sp
53         movem.l         d0-a6, (sp)
54         move.l          _pxCurrentTCB, a0
55         move.l          sp, (a0)
56
57         .endm
58
59 .macro portRESTORE_CONTEXT
60
61         move.l          _pxCurrentTCB, a0
62         move.l          (a0), sp
63         movem.l         (sp), d0-a6
64         lea.l           (60, sp), sp
65         rte
66
67         .endm
68
69 /********************************************************************/
70 /*
71  * This routines changes the IPL to the value passed into the routine.
72  * It also returns the old IPL value back.
73  * Calling convention from C:
74  *   old_ipl = asm_set_ipl(new_ipl);
75  * For the Diab Data C compiler, it passes return value thru D0.
76  * Note that only the least significant three bits of the passed
77  * value are used.
78  */
79
80 ulPortSetIPL:
81 _ulPortSetIPL:
82     link    A6,#-8
83     movem.l D6-D7,(SP)
84
85     move.w  SR,D7       /* current sr    */
86
87     move.l  D7,D6       /* prepare return value  */
88     andi.l  #0x0700,D6  /* mask out IPL  */
89     lsr.l   #8,D6       /* IPL   */
90
91     andi.l  #0x07,D0    /* least significant three bits  */
92     lsl.l   #8,D0       /* move over to make mask    */
93
94     andi.l  #0x0000F8FF,D7  /* zero out current IPL  */
95     or.l    D0,D7           /* place new IPL in sr   */
96     move.w  D7,SR
97
98         move.l  D6, D0          /* Return value in D0. */
99     movem.l (SP),D6-D7
100     lea     8(SP),SP
101     unlk    A6
102     rts
103 /********************************************************************/
104
105 mcf5xxx_wr_cacrx:
106 _mcf5xxx_wr_cacrx:
107     move.l  4(sp),d0
108     .long   0x4e7b0002  /* movec d0,cacr   */
109     nop
110     rts
111
112 /********************************************************************/
113
114 /* Yield interrupt. */
115 _vPortYieldISR:
116 vPortYieldISR:
117         portSAVE_CONTEXT
118         jsr _vPortYieldHandler
119         portRESTORE_CONTEXT
120
121 /********************************************************************/
122
123
124 vPortStartFirstTask:
125 _vPortStartFirstTask:
126         portRESTORE_CONTEXT
127
128     .end
129
130