* config/mn10300/tm-mn10300.h (INIT_FRAME_PC): Delete.
[deliverable/binutils-gdb.git] / gdb / ser-mac.c
1 /* OBSOLETE /* Remote serial interface for local (hardwired) serial ports for Macintosh. */
2 /* OBSOLETE Copyright 1994, 1995, 1996, 1998, 2000 Free Software Foundation, Inc. */
3 /* OBSOLETE Contributed by Cygnus Support. Written by Stan Shebs. */
4 /* OBSOLETE */
5 /* OBSOLETE This file is part of GDB. */
6 /* OBSOLETE */
7 /* OBSOLETE This program is free software; you can redistribute it and/or modify */
8 /* OBSOLETE it under the terms of the GNU General Public License as published by */
9 /* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
10 /* OBSOLETE (at your option) any later version. */
11 /* OBSOLETE */
12 /* OBSOLETE This program is distributed in the hope that it will be useful, */
13 /* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
14 /* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
15 /* OBSOLETE GNU General Public License for more details. */
16 /* OBSOLETE */
17 /* OBSOLETE You should have received a copy of the GNU General Public License */
18 /* OBSOLETE along with this program; if not, write to the Free Software */
19 /* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
20 /* OBSOLETE Boston, MA 02111-1307, USA. */ */
21 /* OBSOLETE */
22 /* OBSOLETE #include "defs.h" */
23 /* OBSOLETE #include "serial.h" */
24 /* OBSOLETE */
25 /* OBSOLETE #include <Types.h> */
26 /* OBSOLETE #include <Devices.h> */
27 /* OBSOLETE /* This is the regular Mac Serial.h, but copied to a different name */
28 /* OBSOLETE so as not to get confused with the GDB serial.h above. */ */
29 /* OBSOLETE #include "MacSerial.h" */
30 /* OBSOLETE */
31 /* OBSOLETE /* This is unused for now. We just return a placeholder. */ */
32 /* OBSOLETE */
33 /* OBSOLETE struct mac_ttystate */
34 /* OBSOLETE { */
35 /* OBSOLETE int bogus; */
36 /* OBSOLETE }; */
37 /* OBSOLETE */
38 /* OBSOLETE static int mac_open (serial_t scb, const char *name); */
39 /* OBSOLETE static void mac_raw (serial_t scb); */
40 /* OBSOLETE static int mac_readchar (serial_t scb, int timeout); */
41 /* OBSOLETE static int mac_setbaudrate (serial_t scb, int rate); */
42 /* OBSOLETE static int mac_write (serial_t scb, const char *str, int len); */
43 /* OBSOLETE static void mac_close (serial_t scb); */
44 /* OBSOLETE static serial_ttystate mac_get_tty_state (serial_t scb); */
45 /* OBSOLETE static int mac_set_tty_state (serial_t scb, serial_ttystate state); */
46 /* OBSOLETE static char *aptr (short p); */
47 /* OBSOLETE */
48 /* OBSOLETE short input_refnum; */
49 /* OBSOLETE short output_refnum; */
50 /* OBSOLETE */
51 /* OBSOLETE char *mac_input_buffer; */
52 /* OBSOLETE char *mac_output_buffer; */
53 /* OBSOLETE */
54 /* OBSOLETE static int */
55 /* OBSOLETE mac_open (serial_t scb, const char *name) */
56 /* OBSOLETE { */
57 /* OBSOLETE OSErr err; */
58 /* OBSOLETE */
59 /* OBSOLETE /* Alloc buffer space first - that way any allocation failures are */
60 /* OBSOLETE intercepted before the serial driver gets involved. */ */
61 /* OBSOLETE if (mac_input_buffer == NULL) */
62 /* OBSOLETE mac_input_buffer = (char *) xmalloc (4096); */
63 /* OBSOLETE /* Match on a name and open a port. */ */
64 /* OBSOLETE if (strcmp (name, "modem") == 0) */
65 /* OBSOLETE { */
66 /* OBSOLETE err = OpenDriver ("\p.AIn", &input_refnum); */
67 /* OBSOLETE if (err != 0) */
68 /* OBSOLETE { */
69 /* OBSOLETE return (-1); */
70 /* OBSOLETE } */
71 /* OBSOLETE err = OpenDriver ("\p.AOut", &output_refnum); */
72 /* OBSOLETE if (err != 0) */
73 /* OBSOLETE { */
74 /* OBSOLETE CloseDriver (input_refnum); */
75 /* OBSOLETE return (-1); */
76 /* OBSOLETE } */
77 /* OBSOLETE } */
78 /* OBSOLETE else if (strcmp (name, "printer") == 0) */
79 /* OBSOLETE { */
80 /* OBSOLETE err = OpenDriver ("\p.BIn", &input_refnum); */
81 /* OBSOLETE if (err != 0) */
82 /* OBSOLETE { */
83 /* OBSOLETE return (-1); */
84 /* OBSOLETE } */
85 /* OBSOLETE err = OpenDriver ("\p.BOut", &output_refnum); */
86 /* OBSOLETE if (err != 0) */
87 /* OBSOLETE { */
88 /* OBSOLETE CloseDriver (input_refnum); */
89 /* OBSOLETE return (-1); */
90 /* OBSOLETE } */
91 /* OBSOLETE /* fake */ */
92 /* OBSOLETE scb->fd = 1; */
93 /* OBSOLETE return 0; */
94 /* OBSOLETE } */
95 /* OBSOLETE else */
96 /* OBSOLETE { */
97 /* OBSOLETE error ("You must specify a valid serial port name; your choices are `modem' or `printer'."); */
98 /* OBSOLETE errno = ENOENT; */
99 /* OBSOLETE return (-1); */
100 /* OBSOLETE } */
101 /* OBSOLETE /* We got something open. */ */
102 /* OBSOLETE if (1 /* using custom buffer */ ) */
103 /* OBSOLETE SerSetBuf (input_refnum, mac_input_buffer, 4096); */
104 /* OBSOLETE /* Set to a GDB-preferred state. */ */
105 /* OBSOLETE SerReset (input_refnum, stop10 | noParity | data8 | baud9600); */
106 /* OBSOLETE SerReset (output_refnum, stop10 | noParity | data8 | baud9600); */
107 /* OBSOLETE { */
108 /* OBSOLETE CntrlParam cb; */
109 /* OBSOLETE struct SerShk *handshake; */
110 /* OBSOLETE */
111 /* OBSOLETE cb.ioCRefNum = output_refnum; */
112 /* OBSOLETE cb.csCode = 14; */
113 /* OBSOLETE handshake = (struct SerShk *) &cb.csParam[0]; */
114 /* OBSOLETE handshake->fXOn = 0; */
115 /* OBSOLETE handshake->fCTS = 0; */
116 /* OBSOLETE handshake->xOn = 0; */
117 /* OBSOLETE handshake->xOff = 0; */
118 /* OBSOLETE handshake->errs = 0; */
119 /* OBSOLETE handshake->evts = 0; */
120 /* OBSOLETE handshake->fInX = 0; */
121 /* OBSOLETE handshake->fDTR = 0; */
122 /* OBSOLETE err = PBControl ((ParmBlkPtr) & cb, 0); */
123 /* OBSOLETE if (err < 0) */
124 /* OBSOLETE return (-1); */
125 /* OBSOLETE } */
126 /* OBSOLETE /* fake */ */
127 /* OBSOLETE scb->fd = 1; */
128 /* OBSOLETE return 0; */
129 /* OBSOLETE } */
130 /* OBSOLETE */
131 /* OBSOLETE static int */
132 /* OBSOLETE mac_noop (serial_t scb) */
133 /* OBSOLETE { */
134 /* OBSOLETE return 0; */
135 /* OBSOLETE } */
136 /* OBSOLETE */
137 /* OBSOLETE static void */
138 /* OBSOLETE mac_raw (serial_t scb) */
139 /* OBSOLETE { */
140 /* OBSOLETE /* Always effectively in raw mode. */ */
141 /* OBSOLETE } */
142 /* OBSOLETE */
143 /* OBSOLETE /* Read a character with user-specified timeout. TIMEOUT is number of seconds */
144 /* OBSOLETE to wait, or -1 to wait forever. Use timeout of 0 to effect a poll. Returns */
145 /* OBSOLETE char if successful. Returns -2 if timeout expired, EOF if line dropped */
146 /* OBSOLETE dead, or -3 for any other error (see errno in that case). */ */
147 /* OBSOLETE */
148 /* OBSOLETE static int */
149 /* OBSOLETE mac_readchar (serial_t scb, int timeout) */
150 /* OBSOLETE { */
151 /* OBSOLETE int status, n; */
152 /* OBSOLETE /* time_t */ unsigned long start_time, now; */
153 /* OBSOLETE OSErr err; */
154 /* OBSOLETE CntrlParam cb; */
155 /* OBSOLETE IOParam pb; */
156 /* OBSOLETE */
157 /* OBSOLETE if (scb->bufcnt-- > 0) */
158 /* OBSOLETE return *scb->bufp++; */
159 /* OBSOLETE */
160 /* OBSOLETE time (&start_time); */
161 /* OBSOLETE */
162 /* OBSOLETE while (1) */
163 /* OBSOLETE { */
164 /* OBSOLETE cb.ioCRefNum = input_refnum; */
165 /* OBSOLETE cb.csCode = 2; */
166 /* OBSOLETE err = PBStatus ((ParmBlkPtr) & cb, 0); */
167 /* OBSOLETE if (err < 0) */
168 /* OBSOLETE return SERIAL_ERROR; */
169 /* OBSOLETE n = *((long *) &cb.csParam[0]); */
170 /* OBSOLETE if (n > 0) */
171 /* OBSOLETE { */
172 /* OBSOLETE pb.ioRefNum = input_refnum; */
173 /* OBSOLETE pb.ioBuffer = (Ptr) (scb->buf); */
174 /* OBSOLETE pb.ioReqCount = (n > 64 ? 64 : n); */
175 /* OBSOLETE err = PBRead ((ParmBlkPtr) & pb, 0); */
176 /* OBSOLETE if (err < 0) */
177 /* OBSOLETE return SERIAL_ERROR; */
178 /* OBSOLETE scb->bufcnt = pb.ioReqCount; */
179 /* OBSOLETE scb->bufcnt--; */
180 /* OBSOLETE scb->bufp = scb->buf; */
181 /* OBSOLETE return *scb->bufp++; */
182 /* OBSOLETE } */
183 /* OBSOLETE else if (timeout == 0) */
184 /* OBSOLETE return SERIAL_TIMEOUT; */
185 /* OBSOLETE else if (timeout == -1) */
186 /* OBSOLETE ; */
187 /* OBSOLETE else */
188 /* OBSOLETE { */
189 /* OBSOLETE time (&now); */
190 /* OBSOLETE if (now > start_time + timeout) */
191 /* OBSOLETE return SERIAL_TIMEOUT; */
192 /* OBSOLETE } */
193 /* OBSOLETE PROGRESS (1); */
194 /* OBSOLETE } */
195 /* OBSOLETE } */
196 /* OBSOLETE */
197 /* OBSOLETE /* mac_{get set}_tty_state() are both dummys to fill out the function */
198 /* OBSOLETE vector. Someday, they may do something real... */ */
199 /* OBSOLETE */
200 /* OBSOLETE static serial_ttystate */
201 /* OBSOLETE mac_get_tty_state (serial_t scb) */
202 /* OBSOLETE { */
203 /* OBSOLETE struct mac_ttystate *state; */
204 /* OBSOLETE */
205 /* OBSOLETE state = (struct mac_ttystate *) xmalloc (sizeof *state); */
206 /* OBSOLETE */
207 /* OBSOLETE return (serial_ttystate) state; */
208 /* OBSOLETE } */
209 /* OBSOLETE */
210 /* OBSOLETE static int */
211 /* OBSOLETE mac_set_tty_state (serial_t scb, serial_ttystate ttystate) */
212 /* OBSOLETE { */
213 /* OBSOLETE return 0; */
214 /* OBSOLETE } */
215 /* OBSOLETE */
216 /* OBSOLETE static int */
217 /* OBSOLETE mac_noflush_set_tty_state (serial_t scb, serial_ttystate new_ttystate, */
218 /* OBSOLETE serial_ttystate old_ttystate) */
219 /* OBSOLETE { */
220 /* OBSOLETE return 0; */
221 /* OBSOLETE } */
222 /* OBSOLETE */
223 /* OBSOLETE static void */
224 /* OBSOLETE mac_print_tty_state (serial_t scb, */
225 /* OBSOLETE serial_ttystate ttystate, */
226 /* OBSOLETE struct ui_file *stream) */
227 /* OBSOLETE { */
228 /* OBSOLETE /* Nothing to print. */ */
229 /* OBSOLETE return; */
230 /* OBSOLETE } */
231 /* OBSOLETE */
232 /* OBSOLETE /* If there is a tricky formula to relate real baud rates */
233 /* OBSOLETE to what the serial driver wants, we should use it. Until */
234 /* OBSOLETE we get one, this table will have to do. */ */
235 /* OBSOLETE */
236 /* OBSOLETE static struct */
237 /* OBSOLETE { */
238 /* OBSOLETE int real_rate; */
239 /* OBSOLETE int bits; */
240 /* OBSOLETE } */
241 /* OBSOLETE mac_baud_rate_table[] = */
242 /* OBSOLETE { */
243 /* OBSOLETE { */
244 /* OBSOLETE 57600, baud57600 */
245 /* OBSOLETE } */
246 /* OBSOLETE , */
247 /* OBSOLETE { */
248 /* OBSOLETE 38400, 1 */
249 /* OBSOLETE } */
250 /* OBSOLETE , */
251 /* OBSOLETE { */
252 /* OBSOLETE 19200, baud19200 */
253 /* OBSOLETE } */
254 /* OBSOLETE , */
255 /* OBSOLETE { */
256 /* OBSOLETE 9600, baud9600 */
257 /* OBSOLETE } */
258 /* OBSOLETE , */
259 /* OBSOLETE { */
260 /* OBSOLETE 7200, baud7200 */
261 /* OBSOLETE } */
262 /* OBSOLETE , */
263 /* OBSOLETE { */
264 /* OBSOLETE 4800, baud4800 */
265 /* OBSOLETE } */
266 /* OBSOLETE , */
267 /* OBSOLETE { */
268 /* OBSOLETE 3600, baud3600 */
269 /* OBSOLETE } */
270 /* OBSOLETE , */
271 /* OBSOLETE { */
272 /* OBSOLETE 2400, baud2400 */
273 /* OBSOLETE } */
274 /* OBSOLETE , */
275 /* OBSOLETE { */
276 /* OBSOLETE 1800, baud1800 */
277 /* OBSOLETE } */
278 /* OBSOLETE , */
279 /* OBSOLETE { */
280 /* OBSOLETE 1200, baud1200 */
281 /* OBSOLETE } */
282 /* OBSOLETE , */
283 /* OBSOLETE { */
284 /* OBSOLETE 600, baud600 */
285 /* OBSOLETE } */
286 /* OBSOLETE , */
287 /* OBSOLETE { */
288 /* OBSOLETE 300, baud300 */
289 /* OBSOLETE } */
290 /* OBSOLETE , */
291 /* OBSOLETE { */
292 /* OBSOLETE 0, 0 */
293 /* OBSOLETE } */
294 /* OBSOLETE }; */
295 /* OBSOLETE */
296 /* OBSOLETE static int */
297 /* OBSOLETE mac_set_baud_rate (serial_t scb, int rate) */
298 /* OBSOLETE { */
299 /* OBSOLETE int i, bits; */
300 /* OBSOLETE */
301 /* OBSOLETE for (i = 0; mac_baud_rate_table[i].real_rate != 0; ++i) */
302 /* OBSOLETE { */
303 /* OBSOLETE if (mac_baud_rate_table[i].real_rate == rate) */
304 /* OBSOLETE { */
305 /* OBSOLETE bits = mac_baud_rate_table[i].bits; */
306 /* OBSOLETE break; */
307 /* OBSOLETE } */
308 /* OBSOLETE } */
309 /* OBSOLETE SerReset (input_refnum, stop10 | noParity | data8 | bits); */
310 /* OBSOLETE SerReset (output_refnum, stop10 | noParity | data8 | bits); */
311 /* OBSOLETE } */
312 /* OBSOLETE */
313 /* OBSOLETE static int */
314 /* OBSOLETE mac_set_stop_bits (serial_t scb, int num) */
315 /* OBSOLETE { */
316 /* OBSOLETE return 0; */
317 /* OBSOLETE } */
318 /* OBSOLETE */
319 /* OBSOLETE int first_mac_write = 0; */
320 /* OBSOLETE */
321 /* OBSOLETE static int */
322 /* OBSOLETE mac_write (serial_t scb, const char *str, int len) */
323 /* OBSOLETE { */
324 /* OBSOLETE OSErr err; */
325 /* OBSOLETE IOParam pb; */
326 /* OBSOLETE */
327 /* OBSOLETE if (first_mac_write++ < 4) */
328 /* OBSOLETE { */
329 /* OBSOLETE sleep (1); */
330 /* OBSOLETE } */
331 /* OBSOLETE pb.ioRefNum = output_refnum; */
332 /* OBSOLETE pb.ioBuffer = (Ptr) str; */
333 /* OBSOLETE pb.ioReqCount = len; */
334 /* OBSOLETE err = PBWrite ((ParmBlkPtr) & pb, 0); */
335 /* OBSOLETE if (err < 0) */
336 /* OBSOLETE { */
337 /* OBSOLETE return 1; */
338 /* OBSOLETE } */
339 /* OBSOLETE return 0; */
340 /* OBSOLETE } */
341 /* OBSOLETE */
342 /* OBSOLETE static void */
343 /* OBSOLETE mac_close (serial_t scb) */
344 /* OBSOLETE { */
345 /* OBSOLETE if (input_refnum) */
346 /* OBSOLETE { */
347 /* OBSOLETE if (1 /* custom buffer */ ) */
348 /* OBSOLETE SerSetBuf (input_refnum, mac_input_buffer, 0); */
349 /* OBSOLETE CloseDriver (input_refnum); */
350 /* OBSOLETE input_refnum = 0; */
351 /* OBSOLETE } */
352 /* OBSOLETE if (output_refnum) */
353 /* OBSOLETE { */
354 /* OBSOLETE if (0 /* custom buffer */ ) */
355 /* OBSOLETE SerSetBuf (input_refnum, mac_output_buffer, 0); */
356 /* OBSOLETE CloseDriver (output_refnum); */
357 /* OBSOLETE output_refnum = 0; */
358 /* OBSOLETE } */
359 /* OBSOLETE } */
360 /* OBSOLETE */
361 /* OBSOLETE static struct serial_ops mac_ops = */
362 /* OBSOLETE { */
363 /* OBSOLETE "hardwire", */
364 /* OBSOLETE 0, */
365 /* OBSOLETE mac_open, */
366 /* OBSOLETE mac_close, */
367 /* OBSOLETE mac_readchar, */
368 /* OBSOLETE mac_write, */
369 /* OBSOLETE mac_noop, /* flush output */ */
370 /* OBSOLETE mac_noop, /* flush input */ */
371 /* OBSOLETE mac_noop, /* send break -- currently only for nindy */ */
372 /* OBSOLETE mac_raw, */
373 /* OBSOLETE mac_get_tty_state, */
374 /* OBSOLETE mac_set_tty_state, */
375 /* OBSOLETE mac_print_tty_state, */
376 /* OBSOLETE mac_noflush_set_tty_state, */
377 /* OBSOLETE mac_set_baud_rate, */
378 /* OBSOLETE mac_set_stop_bits, */
379 /* OBSOLETE mac_noop, /* wait for output to drain */ */
380 /* OBSOLETE }; */
381 /* OBSOLETE */
382 /* OBSOLETE void */
383 /* OBSOLETE _initialize_ser_mac (void) */
384 /* OBSOLETE { */
385 /* OBSOLETE serial_add_interface (&mac_ops); */
386 /* OBSOLETE } */
This page took 0.038424 seconds and 4 git commands to generate.