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

@ -48,10 +48,6 @@
gEmuVirtualDisksGuid = { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } } gEmuVirtualDisksGuid = { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
gEmuPhysicalDisksGuid = { 0xf2bdcc96, 0x8985, 0x11db, { 0x87, 0x19, 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] [PcdsFixedAtBuild]
gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|0x0|UINT64|0x00001014 gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|0x0|UINT64|0x00001014
gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|0x0|UINT64|0x00001015 gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|0x0|UINT64|0x00001015
@ -82,14 +78,17 @@
gInOsEmuPkgTokenSpaceGuid.PcdEmuMemorySize|L"64!64"|VOID*|0x0000100c 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 # filename can be a device node, like /dev/disk1
# R - Removable Media F - Fixed Media # R - Removable Media F - Fixed Media
# O - Write protected W - Writable # O - Write protected W - Writable
# Default is Fixed Media, 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 # 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.PcdEmuGop|L"GOP Window"|VOID*|0x00001018
gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../../EdkShellBinPkg/bin/ia32/Apps"|VOID*|0x00001004 gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../../EdkShellBinPkg/bin/ia32/Apps"|VOID*|0x00001004

View File

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

View File

@ -1,6 +1,6 @@
## @file ## @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 # 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. # a real platform. This also provides an example for how an DSC is created.
@ -216,6 +216,7 @@
gInOsEmuPkgTokenSpaceGuid.PcdEmuApCount|L"1" gInOsEmuPkgTokenSpaceGuid.PcdEmuApCount|L"1"
# For a CD-ROM/DVD use L"diag.dmg:RO:2048"
gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW" gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"
gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window" gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"
gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../EdkShellBinPkg/Bin" gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../EdkShellBinPkg/Bin"
@ -266,7 +267,7 @@
[Components] [Components]
!if $(SEC_ONLY) !if $(SEC_ONLY)
## ##
# SEC Phase modules # Emulator, OS POSIX application
## ##
InOsEmuPkg/Unix/Sec/SecMain.inf InOsEmuPkg/Unix/Sec/SecMain.inf
!else !else
@ -349,10 +350,10 @@
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
# { #{
# <LibraryClasses> # <LibraryClasses>
# NULL|InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf # NULL|InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
# } #}
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
@ -413,6 +414,9 @@
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
# SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf
# SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf
<PcdsFixedAtBuild> <PcdsFixedAtBuild>
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE