]> git.proxmox.com Git - mirror_edk2.git/commitdiff
InOsEmuPkg: Add support for mounting CD-ROM images.
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Jun 2011 16:18:14 +0000 (16:18 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Jun 2011 16:18:14 +0000 (16:18 +0000)
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

InOsEmuPkg/InOsEmuPkg.dec
InOsEmuPkg/Unix/Sec/BlockIo.c
InOsEmuPkg/Unix/UnixX64.dsc

index 33510406cc699c54d4c500bbd59c7fe07e097dd0..a2cce7888b40aa9d1f62a682d4467284d8272b79 100644 (file)
   gEmuVirtualDisksGuid       = { 0xf2ba331a, 0x8985, 0x11db, { 0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
   gEmuPhysicalDisksGuid      = { 0xf2bdcc96, 0x8985, 0x11db, { 0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }\r
 \r
-#  gEmuFileSystemGuid         = {0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}\r
-#  gEmuSerialPortGuid         = {0x6d3a727d, 0x66c8, 0x4d19, {0x87, 0xe6, 0x02, 0x15, 0x86, 0x14, 0x90, 0xf3}}\r
-#  gEmuNetworkGuid            = {0x081603B4, 0x0F1D, 0x4022, {0xB6, 0xFD, 0x4C, 0xE3, 0x5E, 0x09, 0xA1, 0xA6}}\r
-\r
 [PcdsFixedAtBuild]\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|0x0|UINT64|0x00001014\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|0x0|UINT64|0x00001015\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuMemorySize|L"64!64"|VOID*|0x0000100c\r
   \r
   #\r
-  # filename[:][R|F][O|W]\r
+  # filename[:[R|F][O|W]][:BlockSize]\r
   # filename can be a device node, like /dev/disk1\r
   # R - Removable Media F - Fixed Media\r
   # O - Write protected W - Writable\r
   #   Default is Fixed Media, Writable\r
-  # Size comes from file or device. \r
+  # For a file the default BlockSize is 512, and can be overridden via BlockSize,\r
+  #  for example 2048 for an ISO CD image. The block size for a device comes from\r
+  #  the device and is not configurable. \r
+  # Device Size comes from file or device. \r
   # On Mac OS X you can use Disk Utility to create .dmg files and mount then like disks\r
-  gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"FW;40960;512"|VOID*|0x00001001\r
+  gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"|VOID*|0x00001001\r
   \r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"|VOID*|0x00001018\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../../EdkShellBinPkg/bin/ia32/Apps"|VOID*|0x00001004\r
index 8b760cc41a94aab0414c9402479f7ac7e17eeca5..57bfdfa78a784bbdd4ab43149323f8e0f26162dc 100644 (file)
@@ -29,6 +29,7 @@ typedef struct {
   BOOLEAN                     WriteProtected;\r
 \r
   UINT64                      NumberOfBlocks;\r
+  UINT32                      BlockSize;\r
 \r
   EMU_BLOCK_IO_PROTOCOL       EmuBlockIo;\r
   EFI_BLOCK_IO_MEDIA          *Media;\r
@@ -157,14 +158,14 @@ EmuBlockIoOpenDevice (
     }\r
 #endif\r
     \r
-  } else if (fstatfs (Private->fd, &buf) == 0) {\r
-    //\r
-    // Works for files, not devices\r
-    //\r
-    Private->Media->BlockSize = buf.f_bsize;\r
-    Private->Media->OptimalTransferLengthGranularity = buf.f_iosize/buf.f_bsize;\r
+  } else {\r
+    Private->Media->BlockSize = Private->BlockSize;\r
     Private->NumberOfBlocks = DivU64x32 (FileSize, Private->Media->BlockSize);\r
     Private->Media->LastBlock = Private->NumberOfBlocks - 1;\r
+    \r
+    if (fstatfs (Private->fd, &buf) == 0) {\r
+      Private->Media->OptimalTransferLengthGranularity = buf.f_iosize/buf.f_bsize;\r
+    }\r
   } \r
 \r
   DEBUG ((EFI_D_INIT, "%HEmuOpenBlock: opened %a%N\n", Private->Filename));\r
@@ -627,7 +628,8 @@ EmuBlockIoThunkOpen (
   Private->Signature = EMU_BLOCK_IO_PRIVATE_SIGNATURE;\r
   Private->Thunk     = This;\r
   CopyMem (&Private->EmuBlockIo, &gEmuBlockIoProtocol, sizeof (gEmuBlockIoProtocol));\r
-  Private->fd = -1;\r
+  Private->fd        = -1;\r
+  Private->BlockSize = 512;\r
  \r
   Private->Filename = StdDupUnicodeToAscii (This->ConfigString);\r
   if (Private->Filename == NULL) {\r
@@ -646,6 +648,10 @@ EmuBlockIoThunkOpen (
       if (*Str == 'O' || *Str == 'W') {\r
         Private->WriteProtected  = (BOOLEAN) (*Str == 'O');\r
       }\r
+      if (*Str == ':') {\r
+        Private->BlockSize = strtol (++Str, NULL, 0);\r
+        break;\r
+      }\r
     }\r
   }\r
   \r
index 10bb0cf2f6e717f216a8b5fe20e6d782b5eaa36e..a601c0cbceb70350db4f7269feba24491da0c1c6 100644 (file)
@@ -1,6 +1,6 @@
 ## @file\r
 #\r
-# EFI/Framework Emulation Platform with UEFI HII interface supported.\r
+# UEFI/PI Emulation Platform with UEFI HII interface supported.\r
 #\r
 # The Emulation Platform can be used to debug individual modules, prior to creating\r
 #       a real platform. This also provides an example for how an DSC is created.\r
   \r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuApCount|L"1"\r
 \r
+  # For a CD-ROM/DVD use L"diag.dmg:RO:2048"\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuVirtualDisk|L"disk.dmg:FW"\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuGop|L"GOP Window"\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuFileSystem|L".!../../../../EdkShellBinPkg/Bin"\r
 [Components]\r
 !if $(SEC_ONLY)\r
   ##\r
-  #  SEC Phase modules\r
+  #  Emulator, OS POSIX application\r
   ##\r
   InOsEmuPkg/Unix/Sec/SecMain.inf\r
 !else\r
   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
   IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf \r
{\r
  <LibraryClasses>  \r
    NULL|InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf\r
}\r
 #{\r
 #  <LibraryClasses>  \r
 #    NULL|InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf\r
 #}\r
   \r
   MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
   MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
       ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
       SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf\r
       PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
+#      SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf\r
+#      SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf\r
+\r
     <PcdsFixedAtBuild>\r
       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF\r
       gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE\r