+static VOID UninitVolumes(VOID)
+{
+ REFIT_VOLUME *Volume;
+ UINTN VolumeIndex;
+
+ for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
+ Volume = Volumes[VolumeIndex];
+
+ if (Volume->RootDir != NULL) {
+ refit_call1_wrapper(Volume->RootDir->Close, Volume->RootDir);
+ Volume->RootDir = NULL;
+ }
+
+ Volume->DeviceHandle = NULL;
+ Volume->BlockIO = NULL;
+ Volume->WholeDiskBlockIO = NULL;
+ }
+} /* VOID UninitVolumes() */
+
+VOID ReinitVolumes(VOID)
+{
+ EFI_STATUS Status;
+ REFIT_VOLUME *Volume;
+ UINTN VolumeIndex;
+ EFI_DEVICE_PATH *RemainingDevicePath;
+ EFI_HANDLE DeviceHandle, WholeDiskHandle;
+
+ for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) {
+ Volume = Volumes[VolumeIndex];
+
+ if (Volume->DevicePath != NULL) {
+ // get the handle for that path
+ RemainingDevicePath = Volume->DevicePath;
+ Status = refit_call3_wrapper(BS->LocateDevicePath, &BlockIoProtocol, &RemainingDevicePath, &DeviceHandle);
+
+ if (!EFI_ERROR(Status)) {
+ Volume->DeviceHandle = DeviceHandle;
+
+ // get the root directory
+ Volume->RootDir = LibOpenRoot(Volume->DeviceHandle);
+
+ } else
+ CheckError(Status, L"from LocateDevicePath");
+ }
+
+ if (Volume->WholeDiskDevicePath != NULL) {
+ // get the handle for that path
+ RemainingDevicePath = Volume->WholeDiskDevicePath;
+ Status = refit_call3_wrapper(BS->LocateDevicePath, &BlockIoProtocol, &RemainingDevicePath, &WholeDiskHandle);
+
+ if (!EFI_ERROR(Status)) {
+ // get the BlockIO protocol
+ Status = refit_call3_wrapper(BS->HandleProtocol, WholeDiskHandle, &BlockIoProtocol,
+ (VOID **) &Volume->WholeDiskBlockIO);
+ if (EFI_ERROR(Status)) {
+ Volume->WholeDiskBlockIO = NULL;
+ CheckError(Status, L"from HandleProtocol");
+ }
+ } else
+ CheckError(Status, L"from LocateDevicePath");
+ }
+ }
+} /* VOID ReinitVolumes(VOID) */
+