From: Heyi Guo <guoheyi@huawei.com>
To: Laszlo Ersek <lersek@redhat.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Hao Wu <hao.a.wu@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
Julien Grall <julien.grall@arm.com>,
wanghaibin 00208455 <wanghaibin.wang@huawei.com>
Subject: Re: [RFC 0/3] Enable runtime serial debug for ArmVirtQemu
Date: Wed, 20 Mar 2019 20:16:07 +0800 [thread overview]
Message-ID: <1e39908c-3f26-7b87-8bd3-8ae04221cf58@huawei.com> (raw)
In-Reply-To: <8b2a9fcd-fb0d-6432-4481-e05d08816332@redhat.com>
On 2019/3/20 17:55, Laszlo Ersek wrote:
> On 03/16/19 10:41, Heyi Guo wrote:
>> On 2019/3/13 1:05, Laszlo Ersek wrote:
>>> Given that you'd have to implement a "special" SerialPortLib instance
>>> just for StatusCodeHandlerRuntimeDxe anyway, can we perhaps:
>>>
>>> (1) Undo -- dependent on a build flag? -- commit ebfca258f5d7; i.e.,
>>> stick universally with BaseDebugLibSerialPort, for DebugLib,
>>>
>>> (2) add a new implementation of "FdtPL011SerialPortLib.inf" with both
>>> (a) runtime behavior and (b) handling of a special serial port?
>>>
>>> In other words, push down the "runtime?" distinction from DebugLib (see
>>> commit 7f029e1b31ee) to SerialPortLib. The new SerialPortLib instance
>>> would be used only with DXE_RUNTIME_DRIVERs.
>>>
>>> The lib instance would prepare everything in advance for accessing the
>>> "special" serial port at runtime (which could require allocating runtime
>>> memory in advance). Once ExitBootServices() is called, a callback should
>>> switch over the behavior of the lib instance, without allocating further
>>> memory. (The switched-over behavior would not have to be functional
>>> until the virtual address map is set.)
>> My first idea was also simply implement a runtime serial port instance,
>> but the problem is for the initialization.
>>
>> Since serial port lib is only a library, it seems we can only initialize
>> everything in SerialPortInitialize() or library constructor, but either
>> of which could no work in current EDK2 code framework. Please see my
>> explanation in earlier mail as below:
>>
>> "The long story is: at first I proposed to still use
>> BaseSerialPortDebugLib, so I added RuntimePrepare() function into the
>> constructor directly, but the builder complained about looped
>> constructors, for RuntimePrepare() invokes gBS and some RunTime
>> libraries. Then I tried disabling the constructor and moved
>> RuntimePrepare() into SerialPortInitialize() which could complete the
>> build, but still couldn't guarantee the calling order of these
>> constructors, for BaseSerialPortDebugLib has a constructor to call
>> SerialPortInitialize()."
> (Sorry about the late response (I've been away for a few days), and also
> for missing that construction loop that you apparently mentioned earlier.)
Nothing at all, and thanks for your time in reading and replying the mails even when out of office :)
>
> You mention that "RuntimePrepare() invokes gBS and some RunTime
> libraries". How important is it to rely on those libraries?
>
> For example, "gBS" is simply a convenience; you can get at the same
> thing from the parameter list of the constructor function too (assuming
> you use a MODULE_TYPE of (minimally) DXE_DRIVER, in the lib instance's
> INF file).
>
> If we don't have to flatten a ridiculous amount of other library code
> into the RuntimePrepare() function, I think such flattening would be a
> viable approach. We've run into this constructor loop several times
> before, and -- if I remember correctly anyway! -- one approach has been
> to declare SerialPortLib the "lowest level abstraction", and make the
> affected lib instance self-contained.
In my RFC, we need to use gDS which is from DxeServicesTableLib->EfiGetSystemConfigurationTable()->UefiLib, so that we need to flatten EfiGetSystemConfigurationTable(). And gDS->SetMemorySpaceAttributes() actually relies on gEfiCpuArchProtocolGuid or it will return EFI_NOT_AVAILABLE_YET.
Thanks,
Heyi
>
>> Can we use event notify or protocol notify to do the runtime
>> intialization? Like EndOfDxe event group. Any other advice?
> I guess this could work too. I'm not really a fan of callbacks as long
> as we can manage otherwise (for example, we can't propagate errors out
> of callbacks), but if the lib flattening thing gets too complex, we
> could do this as well.
>
> Regarding EndOfDxe -- I think EndOfDxe is considered a trust barrier
> (namely between platform fw modules and 3rd party modules), so I
> wouldn't tie our initialization to that, for clarity's sake. ReadyToBoot
> seems a tiny bit less "forced" -- it is sufficiently late, you can still
> allocate resources, and we can claim it is "on the path towards OS
> runtime". Just be aware that ReadyToBoot can be signaled multiple times,
> e.g. if some boot options fail (so uninstall the handler / close the
> event when serving the first callback I guess).
>
> Thanks
> Laszlo
>
> .
>
next prev parent reply other threads:[~2019-03-20 12:16 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-28 8:05 [RFC 0/3] Enable runtime serial debug for ArmVirtQemu Heyi Guo
2019-02-28 8:05 ` [RFC 1/3] MdeModulePkg/StatusCode: Add PCD to enable runtime serial debug Heyi Guo
2019-02-28 8:05 ` [RFC 2/3] ArmVirtPkg: add runtime instance of FdtPL011SerialPortLib Heyi Guo
2019-02-28 8:05 ` [RFC 3/3] ArmVirtQemu: enable runtime debug by build flag Heyi Guo
2019-02-28 12:10 ` [RFC 0/3] Enable runtime serial debug for ArmVirtQemu Ard Biesheuvel
2019-03-01 15:27 ` Laszlo Ersek
2019-03-04 13:52 ` Heyi Guo
2019-03-12 6:56 ` Heyi Guo
2019-03-12 17:05 ` Laszlo Ersek
2019-03-12 17:28 ` Andrew Fish
2019-03-12 19:42 ` Laszlo Ersek
2019-03-13 20:16 ` Brian J. Johnson
2019-03-14 3:52 ` Andrew Fish
2019-03-16 9:41 ` Heyi Guo
2019-03-20 9:55 ` Laszlo Ersek
2019-03-20 12:16 ` Heyi Guo [this message]
2019-03-20 17:47 ` Laszlo Ersek
2019-03-21 3:23 ` Heyi Guo
2019-02-28 13:39 ` Laszlo Ersek
2019-03-01 12:24 ` Heyi Guo
2019-03-01 14:59 ` Laszlo Ersek
2019-03-01 15:14 ` Ard Biesheuvel
[not found] ` <CAFEAcA8AQjMJytpbXbBPH_YyuVW-PawhSgGeXaZGhVzRUPh9+A@mail.gmail.com>
2019-03-01 16:14 ` Laszlo Ersek
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=1e39908c-3f26-7b87-8bd3-8ae04221cf58@huawei.com \
--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