]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/GCC/IA32_flat/ISR_Support.h
Update version numbers ready for release.
[freertos] / FreeRTOS / Source / portable / GCC / IA32_flat / ISR_Support.h
1 /*\r
2  * FreeRTOS Kernel V10.1.1\r
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28         .extern ulTopOfSystemStack\r
29         .extern ulInterruptNesting\r
30 \r
31 /*-----------------------------------------------------------*/\r
32 \r
33 .macro portFREERTOS_INTERRUPT_ENTRY\r
34 \r
35         /* Save general purpose registers. */\r
36         pusha\r
37 \r
38         /* If ulInterruptNesting is zero the rest of the task context will need\r
39         saving and a stack switch might be required. */\r
40         movl    ulInterruptNesting, %eax\r
41         test    %eax, %eax\r
42         jne             2f\r
43 \r
44         /* Interrupts are not nested, so save the rest of the task context. */\r
45         .if configSUPPORT_FPU == 1\r
46 \r
47                 /* If the task has a buffer allocated to save the FPU context then\r
48                 save the FPU context now. */\r
49                 movl    pucPortTaskFPUContextBuffer, %eax\r
50                 test    %eax, %eax\r
51                 je              1f\r
52                 fnsave  ( %eax ) /* Save FLOP context into ucTempFPUBuffer array. */\r
53                 fwait\r
54 \r
55                 1:\r
56                 /* Save the address of the FPU context, if any. */\r
57                 push    pucPortTaskFPUContextBuffer\r
58 \r
59         .endif /* configSUPPORT_FPU */\r
60 \r
61         /* Find the TCB. */\r
62         movl    pxCurrentTCB, %eax\r
63 \r
64         /* Stack location is first item in the TCB. */\r
65         movl    %esp, (%eax)\r
66 \r
67         /* Switch stacks. */\r
68         movl    ulTopOfSystemStack, %esp\r
69         movl    %esp, %ebp\r
70 \r
71         2:\r
72         /* Increment nesting count. */\r
73         add     $1, ulInterruptNesting\r
74 \r
75 .endm\r
76 /*-----------------------------------------------------------*/\r
77 \r
78 .macro portINTERRUPT_EPILOGUE\r
79 \r
80         cli\r
81         sub             $1, ulInterruptNesting\r
82 \r
83         /* If the nesting has unwound to zero. */\r
84         movl    ulInterruptNesting, %eax\r
85         test    %eax, %eax\r
86         jne             2f\r
87 \r
88         /* If a yield was requested then select a new TCB now. */\r
89         movl    ulPortYieldPending, %eax\r
90         test    %eax, %eax\r
91         je              1f\r
92         movl    $0, ulPortYieldPending\r
93         call    vTaskSwitchContext\r
94 \r
95         1:\r
96         /* Stack location is first item in the TCB. */\r
97         movl    pxCurrentTCB, %eax\r
98         movl    (%eax), %esp\r
99 \r
100         .if configSUPPORT_FPU == 1\r
101 \r
102                 /* Restore address of task's FPU context buffer. */\r
103                 pop     pucPortTaskFPUContextBuffer\r
104 \r
105                 /* If the task has a buffer allocated in which its FPU context is saved,\r
106                 then restore it now. */\r
107                 movl    pucPortTaskFPUContextBuffer, %eax\r
108                 test    %eax, %eax\r
109                 je              1f\r
110                 frstor  ( %eax )\r
111                 1:\r
112         .endif\r
113 \r
114         2:\r
115         popa\r
116 \r
117 .endm\r
118 /*-----------------------------------------------------------*/\r
119 \r
120 .macro portFREERTOS_INTERRUPT_EXIT\r
121 \r
122         portINTERRUPT_EPILOGUE\r
123         /* EOI. */\r
124         movl    $0x00, (0xFEE000B0)\r
125         iret\r
126 \r
127 .endm\r