Name of user not set #1004601 has uploaded this change for review.

View Change

serial.c: support BAUD rates > 230400 on macOS

use the apple way to set BAUD rates > 2000000 on macOS.

Signed-off-by: Denis Ahrens <denis@h3q.com>
Change-Id: I9c67048b9c7bc704d9b0c4ef4771f708fdb3e0f3
---
M serial.c
1 file changed, 36 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/22/67822/1
diff --git a/serial.c b/serial.c
index 72f9ef6..1a22228 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 @@
return 1;
}
wanted = observed;
+#ifdef __APPLE__
+ int fakebaud = 0;
+ if (baud > 230400)
+ {
+ fakebaud = baud;
+ baud = 19200;
+ }
+#endif
if (baud >= 0) {
if (use_custom_baud(baud, sp_baudtable)) {
if (set_custom_baudrate(fd, baud)) {
@@ -244,6 +256,18 @@
}
// 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;
}


To view, visit change 67822. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I9c67048b9c7bc704d9b0c4ef4771f708fdb3e0f3
Gerrit-Change-Number: 67822
Gerrit-PatchSet: 1
Gerrit-Owner: Name of user not set #1004601
Gerrit-MessageType: newchange