]>
Commit | Line | Data |
---|---|---|
432cf05b | 1 | /** @file\r |
2 | DiskIo driver that lays on every BlockIo protocol in the system.\r | |
3 | DiskIo converts a block oriented device to a byte oriented device.\r | |
4 | \r | |
5 | Disk access may have to handle unaligned request about sector boundaries.\r | |
6 | There are three cases:\r | |
7 | UnderRun - The first byte is not on a sector boundary or the read request is\r | |
8 | less than a sector in length.\r | |
9 | Aligned - A read of N contiguous sectors.\r | |
10 | OverRun - The last byte is not on a sector boundary.\r | |
11 | \r | |
12 | Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r | |
13 | All rights reserved. This program and the accompanying materials \r | |
14 | are licensed and made available under the terms and conditions of the BSD License \r | |
15 | which accompanies this distribution. The full text of the license may be found at \r | |
16 | http://opensource.org/licenses/bsd-license.php \r | |
17 | \r | |
18 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
19 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
20 | \r | |
21 | **/\r | |
22 | \r | |
23 | #include "DriverHealthDxe.h"\r | |
24 | \r | |
25 | #undef STRING_TOKEN\r | |
26 | #define STRING_TOKEN(x) 0\r | |
27 | \r | |
28 | extern EFI_GUID gEfiCallerIdGuid;\r | |
29 | \r | |
30 | CHAR16 VariableName[] = L"Config";\r | |
31 | UINTN mNumNotHealthy = 0;\r | |
32 | UINT8 ControllerIndex = 0;\r | |
33 | \r | |
34 | //\r | |
35 | // Link used to store the controller health status\r | |
36 | //\r | |
37 | LIST_ENTRY mControllerList = {NULL, NULL};\r | |
38 | \r | |
39 | //\r | |
40 | // 0 - Healthy -> {0}\r | |
41 | // 1 - Health with warning messages -> {1}\r | |
42 | // 2 - Failed -> {2}\r | |
43 | // 3 - Failed with error messages -> {3}\r | |
44 | // 4 - RebootRequired -> {4}\r | |
45 | // 5 - RebootRequired with messages -> {5}\r | |
46 | // 6 - ReconnectRequired -> {6}\r | |
47 | // 7 - ReconnectRequired with messages -> {7}\r | |
48 | // 100..103 - RepairRequired -> {0..3}\r | |
49 | // 104..107 - RepairRequired with error messages -> {0..3}\r | |
50 | // 108..111 - RepairRequired with progress notifications -> {0..3}\r | |
51 | // 112..115 - RepairRequired with error messages and progress notifications -> {0..3}\r | |
52 | // 132..163 - RepairRequired -> {300..331}\r | |
53 | // 164..195 - RepairRequired with error messages -> {300..331}\r | |
54 | // 196..227 - RepairRequired with progress notifications -> {300..331}\r | |
55 | // 228..259 - RepairRequired with error messages and progress notifications -> {300..331}\r | |
56 | // 300..307 - ConfigRequired -> {0..7}\r | |
57 | // 308..315 - ConfigRequired with error messages -> {0..7}\r | |
58 | // 316..323 - ConfigRequired with forms -> {0..7}\r | |
59 | // 324..331 - ConfigRequired with forms and error messages -> {0..7}\r | |
60 | // 332..347 - ConfigRequired -> {100..115}\r | |
61 | // 348..363 - ConfigRequired with error messages -> {100..115}\r | |
62 | // 364..379 - ConfigRequired with forms -> {100.115}\r | |
63 | // 380..395 - ConfigRequired with forms and error messages -> {100..115}\r | |
64 | \r | |
65 | DEVICE_STATE mDeviceState[] = {\r | |
66 | { TRUE, 308, 000, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
67 | { TRUE, 309, 001, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
68 | { TRUE, 310, 002, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
69 | { TRUE, 311, 003, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
70 | { TRUE, 312, 004, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
71 | { TRUE, 313, 005, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
72 | { TRUE, 314, 006, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
73 | { TRUE, 315, 007, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
74 | \r | |
75 | { TRUE, 000, 000, 0, FALSE, EfiDriverHealthStatusHealthy },\r | |
76 | { TRUE, 001, 001, STRING_TOKEN (STR_HEALTHY_WARNING), FALSE, EfiDriverHealthStatusHealthy },\r | |
77 | \r | |
78 | { TRUE, 002, 002, 0, FALSE, EfiDriverHealthStatusFailed },\r | |
79 | { TRUE, 003, 003, STRING_TOKEN (STR_FAILED_ERROR), FALSE, EfiDriverHealthStatusFailed },\r | |
80 | \r | |
81 | { FALSE, 004, 004, 0, FALSE, EfiDriverHealthStatusRebootRequired },\r | |
82 | { FALSE, 005, 005, STRING_TOKEN (STR_REBOOT_REQUIRED), FALSE, EfiDriverHealthStatusRebootRequired },\r | |
83 | \r | |
84 | { FALSE, 006, 006, 0, FALSE, EfiDriverHealthStatusReconnectRequired },\r | |
85 | { FALSE, 007, 007, STRING_TOKEN (STR_RECONNECT_REQUIRED), FALSE, EfiDriverHealthStatusReconnectRequired },\r | |
86 | \r | |
87 | { TRUE, 100, 000, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
88 | { TRUE, 101, 001, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
89 | { TRUE, 102, 002, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
90 | { TRUE, 103, 003, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
91 | \r | |
92 | { TRUE, 104, 000, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
93 | { TRUE, 105, 001, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
94 | { TRUE, 106, 002, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
95 | { TRUE, 107, 003, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
96 | \r | |
97 | { TRUE, 108, 000, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
98 | { TRUE, 109, 001, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
99 | { TRUE, 110, 002, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
100 | { TRUE, 111, 003, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
101 | \r | |
102 | { TRUE, 112, 000, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
103 | { TRUE, 113, 001, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
104 | { TRUE, 114, 002, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
105 | { TRUE, 115, 003, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
106 | \r | |
107 | { TRUE, 132, 300, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
108 | { TRUE, 133, 301, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
109 | { TRUE, 134, 302, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
110 | { TRUE, 135, 303, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
111 | { TRUE, 136, 304, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
112 | { TRUE, 137, 305, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
113 | { TRUE, 138, 306, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
114 | { TRUE, 139, 307, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
115 | { TRUE, 140, 308, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
116 | { TRUE, 141, 309, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
117 | { TRUE, 142, 310, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
118 | { TRUE, 143, 311, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
119 | { TRUE, 144, 312, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
120 | { TRUE, 145, 313, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
121 | { TRUE, 146, 314, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
122 | { TRUE, 147, 315, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
123 | { TRUE, 148, 316, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
124 | { TRUE, 149, 317, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
125 | { TRUE, 150, 318, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
126 | { TRUE, 151, 319, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
127 | { TRUE, 152, 320, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
128 | { TRUE, 153, 321, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
129 | { TRUE, 154, 322, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
130 | { TRUE, 155, 323, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
131 | { TRUE, 156, 324, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
132 | { TRUE, 157, 325, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
133 | { TRUE, 158, 326, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
134 | { TRUE, 159, 327, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
135 | { TRUE, 160, 328, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
136 | { TRUE, 161, 329, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
137 | { TRUE, 162, 330, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
138 | { TRUE, 163, 331, 0, FALSE, EfiDriverHealthStatusRepairRequired },\r | |
139 | \r | |
140 | { TRUE, 164, 300, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
141 | { TRUE, 165, 301, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
142 | { TRUE, 166, 302, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
143 | { TRUE, 167, 303, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
144 | { TRUE, 168, 304, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
145 | { TRUE, 169, 305, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
146 | { TRUE, 170, 306, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
147 | { TRUE, 171, 307, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
148 | { TRUE, 172, 308, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
149 | { TRUE, 173, 309, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
150 | { TRUE, 174, 310, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
151 | { TRUE, 175, 311, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
152 | { TRUE, 176, 312, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
153 | { TRUE, 177, 313, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
154 | { TRUE, 178, 314, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
155 | { TRUE, 179, 315, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
156 | { TRUE, 180, 316, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
157 | { TRUE, 181, 317, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
158 | { TRUE, 182, 318, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
159 | { TRUE, 183, 319, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
160 | { TRUE, 184, 320, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
161 | { TRUE, 185, 321, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
162 | { TRUE, 186, 322, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
163 | { TRUE, 187, 323, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
164 | { TRUE, 188, 324, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
165 | { TRUE, 189, 325, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
166 | { TRUE, 190, 326, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
167 | { TRUE, 191, 327, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
168 | { TRUE, 192, 328, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
169 | { TRUE, 193, 329, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
170 | { TRUE, 194, 330, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
171 | { TRUE, 195, 331, STRING_TOKEN (STR_REPAIR_REQUIRED), FALSE, EfiDriverHealthStatusRepairRequired },\r | |
172 | \r | |
173 | { TRUE, 196, 300, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
174 | { TRUE, 197, 301, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
175 | { TRUE, 198, 302, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
176 | { TRUE, 199, 303, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
177 | { TRUE, 200, 304, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
178 | { TRUE, 201, 305, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
179 | { TRUE, 202, 306, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
180 | { TRUE, 203, 307, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
181 | { TRUE, 204, 308, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
182 | { TRUE, 205, 309, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
183 | { TRUE, 206, 310, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
184 | { TRUE, 207, 311, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
185 | { TRUE, 208, 312, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
186 | { TRUE, 209, 313, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
187 | { TRUE, 210, 314, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
188 | { TRUE, 211, 315, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
189 | { TRUE, 212, 316, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
190 | { TRUE, 213, 317, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
191 | { TRUE, 214, 318, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
192 | { TRUE, 215, 319, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
193 | { TRUE, 216, 320, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
194 | { TRUE, 217, 321, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
195 | { TRUE, 218, 322, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
196 | { TRUE, 219, 323, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
197 | { TRUE, 220, 324, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
198 | { TRUE, 221, 325, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
199 | { TRUE, 222, 326, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
200 | { TRUE, 223, 327, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
201 | { TRUE, 224, 328, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
202 | { TRUE, 225, 329, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
203 | { TRUE, 226, 330, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
204 | { TRUE, 227, 331, 0, TRUE, EfiDriverHealthStatusRepairRequired },\r | |
205 | \r | |
206 | { TRUE, 228, 300, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
207 | { TRUE, 229, 301, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
208 | { TRUE, 230, 302, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
209 | { TRUE, 231, 303, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
210 | { TRUE, 232, 304, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
211 | { TRUE, 233, 305, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
212 | { TRUE, 234, 306, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
213 | { TRUE, 235, 307, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
214 | { TRUE, 236, 308, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
215 | { TRUE, 237, 309, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
216 | { TRUE, 238, 310, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
217 | { TRUE, 239, 311, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
218 | { TRUE, 240, 312, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
219 | { TRUE, 241, 313, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
220 | { TRUE, 242, 314, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
221 | { TRUE, 243, 315, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
222 | { TRUE, 244, 316, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
223 | { TRUE, 245, 317, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
224 | { TRUE, 246, 318, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
225 | { TRUE, 247, 319, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
226 | { TRUE, 248, 320, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
227 | { TRUE, 249, 321, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
228 | { TRUE, 250, 322, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
229 | { TRUE, 251, 323, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
230 | { TRUE, 252, 324, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
231 | { TRUE, 253, 325, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
232 | { TRUE, 254, 326, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
233 | { TRUE, 255, 327, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
234 | { TRUE, 256, 328, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
235 | { TRUE, 257, 329, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
236 | { TRUE, 258, 330, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
237 | { TRUE, 259, 331, STRING_TOKEN (STR_REPAIR_REQUIRED), TRUE, EfiDriverHealthStatusRepairRequired },\r | |
238 | \r | |
239 | { TRUE, 300, 000, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
240 | { TRUE, 301, 001, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
241 | { TRUE, 302, 002, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
242 | { TRUE, 303, 003, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
243 | { TRUE, 304, 004, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
244 | { TRUE, 305, 005, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
245 | { TRUE, 306, 006, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
246 | { TRUE, 307, 007, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
247 | \r | |
248 | { TRUE, 308, 000, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
249 | { TRUE, 309, 001, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
250 | { TRUE, 310, 002, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
251 | { TRUE, 311, 003, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
252 | { TRUE, 312, 004, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
253 | { TRUE, 313, 005, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
254 | { TRUE, 314, 006, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
255 | { TRUE, 315, 007, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
256 | \r | |
257 | { TRUE, 316, 000, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
258 | { TRUE, 317, 001, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
259 | { TRUE, 318, 002, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
260 | { TRUE, 319, 003, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
261 | { TRUE, 320, 004, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
262 | { TRUE, 321, 005, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
263 | { TRUE, 322, 006, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
264 | { TRUE, 323, 007, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
265 | \r | |
266 | { TRUE, 324, 000, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
267 | { TRUE, 325, 001, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
268 | { TRUE, 326, 002, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
269 | { TRUE, 327, 003, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
270 | { TRUE, 328, 004, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
271 | { TRUE, 329, 005, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
272 | { TRUE, 330, 006, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
273 | { TRUE, 331, 007, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
274 | \r | |
275 | { TRUE, 332, 100, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
276 | { TRUE, 333, 101, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
277 | { TRUE, 334, 102, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
278 | { TRUE, 335, 103, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
279 | { TRUE, 336, 104, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
280 | { TRUE, 337, 105, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
281 | { TRUE, 338, 106, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
282 | { TRUE, 339, 107, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
283 | { TRUE, 340, 108, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
284 | { TRUE, 341, 109, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
285 | { TRUE, 342, 110, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
286 | { TRUE, 343, 111, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
287 | { TRUE, 344, 112, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
288 | { TRUE, 345, 113, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
289 | { TRUE, 346, 114, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
290 | { TRUE, 347, 115, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
291 | \r | |
292 | { TRUE, 348, 100, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
293 | { TRUE, 349, 101, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
294 | { TRUE, 350, 102, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
295 | { TRUE, 351, 103, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
296 | { TRUE, 352, 104, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
297 | { TRUE, 353, 105, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
298 | { TRUE, 354, 106, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
299 | { TRUE, 355, 107, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
300 | { TRUE, 356, 108, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
301 | { TRUE, 357, 109, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
302 | { TRUE, 358, 110, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
303 | { TRUE, 359, 111, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
304 | { TRUE, 360, 112, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
305 | { TRUE, 361, 113, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
306 | { TRUE, 362, 114, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
307 | { TRUE, 363, 115, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
308 | \r | |
309 | { TRUE, 364, 100, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
310 | { TRUE, 365, 101, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
311 | { TRUE, 366, 102, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
312 | { TRUE, 367, 103, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
313 | { TRUE, 368, 104, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
314 | { TRUE, 369, 105, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
315 | { TRUE, 370, 106, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
316 | { TRUE, 371, 107, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
317 | { TRUE, 372, 108, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
318 | { TRUE, 373, 109, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
319 | { TRUE, 374, 110, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
320 | { TRUE, 375, 111, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
321 | { TRUE, 376, 112, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
322 | { TRUE, 377, 113, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
323 | { TRUE, 378, 114, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
324 | { TRUE, 379, 115, 0, FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
325 | \r | |
326 | { TRUE, 380, 100, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
327 | { TRUE, 381, 101, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
328 | { TRUE, 382, 102, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
329 | { TRUE, 383, 103, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
330 | { TRUE, 384, 104, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
331 | { TRUE, 385, 105, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
332 | { TRUE, 386, 106, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
333 | { TRUE, 387, 107, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
334 | { TRUE, 388, 108, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
335 | { TRUE, 389, 109, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
336 | { TRUE, 390, 110, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
337 | { TRUE, 391, 111, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
338 | { TRUE, 392, 112, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
339 | { TRUE, 393, 113, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
340 | { TRUE, 394, 114, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
341 | { TRUE, 395, 115, STRING_TOKEN (STR_CONFIG_WARNING), FALSE, EfiDriverHealthStatusConfigurationRequired },\r | |
342 | \r | |
343 | { TRUE, 999, 999, 0, FALSE }\r | |
344 | };\r | |
345 | \r | |
346 | HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathDiskIoDummy = {\r | |
347 | {\r | |
348 | {\r | |
349 | HARDWARE_DEVICE_PATH,\r | |
350 | HW_VENDOR_DP,\r | |
351 | {\r | |
352 | (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r | |
353 | (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r | |
354 | }\r | |
355 | },\r | |
356 | //\r | |
357 | // {C153B68E-EBFC-488e-B110-662867745BBE}\r | |
358 | //\r | |
359 | { 0xc153b68e, 0xebfc, 0x488e, { 0xb1, 0x10, 0x66, 0x28, 0x67, 0x74, 0x5b, 0xbe} }\r | |
360 | },\r | |
361 | {\r | |
362 | END_DEVICE_PATH_TYPE,\r | |
363 | END_ENTIRE_DEVICE_PATH_SUBTYPE,\r | |
364 | { \r | |
365 | (UINT8) (END_DEVICE_PATH_LENGTH),\r | |
366 | (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r | |
367 | }\r | |
368 | }\r | |
369 | };\r | |
370 | \r | |
371 | EFI_HII_HANDLE mHiiHandle = NULL;\r | |
372 | \r | |
373 | EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding = {\r | |
374 | DiskIoDriverBindingSupported,\r | |
375 | DiskIoDriverBindingStart,\r | |
376 | DiskIoDriverBindingStop,\r | |
377 | 0xaa,\r | |
378 | NULL,\r | |
379 | NULL\r | |
380 | };\r | |
381 | \r | |
382 | EFI_DRIVER_HEALTH_PROTOCOL gDiskIoDriverHealth = {\r | |
383 | DiskIoDriverHealthGetHealthStatus,\r | |
384 | DiskIoDriverHealthRepair\r | |
385 | };\r | |
386 | //\r | |
387 | // Template for DiskIo private data structure.\r | |
388 | // The pointer to BlockIo protocol interface is assigned dynamically.\r | |
389 | //\r | |
390 | DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate = {\r | |
391 | DISK_IO_PRIVATE_DATA_SIGNATURE,\r | |
392 | {\r | |
393 | EFI_DISK_IO_PROTOCOL_REVISION,\r | |
394 | DiskIoReadDisk,\r | |
395 | DiskIoWriteDisk\r | |
396 | },\r | |
397 | NULL,\r | |
398 | NULL, // Handle\r | |
399 | NULL, // Consumed Protocol\r | |
400 | NULL,\r | |
401 | //\r | |
402 | // Produced Protocol\r | |
403 | //\r | |
404 | {\r | |
405 | DummyExtractConfig,\r | |
406 | DummyRouteConfig,\r | |
407 | DummyDriverCallback\r | |
408 | },\r | |
409 | //\r | |
410 | // NVdata\r | |
411 | //\r | |
412 | { 0x0 },\r | |
413 | //\r | |
414 | // Controller Name\r | |
415 | //\r | |
416 | NULL,\r | |
417 | //\r | |
418 | // Controller Index\r | |
419 | //\r | |
420 | 0\r | |
421 | };\r | |
422 | \r | |
423 | DEVICE_STATE *\r | |
424 | GetDeviceState (\r | |
425 | UINTN DeviceStateNumber\r | |
426 | )\r | |
427 | {\r | |
428 | UINTN Index;\r | |
429 | \r | |
430 | for (Index = 0; mDeviceState[Index].CurrentState != 999 && mDeviceState[Index].CurrentState != DeviceStateNumber; Index++);\r | |
431 | ASSERT (mDeviceState[Index].CurrentState != 999);\r | |
432 | \r | |
433 | return &mDeviceState[Index];\r | |
434 | }\r | |
435 | \r | |
436 | \r | |
437 | /**\r | |
438 | Test to see if this driver supports ControllerHandle. \r | |
439 | \r | |
440 | @param This Protocol instance pointer.\r | |
441 | @param ControllerHandle Handle of device to test\r | |
442 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
443 | device to start.\r | |
444 | \r | |
445 | @retval EFI_SUCCESS This driver supports this device\r | |
446 | @retval EFI_ALREADY_STARTED This driver is already running on this device\r | |
447 | @retval other This driver does not support this device\r | |
448 | \r | |
449 | **/\r | |
450 | EFI_STATUS\r | |
451 | EFIAPI\r | |
452 | DiskIoDriverBindingSupported (\r | |
453 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
454 | IN EFI_HANDLE ControllerHandle,\r | |
455 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
456 | )\r | |
457 | {\r | |
458 | EFI_STATUS Status;\r | |
459 | EFI_BLOCK_IO_PROTOCOL *BlockIo;\r | |
460 | \r | |
461 | //\r | |
462 | // Open the IO Abstraction(s) needed to perform the supported test.\r | |
463 | //\r | |
464 | Status = gBS->OpenProtocol (\r | |
465 | ControllerHandle,\r | |
466 | &gEfiBlockIoProtocolGuid,\r | |
467 | (VOID **) &BlockIo,\r | |
468 | This->DriverBindingHandle,\r | |
469 | ControllerHandle,\r | |
470 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
471 | );\r | |
472 | if (EFI_ERROR (Status)) {\r | |
473 | return Status;\r | |
474 | }\r | |
475 | \r | |
476 | //\r | |
477 | // Close the I/O Abstraction(s) used to perform the supported test.\r | |
478 | //\r | |
479 | gBS->CloseProtocol (\r | |
480 | ControllerHandle,\r | |
481 | &gEfiBlockIoProtocolGuid,\r | |
482 | This->DriverBindingHandle,\r | |
483 | ControllerHandle\r | |
484 | );\r | |
485 | return EFI_SUCCESS;\r | |
486 | }\r | |
487 | \r | |
488 | \r | |
489 | /**\r | |
490 | Start this driver on ControllerHandle by opening a Block IO protocol and\r | |
491 | installing a Disk IO protocol on ControllerHandle.\r | |
492 | \r | |
493 | @param This Protocol instance pointer.\r | |
494 | @param ControllerHandle Handle of device to bind driver to\r | |
495 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
496 | device to start.\r | |
497 | \r | |
498 | @retval EFI_SUCCESS This driver is added to ControllerHandle\r | |
499 | @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r | |
500 | @retval other This driver does not support this device\r | |
501 | \r | |
502 | **/\r | |
503 | EFI_STATUS\r | |
504 | EFIAPI\r | |
505 | DiskIoDriverBindingStart (\r | |
506 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
507 | IN EFI_HANDLE ControllerHandle,\r | |
508 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
509 | )\r | |
510 | {\r | |
511 | EFI_STATUS Status;\r | |
512 | DISK_IO_PRIVATE_DATA *Private;\r | |
513 | DEVICE_STATE *DeviceState;\r | |
514 | UINTN DataSize;\r | |
515 | UINT32 StartCount;\r | |
516 | CONTROLLER_STATE *ControllerState;\r | |
517 | \r | |
518 | Private = NULL;\r | |
519 | ControllerState = NULL;\r | |
520 | \r | |
521 | //\r | |
522 | // Connect to the Block IO interface on ControllerHandle.\r | |
523 | //\r | |
524 | Status = gBS->OpenProtocol (\r | |
525 | ControllerHandle,\r | |
526 | &gEfiBlockIoProtocolGuid,\r | |
527 | (VOID **) &gDiskIoPrivateDataTemplate.BlockIo,\r | |
528 | This->DriverBindingHandle,\r | |
529 | ControllerHandle,\r | |
530 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
531 | );\r | |
532 | if (EFI_ERROR (Status)) {\r | |
533 | return Status;\r | |
534 | }\r | |
535 | \r | |
536 | //\r | |
537 | // Initialize the Disk IO device instance.\r | |
538 | //\r | |
539 | Private = AllocateCopyPool (sizeof (DISK_IO_PRIVATE_DATA), &gDiskIoPrivateDataTemplate);\r | |
540 | if (Private == NULL) {\r | |
541 | Status = EFI_OUT_OF_RESOURCES;\r | |
542 | goto ErrorExit;\r | |
543 | }\r | |
544 | \r | |
545 | //\r | |
546 | // Begin Driver Health Protocol Support\r | |
547 | //\r | |
548 | DataSize = sizeof (StartCount);\r | |
549 | Status = gRT->GetVariable (\r | |
550 | L"StartCount",\r | |
551 | &gEfiCallerIdGuid,\r | |
552 | NULL,\r | |
553 | &DataSize,\r | |
554 | &StartCount\r | |
555 | );\r | |
556 | if (EFI_ERROR (Status)) {\r | |
557 | //\r | |
558 | // If the configuration can not be read, then set the default config value of 0\r | |
559 | //\r | |
560 | StartCount = 0;\r | |
561 | }\r | |
562 | \r | |
563 | ControllerIndex++;\r | |
564 | \r | |
565 | DeviceState = GetDeviceState (mDeviceState[StartCount].CurrentState);\r | |
566 | ASSERT (DeviceState != NULL);\r | |
567 | \r | |
568 | ControllerState = AllocateZeroPool (sizeof (CONTROLLER_STATE));\r | |
569 | if (ControllerState == NULL) {\r | |
570 | return EFI_OUT_OF_RESOURCES;\r | |
571 | }\r | |
572 | \r | |
573 | ControllerState->ControllerHandle = ControllerHandle;\r | |
574 | ControllerState->Signature = DISK_IO_CONTROLLER_STATE_SIGNATURE;\r | |
575 | ControllerState->DeviceStateNum = DeviceState->CurrentState;\r | |
576 | ControllerState->ChildHandle = NULL;\r | |
577 | ControllerState->ControllerIndex = ControllerIndex; \r | |
578 | \r | |
579 | InsertTailList (&mControllerList, &ControllerState->Link);\r | |
580 | \r | |
581 | if (DeviceState->HealthStatus != EfiDriverHealthStatusHealthy || DeviceState->StringId != 0) {\r | |
582 | mNumNotHealthy++;\r | |
583 | }\r | |
584 | \r | |
585 | StartCount++;\r | |
586 | while (!mDeviceState[StartCount].StartState) {\r | |
587 | if (mDeviceState[StartCount].CurrentState == 999) {\r | |
588 | StartCount = 0;\r | |
589 | } else {\r | |
590 | StartCount++;\r | |
591 | }\r | |
592 | }\r | |
593 | if (mDeviceState[StartCount].CurrentState == 999) {\r | |
594 | StartCount = 0;\r | |
595 | }\r | |
596 | \r | |
597 | Status = gRT->SetVariable (\r | |
598 | L"StartCount",\r | |
599 | &gEfiCallerIdGuid,\r | |
600 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
601 | sizeof (StartCount),\r | |
602 | &StartCount\r | |
603 | );\r | |
604 | ASSERT_EFI_ERROR (Status);\r | |
605 | \r | |
606 | if (DeviceState->HealthStatus == EfiDriverHealthStatusConfigurationRequired) {\r | |
607 | Private->NVdata.ConfigGood = 0;\r | |
608 | } else {\r | |
609 | Private->NVdata.ConfigGood = 1;\r | |
610 | }\r | |
611 | Status = gRT->SetVariable (\r | |
612 | L"Config",\r | |
613 | &gEfiCallerIdGuid,\r | |
614 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
615 | sizeof (Private->NVdata.ConfigGood),\r | |
616 | &Private->NVdata.ConfigGood\r | |
617 | );\r | |
618 | ASSERT_EFI_ERROR (Status);\r | |
619 | \r | |
620 | //\r | |
621 | // End Driver Health Protocol Support\r | |
622 | //\r | |
623 | \r | |
624 | //\r | |
625 | // Install protocol interfaces for the Disk IO device.\r | |
626 | //\r | |
627 | Status = gBS->InstallProtocolInterface (\r | |
628 | &ControllerHandle,\r | |
629 | &gEfiDiskIoProtocolGuid,\r | |
630 | EFI_NATIVE_INTERFACE,\r | |
631 | &Private->DiskIo\r | |
632 | );\r | |
633 | \r | |
634 | Private->ControllerIndex = ControllerIndex;\r | |
635 | AddName (Private);\r | |
636 | \r | |
637 | ErrorExit:\r | |
638 | if (EFI_ERROR (Status)) {\r | |
639 | \r | |
640 | if (Private != NULL) {\r | |
641 | FreeUnicodeStringTable (Private->ControllerNameTable);\r | |
642 | FreePool (Private);\r | |
643 | }\r | |
644 | \r | |
645 | gBS->CloseProtocol (\r | |
646 | ControllerHandle,\r | |
647 | &gEfiBlockIoProtocolGuid,\r | |
648 | This->DriverBindingHandle,\r | |
649 | ControllerHandle\r | |
650 | );\r | |
651 | }\r | |
652 | \r | |
653 | return Status;\r | |
654 | }\r | |
655 | \r | |
656 | \r | |
657 | /**\r | |
658 | Stop this driver on ControllerHandle by removing Disk IO protocol and closing\r | |
659 | the Block IO protocol on ControllerHandle.\r | |
660 | \r | |
661 | @param This Protocol instance pointer.\r | |
662 | @param ControllerHandle Handle of device to stop driver on\r | |
663 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
664 | children is zero stop the entire bus driver.\r | |
665 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
666 | \r | |
667 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
668 | @retval other This driver was not removed from this device\r | |
669 | \r | |
670 | **/\r | |
671 | EFI_STATUS\r | |
672 | EFIAPI\r | |
673 | DiskIoDriverBindingStop (\r | |
674 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
675 | IN EFI_HANDLE ControllerHandle,\r | |
676 | IN UINTN NumberOfChildren,\r | |
677 | IN EFI_HANDLE *ChildHandleBuffer\r | |
678 | )\r | |
679 | {\r | |
680 | EFI_STATUS Status;\r | |
681 | EFI_DISK_IO_PROTOCOL *DiskIo;\r | |
682 | DISK_IO_PRIVATE_DATA *Private;\r | |
683 | DEVICE_STATE *DeviceState;\r | |
684 | CONTROLLER_STATE *ControllerState;\r | |
685 | LIST_ENTRY *Link;\r | |
686 | \r | |
687 | ControllerState = NULL;\r | |
688 | DeviceState = NULL;\r | |
689 | \r | |
690 | //\r | |
691 | // Get our context back.\r | |
692 | //\r | |
693 | Status = gBS->OpenProtocol (\r | |
694 | ControllerHandle,\r | |
695 | &gEfiDiskIoProtocolGuid,\r | |
696 | (VOID **) &DiskIo,\r | |
697 | This->DriverBindingHandle,\r | |
698 | ControllerHandle,\r | |
699 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
700 | );\r | |
701 | if (EFI_ERROR (Status)) {\r | |
702 | return EFI_UNSUPPORTED;\r | |
703 | }\r | |
704 | \r | |
705 | Private = DISK_IO_PRIVATE_DATA_FROM_THIS (DiskIo);\r | |
706 | \r | |
707 | Status = gBS->UninstallProtocolInterface (\r | |
708 | ControllerHandle,\r | |
709 | &gEfiDiskIoProtocolGuid,\r | |
710 | &Private->DiskIo\r | |
711 | );\r | |
712 | if (!EFI_ERROR (Status)) {\r | |
713 | \r | |
714 | Status = gBS->CloseProtocol (\r | |
715 | ControllerHandle,\r | |
716 | &gEfiBlockIoProtocolGuid,\r | |
717 | This->DriverBindingHandle,\r | |
718 | ControllerHandle\r | |
719 | );\r | |
720 | //\r | |
721 | // Get the Controller State from global list\r | |
722 | //\r | |
723 | Link = GetFirstNode (&mControllerList);\r | |
724 | \r | |
725 | while (!IsNull (&mControllerList, Link)) {\r | |
726 | ControllerState = DISK_IO_CONTROLLER_STATE_FROM_LINK (Link);\r | |
727 | \r | |
728 | if (ControllerState->ControllerHandle == ControllerHandle) {\r | |
729 | DeviceState = GetDeviceState (ControllerState->DeviceStateNum);\r | |
730 | break;\r | |
731 | }\r | |
732 | Link = GetNextNode (&mControllerList, Link);\r | |
733 | }\r | |
734 | \r | |
735 | ASSERT (DeviceState != NULL);\r | |
736 | \r | |
737 | if (DeviceState->HealthStatus != EfiDriverHealthStatusHealthy || DeviceState->StringId != 0) {\r | |
738 | mNumNotHealthy--;\r | |
739 | }\r | |
740 | \r | |
741 | RemoveEntryList (Link);\r | |
742 | \r | |
743 | if (ControllerState != NULL) {\r | |
744 | FreePool (ControllerState);\r | |
745 | } \r | |
746 | }\r | |
747 | \r | |
748 | if (!EFI_ERROR (Status)) {\r | |
749 | FreeUnicodeStringTable (Private->ControllerNameTable);\r | |
750 | FreePool (Private);\r | |
751 | }\r | |
752 | \r | |
753 | ControllerIndex = 0;\r | |
754 | return Status;\r | |
755 | }\r | |
756 | \r | |
757 | \r | |
758 | \r | |
759 | /**\r | |
760 | Read BufferSize bytes from Offset into Buffer.\r | |
761 | Reads may support reads that are not aligned on\r | |
762 | sector boundaries. There are three cases:\r | |
763 | UnderRun - The first byte is not on a sector boundary or the read request is\r | |
764 | less than a sector in length.\r | |
765 | Aligned - A read of N contiguous sectors.\r | |
766 | OverRun - The last byte is not on a sector boundary.\r | |
767 | \r | |
768 | @param This Protocol instance pointer.\r | |
769 | @param MediaId Id of the media, changes every time the media is replaced.\r | |
770 | @param Offset The starting byte offset to read from\r | |
771 | @param BufferSize Size of Buffer\r | |
772 | @param Buffer Buffer containing read data\r | |
773 | \r | |
774 | @retval EFI_SUCCESS The data was read correctly from the device.\r | |
775 | @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r | |
776 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
777 | @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r | |
778 | @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r | |
779 | valid for the device.\r | |
780 | \r | |
781 | **/\r | |
782 | EFI_STATUS\r | |
783 | EFIAPI\r | |
784 | DiskIoReadDisk (\r | |
785 | IN EFI_DISK_IO_PROTOCOL *This,\r | |
786 | IN UINT32 MediaId,\r | |
787 | IN UINT64 Offset,\r | |
788 | IN UINTN BufferSize,\r | |
789 | OUT VOID *Buffer\r | |
790 | )\r | |
791 | {\r | |
792 | EFI_STATUS Status;\r | |
793 | DISK_IO_PRIVATE_DATA *Private;\r | |
794 | EFI_BLOCK_IO_PROTOCOL *BlockIo;\r | |
795 | EFI_BLOCK_IO_MEDIA *Media;\r | |
796 | UINT32 BlockSize;\r | |
797 | UINT64 Lba;\r | |
798 | UINT64 OverRunLba;\r | |
799 | UINT32 UnderRun;\r | |
800 | UINT32 OverRun;\r | |
801 | BOOLEAN TransactionComplete;\r | |
802 | UINTN WorkingBufferSize;\r | |
803 | UINT8 *WorkingBuffer;\r | |
804 | UINTN Length;\r | |
805 | UINT8 *Data;\r | |
806 | UINT8 *PreData;\r | |
807 | UINTN IsBufferAligned;\r | |
808 | UINTN DataBufferSize;\r | |
809 | BOOLEAN LastRead;\r | |
810 | \r | |
811 | Private = DISK_IO_PRIVATE_DATA_FROM_THIS (This);\r | |
812 | \r | |
813 | BlockIo = Private->BlockIo;\r | |
814 | Media = BlockIo->Media;\r | |
815 | BlockSize = Media->BlockSize;\r | |
816 | \r | |
817 | if (Media->MediaId != MediaId) {\r | |
818 | return EFI_MEDIA_CHANGED;\r | |
819 | }\r | |
820 | \r | |
821 | WorkingBuffer = Buffer;\r | |
822 | WorkingBufferSize = BufferSize;\r | |
823 | \r | |
824 | //\r | |
825 | // Allocate a temporary buffer for operation\r | |
826 | //\r | |
827 | DataBufferSize = BlockSize * DATA_BUFFER_BLOCK_NUM;\r | |
828 | \r | |
829 | if (Media->IoAlign > 1) {\r | |
830 | PreData = AllocatePool (DataBufferSize + Media->IoAlign);\r | |
831 | Data = PreData - ((UINTN) PreData & (Media->IoAlign - 1)) + Media->IoAlign;\r | |
832 | } else {\r | |
833 | PreData = AllocatePool (DataBufferSize);\r | |
834 | Data = PreData;\r | |
835 | }\r | |
836 | \r | |
837 | if (PreData == NULL) {\r | |
838 | return EFI_OUT_OF_RESOURCES;\r | |
839 | }\r | |
840 | \r | |
841 | Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun);\r | |
842 | \r | |
843 | Length = BlockSize - UnderRun;\r | |
844 | TransactionComplete = FALSE;\r | |
845 | \r | |
846 | Status = EFI_SUCCESS;\r | |
847 | if (UnderRun != 0) {\r | |
848 | //\r | |
849 | // Offset starts in the middle of an Lba, so read the entire block.\r | |
850 | //\r | |
851 | Status = BlockIo->ReadBlocks (\r | |
852 | BlockIo,\r | |
853 | MediaId,\r | |
854 | Lba,\r | |
855 | BlockSize,\r | |
856 | Data\r | |
857 | );\r | |
858 | \r | |
859 | if (EFI_ERROR (Status)) {\r | |
860 | goto Done;\r | |
861 | }\r | |
862 | \r | |
863 | if (Length > BufferSize) {\r | |
864 | Length = BufferSize;\r | |
865 | TransactionComplete = TRUE;\r | |
866 | }\r | |
867 | \r | |
868 | CopyMem (WorkingBuffer, Data + UnderRun, Length);\r | |
869 | \r | |
870 | WorkingBuffer += Length;\r | |
871 | \r | |
872 | WorkingBufferSize -= Length;\r | |
873 | if (WorkingBufferSize == 0) {\r | |
874 | goto Done;\r | |
875 | }\r | |
876 | \r | |
877 | Lba += 1;\r | |
878 | }\r | |
879 | \r | |
880 | OverRunLba = Lba + DivU64x32Remainder (WorkingBufferSize, BlockSize, &OverRun);\r | |
881 | \r | |
882 | if (!TransactionComplete && WorkingBufferSize >= BlockSize) {\r | |
883 | //\r | |
884 | // If the DiskIo maps directly to a BlockIo device do the read.\r | |
885 | //\r | |
886 | if (OverRun != 0) {\r | |
887 | WorkingBufferSize -= OverRun;\r | |
888 | }\r | |
889 | //\r | |
890 | // Check buffer alignment\r | |
891 | //\r | |
892 | IsBufferAligned = (UINTN) WorkingBuffer & (UINTN) (Media->IoAlign - 1);\r | |
893 | \r | |
894 | if (Media->IoAlign <= 1 || IsBufferAligned == 0) {\r | |
895 | //\r | |
896 | // Alignment is satisfied, so read them together\r | |
897 | //\r | |
898 | Status = BlockIo->ReadBlocks (\r | |
899 | BlockIo,\r | |
900 | MediaId,\r | |
901 | Lba,\r | |
902 | WorkingBufferSize,\r | |
903 | WorkingBuffer\r | |
904 | );\r | |
905 | \r | |
906 | if (EFI_ERROR (Status)) {\r | |
907 | goto Done;\r | |
908 | }\r | |
909 | \r | |
910 | WorkingBuffer += WorkingBufferSize;\r | |
911 | \r | |
912 | } else {\r | |
913 | //\r | |
914 | // Use the allocated buffer instead of the original buffer\r | |
915 | // to avoid alignment issue.\r | |
916 | // Here, the allocated buffer (8-byte align) can satisfy the alignment\r | |
917 | //\r | |
918 | LastRead = FALSE;\r | |
919 | do {\r | |
920 | if (WorkingBufferSize <= DataBufferSize) {\r | |
921 | //\r | |
922 | // It is the last calling to readblocks in this loop\r | |
923 | //\r | |
924 | DataBufferSize = WorkingBufferSize;\r | |
925 | LastRead = TRUE;\r | |
926 | }\r | |
927 | \r | |
928 | Status = BlockIo->ReadBlocks (\r | |
929 | BlockIo,\r | |
930 | MediaId,\r | |
931 | Lba,\r | |
932 | DataBufferSize,\r | |
933 | Data\r | |
934 | );\r | |
935 | if (EFI_ERROR (Status)) {\r | |
936 | goto Done;\r | |
937 | }\r | |
938 | \r | |
939 | CopyMem (WorkingBuffer, Data, DataBufferSize);\r | |
940 | WorkingBufferSize -= DataBufferSize;\r | |
941 | WorkingBuffer += DataBufferSize;\r | |
942 | Lba += DATA_BUFFER_BLOCK_NUM;\r | |
943 | } while (!LastRead);\r | |
944 | }\r | |
945 | }\r | |
946 | \r | |
947 | if (!TransactionComplete && OverRun != 0) {\r | |
948 | //\r | |
949 | // Last read is not a complete block.\r | |
950 | //\r | |
951 | Status = BlockIo->ReadBlocks (\r | |
952 | BlockIo,\r | |
953 | MediaId,\r | |
954 | OverRunLba,\r | |
955 | BlockSize,\r | |
956 | Data\r | |
957 | );\r | |
958 | \r | |
959 | if (EFI_ERROR (Status)) {\r | |
960 | goto Done;\r | |
961 | }\r | |
962 | \r | |
963 | CopyMem (WorkingBuffer, Data, OverRun);\r | |
964 | }\r | |
965 | \r | |
966 | Done:\r | |
967 | if (PreData != NULL) {\r | |
968 | FreePool (PreData);\r | |
969 | }\r | |
970 | \r | |
971 | return Status;\r | |
972 | }\r | |
973 | \r | |
974 | \r | |
975 | /**\r | |
976 | Writes BufferSize bytes from Buffer into Offset.\r | |
977 | Writes may require a read modify write to support writes that are not\r | |
978 | aligned on sector boundaries. There are three cases:\r | |
979 | UnderRun - The first byte is not on a sector boundary or the write request\r | |
980 | is less than a sector in length. Read modify write is required.\r | |
981 | Aligned - A write of N contiguous sectors.\r | |
982 | OverRun - The last byte is not on a sector boundary. Read modified write\r | |
983 | required.\r | |
984 | \r | |
985 | @param This Protocol instance pointer.\r | |
986 | @param MediaId Id of the media, changes every time the media is replaced.\r | |
987 | @param Offset The starting byte offset to read from\r | |
988 | @param BufferSize Size of Buffer\r | |
989 | @param Buffer Buffer containing read data\r | |
990 | \r | |
991 | @retval EFI_SUCCESS The data was written correctly to the device.\r | |
992 | @retval EFI_WRITE_PROTECTED The device can not be written to.\r | |
993 | @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r | |
994 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
995 | @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r | |
996 | @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not\r | |
997 | valid for the device.\r | |
998 | \r | |
999 | **/\r | |
1000 | EFI_STATUS\r | |
1001 | EFIAPI\r | |
1002 | DiskIoWriteDisk (\r | |
1003 | IN EFI_DISK_IO_PROTOCOL *This,\r | |
1004 | IN UINT32 MediaId,\r | |
1005 | IN UINT64 Offset,\r | |
1006 | IN UINTN BufferSize,\r | |
1007 | IN VOID *Buffer\r | |
1008 | )\r | |
1009 | {\r | |
1010 | EFI_STATUS Status;\r | |
1011 | DISK_IO_PRIVATE_DATA *Private;\r | |
1012 | EFI_BLOCK_IO_PROTOCOL *BlockIo;\r | |
1013 | EFI_BLOCK_IO_MEDIA *Media;\r | |
1014 | UINT32 BlockSize;\r | |
1015 | UINT64 Lba;\r | |
1016 | UINT64 OverRunLba;\r | |
1017 | UINT32 UnderRun;\r | |
1018 | UINT32 OverRun;\r | |
1019 | BOOLEAN TransactionComplete;\r | |
1020 | UINTN WorkingBufferSize;\r | |
1021 | UINT8 *WorkingBuffer;\r | |
1022 | UINTN Length;\r | |
1023 | UINT8 *Data;\r | |
1024 | UINT8 *PreData;\r | |
1025 | UINTN IsBufferAligned;\r | |
1026 | UINTN DataBufferSize;\r | |
1027 | BOOLEAN LastWrite;\r | |
1028 | \r | |
1029 | Private = DISK_IO_PRIVATE_DATA_FROM_THIS (This);\r | |
1030 | \r | |
1031 | BlockIo = Private->BlockIo;\r | |
1032 | Media = BlockIo->Media;\r | |
1033 | BlockSize = Media->BlockSize;\r | |
1034 | \r | |
1035 | if (Media->ReadOnly) {\r | |
1036 | return EFI_WRITE_PROTECTED;\r | |
1037 | }\r | |
1038 | \r | |
1039 | if (Media->MediaId != MediaId) {\r | |
1040 | return EFI_MEDIA_CHANGED;\r | |
1041 | }\r | |
1042 | \r | |
1043 | DataBufferSize = BlockSize * DATA_BUFFER_BLOCK_NUM;\r | |
1044 | \r | |
1045 | if (Media->IoAlign > 1) {\r | |
1046 | PreData = AllocatePool (DataBufferSize + Media->IoAlign);\r | |
1047 | Data = PreData - ((UINTN) PreData & (Media->IoAlign - 1)) + Media->IoAlign;\r | |
1048 | } else {\r | |
1049 | PreData = AllocatePool (DataBufferSize);\r | |
1050 | Data = PreData;\r | |
1051 | }\r | |
1052 | \r | |
1053 | if (PreData == NULL) {\r | |
1054 | return EFI_OUT_OF_RESOURCES;\r | |
1055 | }\r | |
1056 | \r | |
1057 | WorkingBuffer = Buffer;\r | |
1058 | WorkingBufferSize = BufferSize;\r | |
1059 | \r | |
1060 | Lba = DivU64x32Remainder (Offset, BlockSize, &UnderRun);\r | |
1061 | \r | |
1062 | Length = BlockSize - UnderRun;\r | |
1063 | TransactionComplete = FALSE;\r | |
1064 | \r | |
1065 | Status = EFI_SUCCESS;\r | |
1066 | if (UnderRun != 0) {\r | |
1067 | //\r | |
1068 | // Offset starts in the middle of an Lba, so do read modify write.\r | |
1069 | //\r | |
1070 | Status = BlockIo->ReadBlocks (\r | |
1071 | BlockIo,\r | |
1072 | MediaId,\r | |
1073 | Lba,\r | |
1074 | BlockSize,\r | |
1075 | Data\r | |
1076 | );\r | |
1077 | \r | |
1078 | if (EFI_ERROR (Status)) {\r | |
1079 | goto Done;\r | |
1080 | }\r | |
1081 | \r | |
1082 | if (Length > BufferSize) {\r | |
1083 | Length = BufferSize;\r | |
1084 | TransactionComplete = TRUE;\r | |
1085 | }\r | |
1086 | \r | |
1087 | CopyMem (Data + UnderRun, WorkingBuffer, Length);\r | |
1088 | \r | |
1089 | Status = BlockIo->WriteBlocks (\r | |
1090 | BlockIo,\r | |
1091 | MediaId,\r | |
1092 | Lba,\r | |
1093 | BlockSize,\r | |
1094 | Data\r | |
1095 | );\r | |
1096 | if (EFI_ERROR (Status)) {\r | |
1097 | goto Done;\r | |
1098 | }\r | |
1099 | \r | |
1100 | WorkingBuffer += Length;\r | |
1101 | WorkingBufferSize -= Length;\r | |
1102 | if (WorkingBufferSize == 0) {\r | |
1103 | goto Done;\r | |
1104 | }\r | |
1105 | \r | |
1106 | Lba += 1;\r | |
1107 | }\r | |
1108 | \r | |
1109 | OverRunLba = Lba + DivU64x32Remainder (WorkingBufferSize, BlockSize, &OverRun);\r | |
1110 | \r | |
1111 | if (!TransactionComplete && WorkingBufferSize >= BlockSize) {\r | |
1112 | //\r | |
1113 | // If the DiskIo maps directly to a BlockIo device do the write.\r | |
1114 | //\r | |
1115 | if (OverRun != 0) {\r | |
1116 | WorkingBufferSize -= OverRun;\r | |
1117 | }\r | |
1118 | //\r | |
1119 | // Check buffer alignment\r | |
1120 | //\r | |
1121 | IsBufferAligned = (UINTN) WorkingBuffer & (UINTN) (Media->IoAlign - 1);\r | |
1122 | \r | |
1123 | if (Media->IoAlign <= 1 || IsBufferAligned == 0) {\r | |
1124 | //\r | |
1125 | // Alignment is satisfied, so write them together\r | |
1126 | //\r | |
1127 | Status = BlockIo->WriteBlocks (\r | |
1128 | BlockIo,\r | |
1129 | MediaId,\r | |
1130 | Lba,\r | |
1131 | WorkingBufferSize,\r | |
1132 | WorkingBuffer\r | |
1133 | );\r | |
1134 | \r | |
1135 | if (EFI_ERROR (Status)) {\r | |
1136 | goto Done;\r | |
1137 | }\r | |
1138 | \r | |
1139 | WorkingBuffer += WorkingBufferSize;\r | |
1140 | \r | |
1141 | } else {\r | |
1142 | //\r | |
1143 | // The buffer parameter is not aligned with the request\r | |
1144 | // So use the allocated instead.\r | |
1145 | // It can fit almost all the cases.\r | |
1146 | //\r | |
1147 | LastWrite = FALSE;\r | |
1148 | do {\r | |
1149 | if (WorkingBufferSize <= DataBufferSize) {\r | |
1150 | //\r | |
1151 | // It is the last calling to writeblocks in this loop\r | |
1152 | //\r | |
1153 | DataBufferSize = WorkingBufferSize;\r | |
1154 | LastWrite = TRUE;\r | |
1155 | }\r | |
1156 | \r | |
1157 | CopyMem (Data, WorkingBuffer, DataBufferSize);\r | |
1158 | Status = BlockIo->WriteBlocks (\r | |
1159 | BlockIo,\r | |
1160 | MediaId,\r | |
1161 | Lba,\r | |
1162 | DataBufferSize,\r | |
1163 | Data\r | |
1164 | );\r | |
1165 | if (EFI_ERROR (Status)) {\r | |
1166 | goto Done;\r | |
1167 | }\r | |
1168 | \r | |
1169 | WorkingBufferSize -= DataBufferSize;\r | |
1170 | WorkingBuffer += DataBufferSize;\r | |
1171 | Lba += DATA_BUFFER_BLOCK_NUM;\r | |
1172 | } while (!LastWrite);\r | |
1173 | }\r | |
1174 | }\r | |
1175 | \r | |
1176 | if (!TransactionComplete && OverRun != 0) {\r | |
1177 | //\r | |
1178 | // Last bit is not a complete block, so do a read modify write.\r | |
1179 | //\r | |
1180 | Status = BlockIo->ReadBlocks (\r | |
1181 | BlockIo,\r | |
1182 | MediaId,\r | |
1183 | OverRunLba,\r | |
1184 | BlockSize,\r | |
1185 | Data\r | |
1186 | );\r | |
1187 | \r | |
1188 | if (EFI_ERROR (Status)) {\r | |
1189 | goto Done;\r | |
1190 | }\r | |
1191 | \r | |
1192 | CopyMem (Data, WorkingBuffer, OverRun);\r | |
1193 | \r | |
1194 | Status = BlockIo->WriteBlocks (\r | |
1195 | BlockIo,\r | |
1196 | MediaId,\r | |
1197 | OverRunLba,\r | |
1198 | BlockSize,\r | |
1199 | Data\r | |
1200 | );\r | |
1201 | if (EFI_ERROR (Status)) {\r | |
1202 | goto Done;\r | |
1203 | }\r | |
1204 | }\r | |
1205 | \r | |
1206 | Done:\r | |
1207 | if (PreData != NULL) {\r | |
1208 | FreePool (PreData);\r | |
1209 | }\r | |
1210 | \r | |
1211 | return Status;\r | |
1212 | }\r | |
1213 | \r | |
1214 | \r | |
1215 | /**\r | |
1216 | Retrieves the health status of a controller in the platform. This function can also \r | |
1217 | optionally return warning messages, error messages, and a set of HII Forms that may \r | |
1218 | be repair a controller that is not proper configured. \r | |
1219 | \r | |
1220 | @param This A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r | |
1221 | \r | |
1222 | @param ControllerHandle The handle of the controller to retrieve the health status \r | |
1223 | on. This is an optional parameter that may be NULL. If \r | |
1224 | this parameter is NULL, then the value of ChildHandle is \r | |
1225 | ignored, and the combined health status of all the devices \r | |
1226 | that the driver is managing is returned.\r | |
1227 | \r | |
1228 | @param ChildHandle The handle of the child controller to retrieve the health \r | |
1229 | status on. This is an optional parameter that may be NULL. \r | |
1230 | This parameter is ignored of ControllerHandle is NULL. It \r | |
1231 | will be NULL for device drivers. It will also be NULL for \r | |
1232 | bus drivers when an attempt is made to collect the health \r | |
1233 | status of the bus controller. If will not be NULL when an \r | |
1234 | attempt is made to collect the health status for a child \r | |
1235 | controller produced by the driver.\r | |
1236 | \r | |
1237 | @param HealthStatus A pointer to the health status that is returned by this \r | |
1238 | function. This is an optional parameter that may be NULL. \r | |
1239 | This parameter is ignored of ControllerHandle is NULL. \r | |
1240 | The health status for the controller specified by \r | |
1241 | ControllerHandle and ChildHandle is returned. \r | |
1242 | \r | |
1243 | @param MessageList A pointer to an array of warning or error messages associated \r | |
1244 | with the controller specified by ControllerHandle and \r | |
1245 | ChildHandle. This is an optional parameter that may be NULL. \r | |
1246 | MessageList is allocated by this function with the EFI Boot \r | |
1247 | Service AllocatePool(), and it is the caller's responsibility \r | |
1248 | to free MessageList with the EFI Boot Service FreePool(). \r | |
1249 | Each message is specified by tuple of an EFI_HII_HANDLE and \r | |
1250 | an EFI_STRING_ID. The array of messages is terminated by tuple \r | |
1251 | containing a EFI_HII_HANDLE with a value of NULL. The \r | |
1252 | EFI_HII_STRING_PROTOCOL.GetString() function can be used to \r | |
1253 | retrieve the warning or error message as a Null-terminated \r | |
1254 | Unicode string in a specific language. Messages may be \r | |
1255 | returned for any of the HealthStatus values except \r | |
1256 | EfiDriverHealthStatusReconnectRequired and \r | |
1257 | EfiDriverHealthStatusRebootRequired.\r | |
1258 | \r | |
1259 | @param FormHiiHandle A pointer to the HII handle for an HII form associated with the \r | |
1260 | controller specified by ControllerHandle and ChildHandle. \r | |
1261 | This is an optional parameter that may be NULL. An HII form \r | |
1262 | is specified by a combination of an EFI_HII_HANDLE and an \r | |
1263 | EFI_GUID that identifies the Form Set GUID. The \r | |
1264 | EFI_FORM_BROWSER2_PROTOCOL.SendForm() function can be used \r | |
1265 | to display and allow the user to make configuration changes \r | |
1266 | to the HII Form. An HII form may only be returned with a \r | |
1267 | HealthStatus value of EfiDriverHealthStatusConfigurationRequired.\r | |
1268 | \r | |
1269 | @retval EFI_SUCCESS ControllerHandle is NULL, and all the controllers \r | |
1270 | managed by this driver specified by This have a health \r | |
1271 | status of EfiDriverHealthStatusHealthy with no warning \r | |
1272 | messages to be returned. The ChildHandle, HealthStatus, \r | |
1273 | MessageList, and FormList parameters are ignored.\r | |
1274 | \r | |
1275 | @retval EFI_DEVICE_ERROR ControllerHandle is NULL, and one or more of the \r | |
1276 | controllers managed by this driver specified by This \r | |
1277 | do not have a health status of EfiDriverHealthStatusHealthy. \r | |
1278 | The ChildHandle, HealthStatus, MessageList, and \r | |
1279 | FormList parameters are ignored.\r | |
1280 | \r | |
1281 | @retval EFI_DEVICE_ERROR ControllerHandle is NULL, and one or more of the \r | |
1282 | controllers managed by this driver specified by This \r | |
1283 | have one or more warning and/or error messages. \r | |
1284 | The ChildHandle, HealthStatus, MessageList, and \r | |
1285 | FormList parameters are ignored.\r | |
1286 | \r | |
1287 | @retval EFI_SUCCESS ControllerHandle is not NULL and the health status \r | |
1288 | of the controller specified by ControllerHandle and \r | |
1289 | ChildHandle was returned in HealthStatus. A list \r | |
1290 | of warning and error messages may be optionally \r | |
1291 | returned in MessageList, and a list of HII Forms \r | |
1292 | may be optionally returned in FormList.\r | |
1293 | \r | |
1294 | @retval EFI_UNSUPPORTED ControllerHandle is not NULL, and the controller \r | |
1295 | specified by ControllerHandle and ChildHandle is not \r | |
1296 | currently being managed by the driver specified by This.\r | |
1297 | \r | |
1298 | @retval EFI_INVALID_PARAMETER HealthStatus is NULL.\r | |
1299 | \r | |
1300 | @retval EFI_OUT_OF_RESOURCES MessageList is not NULL, and there are not enough \r | |
1301 | resource available to allocate memory for MessageList.\r | |
1302 | \r | |
1303 | **/\r | |
1304 | EFI_STATUS\r | |
1305 | DiskIoDriverHealthGetHealthStatus (\r | |
1306 | IN EFI_DRIVER_HEALTH_PROTOCOL *This,\r | |
1307 | IN EFI_HANDLE ControllerHandle OPTIONAL,\r | |
1308 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
1309 | OUT EFI_DRIVER_HEALTH_STATUS *HealthStatus,\r | |
1310 | OUT EFI_DRIVER_HEALTH_HII_MESSAGE **MessageList OPTIONAL,\r | |
1311 | OUT EFI_HII_HANDLE *FormHiiHandle OPTIONAL\r | |
1312 | )\r | |
1313 | {\r | |
1314 | EFI_STATUS Status;\r | |
1315 | EFI_DISK_IO_PROTOCOL *DiskIo;\r | |
1316 | DISK_IO_PRIVATE_DATA *Private;\r | |
1317 | DEVICE_STATE *DeviceState;\r | |
1318 | CONTROLLER_STATE *ControllerState;\r | |
1319 | LIST_ENTRY *Link;\r | |
1320 | UINTN BufferSize;\r | |
1321 | \r | |
1322 | ControllerState = NULL;\r | |
1323 | DeviceState = NULL;\r | |
1324 | \r | |
1325 | if (HealthStatus == NULL) {\r | |
1326 | return EFI_INVALID_PARAMETER;\r | |
1327 | }\r | |
1328 | \r | |
1329 | if (ControllerHandle == NULL) {\r | |
1330 | *HealthStatus = EfiDriverHealthStatusHealthy;\r | |
1331 | if (mNumNotHealthy != 0) {\r | |
1332 | *HealthStatus = EfiDriverHealthStatusFailed;\r | |
1333 | }\r | |
1334 | return EFI_SUCCESS;\r | |
1335 | }\r | |
1336 | \r | |
1337 | //\r | |
1338 | // This is a device driver, so ChildHandle must be NULL.\r | |
1339 | //\r | |
1340 | if (ChildHandle != NULL) {\r | |
1341 | return EFI_UNSUPPORTED;\r | |
1342 | }\r | |
1343 | //\r | |
1344 | // Make sure this driver is currently managing ControllerHandle\r | |
1345 | //\r | |
1346 | Status = EfiTestManagedDevice (\r | |
1347 | ControllerHandle,\r | |
1348 | gDiskIoDriverBinding.DriverBindingHandle,\r | |
1349 | &gEfiBlockIoProtocolGuid\r | |
1350 | );\r | |
1351 | if (EFI_ERROR (Status)) {\r | |
1352 | return Status;\r | |
1353 | }\r | |
1354 | \r | |
1355 | if (HealthStatus == NULL) {\r | |
1356 | return EFI_INVALID_PARAMETER;\r | |
1357 | }\r | |
1358 | Status = gBS->HandleProtocol (ControllerHandle, &gEfiDiskIoProtocolGuid, (VOID **) &DiskIo);\r | |
1359 | if (EFI_ERROR (Status)) {\r | |
1360 | return EFI_UNSUPPORTED;\r | |
1361 | }\r | |
1362 | \r | |
1363 | if (HealthStatus == NULL) {\r | |
1364 | return EFI_INVALID_PARAMETER;\r | |
1365 | }\r | |
1366 | \r | |
1367 | Private = DISK_IO_PRIVATE_DATA_FROM_THIS (DiskIo);\r | |
1368 | \r | |
1369 | \r | |
1370 | //\r | |
1371 | // Get the Controller State from global list\r | |
1372 | //\r | |
1373 | Link = GetFirstNode (&mControllerList);\r | |
1374 | \r | |
1375 | while (!IsNull (&mControllerList, Link)) {\r | |
1376 | ControllerState = DISK_IO_CONTROLLER_STATE_FROM_LINK (Link);\r | |
1377 | \r | |
1378 | if (ControllerState->ControllerHandle == ControllerHandle) {\r | |
1379 | DeviceState = GetDeviceState (ControllerState->DeviceStateNum);\r | |
1380 | break;\r | |
1381 | }\r | |
1382 | Link = GetNextNode (&mControllerList, Link);\r | |
1383 | }\r | |
1384 | \r | |
1385 | ASSERT (DeviceState != NULL);\r | |
1386 | \r | |
1387 | if (DeviceState->HealthStatus == EfiDriverHealthStatusConfigurationRequired) {\r | |
1388 | \r | |
1389 | //\r | |
1390 | // Read the configuration for this device\r | |
1391 | //\r | |
1392 | BufferSize = sizeof (Private->NVdata.ConfigGood);\r | |
1393 | Status = gRT->GetVariable (\r | |
1394 | L"Config",\r | |
1395 | &gEfiCallerIdGuid,\r | |
1396 | NULL,\r | |
1397 | &BufferSize,\r | |
1398 | &Private->NVdata.ConfigGood\r | |
1399 | );\r | |
1400 | ASSERT_EFI_ERROR (Status);\r | |
1401 | \r | |
1402 | //\r | |
1403 | // If the config value is 1, then the configuration is valid and the state machine can move to the next state\r | |
1404 | // Otherwise, the state machine returns ConfigurationRequired again\r | |
1405 | //\r | |
1406 | if (Private->NVdata.ConfigGood == ControllerState->ControllerIndex) {\r | |
1407 | if (DeviceState->HealthStatus != EfiDriverHealthStatusHealthy || DeviceState->StringId != 0) {\r | |
1408 | mNumNotHealthy--;\r | |
1409 | }\r | |
1410 | \r | |
1411 | ControllerState->DeviceStateNum = DeviceState->NextState;\r | |
1412 | \r | |
1413 | DeviceState = GetDeviceState (ControllerState->DeviceStateNum);\r | |
1414 | ASSERT (DeviceState != NULL);\r | |
1415 | \r | |
1416 | if (DeviceState->HealthStatus != EfiDriverHealthStatusHealthy) {\r | |
1417 | mNumNotHealthy++;\r | |
1418 | }\r | |
1419 | }\r | |
1420 | } \r | |
1421 | \r | |
1422 | *HealthStatus = DeviceState->HealthStatus;\r | |
1423 | \r | |
1424 | if (MessageList != NULL) {\r | |
1425 | *MessageList = NULL;\r | |
1426 | if (DeviceState->StringId != 0) {\r | |
1427 | *MessageList = AllocateZeroPool (sizeof(EFI_DRIVER_HEALTH_HII_MESSAGE) * 2);\r | |
1428 | if (*MessageList == NULL) {\r | |
1429 | return EFI_UNSUPPORTED;\r | |
1430 | }\r | |
1431 | (*MessageList)[0].HiiHandle = mHiiHandle;\r | |
1432 | (*MessageList)[0].StringId = DeviceState->StringId;\r | |
1433 | } else {\r | |
1434 | *MessageList = AllocateZeroPool (sizeof(EFI_DRIVER_HEALTH_HII_MESSAGE) * 1);\r | |
1435 | if (*MessageList == NULL) {\r | |
1436 | return EFI_UNSUPPORTED;\r | |
1437 | }\r | |
1438 | }\r | |
1439 | }\r | |
1440 | if (FormHiiHandle != NULL) {\r | |
1441 | *FormHiiHandle = mHiiHandle;\r | |
1442 | }\r | |
1443 | \r | |
1444 | if (DeviceState->HealthStatus == EfiDriverHealthStatusConfigurationRequired) {\r | |
1445 | Private->NVdata.ConfigGood = 0;\r | |
1446 | Status = gRT->SetVariable (\r | |
1447 | L"Config",\r | |
1448 | &gEfiCallerIdGuid,\r | |
1449 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
1450 | sizeof (Private->NVdata.ConfigGood),\r | |
1451 | &Private->NVdata.ConfigGood\r | |
1452 | );\r | |
1453 | ASSERT_EFI_ERROR (Status);\r | |
1454 | }\r | |
1455 | \r | |
1456 | return EFI_SUCCESS;\r | |
1457 | }\r | |
1458 | \r | |
1459 | /**\r | |
1460 | Performs a repair operation on a controller in the platform. This function can \r | |
1461 | optionally report repair progress information back to the platform. \r | |
1462 | \r | |
1463 | @param This A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.\r | |
1464 | @param ControllerHandle The handle of the controller to repair.\r | |
1465 | @param ChildHandle The handle of the child controller to repair. This is \r | |
1466 | an optional parameter that may be NULL. It will be NULL \r | |
1467 | for device drivers. It will also be NULL for bus \r | |
1468 | drivers when an attempt is made to repair a bus controller.\r | |
1469 | If will not be NULL when an attempt is made to repair a \r | |
1470 | child controller produced by the driver.\r | |
1471 | @param RepairNotify A notification function that may be used by a driver to \r | |
1472 | report the progress of the repair operation. This is \r | |
1473 | an optional parameter that may be NULL. \r | |
1474 | \r | |
1475 | \r | |
1476 | @retval EFI_SUCCESS An attempt to repair the controller specified by \r | |
1477 | ControllerHandle and ChildHandle was performed. \r | |
1478 | The result of the repair operation can be \r | |
1479 | determined by calling GetHealthStatus().\r | |
1480 | @retval EFI_UNSUPPORTED The driver specified by This is not currently \r | |
1481 | managing the controller specified by ControllerHandle \r | |
1482 | and ChildHandle.\r | |
1483 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to perform the \r | |
1484 | repair operation.\r | |
1485 | \r | |
1486 | */\r | |
1487 | EFI_STATUS\r | |
1488 | DiskIoDriverHealthRepair (\r | |
1489 | IN EFI_DRIVER_HEALTH_PROTOCOL *This,\r | |
1490 | IN EFI_HANDLE ControllerHandle,\r | |
1491 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
1492 | IN EFI_DRIVER_HEALTH_REPAIR_PROGRESS_NOTIFY RepairNotify OPTIONAL\r | |
1493 | )\r | |
1494 | {\r | |
1495 | EFI_STATUS Status;\r | |
1496 | UINTN Index;\r | |
1497 | DEVICE_STATE *DeviceState;\r | |
1498 | CONTROLLER_STATE *ControllerState;\r | |
1499 | LIST_ENTRY *Link;\r | |
1500 | EFI_DISK_IO_PROTOCOL *DiskIo;\r | |
1501 | DISK_IO_PRIVATE_DATA *Private;\r | |
1502 | \r | |
1503 | Index = 0;\r | |
1504 | ControllerState = NULL;\r | |
1505 | DeviceState = NULL;\r | |
1506 | //\r | |
1507 | // This is a device driver, so ChildHandle must be NULL.\r | |
1508 | //\r | |
1509 | if (ChildHandle != NULL) {\r | |
1510 | return EFI_UNSUPPORTED;\r | |
1511 | }\r | |
1512 | //\r | |
1513 | // Make sure this driver is currently managing ControllerHandle\r | |
1514 | //\r | |
1515 | Status = EfiTestManagedDevice (\r | |
1516 | ControllerHandle,\r | |
1517 | gDiskIoDriverBinding.DriverBindingHandle,\r | |
1518 | &gEfiBlockIoProtocolGuid\r | |
1519 | );\r | |
1520 | if (EFI_ERROR (Status)) {\r | |
1521 | return Status;\r | |
1522 | }\r | |
1523 | \r | |
1524 | Status = gBS->HandleProtocol (ControllerHandle, &gEfiDiskIoProtocolGuid, (VOID **) &DiskIo);\r | |
1525 | if (EFI_ERROR (Status)) {\r | |
1526 | return EFI_UNSUPPORTED;\r | |
1527 | }\r | |
1528 | \r | |
1529 | Private = DISK_IO_PRIVATE_DATA_FROM_THIS (DiskIo);\r | |
1530 | \r | |
1531 | Link = GetFirstNode (&mControllerList);\r | |
1532 | \r | |
1533 | while (!IsNull (&mControllerList, Link)) {\r | |
1534 | ControllerState = DISK_IO_CONTROLLER_STATE_FROM_LINK (Link);\r | |
1535 | \r | |
1536 | if (ControllerState->ControllerHandle == ControllerHandle) {\r | |
1537 | DeviceState = GetDeviceState (ControllerState->DeviceStateNum);\r | |
1538 | break;\r | |
1539 | }\r | |
1540 | Link = GetNextNode (&mControllerList, Link);\r | |
1541 | }\r | |
1542 | \r | |
1543 | ASSERT (DeviceState != NULL);\r | |
1544 | //\r | |
1545 | // Check to see if the controller has already been repaired\r | |
1546 | //\r | |
1547 | if (DeviceState->HealthStatus != EfiDriverHealthStatusRepairRequired) {\r | |
1548 | return EFI_SUCCESS;\r | |
1549 | }\r | |
1550 | \r | |
1551 | if (DeviceState->RepairNotify) {\r | |
1552 | do {\r | |
1553 | RepairNotify(Index, 10);\r | |
1554 | Index++;\r | |
1555 | } while ((gBS->Stall(100000) == EFI_SUCCESS) && (Index < 10));\r | |
1556 | }\r | |
1557 | \r | |
1558 | if (DeviceState->HealthStatus != EfiDriverHealthStatusHealthy || DeviceState->StringId != 0) {\r | |
1559 | mNumNotHealthy--;\r | |
1560 | }\r | |
1561 | \r | |
1562 | //\r | |
1563 | // Repair success, go to next state\r | |
1564 | //\r | |
1565 | ControllerState->DeviceStateNum = DeviceState->NextState;\r | |
1566 | \r | |
1567 | DeviceState = GetDeviceState (ControllerState->DeviceStateNum);\r | |
1568 | ASSERT (DeviceState != NULL);\r | |
1569 | \r | |
1570 | if (DeviceState->HealthStatus != EfiDriverHealthStatusHealthy || DeviceState->StringId != 0) {\r | |
1571 | mNumNotHealthy++;\r | |
1572 | }\r | |
1573 | \r | |
1574 | if (DeviceState->HealthStatus == EfiDriverHealthStatusConfigurationRequired) {\r | |
1575 | Private->NVdata.ConfigGood = 0;\r | |
1576 | Status = gRT->SetVariable (\r | |
1577 | L"Config",\r | |
1578 | &gEfiCallerIdGuid,\r | |
1579 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
1580 | sizeof (Private->NVdata.ConfigGood),\r | |
1581 | &Private->NVdata.ConfigGood\r | |
1582 | );\r | |
1583 | ASSERT_EFI_ERROR (Status);\r | |
1584 | }\r | |
1585 | \r | |
1586 | return EFI_SUCCESS;\r | |
1587 | }\r | |
1588 | \r | |
1589 | /**\r | |
1590 | The user Entry Point for module DiskIo. The user code starts with this function.\r | |
1591 | \r | |
1592 | @param[in] ImageHandle The firmware allocated handle for the EFI image. \r | |
1593 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
1594 | \r | |
1595 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
1596 | @retval other Some error occurs when executing this entry point.\r | |
1597 | \r | |
1598 | **/\r | |
1599 | EFI_STATUS\r | |
1600 | EFIAPI\r | |
1601 | InitializeDiskIo (\r | |
1602 | IN EFI_HANDLE ImageHandle,\r | |
1603 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
1604 | )\r | |
1605 | {\r | |
1606 | EFI_STATUS Status;\r | |
1607 | //\r | |
1608 | // Install driver model protocol(s).\r | |
1609 | //\r | |
1610 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
1611 | ImageHandle,\r | |
1612 | SystemTable,\r | |
1613 | &gDiskIoDriverBinding,\r | |
1614 | ImageHandle,\r | |
1615 | &gDiskIoComponentName,\r | |
1616 | &gDiskIoComponentName2\r | |
1617 | );\r | |
1618 | \r | |
1619 | ASSERT_EFI_ERROR (Status);\r | |
1620 | \r | |
1621 | Status = gBS->InstallProtocolInterface (\r | |
1622 | &ImageHandle,\r | |
1623 | &gEfiDriverHealthProtocolGuid,\r | |
1624 | EFI_NATIVE_INTERFACE,\r | |
1625 | &gDiskIoDriverHealth\r | |
1626 | );\r | |
1627 | ASSERT_EFI_ERROR (Status);\r | |
1628 | \r | |
1629 | InitializeListHead (&mControllerList);\r | |
1630 | \r | |
1631 | gDiskIoPrivateDataTemplate.Handle = ImageHandle;\r | |
1632 | Status = DiskIoConfigFormInit ();\r | |
1633 | \r | |
1634 | ASSERT_EFI_ERROR (Status);\r | |
1635 | \r | |
1636 | return Status;\r | |
1637 | }\r | |
1638 | \r | |
1639 | /**\r | |
1640 | Initialize the serial configuration form.\r | |
1641 | \r | |
1642 | @retval EFI_SUCCESS The serial configuration form is initialized.\r | |
1643 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
1644 | @retval Others Other errors as indicated.\r | |
1645 | **/\r | |
1646 | EFI_STATUS\r | |
1647 | DiskIoConfigFormInit (\r | |
1648 | VOID\r | |
1649 | )\r | |
1650 | {\r | |
1651 | EFI_STATUS Status;\r | |
1652 | \r | |
1653 | //\r | |
1654 | // Locate Hii Database protocol\r | |
1655 | //\r | |
1656 | Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&gDiskIoPrivateDataTemplate.HiiDatabase);\r | |
1657 | if (EFI_ERROR (Status)) {\r | |
1658 | return Status;\r | |
1659 | }\r | |
1660 | \r | |
1661 | Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **)&gDiskIoPrivateDataTemplate.HiiConfigRouting);\r | |
1662 | if (EFI_ERROR (Status)) {\r | |
1663 | return Status;\r | |
1664 | }\r | |
1665 | \r | |
1666 | //\r | |
1667 | // Install Device Path Protocol and Config Access protocol to driver handle\r | |
1668 | //\r | |
1669 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
1670 | &gDiskIoPrivateDataTemplate.Handle,\r | |
1671 | &gEfiDevicePathProtocolGuid, &mHiiVendorDevicePathDiskIoDummy,\r | |
1672 | &gEfiHiiConfigAccessProtocolGuid, &gDiskIoPrivateDataTemplate.ConfigAccess,\r | |
1673 | NULL\r | |
1674 | );\r | |
1675 | if (EFI_ERROR (Status)) {\r | |
1676 | return Status;\r | |
1677 | }\r | |
1678 | \r | |
1679 | //\r | |
1680 | // Publish our HII data\r | |
1681 | //\r | |
1682 | mHiiHandle = HiiAddPackages (\r | |
1683 | &gEfiCallerIdGuid,\r | |
1684 | gDiskIoPrivateDataTemplate.Handle,\r | |
1685 | DriverHealthDxeStrings,\r | |
1686 | DriverHealthVfrBin,\r | |
1687 | NULL\r | |
1688 | );\r | |
1689 | if (mHiiHandle == NULL) {\r | |
1690 | return EFI_OUT_OF_RESOURCES;\r | |
1691 | }\r | |
1692 | \r | |
1693 | return EFI_SUCCESS;\r | |
1694 | }\r | |
1695 | /**\r | |
1696 | This function processes the results of changes in configuration.\r | |
1697 | \r | |
1698 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
1699 | @param Action Specifies the type of action taken by the browser.\r | |
1700 | @param QuestionId A unique value which is sent to the original\r | |
1701 | exporting driver so that it can identify the type\r | |
1702 | of data to expect.\r | |
1703 | @param Type The type of value for the question.\r | |
1704 | @param Value A pointer to the data being sent to the original\r | |
1705 | exporting driver.\r | |
1706 | @param ActionRequest On return, points to the action requested by the\r | |
1707 | callback function.\r | |
1708 | \r | |
1709 | @retval EFI_SUCCESS The callback successfully handled the action.\r | |
1710 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r | |
1711 | variable and its data.\r | |
1712 | @retval EFI_DEVICE_ERROR The variable could not be saved.\r | |
1713 | @retval EFI_UNSUPPORTED The specified Action is not supported by the\r | |
1714 | callback.\r | |
1715 | \r | |
1716 | **/\r | |
1717 | EFI_STATUS\r | |
1718 | EFIAPI\r | |
1719 | DummyDriverCallback (\r | |
1720 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
1721 | IN EFI_BROWSER_ACTION Action,\r | |
1722 | IN EFI_QUESTION_ID QuestionId,\r | |
1723 | IN UINT8 Type,\r | |
1724 | IN EFI_IFR_TYPE_VALUE *Value,\r | |
1725 | OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r | |
1726 | )\r | |
1727 | {\r | |
1728 | \r | |
1729 | DISK_IO_NV_DATA *IfrNvData;\r | |
1730 | \r | |
1731 | //\r | |
1732 | // Retrieve uncommitted data from Browser\r | |
1733 | //\r | |
1734 | \r | |
1735 | IfrNvData = AllocateZeroPool (sizeof (DISK_IO_NV_DATA));\r | |
1736 | ASSERT (IfrNvData != NULL);\r | |
1737 | \r | |
1738 | if (!HiiGetBrowserData (&gEfiCallerIdGuid, VariableName, sizeof (DISK_IO_NV_DATA), (UINT8 *) IfrNvData)) {\r | |
1739 | FreePool (IfrNvData);\r | |
1740 | return EFI_NOT_FOUND;\r | |
1741 | }\r | |
1742 | \r | |
1743 | if ((Value == NULL) || (ActionRequest == NULL)) {\r | |
1744 | return EFI_INVALID_PARAMETER;\r | |
1745 | }\r | |
1746 | \r | |
1747 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r | |
1748 | \r | |
1749 | \r | |
1750 | return EFI_SUCCESS;\r | |
1751 | }\r | |
1752 | \r | |
1753 | /**\r | |
1754 | This function allows a caller to extract the current configuration for one\r | |
1755 | or more named elements from the target driver.\r | |
1756 | \r | |
1757 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
1758 | @param Request A null-terminated Unicode string in\r | |
1759 | <ConfigRequest> format.\r | |
1760 | @param Progress On return, points to a character in the Request\r | |
1761 | string. Points to the string's null terminator if\r | |
1762 | request was successful. Points to the most recent\r | |
1763 | '&' before the first failing name/value pair (or\r | |
1764 | the beginning of the string if the failure is in\r | |
1765 | the first name/value pair) if the request was not\r | |
1766 | successful.\r | |
1767 | @param Results A null-terminated Unicode string in\r | |
1768 | <ConfigAltResp> format which has all values filled\r | |
1769 | in for the names in the Request string. String to\r | |
1770 | be allocated by the called function.\r | |
1771 | \r | |
1772 | @retval EFI_SUCCESS The Results is filled with the requested values.\r | |
1773 | @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r | |
1774 | @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.\r | |
1775 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r | |
1776 | driver.\r | |
1777 | \r | |
1778 | **/\r | |
1779 | EFI_STATUS\r | |
1780 | EFIAPI\r | |
1781 | DummyExtractConfig (\r | |
1782 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
1783 | IN CONST EFI_STRING Request,\r | |
1784 | OUT EFI_STRING *Progress,\r | |
1785 | OUT EFI_STRING *Results\r | |
1786 | )\r | |
1787 | {\r | |
1788 | EFI_STATUS Status;\r | |
1789 | UINTN BufferSize;\r | |
1790 | DISK_IO_PRIVATE_DATA *PrivateData;\r | |
1791 | EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r | |
1792 | EFI_STRING ConfigRequest;\r | |
1793 | EFI_STRING ConfigRequestHdr;\r | |
1794 | UINTN Size;\r | |
1795 | \r | |
1796 | if (Progress == NULL || Results == NULL || Request == NULL) {\r | |
1797 | return EFI_INVALID_PARAMETER;\r | |
1798 | }\r | |
1799 | //\r | |
1800 | // Initialize the local variables.\r | |
1801 | //\r | |
1802 | ConfigRequestHdr = NULL;\r | |
1803 | ConfigRequest = NULL;\r | |
1804 | Size = 0;\r | |
1805 | *Progress = Request;\r | |
1806 | \r | |
1807 | PrivateData = DISK_IO_PRIVATE_DATA_FROM_CONFIG_ACCESS(This);\r | |
1808 | HiiConfigRouting = PrivateData->HiiConfigRouting;\r | |
1809 | \r | |
1810 | //\r | |
1811 | // Get Buffer Storage data from EFI variable.\r | |
1812 | // Try to get the current setting from variable.\r | |
1813 | //\r | |
1814 | BufferSize = sizeof (DISK_IO_NV_DATA);\r | |
1815 | Status = gRT->GetVariable (\r | |
1816 | VariableName,\r | |
1817 | &gEfiCallerIdGuid,\r | |
1818 | NULL,\r | |
1819 | &BufferSize,\r | |
1820 | &PrivateData->NVdata\r | |
1821 | );\r | |
1822 | if (EFI_ERROR (Status)) {\r | |
1823 | return EFI_NOT_FOUND;\r | |
1824 | }\r | |
1825 | \r | |
1826 | if (Request == NULL) {\r | |
1827 | //\r | |
1828 | // Request is set to NULL, construct full request string.\r | |
1829 | //\r | |
1830 | \r | |
1831 | //\r | |
1832 | // Allocate and fill a buffer large enough to hold the <ConfigHdr> template \r | |
1833 | // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r | |
1834 | //\r | |
1835 | ConfigRequestHdr = HiiConstructConfigHdr (&gEfiCallerIdGuid, VariableName, PrivateData->Handle);\r | |
1836 | Size = (StrLen (ConfigRequest) + 32 + 1) * sizeof (CHAR16);\r | |
1837 | ConfigRequest = AllocateZeroPool (Size);\r | |
1838 | UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r | |
1839 | FreePool (ConfigRequestHdr);\r | |
1840 | } else {\r | |
1841 | //\r | |
1842 | // Check routing data in <ConfigHdr>.\r | |
1843 | // Note: if only one Storage is used, then this checking could be skipped.\r | |
1844 | //\r | |
1845 | if (!HiiIsConfigHdrMatch (Request, &gEfiCallerIdGuid, VariableName)) {\r | |
1846 | return EFI_NOT_FOUND;\r | |
1847 | }\r | |
1848 | ConfigRequest = Request;\r | |
1849 | }\r | |
1850 | \r | |
1851 | //\r | |
1852 | // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r | |
1853 | //\r | |
1854 | Status = HiiConfigRouting->BlockToConfig (\r | |
1855 | HiiConfigRouting,\r | |
1856 | ConfigRequest,\r | |
1857 | (UINT8 *) &PrivateData->NVdata,\r | |
1858 | BufferSize,\r | |
1859 | Results,\r | |
1860 | Progress\r | |
1861 | );\r | |
1862 | \r | |
1863 | if (Request == NULL) {\r | |
1864 | FreePool (ConfigRequest);\r | |
1865 | *Progress = NULL;\r | |
1866 | }\r | |
1867 | \r | |
1868 | return Status;\r | |
1869 | }\r | |
1870 | \r | |
1871 | /**\r | |
1872 | This function processes the results of changes in configuration.\r | |
1873 | \r | |
1874 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
1875 | @param Configuration A null-terminated Unicode string in <ConfigResp>\r | |
1876 | format.\r | |
1877 | @param Progress A pointer to a string filled in with the offset of\r | |
1878 | the most recent '&' before the first failing\r | |
1879 | name/value pair (or the beginning of the string if\r | |
1880 | the failure is in the first name/value pair) or\r | |
1881 | the terminating NULL if all was successful.\r | |
1882 | \r | |
1883 | @retval EFI_SUCCESS The Results is processed successfully.\r | |
1884 | @retval EFI_INVALID_PARAMETER Configuration is NULL.\r | |
1885 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r | |
1886 | driver.\r | |
1887 | \r | |
1888 | **/\r | |
1889 | EFI_STATUS\r | |
1890 | EFIAPI\r | |
1891 | DummyRouteConfig (\r | |
1892 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
1893 | IN CONST EFI_STRING Configuration,\r | |
1894 | OUT EFI_STRING *Progress\r | |
1895 | )\r | |
1896 | {\r | |
1897 | EFI_STATUS Status;\r | |
1898 | UINTN BufferSize;\r | |
1899 | DISK_IO_PRIVATE_DATA *PrivateData;\r | |
1900 | EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r | |
1901 | \r | |
1902 | if (Configuration == NULL || Progress == NULL) {\r | |
1903 | return EFI_INVALID_PARAMETER;\r | |
1904 | }\r | |
1905 | \r | |
1906 | \r | |
1907 | PrivateData = DISK_IO_PRIVATE_DATA_FROM_CONFIG_ACCESS (This);\r | |
1908 | HiiConfigRouting = PrivateData->HiiConfigRouting;\r | |
1909 | *Progress = Configuration;\r | |
1910 | \r | |
1911 | //\r | |
1912 | // Check routing data in <ConfigHdr>.\r | |
1913 | // Note: if only one Storage is used, then this checking could be skipped.\r | |
1914 | //\r | |
1915 | if (!HiiIsConfigHdrMatch (Configuration, &gEfiCallerIdGuid, VariableName)) {\r | |
1916 | return EFI_NOT_FOUND;\r | |
1917 | }\r | |
1918 | \r | |
1919 | //\r | |
1920 | // Get Buffer Storage data from EFI variable\r | |
1921 | //\r | |
1922 | BufferSize = sizeof (DISK_IO_NV_DATA);\r | |
1923 | Status = gRT->GetVariable (\r | |
1924 | VariableName,\r | |
1925 | &gEfiCallerIdGuid,\r | |
1926 | NULL,\r | |
1927 | &BufferSize,\r | |
1928 | &PrivateData->NVdata\r | |
1929 | );\r | |
1930 | if (EFI_ERROR (Status)) {\r | |
1931 | return Status;\r | |
1932 | }\r | |
1933 | \r | |
1934 | //\r | |
1935 | // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()\r | |
1936 | //\r | |
1937 | BufferSize = sizeof (DISK_IO_NV_DATA);\r | |
1938 | Status = HiiConfigRouting->ConfigToBlock (\r | |
1939 | HiiConfigRouting,\r | |
1940 | Configuration,\r | |
1941 | (UINT8 *) &PrivateData->NVdata,\r | |
1942 | &BufferSize,\r | |
1943 | Progress\r | |
1944 | );\r | |
1945 | if (EFI_ERROR (Status)) {\r | |
1946 | return Status;\r | |
1947 | }\r | |
1948 | \r | |
1949 | //\r | |
1950 | // Store Buffer Storage back to EFI variable\r | |
1951 | //\r | |
1952 | Status = gRT->SetVariable(\r | |
1953 | VariableName,\r | |
1954 | &gEfiCallerIdGuid,\r | |
1955 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
1956 | sizeof (DISK_IO_NV_DATA),\r | |
1957 | &PrivateData->NVdata\r | |
1958 | );\r | |
1959 | \r | |
1960 | return Status;\r | |
1961 | }\r |