On Feb 5, 2014, at 10:27 AM, John Davis <[email protected]> wrote:

> Hello
> 
> I notice that there are many file types in the edkII build workspace.  I 
> notice the workspace also contains files like .efi and .ifi.  Besides knowing 
> these are both PE files by examining them with a hex editor its not easy for 
> me to find what the difference in these files are.  From the EDK II Build 
> Spec in chapter 10 it has some info on the file types by extension, but when 
> I look at the UEFI specs I don't see anything which jumps out.
> 
> For instance I the tables in Chapter 10 say that .efi 
>   o Is an input to GenFds.
>   o Is an input to ImageGen
> 
> I know there is a _EFI_FILE Structure Protocol which seems to be a file 
> handle for accessing files on the EFI Partition.  I'm guessing its kind of 
> like a FILE handle for regular user mode file I/O.  I also know that in the 
> shell, whn you hit F8 and do dir you see a bunch of .efi files. 
> 
> Some of the files are xxx.efi and others are xxxDxe.efi. I thought the 
> xxx.efi form would be applications since the Hello program I made from the 
> Beyond Bios book makes a Hello.efi.  The hello.efi program can be run by 
> simply saying Hello, but the others like Cpu.efi or Cpu can not.  I was 
> thinking it would be something like cpuinfo in linux.
> 
> As far as the xxxDxe.efi files, I'm pretty sure they are drivers since they 
> correspond to the output of the drivers command.  I don't know what the 
> difference between a dxe driver and dxe application other than one might be 
> an installer for a driver.  Anyway, I notice that you can load and unload 
> drivers in the shell.  Odd that you can load a driver multiple times.  Its 
> also odd that if you load a driver it will show up in drivers output as 
> \/ArpDxe.efi instead of ArpDxe as it is when loaded at boot.
> 
> Also load Cpu.efi will crash the emulator.
> 

You can run an Application, but you have to load a driver. In general drivers 
produce protocols for others to consume. 

The emulator runs as an application, so crashing usually means an operation was 
attempted that is not allowed in user space. So this is the expected behavior 
for an EFI X64 CPU driver as it is probably setting up GDTs, ITDs, MTRRs, 
writing MSRs, etc. which are not legal to do in user space. 

You need to think of the emulator like a hardware target. So how the CPU works 
in the emulator is different than a generic X86 CPU, so you can’t use a generic 
X86 driver. For the Unix emulator @ 
https://svn.code.sf.net/p/edk2/code/trunk/edk2/EmulatorPkg/CpuRuntimeDxe/ Posix 
is used to provide the MpServices and an emulation of multiple CPUs in the 
system. This driver produces the CPU Architectural, MpServices, and CpuIo2. So 
code that is hardware agnostic and coded to the PI spec can run (and be 
debugged) in the emulator as long as it only depends on the spec defined CPU 
abstractions. 

> TLDR. Where in the UEFI spec is the pointer to all the different file types? 
> .efi, .ifi, What is difference between drivers, driver applications?
> 

UEFI 2.4 6.4 Image Services is what you are looking for. There is a table that 
explains the differences. 

Basically there are three types of images. Application, Boot Services Driver, 
and Runtime Driver. 

The big difference between an Application and a Driver is an Application is 
unloaded from memory when it exists and a Driver is not unloaded if it returns 
success. The difference between a Runtime Driver and a Boot Services driver is 
the type of memory that gets allocated and some fix-ups that happen to the 
driver to support calling at Runtime. The Boot Services drivers memory is freed 
back to the OS, and a Runtime Driver consume memory that the OS can not use.


PE/COFF spec: 
http://msdn.microsoft.com/en-us/library/windows/hardware/gg463119.aspx

https://svn.code.sf.net/p/edk2/code/trunk/edk2/MdePkg/Include/IndustryStandard/PeImage.h
//
// PE32+ Subsystem type for EFI images
//
#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION         10
#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER      12

Thanks,

Andrew Fish

> 
> -- 
> John F. Davis
> 6 Kandes Court
> Durham, NC 27713
> 919-888-8358
> 
> 独树一帜
> 
> 
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk_______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to