--- /dev/null
+/** @file
+ ResetSystemLib implementation using PSCI calls
+
+ Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
+
+ 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 <AsmMacroIoLibV8.h>
+
+ASM_FUNC(DisableMmuAndReenterPei)
+ stp x29, x30, [sp, #-16]!
+ mov x29, sp
+
+ bl ArmDisableMmu
+
+ // no memory accesses after MMU and caches have been disabled
+
+ MOV64 (x0, FixedPcdGet64 (PcdFvBaseAddress))
+ blr x0
+
+ // never returns
+ nop
--- /dev/null
+;/** @file
+; ResetSystemLib implementation using PSCI calls
+;
+; Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
+;
+; 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.
+;
+;**/
+
+ AREA Reset, CODE, READONLY
+
+ EXPORT DisableMmuAndReenterPei
+ IMPORT ArmDisableMmu
+
+DisableMmuAndReenterPei
+ stp x29, x30, [sp, #-16]!
+ mov x29, sp
+
+ bl ArmDisableMmu
+
+ ; no memory accesses after MMU and caches have been disabled
+
+ movl x0, FixedPcdGet64 (PcdFvBaseAddress)
+ blr x0
+
+ ; never returns
+ nop
+
+ END
--- /dev/null
+/** @file
+ ResetSystemLib implementation using PSCI calls
+
+ Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
+
+ 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 <AsmMacroIoLib.h>
+
+ASM_FUNC(DisableMmuAndReenterPei)
+ push {lr}
+
+ bl ArmDisableMmu
+
+ // no memory accesses after MMU and caches have been disabled
+
+ MOV32 (r0, FixedPcdGet64 (PcdFvBaseAddress))
+ blx r0
+
+ // never returns
+ nop
--- /dev/null
+;/** @file
+; ResetSystemLib implementation using PSCI calls
+;
+; Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
+;
+; 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 AsmMacroExport.inc
+ PRESERVE8
+
+ IMPORT ArmDisableMmu
+
+RVCT_ASM_EXPORT DisableMmuAndReenterPei
+ push {lr}
+
+ bl ArmDisableMmu
+
+ ; no memory accesses after MMU and caches have been disabled
+
+ mov32 r0, FixedPcdGet64 (PcdFvBaseAddress)
+ blx r0
+
+ ; never returns
+ nop
+
+ END
/** @file\r
ResetSystemLib implementation using PSCI calls\r
\r
- Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>\r
+ Copyright (c) 2017 - 2018, Linaro Ltd. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
ArmCallSmc (&ArmSmcArgs);\r
}\r
\r
+VOID DisableMmuAndReenterPei (VOID);\r
+\r
/**\r
This function causes the system to enter S3 and then wake up immediately.\r
\r
VOID\r
)\r
{\r
- VOID (*Reset)(VOID);\r
+ EFI_PHYSICAL_ADDRESS Alloc;\r
+ EFI_MEMORY_DESCRIPTOR *MemMap;\r
+ UINTN MemMapSize;\r
+ UINTN MapKey, DescriptorSize;\r
+ UINT32 DescriptorVersion;\r
+ EFI_STATUS Status;\r
\r
if (FeaturePcdGet (PcdArmReenterPeiForCapsuleWarmReboot) &&\r
!EfiAtRuntime ()) {\r
// immediate wake (which is used by capsule update) by disabling the MMU\r
// and interrupts, and jumping to the PEI entry point.\r
//\r
- Reset = (VOID (*)(VOID))(UINTN)FixedPcdGet64 (PcdFvBaseAddress);\r
\r
- gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
- ArmDisableMmu ();\r
- Reset ();\r
+ //\r
+ // Obtain the size of the memory map\r
+ //\r
+ MemMapSize = 0;\r
+ MemMap = NULL;\r
+ Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize,\r
+ &DescriptorVersion);\r
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
+\r
+ //\r
+ // Add some slack to the allocation to cater for changes in the memory\r
+ // map if ExitBootServices () fails the first time around.\r
+ //\r
+ MemMapSize += SIZE_4KB;\r
+ Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData,\r
+ EFI_SIZE_TO_PAGES (MemMapSize), &Alloc);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ MemMap = (EFI_MEMORY_DESCRIPTOR *)(UINTN)Alloc;\r
+\r
+ Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize,\r
+ &DescriptorVersion);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gBS->ExitBootServices (gImageHandle, MapKey);\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // ExitBootServices () may fail the first time around if an event fired\r
+ // right after the call to GetMemoryMap() which allocated or freed memory.\r
+ // Since that first call to ExitBootServices () will disarm the timer,\r
+ // this is guaranteed not to happen again, so one additional attempt\r
+ // should suffice.\r
+ //\r
+ Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize,\r
+ &DescriptorVersion);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gBS->ExitBootServices (gImageHandle, MapKey);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ DisableMmuAndReenterPei ();\r
}\r
}\r
\r
VERSION_STRING = 1.0\r
LIBRARY_CLASS = ResetSystemLib\r
\r
+[Sources.AARCH64]\r
+ AArch64/Reset.S | GCC\r
+ AArch64/Reset.asm | MSFT\r
+\r
+[Sources.ARM]\r
+ Arm/Reset.S | GCC\r
+ Arm/Reset.asm | RVCT\r
+\r
[Sources]\r
ArmSmcPsciResetSystemLib.c\r
\r