From nobody Fri Feb 03 10:01:21 2023 X-Original-To: dev-commits-src-main@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 4P7WQ94Ctjz2nQy9; Fri, 3 Feb 2023 10:01:21 +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 4P7WQ93nqtz3J25; Fri, 3 Feb 2023 10:01:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675418481; 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=VY0FQPGa+SZdYlh4ySUvk3Nj47mFqi9Rw6+3NNkpdxo=; b=G4KnlmSVK6I+XrW/rrK7Vbwlqy+CaNNVA34K2Wves2gN8+BeSBqj5rfG/o296l2J4P9sLe OYfLzv2bmY/dQlWocFVZmkaejDtVDALFtRom8L2X6afqKvNX5LQcIF4nfBSSdPpqkDCISz JOzEhQnxM3WNOUK3RfziPt2Ua1siCOodTYbsiQoRTMjtM0K3rvO+U4MkeIcw72bBg0WWaz tGMpqQDOvYztLD1ueMv95wG0NPgk/4Evwcw/NrJ1QHT19qE4jIIUxAKF1SZpzdaHJmjQrm OsLFqWHnkJCV3OhZyboK/ue+FXfF0LUUf3MfWrIXoRQehQvNweWRwS0urxe6HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675418481; 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=VY0FQPGa+SZdYlh4ySUvk3Nj47mFqi9Rw6+3NNkpdxo=; b=LhXjeEPYV1s/+0ju3dBLFal07ZRmcndEpa6eVgxn105wPcbzhwr/C9knRZtPicYTG9rGER ha5ipnnPKz08ZamfEcYP39zu5RaICVZzJItYPYjBlfUHj/l95rZB9SF9bcEYOtpYLmEoSZ +cY8MkAy6IQ7NLTHl53h8HD9IHckCzipBFWN4awLB91WwplLqXPMwlF8TJ2H5RAdvRQCcq wW9RFgwMpx7H0ZxUPVqpKqJ9yAdkUwNbxd/xV7WN/vt7b3Zi2MxQI6lEn65/I5N8Qs8Ok1 GMpCG3VK45sXHsPB/tdYewOOATfiuoVcD7Rn/6dbj71BaeFbN1Kdj0IHHQ+zSQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675418481; a=rsa-sha256; cv=none; b=FMxuDOcG1V6IP1g/Nu6D+VBTSyKF4xvJ0JfuvEvrfxPMAvO8a/QumdpPqZVGYXxRrGEvn0 A9R5zMEFZEoAXV94FgcrQPgyorzg1i8TCQGS42pJcVNfdk6qh0RAfVE+Aiz9wL4qThsWGd We+B/ootqNhrzNGe8+txY0phYGnt2c234p/WK1LLlEV1FeasaZO8oe4O4FEJOMeraCcC8d fOC2R3X3UCqWHd59WvvbbgGQsz/+3glt0JhvyMMSQiFaSsEZkRu/oiKrD7Azf1M0VDQzhX DO+X7/6e69gcddp+Tw46UJ1yXnIFUt5EAiXpbewRDimy/x4KFZWFi3Pn9qs9ww== 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 4P7WQ92t7vzW9q; Fri, 3 Feb 2023 10:01:21 +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 313A1Lc1029578; Fri, 3 Feb 2023 10:01:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 313A1LVC029577; Fri, 3 Feb 2023 10:01:21 GMT (envelope-from git) Date: Fri, 3 Feb 2023 10:01:21 GMT Message-Id: <202302031001.313A1LVC029577@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: a1f8a0c793c6 - main - efiserialio: use port settings (sio->Mode) for initial setup List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: a1f8a0c793c67ab5854035e017f34d3d016b6d0d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=a1f8a0c793c67ab5854035e017f34d3d016b6d0d commit a1f8a0c793c67ab5854035e017f34d3d016b6d0d Author: Toomas Soome AuthorDate: 2023-02-02 14:01:02 +0000 Commit: Toomas Soome CommitDate: 2023-02-03 09:53:32 +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 --- 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);