[edk2-devel] [edk2-platforms][PATCH v4 2/2] KabylakeOpenBoardPkg/AspireVn7Dash572G/DxeBoardInitLib: Fix byte shift

Benjamin Doron benjamin.doron00 at gmail.com
Mon Sep 6 02:55:30 UTC 2021


Since the time is sent to the EC byte-by-byte, perform shift by a byte
multiple of bits. Also update some comments.

Cc: Chasel Chiu <chasel.chiu at intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
Signed-off-by: Benjamin Doron <benjamin.doron00 at gmail.com>
---
 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/DxeBoardInitLib.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/DxeBoardInitLib.c b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/DxeBoardInitLib.c
index 906b2d265092..4bce51886e3a 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/DxeBoardInitLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardInitLib/DxeBoardInitLib.c
@@ -24,7 +24,7 @@ EcSendTime (
 {
   EFI_STATUS  Status;
   EFI_TIME    EfiTime;
-  // TODO: Confirm this is really INTN and not UINTN
+  // Time could be negative (before 2016)
   INTN        EcTime;
   UINT8       EcTimeByte;
   INTN        Index;
@@ -36,7 +36,7 @@ EcSendTime (
     return;
   }
 
-  // Time since year of release?
+  // Time since year of release. Note that "century" is ignored.
   EcTime = ((EfiTime.Year << 26) + (EfiTime.Month << 22) + (EfiTime.Day << 17)
          + (EfiTime.Hour << 12) + (EfiTime.Minute << 6) + (EfiTime.Second)
          /* 16 years */
@@ -45,7 +45,8 @@ EcSendTime (
   DEBUG ((DEBUG_INFO, "EC: reporting present time 0x%x\n", EcTime));
   SendEcCommand (0xE0);
   for (Index = 0; Index < 4; Index++) {
-    EcTimeByte = EcTime >> Index;
+    // Shift bytes
+    EcTimeByte = EcTime >> Index*8;
     DEBUG ((DEBUG_INFO, "EC: Sending 0x%x (iteration %d)\n", EcTimeByte, Index));
     SendEcData (EcTimeByte);
   }
@@ -61,13 +62,14 @@ EcSendTime (
 
 **/
 VOID
-EcInit (
+EcRequestsTime (
   VOID
   )
 {
   UINT8           Dat;
 
-  /* Vendor's UEFI modules "notify" this protocol in RtKbcDriver */
+  /* This is executed as protocol notify in vendor's RtKbcDriver when *CommonService
+   * protocol is installed. Effectively, this code could execute from the entrypoint */
   EcCmd90Read (0x79, &Dat);
   if (Dat & BIT0) {
     EcSendTime ();
@@ -86,7 +88,7 @@ BoardInitAfterPciEnumeration (
   VOID
   )
 {
-  EcInit ();
+  EcRequestsTime ();
   return EFI_SUCCESS;
 }
 
-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80255): https://edk2.groups.io/g/devel/message/80255
Mute This Topic: https://groups.io/mt/85404951/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list