gdbhost.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* gdbhost.c -- ARMulator RDP to gdb comms code: ARM6 Instruction Emulator.
  2. Copyright (C) 1994 Advanced RISC Machines Ltd.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>. */
  13. /***********************************************************/
  14. /* Functions that communicate info back to the debugger... */
  15. /***********************************************************/
  16. #include <stdio.h>
  17. #include <stdarg.h>
  18. #include "armdefs.h"
  19. #include "communicate.h"
  20. #include "dbg_rdi.h"
  21. #include "armos.h"
  22. #define OS_SendNothing 0x0
  23. #define OS_SendChar 0x1
  24. #define OS_SendWord 0x2
  25. #define OS_SendString 0x3
  26. /* Defined in kid.c */
  27. extern int wait_for_osreply (ARMword * reply);
  28. /* A pipe for handling SWI return values that goes straight from the */
  29. /* parent to the ARMulator host interface, bypassing the childs RDP */
  30. /* to RDI interpreter */
  31. int DebuggerARMul[2];
  32. /* The pipes between the two processes */
  33. int mumkid[2];
  34. int kidmum[2];
  35. void
  36. myprint (void *arg, const char *format, va_list ap)
  37. {
  38. #ifdef DEBUG
  39. fprintf (stderr, "Host: myprint\n");
  40. #endif
  41. vfprintf (stderr, format, ap);
  42. }
  43. /* Waits for a keypress on the debuggers' keyboard */
  44. void
  45. mypause (void *arg)
  46. {
  47. #ifdef DEBUG
  48. fprintf (stderr, "Host: mypause\n");
  49. #endif
  50. } /* I do love exciting functions */
  51. void
  52. mywritec (void *arg, int c)
  53. {
  54. #ifdef DEBUG
  55. fprintf (stderr, "Mywrite : %c\n", c);
  56. #endif
  57. MYwrite_char (kidmum[1], RDP_OSOp); /* OS Operation Request Message */
  58. MYwrite_word (kidmum[1], SWI_WriteC); /* Print... */
  59. MYwrite_char (kidmum[1], OS_SendChar); /* ...a single character */
  60. MYwrite_char (kidmum[1], (unsigned char) c);
  61. wait_for_osreply ((ARMword *) 0);
  62. }
  63. int
  64. myreadc (void *arg)
  65. {
  66. char c;
  67. ARMword x;
  68. #ifdef DEBUG
  69. fprintf (stderr, "Host: myreadc\n");
  70. #endif
  71. MYwrite_char (kidmum[1], RDP_OSOp); /* OS Operation Request Message */
  72. MYwrite_word (kidmum[1], SWI_ReadC); /* Read... */
  73. MYwrite_char (kidmum[1], OS_SendNothing);
  74. c = wait_for_osreply (&x);
  75. return (x);
  76. }
  77. int
  78. mywrite (void *arg, char const *buffer, int len)
  79. {
  80. #ifdef DEBUG
  81. fprintf (stderr, "Host: mywrite\n");
  82. #endif
  83. return 0;
  84. }
  85. char *
  86. mygets (void *arg, char *buffer, int len)
  87. {
  88. #ifdef DEBUG
  89. fprintf (stderr, "Host: mygets\n");
  90. #endif
  91. return buffer;
  92. }