vt/console
时间:2007-02-14 来源:ffjnfj
1. 在cmdline中传入console=tty0,在console_setup中加入到console_cmdline数组中.
在register_console中将其加入到console_drivers链表中,而且每种类型的console,
比如tty,ttyS只能有一个。该函数在串口之类的设备初始化时会被调用。
在con_init中调用register_console(&vt_console_driver);
vt_console_print将默认使用tty0作为输出
2. printk打印时会调用console_drivers链表的所有console进行打印,也就是会输出
到多个console上。
3.
/dev/tty0, Current virtual console(当前正在使用的vc)
/dev/tty, 相对于某个进程的控制终端(controlling tty)
/dev/console, 一般等于/dev/tty0
在tty_open中/dev/console的tty_driver是根据console_device得到的,也就是从
console_drivers中搜一个合适的,一般会是/dev/tty0
http://www.linux-mips.org/wiki/Serial_Driver_and_Console
Writing the kernel console driver ~
First of all, the kernel needs a very simple serial driver that only allows to
output characters. It should not use interrupts nor DMA to be as simple as
possible. It is used to display all kernel messages printed with printk().
http://www.linux.it/~rubini/docs/sercons/sercons.html
it is called directly from printk. Since printk can be called at any time,
even at interrupt time, the write function of a console should not sleep for
any noticeable amount of time. To prevent data corruption due to reentrancy,
printk is protected by a spinlock and runs with interrupts disabled;
On the other hand, you may want to see all messages that are printed before a
system panic, so for maximum reliability the console print function should not
return before data is actually output. For this reason, the serial console
driver operates in a busy loop and its write function doesn't return before
the last byte has been transmitted
每个tty(tty1,tty2...)都有一个buffer用于存放其该显示的东东,在tty切换的时候就要
重新显示该buffer.(con_switch)
/dev/console跟register_console的console是很有关系的,/dev/console就是这些注册
的console的一个。这些console包括2个功能,1)作为console使用,内核中使用struct
console表示,提供给printk使用,2)作为tty使用,使用tty_driver表示,提供给
/dev/console使用。也就是说,如果一个console没有实现相应的tty的功能,其实是可以
的,这样就只能供printk使用,而不能作为/dev/console。所以要使用/dev/console,
register_console的consoles中至少要有一个提供tty功能
在register_console中将其加入到console_drivers链表中,而且每种类型的console,
比如tty,ttyS只能有一个。该函数在串口之类的设备初始化时会被调用。
在con_init中调用register_console(&vt_console_driver);
vt_console_print将默认使用tty0作为输出
2. printk打印时会调用console_drivers链表的所有console进行打印,也就是会输出
到多个console上。
3.
/dev/tty0, Current virtual console(当前正在使用的vc)
/dev/tty, 相对于某个进程的控制终端(controlling tty)
/dev/console, 一般等于/dev/tty0
在tty_open中/dev/console的tty_driver是根据console_device得到的,也就是从
console_drivers中搜一个合适的,一般会是/dev/tty0
http://www.linux-mips.org/wiki/Serial_Driver_and_Console
Writing the kernel console driver ~
First of all, the kernel needs a very simple serial driver that only allows to
output characters. It should not use interrupts nor DMA to be as simple as
possible. It is used to display all kernel messages printed with printk().
http://www.linux.it/~rubini/docs/sercons/sercons.html
it is called directly from printk. Since printk can be called at any time,
even at interrupt time, the write function of a console should not sleep for
any noticeable amount of time. To prevent data corruption due to reentrancy,
printk is protected by a spinlock and runs with interrupts disabled;
On the other hand, you may want to see all messages that are printed before a
system panic, so for maximum reliability the console print function should not
return before data is actually output. For this reason, the serial console
driver operates in a busy loop and its write function doesn't return before
the last byte has been transmitted
每个tty(tty1,tty2...)都有一个buffer用于存放其该显示的东东,在tty切换的时候就要
重新显示该buffer.(con_switch)
/dev/console跟register_console的console是很有关系的,/dev/console就是这些注册
的console的一个。这些console包括2个功能,1)作为console使用,内核中使用struct
console表示,提供给printk使用,2)作为tty使用,使用tty_driver表示,提供给
/dev/console使用。也就是说,如果一个console没有实现相应的tty的功能,其实是可以
的,这样就只能供printk使用,而不能作为/dev/console。所以要使用/dev/console,
register_console的consoles中至少要有一个提供tty功能
相关阅读 更多 +