QuarkPlatformPkg: Add ForceRecovery UEFI application
[mirror_edk2.git] / QuarkPlatformPkg / Library / RecoveryOemHookLib / RecoveryOemHookLib.c
CommitLineData
b303605e
MK
1/** @file\r
2This file includes the function that can be customized by OEM.\r
3\r
4Copyright (c) 2013-2015 Intel Corporation.\r
5\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "CommonHeader.h"\r
17\r
18/**\r
19 This function allows the user to force a system recovery\r
20\r
21**/\r
22VOID\r
23EFIAPI\r
24OemInitiateRecovery (\r
25 VOID\r
26 )\r
27{\r
28 UINT32 Data32;\r
29\r
30 //\r
31 // Set 'B_CFG_STICKY_RW_FORCE_RECOVERY' sticky bit so we know we need to do a recovery following warm reset\r
32 //\r
33 Data32 = QNCAltPortRead (QUARK_SCSS_SOC_UNIT_SB_PORT_ID, QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW);\r
34 Data32 |= B_CFG_STICKY_RW_FORCE_RECOVERY;\r
35 QNCAltPortWrite (QUARK_SCSS_SOC_UNIT_SB_PORT_ID, QUARK_SCSS_SOC_UNIT_CFG_STICKY_RW, Data32);\r
36\r
37 //\r
38 // Initialte the warm reset\r
39 //\r
40 ResetWarm ();\r
41}\r
42\r
43/**\r
44 This function allows the user to force a system recovery and deadloop.\r
45\r
46 Deadloop required since system should not execute beyond this point.\r
47 Deadloop should never happen since OemInitiateRecovery () called within\r
48 this routine should never return since it executes a Warm Reset.\r
49\r
50**/\r
51VOID\r
52EFIAPI\r
53OemInitiateRecoveryAndWait (\r
54 VOID\r
55 )\r
56{\r
57 volatile UINTN Index;\r
58\r
59 OemInitiateRecovery ();\r
60 for (Index = 0; Index == 0;);\r
61}\r