* [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances
@ 2023-10-20 12:18 Laszlo Ersek
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 1/7] Hisilicon/DS3231RealTimeClockLib: remove superfluous instance init steps Laszlo Ersek
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Laszlo Ersek @ 2023-10-20 12:18 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Bibo Mao, Chao Li, Leif Lindholm, Ling Jia,
Marcin Wojtas, Peng Xie, Wenyi Xie, Xianglai li, Yiqi Shu
https://bugzilla.tianocore.org/show_bug.cgi?id=4565
RealTimeClockLib instances should neither set gRT fields nor install
EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL in LibRtcInitialize();
EmbeddedPkg/RealTimeClockRuntimeDxe already performs those actions.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Bibo Mao <maobibo@loongson.cn>
Cc: Chao Li <lichao@loongson.cn>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ling Jia <jialing@phytium.com.cn>
Cc: Marcin Wojtas <mw@semihalf.com>
Cc: Peng Xie <xiepeng@phytium.com.cn>
Cc: Wenyi Xie <xiewenyi2@huawei.com>
Cc: Xianglai li <lixianglai@loongson.cn>
Cc: Yiqi Shu <shuyiqi@phytium.com.cn>
Thanks
Laszlo
Laszlo Ersek (7):
Hisilicon/DS3231RealTimeClockLib: remove superfluous instance init
steps
LoongArchQemuPkg/LsRealTimeClockLib: remove superfluous instance init
steps
Hisilicon/M41T83RealTimeClockLib: remove superfluous instance init
steps
Hisilicon/RX8900RealTimeClockLib: remove superfluous instance init
steps
Silicon/Marvell/RealTimeClockLib: remove superfluous instance init
steps
FT2000-4Pkg/RealTimeClockLib: remove superfluous instance init steps
Omap35xxPkg/RealTimeClockLib: remove superfluous instance init steps
Platform/Hisilicon/D03/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c | 27 +++-----------------
Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c | 16 ------------
Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf | 3 ---
Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c | 7 -----
Silicon/Hisilicon/Library/RX8900RealTimeClockLib/RX8900RealTimeClockLib.c | 24 +++--------------
Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c | 19 +-------------
Silicon/Phytium/FT2000-4Pkg/Library/RealTimeClockLib/RealTimeClockLib.c | 13 ----------
Silicon/TexasInstruments/Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c | 19 +-------------
8 files changed, 8 insertions(+), 120 deletions(-)
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109837): https://edk2.groups.io/g/devel/message/109837
Mute This Topic: https://groups.io/mt/102079655/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 11+ messages in thread
* [edk2-devel] [edk2-platforms PATCH 1/7] Hisilicon/DS3231RealTimeClockLib: remove superfluous instance init steps
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
@ 2023-10-20 12:18 ` Laszlo Ersek
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 2/7] LoongArchQemuPkg/LsRealTimeClockLib: " Laszlo Ersek
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laszlo Ersek @ 2023-10-20 12:18 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Wenyi Xie
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 Hisilicon/DS3231RealTimeClockLib accordingly.
(Note that the lib instance INF file already does not list
UefiBootServicesTableLib, UefiRuntimeServicesTableLib, and
gEfiRealTimeClockArchProtocolGuid.)
Build-tested only (with the D03 and D05 platforms).
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Wenyi Xie <xiewenyi2@huawei.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4565
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Platform/Hisilicon/D03/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c | 27 +++-----------------
1 file changed, 3 insertions(+), 24 deletions(-)
diff --git a/Platform/Hisilicon/D03/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c b/Platform/Hisilicon/D03/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c
index 3a84b6e9297b..be143c47577b 100644
--- a/Platform/Hisilicon/D03/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c
+++ b/Platform/Hisilicon/D03/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c
@@ -25,11 +25,8 @@
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/TimerLib.h>
#include <Library/TimeBaseLib.h>
-#include <Protocol/RealTimeClock.h>
#include <Library/I2CLib.h>
#include "DS3231RealTimeClock.h"
#include <Library/CpldD03.h>
@@ -433,19 +430,9 @@ LibRtcInitialize (
)
{
EFI_STATUS Status;
- EFI_HANDLE Handle;
-
-
EFI_TIME EfiTime;
- // Setup the setters and getters
- gRT->GetTime = LibGetTime;
- gRT->SetTime = LibSetTime;
- gRT->GetWakeupTime = LibGetWakeupTime;
- gRT->SetWakeupTime = LibSetWakeupTime;
-
-
- (VOID)gRT->GetTime (&EfiTime, NULL);
+ (VOID)LibGetTime (&EfiTime, NULL);
if((EfiTime.Year < 2015) || (EfiTime.Year > 2099)){
EfiTime.Year = 2015;
EfiTime.Month = 1;
@@ -454,20 +441,12 @@ LibRtcInitialize (
EfiTime.Minute = 0;
EfiTime.Second = 0;
EfiTime.Nanosecond = 0;
- Status = gRT->SetTime(&EfiTime);
+ Status = LibSetTime(&EfiTime);
if (EFI_ERROR(Status))
{
DEBUG((EFI_D_ERROR, "[%a]:[%dL] Status : %r\n", __FUNCTION__, __LINE__, Status));
}
}
- // Install the protocol
- Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiRealTimeClockArchProtocolGuid, NULL,
- NULL
- );
-
- return Status;
+ return EFI_SUCCESS;
}
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109836): https://edk2.groups.io/g/devel/message/109836
Mute This Topic: https://groups.io/mt/102079654/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [edk2-devel] [edk2-platforms PATCH 2/7] LoongArchQemuPkg/LsRealTimeClockLib: remove superfluous instance init steps
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 1/7] Hisilicon/DS3231RealTimeClockLib: remove superfluous instance init steps Laszlo Ersek
@ 2023-10-20 12:18 ` Laszlo Ersek
2023-10-23 6:52 ` Chao Li
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 3/7] Hisilicon/M41T83RealTimeClockLib: " Laszlo Ersek
` (6 subsequent siblings)
8 siblings, 1 reply; 11+ messages in thread
From: Laszlo Ersek @ 2023-10-20 12:18 UTC (permalink / raw)
To: devel; +Cc: Bibo Mao, Chao Li, Xianglai li
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 (#109840): https://edk2.groups.io/g/devel/message/109840
Mute This Topic: https://groups.io/mt/102079659/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [edk2-devel] [edk2-platforms PATCH 3/7] Hisilicon/M41T83RealTimeClockLib: remove superfluous instance init steps
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 1/7] Hisilicon/DS3231RealTimeClockLib: remove superfluous instance init steps Laszlo Ersek
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 2/7] LoongArchQemuPkg/LsRealTimeClockLib: " Laszlo Ersek
@ 2023-10-20 12:18 ` Laszlo Ersek
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 4/7] Hisilicon/RX8900RealTimeClockLib: " Laszlo Ersek
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laszlo Ersek @ 2023-10-20 12:18 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Wenyi Xie
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 Hisilicon/M41T83RealTimeClockLib accordingly (it only has code
that's redundant for step (2); it does not try to install
EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL).
(Note that the lib instance INF file already does not list
UefiRuntimeServicesTableLib.)
Build-tested only (with the D06 platform).
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Wenyi Xie <xiewenyi2@huawei.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4565
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c
index 5f9465843475..3a2cd451c4ef 100644
--- a/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c
+++ b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c
@@ -18,7 +18,6 @@
#include <Library/TimerLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
#include "M41T83RealTimeClock.h"
extern I2C_DEVICE gRtcDevice;
@@ -427,12 +426,6 @@ LibRtcInitialize (
EfiInitializeLock (&mRtcLock, TPL_CALLBACK);
- // Setup the setters and getters
- gRT->GetTime = LibGetTime;
- gRT->SetTime = LibSetTime;
- gRT->GetWakeupTime = LibGetWakeupTime;
- gRT->SetWakeupTime = LibSetWakeupTime;
-
Status = InitializeM41T83 ();
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Status : %r\nRTC M41T83 Init Failed !!!\n",
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109838): https://edk2.groups.io/g/devel/message/109838
Mute This Topic: https://groups.io/mt/102079657/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [edk2-devel] [edk2-platforms PATCH 4/7] Hisilicon/RX8900RealTimeClockLib: remove superfluous instance init steps
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
` (2 preceding siblings ...)
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 3/7] Hisilicon/M41T83RealTimeClockLib: " Laszlo Ersek
@ 2023-10-20 12:19 ` Laszlo Ersek
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 5/7] Silicon/Marvell/RealTimeClockLib: " Laszlo Ersek
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laszlo Ersek @ 2023-10-20 12:19 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm, Wenyi Xie
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 Hisilicon/RX8900RealTimeClockLib accordingly.
(Note that the lib instance INF file already does not list
UefiBootServicesTableLib, UefiRuntimeServicesTableLib, and
gEfiRealTimeClockArchProtocolGuid.)
Note that this patch is *untestable* in edk2-platforms (and in
edk2-non-osi too), because no platform consumes RX8900RealTimeClockLib --
worse, there hasn't been a single consumer since the introduction of the
lib instance in commit de704335c47f ("Silicon/Hisilicon: Add
RX8900RealTimeClockLib", 2020-05-20).
Normally this would nominate RX8900RealTimeClockLib to the axe, but commit
de704335c47f said, "There are some boards base on D06, but use RX8900 RTC,
so upstream the RX8900RealTimeClockLib", so I guess there might be
out-of-tree / proprietary consumers. Quite unfortunate.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Wenyi Xie <xiewenyi2@huawei.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4565
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Silicon/Hisilicon/Library/RX8900RealTimeClockLib/RX8900RealTimeClockLib.c | 24 +++-----------------
1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/Silicon/Hisilicon/Library/RX8900RealTimeClockLib/RX8900RealTimeClockLib.c b/Silicon/Hisilicon/Library/RX8900RealTimeClockLib/RX8900RealTimeClockLib.c
index ea41202fc72a..eaaf95a1979d 100644
--- a/Silicon/Hisilicon/Library/RX8900RealTimeClockLib/RX8900RealTimeClockLib.c
+++ b/Silicon/Hisilicon/Library/RX8900RealTimeClockLib/RX8900RealTimeClockLib.c
@@ -15,11 +15,8 @@
#include <Library/RtcHelperLib.h>
#include <Library/TimeBaseLib.h>
#include <Library/TimerLib.h>
-#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Protocol/RealTimeClock.h>
#include "RX8900RealTimeClock.h"
extern I2C_DEVICE gRtcDevice;
@@ -417,16 +414,9 @@ LibRtcInitialize (
)
{
EFI_STATUS Status;
- EFI_HANDLE Handle;
EFI_TIME EfiTime;
- // Setup the setters and getters
- gRT->GetTime = LibGetTime;
- gRT->SetTime = LibSetTime;
- gRT->GetWakeupTime = LibGetWakeupTime;
- gRT->SetWakeupTime = LibSetWakeupTime;
-
- Status = gRT->GetTime (&EfiTime, NULL);
+ Status = LibGetTime (&EfiTime, NULL);
if (EFI_ERROR (Status) || (EfiTime.Year < 2000) || (EfiTime.Year > 2099) ||
(!IsTimeValid (&EfiTime))) {
EfiTime.Year = 2000;
@@ -439,19 +429,11 @@ LibRtcInitialize (
EfiTime.Daylight = 0;
EfiTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
- Status = gRT->SetTime (&EfiTime);
+ Status = LibSetTime (&EfiTime);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "SetTime Status : %r\n", Status));
}
}
- Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiRealTimeClockArchProtocolGuid,
- NULL,
- NULL
- );
-
- return Status;
+ return EFI_SUCCESS;
}
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109843): https://edk2.groups.io/g/devel/message/109843
Mute This Topic: https://groups.io/mt/102079662/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [edk2-devel] [edk2-platforms PATCH 5/7] Silicon/Marvell/RealTimeClockLib: remove superfluous instance init steps
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
` (3 preceding siblings ...)
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 4/7] Hisilicon/RX8900RealTimeClockLib: " Laszlo Ersek
@ 2023-10-20 12:19 ` Laszlo Ersek
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 6/7] FT2000-4Pkg/RealTimeClockLib: " Laszlo Ersek
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laszlo Ersek @ 2023-10-20 12:19 UTC (permalink / raw)
To: devel; +Cc: Leif Lindholm, Marcin Wojtas
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 Silicon/Marvell/RealTimeClockLib accordingly (it only has code
that's redundant for step (3); it does not try to set "gRT" fields).
(Note that the lib instance INF file already does not list
gEfiRealTimeClockArchProtocolGuid.)
Build-tested only (with "Armada70x0Db.dsc").
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Marcin Wojtas <mw@semihalf.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4565
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Notes:
context:-W
Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c
index d538b030b111..c026ac2dee31 100644
--- a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c
+++ b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c
@@ -1,30 +1,29 @@
/** @file
Implement EFI RealTimeClock runtime services via RTC Lib.
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
Copyright (c) 2017, Marvell International Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
/**
Derived from:
ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
**/
#include <PiDxe.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/TimeBaseLib.h>
#include <Library/IoLib.h>
#include <Library/RealTimeClockLib.h>
#include <Library/TimerLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
-#include <Protocol/RealTimeClock.h>
#include "RealTimeClockLib.h"
STATIC EFI_EVENT mRtcVirtualAddrChangeEvent;
@@ -245,85 +244,69 @@ EFIAPI
LibRtcInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_HANDLE Handle;
EFI_STATUS Status;
// Obtain RTC device base address
mArmadaRtcBase = PcdGet64 (PcdRtcBaseAddress);
// Check if the controller can be initialized
if (mArmadaRtcBase == 0) {
DEBUG ((DEBUG_ERROR, "RTC: None of controllers enabled\n"));
return EFI_INVALID_PARAMETER;
}
// Declare the controller as EFI_MEMORY_RUNTIME
Status = gDS->AddMemorySpace (
EfiGcdMemoryTypeMemoryMappedIo,
mArmadaRtcBase,
SIZE_4KB,
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "RTC: Failed to add memory space\n"));
return Status;
}
Status = gDS->SetMemorySpaceAttributes (
mArmadaRtcBase,
SIZE_4KB,
EFI_MEMORY_UC | EFI_MEMORY_RUNTIME
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "RTC: Failed to set memory attributes\n"));
goto ErrSetMem;
}
/* Update RTC-MBUS bridge timing parameters */
MmioAndThenOr32 (
mArmadaRtcBase + RTC_BRIDGE_TIMING_CTRL0_REG_OFFS,
~(RTC_WRITE_SETUP_DELAY_MASK | RTC_WRITE_PERIOD_DELAY_MASK),
(RTC_WRITE_SETUP_DELAY_DEFAULT | RTC_WRITE_PERIOD_DELAY_DEFAULT)
);
MmioAndThenOr32 (
mArmadaRtcBase + RTC_BRIDGE_TIMING_CTRL1_REG_OFFS,
~RTC_READ_OUTPUT_DELAY_MASK,
RTC_READ_OUTPUT_DELAY_DEFAULT
);
- // Install the protocol
- Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiRealTimeClockArchProtocolGuid,
- NULL,
- NULL
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "RTC: Failed to install the protocol\n"));
- goto ErrSetMem;
- }
-
// Register for the virtual address change event
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
VirtualNotifyEvent,
NULL,
&gEfiEventVirtualAddressChangeGuid,
&mRtcVirtualAddrChangeEvent
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "RTC: Failed to register virtual address change event\n"));
- goto ErrEvent;
+ goto ErrSetMem;
}
return Status;
-ErrEvent:
- gBS->UninstallProtocolInterface (Handle, &gEfiRealTimeClockArchProtocolGuid, NULL);
ErrSetMem:
gDS->RemoveMemorySpace (mArmadaRtcBase, SIZE_4KB);
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109839): https://edk2.groups.io/g/devel/message/109839
Mute This Topic: https://groups.io/mt/102079658/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [edk2-devel] [edk2-platforms PATCH 6/7] FT2000-4Pkg/RealTimeClockLib: remove superfluous instance init steps
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
` (4 preceding siblings ...)
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 5/7] Silicon/Marvell/RealTimeClockLib: " Laszlo Ersek
@ 2023-10-20 12:19 ` Laszlo Ersek
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 7/7] Omap35xxPkg/RealTimeClockLib: " Laszlo Ersek
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laszlo Ersek @ 2023-10-20 12:19 UTC (permalink / raw)
To: devel; +Cc: Leif Lindholm, Ling Jia, Peng Xie, Yiqi Shu
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 FT2000-4Pkg/RealTimeClockLib accordingly (it only has code that's
redundant for step (3); it does not try to set "gRT" fields).
(Note that the lib instance INF file already does not list
gEfiRealTimeClockArchProtocolGuid.)
Build-tested only (with "DurianPkg.dsc").
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ling Jia <jialing@phytium.com.cn>
Cc: Peng Xie <xiepeng@phytium.com.cn>
Cc: Yiqi Shu <shuyiqi@phytium.com.cn>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4565
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Silicon/Phytium/FT2000-4Pkg/Library/RealTimeClockLib/RealTimeClockLib.c | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/Silicon/Phytium/FT2000-4Pkg/Library/RealTimeClockLib/RealTimeClockLib.c b/Silicon/Phytium/FT2000-4Pkg/Library/RealTimeClockLib/RealTimeClockLib.c
index 5c3d0cdccff8..26fbd7a3552a 100644
--- a/Silicon/Phytium/FT2000-4Pkg/Library/RealTimeClockLib/RealTimeClockLib.c
+++ b/Silicon/Phytium/FT2000-4Pkg/Library/RealTimeClockLib/RealTimeClockLib.c
@@ -15,7 +15,6 @@
#include <Library/TimeBaseLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
-#include <Protocol/RealTimeClock.h>
#include "RealTimeClockLib.h"
STATIC EFI_EVENT mRtcVirtualAddrChangeEvent;
@@ -344,7 +343,6 @@ LibRtcInitialize (
)
{
EFI_STATUS Status;
- EFI_HANDLE Handle;
INT16 TimeZone;
UINTN Size;
EFI_TIME Time;
@@ -437,17 +435,6 @@ LibRtcInitialize (
return Status;
}
//
- // 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 (
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109842): https://edk2.groups.io/g/devel/message/109842
Mute This Topic: https://groups.io/mt/102079661/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [edk2-devel] [edk2-platforms PATCH 7/7] Omap35xxPkg/RealTimeClockLib: remove superfluous instance init steps
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
` (5 preceding siblings ...)
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 6/7] FT2000-4Pkg/RealTimeClockLib: " Laszlo Ersek
@ 2023-10-20 12:19 ` Laszlo Ersek
2023-10-20 12:26 ` [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Ard Biesheuvel
2023-10-24 13:20 ` Laszlo Ersek
8 siblings, 0 replies; 11+ messages in thread
From: Laszlo Ersek @ 2023-10-20 12:19 UTC (permalink / raw)
To: devel; +Cc: Ard Biesheuvel, Leif Lindholm
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 Omap35xxPkg/RealTimeClockLib accordingly.
(Note that the lib instance INF file already does not list
UefiRuntimeServicesTableLib and gEfiRealTimeClockArchProtocolGuid.)
Build-tested only (with "BeagleBoardPkg.dsc").
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4565
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Silicon/TexasInstruments/Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/Silicon/TexasInstruments/Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c b/Silicon/TexasInstruments/Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c
index 10920a13786b..24fcaaf125c4 100644
--- a/Silicon/TexasInstruments/Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c
+++ b/Silicon/TexasInstruments/Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c
@@ -10,11 +10,9 @@
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
-#include <Protocol/RealTimeClock.h>
#include <Protocol/EmbeddedExternalDevice.h>
#include <Omap3530/Omap3530.h>
@@ -242,7 +240,6 @@ LibRtcInitialize (
)
{
EFI_STATUS Status;
- EFI_HANDLE Handle;
UINT8 Data;
EFI_TPL OldTpl;
@@ -255,19 +252,5 @@ LibRtcInitialize (
ASSERT_EFI_ERROR(Status);
gBS->RestoreTPL(OldTpl);
- // Setup the setters and getters
- gRT->GetTime = LibGetTime;
- gRT->SetTime = LibSetTime;
- gRT->GetWakeupTime = LibGetWakeupTime;
- gRT->SetWakeupTime = LibSetWakeupTime;
-
- // Install the protocol
- Handle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiRealTimeClockArchProtocolGuid, NULL,
- NULL
- );
-
- return Status;
+ return EFI_SUCCESS;
}
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109841): https://edk2.groups.io/g/devel/message/109841
Mute This Topic: https://groups.io/mt/102079660/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
` (6 preceding siblings ...)
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 7/7] Omap35xxPkg/RealTimeClockLib: " Laszlo Ersek
@ 2023-10-20 12:26 ` Ard Biesheuvel
2023-10-24 13:20 ` Laszlo Ersek
8 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2023-10-20 12:26 UTC (permalink / raw)
To: Laszlo Ersek
Cc: devel, Ard Biesheuvel, Bibo Mao, Chao Li, Leif Lindholm, Ling Jia,
Marcin Wojtas, Peng Xie, Wenyi Xie, Xianglai li, Yiqi Shu
On Fri, 20 Oct 2023 at 14:19, Laszlo Ersek <lersek@redhat.com> wrote:
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=4565
>
> RealTimeClockLib instances should neither set gRT fields nor install
> EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL in LibRtcInitialize();
> EmbeddedPkg/RealTimeClockRuntimeDxe already performs those actions.
>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Bibo Mao <maobibo@loongson.cn>
> Cc: Chao Li <lichao@loongson.cn>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Ling Jia <jialing@phytium.com.cn>
> Cc: Marcin Wojtas <mw@semihalf.com>
> Cc: Peng Xie <xiepeng@phytium.com.cn>
> Cc: Wenyi Xie <xiewenyi2@huawei.com>
> Cc: Xianglai li <lixianglai@loongson.cn>
> Cc: Yiqi Shu <shuyiqi@phytium.com.cn>
>
> Thanks
> Laszlo
>
> Laszlo Ersek (7):
> Hisilicon/DS3231RealTimeClockLib: remove superfluous instance init
> steps
> LoongArchQemuPkg/LsRealTimeClockLib: remove superfluous instance init
> steps
> Hisilicon/M41T83RealTimeClockLib: remove superfluous instance init
> steps
> Hisilicon/RX8900RealTimeClockLib: remove superfluous instance init
> steps
> Silicon/Marvell/RealTimeClockLib: remove superfluous instance init
> steps
> FT2000-4Pkg/RealTimeClockLib: remove superfluous instance init steps
> Omap35xxPkg/RealTimeClockLib: remove superfluous instance init steps
>
For the series,
Acked-by: Ard Biesheuvel <ardb@kernel.org>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109847): https://edk2.groups.io/g/devel/message/109847
Mute This Topic: https://groups.io/mt/102079655/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [edk2-platforms PATCH 2/7] LoongArchQemuPkg/LsRealTimeClockLib: remove superfluous instance init steps
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 2/7] LoongArchQemuPkg/LsRealTimeClockLib: " Laszlo Ersek
@ 2023-10-23 6:52 ` Chao Li
0 siblings, 0 replies; 11+ messages in thread
From: Chao Li @ 2023-10-23 6:52 UTC (permalink / raw)
To: devel, lersek; +Cc: Bibo Mao, Xianglai li
[-- Attachment #1: Type: text/plain, Size: 5820 bytes --]
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): 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]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 7229 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
` (7 preceding siblings ...)
2023-10-20 12:26 ` [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Ard Biesheuvel
@ 2023-10-24 13:20 ` Laszlo Ersek
8 siblings, 0 replies; 11+ messages in thread
From: Laszlo Ersek @ 2023-10-24 13:20 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Bibo Mao, Chao Li, Leif Lindholm, Ling Jia,
Marcin Wojtas, Peng Xie, Wenyi Xie, Xianglai li, Yiqi Shu
On 10/20/23 14:18, Laszlo Ersek wrote:
> https://bugzilla.tianocore.org/show_bug.cgi?id=4565
>
> RealTimeClockLib instances should neither set gRT fields nor install
> EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL in LibRtcInitialize();
> EmbeddedPkg/RealTimeClockRuntimeDxe already performs those actions.
>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Bibo Mao <maobibo@loongson.cn>
> Cc: Chao Li <lichao@loongson.cn>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Ling Jia <jialing@phytium.com.cn>
> Cc: Marcin Wojtas <mw@semihalf.com>
> Cc: Peng Xie <xiepeng@phytium.com.cn>
> Cc: Wenyi Xie <xiewenyi2@huawei.com>
> Cc: Xianglai li <lixianglai@loongson.cn>
> Cc: Yiqi Shu <shuyiqi@phytium.com.cn>
>
> Thanks
> Laszlo
>
> Laszlo Ersek (7):
> Hisilicon/DS3231RealTimeClockLib: remove superfluous instance init
> steps
> LoongArchQemuPkg/LsRealTimeClockLib: remove superfluous instance init
> steps
> Hisilicon/M41T83RealTimeClockLib: remove superfluous instance init
> steps
> Hisilicon/RX8900RealTimeClockLib: remove superfluous instance init
> steps
> Silicon/Marvell/RealTimeClockLib: remove superfluous instance init
> steps
> FT2000-4Pkg/RealTimeClockLib: remove superfluous instance init steps
> Omap35xxPkg/RealTimeClockLib: remove superfluous instance init steps
>
> Platform/Hisilicon/D03/Library/DS3231RealTimeClockLib/DS3231RealTimeClockLib.c | 27 +++-----------------
> Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.c | 16 ------------
> Platform/Loongson/LoongArchQemuPkg/Library/LsRealTimeClockLib/LsRealTimeClockLib.inf | 3 ---
> Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c | 7 -----
> Silicon/Hisilicon/Library/RX8900RealTimeClockLib/RX8900RealTimeClockLib.c | 24 +++--------------
> Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c | 19 +-------------
> Silicon/Phytium/FT2000-4Pkg/Library/RealTimeClockLib/RealTimeClockLib.c | 13 ----------
> Silicon/TexasInstruments/Omap35xxPkg/Library/RealTimeClockLib/RealTimeClockLib.c | 19 +-------------
> 8 files changed, 8 insertions(+), 120 deletions(-)
Commit range fdbe20318f27..b68199ec5895.
Thanks!
Laszlo
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110007): https://edk2.groups.io/g/devel/message/110007
Mute This Topic: https://groups.io/mt/102079655/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-10-24 13:21 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-20 12:18 [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Laszlo Ersek
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 1/7] Hisilicon/DS3231RealTimeClockLib: remove superfluous instance init steps Laszlo Ersek
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 2/7] LoongArchQemuPkg/LsRealTimeClockLib: " Laszlo Ersek
2023-10-23 6:52 ` Chao Li
2023-10-20 12:18 ` [edk2-devel] [edk2-platforms PATCH 3/7] Hisilicon/M41T83RealTimeClockLib: " Laszlo Ersek
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 4/7] Hisilicon/RX8900RealTimeClockLib: " Laszlo Ersek
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 5/7] Silicon/Marvell/RealTimeClockLib: " Laszlo Ersek
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 6/7] FT2000-4Pkg/RealTimeClockLib: " Laszlo Ersek
2023-10-20 12:19 ` [edk2-devel] [edk2-platforms PATCH 7/7] Omap35xxPkg/RealTimeClockLib: " Laszlo Ersek
2023-10-20 12:26 ` [edk2-devel] [edk2-platforms PATCH 0/7] drop needless init steps in RealTimeClockLib instances Ard Biesheuvel
2023-10-24 13:20 ` Laszlo Ersek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox