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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef CONSOLE_H
  2. #define CONSOLE_H
  3. #include "stdint.h"
  4. #include "vsprintf.h"
  5. #include <gpxe/tables.h>
  6. /** @file
  7. *
  8. * User interaction.
  9. *
  10. * Various console devices can be selected via the build options
  11. * CONSOLE_FIRMWARE, CONSOLE_SERIAL etc. The console functions
  12. * putchar(), getchar() and iskey() delegate to the individual console
  13. * drivers.
  14. *
  15. */
  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 INIT_FN() has
  24. * completed should set #disabled=1 initially. This allows other
  25. * console devices to still be used to print out early debugging
  26. * 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
  34. * console's initialisation functions (called via INIT_FN())
  35. * will set #disabled=0 upon 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. /**
  73. * Mark a <tt> struct console_driver </tt> as being part of the
  74. * console drivers table.
  75. *
  76. * Use as e.g.
  77. *
  78. * @code
  79. *
  80. * struct console_driver my_console __console_driver = {
  81. * .putchar = my_putchar,
  82. * .getchar = my_getchar,
  83. * .iskey = my_iskey,
  84. * };
  85. *
  86. * @endcode
  87. *
  88. */
  89. #define __console_driver __table ( console, 01 )
  90. /* Function prototypes */
  91. extern void putchar ( int character );
  92. extern int getchar ( void );
  93. extern int iskey ( void );
  94. #endif /* CONSOLE_H */