From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (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 BB87F2119EF4C for ; Tue, 18 Dec 2018 05:44:38 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id g67so2862948wmd.2 for ; Tue, 18 Dec 2018 05:44:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RcbVBo/qNmE6f9/nb6uqy2EGi5JST1vsuKH/Vj4Y81o=; b=BgJLfbevT8fHxMNm0NXesZfLAZ8uCpJxg7kcNDaV/crtjUTTUpGTbi9G1X71moNVSR BEIpWD/f3eml/eXbXCSIuSjhlAeIoGwDkULIyc5I9brwdIcMyzX8pf/tfs5WfdaE+1ez XMJwpdxm0CyY1+LuC8PGlMB0/nNJK4WiWQtVo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RcbVBo/qNmE6f9/nb6uqy2EGi5JST1vsuKH/Vj4Y81o=; b=YtH641LwKNgmJpXVn5Kl4q57mf2em4aBC3Q2YQtoKVNMnd+xQkBiAANnzELR9cl7mM PU/VdWFZkZFL9V78vT+Lt6zSRPgyf/ULZT97AF6C+TGCHB//mrgJgjxzh/uNXQoxWW1K +uaIYLxO7parZJYyF7SLuGQNqRaSVbJKSjd7WIuAATVQmGWr43tvk/Wlh/MSE8R5UWQs HUoBvS/EmHp0aJryA2g0o4TyYlAbYI9WNFOY2bjgPVOE11IpqvzjNnQHDWI3TTJVwB2P eFfBsepMrA1K7P+g++ge1l0pGpDDIq6Db2qaQp6UUJnsERoLR9Sca6C4AqAi6sEy7idO Rmuw== X-Gm-Message-State: AA+aEWZbZ0FemzWmVQAfXFnEdFH9VvsweQd7lQQslGKbUV9tvRFqFaUf Gpy1dB2Vqa06JsHwDC8lDaqeSQ== X-Google-Smtp-Source: AFSGD/XXu0gYdofucRkOJP7LbUsQ+KJWKPG9lGNrcFqxMVt9FS33tg21yVC2MllSR+LfshKPbVYbcQ== X-Received: by 2002:a1c:8548:: with SMTP id h69mr3134318wmd.11.1545140676601; Tue, 18 Dec 2018 05:44:36 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id r3sm2485269wrs.78.2018.12.18.05.44.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Dec 2018 05:44:35 -0800 (PST) Date: Tue, 18 Dec 2018 13:44:34 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, Sami Mujawar , Thomas Panakamattam Abraham , Meenakshi Aggarwal , Udit Kumar , Matteo Carlini , Nariman Poushin Message-ID: <20181218134434.tlqhd4wks2plqoq7@bivouac.eciton.net> References: <20181218131015.20062-1-ard.biesheuvel@linaro.org> <20181218131015.20062-5-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20181218131015.20062-5-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [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: , X-List-Received-Date: Tue, 18 Dec 2018 13:44:39 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Dec 18, 2018 at 02:10:14PM +0100, Ard Biesheuvel wrote: > 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 Reviewed-by: Leif Lindholm Thanks! > --- > ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c | 34 ++++++++++++++------ > 1 file changed, 25 insertions(+), 9 deletions(-) > > 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; > } > > /** > -- > 2.17.1 >