public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Benjamin Doron" <benjamin.doron00@gmail.com>
To: devel@edk2.groups.io
Cc: Chasel Chiu <chasel.chiu@intel.com>,
	Nate DeSimone <nathaniel.l.desimone@intel.com>
Subject: [edk2-platforms][PATCH v1 2/2] KabylakeOpenBoardPkg/AspireVn7Dash572G/DxeBoardInitLib: Fix byte shift
Date: Fri,  3 Sep 2021 00:30:20 -0400	[thread overview]
Message-ID: <20210903043020.20233-2-benjamin.doron00@gmail.com> (raw)
In-Reply-To: <20210903043020.20233-1-benjamin.doron00@gmail.com>

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@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Benjamin Doron <benjamin.doron00@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..d87cb006bf6f 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 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


      reply	other threads:[~2021-09-03  4:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03  4:30 [edk2-platforms][PATCH v1 1/2] KabylakeOpenBoardPkg/AspireVn7Dash572G/BoardEcLib: Check for NULL Benjamin Doron
2021-09-03  4:30 ` Benjamin Doron [this message]

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=20210903043020.20233-2-benjamin.doron00@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