From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 2D7117803CD for ; Mon, 23 Oct 2023 06:53:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=QIArHn4GW7M7ufPJqMyx4KZt/KaqOCETtx0lQeOoldk=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1698043984; v=1; b=VQ/JHQWz7k3Rb7a0qLgRSpNKmu4cRbncVD5f3PEa+3QGTE8oaz6cp5W7qJEcUbFHdHlB9kw3 qZ7Qulco/7aFZQG8FeiBCgR0eho+T5NpUUsayjpwoOg0El142E9hY192dHFZcDPd+lnpbEdlLJT 4+G8EUfNxFICJmM52ftG20rM= X-Received: by 127.0.0.2 with SMTP id V2R1YY7687511xBbUxDIjzNQ; Sun, 22 Oct 2023 23:53:04 -0700 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web10.114992.1698043983332160149 for ; Sun, 22 Oct 2023 23:53:03 -0700 X-Received: from loongson.cn (unknown [10.40.24.149]) by gateway (Coremail) with SMTP id _____8AxJuhJGDZlK+MzAA--.42014S3; Mon, 23 Oct 2023 14:52:58 +0800 (CST) X-Received: from [10.40.24.149] (unknown [10.40.24.149]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxfNxEGDZln_suAA--.34025S3; Mon, 23 Oct 2023 14:52:53 +0800 (CST) Message-ID: Date: Mon, 23 Oct 2023 14:52:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [edk2-devel] [edk2-platforms PATCH 2/7] LoongArchQemuPkg/LsRealTimeClockLib: remove superfluous instance init steps To: devel@edk2.groups.io, lersek@redhat.com Cc: Bibo Mao , Xianglai li References: <20231020121903.44986-1-lersek@redhat.com> <20231020121903.44986-3-lersek@redhat.com> From: "Chao Li" In-Reply-To: <20231020121903.44986-3-lersek@redhat.com> X-CM-TRANSID: AQAAf8CxfNxEGDZln_suAA--.34025S3 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQANCGU12CcDkwABs6 X-Coremail-Antispam: 1Uk129KBj93XoWxKFWDWFy5WFWxuFW8XF4fWFX_yoW7CFy5pF W8uFsxKr4Yqr4Fva9xX3yxuFnY9anIkFW5Ars8Zwn2kasrJr1jqrWqvFn0qr45Z3y2kF1k Xa40gw48ZFs8WrXCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnRJUUUv0b4IE77IF4wAF F20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r 106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAF wI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv67 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr0_Cr1UM2AIxVAIcxkEcVAq 07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1lYx0E2Ix0cI8IcVAFwI0_Jr0_Jr 4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwCj r7xvwVCIw2I0I7xG6c02F41lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r106r1rMI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxK x2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI 0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU1Au4UUUUUU== Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lichao@loongson.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: uj7LYLEysYrGNYdS9MTZX8Yix7686176AA= Content-Type: multipart/alternative; boundary="------------0CnxY3cHcQTMAOVHi3yFZ9YD" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="VQ/JHQWz"; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io --------------0CnxY3cHcQTMAOVHi3yFZ9YD Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Laszlo, This change is look good to me and I will take this change into edk2/OvmfPkg/LoongArchVirt/ which I'm porting. Thanks. Reviewed-by: Chao Li Thanks, Chao 在 2023/10/20 20:18, Laszlo Ersek 写道: > RealTimeClockLib instances are consumed by edk2's > EmbeddedPkg/RealTimeClockRuntimeDxe driver. In its entry point function > InitializeRealTimeClock(), the driver: > > (1) calls LibRtcInitialize(), > > (2) sets the GetTime(), SetTime(), GetWakeupTime() and SetWakeupTime() > runtime services to its own similarly-named functions -- where those > functions wrap the corresponding RealTimeClockLib APIs, > > (3) installs EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL with a NULL protocol > interface. > > Steps (2) and (3) conform to PI v1.8 sections II-9.7.2.4 through > II-9.7.2.7. > > However, this means that LibRtcInitialize() (of any RealTimeClockLib > instance) should not itself (a) set the GetTime(), SetTime(), > GetWakeupTime() and SetWakeupTime() runtime services, nor (b) install > EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL. The runtime service pointers will be > overwritten in step (2) anyway, and step (3) will uselessly install a > second (NULL-interface) EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL instance in the > protocol database. (The protocol only serves to notify the DXE Foundation > about said runtime services being available.) > > Clean up LoongArchQemuPkg/LsRealTimeClockLib accordingly. > > (Note that the lib instance INF file already does not list > UefiRuntimeServicesTableLib.) > > Build-tested only (with "Loongson.dsc"). > > Cc: Bibo Mao > Cc: Chao Li > Cc: Xianglai li > Ref:https://bugzilla.tianocore.org/show_bug.cgi?id=4565 > Signed-off-by: Laszlo Ersek > --- > > Notes: > context:-W > > Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf | 3 --- > Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c | 16 ---------------- > 2 files changed, 19 deletions(-) > > diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf b/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf > index 5aa95650f8ba..c5ab1a702167 100644 > --- a/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf > +++ b/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf > @@ -40,8 +40,5 @@ [Pcd] > [Guids] > gEfiEventVirtualAddressChangeGuid > > -[Protocols] > - gEfiRealTimeClockArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED > - > [Depex] > TRUE > diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c b/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c > index eeac011a9400..954589ecb328 100644 > --- a/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c > +++ b/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c > @@ -1,30 +1,28 @@ > /** @file > Implement EFI RealTimeClock runtime services via RTC Lib. > > Copyright (c) 2022, Loongson Limited. All rights reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > > #include > #include > > #include > #include > > #include > #include > #include > #include > #include > #include > #include > #include > #include > -#include > #include > -#include > #include "LsRealTimeClock.h" > > STATIC BOOLEAN mInitialized = FALSE; > @@ -291,46 +289,32 @@ EFIAPI > LibRtcInitialize ( > IN EFI_HANDLE ImageHandle, > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > EFI_STATUS Status; > - EFI_HANDLE Handle; > > InitRtc (); > Status = KvmtoolRtcMapMemory (ImageHandle, (mRtcBase & ~EFI_PAGE_MASK)); > if (EFI_ERROR (Status)) { > DEBUG (( > DEBUG_ERROR, > "Failed to map memory for loongson 7A RTC. Status = %r\n", > Status > )); > return Status; > } > > - // Setup the setters and getters > - gRT->GetTime = LibGetTime; > - gRT->SetTime = LibSetTime; > - > - // Install the protocol > - Handle = NULL; > - Status = gBS->InstallMultipleProtocolInterfaces ( > - &Handle, > - &gEfiRealTimeClockArchProtocolGuid, NULL, > - NULL > - ); > - ASSERT_EFI_ERROR (Status); > - > // > // Register for the virtual address change event > // > Status = gBS->CreateEventEx ( > EVT_NOTIFY_SIGNAL, > TPL_NOTIFY, > VirtualNotifyEvent, > NULL, > &gEfiEventVirtualAddressChangeGuid, > &mRtcVirtualAddrChangeEvent > ); > ASSERT_EFI_ERROR (Status); > return Status; > } > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109889): https://edk2.groups.io/g/devel/message/109889 Mute This Topic: https://groups.io/mt/102079659/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- --------------0CnxY3cHcQTMAOVHi3yFZ9YD Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi Laszlo,

This change is look good to me and I will take this change into edk2/OvmfPkg/LoongArchVirt/ which I'm porting. Thanks.

Reviewed-by: Chao Li <lichao@loongson.cn>



Thanks,
Chao
在 2023/10/20 20:18, Laszlo Ersek 写道:
RealTimeClockLib instances are consumed by edk2's
EmbeddedPkg/RealTimeClockRuntimeDxe driver. In its entry point function
InitializeRealTimeClock(), the driver:

(1) calls LibRtcInitialize(),

(2) sets the GetTime(), SetTime(), GetWakeupTime() and SetWakeupTime()
    runtime services to its own similarly-named functions -- where those
    functions wrap the corresponding RealTimeClockLib APIs,

(3) installs EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL with a NULL protocol
    interface.

Steps (2) and (3) conform to PI v1.8 sections II-9.7.2.4 through
II-9.7.2.7.

However, this means that LibRtcInitialize() (of any RealTimeClockLib
instance) should not itself (a) set the GetTime(), SetTime(),
GetWakeupTime() and SetWakeupTime() runtime services, nor (b) install
EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL. The runtime service pointers will be
overwritten in step (2) anyway, and step (3) will uselessly install a
second (NULL-interface) EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL instance in the
protocol database. (The protocol only serves to notify the DXE Foundation
about said runtime services being available.)

Clean up LoongArchQemuPkg/LsRealTimeClockLib accordingly.

(Note that the lib instance INF file already does not list
UefiRuntimeServicesTableLib.)

Build-tested only (with "Loongson.dsc").

Cc: Bibo Mao <maobibo@loongson.cn>
Cc: Chao Li <lichao@loongson.cn>
Cc: Xianglai li <lixianglai@loongson.cn>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4565
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
    context:-W

 Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf |  3 ---
 Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c   | 16 ----------------
 2 files changed, 19 deletions(-)

diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf b/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf
index 5aa95650f8ba..c5ab1a702167 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf
+++ b/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf
@@ -40,8 +40,5 @@ [Pcd]
 [Guids]
   gEfiEventVirtualAddressChangeGuid
 
-[Protocols]
-  gEfiRealTimeClockArchProtocolGuid             # PROTOCOL ALWAYS_PRODUCED
-
 [Depex]
   TRUE
diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c b/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c
index eeac011a9400..954589ecb328 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c
+++ b/Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c
@@ -1,30 +1,28 @@
 /** @file
   Implement EFI RealTimeClock runtime services via RTC Lib.
 
   Copyright (c) 2022, Loongson Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
 #include <Uefi.h>
 #include <PiDxe.h>
 
 #include <Guid/EventGroup.h>
 #include <Guid/GlobalVariable.h>
 
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
 #include <Library/DxeServicesTableLib.h>
 #include <Library/IoLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/PcdLib.h>
 #include <Library/RealTimeClockLib.h>
 #include <Library/TimeBaseLib.h>
 #include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
 #include <Library/UefiRuntimeLib.h>
-#include <Protocol/RealTimeClock.h>
 #include "LsRealTimeClock.h"
 
 STATIC BOOLEAN                mInitialized = FALSE;
@@ -291,46 +289,32 @@ EFIAPI
 LibRtcInitialize (
   IN EFI_HANDLE                            ImageHandle,
   IN EFI_SYSTEM_TABLE                      *SystemTable
   )
 {
   EFI_STATUS    Status;
-  EFI_HANDLE    Handle;
 
   InitRtc ();
   Status = KvmtoolRtcMapMemory (ImageHandle, (mRtcBase & ~EFI_PAGE_MASK));
   if (EFI_ERROR (Status)) {
     DEBUG ((
       DEBUG_ERROR,
       "Failed to map memory for loongson 7A RTC. Status = %r\n",
       Status
       ));
     return Status;
   }
 
-  // Setup the setters and getters
-  gRT->GetTime       = LibGetTime;
-  gRT->SetTime       = LibSetTime;
-
-  // Install the protocol
-  Handle = NULL;
-  Status = gBS->InstallMultipleProtocolInterfaces (
-                  &Handle,
-                  &gEfiRealTimeClockArchProtocolGuid,  NULL,
-                  NULL
-                 );
-  ASSERT_EFI_ERROR (Status);
-
   //
   // Register for the virtual address change event
   //
   Status = gBS->CreateEventEx (
                   EVT_NOTIFY_SIGNAL,
                   TPL_NOTIFY,
                   VirtualNotifyEvent,
                   NULL,
                   &gEfiEventVirtualAddressChangeGuid,
                   &mRtcVirtualAddrChangeEvent
                   );
   ASSERT_EFI_ERROR (Status);
   return Status;
 }






_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#109889) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--------------0CnxY3cHcQTMAOVHi3yFZ9YD--