]> git.sur5r.net Git - freertos/blob - Source/portable/IAR/STR75x/ISR_Support.h
Update version number to V4.2.0.
[freertos] / Source / portable / IAR / STR75x / ISR_Support.h
1 ;       FreeRTOS.org V4.2.0 - Copyright (C) 2003-2007 Richard Barry.\r
2 ;\r
3 ;       This file is part of the FreeRTOS.org distribution.\r
4 ;\r
5 ;       FreeRTOS.org is free software; you can redistribute it and/or modify\r
6 ;       it under the terms of the GNU General Public License as published by\r
7 ;       the Free Software Foundation; either version 2 of the License, or\r
8 ;       (at your option) any later version.\r
9 ;\r
10 ;       FreeRTOS.org is distributed in the hope that it will be useful,\r
11 ;       but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 ;       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 ;       GNU General Public License for more details.\r
14 ;\r
15 ;       You should have received a copy of the GNU General Public License\r
16 ;       along with FreeRTOS.org; if not, write to the Free Software\r
17 ;       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
18 ;\r
19 ;       A special exception to the GPL can be applied should you wish to distribute\r
20 ;       a combined work that includes FreeRTOS.org, without being obliged to provide\r
21 ;       the source code for any proprietary components.  See the licensing section\r
22 ;       of http://www.FreeRTOS.org for full details of how and when the exception\r
23 ;       can be applied.\r
24 ;\r
25 ;       ***************************************************************************\r
26 ;       See http://www.FreeRTOS.org for documentation, latest information, license\r
27 ;       and contact details.  Please ensure to read the configuration and relevant\r
28 ;       port sections of the online documentation.\r
29 ;       ***************************************************************************\r
30 \r
31         EXTERN pxCurrentTCB\r
32         EXTERN ulCriticalNesting\r
33 \r
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
35 ; Context save and restore macro definitions\r
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
37 \r
38 portSAVE_CONTEXT MACRO\r
39 \r
40         ; Push R0 as we are going to use the register.                                  \r
41         STMDB   SP!, {R0}\r
42 \r
43         ; Set R0 to point to the task stack pointer.                                    \r
44         STMDB   SP, {SP}^\r
45         NOP\r
46         SUB             SP, SP, #4\r
47         LDMIA   SP!, {R0}\r
48 \r
49         ; Push the return address onto the stack.                                               \r
50         STMDB   R0!, {LR}\r
51 \r
52         ; Now we have saved LR we can use it instead of R0.                             \r
53         MOV             LR, R0\r
54 \r
55         ; Pop R0 so we can save it onto the system mode stack.                  \r
56         LDMIA   SP!, {R0}\r
57 \r
58         ; Push all the system mode registers onto the task stack.               \r
59         STMDB   LR, {R0-LR}^\r
60         NOP\r
61         SUB             LR, LR, #60\r
62 \r
63         ; Push the SPSR onto the task stack.                                                    \r
64         MRS             R0, SPSR\r
65         STMDB   LR!, {R0}\r
66 \r
67         LDR             R0, =ulCriticalNesting \r
68         LDR             R0, [R0]\r
69         STMDB   LR!, {R0}\r
70 \r
71         ; Store the new top of stack for the task.                                              \r
72         LDR             R1, =pxCurrentTCB\r
73         LDR             R0, [R1]\r
74         STR             LR, [R0]\r
75 \r
76         ENDM\r
77 \r
78 \r
79 portRESTORE_CONTEXT MACRO\r
80 \r
81         ; Set the LR to the task stack.                                                                         \r
82         LDR             R1, =pxCurrentTCB\r
83         LDR             R0, [R1]\r
84         LDR             LR, [R0]\r
85 \r
86         ; The critical nesting depth is the first item on the stack.    \r
87         ; Load it into the ulCriticalNesting variable.                                  \r
88         LDR             R0, =ulCriticalNesting\r
89         LDMFD   LR!, {R1}\r
90         STR             R1, [R0]\r
91 \r
92         ; Get the SPSR from the stack.                                                                  \r
93         LDMFD   LR!, {R0}\r
94         MSR             SPSR_cxsf, R0\r
95 \r
96         ; Restore all system mode registers for the task.                               \r
97         LDMFD   LR, {R0-R14}^\r
98         NOP\r
99 \r
100         ; Restore the return address.                                                                   \r
101         LDR             LR, [LR, #+60]\r
102 \r
103         ; And return - correcting the offset in the LR to obtain the    \r
104         ; correct address.                                                                                              \r
105         SUBS    PC, LR, #4\r
106 \r
107         ENDM\r
108 \r