gen550_kgdb.c 1.9 KB

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