]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Do a generic Cold Reset for OMAP3550 and BeagleBoard specific Warm reset\r | |
3 | \r | |
4 | Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
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 | |
30 | VOID\r | |
31 | ShutdownEfi (\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 | |
57 | \r | |
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 | |
90 | typedef\r | |
91 | VOID\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 | |
108 | EFI_STATUS\r | |
109 | EFIAPI\r | |
110 | LibResetSystem (\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 | |
128 | StartOfFv = (CALL_STUB)(UINTN)PcdGet32(PcdFvBaseAddress);\r | |
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 | |
144 | \r | |
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 | |
152 | \r | |
153 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
154 | \r | |
155 | **/\r | |
156 | EFI_STATUS\r | |
157 | EFIAPI\r | |
158 | LibInitializeResetSystem (\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 |