| 
									
										
										
										
											2019-11-15 17:14:48 +08:00
										 |  |  | // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Licensed under the Apache License, Version 2.0 (the "License");
 | 
					
						
							|  |  |  | // you may not use this file except in compliance with the License. | 
					
						
							|  |  |  | // You may obtain a copy of the License at | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //     http://www.apache.org/licenses/LICENSE-2.0 | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  | // distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  | // See the License for the specific language governing permissions and | 
					
						
							|  |  |  | // limitations under the License. | 
					
						
							| 
									
										
										
										
											2019-11-15 16:07:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-27 13:52:27 -03:00
										 |  |  | #include <freertos/xtensa_context.h> | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     .extern esp_clear_watchpoint
 | 
					
						
							| 
									
										
										
										
											2019-11-15 16:07:57 +08:00
										 |  |  |     .text | 
					
						
							| 
									
										
										
										
											2019-11-27 13:52:27 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 16:07:57 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * extern void switch_stack_enter(portSTACK_TYPE *stack, portSTACK_TYPE *backup_stack);
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-11-15 16:49:25 +08:00
										 |  |  |     .globl     esp_switch_stack_enter
 | 
					
						
							|  |  |  |     .type       esp_switch_stack_enter,@function
 | 
					
						
							| 
									
										
										
										
											2019-11-15 16:07:57 +08:00
										 |  |  |     .align      4
 | 
					
						
							| 
									
										
										
										
											2019-11-15 16:49:25 +08:00
										 |  |  | esp_switch_stack_enter: | 
					
						
							| 
									
										
										
										
											2019-11-15 17:14:48 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     #ifndef __XTENSA_CALL0_ABI__ | 
					
						
							| 
									
										
										
										
											2020-02-06 16:24:39 -03:00
										 |  |  |     entry   sp, 0x10 | 
					
						
							|  |  |  |     mov   a4, a1 | 
					
						
							|  |  |  |     s32i   a4, a3, 0 /* on a3 there is a safe place to save the current stack */ | 
					
						
							|  |  |  |     l32i   a4, a2, 0 /* obtains the user allocated stack buffer */ | 
					
						
							|  |  |  |     mov   a1, a4     /* sp register now contains caller specified stack */ | 
					
						
							|  |  |  |     retw | 
					
						
							| 
									
										
										
										
											2019-11-15 17:14:48 +08:00
										 |  |  |     #else  | 
					
						
							| 
									
										
										
										
											2020-02-06 16:24:39 -03:00
										 |  |  |     #error "this code is written for Window ABI" | 
					
						
							| 
									
										
										
										
											2019-11-15 17:14:48 +08:00
										 |  |  |     #endif | 
					
						
							| 
									
										
										
										
											2019-11-15 16:07:57 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * extern void switch_stack_exit(portSTACK_TYPE *backup_stack);
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-11-15 16:49:25 +08:00
										 |  |  |     .globl  esp_switch_stack_exit
 | 
					
						
							|  |  |  |     .type   esp_switch_stack_exit,@function
 | 
					
						
							| 
									
										
										
										
											2019-11-15 16:07:57 +08:00
										 |  |  |     .align  4
 | 
					
						
							| 
									
										
										
										
											2019-11-15 16:49:25 +08:00
										 |  |  | esp_switch_stack_exit: | 
					
						
							| 
									
										
										
										
											2019-11-15 17:14:48 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     #ifndef __XTENSA_CALL0_ABI__ | 
					
						
							| 
									
										
										
										
											2020-02-06 16:24:39 -03:00
										 |  |  |     entry   sp, 0x10 | 
					
						
							| 
									
										
										
										
											2020-01-06 17:01:53 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-06 16:24:39 -03:00
										 |  |  |     l32i a4, a2, 0  /* recover the original task stack */ | 
					
						
							|  |  |  |     mov a1, a4      /* put it on sp register again */ | 
					
						
							|  |  |  |     retw | 
					
						
							| 
									
										
										
										
											2020-01-06 17:01:53 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 17:14:48 +08:00
										 |  |  |     #else  | 
					
						
							| 
									
										
										
										
											2020-02-06 16:24:39 -03:00
										 |  |  |     #error "this code is written for Window ABI" | 
					
						
							| 
									
										
										
										
											2019-11-15 17:14:48 +08:00
										 |  |  |     #endif |