From patchwork Tue Dec 18 13:10:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 154143 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3690601ljp; Tue, 18 Dec 2018 05:10:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uw/sGG8KpzqIPfbkA6LK7trkwymFUjHkw43T4JbffwTmOveSM6gtQMSKMRhfpLacYIMrTF X-Received: by 2002:a17:902:9a9:: with SMTP id 38mr16103033pln.204.1545138633876; Tue, 18 Dec 2018 05:10:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545138633; cv=none; d=google.com; s=arc-20160816; b=R+UgFHjsnBwRV7YCApb/fF+S9kVWQDYrfJmSfqSmkG7WtqXajmpErn4d3Of5WyJt2c Mq8XVTYObOD9ldWw+3S+Qe/Fbz0zmmCexqi8F9aE0ymrXCxNhQb1pG0+43TZtG8+8bU0 f0MNZLv/zWOXw6ligYbD76MTzeikuKd/ztz7EOkKDXkbHh9oXfJyuae8fy+NZc3elYtF cbymRqa4y7Cm0hZeMuDeUeozhVuTz7nfLV5FNZunHrLDj2xpmV0cqWW9V9EEd30aXMUt bKASIq8BBMMwIDJ6Tf+1S+YdKWFv1dvQyKqTWulRlvdEX/VEt8j4WUcOomuAAESD/8FZ IFjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=GpK1eDNu3GyAZKNtRJ2bB6usLpll6MNjTZP9b/BdDkc=; b=MPcZv/3Lo62vJEvWxJNgHP7Que91Kh0BgrcJAWLPvh1ky6yjQkq0ZCtGs82lMkcHhT AwtmglPO/8zkaBXUD4lrl+sdsvrMRn3B/Yf+9OHVd+PHo4uiWTst74da5u+o1cm2iZWP IZXsm++wQgXcgKwJYwTWfYEGxGBFbKrNg1oIJWimsNtYjVmLae+qopvSkrWx4pmdz/oB nbPFme6dlsiYW5/C1c6UpZNYo11Xf8iz9AfZSuhKahyJGjrfIeMLeYjXMCLIhX8fOXPj qQTTabc/d6QTuq8unJTxiV0p9aSMSNDTALI7KVydrLi6QarXeAnkx1Q9mcSFpkN7gD9j UJ4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HPQzYmTK; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 39si13309448pla.352.2018.12.18.05.10.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Dec 2018 05:10:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HPQzYmTK; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 254752119EF4E; Tue, 18 Dec 2018 05:10:28 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::541; helo=mail-ed1-x541.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C39FF2194D3B9 for ; Tue, 18 Dec 2018 05:10:24 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id p6so13851007eds.0 for ; Tue, 18 Dec 2018 05:10:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MaFR7XwBQn3hF+JpwiiKJbqLzCP1Uis9dfEvQOgw14w=; b=HPQzYmTKsJQBtTvYays883TPh9P4oBCTsJGJS3eYA+sMyga/plh6cA043bfkGNuhnO yXX04KlNwA2WHML82Heo34JV3RRq5IprCg4VPqo4EgZEHdcvtadb66jvA7Hn5nSN3SR5 a91rLepLpwbw4fyreBAiBNRFDpo6bSsO/Ydfg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MaFR7XwBQn3hF+JpwiiKJbqLzCP1Uis9dfEvQOgw14w=; b=kCNRkvzskYC7SDpwCo88+XQ/Q60uJhIQ27UnfgAEEVjLvWbNkp1FC1gujSMRU2Knvi L4zYKktgeRTURMowJMSSEBjGsApW5Hxuy9EE7D0nSAz78df50d9cIXEoHiuQlDrLcaaZ XeTNgfNQZ8x859z2M4NDC+JWZrE+8uH5ib7a5Fn0jLbuzHgMzyRlpxTofNc72Ao2zvqY 6nv/pmedxYNn79wI/1G8tiCHYEUVOVSbYGryyHrk4+F9KiypSS31co8RXUyJpmzexE3Y eCPIVXouVRQOtX9sTeqGziOfx5oOqZBhqz5szu4MlxgLgESFe8+bRA4aBbMDs+goRFcR 0hKw== X-Gm-Message-State: AA+aEWYYNymtGjvhan17jDuFM5mQrGPCZAo1O5Sxyn1iClXQwFL+uSQG hN1u9JqINpBSzsydU7mnf2Douh4C6GrDgK28 X-Received: by 2002:a17:906:8052:: with SMTP id x18-v6mr13315814ejw.131.1545138622977; Tue, 18 Dec 2018 05:10:22 -0800 (PST) Received: from mba13.arnhem.chello.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id f6sm4384755ede.53.2018.12.18.05.10.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Dec 2018 05:10:22 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 18 Dec 2018 14:10:14 +0100 Message-Id: <20181218131015.20062-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181218131015.20062-1-ard.biesheuvel@linaro.org> References: <20181218131015.20062-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 4/4] ArmPkg/GenericWatchdogDxe: implement RegisterHandler() method X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Even though UEFI does not appear to use it, let's implement the complete PI watchdog protocol, including handler registration, which will be invoked instead of the ResetSystem() runtime service when the watchdog timer expires. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c | 34 ++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c index 717a180a64ec..21118a3c88d1 100644 --- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c +++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c @@ -42,6 +42,7 @@ STATIC UINTN mTimerFrequencyHz = 0; STATIC UINT64 mNumTimerTicks = 0; STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol; +STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify; STATIC VOID @@ -107,17 +108,25 @@ WatchdogInterruptHandler ( ) { STATIC CONST CHAR16 ResetString[]= L"The generic watchdog timer ran out."; + UINT64 TimerPeriod; WatchdogDisable (); mInterruptProtocol->EndOfInterrupt (mInterruptProtocol, Source); - gRT->ResetSystem ( - EfiResetCold, - EFI_TIMEOUT, - StrSize (ResetString), - (VOID *) &ResetString - ); + // + // The notify function should be called with the elapsed number of ticks + // since the watchdog was armed, which should exceed the timer period. + // We don't actually know the elapsed number of ticks, so let's return + // the timer period plus 1. + // + if (mWatchdogNotify != NULL) { + TimerPeriod = ((TIME_UNITS_PER_SECOND / mTimerFrequencyHz) * mNumTimerTicks); + mWatchdogNotify (TimerPeriod + 1); + } else { + gRT->ResetSystem (EfiResetCold, EFI_TIMEOUT, StrSize (ResetString), + (CHAR16 *)ResetString); + } // If we got here then the reset didn't work ASSERT (FALSE); @@ -155,9 +164,16 @@ WatchdogRegisterHandler ( IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction ) { - // ERROR: This function is not supported. - // The watchdog will reset the board - return EFI_UNSUPPORTED; + if (mWatchdogNotify == NULL && NotifyFunction == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (mWatchdogNotify != NULL && NotifyFunction != NULL) { + return EFI_ALREADY_STARTED; + } + + mWatchdogNotify = NotifyFunction; + return EFI_SUCCESS; } /**