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.

bios_console.c 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Etherboot routines for PCBIOS firmware.
  2. *
  3. * Body of routines taken from old pcbios.S
  4. */
  5. #include "realmode.h"
  6. #include "console.h"
  7. #define ZF ( 1 << 6 )
  8. /**************************************************************************
  9. bios_putchar - Print a character on console
  10. **************************************************************************/
  11. static void bios_putchar ( int character ) {
  12. REAL_EXEC ( rm_console_putc,
  13. "sti\n\t"
  14. "movb $0x0e, %%ah\n\t"
  15. "movl $1, %%ebx\n\t"
  16. "int $0x10\n\t"
  17. "cli\n\t",
  18. 1,
  19. OUT_CONSTRAINTS ( "=a" ( character ) ),
  20. IN_CONSTRAINTS ( "a" ( character ) ),
  21. CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
  22. /* NOTE: %eax may be clobbered, so must be specified as an output
  23. * parameter, even though we don't then do anything with it.
  24. */
  25. }
  26. /**************************************************************************
  27. bios_getchar - Get a character from console
  28. **************************************************************************/
  29. static int bios_getchar ( void ) {
  30. uint16_t character;
  31. REAL_EXEC ( rm_console_getc,
  32. "sti\n\t"
  33. "xorw %%ax, %%ax\n\t"
  34. "int $0x16\n\t"
  35. "cli\n\t",
  36. 1,
  37. OUT_CONSTRAINTS ( "=a" ( character ) ),
  38. IN_CONSTRAINTS (),
  39. CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
  40. return ( character & 0xff );
  41. }
  42. /**************************************************************************
  43. bios_iskey - Check for keyboard interrupt
  44. **************************************************************************/
  45. static int bios_iskey ( void ) {
  46. uint16_t flags;
  47. REAL_EXEC ( rm_console_ischar,
  48. "sti\n\t"
  49. "movb $1, %%ah\n\t"
  50. "int $0x16\n\t"
  51. "pushfw\n\t"
  52. "popw %%ax\n\t"
  53. "cli\n\t",
  54. 1,
  55. OUT_CONSTRAINTS ( "=a" ( flags ) ),
  56. IN_CONSTRAINTS (),
  57. CLOBBER ( "ebx", "ecx", "edx", "ebp", "esi", "edi" ) );
  58. return ( ( flags & ZF ) == 0 );
  59. }
  60. static struct console_driver bios_console __console_driver = {
  61. .putchar = bios_putchar,
  62. .getchar = bios_getchar,
  63. .iskey = bios_iskey,
  64. };