1 /* 2 * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef _SOC_CPU_H 8 #define _SOC_CPU_H 9 10 #include <stdint.h> 11 #include <stdbool.h> 12 #include <stddef.h> 13 14 #include "esp_cpu.h" 15 16 #if __XTENSA__ 17 #include "xt_instr_macros.h" 18 // [refactor-todo] not actually needed in this header now, 19 // but kept for compatibility 20 #include "xtensa/corebits.h" 21 #include "xtensa/config/core.h" 22 23 #include "xtensa/config/specreg.h" 24 #endif 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /** @brief Read current stack pointer address. 31 * Superseded by esp_cpu_get_sp in esp_cpu.h. 32 */ get_sp(void)33static inline __attribute__((deprecated)) void *get_sp(void) 34 { 35 return esp_cpu_get_sp(); 36 } 37 esp_cpu_process_stack_pc(uint32_t pc)38static inline uint32_t esp_cpu_process_stack_pc(uint32_t pc) 39 { 40 if (pc & 0x80000000) { 41 //Top two bits of a0 (return address) specify window increment. Overwrite to map to address space. 42 pc = (pc & 0x3fffffff) | 0x40000000; 43 } 44 //Minus 3 to get PC of previous instruction (i.e. instruction executed before return address) 45 return pc - 3; 46 } 47 48 /** 49 * @brief Configure CPU to disable access to invalid memory regions 50 * 51 */ 52 void esp_cpu_configure_region_protection(void); 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 #endif 59