| 1247 | } |
| 1248 | |
| 1249 | VOID ReinitVolumes(VOID) |
| 1250 | { |
| 1251 | EFI_STATUS Status; |
| 1252 | REFIT_VOLUME *Volume; |
| 1253 | UINTN VolumeIndex; |
| 1254 | UINTN VolumesFound = 0; |
| 1255 | EFI_DEVICE_PATH *RemainingDevicePath; |
| 1256 | EFI_HANDLE DeviceHandle, WholeDiskHandle; |
| 1257 | |
| 1258 | for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) { |
| 1259 | Volume = &Volumes[VolumeIndex]; |
| 1260 | if (!Volume) { |
| 1261 | continue; |
| 1262 | } |
| 1263 | DBG("Volume %llu at reinit found:\n", VolumeIndex); |
| 1264 | DBG("Volume->DevicePath=%ls\n", FileDevicePathToXStringW(Volume->DevicePath).wc_str()); |
| 1265 | VolumesFound++; |
| 1266 | if (Volume->DevicePath != NULL) { |
| 1267 | // get the handle for that path |
| 1268 | RemainingDevicePath = Volume->DevicePath; |
| 1269 | Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &RemainingDevicePath, &DeviceHandle); |
| 1270 | |
| 1271 | if (!EFI_ERROR(Status)) { |
| 1272 | Volume->DeviceHandle = DeviceHandle; |
| 1273 | |
| 1274 | // get the root directory |
| 1275 | Volume->RootDir = EfiLibOpenRoot(Volume->DeviceHandle); |
| 1276 | |
| 1277 | } |
| 1278 | //else |
| 1279 | // CheckError(Status, L"from LocateDevicePath"); |
| 1280 | } |
| 1281 | |
| 1282 | if (Volume->WholeDiskDevicePath != NULL) { |
| 1283 | // get the handle for that path |
| 1284 | RemainingDevicePath = DuplicateDevicePath(Volume->WholeDiskDevicePath); |
| 1285 | Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &RemainingDevicePath, &WholeDiskHandle); |
| 1286 | |
| 1287 | if (!EFI_ERROR(Status)) { |
| 1288 | Volume->WholeDiskBlockIO = (__typeof__(Volume->WholeDiskBlockIO))WholeDiskHandle; |
| 1289 | // get the BlockIO protocol |
| 1290 | Status = gBS->HandleProtocol(WholeDiskHandle, &gEfiBlockIoProtocolGuid, (VOID **) &Volume->WholeDiskBlockIO); |
| 1291 | if (EFI_ERROR(Status)) { |
| 1292 | Volume->WholeDiskBlockIO = NULL; |
| 1293 | CheckError(Status, L"from HandleProtocol"); |
| 1294 | } |
| 1295 | } |
| 1296 | //else |
| 1297 | // CheckError(Status, L"from LocateDevicePath"); |
| 1298 | } |
| 1299 | } |
| 1300 | // Jief : I'm not sure to understand the next line. Why would we change the count when we didn't change the array. |
| 1301 | // This code is not currently not used. |
| 1302 | // Beware if you want to reuse this. |
| 1303 | // VolumesCount = VolumesFound; |
| 1304 | } |
| 1305 | |
| 1306 | REFIT_VOLUME *FindVolumeByName(IN CONST CHAR16 *VolName) |
no test coverage detected