]>
Commit | Line | Data |
---|---|---|
804405e7 | 1 | /*++\r |
2 | \r | |
ccd55824 | 3 | Copyright (c) 2004 - 2009, Intel Corporation \r |
804405e7 | 4 | All rights reserved. This program and the accompanying materials \r |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | Reset.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Reset Architectural Protocol as defined in Tiano under UNIX Emulation\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "PiDxe.h"\r | |
23 | #include "UnixDxe.h"\r | |
24 | #include <Protocol/Reset.h>\r | |
25 | \r | |
26 | #include <Library/BaseLib.h>\r | |
27 | #include <Library/DebugLib.h>\r | |
28 | #include <Library/UefiLib.h>\r | |
29 | #include <Library/UefiDriverEntryPoint.h>\r | |
30 | #include <Library/UnixLib.h>\r | |
31 | #include <Library/MemoryAllocationLib.h>\r | |
32 | #include <Library/UefiBootServicesTableLib.h>\r | |
33 | \r | |
34 | EFI_STATUS\r | |
35 | EFIAPI\r | |
36 | InitializeUnixReset (\r | |
37 | IN EFI_HANDLE ImageHandle,\r | |
38 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
39 | );\r | |
40 | \r | |
7492c63d | 41 | VOID\r |
804405e7 | 42 | EFIAPI\r |
43 | UnixResetSystem (\r | |
44 | IN EFI_RESET_TYPE ResetType,\r | |
45 | IN EFI_STATUS ResetStatus,\r | |
46 | IN UINTN DataSize,\r | |
7646204c | 47 | IN VOID *ResetData OPTIONAL\r |
804405e7 | 48 | );\r |
49 | \r | |
50 | EFI_STATUS\r | |
51 | EFIAPI\r | |
52 | InitializeUnixReset (\r | |
53 | IN EFI_HANDLE ImageHandle,\r | |
54 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
55 | )\r | |
56 | /*++\r | |
57 | \r | |
58 | Routine Description:\r | |
59 | \r | |
60 | \r | |
61 | Arguments:\r | |
62 | \r | |
63 | ImageHandle of the loaded driver\r | |
64 | Pointer to the System Table\r | |
65 | \r | |
66 | Returns:\r | |
67 | \r | |
68 | Status\r | |
69 | --*/\r | |
70 | // TODO: SystemTable - add argument and description to function comment\r | |
71 | {\r | |
72 | EFI_STATUS Status;\r | |
73 | EFI_HANDLE Handle;\r | |
74 | \r | |
75 | SystemTable->RuntimeServices->ResetSystem = UnixResetSystem;\r | |
76 | \r | |
77 | Handle = NULL;\r | |
78 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
79 | &Handle,\r | |
80 | &gEfiResetArchProtocolGuid,\r | |
81 | NULL,\r | |
82 | NULL\r | |
83 | );\r | |
84 | ASSERT_EFI_ERROR (Status);\r | |
85 | \r | |
86 | return Status;\r | |
87 | }\r | |
88 | \r | |
7492c63d | 89 | VOID\r |
804405e7 | 90 | EFIAPI\r |
91 | UnixResetSystem (\r | |
92 | IN EFI_RESET_TYPE ResetType,\r | |
93 | IN EFI_STATUS ResetStatus,\r | |
94 | IN UINTN DataSize,\r | |
7646204c | 95 | IN VOID *ResetData OPTIONAL\r |
804405e7 | 96 | )\r |
97 | /*++\r | |
98 | \r | |
99 | Routine Description:\r | |
100 | \r | |
101 | TODO: Add function description\r | |
102 | \r | |
103 | Arguments:\r | |
104 | \r | |
105 | ResetType - TODO: add argument description\r | |
106 | ResetStatus - TODO: add argument description\r | |
107 | DataSize - TODO: add argument description\r | |
108 | ResetData - TODO: add argument description\r | |
109 | \r | |
110 | Returns:\r | |
111 | \r | |
112 | EFI_SUCCESS - TODO: Add description for return value\r | |
113 | \r | |
114 | --*/\r | |
115 | {\r | |
ccd55824 | 116 | EFI_STATUS Status;\r |
117 | UINTN HandleCount;\r | |
118 | EFI_HANDLE *HandleBuffer;\r | |
119 | UINTN Index;\r | |
120 | \r | |
804405e7 | 121 | //\r |
ccd55824 | 122 | // Disconnect all\r |
804405e7 | 123 | //\r |
ccd55824 | 124 | Status = gBS->LocateHandleBuffer (\r |
125 | AllHandles,\r | |
126 | NULL,\r | |
127 | NULL,\r | |
128 | &HandleCount,\r | |
129 | &HandleBuffer\r | |
130 | );\r | |
131 | if (!EFI_ERROR (Status)) {\r | |
132 | for (Index = 0; Index < HandleCount; Index++) {\r | |
133 | Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r | |
134 | }\r | |
135 | \r | |
136 | gBS->FreePool (HandleBuffer);\r | |
137 | }\r | |
138 | \r | |
139 | \r | |
804405e7 | 140 | //\r |
141 | // Discard ResetType, always return 0 as exit code\r | |
142 | //\r | |
143 | gUnix->Exit (0);\r | |
144 | \r | |
145 | //\r | |
146 | // Should never go here\r | |
147 | //\r | |
ccd55824 | 148 | ASSERT (FALSE);\r |
149 | \r | |
150 | return;\r | |
804405e7 | 151 | }\r |