summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-17 16:18:14 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-17 16:18:14 +0000
commit5dcda296a4af4cee45a90c9048f66e96a95928f2 (patch)
tree49c3cc7fd5a32d51dd8e2c7c69a0c2844d4d778d
parent323940278e0c94d18b3824764236162e2b0dcfcf (diff)
downloadedk2-platforms-5dcda296a4af4cee45a90c9048f66e96a95928f2.tar.xz
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
-rw-r--r--InOsEmuPkg/InOsEmuPkg.dec13
-rw-r--r--InOsEmuPkg/Unix/Sec/BlockIo.c20
-rw-r--r--InOsEmuPkg/Unix/UnixX64.dsc16
3 files changed, 29 insertions, 20 deletions
diff --git a/InOsEmuPkg/InOsEmuPkg.dec b/InOsEmuPkg/InOsEmuPkg.dec
index 33510406cc..a2cce7888b 100644
--- a/InOsEmuPkg/InOsEmuPkg.dec
+++ b/InOsEmuPkg/InOsEmuPkg.dec
@@ -48,10 +48,6 @@
gEmuVirtualDisksGuid = { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
gEmuPhysicalDisksGuid = { 0xf2bdcc96, 0x8985, 0x11db, { 0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
-# gEmuFileSystemGuid = {0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}
-# gEmuSerialPortGuid = {0x6d3a727d, 0x66c8, 0x4d19, {0x87, 0xe6, 0x02, 0x15, 0x86, 0x14, 0x90, 0xf3}}
-# gEmuNetworkGuid = {0x081603B4, 0x0F1D, 0x4022, {0xB6, 0xFD, 0x4C, 0xE3, 0x5E, 0x09, 0xA1, 0xA6}}
-
[PcdsFixedAtBuild]
gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|0x0|UINT64|0x00001014
gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|0x0|UINT64|0x00001015
@@ -82,14 +78,17 @@
gInOsEmuPkgTokenSpaceGuid.PcdEmuMemorySize|L"64!64"|VOID*|0x0000100c
#
- # filename[:][R|F][O|W]
+ # filename[:[R|F][O|W]][:BlockSize]
# filename can be a device node, like /dev/disk1
# R - Removable Media F - Fixed Media
# O - Write protected W - Writable
# Default is Fixed Media, Writable
- # Size comes from file or device.
+ # For a file the default BlockSize is 512, and can be overridden via BlockSize,
+ # for example 2048 for an ISO CD image. The block size for a device comes from
+ # the device and is not configurable.
+ # Device Size comes from file or device.
# On Mac OS X you can use Disk Utility to create .dmg files and mount then like disks
- gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"FW;40960;512"|VOID*|0x00001001
+ gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"|VOID*|0x00001001
gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"|VOID*|0x00001018
gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../../EdkShellBinPkg/bin/ia32/Apps"|VOID*|0x00001004
diff --git a/InOsEmuPkg/Unix/Sec/BlockIo.c b/InOsEmuPkg/Unix/Sec/BlockIo.c
index 8b760cc41a..57bfdfa78a 100644
--- a/InOsEmuPkg/Unix/Sec/BlockIo.c
+++ b/InOsEmuPkg/Unix/Sec/BlockIo.c
@@ -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;
+ }
}
}
diff --git a/InOsEmuPkg/Unix/UnixX64.dsc b/InOsEmuPkg/Unix/UnixX64.dsc
index 10bb0cf2f6..a601c0cbce 100644
--- a/InOsEmuPkg/Unix/UnixX64.dsc
+++ b/InOsEmuPkg/Unix/UnixX64.dsc
@@ -1,6 +1,6 @@
## @file
#
-# EFI/Framework Emulation Platform with UEFI HII interface supported.
+# UEFI/PI Emulation Platform with UEFI HII interface supported.
#
# The Emulation Platform can be used to debug individual modules, prior to creating
# a real platform. This also provides an example for how an DSC is created.
@@ -216,6 +216,7 @@
gInOsEmuPkgTokenSpaceGuid.PcdEmuApCount|L"1"
+ # For a CD-ROM/DVD use L"diag.dmg:RO:2048"
gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"
gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"
gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../EdkShellBinPkg/Bin"
@@ -266,7 +267,7 @@
[Components]
!if $(SEC_ONLY)
##
- # SEC Phase modules
+ # Emulator, OS POSIX application
##
InOsEmuPkg/Unix/Sec/SecMain.inf
!else
@@ -349,10 +350,10 @@
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
- # {
- # <LibraryClasses>
- # NULL|InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
- # }
+ #{
+ # <LibraryClasses>
+ # NULL|InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
+ #}
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
@@ -413,6 +414,9 @@
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+# SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf
+# SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf
+
<PcdsFixedAtBuild>
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE