2 DiskIo driver that lays on every BlockIo protocol in the system.
3 DiskIo converts a block oriented device to a byte oriented device.
5 Disk access may have to handle unaligned request about sector boundaries.
7 UnderRun - The first byte is not on a sector boundary or the read request is
8 less than a sector in length.
9 Aligned - A read of N contiguous sectors.
10 OverRun - The last byte is not on a sector boundary.
12 Copyright (c) 2006 - 2009, Intel Corporation. <BR>
13 All rights reserved. This program and the accompanying materials
14 are licensed and made available under the terms and conditions of the BSD License
15 which accompanies this distribution. The full text of the license may be found at
16 http://opensource.org/licenses/bsd-license.php
18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #include "DriverHealthDxe.h"
26 #define STRING_TOKEN(x) 0
28 extern EFI_GUID gEfiCallerIdGuid
;
30 CHAR16 VariableName
[] = L
"Config";
31 UINTN mNumNotHealthy
= 0;
32 UINT8 ControllerIndex
= 0;
35 // Link used to store the controller health status
37 LIST_ENTRY mControllerList
= {NULL
, NULL
};
41 // 1 - Health with warning messages -> {1}
43 // 3 - Failed with error messages -> {3}
44 // 4 - RebootRequired -> {4}
45 // 5 - RebootRequired with messages -> {5}
46 // 6 - ReconnectRequired -> {6}
47 // 7 - ReconnectRequired with messages -> {7}
48 // 100..103 - RepairRequired -> {0..3}
49 // 104..107 - RepairRequired with error messages -> {0..3}
50 // 108..111 - RepairRequired with progress notifications -> {0..3}
51 // 112..115 - RepairRequired with error messages and progress notifications -> {0..3}
52 // 132..163 - RepairRequired -> {300..331}
53 // 164..195 - RepairRequired with error messages -> {300..331}
54 // 196..227 - RepairRequired with progress notifications -> {300..331}
55 // 228..259 - RepairRequired with error messages and progress notifications -> {300..331}
56 // 300..307 - ConfigRequired -> {0..7}
57 // 308..315 - ConfigRequired with error messages -> {0..7}
58 // 316..323 - ConfigRequired with forms -> {0..7}
59 // 324..331 - ConfigRequired with forms and error messages -> {0..7}
60 // 332..347 - ConfigRequired -> {100..115}
61 // 348..363 - ConfigRequired with error messages -> {100..115}
62 // 364..379 - ConfigRequired with forms -> {100.115}
63 // 380..395 - ConfigRequired with forms and error messages -> {100..115}
65 DEVICE_STATE mDeviceState
[] = {
66 { TRUE
, 308, 000, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
67 { TRUE
, 309, 001, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
68 { TRUE
, 310, 002, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
69 { TRUE
, 311, 003, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
70 { TRUE
, 312, 004, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
71 { TRUE
, 313, 005, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
72 { TRUE
, 314, 006, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
73 { TRUE
, 315, 007, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
75 { TRUE
, 000, 000, 0, FALSE
, EfiDriverHealthStatusHealthy
},
76 { TRUE
, 001, 001, STRING_TOKEN (STR_HEALTHY_WARNING
), FALSE
, EfiDriverHealthStatusHealthy
},
78 { TRUE
, 002, 002, 0, FALSE
, EfiDriverHealthStatusFailed
},
79 { TRUE
, 003, 003, STRING_TOKEN (STR_FAILED_ERROR
), FALSE
, EfiDriverHealthStatusFailed
},
81 { FALSE
, 004, 004, 0, FALSE
, EfiDriverHealthStatusRebootRequired
},
82 { FALSE
, 005, 005, STRING_TOKEN (STR_REBOOT_REQUIRED
), FALSE
, EfiDriverHealthStatusRebootRequired
},
84 { FALSE
, 006, 006, 0, FALSE
, EfiDriverHealthStatusReconnectRequired
},
85 { FALSE
, 007, 007, STRING_TOKEN (STR_RECONNECT_REQUIRED
), FALSE
, EfiDriverHealthStatusReconnectRequired
},
87 { TRUE
, 100, 000, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
88 { TRUE
, 101, 001, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
89 { TRUE
, 102, 002, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
90 { TRUE
, 103, 003, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
92 { TRUE
, 104, 000, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
93 { TRUE
, 105, 001, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
94 { TRUE
, 106, 002, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
95 { TRUE
, 107, 003, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
97 { TRUE
, 108, 000, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
98 { TRUE
, 109, 001, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
99 { TRUE
, 110, 002, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
100 { TRUE
, 111, 003, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
102 { TRUE
, 112, 000, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
103 { TRUE
, 113, 001, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
104 { TRUE
, 114, 002, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
105 { TRUE
, 115, 003, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
107 { TRUE
, 132, 300, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
108 { TRUE
, 133, 301, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
109 { TRUE
, 134, 302, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
110 { TRUE
, 135, 303, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
111 { TRUE
, 136, 304, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
112 { TRUE
, 137, 305, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
113 { TRUE
, 138, 306, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
114 { TRUE
, 139, 307, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
115 { TRUE
, 140, 308, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
116 { TRUE
, 141, 309, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
117 { TRUE
, 142, 310, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
118 { TRUE
, 143, 311, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
119 { TRUE
, 144, 312, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
120 { TRUE
, 145, 313, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
121 { TRUE
, 146, 314, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
122 { TRUE
, 147, 315, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
123 { TRUE
, 148, 316, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
124 { TRUE
, 149, 317, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
125 { TRUE
, 150, 318, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
126 { TRUE
, 151, 319, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
127 { TRUE
, 152, 320, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
128 { TRUE
, 153, 321, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
129 { TRUE
, 154, 322, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
130 { TRUE
, 155, 323, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
131 { TRUE
, 156, 324, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
132 { TRUE
, 157, 325, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
133 { TRUE
, 158, 326, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
134 { TRUE
, 159, 327, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
135 { TRUE
, 160, 328, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
136 { TRUE
, 161, 329, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
137 { TRUE
, 162, 330, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
138 { TRUE
, 163, 331, 0, FALSE
, EfiDriverHealthStatusRepairRequired
},
140 { TRUE
, 164, 300, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
141 { TRUE
, 165, 301, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
142 { TRUE
, 166, 302, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
143 { TRUE
, 167, 303, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
144 { TRUE
, 168, 304, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
145 { TRUE
, 169, 305, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
146 { TRUE
, 170, 306, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
147 { TRUE
, 171, 307, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
148 { TRUE
, 172, 308, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
149 { TRUE
, 173, 309, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
150 { TRUE
, 174, 310, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
151 { TRUE
, 175, 311, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
152 { TRUE
, 176, 312, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
153 { TRUE
, 177, 313, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
154 { TRUE
, 178, 314, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
155 { TRUE
, 179, 315, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
156 { TRUE
, 180, 316, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
157 { TRUE
, 181, 317, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
158 { TRUE
, 182, 318, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
159 { TRUE
, 183, 319, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
160 { TRUE
, 184, 320, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
161 { TRUE
, 185, 321, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
162 { TRUE
, 186, 322, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
163 { TRUE
, 187, 323, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
164 { TRUE
, 188, 324, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
165 { TRUE
, 189, 325, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
166 { TRUE
, 190, 326, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
167 { TRUE
, 191, 327, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
168 { TRUE
, 192, 328, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
169 { TRUE
, 193, 329, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
170 { TRUE
, 194, 330, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
171 { TRUE
, 195, 331, STRING_TOKEN (STR_REPAIR_REQUIRED
), FALSE
, EfiDriverHealthStatusRepairRequired
},
173 { TRUE
, 196, 300, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
174 { TRUE
, 197, 301, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
175 { TRUE
, 198, 302, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
176 { TRUE
, 199, 303, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
177 { TRUE
, 200, 304, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
178 { TRUE
, 201, 305, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
179 { TRUE
, 202, 306, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
180 { TRUE
, 203, 307, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
181 { TRUE
, 204, 308, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
182 { TRUE
, 205, 309, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
183 { TRUE
, 206, 310, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
184 { TRUE
, 207, 311, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
185 { TRUE
, 208, 312, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
186 { TRUE
, 209, 313, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
187 { TRUE
, 210, 314, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
188 { TRUE
, 211, 315, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
189 { TRUE
, 212, 316, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
190 { TRUE
, 213, 317, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
191 { TRUE
, 214, 318, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
192 { TRUE
, 215, 319, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
193 { TRUE
, 216, 320, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
194 { TRUE
, 217, 321, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
195 { TRUE
, 218, 322, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
196 { TRUE
, 219, 323, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
197 { TRUE
, 220, 324, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
198 { TRUE
, 221, 325, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
199 { TRUE
, 222, 326, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
200 { TRUE
, 223, 327, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
201 { TRUE
, 224, 328, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
202 { TRUE
, 225, 329, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
203 { TRUE
, 226, 330, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
204 { TRUE
, 227, 331, 0, TRUE
, EfiDriverHealthStatusRepairRequired
},
206 { TRUE
, 228, 300, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
207 { TRUE
, 229, 301, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
208 { TRUE
, 230, 302, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
209 { TRUE
, 231, 303, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
210 { TRUE
, 232, 304, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
211 { TRUE
, 233, 305, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
212 { TRUE
, 234, 306, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
213 { TRUE
, 235, 307, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
214 { TRUE
, 236, 308, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
215 { TRUE
, 237, 309, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
216 { TRUE
, 238, 310, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
217 { TRUE
, 239, 311, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
218 { TRUE
, 240, 312, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
219 { TRUE
, 241, 313, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
220 { TRUE
, 242, 314, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
221 { TRUE
, 243, 315, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
222 { TRUE
, 244, 316, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
223 { TRUE
, 245, 317, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
224 { TRUE
, 246, 318, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
225 { TRUE
, 247, 319, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
226 { TRUE
, 248, 320, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
227 { TRUE
, 249, 321, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
228 { TRUE
, 250, 322, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
229 { TRUE
, 251, 323, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
230 { TRUE
, 252, 324, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
231 { TRUE
, 253, 325, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
232 { TRUE
, 254, 326, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
233 { TRUE
, 255, 327, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
234 { TRUE
, 256, 328, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
235 { TRUE
, 257, 329, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
236 { TRUE
, 258, 330, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
237 { TRUE
, 259, 331, STRING_TOKEN (STR_REPAIR_REQUIRED
), TRUE
, EfiDriverHealthStatusRepairRequired
},
239 { TRUE
, 300, 000, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
240 { TRUE
, 301, 001, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
241 { TRUE
, 302, 002, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
242 { TRUE
, 303, 003, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
243 { TRUE
, 304, 004, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
244 { TRUE
, 305, 005, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
245 { TRUE
, 306, 006, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
246 { TRUE
, 307, 007, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
248 { TRUE
, 308, 000, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
249 { TRUE
, 309, 001, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
250 { TRUE
, 310, 002, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
251 { TRUE
, 311, 003, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
252 { TRUE
, 312, 004, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
253 { TRUE
, 313, 005, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
254 { TRUE
, 314, 006, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
255 { TRUE
, 315, 007, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
257 { TRUE
, 316, 000, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
258 { TRUE
, 317, 001, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
259 { TRUE
, 318, 002, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
260 { TRUE
, 319, 003, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
261 { TRUE
, 320, 004, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
262 { TRUE
, 321, 005, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
263 { TRUE
, 322, 006, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
264 { TRUE
, 323, 007, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
266 { TRUE
, 324, 000, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
267 { TRUE
, 325, 001, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
268 { TRUE
, 326, 002, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
269 { TRUE
, 327, 003, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
270 { TRUE
, 328, 004, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
271 { TRUE
, 329, 005, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
272 { TRUE
, 330, 006, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
273 { TRUE
, 331, 007, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
275 { TRUE
, 332, 100, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
276 { TRUE
, 333, 101, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
277 { TRUE
, 334, 102, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
278 { TRUE
, 335, 103, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
279 { TRUE
, 336, 104, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
280 { TRUE
, 337, 105, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
281 { TRUE
, 338, 106, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
282 { TRUE
, 339, 107, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
283 { TRUE
, 340, 108, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
284 { TRUE
, 341, 109, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
285 { TRUE
, 342, 110, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
286 { TRUE
, 343, 111, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
287 { TRUE
, 344, 112, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
288 { TRUE
, 345, 113, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
289 { TRUE
, 346, 114, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
290 { TRUE
, 347, 115, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
292 { TRUE
, 348, 100, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
293 { TRUE
, 349, 101, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
294 { TRUE
, 350, 102, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
295 { TRUE
, 351, 103, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
296 { TRUE
, 352, 104, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
297 { TRUE
, 353, 105, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
298 { TRUE
, 354, 106, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
299 { TRUE
, 355, 107, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
300 { TRUE
, 356, 108, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
301 { TRUE
, 357, 109, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
302 { TRUE
, 358, 110, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
303 { TRUE
, 359, 111, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
304 { TRUE
, 360, 112, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
305 { TRUE
, 361, 113, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
306 { TRUE
, 362, 114, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
307 { TRUE
, 363, 115, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
309 { TRUE
, 364, 100, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
310 { TRUE
, 365, 101, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
311 { TRUE
, 366, 102, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
312 { TRUE
, 367, 103, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
313 { TRUE
, 368, 104, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
314 { TRUE
, 369, 105, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
315 { TRUE
, 370, 106, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
316 { TRUE
, 371, 107, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
317 { TRUE
, 372, 108, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
318 { TRUE
, 373, 109, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
319 { TRUE
, 374, 110, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
320 { TRUE
, 375, 111, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
321 { TRUE
, 376, 112, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
322 { TRUE
, 377, 113, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
323 { TRUE
, 378, 114, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
324 { TRUE
, 379, 115, 0, FALSE
, EfiDriverHealthStatusConfigurationRequired
},
326 { TRUE
, 380, 100, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
327 { TRUE
, 381, 101, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
328 { TRUE
, 382, 102, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
329 { TRUE
, 383, 103, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
330 { TRUE
, 384, 104, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
331 { TRUE
, 385, 105, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
332 { TRUE
, 386, 106, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
333 { TRUE
, 387, 107, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
334 { TRUE
, 388, 108, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
335 { TRUE
, 389, 109, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
336 { TRUE
, 390, 110, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
337 { TRUE
, 391, 111, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
338 { TRUE
, 392, 112, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
339 { TRUE
, 393, 113, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
340 { TRUE
, 394, 114, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
341 { TRUE
, 395, 115, STRING_TOKEN (STR_CONFIG_WARNING
), FALSE
, EfiDriverHealthStatusConfigurationRequired
},
343 { TRUE
, 999, 999, 0, FALSE
}
346 HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathDiskIoDummy
= {
349 HARDWARE_DEVICE_PATH
,
352 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
353 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
357 // {C153B68E-EBFC-488e-B110-662867745BBE}
359 { 0xc153b68e, 0xebfc, 0x488e, { 0xb1, 0x10, 0x66, 0x28, 0x67, 0x74, 0x5b, 0xbe} }
362 END_DEVICE_PATH_TYPE
,
363 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
365 (UINT8
) (END_DEVICE_PATH_LENGTH
),
366 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
371 EFI_HII_HANDLE mHiiHandle
= NULL
;
373 EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding
= {
374 DiskIoDriverBindingSupported
,
375 DiskIoDriverBindingStart
,
376 DiskIoDriverBindingStop
,
382 EFI_DRIVER_HEALTH_PROTOCOL gDiskIoDriverHealth
= {
383 DiskIoDriverHealthGetHealthStatus
,
384 DiskIoDriverHealthRepair
387 // Template for DiskIo private data structure.
388 // The pointer to BlockIo protocol interface is assigned dynamically.
390 DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate
= {
391 DISK_IO_PRIVATE_DATA_SIGNATURE
,
393 EFI_DISK_IO_PROTOCOL_REVISION
,
399 NULL
, // Consumed Protocol
425 UINTN DeviceStateNumber
430 for (Index
= 0; mDeviceState
[Index
].CurrentState
!= 999 && mDeviceState
[Index
].CurrentState
!= DeviceStateNumber
; Index
++);
431 ASSERT (mDeviceState
[Index
].CurrentState
!= 999);
433 return &mDeviceState
[Index
];
438 Test to see if this driver supports ControllerHandle.
440 @param This Protocol instance pointer.
441 @param ControllerHandle Handle of device to test
442 @param RemainingDevicePath Optional parameter use to pick a specific child
445 @retval EFI_SUCCESS This driver supports this device
446 @retval EFI_ALREADY_STARTED This driver is already running on this device
447 @retval other This driver does not support this device
452 DiskIoDriverBindingSupported (
453 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
454 IN EFI_HANDLE ControllerHandle
,
455 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
459 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
462 // Open the IO Abstraction(s) needed to perform the supported test.
464 Status
= gBS
->OpenProtocol (
466 &gEfiBlockIoProtocolGuid
,
468 This
->DriverBindingHandle
,
470 EFI_OPEN_PROTOCOL_BY_DRIVER
472 if (EFI_ERROR (Status
)) {
477 // Close the I/O Abstraction(s) used to perform the supported test.
481 &gEfiBlockIoProtocolGuid
,
482 This
->DriverBindingHandle
,
490 Start this driver on ControllerHandle by opening a Block IO protocol and
491 installing a Disk IO protocol on ControllerHandle.
493 @param This Protocol instance pointer.
494 @param ControllerHandle Handle of device to bind driver to
495 @param RemainingDevicePath Optional parameter use to pick a specific child
498 @retval EFI_SUCCESS This driver is added to ControllerHandle
499 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
500 @retval other This driver does not support this device
505 DiskIoDriverBindingStart (
506 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
507 IN EFI_HANDLE ControllerHandle
,
508 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
512 DISK_IO_PRIVATE_DATA
*Private
;
513 DEVICE_STATE
*DeviceState
;
516 CONTROLLER_STATE
*ControllerState
;
519 ControllerState
= NULL
;
522 // Connect to the Block IO interface on ControllerHandle.
524 Status
= gBS
->OpenProtocol (
526 &gEfiBlockIoProtocolGuid
,
527 (VOID
**) &gDiskIoPrivateDataTemplate
.BlockIo
,
528 This
->DriverBindingHandle
,
530 EFI_OPEN_PROTOCOL_BY_DRIVER
532 if (EFI_ERROR (Status
)) {
537 // Initialize the Disk IO device instance.
539 Private
= AllocateCopyPool (sizeof (DISK_IO_PRIVATE_DATA
), &gDiskIoPrivateDataTemplate
);
540 if (Private
== NULL
) {
541 Status
= EFI_OUT_OF_RESOURCES
;
546 // Begin Driver Health Protocol Support
548 DataSize
= sizeof (StartCount
);
549 Status
= gRT
->GetVariable (
556 if (EFI_ERROR (Status
)) {
558 // If the configuration can not be read, then set the default config value of 0
565 DeviceState
= GetDeviceState (mDeviceState
[StartCount
].CurrentState
);
566 ASSERT (DeviceState
!= NULL
);
568 ControllerState
= AllocateZeroPool (sizeof (CONTROLLER_STATE
));
569 if (ControllerState
== NULL
) {
570 return EFI_OUT_OF_RESOURCES
;
573 ControllerState
->ControllerHandle
= ControllerHandle
;
574 ControllerState
->Signature
= DISK_IO_CONTROLLER_STATE_SIGNATURE
;
575 ControllerState
->DeviceStateNum
= DeviceState
->CurrentState
;
576 ControllerState
->ChildHandle
= NULL
;
577 ControllerState
->ControllerIndex
= ControllerIndex
;
579 InsertTailList (&mControllerList
, &ControllerState
->Link
);
581 if (DeviceState
->HealthStatus
!= EfiDriverHealthStatusHealthy
|| DeviceState
->StringId
!= 0) {
586 while (!mDeviceState
[StartCount
].StartState
) {
587 if (mDeviceState
[StartCount
].CurrentState
== 999) {
593 if (mDeviceState
[StartCount
].CurrentState
== 999) {
597 Status
= gRT
->SetVariable (
600 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
604 ASSERT_EFI_ERROR (Status
);
606 if (DeviceState
->HealthStatus
== EfiDriverHealthStatusConfigurationRequired
) {
607 Private
->NVdata
.ConfigGood
= 0;
609 Private
->NVdata
.ConfigGood
= 1;
611 Status
= gRT
->SetVariable (
614 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
615 sizeof (Private
->NVdata
.ConfigGood
),
616 &Private
->NVdata
.ConfigGood
618 ASSERT_EFI_ERROR (Status
);
621 // End Driver Health Protocol Support
625 // Install protocol interfaces for the Disk IO device.
627 Status
= gBS
->InstallProtocolInterface (
629 &gEfiDiskIoProtocolGuid
,
630 EFI_NATIVE_INTERFACE
,
634 Private
->ControllerIndex
= ControllerIndex
;
638 if (EFI_ERROR (Status
)) {
640 if (Private
!= NULL
) {
641 FreeUnicodeStringTable (Private
->ControllerNameTable
);
647 &gEfiBlockIoProtocolGuid
,
648 This
->DriverBindingHandle
,
658 Stop this driver on ControllerHandle by removing Disk IO protocol and closing
659 the Block IO protocol on ControllerHandle.
661 @param This Protocol instance pointer.
662 @param ControllerHandle Handle of device to stop driver on
663 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
664 children is zero stop the entire bus driver.
665 @param ChildHandleBuffer List of Child Handles to Stop.
667 @retval EFI_SUCCESS This driver is removed ControllerHandle
668 @retval other This driver was not removed from this device
673 DiskIoDriverBindingStop (
674 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
675 IN EFI_HANDLE ControllerHandle
,
676 IN UINTN NumberOfChildren
,
677 IN EFI_HANDLE
*ChildHandleBuffer
681 EFI_DISK_IO_PROTOCOL
*DiskIo
;
682 DISK_IO_PRIVATE_DATA
*Private
;
683 DEVICE_STATE
*DeviceState
;
684 CONTROLLER_STATE
*ControllerState
;
687 ControllerState
= NULL
;
691 // Get our context back.
693 Status
= gBS
->OpenProtocol (
695 &gEfiDiskIoProtocolGuid
,
697 This
->DriverBindingHandle
,
699 EFI_OPEN_PROTOCOL_GET_PROTOCOL
701 if (EFI_ERROR (Status
)) {
702 return EFI_UNSUPPORTED
;
705 Private
= DISK_IO_PRIVATE_DATA_FROM_THIS (DiskIo
);
707 Status
= gBS
->UninstallProtocolInterface (
709 &gEfiDiskIoProtocolGuid
,
712 if (!EFI_ERROR (Status
)) {
714 Status
= gBS
->CloseProtocol (
716 &gEfiBlockIoProtocolGuid
,
717 This
->DriverBindingHandle
,
721 // Get the Controller State from global list
723 Link
= GetFirstNode (&mControllerList
);
725 while (!IsNull (&mControllerList
, Link
)) {
726 ControllerState
= DISK_IO_CONTROLLER_STATE_FROM_LINK (Link
);
728 if (ControllerState
->ControllerHandle
== ControllerHandle
) {
729 DeviceState
= GetDeviceState (ControllerState
->DeviceStateNum
);
732 Link
= GetNextNode (&mControllerList
, Link
);
735 ASSERT (DeviceState
!= NULL
);
737 if (DeviceState
->HealthStatus
!= EfiDriverHealthStatusHealthy
|| DeviceState
->StringId
!= 0) {
741 RemoveEntryList (Link
);
743 if (ControllerState
!= NULL
) {
744 FreePool (ControllerState
);
748 if (!EFI_ERROR (Status
)) {
749 FreeUnicodeStringTable (Private
->ControllerNameTable
);
760 Read BufferSize bytes from Offset into Buffer.
761 Reads may support reads that are not aligned on
762 sector boundaries. There are three cases:
763 UnderRun - The first byte is not on a sector boundary or the read request is
764 less than a sector in length.
765 Aligned - A read of N contiguous sectors.
766 OverRun - The last byte is not on a sector boundary.
768 @param This Protocol instance pointer.
769 @param MediaId Id of the media, changes every time the media is replaced.
770 @param Offset The starting byte offset to read from
771 @param BufferSize Size of Buffer
772 @param Buffer Buffer containing read data
774 @retval EFI_SUCCESS The data was read correctly from the device.
775 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
776 @retval EFI_NO_MEDIA There is no media in the device.
777 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
778 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
779 valid for the device.
785 IN EFI_DISK_IO_PROTOCOL
*This
,
793 DISK_IO_PRIVATE_DATA
*Private
;
794 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
795 EFI_BLOCK_IO_MEDIA
*Media
;
801 BOOLEAN TransactionComplete
;
802 UINTN WorkingBufferSize
;
803 UINT8
*WorkingBuffer
;
807 UINTN IsBufferAligned
;
808 UINTN DataBufferSize
;
811 Private
= DISK_IO_PRIVATE_DATA_FROM_THIS (This
);
813 BlockIo
= Private
->BlockIo
;
814 Media
= BlockIo
->Media
;
815 BlockSize
= Media
->BlockSize
;
817 if (Media
->MediaId
!= MediaId
) {
818 return EFI_MEDIA_CHANGED
;
821 WorkingBuffer
= Buffer
;
822 WorkingBufferSize
= BufferSize
;
825 // Allocate a temporary buffer for operation
827 DataBufferSize
= BlockSize
* DATA_BUFFER_BLOCK_NUM
;
829 if (Media
->IoAlign
> 1) {
830 PreData
= AllocatePool (DataBufferSize
+ Media
->IoAlign
);
831 Data
= PreData
- ((UINTN
) PreData
& (Media
->IoAlign
- 1)) + Media
->IoAlign
;
833 PreData
= AllocatePool (DataBufferSize
);
837 if (PreData
== NULL
) {
838 return EFI_OUT_OF_RESOURCES
;
841 Lba
= DivU64x32Remainder (Offset
, BlockSize
, &UnderRun
);
843 Length
= BlockSize
- UnderRun
;
844 TransactionComplete
= FALSE
;
846 Status
= EFI_SUCCESS
;
849 // Offset starts in the middle of an Lba, so read the entire block.
851 Status
= BlockIo
->ReadBlocks (
859 if (EFI_ERROR (Status
)) {
863 if (Length
> BufferSize
) {
865 TransactionComplete
= TRUE
;
868 CopyMem (WorkingBuffer
, Data
+ UnderRun
, Length
);
870 WorkingBuffer
+= Length
;
872 WorkingBufferSize
-= Length
;
873 if (WorkingBufferSize
== 0) {
880 OverRunLba
= Lba
+ DivU64x32Remainder (WorkingBufferSize
, BlockSize
, &OverRun
);
882 if (!TransactionComplete
&& WorkingBufferSize
>= BlockSize
) {
884 // If the DiskIo maps directly to a BlockIo device do the read.
887 WorkingBufferSize
-= OverRun
;
890 // Check buffer alignment
892 IsBufferAligned
= (UINTN
) WorkingBuffer
& (UINTN
) (Media
->IoAlign
- 1);
894 if (Media
->IoAlign
<= 1 || IsBufferAligned
== 0) {
896 // Alignment is satisfied, so read them together
898 Status
= BlockIo
->ReadBlocks (
906 if (EFI_ERROR (Status
)) {
910 WorkingBuffer
+= WorkingBufferSize
;
914 // Use the allocated buffer instead of the original buffer
915 // to avoid alignment issue.
916 // Here, the allocated buffer (8-byte align) can satisfy the alignment
920 if (WorkingBufferSize
<= DataBufferSize
) {
922 // It is the last calling to readblocks in this loop
924 DataBufferSize
= WorkingBufferSize
;
928 Status
= BlockIo
->ReadBlocks (
935 if (EFI_ERROR (Status
)) {
939 CopyMem (WorkingBuffer
, Data
, DataBufferSize
);
940 WorkingBufferSize
-= DataBufferSize
;
941 WorkingBuffer
+= DataBufferSize
;
942 Lba
+= DATA_BUFFER_BLOCK_NUM
;
947 if (!TransactionComplete
&& OverRun
!= 0) {
949 // Last read is not a complete block.
951 Status
= BlockIo
->ReadBlocks (
959 if (EFI_ERROR (Status
)) {
963 CopyMem (WorkingBuffer
, Data
, OverRun
);
967 if (PreData
!= NULL
) {
976 Writes BufferSize bytes from Buffer into Offset.
977 Writes may require a read modify write to support writes that are not
978 aligned on sector boundaries. There are three cases:
979 UnderRun - The first byte is not on a sector boundary or the write request
980 is less than a sector in length. Read modify write is required.
981 Aligned - A write of N contiguous sectors.
982 OverRun - The last byte is not on a sector boundary. Read modified write
985 @param This Protocol instance pointer.
986 @param MediaId Id of the media, changes every time the media is replaced.
987 @param Offset The starting byte offset to read from
988 @param BufferSize Size of Buffer
989 @param Buffer Buffer containing read data
991 @retval EFI_SUCCESS The data was written correctly to the device.
992 @retval EFI_WRITE_PROTECTED The device can not be written to.
993 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
994 @retval EFI_NO_MEDIA There is no media in the device.
995 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
996 @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not
997 valid for the device.
1003 IN EFI_DISK_IO_PROTOCOL
*This
,
1006 IN UINTN BufferSize
,
1011 DISK_IO_PRIVATE_DATA
*Private
;
1012 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
1013 EFI_BLOCK_IO_MEDIA
*Media
;
1019 BOOLEAN TransactionComplete
;
1020 UINTN WorkingBufferSize
;
1021 UINT8
*WorkingBuffer
;
1025 UINTN IsBufferAligned
;
1026 UINTN DataBufferSize
;
1029 Private
= DISK_IO_PRIVATE_DATA_FROM_THIS (This
);
1031 BlockIo
= Private
->BlockIo
;
1032 Media
= BlockIo
->Media
;
1033 BlockSize
= Media
->BlockSize
;
1035 if (Media
->ReadOnly
) {
1036 return EFI_WRITE_PROTECTED
;
1039 if (Media
->MediaId
!= MediaId
) {
1040 return EFI_MEDIA_CHANGED
;
1043 DataBufferSize
= BlockSize
* DATA_BUFFER_BLOCK_NUM
;
1045 if (Media
->IoAlign
> 1) {
1046 PreData
= AllocatePool (DataBufferSize
+ Media
->IoAlign
);
1047 Data
= PreData
- ((UINTN
) PreData
& (Media
->IoAlign
- 1)) + Media
->IoAlign
;
1049 PreData
= AllocatePool (DataBufferSize
);
1053 if (PreData
== NULL
) {
1054 return EFI_OUT_OF_RESOURCES
;
1057 WorkingBuffer
= Buffer
;
1058 WorkingBufferSize
= BufferSize
;
1060 Lba
= DivU64x32Remainder (Offset
, BlockSize
, &UnderRun
);
1062 Length
= BlockSize
- UnderRun
;
1063 TransactionComplete
= FALSE
;
1065 Status
= EFI_SUCCESS
;
1066 if (UnderRun
!= 0) {
1068 // Offset starts in the middle of an Lba, so do read modify write.
1070 Status
= BlockIo
->ReadBlocks (
1078 if (EFI_ERROR (Status
)) {
1082 if (Length
> BufferSize
) {
1083 Length
= BufferSize
;
1084 TransactionComplete
= TRUE
;
1087 CopyMem (Data
+ UnderRun
, WorkingBuffer
, Length
);
1089 Status
= BlockIo
->WriteBlocks (
1096 if (EFI_ERROR (Status
)) {
1100 WorkingBuffer
+= Length
;
1101 WorkingBufferSize
-= Length
;
1102 if (WorkingBufferSize
== 0) {
1109 OverRunLba
= Lba
+ DivU64x32Remainder (WorkingBufferSize
, BlockSize
, &OverRun
);
1111 if (!TransactionComplete
&& WorkingBufferSize
>= BlockSize
) {
1113 // If the DiskIo maps directly to a BlockIo device do the write.
1116 WorkingBufferSize
-= OverRun
;
1119 // Check buffer alignment
1121 IsBufferAligned
= (UINTN
) WorkingBuffer
& (UINTN
) (Media
->IoAlign
- 1);
1123 if (Media
->IoAlign
<= 1 || IsBufferAligned
== 0) {
1125 // Alignment is satisfied, so write them together
1127 Status
= BlockIo
->WriteBlocks (
1135 if (EFI_ERROR (Status
)) {
1139 WorkingBuffer
+= WorkingBufferSize
;
1143 // The buffer parameter is not aligned with the request
1144 // So use the allocated instead.
1145 // It can fit almost all the cases.
1149 if (WorkingBufferSize
<= DataBufferSize
) {
1151 // It is the last calling to writeblocks in this loop
1153 DataBufferSize
= WorkingBufferSize
;
1157 CopyMem (Data
, WorkingBuffer
, DataBufferSize
);
1158 Status
= BlockIo
->WriteBlocks (
1165 if (EFI_ERROR (Status
)) {
1169 WorkingBufferSize
-= DataBufferSize
;
1170 WorkingBuffer
+= DataBufferSize
;
1171 Lba
+= DATA_BUFFER_BLOCK_NUM
;
1172 } while (!LastWrite
);
1176 if (!TransactionComplete
&& OverRun
!= 0) {
1178 // Last bit is not a complete block, so do a read modify write.
1180 Status
= BlockIo
->ReadBlocks (
1188 if (EFI_ERROR (Status
)) {
1192 CopyMem (Data
, WorkingBuffer
, OverRun
);
1194 Status
= BlockIo
->WriteBlocks (
1201 if (EFI_ERROR (Status
)) {
1207 if (PreData
!= NULL
) {
1216 Retrieves the health status of a controller in the platform. This function can also
1217 optionally return warning messages, error messages, and a set of HII Forms that may
1218 be repair a controller that is not proper configured.
1220 @param This A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
1222 @param ControllerHandle The handle of the controller to retrieve the health status
1223 on. This is an optional parameter that may be NULL. If
1224 this parameter is NULL, then the value of ChildHandle is
1225 ignored, and the combined health status of all the devices
1226 that the driver is managing is returned.
1228 @param ChildHandle The handle of the child controller to retrieve the health
1229 status on. This is an optional parameter that may be NULL.
1230 This parameter is ignored of ControllerHandle is NULL. It
1231 will be NULL for device drivers. It will also be NULL for
1232 bus drivers when an attempt is made to collect the health
1233 status of the bus controller. If will not be NULL when an
1234 attempt is made to collect the health status for a child
1235 controller produced by the driver.
1237 @param HealthStatus A pointer to the health status that is returned by this
1238 function. This is an optional parameter that may be NULL.
1239 This parameter is ignored of ControllerHandle is NULL.
1240 The health status for the controller specified by
1241 ControllerHandle and ChildHandle is returned.
1243 @param MessageList A pointer to an array of warning or error messages associated
1244 with the controller specified by ControllerHandle and
1245 ChildHandle. This is an optional parameter that may be NULL.
1246 MessageList is allocated by this function with the EFI Boot
1247 Service AllocatePool(), and it is the caller's responsibility
1248 to free MessageList with the EFI Boot Service FreePool().
1249 Each message is specified by tuple of an EFI_HII_HANDLE and
1250 an EFI_STRING_ID. The array of messages is terminated by tuple
1251 containing a EFI_HII_HANDLE with a value of NULL. The
1252 EFI_HII_STRING_PROTOCOL.GetString() function can be used to
1253 retrieve the warning or error message as a Null-terminated
1254 Unicode string in a specific language. Messages may be
1255 returned for any of the HealthStatus values except
1256 EfiDriverHealthStatusReconnectRequired and
1257 EfiDriverHealthStatusRebootRequired.
1259 @param FormHiiHandle A pointer to the HII handle for an HII form associated with the
1260 controller specified by ControllerHandle and ChildHandle.
1261 This is an optional parameter that may be NULL. An HII form
1262 is specified by a combination of an EFI_HII_HANDLE and an
1263 EFI_GUID that identifies the Form Set GUID. The
1264 EFI_FORM_BROWSER2_PROTOCOL.SendForm() function can be used
1265 to display and allow the user to make configuration changes
1266 to the HII Form. An HII form may only be returned with a
1267 HealthStatus value of EfiDriverHealthStatusConfigurationRequired.
1269 @retval EFI_SUCCESS ControllerHandle is NULL, and all the controllers
1270 managed by this driver specified by This have a health
1271 status of EfiDriverHealthStatusHealthy with no warning
1272 messages to be returned. The ChildHandle, HealthStatus,
1273 MessageList, and FormList parameters are ignored.
1275 @retval EFI_DEVICE_ERROR ControllerHandle is NULL, and one or more of the
1276 controllers managed by this driver specified by This
1277 do not have a health status of EfiDriverHealthStatusHealthy.
1278 The ChildHandle, HealthStatus, MessageList, and
1279 FormList parameters are ignored.
1281 @retval EFI_DEVICE_ERROR ControllerHandle is NULL, and one or more of the
1282 controllers managed by this driver specified by This
1283 have one or more warning and/or error messages.
1284 The ChildHandle, HealthStatus, MessageList, and
1285 FormList parameters are ignored.
1287 @retval EFI_SUCCESS ControllerHandle is not NULL and the health status
1288 of the controller specified by ControllerHandle and
1289 ChildHandle was returned in HealthStatus. A list
1290 of warning and error messages may be optionally
1291 returned in MessageList, and a list of HII Forms
1292 may be optionally returned in FormList.
1294 @retval EFI_UNSUPPORTED ControllerHandle is not NULL, and the controller
1295 specified by ControllerHandle and ChildHandle is not
1296 currently being managed by the driver specified by This.
1298 @retval EFI_INVALID_PARAMETER HealthStatus is NULL.
1300 @retval EFI_OUT_OF_RESOURCES MessageList is not NULL, and there are not enough
1301 resource available to allocate memory for MessageList.
1305 DiskIoDriverHealthGetHealthStatus (
1306 IN EFI_DRIVER_HEALTH_PROTOCOL
*This
,
1307 IN EFI_HANDLE ControllerHandle OPTIONAL
,
1308 IN EFI_HANDLE ChildHandle OPTIONAL
,
1309 OUT EFI_DRIVER_HEALTH_STATUS
*HealthStatus
,
1310 OUT EFI_DRIVER_HEALTH_HII_MESSAGE
**MessageList OPTIONAL
,
1311 OUT EFI_HII_HANDLE
*FormHiiHandle OPTIONAL
1315 EFI_DISK_IO_PROTOCOL
*DiskIo
;
1316 DISK_IO_PRIVATE_DATA
*Private
;
1317 DEVICE_STATE
*DeviceState
;
1318 CONTROLLER_STATE
*ControllerState
;
1322 ControllerState
= NULL
;
1325 if (HealthStatus
== NULL
) {
1326 return EFI_INVALID_PARAMETER
;
1329 if (ControllerHandle
== NULL
) {
1330 *HealthStatus
= EfiDriverHealthStatusHealthy
;
1331 if (mNumNotHealthy
!= 0) {
1332 *HealthStatus
= EfiDriverHealthStatusFailed
;
1338 // This is a device driver, so ChildHandle must be NULL.
1340 if (ChildHandle
!= NULL
) {
1341 return EFI_UNSUPPORTED
;
1344 // Make sure this driver is currently managing ControllerHandle
1346 Status
= EfiTestManagedDevice (
1348 gDiskIoDriverBinding
.DriverBindingHandle
,
1349 &gEfiBlockIoProtocolGuid
1351 if (EFI_ERROR (Status
)) {
1355 if (HealthStatus
== NULL
) {
1356 return EFI_INVALID_PARAMETER
;
1358 Status
= gBS
->HandleProtocol (ControllerHandle
, &gEfiDiskIoProtocolGuid
, (VOID
**) &DiskIo
);
1359 if (EFI_ERROR (Status
)) {
1360 return EFI_UNSUPPORTED
;
1363 if (HealthStatus
== NULL
) {
1364 return EFI_INVALID_PARAMETER
;
1367 Private
= DISK_IO_PRIVATE_DATA_FROM_THIS (DiskIo
);
1371 // Get the Controller State from global list
1373 Link
= GetFirstNode (&mControllerList
);
1375 while (!IsNull (&mControllerList
, Link
)) {
1376 ControllerState
= DISK_IO_CONTROLLER_STATE_FROM_LINK (Link
);
1378 if (ControllerState
->ControllerHandle
== ControllerHandle
) {
1379 DeviceState
= GetDeviceState (ControllerState
->DeviceStateNum
);
1382 Link
= GetNextNode (&mControllerList
, Link
);
1385 ASSERT (DeviceState
!= NULL
);
1387 if (DeviceState
->HealthStatus
== EfiDriverHealthStatusConfigurationRequired
) {
1390 // Read the configuration for this device
1392 BufferSize
= sizeof (Private
->NVdata
.ConfigGood
);
1393 Status
= gRT
->GetVariable (
1398 &Private
->NVdata
.ConfigGood
1400 ASSERT_EFI_ERROR (Status
);
1403 // If the config value is 1, then the configuration is valid and the state machine can move to the next state
1404 // Otherwise, the state machine returns ConfigurationRequired again
1406 if (Private
->NVdata
.ConfigGood
== ControllerState
->ControllerIndex
) {
1407 if (DeviceState
->HealthStatus
!= EfiDriverHealthStatusHealthy
|| DeviceState
->StringId
!= 0) {
1411 ControllerState
->DeviceStateNum
= DeviceState
->NextState
;
1413 DeviceState
= GetDeviceState (ControllerState
->DeviceStateNum
);
1414 ASSERT (DeviceState
!= NULL
);
1416 if (DeviceState
->HealthStatus
!= EfiDriverHealthStatusHealthy
) {
1422 *HealthStatus
= DeviceState
->HealthStatus
;
1424 if (MessageList
!= NULL
) {
1425 *MessageList
= NULL
;
1426 if (DeviceState
->StringId
!= 0) {
1427 *MessageList
= AllocateZeroPool (sizeof(EFI_DRIVER_HEALTH_HII_MESSAGE
) * 2);
1428 if (*MessageList
== NULL
) {
1429 return EFI_UNSUPPORTED
;
1431 (*MessageList
)[0].HiiHandle
= mHiiHandle
;
1432 (*MessageList
)[0].StringId
= DeviceState
->StringId
;
1434 *MessageList
= AllocateZeroPool (sizeof(EFI_DRIVER_HEALTH_HII_MESSAGE
) * 1);
1435 if (*MessageList
== NULL
) {
1436 return EFI_UNSUPPORTED
;
1440 if (FormHiiHandle
!= NULL
) {
1441 *FormHiiHandle
= mHiiHandle
;
1444 if (DeviceState
->HealthStatus
== EfiDriverHealthStatusConfigurationRequired
) {
1445 Private
->NVdata
.ConfigGood
= 0;
1446 Status
= gRT
->SetVariable (
1449 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1450 sizeof (Private
->NVdata
.ConfigGood
),
1451 &Private
->NVdata
.ConfigGood
1453 ASSERT_EFI_ERROR (Status
);
1460 Performs a repair operation on a controller in the platform. This function can
1461 optionally report repair progress information back to the platform.
1463 @param This A pointer to the EFI_DRIVER_HEALTH_PROTOCOL instance.
1464 @param ControllerHandle The handle of the controller to repair.
1465 @param ChildHandle The handle of the child controller to repair. This is
1466 an optional parameter that may be NULL. It will be NULL
1467 for device drivers. It will also be NULL for bus
1468 drivers when an attempt is made to repair a bus controller.
1469 If will not be NULL when an attempt is made to repair a
1470 child controller produced by the driver.
1471 @param RepairNotify A notification function that may be used by a driver to
1472 report the progress of the repair operation. This is
1473 an optional parameter that may be NULL.
1476 @retval EFI_SUCCESS An attempt to repair the controller specified by
1477 ControllerHandle and ChildHandle was performed.
1478 The result of the repair operation can be
1479 determined by calling GetHealthStatus().
1480 @retval EFI_UNSUPPORTED The driver specified by This is not currently
1481 managing the controller specified by ControllerHandle
1483 @retval EFI_OUT_OF_RESOURCES There are not enough resources to perform the
1488 DiskIoDriverHealthRepair (
1489 IN EFI_DRIVER_HEALTH_PROTOCOL
*This
,
1490 IN EFI_HANDLE ControllerHandle
,
1491 IN EFI_HANDLE ChildHandle OPTIONAL
,
1492 IN EFI_DRIVER_HEALTH_REPAIR_PROGRESS_NOTIFY RepairNotify OPTIONAL
1497 DEVICE_STATE
*DeviceState
;
1498 CONTROLLER_STATE
*ControllerState
;
1500 EFI_DISK_IO_PROTOCOL
*DiskIo
;
1501 DISK_IO_PRIVATE_DATA
*Private
;
1504 ControllerState
= NULL
;
1507 // This is a device driver, so ChildHandle must be NULL.
1509 if (ChildHandle
!= NULL
) {
1510 return EFI_UNSUPPORTED
;
1513 // Make sure this driver is currently managing ControllerHandle
1515 Status
= EfiTestManagedDevice (
1517 gDiskIoDriverBinding
.DriverBindingHandle
,
1518 &gEfiBlockIoProtocolGuid
1520 if (EFI_ERROR (Status
)) {
1524 Status
= gBS
->HandleProtocol (ControllerHandle
, &gEfiDiskIoProtocolGuid
, (VOID
**) &DiskIo
);
1525 if (EFI_ERROR (Status
)) {
1526 return EFI_UNSUPPORTED
;
1529 Private
= DISK_IO_PRIVATE_DATA_FROM_THIS (DiskIo
);
1531 Link
= GetFirstNode (&mControllerList
);
1533 while (!IsNull (&mControllerList
, Link
)) {
1534 ControllerState
= DISK_IO_CONTROLLER_STATE_FROM_LINK (Link
);
1536 if (ControllerState
->ControllerHandle
== ControllerHandle
) {
1537 DeviceState
= GetDeviceState (ControllerState
->DeviceStateNum
);
1540 Link
= GetNextNode (&mControllerList
, Link
);
1543 ASSERT (DeviceState
!= NULL
);
1545 // Check to see if the controller has already been repaired
1547 if (DeviceState
->HealthStatus
!= EfiDriverHealthStatusRepairRequired
) {
1551 if (DeviceState
->RepairNotify
) {
1553 RepairNotify(Index
, 10);
1555 } while ((gBS
->Stall(100000) == EFI_SUCCESS
) && (Index
< 10));
1558 if (DeviceState
->HealthStatus
!= EfiDriverHealthStatusHealthy
|| DeviceState
->StringId
!= 0) {
1563 // Repair success, go to next state
1565 ControllerState
->DeviceStateNum
= DeviceState
->NextState
;
1567 DeviceState
= GetDeviceState (ControllerState
->DeviceStateNum
);
1568 ASSERT (DeviceState
!= NULL
);
1570 if (DeviceState
->HealthStatus
!= EfiDriverHealthStatusHealthy
|| DeviceState
->StringId
!= 0) {
1574 if (DeviceState
->HealthStatus
== EfiDriverHealthStatusConfigurationRequired
) {
1575 Private
->NVdata
.ConfigGood
= 0;
1576 Status
= gRT
->SetVariable (
1579 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1580 sizeof (Private
->NVdata
.ConfigGood
),
1581 &Private
->NVdata
.ConfigGood
1583 ASSERT_EFI_ERROR (Status
);
1590 The user Entry Point for module DiskIo. The user code starts with this function.
1592 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1593 @param[in] SystemTable A pointer to the EFI System Table.
1595 @retval EFI_SUCCESS The entry point is executed successfully.
1596 @retval other Some error occurs when executing this entry point.
1602 IN EFI_HANDLE ImageHandle
,
1603 IN EFI_SYSTEM_TABLE
*SystemTable
1608 // Install driver model protocol(s).
1610 Status
= EfiLibInstallDriverBindingComponentName2 (
1613 &gDiskIoDriverBinding
,
1615 &gDiskIoComponentName
,
1616 &gDiskIoComponentName2
1619 ASSERT_EFI_ERROR (Status
);
1621 Status
= gBS
->InstallProtocolInterface (
1623 &gEfiDriverHealthProtocolGuid
,
1624 EFI_NATIVE_INTERFACE
,
1625 &gDiskIoDriverHealth
1627 ASSERT_EFI_ERROR (Status
);
1629 InitializeListHead (&mControllerList
);
1631 gDiskIoPrivateDataTemplate
.Handle
= ImageHandle
;
1632 Status
= DiskIoConfigFormInit ();
1634 ASSERT_EFI_ERROR (Status
);
1640 Initialize the serial configuration form.
1642 @retval EFI_SUCCESS The serial configuration form is initialized.
1643 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
1644 @retval Others Other errors as indicated.
1647 DiskIoConfigFormInit (
1654 // Locate Hii Database protocol
1656 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**)&gDiskIoPrivateDataTemplate
.HiiDatabase
);
1657 if (EFI_ERROR (Status
)) {
1661 Status
= gBS
->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid
, NULL
, (VOID
**)&gDiskIoPrivateDataTemplate
.HiiConfigRouting
);
1662 if (EFI_ERROR (Status
)) {
1667 // Install Device Path Protocol and Config Access protocol to driver handle
1669 Status
= gBS
->InstallMultipleProtocolInterfaces (
1670 &gDiskIoPrivateDataTemplate
.Handle
,
1671 &gEfiDevicePathProtocolGuid
, &mHiiVendorDevicePathDiskIoDummy
,
1672 &gEfiHiiConfigAccessProtocolGuid
, &gDiskIoPrivateDataTemplate
.ConfigAccess
,
1675 if (EFI_ERROR (Status
)) {
1680 // Publish our HII data
1682 mHiiHandle
= HiiAddPackages (
1684 gDiskIoPrivateDataTemplate
.Handle
,
1685 DriverHealthDxeStrings
,
1689 if (mHiiHandle
== NULL
) {
1690 return EFI_OUT_OF_RESOURCES
;
1696 This function processes the results of changes in configuration.
1698 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1699 @param Action Specifies the type of action taken by the browser.
1700 @param QuestionId A unique value which is sent to the original
1701 exporting driver so that it can identify the type
1703 @param Type The type of value for the question.
1704 @param Value A pointer to the data being sent to the original
1706 @param ActionRequest On return, points to the action requested by the
1709 @retval EFI_SUCCESS The callback successfully handled the action.
1710 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
1711 variable and its data.
1712 @retval EFI_DEVICE_ERROR The variable could not be saved.
1713 @retval EFI_UNSUPPORTED The specified Action is not supported by the
1719 DummyDriverCallback (
1720 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1721 IN EFI_BROWSER_ACTION Action
,
1722 IN EFI_QUESTION_ID QuestionId
,
1724 IN EFI_IFR_TYPE_VALUE
*Value
,
1725 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1729 DISK_IO_NV_DATA
*IfrNvData
;
1732 // Retrieve uncommitted data from Browser
1735 IfrNvData
= AllocateZeroPool (sizeof (DISK_IO_NV_DATA
));
1736 ASSERT (IfrNvData
!= NULL
);
1738 if (!HiiGetBrowserData (&gEfiCallerIdGuid
, VariableName
, sizeof (DISK_IO_NV_DATA
), (UINT8
*) IfrNvData
)) {
1739 FreePool (IfrNvData
);
1740 return EFI_NOT_FOUND
;
1743 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
1744 return EFI_INVALID_PARAMETER
;
1747 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
1754 This function allows a caller to extract the current configuration for one
1755 or more named elements from the target driver.
1757 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1758 @param Request A null-terminated Unicode string in
1759 <ConfigRequest> format.
1760 @param Progress On return, points to a character in the Request
1761 string. Points to the string's null terminator if
1762 request was successful. Points to the most recent
1763 '&' before the first failing name/value pair (or
1764 the beginning of the string if the failure is in
1765 the first name/value pair) if the request was not
1767 @param Results A null-terminated Unicode string in
1768 <ConfigAltResp> format which has all values filled
1769 in for the names in the Request string. String to
1770 be allocated by the called function.
1772 @retval EFI_SUCCESS The Results is filled with the requested values.
1773 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
1774 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
1775 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
1781 DummyExtractConfig (
1782 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1783 IN CONST EFI_STRING Request
,
1784 OUT EFI_STRING
*Progress
,
1785 OUT EFI_STRING
*Results
1790 DISK_IO_PRIVATE_DATA
*PrivateData
;
1791 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
1792 EFI_STRING ConfigRequest
;
1793 EFI_STRING ConfigRequestHdr
;
1796 if (Progress
== NULL
|| Results
== NULL
|| Request
== NULL
) {
1797 return EFI_INVALID_PARAMETER
;
1800 // Initialize the local variables.
1802 ConfigRequestHdr
= NULL
;
1803 ConfigRequest
= NULL
;
1805 *Progress
= Request
;
1807 PrivateData
= DISK_IO_PRIVATE_DATA_FROM_CONFIG_ACCESS(This
);
1808 HiiConfigRouting
= PrivateData
->HiiConfigRouting
;
1811 // Get Buffer Storage data from EFI variable.
1812 // Try to get the current setting from variable.
1814 BufferSize
= sizeof (DISK_IO_NV_DATA
);
1815 Status
= gRT
->GetVariable (
1820 &PrivateData
->NVdata
1822 if (EFI_ERROR (Status
)) {
1823 return EFI_NOT_FOUND
;
1826 if (Request
== NULL
) {
1828 // Request is set to NULL, construct full request string.
1832 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
1833 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
1835 ConfigRequestHdr
= HiiConstructConfigHdr (&gEfiCallerIdGuid
, VariableName
, PrivateData
->Handle
);
1836 Size
= (StrLen (ConfigRequest
) + 32 + 1) * sizeof (CHAR16
);
1837 ConfigRequest
= AllocateZeroPool (Size
);
1838 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr
, (UINT64
)BufferSize
);
1839 FreePool (ConfigRequestHdr
);
1842 // Check routing data in <ConfigHdr>.
1843 // Note: if only one Storage is used, then this checking could be skipped.
1845 if (!HiiIsConfigHdrMatch (Request
, &gEfiCallerIdGuid
, VariableName
)) {
1846 return EFI_NOT_FOUND
;
1848 ConfigRequest
= Request
;
1852 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
1854 Status
= HiiConfigRouting
->BlockToConfig (
1857 (UINT8
*) &PrivateData
->NVdata
,
1863 if (Request
== NULL
) {
1864 FreePool (ConfigRequest
);
1872 This function processes the results of changes in configuration.
1874 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1875 @param Configuration A null-terminated Unicode string in <ConfigResp>
1877 @param Progress A pointer to a string filled in with the offset of
1878 the most recent '&' before the first failing
1879 name/value pair (or the beginning of the string if
1880 the failure is in the first name/value pair) or
1881 the terminating NULL if all was successful.
1883 @retval EFI_SUCCESS The Results is processed successfully.
1884 @retval EFI_INVALID_PARAMETER Configuration is NULL.
1885 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
1892 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1893 IN CONST EFI_STRING Configuration
,
1894 OUT EFI_STRING
*Progress
1899 DISK_IO_PRIVATE_DATA
*PrivateData
;
1900 EFI_HII_CONFIG_ROUTING_PROTOCOL
*HiiConfigRouting
;
1902 if (Configuration
== NULL
|| Progress
== NULL
) {
1903 return EFI_INVALID_PARAMETER
;
1907 PrivateData
= DISK_IO_PRIVATE_DATA_FROM_CONFIG_ACCESS (This
);
1908 HiiConfigRouting
= PrivateData
->HiiConfigRouting
;
1909 *Progress
= Configuration
;
1912 // Check routing data in <ConfigHdr>.
1913 // Note: if only one Storage is used, then this checking could be skipped.
1915 if (!HiiIsConfigHdrMatch (Configuration
, &gEfiCallerIdGuid
, VariableName
)) {
1916 return EFI_NOT_FOUND
;
1920 // Get Buffer Storage data from EFI variable
1922 BufferSize
= sizeof (DISK_IO_NV_DATA
);
1923 Status
= gRT
->GetVariable (
1928 &PrivateData
->NVdata
1930 if (EFI_ERROR (Status
)) {
1935 // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()
1937 BufferSize
= sizeof (DISK_IO_NV_DATA
);
1938 Status
= HiiConfigRouting
->ConfigToBlock (
1941 (UINT8
*) &PrivateData
->NVdata
,
1945 if (EFI_ERROR (Status
)) {
1950 // Store Buffer Storage back to EFI variable
1952 Status
= gRT
->SetVariable(
1955 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1956 sizeof (DISK_IO_NV_DATA
),
1957 &PrivateData
->NVdata