mirror of https://github.com/acidanthera/audk.git
Remove probe for removable media from FileLib, it was getting called way too much. Now it is in the EBL shell device command. Cleanup some spacing issues in the lib code.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10454 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
2a9fe5409d
commit
f6381f4c3d
|
@ -51,6 +51,7 @@
|
||||||
#include <Library/DevicePathLib.h>
|
#include <Library/DevicePathLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
#include <Library/EblNetworkLib.h>
|
#include <Library/EblNetworkLib.h>
|
||||||
|
#include <Library/TimerLib.h>
|
||||||
|
|
||||||
#include <IndustryStandard/Pci.h>
|
#include <IndustryStandard/Pci.h>
|
||||||
|
|
||||||
|
|
|
@ -210,12 +210,34 @@ EblDeviceCmd (
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINTN CurrentRow;
|
UINTN CurrentRow;
|
||||||
UINTN Max;
|
UINTN Max;
|
||||||
|
EFI_OPEN_FILE *File;
|
||||||
|
|
||||||
CurrentRow = 0;
|
CurrentRow = 0;
|
||||||
|
|
||||||
// Need to call here to make sure Device Counts are valid
|
// Need to call here to make sure Device Counts are valid
|
||||||
EblUpdateDeviceLists ();
|
EblUpdateDeviceLists ();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Probe for media insertion/removal in removable media devices
|
||||||
|
//
|
||||||
|
Max = EfiGetDeviceCounts (EfiOpenBlockIo);
|
||||||
|
if (Max != 0) {
|
||||||
|
for (Index = 0; Index < Max; Index++) {
|
||||||
|
File = EfiDeviceOpenByType (EfiOpenBlockIo, Index);
|
||||||
|
if (File != NULL) {
|
||||||
|
if (File->FsBlockIoMedia->RemovableMedia) {
|
||||||
|
if (File->FsBlockIoMedia->MediaPresent) {
|
||||||
|
gBS->DisconnectController (File->EfiHandle, NULL, NULL);
|
||||||
|
}
|
||||||
|
gBS->ConnectController (File->EfiHandle, NULL, NULL, TRUE);
|
||||||
|
}
|
||||||
|
EfiClose (File);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we can print out the info...
|
||||||
|
|
||||||
Max = EfiGetDeviceCounts (EfiOpenFirmwareVolume);
|
Max = EfiGetDeviceCounts (EfiOpenFirmwareVolume);
|
||||||
if (Max != 0) {
|
if (Max != 0) {
|
||||||
AsciiPrint ("Firmware Volume Devices:\n");
|
AsciiPrint ("Firmware Volume Devices:\n");
|
||||||
|
@ -759,13 +781,13 @@ EblFileCopyCmd (
|
||||||
|
|
||||||
Status = EfiRead(Source, Buffer, &Chunk);
|
Status = EfiRead(Source, Buffer, &Chunk);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
AsciiPrint("Read file error\n");
|
AsciiPrint("Read file error %r\n", Status);
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EfiWrite(Destination, Buffer, &Chunk);
|
Status = EfiWrite(Destination, Buffer, &Chunk);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
AsciiPrint("Write file error\n");
|
AsciiPrint("Write file error %r\n", Status);
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -776,17 +798,18 @@ EblFileCopyCmd (
|
||||||
|
|
||||||
Status = EfiRead(Source, Buffer, &Chunk);
|
Status = EfiRead(Source, Buffer, &Chunk);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
AsciiPrint("Read file error\n");
|
AsciiPrint("Read file error %r\n", Status);
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EfiWrite(Destination, Buffer, &Chunk);
|
Status = EfiWrite(Destination, Buffer, &Chunk);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
AsciiPrint("Write file error\n");
|
AsciiPrint("Write file error %r\n", Status);
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
if (Source != NULL) {
|
if (Source != NULL) {
|
||||||
Status = EfiClose(Source);
|
Status = EfiClose(Source);
|
||||||
|
@ -794,7 +817,6 @@ Exit:
|
||||||
AsciiPrint("Source close error %r\n", Status);
|
AsciiPrint("Source close error %r\n", Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Destination != NULL) {
|
if (Destination != NULL) {
|
||||||
Status = EfiClose(Destination);
|
Status = EfiClose(Destination);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
|
|
|
@ -143,39 +143,14 @@ EblUpdateDeviceLists (
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
|
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
|
||||||
EFI_BLOCK_IO_PROTOCOL *BlkIo;
|
|
||||||
EFI_FILE_HANDLE Root;
|
EFI_FILE_HANDLE Root;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
BOOLEAN Update;
|
|
||||||
|
|
||||||
if (mBlkIo != NULL) {
|
if (mBlkIo != NULL) {
|
||||||
FreePool (mBlkIo);
|
FreePool (mBlkIo);
|
||||||
}
|
}
|
||||||
gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &mBlkIoCount, &mBlkIo);
|
gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &mBlkIoCount, &mBlkIo);
|
||||||
|
|
||||||
//
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (mFv != NULL) {
|
if (mFv != NULL) {
|
||||||
|
@ -976,13 +951,13 @@ EfiCopyFile (
|
||||||
|
|
||||||
Status = EfiRead(Source, Buffer, &Chunk);
|
Status = EfiRead(Source, Buffer, &Chunk);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
AsciiPrint("Read file error\n");
|
AsciiPrint("Read file error %r\n", Status);
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EfiWrite(Destination, Buffer, &Chunk);
|
Status = EfiWrite(Destination, Buffer, &Chunk);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
AsciiPrint("Write file error\n");
|
AsciiPrint("Write file error %r\n", Status);
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue