⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 console.txt

📁 linux 内核源代码
💻 TXT
字号:
Console Drivers===============The linux kernel has 2 general types of console drivers.  The first type isassigned by the kernel to all the virtual consoles during the boot process.This type will be called 'system driver', and only one system driver is allowedto exist. The system driver is persistent and it can never be unloaded, thoughit may become inactive.The second type has to be explicitly loaded and unloaded. This will be called'modular driver' by this document. Multiple modular drivers can coexist atany time with each driver sharing the console with other drivers includingthe system driver. However, modular drivers cannot take over the consolethat is currently occupied by another modular driver. (Exception: Drivers thatcall take_over_console() will succeed in the takeover regardless of the typeof driver occupying the consoles.) They can only take over the console that isoccupied by the system driver. In the same token, if the modular driver isreleased by the console, the system driver will take over.Modular drivers, from the programmer's point of view, has to call:	 take_over_console() - load and bind driver to console layer	 give_up_console() - unbind and unload driverIn newer kernels, the following are also available:	 register_con_driver()	 unregister_con_driver()If sysfs is enabled, the contents of /sys/class/vtconsole can beexamined. This shows the console backends currently registered by thesystem which are named vtcon<n> where <n> is an integer from 0 to 15. Thus:       ls /sys/class/vtconsole       .  ..  vtcon0  vtcon1Each directory in /sys/class/vtconsole has 3 files:     ls /sys/class/vtconsole/vtcon0     .  ..  bind  name  ueventWhat do these files signify?     1. bind - this is a read/write file. It shows the status of the driver if        read, or acts to bind or unbind the driver to the virtual consoles        when written to. The possible values are:	0 - means the driver is not bound and if echo'ed, commands the driver	    to unbind        1 - means the driver is bound and if echo'ed, commands the driver to	    bind     2. name - read-only file. Shows the name of the driver in this format:	cat /sys/class/vtconsole/vtcon0/name	(S) VGA+	    '(S)' stands for a (S)ystem driver, ie, it cannot be directly	    commanded to bind or unbind	    'VGA+' is the name of the driver	cat /sys/class/vtconsole/vtcon1/name	(M) frame buffer device	    In this case, '(M)' stands for a (M)odular driver, one that can be	    directly commanded to bind or unbind.     3. uevent - ignore this fileWhen unbinding, the modular driver is detached first, and then the systemdriver takes over the consoles vacated by the driver. Binding, on the otherhand, will bind the driver to the consoles that are currently occupied by asystem driver.NOTE1: Binding and binding must be selected in Kconfig. It's under:Device Drivers -> Character devices -> Support for binding and unbindingconsole driversNOTE2: If any of the virtual consoles are in KD_GRAPHICS mode, then binding orunbinding will not succeed. An example of an application that sets the consoleto KD_GRAPHICS is X.How useful is this feature? This is very useful for console driverdevelopers. By unbinding the driver from the console layer, one can unload thedriver, make changes, recompile, reload and rebind the driver without any needfor rebooting the kernel. For regular users who may want to switch fromframebuffer console to VGA console and vice versa, this feature also makesthis possible. (NOTE NOTE NOTE: Please read fbcon.txt under Documentation/fbfor more details).Notes for developers:=====================take_over_console() is now broken up into:     register_con_driver()     bind_con_driver() - private functiongive_up_console() is a wrapper to unregister_con_driver(), and a driver mustbe fully unbound for this call to succeed. con_is_bound() will check if thedriver is bound or not.Guidelines for console driver writers:=====================================In order for binding to and unbinding from the console to properly work,console drivers must follow these guidelines:1. All drivers, except system drivers, must call either register_con_driver()   or take_over_console(). register_con_driver() will just add the driver to   the console's internal list. It won't take over the   console. take_over_console(), as it name implies, will also take over (or   bind to) the console.2. All resources allocated during con->con_init() must be released in   con->con_deinit().3. All resources allocated in con->con_startup() must be released when the   driver, which was previously bound, becomes unbound.  The console layer   does not have a complementary call to con->con_startup() so it's up to the   driver to check when it's legal to release these resources. Calling   con_is_bound() in con->con_deinit() will help.  If the call returned   false(), then it's safe to release the resources.  This balance has to be   ensured because con->con_startup() can be called again when a request to   rebind the driver to the console arrives.4. Upon exit of the driver, ensure that the driver is totally unbound. If the   condition is satisfied, then the driver must call unregister_con_driver()   or give_up_console().5. unregister_con_driver() can also be called on conditions which make it   impossible for the driver to service console requests.  This can happen   with the framebuffer console that suddenly lost all of its drivers.The current crop of console drivers should still work correctly, but bindingand unbinding them may cause problems. With minimal fixes, these drivers canbe made to work correctly.==========================Antonino Daplas <adaplas@pol.net>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -