- //
- // This is a trick to trigger the gBS->ReinstallProtocolInterface () in a removable media
- // device to make a filesystem layer on. Probing devices will detect if media has been
- // inserted and create
- //
- for (Index =0, Update = FALSE; Index < mBlkIoCount; Index++) {
- Status = gBS->HandleProtocol (mBlkIo[Index], &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo);
- if (!EFI_ERROR (Status)) {
- if (BlkIo->Media->RemovableMedia) {
- gBS->DisconnectController (mBlkIo[Index], NULL, NULL);
- gBS->ConnectController (mBlkIo[Index], NULL, NULL, TRUE);
- Update = TRUE;
- }
- }
- }
-
- if (Update) {
- // In case we caused media to be detected that contains a partition (SD Card, ...) rescan
- if (mBlkIo != NULL) {
- FreePool (mBlkIo);
- }
- gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &mBlkIoCount, &mBlkIo);
- }