From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a01:111:f400:fe09::624; helo=eur03-ve1-obe.outbound.protection.outlook.com; envelope-from=alexei.fedorov@arm.com; receiver=edk2-devel@lists.01.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03on0624.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe09::624]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4134F2251215E for ; Fri, 20 Apr 2018 07:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=PVjcPaVf8y/lhfsOR9HUUT+GmSx6cut20/xHFTQjSZY=; b=LLZhhu7lIU7z77+AkhTHw4cE/Orh5e7dyirXB/02AvbIlRK8IPdCie9Bgz+4I5zk3JmL3gSDIfgRXaNUM/ZRspZ/8OZvvH0/pM5l+9Cwj1Fz/kVclk+LFUBvSb8dRlsI5NJ2v0KjiEoJgJmhs+Fejl2mtbbVEGaSI1BgZ0yA8KE= Received: from DB6PR0801MB1766.eurprd08.prod.outlook.com (10.169.227.13) by DB6PR0801MB1959.eurprd08.prod.outlook.com (10.168.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Fri, 20 Apr 2018 14:14:32 +0000 Received: from DB6PR0801MB1766.eurprd08.prod.outlook.com ([fe80::15b1:d95c:d513:6f59]) by DB6PR0801MB1766.eurprd08.prod.outlook.com ([fe80::15b1:d95c:d513:6f59%18]) with mapi id 15.20.0696.013; Fri, 20 Apr 2018 14:14:32 +0000 From: Alexei Fedorov To: Leif Lindholm , 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" Thread-Topic: [edk2] [PATCH 4/4] ArmPlatformPkg: add PL011 UART runtime debug driver Thread-Index: AQHTsYjVEMbEiN33hkOozsUWtFBhBqPRVQiAgDiqt/8= Date: Fri, 20 Apr 2018 14:14:32 +0000 Message-ID: References: <20180301181142.16817-1-ard.biesheuvel@linaro.org> <20180301181142.16817-5-ard.biesheuvel@linaro.org>, <20180315124927.shp2tb5njtc5drlk@bivouac.eciton.net> In-Reply-To: <20180315124927.shp2tb5njtc5drlk@bivouac.eciton.net> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [217.140.96.140] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6PR0801MB1959; 7:ncYQYK0QU0MqEm/2Nawg4H3ofskb9EPX6hTW1o4iEDVt6W4+oeAySBzX/UEui+zjluzolDzOFCruk4IH/DEuMy+OFj3N5EzO+lzAL9NOW0bDv9n/Usyrwoz4KgjbvjlXFB3MfHLgYLm99tUT2JCLMv3I1nXTZB/Xbd+yL/AV2Vqqp9dsOV6Dm5zhcNgb3nHiPOiPAoTgA65GwqRSFpzJq//MCHuNZsM61ZuhAkidE3LXjVEQwxwAXOO4LgtJ4B0Y x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(2017052603328)(7153060)(7193020); SRVR:DB6PR0801MB1959; x-ms-traffictypediagnostic: DB6PR0801MB1959: authentication-results: outbound.protection.outlook.com; spf=skipped (originating message); dkim=none (message not signed) header.d=none; dmarc=none action=none header.from=arm.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231232)(944501395)(52105095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:DB6PR0801MB1959; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB1959; x-forefront-prvs: 0648FCFFA8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(39380400002)(376002)(396003)(366004)(39860400002)(3280700002)(4326008)(6606003)(81166006)(7736002)(6246003)(236005)(2906002)(53936002)(8936002)(8676002)(3660700001)(72206003)(15188155005)(53376002)(33656002)(9686003)(11346002)(16799955002)(55016002)(229853002)(54896002)(74316002)(316002)(6306002)(478600001)(476003)(446003)(59450400001)(6506007)(53546011)(102836004)(5890100001)(6116002)(3846002)(966005)(5250100002)(6436002)(66066001)(5660300001)(2900100001)(110136005)(86362001)(7696005)(26005)(19627405001)(186003)(76176011)(25786009)(606006)(54906003)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB1959; H:DB6PR0801MB1766.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; MLV:sfv; x-microsoft-antispam-message-info: Fjs69OPMtpPNEhoNyvFzTlhGoudJfQOMAz3W31Hu3S9rwptsdgOVgOX4dbRWvyyMY1qYkF4ORnT83e3OShNQNcrkUogWn91nBtLv2Eo90RO9D4LSIwV6e/9zlLOUMwmJZ030zkjTqAEgM8W6T0woCGVgz74t3VyJCr3O8jqXPuw/vB4rZ8RQJj3tZ9wAvjuF spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 435ec866-42b6-4ca1-defa-08d5a6c909c5 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 435ec866-42b6-4ca1-defa-08d5a6c909c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2018 14:14:32.4768 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1959 X-Content-Filtered-By: Mailman/MimeDel 2.1.26 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: Fri, 20 Apr 2018 14:14:37 -0000 Content-Language: en-GB Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Leif, Ard When do you plan to push this patch? Alexei. ________________________________ From: edk2-devel on behalf of Leif Lindho= lm Sent: 15 March 2018 12:49:27 To: Ard Biesheuvel Cc: eric.dong@intel.com; edk2-devel@lists.01.org; liming.gao@intel.com; hey= i.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 debu= g 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/PL011RuntimeDebugOutpu= tDxe.c | 144 ++++++++++++++++++++ > ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebugOutpu= tDxe.inf | 62 +++++++++ > 2 files changed, 206 insertions(+) > > diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011Runti= meDebugOutputDxe.c b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL01= 1RuntimeDebugOutputDxe.c > new file mode 100644 > index 000000000000..155b2c50d463 > --- /dev/null > +++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebug= OutputDxe.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 avai= lable > + under the terms and conditions of the BSD License which accompanies th= is > + 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 I= MPLIED. > + > +**/ > + > +#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 operati= on > + 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 dev= ice. > + If this value is less than NumberOfBytes, the= n 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 =3D { > + 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 =3D (UINTN)FixedPcdGet64 (PcdSerialRegisterBase); > + BaudRate =3D FixedPcdGet64 (PcdUartDefaultBaudRate); > + ReceiveFifoDepth =3D 0; // Use default FIFO depth > + Parity =3D (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultPari= ty); > + DataBits =3D FixedPcdGet8 (PcdUartDefaultDataBits); > + StopBits =3D (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefault= StopBits); > + > + Status =3D PL011UartInitializePort (mUartBase, FixedPcdGet32 (PL011Uar= tClkInHz), > + &BaudRate, &ReceiveFifoDepth, &Parity, &DataBits, &StopBits= ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + // > + // Register for the virtual address change event > + // > + Status =3D gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, > + VirtualNotifyEvent, NULL, &gEfiEventVirtualAddressChan= geGuid, > + &mVirtualAddressChangeEvent); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + // > + // Declare the UART MMIO region as EFI_MEMORY_RUNTIME > + // > + Status =3D gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, mUartB= ase, > + SIZE_4KB, EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); > + if (EFI_ERROR (Status)) { > + goto CloseEvent; > + } > + > + Status =3D gDS->SetMemorySpaceAttributes (mUartBase, SIZE_4KB, > + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); > + if (EFI_ERROR (Status)) { > + goto CloseEvent; > + } > + > + Handle =3D NULL; > + Status =3D gBS->InstallMultipleProtocolInterfaces (&Handle, > + &gEdkiiRuntimeDebugOutputProtocolGuid, &mRuntimeDebugO= utput, > + NULL); > + if (EFI_ERROR (Status)) { > + goto CloseEvent; > + } > + > + return EFI_SUCCESS; > + > +CloseEvent: > + gBS->CloseEvent (mVirtualAddressChangeEvent); > + > + return Status; > +} > diff --git a/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011Runti= meDebugOutputDxe.inf b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL= 011RuntimeDebugOutputDxe.inf > new file mode 100644 > index 000000000000..28a8e514552e > --- /dev/null > +++ b/ArmPlatformPkg/Drivers/PL011RuntimeDebugOutputDxe/PL011RuntimeDebug= OutputDxe.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 ava= ilable > +# under the terms and conditions of the BSD License which accompanies t= his > +# 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 =3D 0x0001001A > + BASE_NAME =3D PL011RuntimeDebugOutputDxe > + FILE_GUID =3D 494297ca-9205-463a-aae5-215ffd067cb= b > + MODULE_TYPE =3D DXE_RUNTIME_DRIVER > + VERSION_STRING =3D 1.0 > + ENTRY_POINT =3D PL011RuntimeDebugOutputDxeEntry > + > +# > +# The following information is for reference only and not required by th= e build tools. > +# > +# VALID_ARCHITECTURES =3D 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_PRODU= CED > + > +[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 confid= ential and may also be privileged. If you are not the intended recipient, p= lease 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.