Просмотр исходного кода

soc: use own macro to assert proper args for cpu abstractions

Renz Christian Bagaporo 6 лет назад
Родитель
Сommit
d5c123c1f5

+ 9 - 6
components/soc/src/hal/cpu_hal.c

@@ -13,6 +13,7 @@
 // limitations under the License.
 
 #include <stdint.h>
+#include <stdlib.h>
 
 #include "esp_err.h"
 
@@ -21,17 +22,19 @@
 
 #include "soc/cpu_caps.h"
 
+#define CHECK(cond)         {  if (!(cond)) abort(); }
+
 #if SOC_CPU_BREAKPOINTS_NUM > 0
 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));
     return ESP_OK;
 }
 
 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);
     return ESP_OK;
 }
@@ -40,9 +43,9 @@ esp_err_t cpu_hal_clear_breakpoint(int id)
 #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)
 {
-    assert(id < SOC_CPU_WATCHPOINTS_NUM && id >= 0);
-    assert(size <= SOC_CPU_WATCHPOINT_SIZE);
-    assert(trigger == WATCHPOINT_TRIGGER_ON_RO || 
+    CHECK(id < SOC_CPU_WATCHPOINTS_NUM && id >= 0);
+    CHECK(size <= SOC_CPU_WATCHPOINT_SIZE);
+    CHECK(trigger == WATCHPOINT_TRIGGER_ON_RO || 
            trigger == WATCHPOINT_TRIGGER_ON_WO ||
            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)
 {
-    assert(id < SOC_CPU_WATCHPOINTS_NUM && id >= 0);
+    CHECK(id < SOC_CPU_WATCHPOINTS_NUM && id >= 0);
     cpu_ll_clear_watchpoint(id);
     return ESP_OK;
 }

+ 4 - 2
components/soc/src/hal/mpu_hal.c

@@ -23,10 +23,12 @@
 
 #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)
 {
-    assert(id < SOC_MPU_REGIONS_MAX_NUM && id >= 0);
-    assert(
+    CHECK(id < SOC_MPU_REGIONS_MAX_NUM && id >= 0);
+    CHECK(
 #if SOC_MPU_REGION_RO_SUPPORTED
            access == MPU_REGION_RO ||
 #endif

+ 6 - 3
components/soc/src/hal/soc_hal.c

@@ -13,6 +13,7 @@
 // limitations under the License.
 
 #include <stdint.h>
+#include <stdlib.h>
 
 #include "esp_err.h"
 
@@ -20,18 +21,20 @@
 #include "hal/soc_ll.h"
 #include "soc/soc_caps.h"
 
+#define CHECK(cond)         {  if (!(cond)) abort(); }
+
 #if SOC_CPU_CORES_NUM > 1
 
 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);
     return ESP_OK;
 }
 
 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);
     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)
 {
-    assert(core < SOC_CPU_CORES_NUM && core >= 0);
+    CHECK(core < SOC_CPU_CORES_NUM && core >= 0);
     soc_ll_reset_core(core);
     return ESP_OK;
 }