OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Source/] [portable/] [IAR/] [ATMega323/] [portmacro.s90] - Blame information for rev 609

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 572 jeremybenn
;/*
2
;    FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
3
;
4
;    ***************************************************************************
5
;    *                                                                         *
6
;    * If you are:                                                             *
7
;    *                                                                         *
8
;    *    + New to FreeRTOS,                                                   *
9
;    *    + Wanting to learn FreeRTOS or multitasking in general quickly       *
10
;    *    + Looking for basic training,                                        *
11
;    *    + Wanting to improve your FreeRTOS skills and productivity           *
12
;    *                                                                         *
13
;    * then take a look at the FreeRTOS books - available as PDF or paperback  *
14
;    *                                                                         *
15
;    *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *
16
;    *                  http://www.FreeRTOS.org/Documentation                  *
17
;    *                                                                         *
18
;    * A pdf reference manual is also available.  Both are usually delivered   *
19
;    * to your inbox within 20 minutes to two hours when purchased between 8am *
20
;    * and 8pm GMT (although please allow up to 24 hours in case of            *
21
;    * exceptional circumstances).  Thank you for your support!                *
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 exception to the GPL is included to allow you to distribute
31
;    a combined work that includes FreeRTOS without being obliged to provide the
32
;    source code for proprietary components outside of the FreeRTOS kernel.
33
;    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
34
;    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35
;    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
#include 
55
 
56
; Declare all extern symbols here - including any ISRs that are referenced in
57
; the vector table.
58
 
59
; ISR functions
60
; -------------
61
EXTERN SIG_OUTPUT_COMPARE1A
62
EXTERN SIG_UART_RECV
63
EXTERN SIG_UART_DATA
64
 
65
 
66
; Functions used by scheduler
67
; ---------------------------
68
EXTERN vTaskSwitchContext
69
EXTERN pxCurrentTCB
70
EXTERN vTaskIncrementTick
71
EXTERN uxCriticalNesting
72
 
73
; Functions implemented in this file
74
; ----------------------------------
75
PUBLIC vPortYield
76
PUBLIC vPortYieldFromTick
77
PUBLIC vPortStart
78
 
79
 
80
; Interrupt vector table.
81
; -----------------------
82
;
83
; For simplicity the RTOS tick interrupt routine uses the __task keyword.
84
; As the IAR compiler does not permit a function to be declared using both
85
; __task and __interrupt, the use of __task necessitates that the interrupt
86
; vector table be setup manually.
87
;
88
; To write an ISR, implement the ISR function using the __interrupt keyword
89
; but do not install the interrupt using the "#pragma vector=ABC" method.
90
; Instead manually place the name of the ISR in the vector table using an
91
; ORG and jmp instruction as demonstrated below.
92
; You will also have to add an EXTERN statement at the top of the file.
93
 
94
        ASEG
95
 
96
 
97
        ORG TIMER1_COMPA_vect                           ; Vector address
98
                jmp SIG_OUTPUT_COMPARE1A                ; ISR
99
 
100
        ORG USART_RXC_vect                                      ; Vector address
101
                jmp SIG_UART_RECV                               ; ISR
102
 
103
        ORG USART_UDRE_vect                                     ; Vector address
104
                jmp SIG_UART_DATA                               ; ISR
105
 
106
 
107
        RSEG CODE
108
 
109
 
110
 
111
; Saving and Restoring a Task Context and Task Switching
112
; ------------------------------------------------------
113
;
114
; The IAR compiler does not fully support inline assembler, so saving and
115
; restoring a task context has to be written in an asm file.
116
;
117
; vPortYield() and vPortYieldFromTick() are usually written in C.  Doing
118
; so in this case would required calls to be made to portSAVE_CONTEXT() and
119
; portRESTORE_CONTEXT().  This is dis-advantageous as the context switch
120
; function would require two extra jump and return instructions over the
121
; WinAVR equivalent.
122
;
123
; To avoid this I have opted to implement both vPortYield() and
124
; vPortYieldFromTick() in this assembly file.  For convenience
125
; portSAVE_CONTEXT and portRESTORE_CONTEXT are implemented as macros.
126
 
127
portSAVE_CONTEXT MACRO
128
        st      -y, r0                  ; First save the r0 register - we need to use this.
129
        in      r0, SREG                ; Obtain the SREG value so we can disable interrupts...
130
        cli                                     ; ... as soon as possible.
131
        st      -y, r0                  ; Store the SREG as it was before we disabled interrupts.
132
 
133
        in      r0, SPL                 ; Next store the hardware stack pointer.  The IAR...
134
        st      -y, r0                  ; ... compiler uses the hardware stack as a call stack ...
135
        in      r0, SPH                 ; ...  only.
136
        st      -y, r0
137
 
138
        st      -y, r1                  ; Now store the rest of the registers.  Dont store the ...
139
        st      -y, r2                  ; ... the Y register here as it is used as the software
140
        st      -y, r3                  ; stack pointer and will get saved into the TCB.
141
        st      -y, r4
142
        st      -y, r5
143
        st      -y, r6
144
        st      -y, r7
145
        st      -y, r8
146
        st      -y, r9
147
        st      -y, r10
148
        st      -y, r11
149
        st      -y, r12
150
        st      -y, r13
151
        st      -y, r14
152
        st      -y, r15
153
        st      -y, r16
154
        st      -y, r17
155
        st      -y, r18
156
        st      -y, r19
157
        st      -y, r20
158
        st      -y, r21
159
        st      -y, r22
160
        st      -y, r23
161
        st      -y, r24
162
        st      -y, r25
163
        st      -y, r26
164
        st      -y, r27
165
        st      -y, r30
166
        st      -y, r31
167
        lds r0, uxCriticalNesting
168
        st      -y, r0                                  ; Store the critical nesting counter.
169
 
170
        lds     r26, pxCurrentTCB               ; Finally save the software stack pointer (Y ...
171
        lds     r27, pxCurrentTCB + 1   ; ... register) into the TCB.
172
        st      x+, r28
173
        st      x+, r29
174
 
175
        ENDM
176
 
177
 
178
portRESTORE_CONTEXT MACRO
179
        lds     r26, pxCurrentTCB
180
        lds     r27, pxCurrentTCB + 1   ; Restore the software stack pointer from ...
181
        ld      r28, x+                                 ; the TCB into the software stack pointer (...
182
        ld      r29, x+                                 ; ... the Y register).
183
 
184
        ld      r0, y+
185
        sts     uxCriticalNesting, r0
186
        ld      r31, y+                                 ; Restore the registers down to R0.  The Y
187
        ld      r30, y+                                 ; register is missing from this list as it
188
        ld      r27, y+                                 ; has already been restored.
189
        ld      r26, y+
190
        ld      r25, y+
191
        ld      r24, y+
192
        ld      r23, y+
193
        ld      r22, y+
194
        ld      r21, y+
195
        ld      r20, y+
196
        ld      r19, y+
197
        ld      r18, y+
198
        ld      r17, y+
199
        ld      r16, y+
200
        ld      r15, y+
201
        ld      r14, y+
202
        ld      r13, y+
203
        ld      r12, y+
204
        ld      r11, y+
205
        ld      r10, y+
206
        ld      r9, y+
207
        ld      r8, y+
208
        ld      r7, y+
209
        ld      r6, y+
210
        ld      r5, y+
211
        ld      r4, y+
212
        ld      r3, y+
213
        ld      r2, y+
214
        ld      r1, y+
215
 
216
        ld      r0, y+                                  ; The next thing on the stack is the ...
217
        out     SPH, r0                                 ; ... hardware stack pointer.
218
        ld      r0, y+
219
        out     SPL, r0
220
 
221
        ld      r0, y+                                  ; Next there is the SREG register.
222
        out SREG, r0
223
 
224
        ld      r0, y+                                  ; Finally we have finished with r0, so restore r0.
225
 
226
        ENDM
227
 
228
 
229
 
230
; vPortYield() and vPortYieldFromTick()
231
; -------------------------------------
232
;
233
; Manual and preemptive context switch functions respectively.
234
; The IAR compiler does not fully support inline assembler,
235
; so these are implemented here rather than the more usually
236
; place of within port.c.
237
 
238
vPortYield:
239
        portSAVE_CONTEXT                        ; Save the context of the current task.
240
        call vTaskSwitchContext         ; Call the scheduler.
241
        portRESTORE_CONTEXT                     ; Restore the context of whichever task the ...
242
        ret                                                     ; ... scheduler decided should run.
243
 
244
vPortYieldFromTick:
245
        portSAVE_CONTEXT                        ; Save the context of the current task.
246
        call vTaskIncrementTick         ; Call the timer tick function.
247
        call vTaskSwitchContext         ; Call the scheduler.
248
        portRESTORE_CONTEXT                     ; Restore the context of whichever task the ...
249
        ret                                                     ; ... scheduler decided should run.
250
 
251
; vPortStart()
252
; ------------
253
;
254
; Again due to the lack of inline assembler, this is required
255
; to get access to the portRESTORE_CONTEXT macro.
256
 
257
vPortStart:
258
        portRESTORE_CONTEXT
259
        ret
260
 
261
 
262
; Just a filler for unused interrupt vectors.
263
vNoISR:
264
        reti
265
 
266
 
267
        END
268
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.