2 Do a generic Cold Reset for OMAP3550 and BeagleBoard specific Warm reset
4 Copyright (c) 2008-2010, Apple Inc. All rights reserved.
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Library/ArmLib.h>
20 #include <Library/CacheMaintenanceLib.h>
21 #include <Library/MemoryAllocationLib.h>
22 #include <Library/IoLib.h>
23 #include <Library/PcdLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/UefiBootServicesTableLib.h>
27 #include <Omap3530/Omap3530.h>
37 EFI_MEMORY_DESCRIPTOR
*MemoryMap
;
40 UINTN DescriptorVersion
;
46 Status
= gBS
->GetMemoryMap (
53 if (Status
== EFI_BUFFER_TOO_SMALL
) {
55 Pages
= EFI_SIZE_TO_PAGES (MemoryMapSize
) + 1;
56 MemoryMap
= AllocatePages (Pages
);
59 // Get System MemoryMap
61 Status
= gBS
->GetMemoryMap (
68 // Don't do anything between the GetMemoryMap() and ExitBootServices()
69 if (!EFI_ERROR (Status
)) {
70 Status
= gBS
->ExitBootServices (gImageHandle
, MapKey
);
71 if (EFI_ERROR (Status
)) {
72 FreePages (MemoryMap
, Pages
);
78 } while (EFI_ERROR (Status
));
80 //Clean and invalidate caches.
81 WriteBackInvalidateDataCache();
82 InvalidateInstructionCache();
84 //Turning off Caches and MMU
85 ArmDisableDataCache ();
86 ArmDisableInstructionCache ();
98 Resets the entire platform.
100 @param ResetType The type of reset to perform.
101 @param ResetStatus The status code for the reset.
102 @param DataSize The size, in bytes, of WatchdogData.
103 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
104 EfiResetShutdown the data buffer starts with a Null-terminated
105 Unicode string, optionally followed by additional binary data.
111 IN EFI_RESET_TYPE ResetType
,
112 IN EFI_STATUS ResetStatus
,
114 IN CHAR16
*ResetData OPTIONAL
119 if (ResetData
!= NULL
) {
120 DEBUG((EFI_D_ERROR
, "%s", ResetData
));
127 //Perform warm reset of the system by jumping to the begining of the FV
128 StartOfFv
= (CALL_STUB
)(UINTN
)PcdGet32(PcdFlashFvMainBase
);
132 case EfiResetShutdown
:
134 //Perform cold reset of the system.
135 MmioOr32 (PRM_RSTCTRL
, RST_DPLL3
);
136 while ((MmioRead32(PRM_RSTST
) & GLOBAL_COLD_RST
) != 0x1);
140 // If the reset didn't work, return an error.
142 return EFI_DEVICE_ERROR
;
148 Initialize any infrastructure required for LibResetSystem () to function.
150 @param ImageHandle The firmware allocated handle for the EFI image.
151 @param SystemTable A pointer to the EFI System Table.
153 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
158 LibInitializeResetSystem (
159 IN EFI_HANDLE ImageHandle
,
160 IN EFI_SYSTEM_TABLE
*SystemTable