mirror of
https://github.com/saymrwulf/pulp-runtime.git
synced 2026-05-14 20:48:09 +00:00
printf fix for fpga
This commit is contained in:
parent
5904a5ae01
commit
3cae6a2e61
8 changed files with 69 additions and 69 deletions
|
|
@ -99,7 +99,7 @@ class stim(object):
|
|||
|
||||
with open(filename, 'w') as file:
|
||||
for key in sorted(self.mem.keys()):
|
||||
file.write('%X_%0*X\n' % (int(key), width*2, self.mem.get(key)))
|
||||
file.write('%X_%0*X\r\n' % (int(key), width*2, self.mem.get(key)))
|
||||
|
||||
def __parse_binaries(self, width):
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ class Efuse(object):
|
|||
for efuseId in range (0, 128):
|
||||
value = efuses[efuseId]
|
||||
self.dump(' Writing register (index: %d, value: 0x%x)' % (efuseId, value))
|
||||
file.write('{0:032b}\n'.format(value))
|
||||
file.write('{0:032b}\r\n'.format(value))
|
||||
|
||||
elif pulp_chip == 'gap8_revc':
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ static inline void hal_debug_send_printf(hal_debug_struct_t *debug_struct) {
|
|||
static inline void hal_debug_putchar(hal_debug_struct_t *debug_struct, char c) {
|
||||
hal_debug_flush_printf(debug_struct);
|
||||
*(volatile uint8_t *)&(debug_struct->putc_buffer[debug_struct->putc_current++]) = c;
|
||||
if (*(volatile uint32_t *)&debug_struct->putc_current == HAL_PRINTF_BUF_SIZE || c == '\n') {
|
||||
if (*(volatile uint32_t *)&debug_struct->putc_current == HAL_PRINTF_BUF_SIZE || c == '\r\n') {
|
||||
hal_debug_send_printf(debug_struct);
|
||||
}
|
||||
}
|
||||
|
|
@ -157,7 +157,7 @@ static inline int hal_debug_putchar_nopoll(hal_debug_struct_t *debug_struct, cha
|
|||
if (*(volatile uint32_t *)&debug_struct->pending_putchar)
|
||||
return -1;
|
||||
*(volatile uint8_t *)&(debug_struct->putc_buffer[debug_struct->putc_current++]) = c;
|
||||
if (*(volatile uint32_t *)&debug_struct->putc_current == HAL_PRINTF_BUF_SIZE || c == '\n') {
|
||||
if (*(volatile uint32_t *)&debug_struct->putc_current == HAL_PRINTF_BUF_SIZE || c == '\r\n') {
|
||||
hal_debug_send_printf(debug_struct);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -76,18 +76,18 @@ void pos_alloc_dump(pos_alloc_t *a)
|
|||
{
|
||||
pos_alloc_chunk_t *pt = a->first_free;
|
||||
|
||||
printf("======== Memory allocator state: ============\n");
|
||||
printf("======== Memory allocator state: ============\r\n");
|
||||
for (pt = a->first_free; pt; pt = pt->next)
|
||||
{
|
||||
printf("Free Block at %8X, size: %8x, Next: %8X ", (unsigned int) pt, pt->size, (unsigned int) pt->next);
|
||||
if (pt == pt->next)
|
||||
{
|
||||
printf(" CORRUPTED\n"); break;
|
||||
printf(" CORRUPTED\r\n"); break;
|
||||
}
|
||||
else
|
||||
printf("\n");
|
||||
printf("\r\n");
|
||||
}
|
||||
printf("=============================================\n");
|
||||
printf("=============================================\r\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ void pos_alloc_init(pos_alloc_t *a, void *_chunk, int size)
|
|||
|
||||
void *pos_alloc(pos_alloc_t *a, int size)
|
||||
{
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Allocating memory chunk (alloc: %p, size: 0x%8x)\n", a, size);
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Allocating memory chunk (alloc: %p, size: 0x%8x)\r\n", a, size);
|
||||
|
||||
pos_alloc_chunk_t *pt = a->first_free, *prev = 0;
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ void *pos_alloc(pos_alloc_t *a, int size)
|
|||
prev->next = pt->next;
|
||||
else
|
||||
a->first_free = pt->next;
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Allocated memory chunk (alloc: %p, base: %p)\n", a, pt);
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Allocated memory chunk (alloc: %p, base: %p)\r\n", a, pt);
|
||||
// As this block was the full free block, the beginning of the block was already taken
|
||||
// for the header and was accounted as allocated, so don't account it twice.
|
||||
pos_alloc_account_alloc(a, (void *)(((uint32_t)pt) + sizeof(pos_alloc_chunk_t)), size - sizeof(pos_alloc_chunk_t));
|
||||
|
|
@ -234,7 +234,7 @@ void *pos_alloc(pos_alloc_t *a, int size)
|
|||
else
|
||||
a->first_free = new_pt;
|
||||
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Allocated memory chunk (alloc: %p, base: %p)\n", a, result);
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Allocated memory chunk (alloc: %p, base: %p)\r\n", a, result);
|
||||
// Don't account the metadata which were in the newly allocated block as they were
|
||||
// already accounted when the block was freed
|
||||
pos_alloc_account_alloc(a, (void *)((uint32_t)result+ sizeof(pos_alloc_chunk_t)), size - sizeof(pos_alloc_chunk_t));
|
||||
|
|
@ -246,9 +246,9 @@ void *pos_alloc(pos_alloc_t *a, int size)
|
|||
}
|
||||
else
|
||||
{
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Not enough memory to allocate\n");
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Not enough memory to allocate\r\n");
|
||||
|
||||
//rt_warning("Not enough memory to allocate\n");
|
||||
//rt_warning("Not enough memory to allocate\r\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -292,7 +292,7 @@ void *pos_alloc_align(pos_alloc_t *a, int size, int align)
|
|||
|
||||
void __attribute__((noinline)) pos_free(pos_alloc_t *a, void *_chunk, int size)
|
||||
{
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Freeing memory chunk (alloc: %p, base: %p, size: 0x%8x)\n", a, _chunk, size);
|
||||
ALLOC_TRACE(POS_LOG_TRACE, "Freeing memory chunk (alloc: %p, base: %p, size: 0x%8x)\r\n", a, _chunk, size);
|
||||
|
||||
pos_alloc_chunk_t *chunk = (pos_alloc_chunk_t *)_chunk;
|
||||
pos_alloc_chunk_t *next = a->first_free, *prev = 0, *new;
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ void pos_allocs_init()
|
|||
#if defined(ARCHI_HAS_L2)
|
||||
#if defined(ARCHI_HAS_L2_MULTI)
|
||||
|
||||
//pos_trace(//pos_trace_INIT, "Initializing L2 private bank0 allocator (base: 0x%8x, size: 0x%8x)\n", (int)pos_l2_priv0_base(), pos_l2_priv0_size());
|
||||
//pos_trace(//pos_trace_INIT, "Initializing L2 private bank0 allocator (base: 0x%8x, size: 0x%8x)\r\n", (int)pos_l2_priv0_base(), pos_l2_priv0_size());
|
||||
pos_alloc_init(&pos_alloc_l2[0], pos_l2_priv0_base(), pos_l2_priv0_size());
|
||||
|
||||
//pos_trace(//pos_trace_INIT, "Initializing L2 private bank1 allocator (base: 0x%8x, size: 0x%8x)\n", (int)pos_l2_priv1_base(), pos_l2_priv1_size());
|
||||
//pos_trace(//pos_trace_INIT, "Initializing L2 private bank1 allocator (base: 0x%8x, size: 0x%8x)\r\n", (int)pos_l2_priv1_base(), pos_l2_priv1_size());
|
||||
pos_alloc_init(&pos_alloc_l2[1], pos_l2_priv1_base(), pos_l2_priv1_size());
|
||||
|
||||
//pos_trace(//pos_trace_INIT, "Initializing L2 shared banks allocator (base: 0x%8x, size: 0x%8x)\n", (int)pos_l2_shared_base(), pos_l2_shared_size());
|
||||
//pos_trace(//pos_trace_INIT, "Initializing L2 shared banks allocator (base: 0x%8x, size: 0x%8x)\r\n", (int)pos_l2_shared_base(), pos_l2_shared_size());
|
||||
pos_alloc_init(&pos_alloc_l2[2], pos_l2_shared_base(), pos_l2_shared_size());
|
||||
|
||||
#ifdef CONFIG_ALLOC_L2_PWD_NB_BANKS
|
||||
|
|
@ -72,13 +72,13 @@ void pos_allocs_init()
|
|||
pos_alloc_account_free(&pos_alloc_l2[2], pos_l2_shared_base() - sizeof(pos_alloc_chunk_t), pos_l2_shared_size() + sizeof(pos_alloc_chunk_t));
|
||||
#endif
|
||||
#else
|
||||
//pos_trace(//pos_trace_INIT, "Initializing L2 allocator (base: 0x%8x, size: 0x%8x)\n", (int)pos_l2_base(), pos_l2_size());
|
||||
//pos_trace(//pos_trace_INIT, "Initializing L2 allocator (base: 0x%8x, size: 0x%8x)\r\n", (int)pos_l2_base(), pos_l2_size());
|
||||
pos_alloc_init(&pos_alloc_l2[0], pos_l2_base(), pos_l2_size());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ARCHI_HAS_FC_TCDM)
|
||||
//pos_trace(//pos_trace_INIT, "Initializing FC TCDM allocator (base: 0x%8x, size: 0x%8x)\n", (int)pos_fc_tcdm_base(), pos_fc_tcdm_size());
|
||||
//pos_trace(//pos_trace_INIT, "Initializing FC TCDM allocator (base: 0x%8x, size: 0x%8x)\r\n", (int)pos_fc_tcdm_base(), pos_fc_tcdm_size());
|
||||
pos_alloc_init(&pos_alloc_fc_tcdm, pos_fc_tcdm_base(), pos_fc_tcdm_size());
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ void print_result(testcase_t *test, testresult_t *result)
|
|||
printf("nr. of errors: %d", result->errors);
|
||||
|
||||
if(result->time == 0)
|
||||
printf("\n");
|
||||
printf("\r\n");
|
||||
else
|
||||
printf(", execution time: %d\n", result->time);
|
||||
printf(", execution time: %d\r\n", result->time);
|
||||
|
||||
#ifdef PROFILE
|
||||
perf_print_all();
|
||||
|
|
@ -95,9 +95,9 @@ void print_summary(unsigned int errors)
|
|||
printf("==== SUMMARY: ");
|
||||
|
||||
if (errors == 0) {
|
||||
printf("SUCCESS\n");
|
||||
printf("SUCCESS\r\n");
|
||||
} else {
|
||||
printf("FAIL\n");
|
||||
printf("FAIL\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -140,56 +140,56 @@ void check_uint32(testresult_t* result, const char* fail_msg, uint32_t actual, u
|
|||
{
|
||||
if(actual != expected) {
|
||||
result->errors += 1;
|
||||
if(enable_printf) printf("%s: Actual %X, expected %X\n", fail_msg, (unsigned int) actual, (unsigned int)expected);
|
||||
if(enable_printf) printf("%s: Actual %X, expected %X\r\n", fail_msg, (unsigned int) actual, (unsigned int)expected);
|
||||
}
|
||||
}
|
||||
|
||||
void perf_print_all(void) {
|
||||
#ifdef __riscv__
|
||||
printf("Perf CYCLES: %d\n", cpu_perf_get(0));
|
||||
printf("Perf INSTR: %d\n", cpu_perf_get(1));
|
||||
printf("Perf CINSTR: %d\n", cpu_perf_get(10));
|
||||
printf("Perf LD_STALL: %d\n", cpu_perf_get(2));
|
||||
printf("Perf JR_STALL: %d\n", cpu_perf_get(3));
|
||||
printf("Perf IMISS: %d\n", cpu_perf_get(4));
|
||||
printf("Perf LD: %d\n", cpu_perf_get(5));
|
||||
printf("Perf ST: %d\n", cpu_perf_get(6));
|
||||
printf("Perf JUMP: %d\n", cpu_perf_get(7));
|
||||
printf("Perf BRANCH: %d\n", cpu_perf_get(8));
|
||||
printf("Perf BTAKEN: %d\n", cpu_perf_get(9));
|
||||
printf("Perf LD EXT: %d\n", cpu_perf_get(11));
|
||||
printf("Perf ST EXT: %d\n", cpu_perf_get(12));
|
||||
printf("Perf LD EXT CYC: %d\n", cpu_perf_get(13));
|
||||
printf("Perf ST EXT CYC: %d\n", cpu_perf_get(14));
|
||||
printf("Perf TCDM CONT: %d\n", cpu_perf_get(15));
|
||||
printf("Perf CSR HAZARD: %d\n", cpu_perf_get(16));
|
||||
printf("Perf CYCLES: %d\r\n", cpu_perf_get(0));
|
||||
printf("Perf INSTR: %d\r\n", cpu_perf_get(1));
|
||||
printf("Perf CINSTR: %d\r\n", cpu_perf_get(10));
|
||||
printf("Perf LD_STALL: %d\r\n", cpu_perf_get(2));
|
||||
printf("Perf JR_STALL: %d\r\n", cpu_perf_get(3));
|
||||
printf("Perf IMISS: %d\r\n", cpu_perf_get(4));
|
||||
printf("Perf LD: %d\r\n", cpu_perf_get(5));
|
||||
printf("Perf ST: %d\r\n", cpu_perf_get(6));
|
||||
printf("Perf JUMP: %d\r\n", cpu_perf_get(7));
|
||||
printf("Perf BRANCH: %d\r\n", cpu_perf_get(8));
|
||||
printf("Perf BTAKEN: %d\r\n", cpu_perf_get(9));
|
||||
printf("Perf LD EXT: %d\r\n", cpu_perf_get(11));
|
||||
printf("Perf ST EXT: %d\r\n", cpu_perf_get(12));
|
||||
printf("Perf LD EXT CYC: %d\r\n", cpu_perf_get(13));
|
||||
printf("Perf ST EXT CYC: %d\r\n", cpu_perf_get(14));
|
||||
printf("Perf TCDM CONT: %d\r\n", cpu_perf_get(15));
|
||||
printf("Perf CSR HAZARD: %d\r\n", cpu_perf_get(16));
|
||||
#ifdef HARD_FLOAT
|
||||
if (!rt_is_fc()) {
|
||||
printf("Perf APU_TY_CONF: %d\n", cpu_perf_get(17));
|
||||
printf("Perf APU_CONT: %d\n", cpu_perf_get(18));
|
||||
printf("Perf APU_DEP: %d\n", cpu_perf_get(19));
|
||||
printf("Perf APU_WB: %d\n", cpu_perf_get(20));
|
||||
printf("Perf APU_TY_CONF: %d\r\n", cpu_perf_get(17));
|
||||
printf("Perf APU_CONT: %d\r\n", cpu_perf_get(18));
|
||||
printf("Perf APU_DEP: %d\r\n", cpu_perf_get(19));
|
||||
printf("Perf APU_WB: %d\r\n", cpu_perf_get(20));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#ifdef CSR_PCER_ALL_EVENTS_MASK
|
||||
printf("Perf CYCLES: %d\n", cpu_perf_get(SPR_PCER_CYCLES));
|
||||
printf("Perf INSTR: %d\n", cpu_perf_get(SPR_PCER_INSTR));
|
||||
printf("Perf LD_STALL: %d\n", cpu_perf_get(SPR_PCER_LD_STALL));
|
||||
printf("Perf JMP_STALL: %d\n", cpu_perf_get(SPR_PCER_JMP_STALL));
|
||||
printf("Perf IMISS: %d\n", cpu_perf_get(SPR_PCER_IMISS));
|
||||
printf("Perf WBRANCH: %d\n", cpu_perf_get(SPR_PCER_WBRANCH));
|
||||
printf("Perf WBRANCH_CYC: %d\n", cpu_perf_get(SPR_PCER_WBRANCH_CYC));
|
||||
printf("Perf LD: %d\n", cpu_perf_get(SPR_PCER_LD));
|
||||
printf("Perf ST: %d\n", cpu_perf_get(SPR_PCER_ST));
|
||||
printf("Perf JUMP: %d\n", cpu_perf_get(SPR_PCER_JUMP));
|
||||
printf("Perf BRANCH: %d\n", cpu_perf_get(SPR_PCER_BRANCH));
|
||||
printf("Perf DELAY NOP: %d\n", cpu_perf_get(SPR_PCER_DELAY_NOP));
|
||||
printf("Perf LD EXT: %d\n", cpu_perf_get(SPR_PCER_LD_EXT));
|
||||
printf("Perf ST EXT: %d\n", cpu_perf_get(SPR_PCER_ST_EXT));
|
||||
printf("Perf LD EXT CYC: %d\n", cpu_perf_get(SPR_PCER_LD_EXT_CYC));
|
||||
printf("Perf ST EXT CYC: %d\n", cpu_perf_get(SPR_PCER_ST_EXT_CYC));
|
||||
printf("Perf TCDM CONT: %d\n", cpu_perf_get(SPR_PCER_TCDM_CONT));
|
||||
printf("Perf CYCLES: %d\r\n", cpu_perf_get(SPR_PCER_CYCLES));
|
||||
printf("Perf INSTR: %d\r\n", cpu_perf_get(SPR_PCER_INSTR));
|
||||
printf("Perf LD_STALL: %d\r\n", cpu_perf_get(SPR_PCER_LD_STALL));
|
||||
printf("Perf JMP_STALL: %d\r\n", cpu_perf_get(SPR_PCER_JMP_STALL));
|
||||
printf("Perf IMISS: %d\r\n", cpu_perf_get(SPR_PCER_IMISS));
|
||||
printf("Perf WBRANCH: %d\r\n", cpu_perf_get(SPR_PCER_WBRANCH));
|
||||
printf("Perf WBRANCH_CYC: %d\r\n", cpu_perf_get(SPR_PCER_WBRANCH_CYC));
|
||||
printf("Perf LD: %d\r\n", cpu_perf_get(SPR_PCER_LD));
|
||||
printf("Perf ST: %d\r\n", cpu_perf_get(SPR_PCER_ST));
|
||||
printf("Perf JUMP: %d\r\n", cpu_perf_get(SPR_PCER_JUMP));
|
||||
printf("Perf BRANCH: %d\r\n", cpu_perf_get(SPR_PCER_BRANCH));
|
||||
printf("Perf DELAY NOP: %d\r\n", cpu_perf_get(SPR_PCER_DELAY_NOP));
|
||||
printf("Perf LD EXT: %d\r\n", cpu_perf_get(SPR_PCER_LD_EXT));
|
||||
printf("Perf ST EXT: %d\r\n", cpu_perf_get(SPR_PCER_ST_EXT));
|
||||
printf("Perf LD EXT CYC: %d\r\n", cpu_perf_get(SPR_PCER_LD_EXT_CYC));
|
||||
printf("Perf ST EXT CYC: %d\r\n", cpu_perf_get(SPR_PCER_ST_EXT_CYC));
|
||||
printf("Perf TCDM CONT: %d\r\n", cpu_perf_get(SPR_PCER_TCDM_CONT));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -197,8 +197,8 @@ void perf_print_all(void) {
|
|||
// // icache
|
||||
// int i;
|
||||
// for(i = 0; i < 4; i++) {
|
||||
// printf("I$ bank %d: Read hits %d\n", i, read_hit_icache_reg(i));
|
||||
// printf("I$ bank %d: Trans %d\n", i, read_trans_icache_reg(i));
|
||||
// printf("I$ bank %d: Read hits %d\r\n", i, read_hit_icache_reg(i));
|
||||
// printf("I$ bank %d: Trans %d\r\n", i, read_trans_icache_reg(i));
|
||||
// }
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ void illegal_insn_handler_c(void)
|
|||
exception_address = hal_spr_read(SPR_EPCR_BASE);
|
||||
#endif
|
||||
insn = *((unsigned int*)(exception_address));
|
||||
printf("Illegal instruction encountered at address 0x%08X: %X\n", exception_address, insn);
|
||||
printf("Illegal instruction encountered at address 0x%08X: %X\r\n", exception_address, insn);
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ void rt_irq_set_handler(int irq, void (*handler)())
|
|||
void __rt_handle_illegal_instr()
|
||||
{
|
||||
//unsigned int mepc = hal_mepc_read();
|
||||
//rt_warning("Reached illegal instruction (PC: 0x%x, opcode: 0x%x\n", mepc, *(int *)mepc);
|
||||
//rt_warning("Reached illegal instruction (PC: 0x%x, opcode: 0x%x\r\n", mepc, *(int *)mepc);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ int puts(const char *s)
|
|||
c = *s;
|
||||
if (c == 0)
|
||||
{
|
||||
pos_putc('\n');
|
||||
pos_putc('\r\n');
|
||||
break;
|
||||
}
|
||||
pos_putc(c);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ def fork(name, cwd, *popenargs, check=False, shell=True,
|
|||
|
||||
return FinishedProcess(name, cwd, process.args, 1,
|
||||
stdout.decode('utf-8'),
|
||||
timeoutmsg + '\n'
|
||||
timeoutmsg + '\r\n'
|
||||
+ stderr.decode('utf-8'),
|
||||
time.time() - start)
|
||||
# Including KeyboardInterrupt, communicate handled that.
|
||||
|
|
@ -274,7 +274,7 @@ the pyyaml library which is not installed.""",
|
|||
try:
|
||||
procresults = pool.starmap(fork, tests)
|
||||
except KeyboardInterrupt:
|
||||
print("\nTerminating bwruntest.py")
|
||||
print("\r\nTerminating bwruntest.py")
|
||||
pool.terminate()
|
||||
pool.join()
|
||||
exit(1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue