Re: [edk2] Boot to ISO image in volatile memory

Subject: Re: [edk2] Boot to ISO image in volatile memory

From: Andrew Fish <afish@apple.com>

To: edk2-devel@lists.sourceforge.net

Date: 2013-04-05 00:15:20



On Apr 4, 2013, at 3:50 PM, Thomas Rognon <tcrognon@gmail.com> wrote:

I found this on the internet,
The UEFI adaptation of ElTorito results in mapping image offset 14800-A27FF as a FAT file system, and executing file EFI/BOOT/BOOTX64.efi in the 64-bit UEFI environment.


That is kind of like saying a file on my disk always resides at a given set of blocks on the disk. I looked at it with a debugger and it must be so.

If you want to see how UEFI deal with El Torito there is no need to reverse engineer (I guess those legacy BIOS habits die hard). It is completely documented in Partition Discovery section (12.3.2 in UEFI 2.3.1)  of the UEFI spec. The code that implements this logic is here: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/MdeModulePkg/Universal/Disk/PartitionDxe/



So here are the steps, if I understand correctly:
- create a new instance of BLOCK_IO using the offsets above

No there is no magic data location in El Torito. Well that is not completely true as the Primary Volume Descriptor must reside at sector 0x10 on the disk, and ElTorito requires some magic at sector 0x11. But these magic sectors are decoded and point to a Booting Catalog that points to a set of sectors on the disk that EFI interprets as a "disk partition"

So you need a memory buffer that contains a  valid ISO-9660 El Torito bootable image. Then the Block IO makes memory offset 0 map to sector zero and memory offset 2k maps to sector 1, etc. 

- ConnectController() on the BLOCK_IO handle (which creates a new SIMPLE_FILE_SYSTEM)
- get device path for newly created SIMPLE_FILE_SYSTEM
- append device path with EFI/BOOT/BOOTX64.efi
- LoadImage using appended device path
- StartImage

Is that right?

Regarding the RAM disk driver, I couldn't find much about it.  Do you think I'd have to have a custom installer with a ram disk driver included to make this work?  I'm guessing the Windows installer doesn't have one?


This is the edk2-developer list so I think Tim was implying you could write one. 

Thanks for taking the time to help me out, btw.

Thomas Rognon



On Thu, Apr 4, 2013 at 4:27 PM, Andrew Fish <afish@apple.com> wrote:
So remember El Torito != ISO-9660, so the image will look different in the OS vs. the EFI. The file system that EFI sees will show up as a file in the OS, and EFI will not see all the ISO-9660 files you can see in the OS. 

Also remember that the OS Installer is going to call ExitBootServices() at some point, and after that it needs a native Windows driver for the RAM disk, as all the EFI device driver stuff goes away. 

Thanks,

Andrew Fish


On Apr 4, 2013, at 2:08 PM, Thomas Rognon <tcrognon@gmail.com> wrote:

Oh ok, that's good news regarding El Torito.  I'll start wrapping my head around the code you mentioned.  The ISOs I will be booting are OS installers.  Specifically, I'm trying to boot a legit Windows 7 installer from memory right now.


On Thu, Apr 4, 2013 at 3:41 PM, Tim Lewis <tim.lewis@insyde.com> wrote:

The partition driver already exists (see MdeModulePkg/Universal/Disk/PartitionDxe).  This already recognizes El Torito format, so, as long as the partition you boot from is FAT32 you should have no trouble (see the FatBinPkg).

 

If you are trying to boot an OS, then you have to figure out how to convince how to convince that OS to continue to use that driver once it reaches the hand-off point in boot, because it then requires a native OS driver to continue to access your ISO.

 

Tim

 

From: Thomas Rognon [mailto:tcrognon@gmail.com]
Sent: Thursday, April 04, 2013 1:31 PM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] Boot to ISO image in volatile memory

 

Thanks!  That gives me a great start.  I'm new to a lot of this stuff, though, so the steps you outlined will be tough for me without guidance.  Is there any UEFI optical drive code floating around the internet somewhere?  I looked but couldn't find any.  I'm essential doing the same thing as booting to a CD/DVD, except its all in memory.

 

Thomas Rognon

 

On Thu, Apr 4, 2013 at 2:27 PM, Tim Lewis <tim.lewis@insyde.com> wrote:

Produce an instance of BLOCK_IO protocol which returns pieces of the in-memory image. Then perform a ConnectController() on that handle, which should cause a DISK_IO and SIMPLE_FILE_SYSTEM to be mounted automatically.

 

Then, you use the file system to load the boot loader (LoadImage()), signal the ready-to-boot event, set up the UEFI watchdog timer, and then start the boot loader (StartImage()). There may be a few more standard boot items I may be forgetting, but thats about it.

 

Tim

 

From: Thomas Rognon [mailto:tcrognon@gmail.com]
Sent: Thursday, April 04, 2013 12:21 PM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] Boot to ISO image in volatile memory

 

Let's say I'm running a UEFI_APPLICATION called IsoBootTest.efi and I have an ISO image in volatile memory and I have the start address and size of the ISO image.  Can I boot the ISO image?  If so, can someone give me a hint on how I would do it?  (If it makes any difference, I'm using UDK2010.)

 

Thomas Rognon


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

 


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel