@@ -124,8 +124,6 @@ extern "C" void z2EapFree(void *ptr, const char* file, int line) __attribute__((
124
124
#include < sys/reent.h>
125
125
#include < user_interface.h>
126
126
127
- #include " heap_cb.h"
128
-
129
127
extern " C" {
130
128
131
129
// /////////////////////////////////////////////////////////////////////////////
@@ -271,41 +269,26 @@ struct umm_last_fail_alloc {
271
269
// OOM - Debug printing
272
270
//
273
271
// IRQ/ISR safe printing macros. Printing is controled according to the results
274
- // of system_get_os_print(). Also, being in a IRQ will prevent the printing of
272
+ // of system_get_os_print(). Also, being in an IRQ may prevent the printing of
275
273
// file names stored in PROGMEM. The PROGMEM address to the string is printed in
276
274
// its place.
277
275
#define DEBUG_HEAP_PRINTF ets_uart_printf
278
-
279
- static ALWAYS_INLINE bool withinISR (uint32_t ps) {
280
- return (0 != (ps & 0x0fu ));
276
+ inline bool withinISR (uint32_t ps) {
277
+ return ((ps & 0x0f ) != 0 );
281
278
}
282
279
283
- #if 0
284
- /*
285
- ICACHE should be accessable from an ISR "IF" it has not been disabled for a
286
- SPI bus transfer. TODO investagate further - `if (inISR && ! isCacheReady())`
287
- */
288
- #define SPIRDY ESP8266_DREG(0x0C) // CACHE_FLASH_CTRL_REG
289
- #define CACHE_READ_EN_BIT BIT8 // eagle_soc.h in RTOS_SDK
290
- static ALWAYS_INLINE bool isCacheReady(void) {
291
- return 0 != (SPIRDY & CACHE_READ_EN_BIT);
292
- }
293
- #endif
294
-
295
280
static void IRAM_ATTR print_loc (bool inISR, size_t size, const char * file, int line, const void * caller) {
296
281
if (system_get_os_print ()) {
297
282
DEBUG_HEAP_PRINTF (" :oom %p(%d), File: " , caller, (int )size);
298
283
if (file) {
299
- if ((uint32_t )file >= 0x40200000 ) {
300
- if (inISR) {
301
- DEBUG_HEAP_PRINTF (" %p" , file);
302
- } else {
303
- char buf[strlen_P (file) + 1 ];
304
- strcpy_P (buf, file);
305
- DEBUG_HEAP_PRINTF (buf);
306
- }
284
+ // Small code reduction by assuming file address is in PROGMEM
285
+ if (inISR) {
286
+ DEBUG_HEAP_PRINTF (" %p" , file);
307
287
} else {
308
- DEBUG_HEAP_PRINTF (file);
288
+ size_t sz = strlen_P (file);
289
+ char buf[sz + 1 ];
290
+ strcpy_P (buf, file);
291
+ DEBUG_HEAP_PRINTF (buf);
309
292
}
310
293
} else {
311
294
DEBUG_HEAP_PRINTF (" ??" );
@@ -326,7 +309,6 @@ static bool IRAM_ATTR oom_check__log_last_fail_atomic_psflc(void *ptr, size_t si
326
309
_umm_last_fail_alloc.line = line;
327
310
print_loc (withinISR (saved_ps), size, file, line, caller);
328
311
xt_wsr_ps (saved_ps);
329
- _HEAP_DEBUG_PROBE_PSFLC_CB (heap_oom_cb_id, ptr, size, file, line, caller);
330
312
return false ;
331
313
}
332
314
return true ;
@@ -342,7 +324,6 @@ static bool IRAM_ATTR oom_check__log_last_fail_atomic_psc(void *ptr, size_t size
342
324
_umm_last_fail_alloc.addr = caller;
343
325
_umm_last_fail_alloc.size = size;
344
326
xt_wsr_ps (saved_ps);
345
- _HEAP_DEBUG_PROBE_PSFLC_CB (heap_oom_cb_id, ptr, size, NULL , 0 , caller);
346
327
return false ;
347
328
}
348
329
return true ;
@@ -358,7 +339,6 @@ static bool oom_check__log_last_fail_psc(void *ptr, size_t size, const void* cal
358
339
if (0 != (size) && 0 == ptr) {
359
340
_umm_last_fail_alloc.addr = caller;
360
341
_umm_last_fail_alloc.size = size;
361
- _HEAP_DEBUG_PROBE_PSFLC_CB (heap_oom_cb_id, ptr, size, NULL , 0 , caller);
362
342
return false ;
363
343
}
364
344
return true ;
@@ -423,7 +403,6 @@ void* IRAM_ATTR _heap_pvPortMalloc(size_t size, const char* file, int line, cons
423
403
INTEGRITY_CHECK__PANIC_FL (file, line, caller);
424
404
POISON_CHECK__PANIC_FL (file, line, caller);
425
405
void * ret = UMM_MALLOC_FL (size, file, line, caller);
426
- ret = _HEAP_DEBUG_PROBE_PSFLC_CB (heap_malloc_cb_id, ret, size, file, line, caller);
427
406
OOM_CHECK__LOG_LAST_FAIL_FL (ret, size, file, line, caller);
428
407
return ret;
429
408
}
@@ -434,7 +413,6 @@ void* IRAM_ATTR _heap_pvPortCalloc(size_t count, size_t size, const char* file,
434
413
POISON_CHECK__PANIC_FL (file, line, caller);
435
414
size_t total_size = umm_umul_sat (count, size);
436
415
void * ret = UMM_CALLOC_FL (1 , total_size, file, line, caller);
437
- ret = _HEAP_DEBUG_PROBE_PSFLC_CB (heap_calloc_cb_id, ret, size, file, line, caller);
438
416
OOM_CHECK__LOG_LAST_FAIL_FL (ret, total_size, file, line, caller);
439
417
return ret;
440
418
}
@@ -443,9 +421,7 @@ void* IRAM_ATTR _heap_pvPortRealloc(void *ptr, size_t size, const char* file, in
443
421
{
444
422
INTEGRITY_CHECK__PANIC_FL (file, line, caller);
445
423
POISON_CHECK__PANIC_FL (file, line, caller);
446
- ptr = _HEAP_DEBUG_PROBE_PSFLC_CB (heap_realloc_in_cb_id, ptr, size, file, line, caller);
447
424
void * ret = UMM_REALLOC_FL (ptr, size, file, line, caller);
448
- ret = _HEAP_DEBUG_PROBE_PSFLC_CB (heap_realloc_out_cb_id, ret, size, file, line, caller);
449
425
OOM_CHECK__LOG_LAST_FAIL_FL (ret, size, file, line, caller);
450
426
return ret;
451
427
}
@@ -454,7 +430,6 @@ void IRAM_ATTR _heap_vPortFree(void *ptr, const char* file, int line, [[maybe_un
454
430
{
455
431
INTEGRITY_CHECK__PANIC_FL (file, line, caller);
456
432
POISON_CHECK__PANIC_FL (file, line, caller);
457
- ptr = _HEAP_DEBUG_PROBE_PSFLC_CB (heap_free_cb_id, ptr, 0 , file, line, caller);
458
433
UMM_FREE_FL (ptr, file, line, caller);
459
434
}
460
435
@@ -672,7 +647,6 @@ void* _heap_abi_malloc(size_t size, bool unhandled, const void* caller)
672
647
INTEGRITY_CHECK__PANIC_FL (file, line, caller);
673
648
POISON_CHECK__PANIC_FL (file, line, caller);
674
649
void * ret = UMM_MALLOC_FL (size, file, line, caller);
675
- ret = _HEAP_DEBUG_PROBE_PSFLC_CB (heap_abi_malloc_cb_id, ret, size, file, line, caller);
676
650
bool ok = OOM_CHECK__LOG_LAST_FAIL_FL (ret, size, file, line, caller);
677
651
#else
678
652
void * ret = UMM_MALLOC (size);
0 commit comments