Hi Ard,
Please see my replies inline.
From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] Sent: Tuesday, October 18, 2016 3:07 PM
On 17 October 2016 at 21:04, Bhupesh Sharma bhupesh.sharma@freescale.com wrote:
From: Sakar Arora sakar.arora@nxp.com
This patch adds the support for system reset library which can be
used
to invoke a system reset via the UEFI shell on LS1043A-RDB board.
Signed-off-by: Sakar Arora sakar.arora@nxp.com Signed-off-by: Bhupesh Sharma bhupesh.sharma@nxp.com
.../Library/ResetSystemLib/ResetSystemLib.c | 87
++++++++++++++++++++++
.../Library/ResetSystemLib/ResetSystemLib.inf | 50
+++++++++++++
2 files changed, 137 insertions(+) create mode 100644 Platforms/Nxp/LS1043aRdb/Library/ResetSystemLib/ResetSystemLib.c create mode 100644 Platforms/Nxp/LS1043aRdb/Library/ResetSystemLib/ResetSystemLib.inf
diff --git a/Platforms/Nxp/LS1043aRdb/Library/ResetSystemLib/ResetSystemLib.c b/Platforms/Nxp/LS1043aRdb/Library/ResetSystemLib/ResetSystemLib.c new file mode 100644 index 0000000..831dd3a --- /dev/null +++
b/Platforms/Nxp/LS1043aRdb/Library/ResetSystemLib/ResetSystemLib.c
@@ -0,0 +1,87 @@ +/** ResetSystemLib.c
- Do a generic Cold Reset for LS1043a
- Based on Reset system library implementation in
- BeagleBoardPkg/Library/ResetSystemLib/ResetSystemLib.c
- Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2016, Freescale Semiconductor, Inc. All rights
reserved.
- This program and the accompanying materials are licensed and made
- available under the terms and conditions of the BSD License which
- accompanies this distribution. The full text of the license may be
- found at http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
- BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
EXPRESS OR IMPLIED.
+**/
+#include <Uefi.h>
+#include <Library/ArmLib.h> +#include <Library/CacheMaintenanceLib.h> #include +<Library/MemoryAllocationLib.h> #include <Library/IoLib.h> #include +<Library/PcdLib.h> #include <Library/TimerLib.h> #include +<Library/DebugLib.h> #include <Library/UefiBootServicesTableLib.h>
+#include <Library/PlatformLib.h>
+#define BITMASK8 0xff +/**
- Resets the entire platform.
- @param ResetType The type of reset to perform.
- @param ResetStatus The status code for the reset.
- @param DataSize The size, in bytes, of WatchdogData.
- @param ResetData For a ResetType of EfiResetCold,
EfiResetWarm, or
EfiResetShutdown the data buffer
starts with a Null-terminated
Unicode string, optionally followed
by additional binary data.
+**/ +EFI_STATUS +EFIAPI +LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
- )
+{
- UINT16 Val;
- //Perform cold reset of the system.
- Val = MmioReadBe16 (WDOG1_BASE_ADDR + WDOG_WCR_OFFSET); Val &=
- BITMASK8; Val |= WDOG_WCR_WDE;
- MmioWriteBe16 (WDOG1_BASE_ADDR + WDOG_WCR_OFFSET, Val);
- MmioWriteBe16(WDOG1_BASE_ADDR + WDOG_WSR_OFFSET,
WDOG_SERVICE_SEQ1);
- MmioWriteBe16(WDOG1_BASE_ADDR + WDOG_WSR_OFFSET,
WDOG_SERVICE_SEQ2);
This will explode when invoked at runtime (i.e., from the OS)
Please look at ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c for an example how to register the MMIO range for use by runtime services.
Right. Like I mentioned in the comments to another review, we have added the RT support for LS1043A UEFI where we also added the correct implementation for RTC clock.
We will send this in the v2.
- MicroSecondDelay(1000000);
- // If the reset didn't work, return an error.
- ASSERT (FALSE);
- return EFI_DEVICE_ERROR;
+}
+/**
- Initialize any infrastructure required for LibResetSystem () to
function.
- @param ImageHandle The firmware allocated handle for the EFI
image.
- @param SystemTable A pointer to the EFI System Table.
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+**/ +EFI_STATUS +EFIAPI +LibInitializeResetSystem (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
+{
- return EFI_SUCCESS;
+} diff --git a/Platforms/Nxp/LS1043aRdb/Library/ResetSystemLib/ResetSystemLib.inf b/Platforms/Nxp/LS1043aRdb/Library/ResetSystemLib/ResetSystemLib.inf new file mode 100644 index 0000000..b568dcf --- /dev/null +++
b/Platforms/Nxp/LS1043aRdb/Library/ResetSystemLib/ResetSystemLib.i
+++ nf @@ -0,0 +1,50 @@ +#/** @ResetSystemLib.inf +# Reset System lib to make it easy to port new platforms # # +Copyright (c) 2016, Freescale Semiconductor, Inc. All rights
reserved.
+# +# This program and the accompanying materials # are licensed and +made available under the terms and conditions of the BSD License # +which accompanies this distribution. The full text of the license
may
+be found at # http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" +BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
EXPRESS OR IMPLIED.
+# +# +#**/
+[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = LS1043aRdbResetSystemLib
- FILE_GUID = 781371a2-3fdd-41d4-96a1-
7b34cbc9e895
Fresh GUID
Ok.
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EfiResetSystemLib
+[Sources.common]
- ResetSystemLib.c
+[Packages]
- MdePkg/MdePkg.dec
- ArmPkg/ArmPkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- OpenPlatformPkg/Platforms/Nxp/LS1043aRdb/LS1043aRdbPkg.dec
+[Pcd.common]
- gArmTokenSpaceGuid.PcdCpuResetAddress
- gEmbeddedTokenSpaceGuid.PcdEmbeddedFdBaseAddress
+[LibraryClasses]
- DebugLib
- ArmLib
- IoLib
- CacheMaintenanceLib
- MemoryAllocationLib
- UefiRuntimeServicesTableLib
- TimerLib
- UefiLib
- UefiBootServicesTableLib
Are you using all of these? Please only include library classes that you actually depend on
Sure, will fix this in v2.
+[FixedPcd]
- gArmTokenSpaceGuid.PcdFvBaseAddress
same here
Ok.
Regards, Bhupesh