This article assumes that you have Visual Studio 2012 and that you have the Visual Studio project to build the EDK2's NT32 platform in C:\sourcecode\edk2.
To set up EDK2's UEFI environment with Visual Studio 2012, click here.
To debug the UEFI environment with Visual Studio 2010, click here.
To debug the UEFI environment with Visual Studio 2008, click here.
Set-Up
1. Open the NT32 project in Visual Studio 2012.2. Go to File -> Open File...
3. Because environment variables no longer work for NT32, we need to change the DSC file. Open Nt32Pkg.dsc (located in C:\sourcecode\edk2\Nt32Pkg\Nt32pkg.dsc).
4. Find the section of Nt32Pkg.dsc labeled "Pcd Dynamic Section."
5. Find the line for PcdWinNtGop and change it so it reads as follows
gEfiNt32PkgTokenSpaceGuid.PcdWinNtGop|L"GOP Window 1!GOP Window 2"|VOID*|52
6.Again, got to File -> Open File...
7. Open the file Main.c, which is located at c:\sourcecode\edk2\AppPkg\Applications\Main\Main.c
8. In Main.c, go to the line of code that reads as follows:
puts("Hello there fellow Programmer");
9. Press F9. A red dot should appear in front of that line of code. You have created a break in the code.
10. Use the tabs in Visual Studios to switch back to Nt32Pkg.dsc.
11. Find the line of code that has "HelloWorld" in it (The line should read MdeModulePkg/Applications/HelloWorld/HelloWorld.inf).
12. Under that line of code, write the following text:
AppPkg/Applications/Main/Main.inf
13. Scroll down to the very bottom of Nt32Pkg.dsc and write the following text:
DEFINE EMULATE
!include StdLib/StdLib.inc
14. Go to Build->Build Solution.
15. Wait for the Build to finish.
The picture to the right shows what the output box will display when it is finished.
Debugging
16. Press F5, then press "No" in the box that appears.
17. When the Graphics Output Window appears, hit "Enter" twice, or wait for the window to load completely.
18. Type "Main" into the Graphics Output Window.
19. The process should halt and bring you to the Break you set in Main.c in Step 9.
20. From here, F10 will bring you through the code line-by-line as it runs. You can also go to Debug->Continue to let the program continue normally.
You can halt the execution of the emulated UEFI environment at any time by selecting Debug->Break All. Then you can set some breakpoints on a specific function by using Debug->New Breakpoint->Break At Function and typing in the function name. You can force a breakpoint by inserting a __debugbreak() into your code or by hitting F9.
No comments:
Post a Comment