gen550_kgdb.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Generic 16550 kgdb support intended to be useful on a variety
  3. * of platforms. To enable this support, it is necessary to set
  4. * the CONFIG_GEN550 option. Any virtual mapping of the serial
  5. * port(s) to be used can be accomplished by setting
  6. * ppc_md.early_serial_map to a platform-specific mapping function.
  7. *
  8. * Adapted from ppc4xx_kgdb.c.
  9. *
  10. * Author: Matt Porter <mporter@kernel.crashing.org>
  11. *
  12. * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under
  13. * the terms of the GNU General Public License version 2. This program
  14. * is licensed "as is" without any warranty of any kind, whether express
  15. * or implied.
  16. */
  17. #include <linux/types.h>
  18. #include <linux/kernel.h>
  19. #include <asm/machdep.h>
  20. extern unsigned long serial_init(int, void *);
  21. extern unsigned long serial_getc(unsigned long);
  22. extern unsigned long serial_putc(unsigned long, unsigned char);
  23. #if defined(CONFIG_KGDB_TTYS0)
  24. #define KGDB_PORT 0
  25. #elif defined(CONFIG_KGDB_TTYS1)
  26. #define KGDB_PORT 1
  27. #elif defined(CONFIG_KGDB_TTYS2)
  28. #define KGDB_PORT 2
  29. #elif defined(CONFIG_KGDB_TTYS3)
  30. #define KGDB_PORT 3
  31. #else
  32. #error "invalid kgdb_tty port"
  33. #endif
  34. static volatile unsigned int kgdb_debugport;
  35. void putDebugChar(unsigned char c)
  36. {
  37. if (kgdb_debugport == 0)
  38. kgdb_debugport = serial_init(KGDB_PORT, NULL);
  39. serial_putc(kgdb_debugport, c);
  40. }
  41. int getDebugChar(void)
  42. {
  43. if (kgdb_debugport == 0)
  44. kgdb_debugport = serial_init(KGDB_PORT, NULL);
  45. return(serial_getc(kgdb_debugport));
  46. }
  47. void kgdb_interruptible(int enable)
  48. {
  49. return;
  50. }
  51. void putDebugString(char* str)
  52. {
  53. while (*str != '\0') {
  54. putDebugChar(*str);
  55. str++;
  56. }
  57. putDebugChar('\r');
  58. return;
  59. }
  60. /*
  61. * Note: gen550_init() must be called already on the port we are going
  62. * to use.
  63. */
  64. void
  65. gen550_kgdb_map_scc(void)
  66. {
  67. printk(KERN_DEBUG "kgdb init\n");
  68. if (ppc_md.early_serial_map)
  69. ppc_md.early_serial_map();
  70. kgdb_debugport = serial_init(KGDB_PORT, NULL);
  71. }