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:c06::22a; helo=mail-io0-x22a.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io0-x22a.google.com (mail-io0-x22a.google.com [IPv6:2607:f8b0:4001:c06::22a]) (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 9C13E209574E0 for ; Tue, 27 Feb 2018 03:24:41 -0800 (PST) Received: by mail-io0-x22a.google.com with SMTP id l12so20818950ioc.10 for ; Tue, 27 Feb 2018 03:30:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=2TW4JNG9SLzMCg8s5Ev852NswqYygMx6CKD1MCxnMXw=; b=hiNx9nVWgKJfs8M/OyXbVLEkxH+brZBTb7EkLjnUJfwR3iGZnB/ikoSQqqSJk8owLB 9Ja03afTpGPP6rn2FOvx7tuLPnipAQTSN8BSaG++afzwAbGDhGa4BNEU1pKrBUChxi5T 0CbAKCMNeERi1mYOMRaHuer1W7aUhS/bUhGWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=2TW4JNG9SLzMCg8s5Ev852NswqYygMx6CKD1MCxnMXw=; b=RwfZj6vG1hILqhaTUXKbbXcXcJaUMywzJymW60xo+PIx8OcA8isVEQYjkn07Ue2OqO jtgYdWLTDNlY3+H8dmFjZO7evHzoLXvi05FA6vHhwJagt6EnOcNoQinbNpvzfqgnpNs1 Mf3x1uVDa8QQE1rPAQwJys5r9PgopEOi3F5rNVgeJOgGzDcX6AVEoTgdJ+iJHLz+TUjg UD+exU20FqReWlK0ckiiNAF/HagMMivgrS3dN4nQO53EJLWYuTmihyWr4F7uTlGB12pN qhajVBic5+CitfKmsPOQGc8AHtDmJzIP4Xx1U0w5mnKx4MrpwwWReEH2HEUONU27Uvid V0nQ== X-Gm-Message-State: APf1xPC1rn3qslz6JV18YnlYNf5w89hlFBo1Ujvbb0idqQ32BqPQxpG/ Ny29tPr9CZxUMjjaOrLod/XCew== X-Google-Smtp-Source: AG47ELtP4MyU9JcFNgFwhS5yowx0Q1XHu/gC8tzBmq5oEBQdR6at9yTieqp8SsqM1YBGdOXxah93Xg== X-Received: by 10.107.59.130 with SMTP id i124mr15234583ioa.129.1519731046819; Tue, 27 Feb 2018 03:30:46 -0800 (PST) Received: from SZX1000114654 ([104.237.91.49]) by smtp.gmail.com with ESMTPSA id d14sm5056467iti.16.2018.02.27.03.30.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 03:30:46 -0800 (PST) From: Guo Heyi X-Google-Original-From: Guo Heyi Date: Tue, 27 Feb 2018 19:30:42 +0800 To: Laszlo Ersek Cc: Ard Biesheuvel , Guo Heyi , "edk2-devel@lists.01.org" , Leif Lindholm Message-ID: <20180227113042.GF3918@SZX1000114654> References: <20180224142515.461-1-ard.biesheuvel@linaro.org> <20180227015036.GC2261@SZX1000114654> <27ef5753-9c6c-3b99-e732-084d9e444158@redhat.com> MIME-Version: 1.0 In-Reply-To: <27ef5753-9c6c-3b99-e732-084d9e444158@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [PATCH edk2-platforms 1/2] Platform, Silicon: use DxeRuntimeDebugLibSerialPort for runtime DXE drivers X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Feb 2018 11:24:42 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Feb 27, 2018 at 11:43:35AM +0100, Laszlo Ersek wrote: > On 02/27/18 10:23, Ard Biesheuvel wrote: > > On 27 February 2018 at 01:50, Guo Heyi wrote: > >> Hi Ard, > >> > >> Sorry for the late of seeing this patch. I have one question: why don't we > >> implement a runtime serial port lib, which will switch UART base address in > >> virtual address map change? I think this will be useful when we want to debug > >> runtime driver in OS stage. And if we have a runtime version of SerialPortLib, > >> then we don't need a runtime version of DebugLib which just disable touching > >> serial port. > >> > > > > Well, only if the serial port is not exposed to the OS as well. The > > Linux PL011 driver is especially easy to confuse, and having both the > > firmware and the OS control it at the same time is likely to cause > > problems. > > > > However, I do agree that having the ability to assign a UART to DEBUG > > at runtime is useful, and so I do intend to create a runtime version > > of the PL011 library, in which case DxeRuntimeDebugLibSerialPort can > > be replaced with BaseDebugLibSerialPort for DXE_RUNTIME_DRIVER > > modules. > > > > Converting the PL011 base address from phys to virt can be done in the > library instance, yes (and then every runtime driver module linked > against this library instance will individually convert the address for > its own use). The messier aspect is getting the PL011 base address into > the UEFI memmap, marked as MMIO / RUNTIME, so that the OS assign a > virtual mapping to it in the first place. > > The flash drivers generally do this with AddMemorySpace / > SetMemorySpaceAttributes. > > (Side point: while I agree that those are good APIs to invoke, I think > they should also call AllocateMemorySpace right after; otherwise a > "stray" AllocateMemorySpace elsewhere could allocate a chunk out of the > middle of what the flash driver *thinks* it owns.) > > The question is where this pair (or triplet) of GCD APIs should be called: > > - In a platform DXE driver? Perhaps. > > - In the DebugLib instance constructor / destructor? That could result > in some ugly reference counting -- you might want to keep the PL011 area > registered in GCD as long as *at least one* such runtime driver is loaded. > > This is different from the flash driver because the flash driver is the > sole runtime DXE (or SMM) driver that accesses & owns the flash MMIO > range. With the PL011 register block, that's not the case; all runtime > drivers that produce debug messages own it co-operatively. On our platforms, we actually use IntelFrameworkModulePkg/PeiDxeDebugLibReportStatusCode, MdeModulePkg/RuntimeDxeReportStatusCodeLib and IntelFrameworkModulePkg/StatusCodeRuntimeDxe as the whole DebugLib call chain for runtime drivers. Is StatusCodeRuntimeDxe a good place for GCD manipulation? But I've no idea on how to distinguish the code between ARM and X86, for X86 uses port IO for serial port access. Regards, Heyi > > Thanks > Laszlo