2021-09-15 17:06:10 -04:00
|
|
|
/*
|
2021-01-05 18:26:07 -05:00
|
|
|
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
2021-09-15 17:06:10 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-01-18 21:02:21 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-06-07 03:01:05 -04:00
|
|
|
/*
|
|
|
|
Note: This is a compatibility header. Call the interfaces in esp_cpu.h instead
|
|
|
|
[refactor-todo]: Mark all API in this header as deprecated
|
|
|
|
*/
|
2020-01-18 21:02:21 -05:00
|
|
|
|
2022-06-07 03:01:05 -04:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
2020-09-09 22:37:58 -04:00
|
|
|
#include "soc/soc_caps.h"
|
2020-01-18 21:02:21 -05:00
|
|
|
#include "hal/cpu_ll.h"
|
2022-06-07 03:01:05 -04:00
|
|
|
#include "esp_cpu.h"
|
2020-01-18 21:02:21 -05:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-06-07 03:01:05 -04:00
|
|
|
typedef enum {
|
|
|
|
WATCHPOINT_TRIGGER_ON_RO = ESP_CPU_WATCHPOINT_LOAD, // on read
|
|
|
|
WATCHPOINT_TRIGGER_ON_WO = ESP_CPU_WATCHPOINT_STORE, // on write
|
|
|
|
WATCHPOINT_TRIGGER_ON_RW = ESP_CPU_WATCHPOINT_ACCESS, // on either read or write
|
|
|
|
} watchpoint_trigger_t;
|
|
|
|
|
2020-01-18 21:02:21 -05:00
|
|
|
/**
|
|
|
|
* Return the ID of the core currently executing this code.
|
|
|
|
*
|
|
|
|
* @return core id [0..SOC_CPU_CORES_NUM - 1]
|
|
|
|
*/
|
|
|
|
#define cpu_hal_get_core_id() cpu_ll_get_core_id()
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current value of the stack pointer.
|
|
|
|
*
|
|
|
|
* @return the current stack pointer
|
|
|
|
*/
|
|
|
|
#define cpu_hal_get_sp() cpu_ll_get_sp()
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current value of the internal counter that increments
|
|
|
|
* every processor-clock cycle.
|
|
|
|
*
|
|
|
|
* @return cycle count; returns 0 if not supported
|
|
|
|
*/
|
|
|
|
#define cpu_hal_get_cycle_count() cpu_ll_get_cycle_count()
|
|
|
|
|
2021-01-11 08:03:45 -05:00
|
|
|
/**
|
|
|
|
* Set the given value into the internal counter that increments
|
|
|
|
* every processor-clock cycle.
|
|
|
|
*/
|
2022-06-07 03:01:05 -04:00
|
|
|
#define cpu_hal_set_cycle_count(val) cpu_ll_set_cycle_count(val)
|
2021-01-11 08:03:45 -05:00
|
|
|
|
2020-01-18 21:02:21 -05:00
|
|
|
/**
|
|
|
|
* Check if some form of debugger is attached to CPU.
|
|
|
|
*
|
|
|
|
* @return true debugger is attached
|
|
|
|
* @return false no debugger is attached/ no support for debuggers
|
|
|
|
*/
|
|
|
|
#define cpu_hal_is_debugger_attached() cpu_ll_is_debugger_attached()
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init HW loop status.
|
|
|
|
*/
|
|
|
|
#define cpu_hal_init_hwloop() cpu_ll_init_hwloop()
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Trigger a call to debugger.
|
|
|
|
*/
|
|
|
|
#define cpu_hal_break() cpu_ll_break()
|
|
|
|
|
2020-12-03 21:19:39 -05:00
|
|
|
/**
|
|
|
|
* Wait for interrupt.
|
|
|
|
*/
|
|
|
|
#define cpu_hal_waiti() cpu_ll_waiti()
|
|
|
|
|
2020-02-03 01:58:19 -05:00
|
|
|
#if SOC_CPU_BREAKPOINTS_NUM > 0
|
|
|
|
|
2020-01-18 21:02:21 -05:00
|
|
|
/**
|
|
|
|
* Set and enable breakpoint at an instruction address.
|
|
|
|
*
|
|
|
|
* @note Overwrites previously set breakpoint with same breakpoint ID.
|
|
|
|
*
|
2020-02-03 01:58:19 -05:00
|
|
|
* @param id breakpoint to set [0..SOC_CPU_BREAKPOINTS_NUM - 1]
|
2020-01-18 21:02:21 -05:00
|
|
|
* @param addr address to set a breakpoint on
|
|
|
|
*/
|
2022-06-07 03:01:05 -04:00
|
|
|
static inline void cpu_hal_set_breakpoint(int id, const void *addr)
|
|
|
|
{
|
|
|
|
esp_cpu_set_breakpoint(id, addr);
|
|
|
|
}
|
2020-01-18 21:02:21 -05:00
|
|
|
/**
|
|
|
|
* Clear and disable breakpoint.
|
|
|
|
*
|
2020-02-03 01:58:19 -05:00
|
|
|
* @param id breakpoint to clear [0..SOC_CPU_BREAKPOINTS_NUM - 1]
|
2020-01-18 21:02:21 -05:00
|
|
|
*/
|
2022-06-07 03:01:05 -04:00
|
|
|
static inline void cpu_hal_clear_breakpoint(int id)
|
|
|
|
{
|
|
|
|
esp_cpu_clear_breakpoint(id);
|
|
|
|
}
|
2020-01-18 21:02:21 -05:00
|
|
|
|
2020-02-03 01:58:19 -05:00
|
|
|
#endif // SOC_CPU_BREAKPOINTS_NUM > 0
|
|
|
|
|
|
|
|
#if SOC_CPU_WATCHPOINTS_NUM > 0
|
|
|
|
|
2020-01-18 21:02:21 -05:00
|
|
|
/**
|
|
|
|
* Set and enable a watchpoint, specifying the memory range and trigger operation.
|
|
|
|
*
|
2020-02-03 01:58:19 -05:00
|
|
|
* @param id watchpoint to set [0..SOC_CPU_WATCHPOINTS_NUM - 1]
|
2020-01-18 21:02:21 -05:00
|
|
|
* @param addr starting address
|
|
|
|
* @param size number of bytes from starting address to watch
|
|
|
|
* @param trigger operation on specified memory range that triggers the watchpoint (read, write, read/write)
|
|
|
|
*/
|
2022-06-07 03:01:05 -04:00
|
|
|
static inline void cpu_hal_set_watchpoint(int id, const void *addr, size_t size, watchpoint_trigger_t trigger)
|
|
|
|
{
|
|
|
|
esp_cpu_set_watchpoint(id, addr, size, (esp_cpu_watchpoint_trigger_t)trigger);
|
|
|
|
}
|
2020-01-18 21:02:21 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear and disable watchpoint.
|
|
|
|
*
|
2020-02-03 01:58:19 -05:00
|
|
|
* @param id watchpoint to clear [0..SOC_CPU_WATCHPOINTS_NUM - 1]
|
2020-01-18 21:02:21 -05:00
|
|
|
*/
|
2022-06-07 03:01:05 -04:00
|
|
|
static inline void cpu_hal_clear_watchpoint(int id)
|
|
|
|
{
|
|
|
|
esp_cpu_clear_watchpoint(id);
|
|
|
|
}
|
2020-01-18 21:02:21 -05:00
|
|
|
|
2020-02-03 01:58:19 -05:00
|
|
|
#endif // SOC_CPU_WATCHPOINTS_NUM > 0
|
|
|
|
|
2020-03-05 22:08:10 -05:00
|
|
|
/**
|
|
|
|
* Set exception vector table base address.
|
|
|
|
*
|
|
|
|
* @param base address to move the exception vector table to
|
|
|
|
*/
|
2022-06-22 06:02:53 -04:00
|
|
|
static inline __attribute__((always_inline)) void cpu_hal_set_vecbase(const void *base)
|
2022-06-07 03:01:05 -04:00
|
|
|
{
|
|
|
|
esp_cpu_intr_set_ivt_addr(base);
|
|
|
|
}
|
2020-03-05 22:08:10 -05:00
|
|
|
|
2020-01-18 21:02:21 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2020-11-10 02:40:01 -05:00
|
|
|
#endif
|