Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

bios_console.c 2.1KB

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