Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 30431
b: refs/heads/master
c: 61a46dc
h: refs/heads/master
i:
  30429: 4ff6b01
  30427: 1416822
  30423: 5fbcb52
  30415: cd5d09b
  30399: 1779126
v: v3
  • Loading branch information
Linus Torvalds committed Jun 26, 2006
1 parent 80606d0 commit a4dc080
Show file tree
Hide file tree
Showing 290 changed files with 11,461 additions and 9,276 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8070b2b1ecbeb5437c92c33b4dcea1d8d80399ee
refs/heads/master: 61a46dc9d1c10d07a2ed6b7d346b868803b52506
144 changes: 144 additions & 0 deletions trunk/Documentation/console/console.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
Console Drivers
===============

The linux kernel has 2 general types of console drivers. The first type is
assigned 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 allowed
to exist. The system driver is persistent and it can never be unloaded, though
it 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 at
any time with each driver sharing the console with other drivers including
the system driver. However, modular drivers cannot take over the console
that is currently occupied by another modular driver. (Exception: Drivers that
call take_over_console() will succeed in the takeover regardless of the type
of driver occupying the consoles.) They can only take over the console that is
occupied by the system driver. In the same token, if the modular driver is
released 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 driver

In newer kernels, the following are also available:

register_con_driver()
unregister_con_driver()

If sysfs is enabled, the contents of /sys/class/vtconsole can be
examined. This shows the console backends currently registered by the
system which are named vtcon<n> where <n> is an integer fro 0 to 15. Thus:

ls /sys/class/vtconsole
. .. vtcon0 vtcon1

Each directory in /sys/class/vtconsole has 3 files:

ls /sys/class/vtconsole/vtcon0
. .. bind name uevent

What 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 file

When unbinding, the modular driver is detached first, and then the system
driver takes over the consoles vacated by the driver. Binding, on the other
hand, will bind the driver to the consoles that are currently occupied by a
system driver.

NOTE1: Binding and binding must be selected in Kconfig. It's under:

Device Drivers -> Character devices -> Support for binding and unbinding
console drivers

NOTE2: If any of the virtual consoles are in KD_GRAPHICS mode, then binding or
unbinding will not succeed. An example of an application that sets the console
to KD_GRAPHICS is X.

How useful is this feature? This is very useful for console driver
developers. By unbinding the driver from the console layer, one can unload the
driver, make changes, recompile, reload and rebind the driver without any need
for rebooting the kernel. For regular users who may want to switch from
framebuffer console to VGA console and vice versa, this feature also makes
this possible. (NOTE NOTE NOTE: Please read fbcon.txt under Documentation/fb
for more details).

Notes for developers:
=====================

take_over_console() is now broken up into:

register_con_driver()
bind_con_driver() - private function

give_up_console() is a wrapper to unregister_con_driver(), and a driver must
be fully unbound for this call to succeed. con_is_bound() will check if the
driver 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 binding
and unbinding them may cause problems. With minimal fixes, these drivers can
be made to work correctly.

==========================
Antonino Daplas <adaplas@pol.net>

180 changes: 176 additions & 4 deletions trunk/Documentation/fb/fbcon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ C. Boot options

The angle can be changed anytime afterwards by 'echoing' the same
numbers to any one of the 2 attributes found in
/sys/class/graphics/fb{x}
/sys/class/graphics/fbcon

con_rotate - rotate the display of the active console
con_rotate_all - rotate the display of all consoles
rotate - rotate the display of the active console
rotate_all - rotate the display of all consoles

Console rotation will only become available if Console Rotation
Support is compiled in your kernel.
Expand All @@ -148,5 +148,177 @@ C. Boot options
Actually, the underlying fb driver is totally ignorant of console
rotation.

---
C. Attaching, Detaching and Unloading

Before going on on how to attach, detach and unload the framebuffer console, an
illustration of the dependencies may help.

The console layer, as with most subsystems, needs a driver that interfaces with
the hardware. Thus, in a VGA console:

console ---> VGA driver ---> hardware.

Assuming the VGA driver can be unloaded, one must first unbind the VGA driver
from the console layer before unloading the driver. The VGA driver cannot be
unloaded if it is still bound to the console layer. (See
Documentation/console/console.txt for more information).

This is more complicated in the case of the the framebuffer console (fbcon),
because fbcon is an intermediate layer between the console and the drivers:

console ---> fbcon ---> fbdev drivers ---> hardware

The fbdev drivers cannot be unloaded if it's bound to fbcon, and fbcon cannot
be unloaded if it's bound to the console layer.

So to unload the fbdev drivers, one must first unbind fbcon from the console,
then unbind the fbdev drivers from fbcon. Fortunately, unbinding fbcon from
the console layer will automatically unbind framebuffer drivers from
fbcon. Thus, there is no need to explicitly unbind the fbdev drivers from
fbcon.

So, how do we unbind fbcon from the console? Part of the answer is in
Documentation/console/console.txt. To summarize:

Echo a value to the bind file that represents the framebuffer console
driver. So assuming vtcon1 represents fbcon, then:

echo 1 > sys/class/vtconsole/vtcon1/bind - attach framebuffer console to
console layer
echo 0 > sys/class/vtconsole/vtcon1/bind - detach framebuffer console from
console layer

If fbcon is detached from the console layer, your boot console driver (which is
usually VGA text mode) will take over. A few drivers (rivafb and i810fb) will
restore VGA text mode for you. With the rest, before detaching fbcon, you
must take a few additional steps to make sure that your VGA text mode is
restored properly. The following is one of the several methods that you can do:

1. Download or install vbetool. This utility is included with most
distributions nowadays, and is usually part of the suspend/resume tool.

2. In your kernel configuration, ensure that CONFIG_FRAMEBUFFER_CONSOLE is set
to 'y' or 'm'. Enable one or more of your favorite framebuffer drivers.

3. Boot into text mode and as root run:

vbetool vbestate save > <vga state file>

The above command saves the register contents of your graphics
hardware to <vga state file>. You need to do this step only once as
the state file can be reused.

4. If fbcon is compiled as a module, load fbcon by doing:

modprobe fbcon

5. Now to detach fbcon:

vbetool vbestate restore < <vga state file> && \
echo 0 > /sys/class/vtconsole/vtcon1/bind

6. That's it, you're back to VGA mode. And if you compiled fbcon as a module,
you can unload it by 'rmmod fbcon'

7. To reattach fbcon:

echo 1 > /sys/class/vtconsole/vtcon1/bind

8. Once fbcon is unbound, all drivers registered to the system will also
become unbound. This means that fbcon and individual framebuffer drivers
can be unloaded or reloaded at will. Reloading the drivers or fbcon will
automatically bind the console, fbcon and the drivers together. Unloading
all the drivers without unloading fbcon will make it impossible for the
console to bind fbcon.

Notes for vesafb users:
=======================

Unfortunately, if your bootline includes a vga=xxx parameter that sets the
hardware in graphics mode, such as when loading vesafb, vgacon will not load.
Instead, vgacon will replace the default boot console with dummycon, and you
won't get any display after detaching fbcon. Your machine is still alive, so
you can reattach vesafb. However, to reattach vesafb, you need to do one of
the following:

Variation 1:

a. Before detaching fbcon, do

vbetool vbemode save > <vesa state file> # do once for each vesafb mode,
# the file can be reused

b. Detach fbcon as in step 5.

c. Attach fbcon

vbetool vbestate restore < <vesa state file> && \
echo 1 > /sys/class/vtconsole/vtcon1/bind

Variation 2:

a. Before detaching fbcon, do:
echo <ID> > /sys/class/tty/console/bind


vbetool vbemode get

b. Take note of the mode number

b. Detach fbcon as in step 5.

c. Attach fbcon:

vbetool vbemode set <mode number> && \
echo 1 > /sys/class/vtconsole/vtcon1/bind

Samples:
========

Here are 2 sample bash scripts that you can use to bind or unbind the
framebuffer console driver if you are in an X86 box:

---------------------------------------------------------------------------
#!/bin/bash
# Unbind fbcon

# Change this to where your actual vgastate file is located
# Or Use VGASTATE=$1 to indicate the state file at runtime
VGASTATE=/tmp/vgastate

# path to vbetool
VBETOOL=/usr/local/bin


for (( i = 0; i < 16; i++))
do
if test -x /sys/class/vtconsole/vtcon$i; then
if [ `cat /sys/class/vtconsole/vtcon$i/name | grep -c "frame buffer"` \
= 1 ]; then
if test -x $VBETOOL/vbetool; then
echo Unbinding vtcon$i
$VBETOOL/vbetool vbestate restore < $VGASTATE
echo 0 > /sys/class/vtconsole/vtcon$i/bind
fi
fi
fi
done

---------------------------------------------------------------------------
#!/bin/bash
# Bind fbcon

for (( i = 0; i < 16; i++))
do
if test -x /sys/class/vtconsole/vtcon$i; then
if [ `cat /sys/class/vtconsole/vtcon$i/name | grep -c "frame buffer"` \
= 1 ]; then
echo Unbinding vtcon$i
echo 1 > /sys/class/vtconsole/vtcon$i/bind
fi
fi
done
---------------------------------------------------------------------------

--
Antonino Daplas <adaplas@pol.net>
8 changes: 8 additions & 0 deletions trunk/Documentation/filesystems/ext3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ noquota
grpquota
usrquota

bh (*) ext3 associates buffer heads to data pages to
nobh (a) cache disk block mapping information
(b) link pages into transaction to provide
ordering guarantees.
"bh" option forces use of buffer heads.
"nobh" option tries to avoid associating buffer
heads (supported only for "writeback" mode).


Specification
=============
Expand Down
Loading

0 comments on commit a4dc080

Please sign in to comment.