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.

debugcon.c 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. *
  19. * You can also choose to distribute this program under the terms of
  20. * the Unmodified Binary Distribution Licence (as given in the file
  21. * COPYING.UBDL), provided that you have satisfied its requirements.
  22. */
  23. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  24. /** @file
  25. *
  26. * Debug port console
  27. *
  28. * The debug port is supported by bochs (via the "port_e9_hack"
  29. * configuration file directive) and by qemu (via the "-debugcon"
  30. * command-line option).
  31. */
  32. #include <stdint.h>
  33. #include <ipxe/io.h>
  34. #include <ipxe/console.h>
  35. #include <ipxe/init.h>
  36. #include <config/console.h>
  37. /** Debug port */
  38. #define DEBUG_PORT 0xe9
  39. /** Debug port installation check magic value */
  40. #define DEBUG_PORT_CHECK 0xe9
  41. /* Set default console usage if applicable */
  42. #if ! ( defined ( CONSOLE_DEBUGCON ) && CONSOLE_EXPLICIT ( CONSOLE_DEBUGCON ) )
  43. #undef CONSOLE_DEBUGCON
  44. #define CONSOLE_DEBUGCON ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_TUI )
  45. #endif
  46. /**
  47. * Print a character to debug port console
  48. *
  49. * @v character Character to be printed
  50. */
  51. static void debugcon_putchar ( int character ) {
  52. /* Write character to debug port */
  53. outb ( character, DEBUG_PORT );
  54. }
  55. /** Debug port console driver */
  56. struct console_driver debugcon_console __console_driver = {
  57. .putchar = debugcon_putchar,
  58. .usage = CONSOLE_DEBUGCON,
  59. };
  60. /**
  61. * Initialise debug port console
  62. *
  63. */
  64. static void debugcon_init ( void ) {
  65. uint8_t check;
  66. /* Check if console is present */
  67. check = inb ( DEBUG_PORT );
  68. if ( check != DEBUG_PORT_CHECK ) {
  69. DBG ( "Debug port not present; disabling console\n" );
  70. debugcon_console.disabled = CONSOLE_DISABLED;
  71. }
  72. }
  73. /**
  74. * Debug port console initialisation function
  75. */
  76. struct init_fn debugcon_init_fn __init_fn ( INIT_EARLY ) = {
  77. .initialise = debugcon_init,
  78. };