mirror of https://github.com/acidanthera/audk.git
Update FileLib to use pointer to BlockIo->Media and not a cached copy also add some code in the library init that allows removable media devices to be probed to see if a media change has happened.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10449 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
24542fb211
commit
0a0951ea84
|
@ -111,24 +111,24 @@ EblPrintBlkIoInfo (
|
||||||
EfiClose (FsFile);
|
EfiClose (FsFile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
EfiClose (FsFile);
|
EfiClose (FsFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Print out useful Block IO media properties
|
// Print out useful Block IO media properties
|
||||||
if (File->FsBlockIoMedia.RemovableMedia) {
|
if (File->FsBlockIoMedia->RemovableMedia) {
|
||||||
AsciiPrint ("Removable ");
|
AsciiPrint ("Removable ");
|
||||||
}
|
}
|
||||||
if (!File->FsBlockIoMedia.MediaPresent) {
|
if (!File->FsBlockIoMedia->MediaPresent) {
|
||||||
AsciiPrint ("No Media ");
|
AsciiPrint ("No Media\n");
|
||||||
}
|
} else {
|
||||||
if (File->FsBlockIoMedia.LogicalPartition) {
|
if (File->FsBlockIoMedia->LogicalPartition) {
|
||||||
AsciiPrint ("Partition ");
|
AsciiPrint ("Partition ");
|
||||||
}
|
}
|
||||||
DeviceSize = MultU64x32 (File->FsBlockIoMedia.LastBlock + 1, File->FsBlockIoMedia.BlockSize);
|
DeviceSize = MultU64x32 (File->FsBlockIoMedia->LastBlock + 1, File->FsBlockIoMedia->BlockSize);
|
||||||
AsciiPrint ("Size = 0x%lX\n", DeviceSize);
|
AsciiPrint ("Size = 0x%lX\n", DeviceSize);
|
||||||
|
}
|
||||||
EfiClose (File);
|
EfiClose (File);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ typedef struct {
|
||||||
EFI_FILE *FsFileHandle; // Information valid for Fs#:
|
EFI_FILE *FsFileHandle; // Information valid for Fs#:
|
||||||
EFI_FILE_SYSTEM_INFO *FsInfo;
|
EFI_FILE_SYSTEM_INFO *FsInfo;
|
||||||
EFI_FILE_INFO *FsFileInfo;
|
EFI_FILE_INFO *FsFileInfo;
|
||||||
EFI_BLOCK_IO_MEDIA FsBlockIoMedia; // Information valid for Fs#: or B#:
|
EFI_BLOCK_IO_MEDIA *FsBlockIoMedia; // Information valid for Fs#: or B#:
|
||||||
|
|
||||||
UINTN DiskOffset; // Information valid for B#:
|
UINTN DiskOffset; // Information valid for B#:
|
||||||
|
|
||||||
|
|
|
@ -143,14 +143,41 @@ 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) {
|
||||||
FreePool (mFv);
|
FreePool (mFv);
|
||||||
}
|
}
|
||||||
|
@ -406,7 +433,7 @@ EblFileDevicePath (
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (File->EfiHandle, &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo);
|
Status = gBS->HandleProtocol (File->EfiHandle, &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CopyMem (&File->FsBlockIoMedia, BlkIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));
|
File->FsBlockIoMedia = BlkIo->Media;
|
||||||
|
|
||||||
// If we are not opening the device this will get over written with file info
|
// If we are not opening the device this will get over written with file info
|
||||||
File->MaxPosition = MultU64x32 (BlkIo->Media->LastBlock + 1, BlkIo->Media->BlockSize);
|
File->MaxPosition = MultU64x32 (BlkIo->Media->LastBlock + 1, BlkIo->Media->BlockSize);
|
||||||
|
@ -1395,7 +1422,7 @@ EfiRead (
|
||||||
case EfiOpenBlockIo:
|
case EfiOpenBlockIo:
|
||||||
Status = gBS->HandleProtocol(File->EfiHandle, &gEfiDiskIoProtocolGuid, (VOID **)&DiskIo);
|
Status = gBS->HandleProtocol(File->EfiHandle, &gEfiDiskIoProtocolGuid, (VOID **)&DiskIo);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
Status = DiskIo->ReadDisk(DiskIo, File->FsBlockIoMedia.MediaId, File->DiskOffset + File->CurrentPosition, *BufferSize, Buffer);
|
Status = DiskIo->ReadDisk(DiskIo, File->FsBlockIoMedia->MediaId, File->DiskOffset + File->CurrentPosition, *BufferSize, Buffer);
|
||||||
}
|
}
|
||||||
File->CurrentPosition += *BufferSize;
|
File->CurrentPosition += *BufferSize;
|
||||||
break;
|
break;
|
||||||
|
@ -1537,7 +1564,7 @@ EfiWrite (
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (File->EfiHandle, &gEfiDiskIoProtocolGuid, (VOID **)&DiskIo);
|
Status = gBS->HandleProtocol (File->EfiHandle, &gEfiDiskIoProtocolGuid, (VOID **)&DiskIo);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
Status = DiskIo->WriteDisk (DiskIo, File->FsBlockIoMedia.MediaId, File->DiskOffset + File->CurrentPosition, *BufferSize, Buffer);
|
Status = DiskIo->WriteDisk (DiskIo, File->FsBlockIoMedia->MediaId, File->DiskOffset + File->CurrentPosition, *BufferSize, Buffer);
|
||||||
}
|
}
|
||||||
File->CurrentPosition += *BufferSize;
|
File->CurrentPosition += *BufferSize;
|
||||||
break;
|
break;
|
||||||
|
@ -1608,7 +1635,7 @@ ExpandPath (
|
||||||
CHAR8 *NewPath;
|
CHAR8 *NewPath;
|
||||||
CHAR8 *Work, *Start, *End;
|
CHAR8 *Work, *Start, *End;
|
||||||
UINTN StrLen;
|
UINTN StrLen;
|
||||||
UINTN i;
|
INTN i;
|
||||||
|
|
||||||
if (Cwd == NULL || Path == NULL) {
|
if (Cwd == NULL || Path == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue