UEFI News and Commentary

Wednesday, July 24, 2013

Writing an IFR Assembler for UEFI - Part 1

In this article, you will learn how to run SysLib and IFR Assembler in Visual Studio 2012.
This article assumes that you have Visual Studio 2012 and that you have built EDK2's NT32 platform in C:\sourcecode\edk2.
 
In order to make these steps work as expected, you must set up Visual Studios as instructed in the blog post here.
 

Set Up:




1. To find the SysLib code, you must use Subversion to download the files onto the computer using this link: https://svn.code.sf.net/p/syslibforuefi/code/trunk
 
2. Create a folder titled SysLib, then take all the downloaded files and put them into the SysLib folder. Keep the files organized in folders in the same way they are on the website.
 
 
 
 
3. Copy the SysLib folder you just created into the folder C:\sourcecode\edk2.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4. Open the folder C:\sourcecode\edk2\Nt32Pkg
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5. Open Nt32Pkg.dsc in Visual Studio.
 
 
 
 
 
 
 
 
 
 
6. On about line 109 of Nt32Pkg.dsc, which is under the section "Generic Modules", write the following code:
SysLib|SysLib/Source/SysLib.inf
 
 
 
 
 
 
 
 

7. On about line 384 of Nt32Pkg.dsc, which is under the section "DXE Phases modules", write the following code: SysLib/Applications/IfrAsm/IfrAsm.inf
 
 
 
 
 
 
 
8. While downloading the files for SysLib, you should have downloaded some test cases. They are held in the folder C:\sourcecode\edk2\SysLib\Application\IfrAsm. Each one is a .pl file and is labeled 1 through 10. Select all the test cases.
 
 
 
9. Right click on the selected test cases and click on "Cut".
 
 
 
 
 
 
 
 
 
 
 
10. Open the folder C:\sourcecode\edk2\Build\NT32\DEBUG_VS2010x86\IA32.
 
 
 
 
 
 
 
 
 
 
 
11. Right click and select "Paste" to add all test cases to the folder.
 
 
 
 
 
 
 
 
 
 
 
 

 Running

12. Open Visual Studio 2012. Make sure that by this point, you have created EDK2's NT32 environment. If not, go set it up using these instructions.















13. Open your NT32 project.
















14. Click on Build->Build Solution or press F7.






15. Wait for the program to finish building.







16. Once the build has finished, click on Debug->Start Debugging or press F5.











17. A window will appear, press the button that says "No".
















18. Two or three windows will appear. Go to one of the GOP windows. Press "Enter" until Shell> _  appears at the bottom of the window.











19. Type f8: into the GOP window, then press "Enter".













20. When f8:\> _ appears at the bottom of the GOP window, enter the following text:
IfrAsm testcase8.pl -o testcase8.ifr











21. The opcodes used for testcase8.pl will be displayed in the GOP window. To run any of the other test cases, simply type in the text you typed in step 21, but replace testcase8 with the name of the test case you would like to run.










Test cases like the one used in the blog post are useful because the can be used to test different parts of the code to ensure that the code is being correctly parsed, read, and written. In the next post, the basic parsing organization of an IFR Assembler will be explained.

No comments: