From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::235; helo=mail-it0-x235.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x235.google.com (mail-it0-x235.google.com [IPv6:2607:f8b0:4001:c0b::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 231402277AF18 for ; Mon, 23 Apr 2018 03:31:36 -0700 (PDT) Received: by mail-it0-x235.google.com with SMTP id 186-v6so10045265itu.0 for ; Mon, 23 Apr 2018 03:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=aY+gvpGZY9aG9FsNDG26hKbF9mw95CGmfJHpDZdHP2Y=; b=AVNO2pNYzc+7vgPwwuNC87RzbqDe7q1QH8h6N0eVQYzllLk+9HiUBIEPuAAFMPcJMn oF60yBBqJk12jFzbOddLqD/xMVVNwpEu9rMhZQ8NngcuVK6VfcS15SVRkYIRr1bEZtFS 9RQlg9VMZR1gs70N2meSnbZB5V944Zgcm7DSo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=aY+gvpGZY9aG9FsNDG26hKbF9mw95CGmfJHpDZdHP2Y=; b=VjIG51W8HJhwcy0WgKNgfRixmUqbwTGxJvuFjY/KzyzKGg67E9DKeguDl0hd66zygS oCpivejK4xSzNQZQ5aBQ7b4gZbGCnMz/CoNRl66akQw5MfXNICHu7IR+Uk+hAl7GjieU VQKBPUwHYwtytFx8E8rNqRT06LnrG38ghulLp9qrs+qDos2m7shJIPHWJuaOSw0Jxazr JhIc8K1q38pOnqBjTynZxzz4btWSdqsghUJnu+4vamfH1V0806xnYGtMbSBZ7ICc78KP 5UsU6iQzVxbH3097I1/Cy8VvPbeXFVvTlcbwgxiU2J3UBcHZnh/SG0XHaRR0q31iKlIz Fmvg== X-Gm-Message-State: ALQs6tCbMpsbs4slIjPrMyVEEKh2rfysC/idREl4qjQ0KcWHBVsJej4m ouLhE9Ld/kBw+RF5jpG28LVqMkUe33KOVcnxhh6dRA== X-Google-Smtp-Source: AB8JxZpdRxIcMy8xWhhGlJHny3mWfV960I8B6Ufg31LL0qr5jED9woQt8bytIKbcA+IvQXpKgtLy9vq6rfYTHEI2GdI= X-Received: by 2002:a24:9456:: with SMTP id j83-v6mr13267275ite.50.1524479495976; Mon, 23 Apr 2018 03:31:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.187.67 with HTTP; Mon, 23 Apr 2018 03:31:35 -0700 (PDT) In-Reply-To: References: <20180301181142.16817-1-ard.biesheuvel@linaro.org> <20180301181142.16817-5-ard.biesheuvel@linaro.org> <20180315124927.shp2tb5njtc5drlk@bivouac.eciton.net> From: Ard Biesheuvel Date: Mon, 23 Apr 2018 12:31:35 +0200 Message-ID: To: Alexei Fedorov Cc: Leif Lindholm , "eric.dong@intel.com" , "edk2-devel@lists.01.org" , "liming.gao@intel.com" , "heyi.guo@linaro.org" , "michael.d.kinney@intel.com" , "lersek@redhat.com" , "star.zeng@intel.com" Subject: Re: [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2018 10:31:37 -0000 Content-Type: text/plain; charset="UTF-8" On 20 April 2018 at 16:14, Alexei Fedorov wrote: > Leif, Ard > > > When do you plan to push this patch? > I don't. There was some pushback from the Intel guys regarding the use of status codes instead of a runtime debug protocol, and nobody came forward to say that they wanted this. If you are interested in this functionality, please respond to the 0/4 cover letter and explain why this approach is preferred over status codes. Thanks, Ard. > ________________________________ > From: edk2-devel on behalf of Leif > Lindholm > Sent: 15 March 2018 12:49:27 > To: Ard Biesheuvel > Cc: eric.dong@intel.com; edk2-devel@lists.01.org; liming.gao@intel.com; > heyi.guo@linaro.org; michael.d.kinney@intel.com; lersek@redhat.com; > star.zeng@intel.com > Subject: Re: [edk2] [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug > driver > > On Thu, Mar 01, 2018 at 06:11:42PM +0000, Ard Biesheuvel wrote: >> Implement the new runtime debug output protocol on top of a PL011 UART. >> >> Contributed-under: TianoCore Contribution Agreement 1.1 >> Signed-off-by: Ard Biesheuvel > > LGTM > Reviewed-by: Leif Lindholm > >> --- >> >> ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c >> | 144 ++++++++++++++++++++ >> >> ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf >> | 62 +++++++++ >> 2 files changed, 206 insertions(+) >> >> diff --git >> a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c >> b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c >> new file mode 100644 >> index 000000000000..155b2c50d463 >> --- /dev/null >> +++ >> b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.c >> @@ -0,0 +1,144 @@ >> +/** @file >> + Runtime driver to produce debug output on a PL011 UART >> + >> + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
>> + >> + This program and the accompanying materials are licensed and made >> available >> + under the terms and conditions of the BSD License which accompanies >> this >> + distribution. The full text of the license may be found at >> + http://opensource.org/licenses/bsd-license.php >> + >> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, >> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR >> IMPLIED. >> + >> +**/ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +STATIC UINTN mUartBase; >> +STATIC EFI_EVENT mVirtualAddressChangeEvent; >> + >> +/** >> + Write data from buffer to debug output device >> + >> + Writes NumberOfBytes data bytes from Buffer to the debug output device. >> + The number of bytes actually written to the device is returned. >> + If the return value is less than NumberOfBytes, then the write >> operation >> + failed. >> + If NumberOfBytes is zero, then return 0. >> + >> + @param Buffer Pointer to the data buffer to be written. >> + @param NumberOfBytes Number of bytes to written to the device. >> + >> + @retval 0 NumberOfBytes is 0. >> + @retval >0 The number of bytes written to the serial >> device. >> + If this value is less than NumberOfBytes, then >> the >> + write operation failed. >> + >> +**/ >> +STATIC >> +UINTN >> +PL011RuntimeDebugOutputWrite ( >> + IN EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL *This, >> + IN UINT8 *Buffer, >> + IN UINTN NumberOfBytes >> + ) >> +{ >> + return PL011UartWrite (mUartBase, Buffer, NumberOfBytes); >> +} >> + >> +STATIC EDK2_RUNTIME_DEBUG_OUTPUT_PROTOCOL mRuntimeDebugOutput = { >> + PL011RuntimeDebugOutputWrite >> +}; >> + >> +/** >> + Fixup internal data so that EFI can be called in virtual mode. >> + >> + @param[in] Event The Event that is being processed >> + @param[in] Context Event Context >> +**/ >> +STATIC >> +VOID >> +EFIAPI >> +VirtualNotifyEvent ( >> + IN EFI_EVENT Event, >> + IN VOID *Context >> + ) >> +{ >> + EfiConvertPointer (0x0, (VOID **)&mUartBase); >> +} >> + >> +EFI_STATUS >> +EFIAPI >> +PL011RuntimeDebugOutputDxeEntry ( >> + IN EFI_HANDLE ImageHandle, >> + IN EFI_SYSTEM_TABLE *SystemTable >> + ) >> +{ >> + EFI_STATUS Status; >> + EFI_HANDLE Handle; >> + UINT64 BaudRate; >> + UINT32 ReceiveFifoDepth; >> + EFI_PARITY_TYPE Parity; >> + UINT8 DataBits; >> + EFI_STOP_BITS_TYPE StopBits; >> + >> + mUartBase = (UINTN)FixedPcdGet64 (PcdSerialRegisterBase); >> + BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate); >> + ReceiveFifoDepth = 0; // Use default FIFO depth >> + Parity = (EFI_PARITY_TYPE)FixedPcdGet8 >> (PcdUartDefaultParity); >> + DataBits = FixedPcdGet8 (PcdUartDefaultDataBits); >> + StopBits = (EFI_STOP_BITS_TYPE) FixedPcdGet8 >> (PcdUartDefaultStopBits); >> + >> + Status = PL011UartInitializePort (mUartBase, FixedPcdGet32 >> (PL011UartClkInHz), >> + &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits, >> &StopBits); >> + if (EFI_ERROR (Status)) { >> + return Status; >> + } >> + >> + // >> + // Register for the virtual address change event >> + // >> + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, >> + VirtualNotifyEvent, NULL, >> &gEfiEventVirtualAddressChangeGuid, >> + &mVirtualAddressChangeEvent); >> + if (EFI_ERROR (Status)) { >> + return Status; >> + } >> + >> + // >> + // Declare the UART MMIO region as EFI_MEMORY_RUNTIME >> + // >> + Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, >> mUartBase, >> + SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); >> + if (EFI_ERROR (Status)) { >> + goto CloseEvent; >> + } >> + >> + Status = gDS->SetMemorySpaceAttributes (mUartBase, SIZE_4KB, >> + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); >> + if (EFI_ERROR (Status)) { >> + goto CloseEvent; >> + } >> + >> + Handle = NULL; >> + Status = gBS->InstallMultipleProtocolInterfaces (&Handle, >> + &gEdkiiRuntimeDebugOutputProtocolGuid, >> &mRuntimeDebugOutput, >> + NULL); >> + if (EFI_ERROR (Status)) { >> + goto CloseEvent; >> + } >> + >> + return EFI_SUCCESS; >> + >> +CloseEvent: >> + gBS->CloseEvent (mVirtualAddressChangeEvent); >> + >> + return Status; >> +} >> diff --git >> a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf >> b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf >> new file mode 100644 >> index 000000000000..28a8e514552e >> --- /dev/null >> +++ >> b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutputDxe.inf >> @@ -0,0 +1,62 @@ >> +#/** @file >> +# Runtime driver to produce debug output on a PL011 UART >> +# >> +# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
>> +# >> +# This program and the accompanying materials are licensed and made >> available >> +# under the terms and conditions of the BSD License which accompanies >> this >> +# distribution. The full text of the license may be found at >> +# http://opensource.org/licenses/bsd-license.php >> +# >> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, >> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR >> IMPLIED. >> +# >> +# >> +#**/ >> + >> +[Defines] >> + INF_VERSION = 0x0001001A >> + BASE_NAME = PL011RuntimeDebugOutputDxe >> + FILE_GUID = 494297ca-9205-463a-aae5-215ffd067cbb >> + MODULE_TYPE = DXE_RUNTIME_DRIVER >> + VERSION_STRING = 1.0 >> + ENTRY_POINT = PL011RuntimeDebugOutputDxeEntry >> + >> +# >> +# The following information is for reference only and not required by the >> build tools. >> +# >> +# VALID_ARCHITECTURES = AARCH64 ARM >> +# >> + >> +[Sources.common] >> + PL011RuntimeDebugOutputDxe.c >> + >> +[Packages] >> + ArmPlatformPkg/ArmPlatformPkg.dec >> + MdeModulePkg/MdeModulePkg.dec >> + MdePkg/MdePkg.dec >> + >> +[LibraryClasses] >> + DxeServicesTableLib >> + PcdLib >> + PL011UartLib >> + UefiBootServicesTableLib >> + UefiDriverEntryPoint >> + UefiRuntimeLib >> + >> +[Guids] >> + gEfiEventVirtualAddressChangeGuid ## CONSUMES # Event >> + >> +[Protocols] >> + gEdkiiRuntimeDebugOutputProtocolGuid ## PROTOCOL >> ALWAYS_PRODUCED >> + >> +[FixedPcd] >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase >> + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate >> + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits >> + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity >> + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits >> + gArmPlatformTokenSpaceGuid.PL011UartClkInHz >> + >> +[Depex] >> + TRUE >> -- >> 2.11.0 >> > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended > recipient, please notify the sender immediately and do not disclose the > contents to any other person, use it for any purpose, or store or copy the > information in any medium. Thank you.