gen550_kgdb.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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/config.h>
  18. #include <linux/types.h>
  19. #include <linux/kernel.h>
  20. #include <asm/machdep.h>
  21. extern unsigned long serial_init(int, void *);
  22. extern unsigned long serial_getc(unsigned long);
  23. extern unsigned long serial_putc(unsigned long, unsigned char);
  24. #if defined(CONFIG_KGDB_TTYS0)
  25. #define KGDB_PORT 0
  26. #elif defined(CONFIG_KGDB_TTYS1)
  27. #define KGDB_PORT 1
  28. #elif defined(CONFIG_KGDB_TTYS2)
  29. #define KGDB_PORT 2
  30. #elif defined(CONFIG_KGDB_TTYS3)
  31. #define KGDB_PORT 3
  32. #else
  33. #error "invalid kgdb_tty port"
  34. #endif
  35. static volatile unsigned int kgdb_debugport;
  36. void putDebugChar(unsigned char c)
  37. {
  38. if (kgdb_debugport == 0)
  39. kgdb_debugport = serial_init(KGDB_PORT, NULL);
  40. serial_putc(kgdb_debugport, c);
  41. }
  42. int getDebugChar(void)
  43. {
  44. if (kgdb_debugport == 0)
  45. kgdb_debugport = serial_init(KGDB_PORT, NULL);
  46. return(serial_getc(kgdb_debugport));
  47. }
  48. void kgdb_interruptible(int enable)
  49. {
  50. return;
  51. }
  52. void putDebugString(char* str)
  53. {
  54. while (*str != '\0') {
  55. putDebugChar(*str);
  56. str++;
  57. }
  58. putDebugChar('\r');
  59. return;
  60. }
  61. /*
  62. * Note: gen550_init() must be called already on the port we are going
  63. * to use.
  64. */
  65. void
  66. gen550_kgdb_map_scc(void)
  67. {
  68. printk(KERN_DEBUG "kgdb init\n");
  69. if (ppc_md.early_serial_map)
  70. ppc_md.early_serial_map();
  71. kgdb_debugport = serial_init(KGDB_PORT, NULL);
  72. }