]> git.proxmox.com Git - mirror_edk2.git/blame - PcAtChipsetPkg/KbcResetDxe/ResetEntry.c
RefRefine soma code to make code run safely.
[mirror_edk2.git] / PcAtChipsetPkg / KbcResetDxe / ResetEntry.c
CommitLineData
18c97f53 1/** @file\r
2 Driver entry for KbcReset driver.\r
c69dd9df 3\r
95d48e82 4Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
18c97f53 5This program and the accompanying materials \r
c69dd9df 6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
18c97f53 12**/\r
c69dd9df 13\r
bb77cee7 14#include <PiDxe.h>\r
15\r
16#include <Library/DebugLib.h>\r
17#include <Library/UefiBootServicesTableLib.h>\r
18#include <Library/ResetSystemLib.h>\r
19\r
20#include <Protocol/Reset.h>\r
c69dd9df 21\r
22//\r
23// The handle onto which the Reset Architectural Protocol is installed\r
24//\r
25EFI_HANDLE mResetHandle = NULL;\r
26\r
bb77cee7 27/**\r
28 Reset the system.\r
29\r
30 @param ResetType warm or cold\r
31 @param ResetStatus possible cause of reset\r
32 @param DataSize Size of ResetData in bytes\r
33 @param ResetData Optional Unicode string\r
34\r
35**/\r
36VOID\r
37EFIAPI\r
38KbcResetSystem (\r
39 IN EFI_RESET_TYPE ResetType,\r
40 IN EFI_STATUS ResetStatus,\r
41 IN UINTN DataSize,\r
42 IN VOID *ResetData OPTIONAL\r
43 )\r
44{\r
45 switch (ResetType) {\r
46 case EfiResetWarm:\r
47 ResetWarm ();\r
48 break;\r
49 case EfiResetCold:\r
50 ResetCold ();\r
51 break;\r
52 case EfiResetShutdown:\r
53 ResetShutdown ();\r
54 break;\r
55 default:\r
56 return;\r
57 }\r
58\r
59 //\r
60 // Given we should have reset getting here would be bad\r
61 //\r
62 ASSERT (FALSE);\r
63}\r
c69dd9df 64\r
18c97f53 65/**\r
24115e44 66 Initialize the state information for the Reset Architectural Protocol.\r
18c97f53 67\r
68 @param ImageHandle Handle of the loaded driver \r
69 @param SystemTable Pointer to the System Table\r
70\r
71 @retval EFI_SUCCESS Thread can be successfully created\r
72 @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure\r
73 @retval EFI_DEVICE_ERROR Cannot create the timer service\r
74\r
75**/\r
c69dd9df 76EFI_STATUS\r
77EFIAPI\r
78InitializeReset (\r
79 IN EFI_HANDLE ImageHandle,\r
80 IN EFI_SYSTEM_TABLE *SystemTable\r
81 )\r
c69dd9df 82{\r
83 EFI_STATUS Status;\r
84\r
85 //\r
86 // Make sure the Reset Architectural Protocol is not already installed in the system\r
87 //\r
88 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiResetArchProtocolGuid);\r
89\r
90 //\r
91 // Hook the runtime service table\r
92 //\r
93 SystemTable->RuntimeServices->ResetSystem = KbcResetSystem;\r
94\r
95 //\r
96 // Now install the Reset RT AP on a new handle\r
97 //\r
98 Status = gBS->InstallMultipleProtocolInterfaces (\r
99 &mResetHandle,\r
bb77cee7 100 &gEfiResetArchProtocolGuid, NULL,\r
c69dd9df 101 NULL\r
102 );\r
103 ASSERT_EFI_ERROR (Status);\r
104\r
105 return Status;\r
106}\r