#include #include /* Never call this function directly: always use the printk, * which disables and reenables interrupts */ extern "C" int c_printk(const char* msg) { while (*msg != '\0') { while ((*dbg::UART_LSR & 0x20) == 0); /* Wait for transmission */ *dbg::UART_THR = *msg; msg++; } return 0; } extern "C" int printkl(const char* msg) { printk(msg); printk("\r\n"); return 0; } static char string[11]; /* TODO: WARNING: this is not thread safe!! */ extern "C" const char* itoa(uint32_t n) { string[10] = '\0'; string[0] = '0'; string[1] = 'x'; for (short i = 0; i < 8; ++i) { string[9 - i] = "0123456789abcdef"[n & 0xF]; n = n >> 4; } return &string[0]; }