/** * Transmit a string, followed by a newline, over UART. * * \param str String to transmit. */ void serial_writeln(uint8_t *str) { int i; for (i = 0; i < strlen(str); i++) { serial_writebyte(str[i]); } serial_writebyte('\n'); }
void serial_write(const char *s) { if (!serial_initialized) { serial_init(); } char ch; while ((ch = *s++)) { serial_writebyte(ch); } }
/* serial_writebyte Write a byte out out to the serial port => c = character to output */ void serial_writebyte(unsigned char c) { /* loop waiting for bit 5 of the line status register to set, indicating data can be written */ while((x86_inportb(SERIAL_HW + 5) & 0x20) == 0) __asm__ __volatile("pause"); x86_outportb(SERIAL_HW + 0, c); /* in case whatever's connected to the serial port expects CRLF */ #ifdef DEBUG_ENDING_CRLF if(c == '\n') serial_writebyte('\r'); #endif }