]> rtime.felk.cvut.cz Git - rpp-test-sw.git/blob - rpp/lib/os/7.0.2_tms570/src/os/portASM.asm
Yet another place to fix
[rpp-test-sw.git] / rpp / lib / os / 7.0.2_tms570 / src / os / portASM.asm
1 ;/*
2 ;    FreeRTOS V7.0.2 - Copyright (C) 2011 Real Time Engineers Ltd.
3 ;
4 ;
5 ;    ***************************************************************************
6 ;     *                                                                       *
7 ;     *    FreeRTOS tutorial books are available in pdf and paperback.        *
8 ;     *    Complete, revised, and edited pdf reference manuals are also       *
9 ;     *    available.                                                         *
10 ;     *                                                                       *
11 ;     *    Purchasing FreeRTOS documentation will not only help you, by       *
12 ;     *    ensuring you get running as quickly as possible and with an        *
13 ;     *    in-depth knowledge of how to use FreeRTOS, it will also help       *
14 ;     *    the FreeRTOS project to continue with its mission of providing     *
15 ;     *    professional grade, cross platform, de facto standard solutions    *
16 ;     *    for microcontrollers - completely free of charge!                  *
17 ;     *                                                                       *
18 ;     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *
19 ;     *                                                                       *
20 ;     *    Thank you for using FreeRTOS, and thank you for your support!      *
21 ;     *                                                                       *
22 ;    ***************************************************************************
23 ;
24 ;
25 ;    This file is part of the FreeRTOS distribution.
26 ;
27 ;    FreeRTOS is free software; you can redistribute it and/or modify it under
28 ;    the terms of the GNU General Public License (version 2) as published by the
29 ;    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
30 ;    >>>NOTE<<< The modification to the GPL is included to allow you to
31 ;    distribute a combined work that includes FreeRTOS without being obliged to
32 ;    provide the source code for proprietary components outside of the FreeRTOS
33 ;    kernel.  FreeRTOS is distributed in the hope that it will be useful, but
34 ;    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
35 ;    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
36 ;    more details. You should have received a copy of the GNU General Public
37 ;    License and the FreeRTOS license exception along with FreeRTOS; if not it
38 ;    can be viewed here: http://www.freertos.org/a00114.html and also obtained
39 ;    by writing to Richard Barry, contact details for whom are available on the
40 ;    FreeRTOS WEB site.
41 ;
42 ;    1 tab == 4 spaces!
43 ;
44 ;    http://www.FreeRTOS.org - Documentation, latest information, license and
45 ;    contact details.
46 ;
47 ;    http://www.SafeRTOS.com - A version that is certified for use in safety
48 ;    critical systems.
49 ;
50 ;    http://www.OpenRTOS.com - Commercial support, development, porting,
51 ;    licensing and training services.
52 ;*/
53
54         .text
55         .arm
56
57
58 ;-------------------------------------------------------------------------------
59 ; Save Task Context
60 ;
61 portSAVE_CONTEXT .macro
62         stmfd   sp!, {r0}
63         stmfd   sp,  {sp}^
64         sub     sp,  sp, #4
65         ldmfd   sp!, {r0}
66         stmfd   r0!, {lr}
67         mov     lr,  r0
68         ldmfd   sp!, {r0}
69         stmfd   lr,  {r0-lr}^
70         sub     lr,  lr, #0x3C
71         fstmdbd lr!, {d0-d15}
72         mrs     r0,  spsr
73         fmrx    r1,  fpscr
74         stmfd   lr!, {r0,r1}
75         ldr     r0, critNest
76         ldr     r0, [r0]
77         stmfd   lr!, {r0}
78         ldr     r0,  curTCB
79         ldr     r0,  [r0]
80         str     lr,  [r0]
81         .endm
82
83 ;-------------------------------------------------------------------------------
84 ; Restore Task Context
85 ;
86 portRESTORE_CONTEXT .macro
87         ldr     r0,  curTCB
88         ldr     r0,  [r0]
89         ldr     lr,  [r0]
90         ldr     r0, critNest
91         ldmfd   lr!, {r1}
92         str r1, [r0]
93         ldmfd   lr!, {r0,r1}
94         fldmiad lr!, {d0-d15}
95         fmxr    fpscr, r1
96         msr     spsr_csxf, r0
97         ldmfd   lr, {r0-r14}^
98         ldr     lr, [lr, #0x3C]
99         subs    pc, lr, #4
100         .endm
101
102 ;-------------------------------------------------------------------------------
103 ; Start First Task
104
105         .def vPortStartFirstTask
106
107         .asmfunc
108 vPortStartFirstTask
109         portRESTORE_CONTEXT
110         .endasmfunc
111
112 ;-------------------------------------------------------------------------------
113 ; Yield Processor
114
115         .def vPortYieldProcessor
116         .ref vTaskSwitchContext
117
118         .asmfunc
119 vPortYieldProcessor
120         add     lr, lr, #4
121         portSAVE_CONTEXT
122         bl      vTaskSwitchContext
123         portRESTORE_CONTEXT
124         .endasmfunc
125
126 ;-------------------------------------------------------------------------------
127 ; Preemptive Tick
128
129         .def vPreemptiveTick
130         .ref vTaskIncrementTick
131
132         .asmfunc
133 vPreemptiveTick
134         portSAVE_CONTEXT
135         stmfd   sp!,         {r0, r1}
136         ; clear interrupt flag
137         ldr     r0,          intFlag
138         mov     r1,          #1
139         str     r1,          [r0]
140         bl      vTaskIncrementTick
141         bl      vTaskSwitchContext
142         ldmfd   sp!,         {r0, r1}
143         portRESTORE_CONTEXT
144     .endasmfunc
145
146
147 ;-------------------------------------------------------------------------------
148 ; isr stub
149
150
151 ;-------------------------------------------------------------------------------
152 ; Port yield
153
154        .def vPortYield
155
156         .asmfunc
157 vPortYield
158             svc   #0
159             bx    lr
160         .endasmfunc
161
162 ;-------------------------------------------------------------------------------
163 ; Global Definitions
164
165           .ref  pxCurrentTCB
166           .ref  ulCriticalNesting
167
168 intFlag   .word 0xFFFFFC88
169 curTCB    .word pxCurrentTCB
170 critNest  .word ulCriticalNesting
171
172
173
174 ;-------------------------------------------------------------------------------
175