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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Etherboot routines for PCBIOS firmware.
  2. *
  3. * Body of routines taken from old pcbios.S
  4. */
  5. #ifdef PCBIOS
  6. #include "etherboot.h"
  7. #include "realmode.h"
  8. #include "segoff.h"
  9. #define ZF ( 1 << 6 )
  10. /**************************************************************************
  11. CONSOLE_PUTC - Print a character on console
  12. **************************************************************************/
  13. void console_putc ( int character )
  14. {
  15. struct {
  16. reg16_t ax;
  17. } PACKED in_stack;
  18. RM_FRAGMENT(rm_console_putc,
  19. "sti\n\t"
  20. "popw %ax\n\t"
  21. "movb $0x0e, %ah\n\t"
  22. "movl $1, %ebx\n\t"
  23. "int $0x10\n\t"
  24. "cli\n\t"
  25. );
  26. in_stack.ax.l = character;
  27. real_call ( rm_console_putc, &in_stack, NULL );
  28. }
  29. /**************************************************************************
  30. CONSOLE_GETC - Get a character from console
  31. **************************************************************************/
  32. int console_getc ( void )
  33. {
  34. RM_FRAGMENT(rm_console_getc,
  35. "sti\n\t"
  36. "xorw %ax, %ax\n\t"
  37. "int $0x16\n\t"
  38. "xorb %ah, %ah\n\t"
  39. "cli\n\t"
  40. );
  41. return real_call ( rm_console_getc, NULL, NULL );
  42. }
  43. /**************************************************************************
  44. CONSOLE_ISCHAR - Check for keyboard interrupt
  45. **************************************************************************/
  46. int console_ischar ( void )
  47. {
  48. RM_FRAGMENT(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. );
  56. return ( ( real_call ( rm_console_ischar, NULL, NULL ) & ZF ) == 0 );
  57. }
  58. /**************************************************************************
  59. GETSHIFT - Get keyboard shift state
  60. **************************************************************************/
  61. int getshift ( void )
  62. {
  63. RM_FRAGMENT(rm_getshift,
  64. "sti\n\t"
  65. "movb $2, %ah\n\t"
  66. "int $0x16\n\t"
  67. "andw $0x3, %ax\n\t"
  68. "cli\n\t"
  69. );
  70. return real_call ( rm_getshift, NULL, NULL );
  71. }
  72. #endif /* PCBIOS */