colibri_imx6: fix video stdout in default environment
[oweals/u-boot.git] / doc / README.iomux
1 SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2008
4  * Gary Jennejohn, DENX Software Engineering GmbH <garyj@denx.de>
5  */
6
7 U-Boot console multiplexing
8 ===========================
9
10 HOW CONSOLE MULTIPLEXING WORKS
11 ------------------------------
12
13 This functionality is controlled with CONFIG_CONSOLE_MUX in the board
14 configuration file.
15
16 Two new files, common/iomux.c and include/iomux.h, contain the heart
17 (iomux_doenv()) of the environment setting implementation.
18
19 iomux_doenv() is called in common/cmd_nvedit.c to handle setenv and in
20 common/console.c in console_init_r() during bootup to initialize
21 stdio_devices[].
22
23 A user can use a comma-separated list of devices to set stdin, stdout
24 and stderr.  For example: "setenv stdin serial,nc".  NOTE: No spaces
25 are allowed around the comma(s)!
26
27 The length of the list is limited by malloc(), since the array used
28 is allocated and freed dynamically.
29
30 It should be possible to specify any device which console_assign()
31 finds acceptable, but the code has only been tested with serial and
32 nc.
33
34 iomux_doenv() prevents multiple use of the same device, e.g. "setenv
35 stdin nc,nc,serial" will discard the second nc.  iomux_doenv() is
36 not able to modify the environment, however, so that "pri stdin" still
37 shows "nc,nc,serial".
38
39 The major change in common/console.c was to modify fgetc() to call
40 the iomux_tstc() routine in a for-loop.  iomux_tstc() in turn calls
41 the tstc() routine for every registered device, but exits immediately
42 when one of them returns true.  fgetc() then calls iomux_getc(),
43 which calls the corresponding getc() routine.  fgetc() hangs in
44 the for-loop until iomux_tstc() returns true and the input can be
45 retrieved.
46
47 Thus, a user can type into any device registered for stdin.  No effort
48 has been made to demulitplex simultaneous input from multiple stdin
49 devices.
50
51 fputc() and fputs() have been modified to call iomux_putc() and
52 iomux_puts() respectively, which call the corresponding output
53 routines for every registered device.
54
55 Thus, a user can see the ouput for any device registered for stdout
56 or stderr on all devices registered for stdout or stderr.  As an
57 example, if stdin=serial,nc and stdout=serial,nc then all output
58 for serial, e.g. echos of input on serial, will appear on serial and nc.
59
60 Just as with the old console code, this statement is still true:
61 If not defined in the environment, the first input device is assigned
62 to the 'stdin' file, the first output one to 'stdout' and 'stderr'.
63
64 If CONFIG_SYS_CONSOLE_IS_IN_ENV is defined then multiple input/output
65 devices can be set at boot time if defined in the environment.
66
67 CAVEATS
68 -------
69
70 Note that common/iomux.c calls console_assign() for every registered
71 device as it is discovered.  This means that the environment settings
72 for application consoles will be set to the last device in the list.
73
74 On a slow machine, such as MPC852T clocked at 66MHz, the overhead associated
75 with calling tstc() and then getc() means that copy&paste will normally not
76 work, even when stdin=stdout=stderr=serial.
77 On a faster machine, such as a sequoia, cut&paste of longer (about 80
78 characters) lines works fine when serial is the only device used.
79
80 Using nc as a stdin device results in even more overhead because nc_tstc()
81 is quite slow.  Even on a sequoia cut&paste does not work on the serial
82 interface when nc is added to stdin, although there is no character loss using
83 the ethernet interface for input. In this test case stdin=serial,nc and
84 stdout=serial.
85
86 In addition, the overhead associated with sending to two devices, when one of
87 them is nc, also causes problems.  Even on a sequoia cut&paste does not work
88 on the serial interface (stdin=serial) when nc is added to stdout (stdout=
89 serial,nc).