rk3288提供了fiq debugger功能, 因此rk将debug uart和普通uart区分开来,
debug uart的初始化集成到了fiq debugger代码中完成,不过uart的初始化
方法还是遵循linux的uart初始化标准,包括tty driver分配,注册, ops的设置等.
代码中和uart debugger相关的用宏CONFIG_FIQ_DEBUGGER_CONSOLE包起来了,
只看这部分即可.
初始化部分:
fiq_debugger_init -> fiq_debugger.c
fiq_debugger_tty_init ->
alloc_tty_driver //分配一个tty driver,后面并填充
tty_set_operations //设置tty对应的struct tty_operations, 为fiq_tty_driver_ops,最终会操作到rk_fiq_debugger.c中的接口函数.
tty_register_driver //注册tty driver到serial core中,让系统知道此tty driver的存在.
platform_driver_register(&fiq_debugger_driver) -> //对应的platform device在rk_fiq_debugger.c而不是dts中.
fiq_debugger_probe ->
request_irq //irq处理函数fiq_debugger_uart_irq()
register_console //注册后当前console,printk()输出log的时候就会调用它最终输出到调试串口. 注册对应的console是fiq_debugger_console
//static struct console fiq_debugger_console = {
//.name = "ttyFIQ", //最后的字符设备就是/dev/ttyFIQx
//.write = fiq_debugger_console_write, //printk()最终会调用它.
//};
fiq_debugger_tty_init_one -> //初始化并注册uart port, 上一篇分析串口驱动有说过,,每个串口用port表示
tty_port_init
tty_port_register_device
可以看到和标准的串口驱动注册类似.
printk()输出log:
printk ->
vprintk_emit ->
console_unlock
console_cont_flush -> printk.c
call_console_drivers ->
con->write -> //调用对用cosole的write()函数
fiq_debugger_console_write fiq_debugger.c
state->pdata->console_write //如果有就调用console thread去输出.
fiq_debugger_putc ->
state->pdata->uart_putc -> 此函数在rk_fiq_debugger.c的rk_serial_debug_init()中注册
debug_putc -> rk_fiq_debugger.c
rk_fiq_write
用户空间write:
SyS_write ->
vfs_write ->
tty_write ->
n_tty_write ->
process_output_block ->
tty->ops->write -> //前面有注册了tty driver对应的ops为fiq_tty_driver_ops
fiq_tty_write ->
fiq_debugger_putc ->
state->pdata->uart_putc -> 此函数在rk_fiq_debugger.c的rk_serial_debug_init()中注册
debug_putc -> rk_fiq_debugger.c
rk_fiq_write
两种方式最终调用输出接口一样.
rk3288提供了fiq debugger功能, 因此rk将debug uart和普通uart区分开来,
debug uart的初始化集成到了fiq debugger代码中完成,不过uart的初始化
方法还是遵循linux的uart初始化标准,包括tty driver分配,注册, ops的设置等.
代码中和uart debugger相关的用宏CONFIG_FIQ_DEBUGGER_CONSOLE包起来了,
只看这部分即可.
初始化部分:
fiq_debugger_init -> fiq_debugger.c
fiq_debugger_tty_init ->
alloc_tty_driver //分配一个tty driver,后面并填充
tty_set_operations //设置tty对应的struct tty_operations, 为fiq_tty_driver_ops,最终会操作到rk_fiq_debugger.c中的接口函数.
tty_register_driver //注册tty driver到serial core中,让系统知道此tty driver的存在.
platform_driver_register(&fiq_debugger_driver) -> //对应的platform device在rk_fiq_debugger.c而不是dts中.
fiq_debugger_probe ->
request_irq //irq处理函数fiq_debugger_uart_irq()
register_console //注册后当前console,printk()输出log的时候就会调用它最终输出到调试串口. 注册对应的console是fiq_debugger_console
//static struct console fiq_debugger_console = {
//.name = "ttyFIQ", //最后的字符设备就是/dev/ttyFIQx
//.write = fiq_debugger_console_write, //printk()最终会调用它.
//};
fiq_debugger_tty_init_one -> //初始化并注册uart port, 上一篇分析串口驱动有说过,,每个串口用port表示
tty_port_init
tty_port_register_device
可以看到和标准的串口驱动注册类似.
printk()输出log:
printk ->
vprintk_emit ->
console_unlock
console_cont_flush -> printk.c
call_console_drivers ->
con->write -> //调用对用cosole的write()函数
fiq_debugger_console_write fiq_debugger.c
state->pdata->console_write //如果有就调用console thread去输出.
fiq_debugger_putc ->
state->pdata->uart_putc -> 此函数在rk_fiq_debugger.c的rk_serial_debug_init()中注册
debug_putc -> rk_fiq_debugger.c
rk_fiq_write
用户空间write:
SyS_write ->
vfs_write ->
tty_write ->
n_tty_write ->
process_output_block ->
tty->ops->write -> //前面有注册了tty driver对应的ops为fiq_tty_driver_ops
fiq_tty_write ->
fiq_debugger_putc ->
state->pdata->uart_putc -> 此函数在rk_fiq_debugger.c的rk_serial_debug_init()中注册
debug_putc -> rk_fiq_debugger.c
rk_fiq_write
两种方式最终调用输出接口一样.
举报