README.iomux 3.6 KB

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