public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: devel@edk2.groups.io, yeoreum.yun@arm.com
Cc: sami.mujawar@arm.com, ray.ni@intel.com, pierre.gondois@arm.com,
	nd@arm.com
Subject: Re: [edk2-devel] [PATCH v1 1/1] StandaloneMmPkg: Initialise serial port early in StandaloneMmEntryPoint
Date: Fri, 5 Jan 2024 17:46:50 +0100	[thread overview]
Message-ID: <CAMj1kXE6KiOtVpdCvzKgJ0JYAAjPHUejzVbT3DO8QuRN6BH4iw@mail.gmail.com> (raw)
In-Reply-To: <20240105114931.844886-1-yeoreum.yun@arm.com>

On Fri, 5 Jan 2024 at 12:49, levi.yun <yeoreum.yun@arm.com> wrote:
>
> Serial port used by the DEBUG macro is initialised in StandaloneMmMain
> by the DebugLib constructor.
>
> When we use a serial port initialised by TF-A it is not a problem.
> However, if we use a serial port that is not initialised by TF-A,
> the debug log prints hangs.
>
> Therefore, initialise the serial port early on in the entry point.
>
> Signed-off-by: levi.yun <yeoreum.yun@arm.com>
> ---
> These changes can be seen at
> https://github.com/LeviYeoReum/edk2/tree/levi/2956_init_serial too.
>

So now we will always initialize the serial port in the entrypoint
only because DebugLib might use it later with doing the
initialization.

That doesn't sound quite correct to me.

Could you explain why we cannot rely on DebugLib to call the
initializer / constructor at the right time?



>  StandaloneMmPkg/StandaloneMmPkg.dsc                                                 | 1 +
>  StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf   | 1 +
>  StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 3 +++
>  3 files changed, 5 insertions(+)
>
> diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/StandaloneMmPkg.dsc
> index 8012f93b7dcc38ea8fdd2de98912bbc09157ec53..040a4aa5b3d268fdfaaec9a975cfc6ff31aa37b4 100644
> --- a/StandaloneMmPkg/StandaloneMmPkg.dsc
> +++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
> @@ -66,6 +66,7 @@ [LibraryClasses.AARCH64, LibraryClasses.ARM]
>    ArmSvcLib|ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
>    CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
>    PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf
> +  SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
>
>    NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
>    NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> index 75cfb98c0e75cd7cee2a59723035679612da4528..086639ecfbc983627aed73817815e2485104375e 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> @@ -42,6 +42,7 @@ [LibraryClasses]
>    DebugLib
>
>  [LibraryClasses.ARM, LibraryClasses.AARCH64]
> +  SerialPortLib
>    StandaloneMmMmuLib
>    ArmSvcLib
>
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> index 96de10405af829c66e3f43ed4692f785d8df113e..66b56bdfe4959d5ab6152ff024caa6e900e7a948 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> @@ -335,6 +335,9 @@ _ModuleEntryPoint (
>    UINTN                           TeDataSize;
>    EFI_PHYSICAL_ADDRESS            ImageBase;
>
> +  // Initialize the Serial Port early to print debug log before StandaloneMmMain.
> +  SerialPortInitialize ();
> +
>    // Get Secure Partition Manager Version Information
>    Status = GetSpmVersion ();
>    if (EFI_ERROR (Status)) {
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> 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.
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113299): https://edk2.groups.io/g/devel/message/113299
Mute This Topic: https://groups.io/mt/103540969/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2024-01-05 16:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05 11:49 [edk2-devel] [PATCH v1 1/1] StandaloneMmPkg: Initialise serial port early in StandaloneMmEntryPoint levi.yun
2024-01-05 11:52 ` levi.yun
2024-01-05 16:46 ` Ard Biesheuvel [this message]
2024-01-05 17:22   ` levi.yun
2024-01-05 18:38     ` Oliver Smith-Denny
2024-01-08 12:16       ` Laszlo Ersek
2024-01-10 16:13         ` levi.yun
2024-01-10 16:41           ` Laszlo Ersek
2024-01-10 17:16             ` levi.yun
2024-01-10 21:06               ` Brian J. Johnson
2024-01-11  9:05                 ` levi.yun
     [not found]                 ` <17A93FAECCFD3533.4530@groups.io>
2024-01-18 10:19                   ` levi.yun

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=CAMj1kXE6KiOtVpdCvzKgJ0JYAAjPHUejzVbT3DO8QuRN6BH4iw@mail.gmail.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