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

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