From patchwork Fri Jul 1 11:52:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Lloyd X-Patchwork-Id: 71304 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp259637qgy; Fri, 1 Jul 2016 04:52:13 -0700 (PDT) X-Received: by 10.66.73.193 with SMTP id n1mr31064436pav.70.1467373933132; Fri, 01 Jul 2016 04:52:13 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id x9si3928982pfj.106.2016.07.01.04.52.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2016 04:52:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 403C81A1E1D; Fri, 1 Jul 2016 04:52:49 -0700 (PDT) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 359291A1E1B for ; Fri, 1 Jul 2016 04:52:47 -0700 (PDT) Received: from E107800.Emea.Arm.com (e107800.emea.arm.com [10.1.31.97]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id u61Bq7iA010570; Fri, 1 Jul 2016 12:52:07 +0100 From: evan.lloyd@arm.com To: edk2-devel@ml01.01.org Date: Fri, 1 Jul 2016 12:52:06 +0100 Message-Id: <20160701115206.14276-1-evan.lloyd@arm.com> X-Mailer: git-send-email 2.8.3 Subject: [edk2] [PATCH] ArmPlatformPkg: Set Juno debug serial port defaults X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ryan Harkin , Leif Lindholm , Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" From: Evan Lloyd Juno has several serial ports, one of which may be used for a remote debug interface (e.g. gdb, WinDbg). The debug serial port needs to be distinct from that used for UEFI trace to prevent corruption of debugger protocol messaging. The UEFI spec requires that serial devices be initialised to default settings. (11.8 Serial I/O Protocol - "The default attributes for all UART-style serial device interfaces are: 115,200 baud, ..." and 17.3.3 EFI Debugport Variable - "These defaults must be used in the absence of a DEBUGPORT variable...") This change adds initialization of the serial device reported in the ACPI DBG2 table. The initialisation is done early in the boot to allow the possibility of remote debug of UEFI itself. NOTE: This is functionally dependent on the DBG2 table being updated in OpenPlatformPkg, but is required as a precursor to that change. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Sami Mujawar Signed-off-by: Evan Lloyd --- Notes: v2 - No code change. - Clarified commit message in response to comments [Ard Bieshevel] Specific points include clarity that change is not OS specific, and pertains to any debugger use, and justification for doing it at an early point in the process. Confirmed with Leif that update here (not OpenPlatformPkg) is appropriate. ArmPlatformPkg/ArmPlatformPkg.dec | 5 +++ ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJunoLib.inf | 15 ++++++++- ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJuno.c | 35 ++++++++++++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) Code available at: https://github.com/EvanLloyd/tianocore/tree/debug_serial_v2 -- Guid("CE165669-3EF3-493F-B85D-6190EE5B9759") _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Tested-by: Ryan Harkin diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec index 1c05132cd625be75b0d9d1cd09950af983d1f049..5864d9835989382b79b1e6db6486fe67082df6a0 100644 --- a/ArmPlatformPkg/ArmPlatformPkg.dec +++ b/ArmPlatformPkg/ArmPlatformPkg.dec @@ -98,6 +98,11 @@ [PcdsFixedAtBuild.common] gArmPlatformTokenSpaceGuid.PL011UartFractional|0|UINT32|0x0000002D gArmPlatformTokenSpaceGuid.PL011UartInterrupt|0x00000000|UINT32|0x0000002F + ## PL011 Serial Debug UART + gArmPlatformTokenSpaceGuid.PcdSerialDbgRegisterBase|0x00000000|UINT64|0x00000030 + gArmPlatformTokenSpaceGuid.PcdSerialDbgUartBaudRate|0x00000000|UINT64|0x00000031 + gArmPlatformTokenSpaceGuid.PcdSerialDbgUartClkInHz|0x00000000|UINT32|0x00000032 + ## PL061 GPIO gArmPlatformTokenSpaceGuid.PcdPL061GpioBase|0x0|UINT32|0x00000025 diff --git a/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJunoLib.inf b/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJunoLib.inf index 8c8b141c35a2693b618c1515cb665b9b1e81cc4e..77d18f855a833fff0d38518436ef331dfab2d7e1 100644 --- a/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJunoLib.inf +++ b/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJunoLib.inf @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2015, ARM Limited. All rights reserved. +# Copyright (c) 2013-2016, ARM Limited. All rights reserved. # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -57,6 +57,19 @@ [FixedPcd] gArmJunoTokenSpaceGuid.PcdPciConfigurationSpaceBaseAddress gArmJunoTokenSpaceGuid.PcdPciConfigurationSpaceSize + + # + # PL011 Serial Debug UART + # + gArmPlatformTokenSpaceGuid.PcdSerialDbgRegisterBase + gArmPlatformTokenSpaceGuid.PcdSerialDbgUartBaudRate + gArmPlatformTokenSpaceGuid.PcdSerialDbgUartClkInHz + + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits + [Pcd] gArmTokenSpaceGuid.PcdPciMmio32Base gArmTokenSpaceGuid.PcdPciMmio32Size diff --git a/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJuno.c b/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJuno.c index ffff5628247f61f4c2f31d3b9f7763b24f10641d..ae7f5e94acdaa5a37ba56c27fe0700c588dafcc9 100644 --- a/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJuno.c +++ b/ArmPlatformPkg/ArmJunoPkg/Library/ArmJunoLib/ArmJuno.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2013-2014, ARM Limited. All rights reserved. +* Copyright (c) 2013-2016, ARM Limited. All rights reserved. * * This program and the accompanying materials * are licensed and made available under the terms and conditions of the BSD License @@ -18,6 +18,7 @@ #include #include +#include #include @@ -112,7 +113,37 @@ ArmPlatformInitialize ( IN UINTN MpId ) { - return RETURN_SUCCESS; + RETURN_STATUS Status; + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + EFI_PARITY_TYPE Parity; + UINT8 DataBits; + EFI_STOP_BITS_TYPE StopBits; + + Status = RETURN_SUCCESS; + + // + // Initialize the Serial Debug UART + // + if (FixedPcdGet64 (PcdSerialDbgRegisterBase)) { + ReceiveFifoDepth = 0; // Use the default value for FIFO depth + Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity); + DataBits = FixedPcdGet8 (PcdUartDefaultDataBits); + StopBits = (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefaultStopBits); + + BaudRate = (UINTN)FixedPcdGet64 (PcdSerialDbgUartBaudRate); + Status = PL011UartInitializePort ( + (UINTN)FixedPcdGet64 (PcdSerialDbgRegisterBase), + FixedPcdGet32 (PcdSerialDbgUartClkInHz), + &BaudRate, + &ReceiveFifoDepth, + &Parity, + &DataBits, + &StopBits + ); + } + + return Status; } /**