You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

console.h 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef _IPXE_CONSOLE_H
  2. #define _IPXE_CONSOLE_H
  3. #include <stdio.h>
  4. #include <ipxe/tables.h>
  5. /** @file
  6. *
  7. * User interaction.
  8. *
  9. * Various console devices can be selected via the build options
  10. * CONSOLE_FIRMWARE, CONSOLE_SERIAL etc. The console functions
  11. * putchar(), getchar() and iskey() delegate to the individual console
  12. * drivers.
  13. *
  14. */
  15. FILE_LICENCE ( GPL2_OR_LATER );
  16. /**
  17. * A console driver
  18. *
  19. * Defines the functions that implement a particular console type.
  20. * Must be made part of the console drivers table by using
  21. * #__console_driver.
  22. *
  23. * @note Consoles that cannot be used before their initialisation
  24. * function has completed should set #disabled=1 initially. This
  25. * allows other console devices to still be used to print out early
  26. * debugging messages.
  27. *
  28. */
  29. struct console_driver {
  30. /** Console is disabled.
  31. *
  32. * The console's putchar(), getchar() and iskey() methods will
  33. * not be called while #disabled==1. Typically the console's
  34. * initialisation functions will set #disabled=0 upon
  35. * completion.
  36. *
  37. */
  38. int disabled;
  39. /** Write a character to the console.
  40. *
  41. * @v character Character to be written
  42. * @ret None -
  43. * @err None -
  44. *
  45. */
  46. void ( *putchar ) ( int character );
  47. /** Read a character from the console.
  48. *
  49. * @v None -
  50. * @ret character Character read
  51. * @err None -
  52. *
  53. * If no character is available to be read, this method will
  54. * block. The character read should not be echoed back to the
  55. * console.
  56. *
  57. */
  58. int ( *getchar ) ( void );
  59. /** Check for available input.
  60. *
  61. * @v None -
  62. * @ret True Input is available
  63. * @ret False Input is not available
  64. * @err None -
  65. *
  66. * This should return True if a subsequent call to getchar()
  67. * will not block.
  68. *
  69. */
  70. int ( *iskey ) ( void );
  71. };
  72. /** Console driver table */
  73. #define CONSOLES __table ( struct console_driver, "consoles" )
  74. /**
  75. * Mark a <tt> struct console_driver </tt> as being part of the
  76. * console drivers table.
  77. *
  78. * Use as e.g.
  79. *
  80. * @code
  81. *
  82. * struct console_driver my_console __console_driver = {
  83. * .putchar = my_putchar,
  84. * .getchar = my_getchar,
  85. * .iskey = my_iskey,
  86. * };
  87. *
  88. * @endcode
  89. *
  90. */
  91. #define __console_driver __table_entry ( CONSOLES, 01 )
  92. /* Function prototypes */
  93. extern int iskey ( void );
  94. extern int getkey ( unsigned long timeout );
  95. #endif /* _IPXE_CONSOLE_H */