Signed-off-by: Denis Ahrens <de...@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;
 }
 
-- 
2.37.0 (Apple Git-136)


_______________________________________________
flashrom mailing list -- flashrom@flashrom.org
To unsubscribe send an email to flashrom-le...@flashrom.org

Reply via email to