UEFI News and Commentary

Monday, June 25, 2012

HOW-TO: Run Main



Okay, I've got it all set up and I want to write a basic C app so I went looking for examples. I found examples, but didn't know how to get them to build and none of the docs showed me how. So here's how I figured out how to get a basic app built.
This article will describe how to run Main, a project that contains a simple C application.  

This article assumes you have downloaded EDK2 into C:\edk2 and have set up the Visual Studio project to build the EDK2's NT32 platform.  The files for Main are located in C:\edk2\AppPkg\Applications\Main

1. Open Nt32Pkg.dsc.  It is located in C:\edk2\NT32Pkg.  



2. Under the [Components.IA32] section, add "AppPkg/Applications/Main/Main.inf" 
What you are building (Nt32Pkg) is actually the platform package (or just the platform). You are adding an application (Main) to the platform (Nt32Pkg) so that it will be built. The DSC file controls which drivers and applications will be built. Libraries, drivers and applications have the generic name 
"modules."   






3. At the very bottom of Nt32Pkg.dsc, add the following:
DEFINE EMULATE
!include StdLib\StdLib.inc 
Main uses the standard C library, which is not used by any other modules in the Nt32 platform. So need to add the C library the platform so that that it will be built. The EMULATE flag tweaks the C Library so that it works well with emulated (or hosted) environments like NT32.


4. Be sure edk2 is up-to-date.


5. You should be able to run the project from Visual Studio by using CTRL+F5.  You can also run it from the command prompt by typing:
cd /d c:\edk2\Build\NT32\DEBUG_VS2010x86\IA32
SecMain.exe


6. Two windows will pop up and will run the emulated Shell environment.  You can now run Main from the Shell.  Type the following into the console window:
map -r
f8:
Main.efi





Ok, I got it built and now I can go about modifying it and creating new stuff.

No comments: