Message ID | 21CFC5F5-194D-4166-B031-A441665BD59E@h3q.com |
---|---|
State | New |
Headers | show |
Series | serial.c: support BAUD rates > 230400 on macOS | expand |
Hi there, thanks for your patch. Could you push it to review.coreboot.org please? // Felix On Mon, 2022-09-19 at 14:53 +0200, Denis Ahrens wrote: > > > Signed-off-by: Denis Ahrens <denis@h3q.com> > --- > serial.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/serial.c b/serial.c > index 72f9ef6..0f86e41 100644 > --- a/serial.c > +++ b/serial.c > @@ -36,6 +36,10 @@ > #include "programmer.h" > #include "custom_baud.h" > > +#ifdef __APPLE__ > +#include <IOKit/serial/ioss.h> > +#endif > + > fdtype sp_fd = SER_INV_FD; > > /* There is no way defined by POSIX to use arbitrary baud rates. It > only defines some macros that can be used to > @@ -185,6 +189,14 @@ int serialport_config(fdtype fd, int baud) > return 1; > } > wanted = observed; > +#ifdef __APPLE__ > + int fakebaud = 0; > + if (baud > 230400) > + { > + fakebaud = baud; > + baud = 115200; > + } > +#endif > if (baud >= 0) { > if (use_custom_baud(baud, sp_baudtable)) { > if (set_custom_baudrate(fd, baud)) { > @@ -244,6 +256,18 @@ int serialport_config(fdtype fd, int baud) > } > // FIXME: display actual baud rate - at least if none was > specified by the user. > #endif > + > +#ifdef __APPLE__ > + if (fakebaud) > + { > + cfmakeraw(&wanted); > + if (ioctl(fd, IOSSIOSPEED, &fakebaud) == -1) { > + msg_perr("[WARN] ioctl(..., IOSSIOSPEED, > %d).\n", fakebaud); > + msg_perr_strerror("problem with > IOSSIOSPEED"); > + return 1; > + } > + } > +#endif > return 0; > } >
diff --git a/serial.c b/serial.c index 72f9ef6..0f86e41 100644 --- a/serial.c +++ b/serial.c @@ -36,6 +36,10 @@ #include "programmer.h" #include "custom_baud.h" +#ifdef __APPLE__ +#include <IOKit/serial/ioss.h> +#endif + fdtype sp_fd = SER_INV_FD; /* There is no way defined by POSIX to use arbitrary baud rates. It only defines some macros that can be used to @@ -185,6 +189,14 @@ int serialport_config(fdtype fd, int baud) return 1; } wanted = observed; +#ifdef __APPLE__ + int fakebaud = 0; + if (baud > 230400) + { + fakebaud = baud; + baud = 115200; + } +#endif if (baud >= 0) { if (use_custom_baud(baud, sp_baudtable)) { if (set_custom_baudrate(fd, baud)) { @@ -244,6 +256,18 @@ int serialport_config(fdtype fd, int baud) } // FIXME: display actual baud rate - at least if none was specified by the user. #endif + +#ifdef __APPLE__ + if (fakebaud) + { + cfmakeraw(&wanted); + if (ioctl(fd, IOSSIOSPEED, &fakebaud) == -1) { + msg_perr("[WARN] ioctl(..., IOSSIOSPEED, %d).\n", fakebaud); + msg_perr_strerror("problem with IOSSIOSPEED"); + return 1; + } + } +#endif return 0; }
Signed-off-by: Denis Ahrens <denis@h3q.com> --- serial.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)