mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
expression_with_stack:make stack overflow detection watchpoint optional
This commit is contained in:
parent
0a8c641e6f
commit
c309112b8a
@ -1,10 +1,26 @@
|
||||
// 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.
|
||||
|
||||
#include <esp_expression_with_stack.h>
|
||||
#include <freertos/xtensa_rtos.h>
|
||||
#include <freertos/xtensa_context.h>
|
||||
|
||||
StackType_t * esp_switch_stack_setup(StackType_t *stack, size_t stack_size)
|
||||
{
|
||||
#if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
|
||||
int watchpoint_place = (((int)stack + 31) & ~31);
|
||||
#endif
|
||||
StackType_t *top_of_stack = (StackType_t *)&stack[0] +
|
||||
((stack_size * sizeof(StackType_t)) / sizeof(StackType_t));
|
||||
|
||||
@ -18,6 +34,9 @@ StackType_t * esp_switch_stack_setup(StackType_t *stack, size_t stack_size)
|
||||
frame->a0 = 0;
|
||||
frame->a1 = (UBaseType_t)top_of_stack;
|
||||
|
||||
#if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
|
||||
esp_set_watchpoint(2, (char*)watchpoint_place, 32, ESP_WATCHPOINT_STORE);
|
||||
#endif
|
||||
|
||||
return top_of_stack;
|
||||
}
|
@ -46,9 +46,13 @@ esp_switch_stack_exit:
|
||||
|
||||
#ifndef __XTENSA_CALL0_ABI__
|
||||
entry sp, 0x10
|
||||
|
||||
#if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
|
||||
movi a6, 2
|
||||
movi a4, esp_clear_watchpoint
|
||||
callx4 a4 /* clear the watchpoint before releasing stack */
|
||||
#endif
|
||||
|
||||
l32i a4, a2, 0 /* recover the original task stack */
|
||||
mov a1, a4 /* put it on sp register again */
|
||||
retw
|
||||
|
Loading…
x
Reference in New Issue
Block a user