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. */
5 /* OBSOLETE This file is part of GDB. */
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. */
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. */
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. */ */
22 /* OBSOLETE #include "defs.h" */
23 /* OBSOLETE #include "serial.h" */
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" */
31 /* OBSOLETE /* This is unused for now. We just return a placeholder. */ */
33 /* OBSOLETE struct mac_ttystate */
35 /* OBSOLETE int bogus; */
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); */
48 /* OBSOLETE short input_refnum; */
49 /* OBSOLETE short output_refnum; */
51 /* OBSOLETE char *mac_input_buffer; */
52 /* OBSOLETE char *mac_output_buffer; */
54 /* OBSOLETE static int */
55 /* OBSOLETE mac_open (serial_t scb, const char *name) */
57 /* OBSOLETE OSErr err; */
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) */
66 /* OBSOLETE err = OpenDriver ("\p.AIn", &input_refnum); */
67 /* OBSOLETE if (err != 0) */
69 /* OBSOLETE return (-1); */
71 /* OBSOLETE err = OpenDriver ("\p.AOut", &output_refnum); */
72 /* OBSOLETE if (err != 0) */
74 /* OBSOLETE CloseDriver (input_refnum); */
75 /* OBSOLETE return (-1); */
78 /* OBSOLETE else if (strcmp (name, "printer") == 0) */
80 /* OBSOLETE err = OpenDriver ("\p.BIn", &input_refnum); */
81 /* OBSOLETE if (err != 0) */
83 /* OBSOLETE return (-1); */
85 /* OBSOLETE err = OpenDriver ("\p.BOut", &output_refnum); */
86 /* OBSOLETE if (err != 0) */
88 /* OBSOLETE CloseDriver (input_refnum); */
89 /* OBSOLETE return (-1); */
91 /* OBSOLETE /* fake */ */
92 /* OBSOLETE scb->fd = 1; */
93 /* OBSOLETE return 0; */
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); */
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); */
108 /* OBSOLETE CntrlParam cb; */
109 /* OBSOLETE struct SerShk *handshake; */
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); */
126 /* OBSOLETE /* fake */ */
127 /* OBSOLETE scb->fd = 1; */
128 /* OBSOLETE return 0; */
131 /* OBSOLETE static int */
132 /* OBSOLETE mac_noop (serial_t scb) */
134 /* OBSOLETE return 0; */
137 /* OBSOLETE static void */
138 /* OBSOLETE mac_raw (serial_t scb) */
140 /* OBSOLETE /* Always effectively in raw mode. */ */
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). */ */
148 /* OBSOLETE static int */
149 /* OBSOLETE mac_readchar (serial_t scb, int timeout) */
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; */
157 /* OBSOLETE if (scb->bufcnt-- > 0) */
158 /* OBSOLETE return *scb->bufp++; */
160 /* OBSOLETE time (&start_time); */
162 /* OBSOLETE while (1) */
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) */
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++; */
183 /* OBSOLETE else if (timeout == 0) */
184 /* OBSOLETE return SERIAL_TIMEOUT; */
185 /* OBSOLETE else if (timeout == -1) */
189 /* OBSOLETE time (&now); */
190 /* OBSOLETE if (now > start_time + timeout) */
191 /* OBSOLETE return SERIAL_TIMEOUT; */
193 /* OBSOLETE PROGRESS (1); */
197 /* OBSOLETE /* mac_{get set}_tty_state() are both dummys to fill out the function */
198 /* OBSOLETE vector. Someday, they may do something real... */ */
200 /* OBSOLETE static serial_ttystate */
201 /* OBSOLETE mac_get_tty_state (serial_t scb) */
203 /* OBSOLETE struct mac_ttystate *state; */
205 /* OBSOLETE state = (struct mac_ttystate *) xmalloc (sizeof *state); */
207 /* OBSOLETE return (serial_ttystate) state; */
210 /* OBSOLETE static int */
211 /* OBSOLETE mac_set_tty_state (serial_t scb, serial_ttystate ttystate) */
213 /* OBSOLETE return 0; */
216 /* OBSOLETE static int */
217 /* OBSOLETE mac_noflush_set_tty_state (serial_t scb, serial_ttystate new_ttystate, */
218 /* OBSOLETE serial_ttystate old_ttystate) */
220 /* OBSOLETE return 0; */
223 /* OBSOLETE static void */
224 /* OBSOLETE mac_print_tty_state (serial_t scb, */
225 /* OBSOLETE serial_ttystate ttystate, */
226 /* OBSOLETE struct ui_file *stream) */
228 /* OBSOLETE /* Nothing to print. */ */
229 /* OBSOLETE return; */
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. */ */
236 /* OBSOLETE static struct */
238 /* OBSOLETE int real_rate; */
239 /* OBSOLETE int bits; */
241 /* OBSOLETE mac_baud_rate_table[] = */
244 /* OBSOLETE 57600, baud57600 */
248 /* OBSOLETE 38400, 1 */
252 /* OBSOLETE 19200, baud19200 */
256 /* OBSOLETE 9600, baud9600 */
260 /* OBSOLETE 7200, baud7200 */
264 /* OBSOLETE 4800, baud4800 */
268 /* OBSOLETE 3600, baud3600 */
272 /* OBSOLETE 2400, baud2400 */
276 /* OBSOLETE 1800, baud1800 */
280 /* OBSOLETE 1200, baud1200 */
284 /* OBSOLETE 600, baud600 */
288 /* OBSOLETE 300, baud300 */
296 /* OBSOLETE static int */
297 /* OBSOLETE mac_set_baud_rate (serial_t scb, int rate) */
299 /* OBSOLETE int i, bits; */
301 /* OBSOLETE for (i = 0; mac_baud_rate_table[i].real_rate != 0; ++i) */
303 /* OBSOLETE if (mac_baud_rate_table[i].real_rate == rate) */
305 /* OBSOLETE bits = mac_baud_rate_table[i].bits; */
306 /* OBSOLETE break; */
309 /* OBSOLETE SerReset (input_refnum, stop10 | noParity | data8 | bits); */
310 /* OBSOLETE SerReset (output_refnum, stop10 | noParity | data8 | bits); */
313 /* OBSOLETE static int */
314 /* OBSOLETE mac_set_stop_bits (serial_t scb, int num) */
316 /* OBSOLETE return 0; */
319 /* OBSOLETE int first_mac_write = 0; */
321 /* OBSOLETE static int */
322 /* OBSOLETE mac_write (serial_t scb, const char *str, int len) */
324 /* OBSOLETE OSErr err; */
325 /* OBSOLETE IOParam pb; */
327 /* OBSOLETE if (first_mac_write++ < 4) */
329 /* OBSOLETE sleep (1); */
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) */
337 /* OBSOLETE return 1; */
339 /* OBSOLETE return 0; */
342 /* OBSOLETE static void */
343 /* OBSOLETE mac_close (serial_t scb) */
345 /* OBSOLETE if (input_refnum) */
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; */
352 /* OBSOLETE if (output_refnum) */
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; */
361 /* OBSOLETE static struct serial_ops mac_ops = */
363 /* OBSOLETE "hardwire", */
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 */ */
383 /* OBSOLETE _initialize_ser_mac (void) */
385 /* OBSOLETE serial_add_interface (&mac_ops); */
This page took 0.037103 seconds and 4 git commands to generate.