cpu/mips32r2_common: changes for heap command
This commit is contained in:
parent
4b009649c6
commit
a63c0dda9c
@ -11,6 +11,7 @@ ifeq ($(USE_UHI_SYSCALLS),1)
|
|||||||
#Use UHI to handle syscalls
|
#Use UHI to handle syscalls
|
||||||
export LINKFLAGS += -luhi
|
export LINKFLAGS += -luhi
|
||||||
export USEMODULE += newlib_syscalls_mips_uhi
|
export USEMODULE += newlib_syscalls_mips_uhi
|
||||||
|
CFLAGS += -DHAVE_HEAP_STATS
|
||||||
else
|
else
|
||||||
#Use RIOT to handle syscalls (default)
|
#Use RIOT to handle syscalls (default)
|
||||||
export USEMODULE += newlib_syscalls_default
|
export USEMODULE += newlib_syscalls_default
|
||||||
|
|||||||
@ -7,11 +7,13 @@
|
|||||||
* directory for more details.
|
* directory for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <mips/hal.h>
|
||||||
#include <mips/m32c0.h>
|
#include <mips/m32c0.h>
|
||||||
#include <mips/regdef.h>
|
#include <mips/regdef.h>
|
||||||
#include <mips/asm.h>
|
#include <mips/asm.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
#include "periph/uart.h"
|
#include "periph/uart.h"
|
||||||
#include "periph/timer.h"
|
#include "periph/timer.h"
|
||||||
@ -79,3 +81,35 @@ void cpu_init(void)
|
|||||||
/* trigger static peripheral initialization */
|
/* trigger static peripheral initialization */
|
||||||
periph_init();
|
periph_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MODULE_NEWLIB_SYSCALLS_DEFAULT
|
||||||
|
|
||||||
|
void heap_stats(void)
|
||||||
|
{
|
||||||
|
puts("heap statistics are not supported for newlib_syscalls_default");
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
extern char _end[]; /* defined in linker script */
|
||||||
|
|
||||||
|
void heap_stats(void)
|
||||||
|
{
|
||||||
|
void *ram_base;
|
||||||
|
void *ram_extent;
|
||||||
|
unsigned long heap_size;
|
||||||
|
|
||||||
|
_get_ram_range (&ram_base, &ram_extent);
|
||||||
|
/* If the _end symbol is within the RAM then use _end. */
|
||||||
|
if ((void*)_end > ram_base && (void*)_end < ram_extent) {
|
||||||
|
heap_size = ram_extent - (void*)_end;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
heap_size = ram_extent - ram_base;
|
||||||
|
}
|
||||||
|
struct mallinfo minfo = mallinfo();
|
||||||
|
printf("heap: %lu (used %lu, free %lu) [bytes]\n",
|
||||||
|
heap_size, minfo.uordblks, heap_size - minfo.uordblks);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user