详解U-Boot中printf函数的实现
详解U-Boot中printf函数的实现
一、printf函数调用关系
U-Boot源代码下载地址
1.1fputc和srial_putc的关系
- /*
- * Output a single byte to the serial port.
- */
- void serial_putc (const char c)//发送数据
- {
- S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
- #ifdef CONFIG_MODEM_SUPPORT
- if (be_quiet)
- return;
- #endif
- /* wait for room in the tx FIFO */
- while (!(uart->UTRSTAT & 0x2));
- #ifdef CONFIG_HWFLOW
- /* Wait for CTS up */
- while(hwflow && !(uart->UMSTAT & 0x1))
- ;
- #endif
- uart->UTXH = c;
- /* If \n, also do \r */
- if (c == '\n')
- serial_putc ('\r');
- }
- void fputc (int file, const char c)
- {
- if (file < MAX_FILES)
- stdio_devices[file]->putc (c);
- }
这是在console_init_r中设置stdio_devices[]后才有的,其他的是类似的。
1.2putc和fputc的关系
- void putc (const char c)
- {
- #ifdef CONFIG_SILENT_CONSOLE
- if (gd->flags & GD_FLG_SILENT)
- return;
- #endif
- if (gd->flags & GD_FLG_DEVINIT) {
- /* Send to the standard output */
- fputc (stdout, c);
- } else {
- /* Send directly to the handler */
- serial_putc (c);
- }
- }
这是console_init_r中设置gd->flags & GD_FLG_DEVINIT,也就是串口设备完全初始化之后才有这种关系,其他的函数是类似的。
|
评论暂时关闭