mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 21:54:33 +02:00
soc: use own macro to assert proper args for cpu abstractions
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
|
|
||||||
@@ -21,17 +22,19 @@
|
|||||||
|
|
||||||
#include "soc/cpu_caps.h"
|
#include "soc/cpu_caps.h"
|
||||||
|
|
||||||
|
#define CHECK(cond) { if (!(cond)) abort(); }
|
||||||
|
|
||||||
#if SOC_CPU_BREAKPOINTS_NUM > 0
|
#if SOC_CPU_BREAKPOINTS_NUM > 0
|
||||||
esp_err_t cpu_hal_set_breakpoint(int id, const void* addr)
|
esp_err_t cpu_hal_set_breakpoint(int id, const void* addr)
|
||||||
{
|
{
|
||||||
assert(id < SOC_CPU_BREAKPOINTS_NUM && id >= 0);
|
CHECK(id < SOC_CPU_BREAKPOINTS_NUM && id >= 0);
|
||||||
cpu_ll_set_breakpoint(id, cpu_ll_ptr_to_pc(addr));
|
cpu_ll_set_breakpoint(id, cpu_ll_ptr_to_pc(addr));
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t cpu_hal_clear_breakpoint(int id)
|
esp_err_t cpu_hal_clear_breakpoint(int id)
|
||||||
{
|
{
|
||||||
assert(id < SOC_CPU_BREAKPOINTS_NUM && id >= 0);
|
CHECK(id < SOC_CPU_BREAKPOINTS_NUM && id >= 0);
|
||||||
cpu_ll_clear_breakpoint(id);
|
cpu_ll_clear_breakpoint(id);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@@ -40,9 +43,9 @@ esp_err_t cpu_hal_clear_breakpoint(int id)
|
|||||||
#if SOC_CPU_WATCHPOINTS_NUM > 0
|
#if SOC_CPU_WATCHPOINTS_NUM > 0
|
||||||
esp_err_t cpu_hal_set_watchpoint(int id, const void* addr, size_t size, watchpoint_trigger_t trigger)
|
esp_err_t cpu_hal_set_watchpoint(int id, const void* addr, size_t size, watchpoint_trigger_t trigger)
|
||||||
{
|
{
|
||||||
assert(id < SOC_CPU_WATCHPOINTS_NUM && id >= 0);
|
CHECK(id < SOC_CPU_WATCHPOINTS_NUM && id >= 0);
|
||||||
assert(size <= SOC_CPU_WATCHPOINT_SIZE);
|
CHECK(size <= SOC_CPU_WATCHPOINT_SIZE);
|
||||||
assert(trigger == WATCHPOINT_TRIGGER_ON_RO ||
|
CHECK(trigger == WATCHPOINT_TRIGGER_ON_RO ||
|
||||||
trigger == WATCHPOINT_TRIGGER_ON_WO ||
|
trigger == WATCHPOINT_TRIGGER_ON_WO ||
|
||||||
trigger == WATCHPOINT_TRIGGER_ON_RW);
|
trigger == WATCHPOINT_TRIGGER_ON_RW);
|
||||||
|
|
||||||
@@ -63,7 +66,7 @@ esp_err_t cpu_hal_set_watchpoint(int id, const void* addr, size_t size, watchpoi
|
|||||||
|
|
||||||
esp_err_t cpu_hal_clear_watchpoint(int id)
|
esp_err_t cpu_hal_clear_watchpoint(int id)
|
||||||
{
|
{
|
||||||
assert(id < SOC_CPU_WATCHPOINTS_NUM && id >= 0);
|
CHECK(id < SOC_CPU_WATCHPOINTS_NUM && id >= 0);
|
||||||
cpu_ll_clear_watchpoint(id);
|
cpu_ll_clear_watchpoint(id);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
@@ -23,10 +23,12 @@
|
|||||||
|
|
||||||
#include "soc/mpu_caps.h"
|
#include "soc/mpu_caps.h"
|
||||||
|
|
||||||
|
#define CHECK(cond) { if (!(cond)) abort(); }
|
||||||
|
|
||||||
esp_err_t mpu_hal_set_region_access(int id, mpu_access_t access)
|
esp_err_t mpu_hal_set_region_access(int id, mpu_access_t access)
|
||||||
{
|
{
|
||||||
assert(id < SOC_MPU_REGIONS_MAX_NUM && id >= 0);
|
CHECK(id < SOC_MPU_REGIONS_MAX_NUM && id >= 0);
|
||||||
assert(
|
CHECK(
|
||||||
#if SOC_MPU_REGION_RO_SUPPORTED
|
#if SOC_MPU_REGION_RO_SUPPORTED
|
||||||
access == MPU_REGION_RO ||
|
access == MPU_REGION_RO ||
|
||||||
#endif
|
#endif
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
|
|
||||||
@@ -20,18 +21,20 @@
|
|||||||
#include "hal/soc_ll.h"
|
#include "hal/soc_ll.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
|
|
||||||
|
#define CHECK(cond) { if (!(cond)) abort(); }
|
||||||
|
|
||||||
#if SOC_CPU_CORES_NUM > 1
|
#if SOC_CPU_CORES_NUM > 1
|
||||||
|
|
||||||
esp_err_t soc_hal_stall_core(int core)
|
esp_err_t soc_hal_stall_core(int core)
|
||||||
{
|
{
|
||||||
assert(core < SOC_CPU_CORES_NUM && core >= 0);
|
CHECK(core < SOC_CPU_CORES_NUM && core >= 0);
|
||||||
soc_ll_stall_core(core);
|
soc_ll_stall_core(core);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t soc_hal_unstall_core(int core)
|
esp_err_t soc_hal_unstall_core(int core)
|
||||||
{
|
{
|
||||||
assert(core < SOC_CPU_CORES_NUM && core >= 0);
|
CHECK(core < SOC_CPU_CORES_NUM && core >= 0);
|
||||||
soc_ll_unstall_core(core);
|
soc_ll_unstall_core(core);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@@ -40,7 +43,7 @@ esp_err_t soc_hal_unstall_core(int core)
|
|||||||
|
|
||||||
esp_err_t soc_hal_reset_core(int core)
|
esp_err_t soc_hal_reset_core(int core)
|
||||||
{
|
{
|
||||||
assert(core < SOC_CPU_CORES_NUM && core >= 0);
|
CHECK(core < SOC_CPU_CORES_NUM && core >= 0);
|
||||||
soc_ll_reset_core(core);
|
soc_ll_reset_core(core);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
Reference in New Issue
Block a user