]> git.proxmox.com Git - mirror_edk2.git/blame - BeagleBoardPkg/Library/ResetSystemLib/ResetSystemLib.c
ARM Packages: Removed trailing spaces
[mirror_edk2.git] / BeagleBoardPkg / Library / ResetSystemLib / ResetSystemLib.c
CommitLineData
f8a61fe7 1/** @file\r
2 Do a generic Cold Reset for OMAP3550 and BeagleBoard specific Warm reset\r
3402aac7 3\r
1ebd6c11 4 Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
3402aac7 5\r
1ebd6c11 6 This program and the accompanying materials\r
f8a61fe7 7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16\r
17#include <Uefi.h>\r
18\r
19#include <Library/ArmLib.h>\r
20#include <Library/CacheMaintenanceLib.h>\r
21#include <Library/MemoryAllocationLib.h>\r
22#include <Library/IoLib.h>\r
23#include <Library/PcdLib.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/UefiBootServicesTableLib.h>\r
26\r
27#include <Omap3530/Omap3530.h>\r
28\r
29\r
30VOID\r
31ShutdownEfi (\r
32 VOID\r
33 )\r
34{\r
35 EFI_STATUS Status;\r
36 UINTN MemoryMapSize;\r
37 EFI_MEMORY_DESCRIPTOR *MemoryMap;\r
38 UINTN MapKey;\r
39 UINTN DescriptorSize;\r
40 UINTN DescriptorVersion;\r
41 UINTN Pages;\r
42\r
43 MemoryMap = NULL;\r
44 MemoryMapSize = 0;\r
45 do {\r
46 Status = gBS->GetMemoryMap (\r
47 &MemoryMapSize,\r
48 MemoryMap,\r
49 &MapKey,\r
50 &DescriptorSize,\r
51 &DescriptorVersion\r
52 );\r
53 if (Status == EFI_BUFFER_TOO_SMALL) {\r
54\r
55 Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;\r
56 MemoryMap = AllocatePages (Pages);\r
3402aac7 57\r
f8a61fe7 58 //\r
59 // Get System MemoryMap\r
60 //\r
61 Status = gBS->GetMemoryMap (\r
62 &MemoryMapSize,\r
63 MemoryMap,\r
64 &MapKey,\r
65 &DescriptorSize,\r
66 &DescriptorVersion\r
67 );\r
68 // Don't do anything between the GetMemoryMap() and ExitBootServices()\r
69 if (!EFI_ERROR (Status)) {\r
70 Status = gBS->ExitBootServices (gImageHandle, MapKey);\r
71 if (EFI_ERROR (Status)) {\r
72 FreePages (MemoryMap, Pages);\r
73 MemoryMap = NULL;\r
74 MemoryMapSize = 0;\r
75 }\r
76 }\r
77 }\r
78 } while (EFI_ERROR (Status));\r
79\r
80 //Clean and invalidate caches.\r
81 WriteBackInvalidateDataCache();\r
82 InvalidateInstructionCache();\r
83\r
84 //Turning off Caches and MMU\r
85 ArmDisableDataCache ();\r
86 ArmDisableInstructionCache ();\r
87 ArmDisableMmu ();\r
88}\r
89\r
90typedef\r
91VOID\r
92(EFIAPI *CALL_STUB)(\r
93 VOID\r
94);\r
95\r
96\r
97/**\r
98 Resets the entire platform.\r
99\r
100 @param ResetType The type of reset to perform.\r
101 @param ResetStatus The status code for the reset.\r
102 @param DataSize The size, in bytes, of WatchdogData.\r
103 @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or\r
104 EfiResetShutdown the data buffer starts with a Null-terminated\r
105 Unicode string, optionally followed by additional binary data.\r
106\r
107**/\r
108EFI_STATUS\r
109EFIAPI\r
110LibResetSystem (\r
111 IN EFI_RESET_TYPE ResetType,\r
112 IN EFI_STATUS ResetStatus,\r
113 IN UINTN DataSize,\r
114 IN CHAR16 *ResetData OPTIONAL\r
115 )\r
116{\r
117 CALL_STUB StartOfFv;\r
118\r
119 if (ResetData != NULL) {\r
120 DEBUG((EFI_D_ERROR, "%s", ResetData));\r
121 }\r
122\r
123 ShutdownEfi ();\r
124\r
125 switch (ResetType) {\r
126 case EfiResetWarm:\r
127 //Perform warm reset of the system by jumping to the begining of the FV\r
886f97c8 128 StartOfFv = (CALL_STUB)(UINTN)PcdGet32(PcdFvBaseAddress);\r
f8a61fe7 129 StartOfFv ();\r
130 break;\r
131 case EfiResetCold:\r
132 case EfiResetShutdown:\r
133 default:\r
134 //Perform cold reset of the system.\r
135 MmioOr32 (PRM_RSTCTRL, RST_DPLL3);\r
136 while ((MmioRead32(PRM_RSTST) & GLOBAL_COLD_RST) != 0x1);\r
137 break;\r
138 }\r
139\r
140 // If the reset didn't work, return an error.\r
141 ASSERT (FALSE);\r
142 return EFI_DEVICE_ERROR;\r
143}\r
3402aac7 144\r
f8a61fe7 145\r
146\r
147/**\r
148 Initialize any infrastructure required for LibResetSystem () to function.\r
149\r
150 @param ImageHandle The firmware allocated handle for the EFI image.\r
151 @param SystemTable A pointer to the EFI System Table.\r
3402aac7 152\r
f8a61fe7 153 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
154\r
155**/\r
156EFI_STATUS\r
157EFIAPI\r
158LibInitializeResetSystem (\r
159 IN EFI_HANDLE ImageHandle,\r
160 IN EFI_SYSTEM_TABLE *SystemTable\r
161 )\r
162{\r
163 return EFI_SUCCESS;\r
164}\r
165\r