Add MIPS ELF64 relocs
[deliverable/binutils-gdb.git] / gdb / ser-ocd.c
1 /* Remote serial interface for Macraigor Systems implementation of
2 On-Chip Debugging using serial target box or serial wiggler
3
4 Copyright 1994, 1997, 1998, 1999, 2000, 2001
5 Free Software Foundation, Inc.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
23
24 #include "defs.h"
25 #include "serial.h"
26
27 #ifdef _WIN32
28 #include <windows.h>
29 #endif
30
31 #ifdef _WIN32
32 /* On Windows, this function pointer is initialized to a function in
33 the wiggler DLL. */
34 static int (*dll_do_command) (const char *, char *);
35 #endif
36
37 static int
38 ocd_open (serial_t scb, const char *name)
39 {
40 #ifdef _WIN32
41 /* Find the wiggler DLL which talks to the board. */
42 if (dll_do_command == NULL)
43 {
44 HINSTANCE handle;
45
46 /* FIXME: Should the user be able to configure this? */
47 handle = LoadLibrary ("Wigglers.dll");
48 if (handle == NULL)
49 error ("Can't load Wigglers.dll");
50
51 dll_do_command = ((int (*) (const char *, char *))
52 GetProcAddress (handle, "do_command"));
53 if (dll_do_command == NULL)
54 error ("Can't find do_command function in Wigglers.dll");
55 }
56 #else
57 /* No wiggler DLLs on Unix yet, fail. */
58 error ("Wiggler library not available for this type of host.");
59 #endif /* _WIN32 */
60 return 0;
61 }
62
63 static int
64 ocd_noop (serial_t scb)
65 {
66 return 0;
67 }
68
69 static void
70 ocd_raw (serial_t scb)
71 {
72 /* Always in raw mode */
73 }
74
75 /* We need a buffer to store responses from the Wigglers.dll */
76 #define WIGGLER_BUFF_SIZE 512
77 unsigned char from_wiggler_buffer[WIGGLER_BUFF_SIZE];
78 unsigned char *wiggler_buffer_ptr; /* curr spot in buffer */
79
80 static int
81 ocd_readchar (serial_t scb, int timeout)
82 {
83 /* Catch attempts at reading past the end of the buffer */
84 if (wiggler_buffer_ptr >
85 (from_wiggler_buffer + (sizeof (char *) * WIGGLER_BUFF_SIZE)))
86 error ("ocd_readchar asked to read past the end of the buffer!");
87
88 return (int) *wiggler_buffer_ptr++; /* return curr char and increment ptr */
89 }
90
91 struct ocd_ttystate
92 {
93 int dummy;
94 };
95
96 /* ocd_{get set}_tty_state() are both dummys to fill out the function
97 vector. Someday, they may do something real... */
98
99 static serial_ttystate
100 ocd_get_tty_state (serial_t scb)
101 {
102 struct ocd_ttystate *state;
103
104 state = (struct ocd_ttystate *) xmalloc (sizeof *state);
105
106 return (serial_ttystate) state;
107 }
108
109 static int
110 ocd_set_tty_state (serial_t scb, serial_ttystate ttystate)
111 {
112 return 0;
113 }
114
115 static int
116 ocd_noflush_set_tty_state (serial_t scb, serial_ttystate new_ttystate,
117 serial_ttystate old_ttystate)
118 {
119 return 0;
120 }
121
122 static void
123 ocd_print_tty_state (serial_t scb,
124 serial_ttystate ttystate,
125 struct ui_file *stream)
126 {
127 /* Nothing to print. */
128 return;
129 }
130
131 static int
132 ocd_setbaudrate (serial_t scb, int rate)
133 {
134 return 0;
135 }
136
137 static int
138 ocd_setstopbits (serial_t scb, int rate)
139 {
140 return 0;
141 }
142
143 static int
144 ocd_write (serial_t scb, const char *str, int len)
145 {
146 #ifdef _WIN32
147 /* send packet to Wigglers.dll and store response so we can give it to
148 remote-wiggler.c when get_packet is run */
149 dll_do_command (str, from_wiggler_buffer);
150 wiggler_buffer_ptr = from_wiggler_buffer;
151 #endif
152
153 return 0;
154 }
155
156 static void
157 ocd_close (serial_t scb)
158 {
159 }
160
161 static struct serial_ops ocd_ops =
162 {
163 "ocd",
164 0,
165 ocd_open,
166 ocd_close,
167 ocd_readchar,
168 ocd_write,
169 ocd_noop, /* flush output */
170 ocd_noop, /* flush input */
171 ocd_noop, /* send break -- currently used only for nindy */
172 ocd_raw,
173 ocd_get_tty_state,
174 ocd_set_tty_state,
175 ocd_print_tty_state,
176 ocd_noflush_set_tty_state,
177 ocd_setbaudrate,
178 ocd_setstopbits,
179 ocd_noop, /* wait for output to drain */
180 };
181
182 void
183 _initialize_ser_ocd_bdm (void)
184 {
185 serial_add_interface (&ocd_ops);
186 }
This page took 0.031722 seconds and 4 git commands to generate.