From patchwork Mon Sep 19 12:53:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Ahrens X-Patchwork-Id: 1681043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flashrom.org (client-ip=78.46.105.101; helo=coreboot.org; envelope-from=flashrom-bounces@flashrom.org; receiver=) Received: from coreboot.org (coreboot.org [78.46.105.101]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MYCLV6Vv5z1ypf for ; Thu, 22 Sep 2022 21:12:50 +1000 (AEST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id A37162F356; Thu, 22 Sep 2022 11:12:45 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 7729920284 for ; Mon, 19 Sep 2022 12:53:39 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mail.h3q.com with ESMTPS (ECDHE-RSA-AES256-GCM-SHA384 encrypted); 19 Sep 2022 12:53:38 -0000 From: Denis Ahrens Mime-Version: 1.0 Message-Id: <21CFC5F5-194D-4166-B031-A441665BD59E@h3q.com> Date: Mon, 19 Sep 2022 14:53:38 +0200 To: flashrom@flashrom.org X-MailFrom: denis@h3q.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-flashrom.flashrom.org-0; header-match-flashrom.flashrom.org-1; header-match-flashrom.flashrom.org-2; header-match-flashrom.flashrom.org-3; header-match-flashrom.flashrom.org-4; header-match-flashrom.flashrom.org-5; header-match-flashrom.flashrom.org-6; header-match-flashrom.flashrom.org-7; header-match-flashrom.flashrom.org-8; header-match-flashrom.flashrom.org-9; header-match-flashrom.flashrom.org-10; header-match-flashrom.flashrom.org-11; header-match-flashrom.flashrom.org-12; header-match-flashrom.flashrom.org-13; header-match-flashrom.flashrom.org-14; header-match-flashrom.flashrom.org-15; header-match-flashrom.flashrom.org-16; header-match-flashrom.flashrom.org-17; header-match-flashrom.flashrom.org-18; header-match-flashrom.flashrom.org-19; header-match-flashrom.flashrom.org-20; header-match-flashrom.flashrom.org-21; header-match-flashrom.flashrom.org- 22; header-match-flashrom.flashrom.org-23; header-match-flashrom.flashrom.org-24; header-match-flashrom.flashrom.org-25; header-match-flashrom.flashrom.org-26; header-match-flashrom.flashrom.org-27; header-match-flashrom.flashrom.org-28; header-match-flashrom.flashrom.org-29; header-match-flashrom.flashrom.org-30; header-match-flashrom.flashrom.org-31; header-match-flashrom.flashrom.org-32; header-match-flashrom.flashrom.org-33; header-match-flashrom.flashrom.org-34; header-match-flashrom.flashrom.org-35; header-match-flashrom.flashrom.org-36; header-match-flashrom.flashrom.org-37; header-match-flashrom.flashrom.org-38; header-match-flashrom.flashrom.org-39; header-match-flashrom.flashrom.org-40; header-match-flashrom.flashrom.org-41; header-match-flashrom.flashrom.org-42; header-match-flashrom.flashrom.org-43; header-match-flashrom.flashrom.org-44; header-match-flashrom.flashrom.org-45; header-match-flashrom.flashrom.org-46; header-match-flashrom.flashrom.org-47; header-match-flash rom.flashrom.org-48; header-match-flashrom.flashrom.org-49; header-match-flashrom.flashrom.org-50; header-match-flashrom.flashrom.org-51; header-match-flashrom.flashrom.org-52; header-match-flashrom.flashrom.org-53; header-match-flashrom.flashrom.org-54; header-match-flashrom.flashrom.org-55; header-match-flashrom.flashrom.org-56; header-match-flashrom.flashrom.org-57; header-match-flashrom.flashrom.org-58; header-match-flashrom.flashrom.org-59; header-match-flashrom.flashrom.org-60; header-match-flashrom.flashrom.org-61; header-match-flashrom.flashrom.org-62; header-match-flashrom.flashrom.org-63; header-match-flashrom.flashrom.org-64; header-match-flashrom.flashrom.org-65; header-match-flashrom.flashrom.org-66; header-match-flashrom.flashrom.org-67; header-match-flashrom.flashrom.org-68; header-match-flashrom.flashrom.org-69; header-match-flashrom.flashrom.org-70; header-match-flashrom.flashrom.org-71; header-match-flashrom.flashrom.org-72; header-match-flashrom.flashrom.org-73; h eader-match-flashrom.flashrom.org-74; header-match-flashrom.flashrom.org-75; header-match-flashrom.flashrom.org-76; header-match-flashrom.flashrom.org-77; header-match-flashrom.flashrom.org-78; header-match-flashrom.flashrom.org-79; header-match-flashrom.flashrom.org-80; header-match-flashrom.flashrom.org-81; header-match-flashrom.flashrom.org-82; header-match-flashrom.flashrom.org-83; header-match-flashrom.flashrom.org-84; header-match-flashrom.flashrom.org-85; header-match-flashrom.flashrom.org-86; header-match-flashrom.flashrom.org-87; header-match-flashrom.flashrom.org-88; header-match-flashrom.flashrom.org-89; header-match-flashrom.flashrom.org-90; header-match-flashrom.flashrom.org-91; header-match-flashrom.flashrom.org-92; header-match-flashrom.flashrom.org-93; header-match-flashrom.flashrom.org-94; header-match-flashrom.flashrom.org-95 Message-ID-Hash: YM75H5CJAJSTER6XCYLZSHYJV3QGXRE3 X-Message-ID-Hash: YM75H5CJAJSTER6XCYLZSHYJV3QGXRE3 X-Mailman-Approved-At: Thu, 22 Sep 2022 11:12:06 +0000 X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [flashrom] [PATCH] serial.c: support BAUD rates > 230400 on macOS List-Id: flashrom discussion and development mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Spamd-Bar: + X-Spam-Level: * Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=flashrom-bounces@flashrom.org Signed-off-by: Denis Ahrens --- 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 +#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; }