From nobody Sat Nov 2 16:21:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 148728329389313.408397675885567; Thu, 16 Feb 2017 14:14:53 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B474282121; Thu, 16 Feb 2017 14:14:43 -0800 (PST) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 434B7820E7 for ; Thu, 16 Feb 2017 14:14:41 -0800 (PST) Received: from E107800.Emea.Arm.com (e107800.emea.arm.com [10.1.29.56]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id v1GMEbK6013954; Thu, 16 Feb 2017 22:14:39 GMT X-Original-To: edk2-devel@ml01.01.org From: evan.lloyd@arm.com To: edk2-devel@ml01.01.org Date: Thu, 16 Feb 2017 22:14:31 +0000 Message-Id: <20170216221431.280072-6-evan.lloyd@arm.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20170216221431.280072-1-evan.lloyd@arm.com> References: <20170216221431.280072-1-evan.lloyd@arm.com> Subject: [edk2] [PATCH 5/5] ArmPkg: Tidy up GenericWatchdogDxe.c X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ryan Harkin , Leif Lindholm , Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Evan Lloyd This cosmetic change has no functional content. It adjusts comment oddities, etc, noticed during previous work. Specific changes are: Re-order #includes Use ns consistently (always "100ns" not sometimes "100 nS") Reflow overlength comments Change multiline comments to C style Adjust indent for overlength code lines. Replace explicit test and assert with ASSERT_EFI_ERROR. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Evan Lloyd Signed-off-by: Alexei Fedorov --- ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c | 127 ++++++++++---= ------- 1 file changed, 61 insertions(+), 66 deletions(-) diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPk= g/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c index 69844db2e11f51907e6c8bff5c67d27ceb498150..7c4c9ecd4e12d433e222d7d08ad= f20bda1ff9842 100644 --- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c +++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c @@ -29,16 +29,16 @@ =20 #include "GenericWatchdog.h" =20 -// The number of 100ns periods (the unit of time passed to these functions) -// in a second +/* The number of 100ns periods (the unit of time passed to these functions) + in a second */ #define TIME_UNITS_PER_SECOND 10000000 =20 -// Tick frequency of the generic timer that is the basis of the generic wa= tchdog +// Tick frequency of the generic timer basis of the generic watchdog. UINTN mTimerFrequencyHz =3D 0; =20 -// In cases where the compare register was set manually, information about -// how long the watchdog was asked to wait cannot be retrieved from hardwa= re. -// It is therefore stored here. 0 means the timer is not running. +/* In cases where the compare register was set manually, information about + how long the watchdog was asked to wait cannot be retrieved from hardwa= re. + It is therefore stored here. 0 means the timer is not running. */ UINT64 mNumTimerTicks =3D 0; =20 EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol; @@ -75,8 +75,7 @@ WatchdogDisable ( return MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_DISABL= ED); } =20 -/** - On exiting boot services we must make sure the Watchdog Timer +/** On exiting boot services we must make sure the Watchdog Timer is stopped. **/ VOID @@ -90,9 +89,8 @@ WatchdogExitBootServicesEvent ( mNumTimerTicks =3D 0; } =20 -/* - This function is called when the watchdog's first signal (WS0) goes high. - It uses the ResetSystem Runtime Service to reset the board. +/* This function is called when the watchdog's first signal (WS0) goes hig= h. + It uses the ResetSystem Runtime Service to reset the board. */ VOID EFIAPI @@ -101,7 +99,7 @@ WatchdogInterruptHandler ( IN EFI_SYSTEM_CONTEXT SystemContext ) { - STATIC CONST CHAR16 ResetString[] =3D L"The generic watchdog timer = ran out."; + STATIC CONST CHAR16 ResetString[]=3D L"The generic watchdog timer ran ou= t."; =20 WatchdogDisable (); =20 @@ -126,10 +124,10 @@ WatchdogInterruptHandler ( then the new handler is registered and EFI_SUCCESS is returned. If NotifyFunction is NULL, and a handler is already registered, then that handler is unregistered. - If an attempt is made to register a handler when a handler is already re= gistered, - then EFI_ALREADY_STARTED is returned. - If an attempt is made to unregister a handler when a handler is not regi= stered, - then EFI_INVALID_PARAMETER is returned. + If an attempt is made to register a handler when a handler is already + registered, then EFI_ALREADY_STARTED is returned. + If an attempt is made to unregister a handler when a handler is not + registered, then EFI_INVALID_PARAMETER is returned. =20 @param This The EFI_TIMER_ARCH_PROTOCOL instance. @param NotifyFunction The function to call when a timer interrupt fir= es. @@ -139,11 +137,7 @@ WatchdogInterruptHandler ( information is used to signal timer based event= s. NULL will unregister the handler. =20 - @retval EFI_SUCCESS The watchdog timer handler was registered. - @retval EFI_ALREADY_STARTED NotifyFunction is not NULL, and a handler = is already - registered. - @retval EFI_INVALID_PARAMETER NotifyFunction is NULL, and a handler was = not - previously registered. + @retval EFI_UNSUPPORTED The code does not support NotifyFunction. =20 **/ EFI_STATUS @@ -160,18 +154,18 @@ WatchdogRegisterHandler ( =20 /** This function sets the amount of time to wait before firing the watchdog - timer to TimerPeriod 100 nS units. If TimerPeriod is 0, then the watchd= og + timer to TimerPeriod 100ns units. If TimerPeriod is 0, then the watchdog timer is disabled. =20 @param This The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance. - @param TimerPeriod The amount of time in 100 nS units to wait befo= re the watchdog - timer is fired. If TimerPeriod is zero, then th= e watchdog - timer is disabled. + @param TimerPeriod The amount of time in 100ns units to wait before + the watchdog timer is fired. If TimerPeriod is = zero, + then the watchdog timer is disabled. =20 - @retval EFI_SUCCESS The watchdog timer has been programmed to = fire in Time - 100 nS units. - @retval EFI_DEVICE_ERROR A watchdog timer could not be programmed d= ue to a device - error. + @retval EFI_SUCCESS The watchdog timer has been programmed to = fire + in Time 100ns units. + @retval EFI_DEVICE_ERROR A watchdog timer could not be programmed d= ue + to a device error. =20 **/ EFI_STATUS @@ -184,7 +178,7 @@ WatchdogSetTimerPeriod ( UINTN SystemCount; EFI_STATUS Status; =20 - // if TimerPerdiod is 0, this is a request to stop the watchdog. + // if TimerPeriod is 0, this is a request to stop the watchdog. if (TimerPeriod =3D=3D 0) { mNumTimerTicks =3D 0; return WatchdogDisable (); @@ -193,17 +187,16 @@ WatchdogSetTimerPeriod ( // Work out how many timer ticks will equate to TimerPeriod mNumTimerTicks =3D (mTimerFrequencyHz * TimerPeriod) / TIME_UNITS_PER_SE= COND; =20 - - // If the number of required ticks is greater than the max number the - // watchdog's offset register (WOR) can hold, we need to manually comput= e and - // set the compare register (WCV) + /* If the number of required ticks is greater than the max the watchdog's + offset register (WOR) can hold, we need to manually compute and set + the compare register (WCV) */ =20 if (mNumTimerTicks > MAX_UINT32) { =20 - // We need to enable the watchdog *before* writing to the compare regi= ster, - // because enabling the watchdog causes an "explicit refresh", which - // clobbers the compare register (WCV). In order to make sure this doe= sn't - // trigger an interrupt, set the offset to max. + /* We need to enable the watchdog *before* writing to the compare regi= ster, + because enabling the watchdog causes an "explicit refresh", which + clobbers the compare register (WCV). In order to make sure this doe= sn't + trigger an interrupt, set the offset to max. */ =20 Status =3D WatchdogWriteOffsetRegister (MAX_UINT32); if (EFI_ERROR (Status)) { @@ -221,14 +214,14 @@ WatchdogSetTimerPeriod ( } =20 /** - This function retrieves the period of timer interrupts in 100 ns units, + This function retrieves the period of timer interrupts in 100ns units, returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPer= iod is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 = is returned, then the timer is currently disabled. =20 @param This The EFI_TIMER_ARCH_PROTOCOL instance. - @param TimerPeriod A pointer to the timer period to retrieve in 100 - ns units. If 0 is returned, then the timer is + @param TimerPeriod A pointer to the timer period to retrieve in + 100ns units. If 0 is returned, then the timer is currently disabled. =20 =20 @@ -275,19 +268,19 @@ WatchdogGetTimerPeriod ( this function will not have any chance of executing. =20 @param SetTimerPeriod - Sets the period of the timer interrupt in 100 nS units. + Sets the period of the timer interrupt in 100ns units. This function is optional, and may return EFI_UNSUPPORTED. If this function is supported, then the timer period will be rounded up to the nearest supported timer period. =20 @param GetTimerPeriod - Retrieves the period of the timer interrupt in 100 nS units. + Retrieves the period of the timer interrupt in 100ns units. =20 **/ EFI_WATCHDOG_TIMER_ARCH_PROTOCOL gWatchdogTimer =3D { - (EFI_WATCHDOG_TIMER_REGISTER_HANDLER) WatchdogRegisterHandler, - (EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD) WatchdogSetTimerPeriod, - (EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD) WatchdogGetTimerPeriod + (EFI_WATCHDOG_TIMER_REGISTER_HANDLER)WatchdogRegisterHandler, + (EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD)WatchdogSetTimerPeriod, + (EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD)WatchdogGetTimerPeriod }; =20 EFI_EVENT EfiExitBootServicesEvent =3D (EFI_EVEN= T)NULL; @@ -303,9 +296,9 @@ GenericWatchdogEntry ( EFI_HANDLE Handle; =20 =20 - // Make sure the Watchdog Timer Architectural Protocol has not been inst= alled - // in the system yet. - // This will avoid conflicts with the universal watchdog + /* Make sure the Watchdog Timer Architectural Protocol has not been inst= alled + in the system yet. + This will avoid conflicts with the universal watchdog */ =20 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiWatchdogTimerArchProtocolG= uid); =20 @@ -314,8 +307,11 @@ GenericWatchdogEntry ( =20 // Register for an ExitBootServicesEvent Status =3D gBS->CreateEvent ( - EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, - WatchdogExitBootServicesEvent, NULL, &EfiExitBootService= sEvent + EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_NOTIFY, + WatchdogExitBootServicesEvent, + NULL, + &EfiExitBootServicesEvent ); if (!EFI_ERROR (Status)) { // Install interrupt handler @@ -326,32 +322,31 @@ GenericWatchdogEntry ( ); if (!EFI_ERROR (Status)) { Status =3D mInterruptProtocol->RegisterInterruptSource ( - mInterruptProtocol, - FixedPcdGet32 (PcdGenericWatchdogEl2In= trNum), - WatchdogInterruptHandler - ); + mInterruptProtocol, + FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum), + WatchdogInterruptHandler + ); if (!EFI_ERROR (Status)) { Status =3D mInterruptProtocol->SetTriggerType ( - mInterruptProtocol, - FixedPcdGet32 (PcdGenericWatchdogEl2In= trNum), - EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_R= ISING); + mInterruptProtocol, + FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum), + EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING + ); if (!EFI_ERROR (Status)) { // Install the Timer Architectural Protocol onto a new handle Handle =3D NULL; Status =3D gBS->InstallMultipleProtocolInterfaces ( - &Handle, - &gEfiWatchdogTimerArchProtocolGuid, &gWatchdogTi= mer, - NULL - ); + &Handle, + &gEfiWatchdogTimerArchProtocolGuid, + &gWatchdogTimer, + NULL + ); } } } } =20 - if (EFI_ERROR (Status)) { - // The watchdog failed to initialize - ASSERT (FALSE); - } + ASSERT_EFI_ERROR (Status); =20 mNumTimerTicks =3D 0; WatchdogDisable (); --=20 Guid("CE165669-3EF3-493F-B85D-6190EE5B9759") _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel