console.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2000-2009
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #ifndef __CONSOLE_H
  7. #define __CONSOLE_H
  8. #include <stdbool.h>
  9. extern char console_buffer[];
  10. /* common/console.c */
  11. int console_init_f(void); /* Before relocation; uses the serial stuff */
  12. int console_init_r(void); /* After relocation; uses the console stuff */
  13. int console_assign(int file, const char *devname); /* Assign the console */
  14. int ctrlc(void);
  15. int had_ctrlc(void); /* have we had a Control-C since last clear? */
  16. void clear_ctrlc(void); /* clear the Control-C condition */
  17. int disable_ctrlc(int); /* 1 to disable, 0 to enable Control-C detect */
  18. int confirm_yesno(void); /* 1 if input is "y", "Y", "yes" or "YES" */
  19. /**
  20. * console_record_init() - set up the console recording buffers
  21. *
  22. * This should be called as soon as malloc() is available so that the maximum
  23. * amount of console output can be recorded.
  24. */
  25. int console_record_init(void);
  26. /**
  27. * console_record_reset() - reset the console recording buffers
  28. *
  29. * Removes any data in the buffers
  30. */
  31. void console_record_reset(void);
  32. /**
  33. * console_record_reset_enable() - reset and enable the console buffers
  34. *
  35. * This should be called to enable the console buffer.
  36. */
  37. void console_record_reset_enable(void);
  38. /**
  39. * console_record_readline() - Read a line from the console output
  40. *
  41. * This reads the next available line from the console output previously
  42. * recorded.
  43. *
  44. * @str: Place to put string
  45. * @maxlen: Maximum length of @str including nul terminator
  46. * @return length of string returned
  47. */
  48. int console_record_readline(char *str, int maxlen);
  49. /**
  50. * console_record_avail() - Get the number of available bytes in console output
  51. *
  52. * @return available bytes (0 if empty)
  53. */
  54. int console_record_avail(void);
  55. /**
  56. * console_announce_r() - print a U-Boot console on non-serial consoles
  57. *
  58. * When U-Boot starts up with a display it generally does not announce itself
  59. * on the display. The banner is instead emitted on the UART before relocation.
  60. * This function prints a banner on devices which (we assume) did not receive
  61. * it before relocation.
  62. *
  63. * @return 0 (meaning no errors)
  64. */
  65. int console_announce_r(void);
  66. /**
  67. * console_puts_select_stderr() - Output a string to selected console devices
  68. *
  69. * This writes to stderr only. It is useful for outputting errors
  70. *
  71. * @serial_only: true to output only to serial, false to output to everything
  72. * else
  73. * @s: String to output
  74. */
  75. void console_puts_select_stderr(bool serial_only, const char *s);
  76. /*
  77. * CONSOLE multiplexing.
  78. */
  79. #ifdef CONFIG_CONSOLE_MUX
  80. #include <iomux.h>
  81. #endif
  82. #endif