2021-08-05 10:30:10 -04:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2016-08-23 05:09:44 -04:00
|
|
|
|
|
|
|
#ifndef _SOC_CPU_H
|
|
|
|
#define _SOC_CPU_H
|
|
|
|
|
2016-10-25 10:12:07 -04:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
2020-11-05 23:00:07 -05:00
|
|
|
|
2021-02-19 07:23:32 -05:00
|
|
|
#include "esp_cpu.h"
|
|
|
|
|
2020-11-05 23:00:07 -05:00
|
|
|
#if __XTENSA__
|
|
|
|
#include "xt_instr_macros.h"
|
|
|
|
// [refactor-todo] not actually needed in this header now,
|
|
|
|
// but kept for compatibility
|
2016-08-23 05:09:44 -04:00
|
|
|
#include "xtensa/corebits.h"
|
2018-10-31 23:30:48 -04:00
|
|
|
#include "xtensa/config/core.h"
|
2016-08-23 05:09:44 -04:00
|
|
|
|
2020-01-18 21:02:21 -05:00
|
|
|
#include "xtensa/config/specreg.h"
|
2020-11-05 23:00:07 -05:00
|
|
|
#endif
|
2020-01-18 21:02:21 -05:00
|
|
|
|
2020-01-26 22:43:08 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-02-19 07:23:32 -05:00
|
|
|
/** @brief Read current stack pointer address.
|
|
|
|
* Superseded by esp_cpu_get_sp in esp_cpu.h.
|
2016-12-20 00:04:15 -05:00
|
|
|
*/
|
2021-02-19 07:23:32 -05:00
|
|
|
static inline __attribute__((deprecated)) void *get_sp(void)
|
2016-12-20 00:04:15 -05:00
|
|
|
{
|
2021-02-19 07:23:32 -05:00
|
|
|
return esp_cpu_get_sp();
|
2016-12-20 00:04:15 -05:00
|
|
|
}
|
|
|
|
|
2018-11-29 04:06:21 -05:00
|
|
|
static inline uint32_t esp_cpu_process_stack_pc(uint32_t pc)
|
|
|
|
{
|
|
|
|
if (pc & 0x80000000) {
|
|
|
|
//Top two bits of a0 (return address) specify window increment. Overwrite to map to address space.
|
|
|
|
pc = (pc & 0x3fffffff) | 0x40000000;
|
|
|
|
}
|
|
|
|
//Minus 3 to get PC of previous instruction (i.e. instruction executed before return address)
|
|
|
|
return pc - 3;
|
|
|
|
}
|
|
|
|
|
2020-11-05 23:00:07 -05:00
|
|
|
/**
|
|
|
|
* @brief Configure CPU to disable access to invalid memory regions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void esp_cpu_configure_region_protection(void);
|
|
|
|
|
2020-01-26 22:43:08 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-08-23 05:09:44 -04:00
|
|
|
#endif
|