]>
git.ipfire.org Git - people/ms/u-boot.git/blob - tools/gdb/serial.c
3 * Murray Jensen <Murray.Jensen@csiro.au>
5 * SPDX-License-Identifier: GPL-2.0+
14 #if defined(__sun__) || \
15 defined(__OpenBSD__) || \
16 defined(__FreeBSD__) || \
17 defined(__NetBSD__) || \
19 static struct termios tios
= { BRKINT
, 0, B115200
|CS8
|CREAD
, 0, { 0 } };
21 static struct termios tios
= { BRKINT
, 0, B115200
|CS8
|CREAD
, 0, 0 };
24 static struct speedmap
{
28 { "50", B50
}, { "75", B75
}, { "110", B110
},
29 { "134", B134
}, { "150", B150
}, { "200", B200
},
30 { "300", B300
}, { "600", B600
}, { "1200", B1200
},
31 { "1800", B1800
}, { "2400", B2400
}, { "4800", B4800
},
32 { "9600", B9600
}, { "19200", B19200
}, { "38400", B38400
},
37 { "115200", B115200
},
39 { "153600", B153600
},
41 { "230400", B230400
},
43 { "307200", B307200
},
49 static int nspeeds
= sizeof speedmap
/ sizeof speedmap
[0];
54 struct speedmap
*smp
= speedmap
, *esmp
= &speedmap
[nspeeds
];
57 if (strcmp(str
, smp
->str
) == 0)
65 serialopen(char *device
, speed_t speed
)
69 if (cfsetospeed(&tios
, speed
) < 0)
72 if ((fd
= open(device
, O_RDWR
)) < 0)
75 if (tcsetattr(fd
, TCSAFLUSH
, &tios
) < 0) {
84 serialreadchar(int fd
, int timeout
)
97 /* this is a fucking horrible quick hack - fix this */
99 if ((n
= select(fd
+ 1, &fds
, 0, 0, &tv
)) < 0)
103 return SERIAL_TIMEOUT
;
105 if ((n
= read(fd
, &ch
, 1)) < 0)
115 serialwrite(int fd
, char *buf
, int len
)
120 n
= write(fd
, buf
, len
);