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