Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

console.h 2.6KB

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