Merge changes Ib331bae9,I9d5000cd,I65ab7310,Ifbe11515,I1edddefd, ...

* changes:
  Organize the build system
  [ion/device] Enable powering the LCD controller from a GPIO
  [liba] Enable malloc/free logging
  [ion] Fix the C API
  [ion] Fix the blackbox platform
  [ion] Add a C bridge for the logging function
  [ion] Implement Log::print using SWO on the device
This commit is contained in:
Romain Goyet
2017-02-16 09:34:24 +01:00
committed by Gerrit
36 changed files with 242 additions and 85 deletions

View File

@@ -1,5 +1,9 @@
SFLAGS += -Iliba/include
ifeq ($(LIBA_LOG_DYNAMIC_MEMORY),1)
SFLAGS += -DLIBA_LOG_DYNAMIC_MEMORY=1
endif
liba/src/external/sqlite/mem5.o: CFLAGS += -w
objs += $(addprefix liba/src/, \

View File

@@ -2,6 +2,20 @@
#include <string.h>
#include <private/memconfig.h>
#if LIBA_LOG_DYNAMIC_MEMORY
#include <stdint.h>
#include <ion/c.h>
void write_uint32_in_buffer(uint32_t n, char * buffer) {
for (int i=0; i<2*sizeof(uint32_t); i++) {
unsigned char v = (n & 0xF);
char c = (v>9) ? 'A'+v-10 : '0'+v;
buffer[2*sizeof(uint32_t)-1-i] = c;
n = n >> 4;
}
}
#endif
extern char _heap_start;
extern char _heap_end;
@@ -26,6 +40,11 @@ static void configure_heap() {
}
void free(void *ptr) {
#if LIBA_LOG_DYNAMIC_MEMORY
char message[5+2*sizeof(uint32_t)+1] = {'F', 'R', 'E', 'E', '-'};
write_uint32_in_buffer((uint32_t)ptr, message+5);
ion_log_print(message);
#endif
if (ptr != NULL) {
memsys5FreeUnsafe(ptr);
}
@@ -39,6 +58,14 @@ void * malloc(size_t size) {
if (size > 0) {
p = memsys5MallocUnsafe(memsys5Roundup(size));
}
#if LIBA_LOG_DYNAMIC_MEMORY
char message[7+2*sizeof(uint32_t)+1+2*sizeof(uint32_t)+1] = {'M','A','L','L','O','C','-'};
write_uint32_in_buffer((uint32_t)p, message+7);
message[7+2*sizeof(uint32_t)] = '-';
write_uint32_in_buffer(size, message+7+2*sizeof(uint32_t)+1);
message[7+2*sizeof(uint32_t)+1+2*sizeof(uint32_t)] = 0;
ion_log_print(message);
#endif
return p;
}