InOsEmuPkg: Add support for mounting CD-ROM images.

Devices get the block size via ioctl, but for a file the block size needs to be set. Default to 512, but optionally allow other values, like 2048/0x800 for ISO CD-ROM images. Also updated the comments in .DSC and .DEC files.

Signed-off-by: andrewfish



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11843 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish
2011-06-17 16:18:14 +00:00
parent 323940278e
commit 5dcda296a4
3 changed files with 29 additions and 20 deletions

View File

@@ -29,6 +29,7 @@ typedef struct {
BOOLEAN WriteProtected;
UINT64 NumberOfBlocks;
UINT32 BlockSize;
EMU_BLOCK_IO_PROTOCOL EmuBlockIo;
EFI_BLOCK_IO_MEDIA *Media;
@@ -157,14 +158,14 @@ EmuBlockIoOpenDevice (
}
#endif
} else if (fstatfs (Private->fd, &buf) == 0) {
//
// Works for files, not devices
//
Private->Media->BlockSize = buf.f_bsize;
Private->Media->OptimalTransferLengthGranularity = buf.f_iosize/buf.f_bsize;
} else {
Private->Media->BlockSize = Private->BlockSize;
Private->NumberOfBlocks = DivU64x32 (FileSize, Private->Media->BlockSize);
Private->Media->LastBlock = Private->NumberOfBlocks - 1;
if (fstatfs (Private->fd, &buf) == 0) {
Private->Media->OptimalTransferLengthGranularity = buf.f_iosize/buf.f_bsize;
}
}
DEBUG ((EFI_D_INIT, "%HEmuOpenBlock: opened %a%N\n", Private->Filename));
@@ -627,7 +628,8 @@ EmuBlockIoThunkOpen (
Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE;
Private->Thunk = This;
CopyMem (&Private->EmuBlockIo, &gEmuBlockIoProtocol, sizeof (gEmuBlockIoProtocol));
Private->fd = -1;
Private->fd = -1;
Private->BlockSize = 512;
Private->Filename = StdDupUnicodeToAscii (This->ConfigString);
if (Private->Filename == NULL) {
@@ -646,6 +648,10 @@ EmuBlockIoThunkOpen (
if (*Str == 'O' || *Str == 'W') {
Private->WriteProtected = (BOOLEAN) (*Str == 'O');
}
if (*Str == ':') {
Private->BlockSize = strtol (++Str, NULL, 0);
break;
}
}
}