void set_color_for_level(int level) { switch (level) { case K_ERROR: mon_set_color(COLOR_BLACK, COLOR_RED); mon_write("ERROR"); break; case K_WARN: mon_set_color(COLOR_BLACK, COLOR_LIGHT_MAGENTA); mon_write("WARN"); break; case K_OK: mon_set_color(COLOR_BLACK, COLOR_LIGHT_GREEN); mon_write("OK"); break; case K_INFO: mon_set_color(COLOR_BLACK, COLOR_LIGHT_CYAN); mon_write("INFO"); break; case K_DEBUG: mon_set_color(COLOR_BLACK, COLOR_MAGENTA); mon_write("DEBUG"); default: mon_set_color(COLOR_BLACK, COLOR_WHITE); } }
void output_state() { if (monitors) { mon_write(MONITOR_STATE,"STATE\n",6); mon_write(MONITOR_STATE,trans[state].name,strlen(trans[state].name)); mon_write(MONITOR_STATE,"\n",1); } }
/* outbyte * * This routine transmits a character out the SOURCE. It may support * XON/XOFF flow control. */ static void outbyte( char ch ) { char buf[10]; /* * If polling, wait for the transmitter to be ready. * Check for flow control requests and process. * Then output the character. */ buf[0] = ch; mon_write( 1, buf, 1 ); /* stdout is fd=1, write 1 byte */ }
void kprintf(int level, const char *format, ...) { if (level == K_DEBUG && !DEBUG) return; if (level != K_NONE) { mon_set_color(COLOR_BLACK, COLOR_WHITE); // print level mon_put('['); set_color_for_level(level); mon_set_color(COLOR_BLACK, COLOR_WHITE); mon_write("] "); } int i = 0; va_list list; va_start(list, format); u8int varNext = 0; while (format[i]) { if (format[i] == '%') { varNext = 1; } else if (varNext == 1) { switch (format[i]) { case 'd': mon_write_dec(va_arg(list, int)); break; case 'x': mon_write_hex(va_arg(list, u32int)); break; case 's': mon_write(va_arg(list, char*)); break; case 'c': mon_put(va_arg(list, int)); break; default: break; } varNext = 0; } else { mon_put(format[i]); } i++; } }