public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Guo Heyi <heyi.guo@linaro.org>
To: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Guo Heyi <heyi.guo@linaro.org>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	Leif Lindholm <leif.lindholm@linaro.org>
Subject: Re: [PATCH edk2-platforms 1/2] Platform, Silicon: use DxeRuntimeDebugLibSerialPort for runtime DXE drivers
Date: Tue, 27 Feb 2018 19:30:42 +0800	[thread overview]
Message-ID: <20180227113042.GF3918@SZX1000114654> (raw)
In-Reply-To: <27ef5753-9c6c-3b99-e732-084d9e444158@redhat.com>

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 <heyi.guo@linaro.org> 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


  reply	other threads:[~2018-02-27 11:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24 14:25 [PATCH edk2-platforms 1/2] Platform, Silicon: use DxeRuntimeDebugLibSerialPort for runtime DXE drivers Ard Biesheuvel
2018-02-24 14:25 ` [PATCH edk2-platforms 2/2] Silicon/SynQuacerI2cDxe: remove special runtime treatment of DEBUG()s Ard Biesheuvel
2018-02-26 14:50 ` [PATCH edk2-platforms 1/2] Platform, Silicon: use DxeRuntimeDebugLibSerialPort for runtime DXE drivers Laszlo Ersek
2018-02-27  1:50 ` Guo Heyi
2018-02-27  9:23   ` Ard Biesheuvel
2018-02-27 10:43     ` Laszlo Ersek
2018-02-27 11:30       ` Guo Heyi [this message]
2018-02-27 15:59         ` Laszlo Ersek
2018-02-27 14:21       ` Ard Biesheuvel
2018-02-27 16:09         ` Laszlo Ersek
2018-02-27 16:10           ` Ard Biesheuvel
2018-02-27 17:33             ` Ard Biesheuvel
2018-02-27 17:47               ` Laszlo Ersek
2018-02-27 17:55                 ` Ard Biesheuvel
2018-02-27 10:39 ` Leif Lindholm
2018-02-27 10:45   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180227113042.GF3918@SZX1000114654 \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox