U-Bootのソースを読んでみる(3)

printf編

[common/console.c]

413 int printf(const char *fmt, ...)
414 {
415     va_list args;
416     uint i;
417     char printbuffer[CONFIG_SYS_PBSIZE];
418 
419 #ifndef CONFIG_PRE_CONSOLE_BUFFER
420     if (!gd->have_console)
421         return 0;
422 #endif
423 
424     va_start(args, fmt);
425 
426     /* For this to work, printbuffer must be larger than
427      * anything we ever want to print.
428      */
429     i = vscnprintf(printbuffer, sizeof(printbuffer), fmt, args);
430     va_end(args);
431 
432     /* Print the string */
433     puts(printbuffer);
434     return i;
435 }

vscnprintfで成形されて、putsで出力

389 void puts(const char *s)
390 {
...
401     if (!gd->have_console)
402         return pre_console_puts(s);
403 
404     if (gd->flags & GD_FLG_DEVINIT) {
405         /* Send to the standard output */
406         fputs(stdout, s);
407     } else {
408         /* Send directly to the handler */
409         serial_puts(s);
410     }
411 }

出力先を選択して、出力。serial_putsを追って見る。
[drivers/serial/serial.c]

417 void serial_puts(const char *s)
418 {
419     get_current()->puts(s);
420 }

zynq向けなので、ここらあたりかな?
[drivers/serial/serial_zynq.c]

136 static void uart_zynq_serial_putc(const char c, const int port)
137 {
138     struct uart_zynq *regs = uart_zynq_ports[port];
139 
140     while ((readl(&regs->channel_sts) & ZYNQ_UART_SR_TXFULL) != 0)
141         WATCHDOG_RESET();
142 
143     if (c == '\n') {
144         writel('\r', &regs->tx_rx_fifo);
145         while ((readl(&regs->channel_sts) & ZYNQ_UART_SR_TXFULL) != 0)
146             WATCHDOG_RESET();
147     }
148     writel(c, &regs->tx_rx_fifo);
149 }
150
151 static void uart_zynq_serial_puts(const char *s, const int port)
152 {
153     while (*s)
154         uart_zynq_serial_putc(*s++, port);
155 }