From nobody Fri Feb 10 07:38:34 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PClwB2lcGz3nsfP; Fri, 10 Feb 2023 07:38:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PClwB2Djnz3G4G; Fri, 10 Feb 2023 07:38:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676014714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YjtBbGv6aQFkT34nS8uUppOuxisHkDG1arPaGr5iQ2A=; b=JhqfvaFF0mzVo5X+xrM/BncIg8tLELaVugTHc6OUInIcf0ty2AhjN5XV27y+HiPh2QLkcS 7uy6XsdeCWT3UwyALq/fYGzsrrnXXl69VTPy15e37ZxwZHc0tt5I958eVO5AVcXBZZAGnD HXQp9bp8pa1JvVI6Ks/RGbJ+uBajgxaWelS8TMu/0j0QDlIbZ2nQSFkN4LYp2Xr0ydO/GW rm7hgbNV/HhcBtef7GbuuGtggd0DNqEVwVjIkbsjSS/0QqsQJoiHNid4hpCsC2sOzxRwzS Dh3uEfCqwwwsdSXzM0B0WK+H3M4Zc9fw5dkDxkPMNXa8G1DBtEEze9ndhnxeVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676014714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YjtBbGv6aQFkT34nS8uUppOuxisHkDG1arPaGr5iQ2A=; b=XMn4HOBXJpGAIw0KdSIY/a0tOeQirrJSPxl/S4E9mec1eWp9z5QmJlSs/VO1DA+T6z279P lCy7x0DqO9fe0wWRRaR2zqIrDhxuEV+x2msWiRDsWGDRsIc+uk3flzSwy8mQD7zLG1QC8d P+mFiqzYYozaUEi250xETmt5oXFBvalsfuvT4FOi340sM0OVIgzH+WpHp2rZJAvm6lnSpW GzpDsHzkq0qcN22pl3EUqdgWksxjLFuheO2qhvpg5ZYIWi7HJqqZdpmjXeYn9yXJYYKD6+ Lw7A3JzD9cH6nZkMeBQOkrtsznODnsbemTE5cdaiuVUkx801v8OU71DSFIh0ow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676014714; a=rsa-sha256; cv=none; b=K4VS0j+ZsNRV9YYpgyFziCJS4Z6QdbHvV+soKWmgbnn3kTqBm+QPe+Ohjcn6V0SlQQ5qUP zPcMiyvgBYwLJNcWOCTrbsSFNuwCmc7vy02EsO0j4YtHRQHoC3Y2WcxmzDtO0Qg6LKzbHc OLdtYLfBkABeozvdq2VuVbQi9H9qi65BIt7LOKABqe5h2ywcwDXkt6J+RGK3XDJWRsZIt4 8WCnK7NPLpKHtzgQSYbvKpyp8r3I/SMWeE4lOzzSXABxcNYDD+oXfHthE6z/ZqkR3Eyov4 HDRxSUjGfF4PeGCfjAqzjeY9TzTgfFiEXS5NFc225FN//WqbgJ2wmTv8OdZgxg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PClwB1Hd3z186t; Fri, 10 Feb 2023 07:38:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31A7cYDS031940; Fri, 10 Feb 2023 07:38:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31A7cYAK031939; Fri, 10 Feb 2023 07:38:34 GMT (envelope-from git) Date: Fri, 10 Feb 2023 07:38:34 GMT Message-Id: <202302100738.31A7cYAK031939@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 4b2322bba19d - stable/13 - efiserialio: use port settings (sio->Mode) for initial setup List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4b2322bba19d26f91d0f1a993798c52ebf45d41b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=4b2322bba19d26f91d0f1a993798c52ebf45d41b commit 4b2322bba19d26f91d0f1a993798c52ebf45d41b Author: Toomas Soome AuthorDate: 2023-02-02 14:01:02 +0000 Commit: Toomas Soome CommitDate: 2023-02-10 07:37:49 +0000 efiserialio: use port settings (sio->Mode) for initial setup Use serial port setup done by system firmware. ARM64 Hyper-V does hung if we attempt to override the defaults, therefore we should default to use settings from firmware. Tested by: schakrabarti@microsoft.com PR: 266248 MFC after: 1 week (cherry picked from commit c243de11cf7c4bb3d67bbc1655b149037e5b04f1) --- stand/efi/loader/efiserialio.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/stand/efi/loader/efiserialio.c b/stand/efi/loader/efiserialio.c index 8b3f8e83e0b3..375e679d2590 100644 --- a/stand/efi/loader/efiserialio.c +++ b/stand/efi/loader/efiserialio.c @@ -40,19 +40,17 @@ static EFI_GUID serial = SERIAL_IO_PROTOCOL; #define COMC_TXWAIT 0x40000 /* transmit timeout */ -#ifndef COMSPEED -#define COMSPEED 9600 -#endif - #define PNP0501 0x501 /* 16550A-compatible COM port */ struct serial { uint64_t baudrate; - uint8_t databits; + uint32_t timeout; + uint32_t receivefifodepth; + uint32_t databits; EFI_PARITY_TYPE parity; EFI_STOP_BITS_TYPE stopbits; - uint8_t ignore_cd; /* boolean */ - uint8_t rtsdtr_off; /* boolean */ + uint32_t ignore_cd; /* boolean */ + uint32_t rtsdtr_off; /* boolean */ int ioaddr; /* index in handles array */ EFI_HANDLE currdev; /* current serial device */ EFI_HANDLE condev; /* EFI Console device */ @@ -257,18 +255,16 @@ comc_probe(struct console *sc) size_t sz; if (comc_port == NULL) { - comc_port = malloc(sizeof (struct serial)); + comc_port = calloc(1, sizeof (struct serial)); if (comc_port == NULL) return; } - comc_port->baudrate = COMSPEED; - comc_port->ioaddr = 0; /* default port */ - comc_port->databits = 8; /* 8,n,1 */ - comc_port->parity = NoParity; /* 8,n,1 */ - comc_port->stopbits = OneStopBit; /* 8,n,1 */ + /* Use defaults from firmware */ + comc_port->databits = 8; + comc_port->parity = DefaultParity; + comc_port->stopbits = DefaultStopBits; comc_port->ignore_cd = 1; /* ignore cd */ comc_port->rtsdtr_off = 0; /* rts-dtr is on */ - comc_port->sio = NULL; handle = NULL; env = getenv("efi_com_port"); @@ -292,8 +288,17 @@ comc_probe(struct console *sc) (void**)&comc_port->sio, IH, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (EFI_ERROR(status)) + if (EFI_ERROR(status)) { comc_port->sio = NULL; + } else { + comc_port->baudrate = comc_port->sio->Mode->BaudRate; + comc_port->timeout = comc_port->sio->Mode->Timeout; + comc_port->receivefifodepth = + comc_port->sio->Mode->ReceiveFifoDepth; + comc_port->databits = comc_port->sio->Mode->DataBits; + comc_port->parity = comc_port->sio->Mode->Parity; + comc_port->stopbits = comc_port->sio->Mode->StopBits; + } } if (env != NULL) @@ -494,7 +499,8 @@ comc_setup(void) return (false); status = comc_port->sio->SetAttributes(comc_port->sio, - comc_port->baudrate, 0, 0, comc_port->parity, + comc_port->baudrate, comc_port->receivefifodepth, + comc_port->timeout, comc_port->parity, comc_port->databits, comc_port->stopbits); if (EFI_ERROR(status)) return (false);