diff --git a/port/moonlight/exception.c b/port/moonlight/exception.c index 8bc2caf..fd29cdb 100644 --- a/port/moonlight/exception.c +++ b/port/moonlight/exception.c @@ -5,7 +5,13 @@ // Expect this to increment one time per second - inside exception handler, after each return of MTI handler. static volatile uint64_t ecall_count = 0; - +#ifdef NX_DEBUG +#define PUTS(STR) puts(STR) +#define PRINTF(...) printf(__VA_ARGS__) +#else +#define PUTS(STR) +#define PRINTF(...) +#endif void exception(uintptr_t mcause, uintptr_t mepc, uintptr_t mtval) { switch(mcause) { case RISCV_EXCP_INSTRUCTION_ADDRESS_MISALIGNED: { @@ -26,8 +32,6 @@ void exception(uintptr_t mcause, uintptr_t mepc, uintptr_t mtval) { } case RISCV_EXCP_LOAD_ADDRESS_MISALIGNED: { puts("[EXCEPTION] : Load address misaligned"); - printf("[EXCEPTION] : PC: 0x%x\n", mepc); - printf("[EXCEPTION] : Addr: 0x%x\n", mtval); break; } case RISCV_EXCP_LOAD_ACCESS_FAULT: { @@ -36,8 +40,6 @@ void exception(uintptr_t mcause, uintptr_t mepc, uintptr_t mtval) { } case RISCV_EXCP_STORE_AMO_ADDRESS_MISALIGNED: { puts("[EXCEPTION] : Store/AMO address misaligned"); - printf("[EXCEPTION] : PC: 0x%x\n", mepc); - printf("[EXCEPTION] : Addr: 0x%x\n", mtval); break; } case RISCV_EXCP_STORE_AMO_ACCESS_FAULT: { @@ -74,6 +76,8 @@ void exception(uintptr_t mcause, uintptr_t mepc, uintptr_t mtval) { printf("[EXCEPTION] : Unknown trap cause: %lu\n", mcause); } } + printf("[EXCEPTION] : PC: 0x%x\n", mepc); + printf("[EXCEPTION] : Addr: 0x%x\n", mtval); while(1) ; } diff --git a/port/moonlight/mnrs_network_driver.c b/port/moonlight/mnrs_network_driver.c index 4a6d9fd..2c77631 100644 --- a/port/moonlight/mnrs_network_driver.c +++ b/port/moonlight/mnrs_network_driver.c @@ -950,7 +950,7 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac){ from_mac.nx_mac_address_msw=(buffer[6]<<8) + buffer[7]; from_mac.nx_mac_address_lsw=(buffer[8]<<24) + (buffer[9]<<16) + (buffer[10]<<8) + buffer[11]; // find the diver instance belonging to our ethmac - for(i=0; i