From nobody Sun Feb 8 21:29:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93289+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93289+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1662486194; cv=none; d=zohomail.com; s=zohoarc; b=mhAkr5uFCrXkutCZe1OgXbdmLjsZ/GNb/C32yOd3aaM4+ErF1oWEjtjY3+bjV8AtDQMK0sqHEcPTUGrnLaUj/o2Z9bqatAP8X6mtSNaJwnSkHtn+kI1hLBEeIxvZ6CYZls+MMx3MsIWBpfP61mLyapMgADVDMlwD8Q0yuqpEEzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662486194; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=2rKNkJr8mg+u7L+LCNR4vjfMcANK3vDGmWWZLPpByXQ=; b=Z4+SWIzkYPdwc+bJmxZjONHR55EZAuG1mJV3fHmX1M5zY1PXqrjR8HUbMc2TSEYkFvd+DpG7iWp+BDgwAHtirfsohvN7y+dKw6gdxokBkfZzaSLR/Tp+DgQ/lf+Cn5sUlU+gBJ4GXfBZFY+D6t1HmqlI5ZXllCdg4DCSzUyZ/is= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93289+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662486194896913.0684394879723; Tue, 6 Sep 2022 10:43:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id rdcKYY1788612xWZanof00Br; Tue, 06 Sep 2022 10:43:14 -0700 X-Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by mx.groups.io with SMTP id smtpd.web09.2363.1662486190522809487 for ; Tue, 06 Sep 2022 10:43:13 -0700 X-Received: by mail-qk1-f179.google.com with SMTP id i9so2784075qka.0 for ; Tue, 06 Sep 2022 10:43:13 -0700 (PDT) X-Gm-Message-State: amF9q0ommX3RN00ZXMVXNKnMx1787277AA= X-Google-Smtp-Source: AA6agR6YehigM1Y+Mtxxzyj5j2ZandHz9guDu78F1ZVtgPpLoxzlRz2mYuPSIGBuLSJnhcZsBtljAg== X-Received: by 2002:ae9:e71a:0:b0:6bb:c3a7:936d with SMTP id m26-20020ae9e71a000000b006bbc3a7936dmr36440838qka.95.1662486192962; Tue, 06 Sep 2022 10:43:12 -0700 (PDT) X-Received: from aturtleortwo-benjamindomain.. ([2607:f2c0:e98c:e:b132:3785:fa38:a51]) by smtp.gmail.com with ESMTPSA id bi3-20020a05620a318300b006b61b2cb1d2sm11221482qkb.46.2022.09.06.10.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 10:43:12 -0700 (PDT) From: "Benjamin Doron" To: devel@edk2.groups.io Cc: Sai Chaganty , Isaac Oram , Chasel Chiu , Nate DeSimone Subject: [edk2-devel][edk2-platforms][PATCH v1 4/7] KabylakeOpenBoardPkg/AspireVn7Dash572G/DxeBoardInitLib: Resets notify EC Date: Tue, 6 Sep 2022 13:42:55 -0400 Message-Id: <0438eacb8567e8a7b032900e88872445fca791c0.1662485273.git.benjamin.doron00@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,benjamin.doron00@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662486194; bh=NeqU1VE/rk9jVHnx5YCDwK5YpbFxDu2gZletBnt7WLA=; h=Cc:Date:From:Reply-To:Subject:To; b=kA5PVCMvT0et7TVFlBYYYlrSrT7oqzm44VEbtDTAla0B1b1XgtY9Q0ovEgxyRmFeDPz p3/FXmRudbrkK6WBQHbQI62nD4ctS3Tt/kIothuJ9WETMRyiOeUWoLibFZVfCjm9/QAam z8OrDfLcCa99iv37STxrKvCiH/nzM1V1314= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662486196719100019 Content-Type: text/plain; charset="utf-8" Add a callback to notify the EC of platform resets. Cc: Sai Chaganty Cc: Isaac Oram Cc: Chasel Chiu Cc: Nate DeSimone Signed-off-by: Benjamin Doron --- .../Library/BoardInitLib/DxeBoardInitLib.c | 92 ++++++++++++++++++- .../Library/BoardInitLib/DxeBoardInitLib.inf | 4 + 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/= BoardInitLib/DxeBoardInitLib.c b/Platform/Intel/KabylakeOpenBoardPkg/Aspire= Vn7Dash572G/Library/BoardInitLib/DxeBoardInitLib.c index 5c5c26d85c58..07278d956ddc 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/DxeBoardInitLib.c +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/DxeBoardInitLib.c @@ -8,17 +8,22 @@ **/ =20 #include -#include +#include #include #include #include -#include +#include +#include +#include + +EFI_RESET_NOTIFICATION_PROTOCOL *mResetNotify =3D NULL; =20 /** - Update the EC's clock? + Update the EC's clock. =20 **/ VOID +EFIAPI EcSendTime ( VOID ) @@ -26,11 +31,13 @@ EcSendTime ( EFI_STATUS Status; EFI_TIME EfiTime; // Time could be negative (before 2016) - INTN EcTime; + INT32 EcTime; UINT8 EcTimeByte; INTN Index; UINT8 EcResponse; =20 + DEBUG ((DEBUG_INFO, "%a() Starts\n", __FUNCTION__)); + Status =3D gRT->GetTime (&EfiTime, NULL); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_INFO, "Failed to retrieve current time\n")); @@ -56,25 +63,72 @@ EcSendTime ( if (!EFI_ERROR (Status)) { DEBUG ((DEBUG_INFO, "EC: response 0x%x\n", EcResponse)); } + + DEBUG ((DEBUG_INFO, "%a() Ends\n", __FUNCTION__)); } =20 /** - Configure EC + Process an EC time request. =20 **/ VOID +EFIAPI EcRequestsTime ( VOID ) { UINT8 Dat; =20 + DEBUG ((DEBUG_INFO, "%a() Starts\n", __FUNCTION__)); + /* This is executed as protocol notify in vendor's RtKbcDriver when *Com= monService * protocol is installed. Effectively, this code could execute from the = entrypoint */ EcCmd90Read (0x79, &Dat); if (Dat & BIT0) { EcSendTime (); } + + DEBUG ((DEBUG_INFO, "%a() Ends\n", __FUNCTION__)); +} + +/** + Notify EC of reset events. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatus The status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, o= r EfiResetShutdown + the data buffer starts with a Null-terminated st= ring, optionally + followed by additional binary data. The string i= s a description + that the caller may use to further indicate the = reason for the + system reset. For a ResetType of EfiResetPlatfor= mSpecific the data + buffer also starts with a Null-terminated string= that is followed + by an EFI_GUID that describes the specific type = of reset to + perform. + +**/ +VOID +EFIAPI +EcResetSystemHook ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ) +{ + // If boolean PCD tokens 0xBD, 0xBE and 0xBF are set in vendor FW, + // OEM also sends command 0x5A with argument 0xAA via ACPI "CMDB" method= and stalls for + // 100000, then sets ResetType to EfiResetShutdown. + // PCD token 0xBF may be set in a separate function of DxeOemDriver if + // some bits of EC RAM offset 0x5E are set. + // TODO: More information is needed + if (ResetType =3D=3D EfiResetShutdown) { + EcCmd91Write (0x76, 7); // "ECSS" register + // TODO: Write twice, like OEM? + EcCmd91Write (0x76, 7); // "ECSS" register + // Now OEM calls function offset 2 in ACER_BOOT_DEVICE_SERVICE_PROTOCO= L_GUID. + // TODO: What does this do? + } } =20 /** @@ -89,7 +143,23 @@ BoardInitAfterPciEnumeration ( VOID ) { + EFI_STATUS Status; + + DEBUG ((DEBUG_INFO, "%a() Starts\n", __FUNCTION__)); + + // Send EC the present time, if requested EcRequestsTime (); + + // Add a callback to gRT->ResetSystem() to notify EC, rather than hookin= g the table, + // (as vendor's DxeOemDriver does) + Status =3D gBS->LocateProtocol (&gEfiResetNotificationProtocolGuid, NULL= , (VOID **) &mResetNotify); + if (!EFI_ERROR (Status)) { + Status =3D mResetNotify->RegisterResetNotify (mResetNotify, EcResetSys= temHook); + ASSERT_EFI_ERROR (Status); + DEBUG ((DEBUG_INFO, "EC: Added callback to notify EC of resets\n")); + } + + DEBUG ((DEBUG_INFO, "%a() Ends\n", __FUNCTION__)); return EFI_SUCCESS; } =20 @@ -120,5 +190,17 @@ BoardInitEndOfFirmware ( VOID ) { + EFI_STATUS Status; + + DEBUG ((DEBUG_INFO, "%a() Starts\n", __FUNCTION__)); + + // Remove ResetSystem callback. ACPI will be notifying EC of events + if (mResetNotify !=3D NULL) { + Status =3D mResetNotify->UnregisterResetNotify (mResetNotify, EcResetS= ystemHook); + ASSERT_EFI_ERROR (Status); + DEBUG ((DEBUG_INFO, "EC: Removed callback to notify EC of resets\n")); + } + + DEBUG ((DEBUG_INFO, "%a() Ends\n", __FUNCTION__)); return EFI_SUCCESS; } diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/= BoardInitLib/DxeBoardInitLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/Aspi= reVn7Dash572G/Library/BoardInitLib/DxeBoardInitLib.inf index 9a868ee15fb2..24747fa7b224 100644 --- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/DxeBoardInitLib.inf +++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Library/BoardIn= itLib/DxeBoardInitLib.inf @@ -15,6 +15,7 @@ LIBRARY_CLASS =3D BoardInitLib =20 [LibraryClasses] + UefiBootServicesTableLib UefiRuntimeServicesTableLib DebugLib EcLib @@ -27,3 +28,6 @@ =20 [Sources] DxeBoardInitLib.c + +[Protocols] + gEfiResetNotificationProtocolGuid ## CONSUMES --=20 2.37.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93289): https://edk2.groups.io/g/devel/message/93289 Mute This Topic: https://groups.io/mt/93507099/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-