UEFI Principles and Programming (a): environmental structures

Foreword
recently engaged in some programming under the UEFI environment. For me this has never touched EFI rookie programmers front development environment to build, program details, and so no one under the guidance of the situation, and take a lot of detours. When the Internet to find information, but also find information online face mostly outdated, or missing key steps, hitting the wall a lot. Today, I will detail the past few days I was out of it completely process, I hope, like me, have UEFI new to programming you can have some help.

A, EDK II and the Download Support Tool
1, UEFI Development do so, you first need to download EDK II environment, you can download the official website, you can also find in the SourceForge above, below posted EDKII of GitHub:
                  https://github.com/tianocore /edk2.git

If you see many names such as: EDK, EDKII, UDK2010, UDK2014 , UDK2015 ...., explanation follows
a, EDK earlier things
b, Intel is now pushing
c, UDK relatively stable EDKII
Note: An Explanation from in biosren. In the option to download that version when I started holding Qiuwen attitude, download some lower version, then all kinds of pits in the course of time, which makes gray head sounded. So I recommend downloading the latest github go on it, at least I use now did not find any problems. PS (I was under the UDK2015, a few days ago to see the latest has UDK2017 !!! -.-)
2, VS2008 (64-bit compiler to ensure there), you can also choose other versions such as: VS2010 ,. In fact, when EDKII you install, you can see tools_def.txt under Conf \ This file all the compiler, but also to check that the configuration is correct, this will be mentioned later. So now I I listed below UDK2015 installed supported:
A, VS2003 (32bit)
B, VS2005 (32bit, 64bit)
C, VS2008 (32bit, 64bit)
D, in VS2010 (32bit, 64bit)
E, VS2012 ( 32bit, 64bit)
F, VS2013 (32bit, 64bit)
G, DDK3790 
H, UNIXGCC
I, GCC44 - GCC49
K, CLANG35 
L, ELFGCC
 J, CYGGCC
K, the ICC \ ICC11
Of course, these circumstances may be, depending on the version you download EDKII, and I am using is VS2008. VS software to do the big man should know.
3, Windows SDK, download the install VS should have, if not, then you can go to the official website to download their own.        
              https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=24826

4, IASL Compiler
http://www.acpica.org/downloads/binary_tools,ps: not open, then your own Google / baidu, to download just fine, good after downloading them to COPY C: \ ASL inside. The reason behind will say, I have been to here in the pit.

5, Package Penalty for openssl-1.0.2d + patch 
https://www.openssl.org/source/, patch: HTTP: //gnuwin32.sourceforge.net/packages/patch.htm
is actually needed patch for openssl patch, specific operations can be seen UDK2015.Complete.MyWorkSpace.zip inside myWorkSpace \ CryptoPkg \ Library \ OpensslLib \ Patch-hOWTO.txt
really do not see it does not matter, I will describe later, but note that if you choose the version with me not the same as I said above, you need to look at that view documentation specific operation.

6, EADK
https://sourceforge.net/projects/edk2/files/EDK%20II%20Releases/EADK/
or: https://svn.code.sf.net/p/edk2/code/trunk/edk2/    
EADK It provides a standard library contains some C stand library, and offers the possibility of floating-point operations. Just for UEFI Application!
Note: If you use UDK2015 or> 2015, please download teach new EADK, Do not use EADK1.02 or EADK_A2!

Two, EDKII Setup
1, unzip the UDK2015

Because we are using Windows, so we'll Base Tool (Windows) .zip and extract to UDK2015.MyWorkSpace.zip: D: \ EDK2 folder
Note that if you look at some of the information online and some of the books (UEFI principles and programming) structure describes the contents of the folder after UDK2015.MyWorkSpace.zip decompression MyWorkSpace referred to the D: \ folder under EDK2, then you can extract them mentioned parent directory D: \ EDK2 inside, with some of the course materials consistent . Of course, if you know these, you can configure their own definition of when you build.
2, Generate OpenSSL * Crypto Library
In fact, this step in front mentioned, I send a picture:
          
at the bottom Patch-HOWTO.txt there are detailed steps. I probably right inside the content posted, if you want to see in detail, you can go to view this file.
Windows Environment the For:
    ------------------------
    1) the Make the Sure at The Patch Utility has been Installed in your Machine.
       The Install Cygwin or GET binary at The Patch Utility from
       http://gnuwin32.sourceforge.net/packages/patch.htm
    2) cd $ (WORKSPACE) \ CryptoPkg \ Library \ OpensslLib \ OpenSSL-1.0.2d
    3) patch -p0 -i ..\EDKII_openssl-1.0.2d.patch
    4) cd ..
    5) Install.cmd

3, IASL decompression, then the compiler copy to C: \ ASL folder

The front said, the specific reasons, have to look down -. - h

4, open with administrator privileges to open the CMD, into the D: \ EDK2: CD / DD: \ EDK2, run edksetup.bat results are as follows:


Note: Please ignore the contents WARNING

5, this time, you need to open EDK2 folder, and found a Conf folder opens, we need to tools_def.txt which target.txt and even a configuration file.
                                                                            
a, target.txt mainly for TOOL_CHAIN_TAG, configure, where lazy programming principles and reference UEFI figure above:
                                            
            ? Please note that 32-bit machines, filled out the VS200 ?, and 64-bit machine 32 VS x32 only fill VS200
b , tools_def.txt mainly to check their own compiler path is correct
, such as my VS2008 is installed in D: \ Visual Stadio2008, then the path I have set up properly as follows:
          
             Please note to be set according to their own circumstances.
Well, here we take a close look found, tools_def.txt IASL the default settings, directly on the map:

It found its path default is C: \ ASL, good to stay in front of suspense explained. If you want to customize it, be consistent enough!
6, let's talk about compiling NT32 simulator.
First, the purpose of this step can run our EFI file again NT32 simulation environment, we will be able to efi files in a simulated environment to test the interesting, of course, using the simulated environment is defective, the back talk anymore.
Step:
A, D: \ EDK2> edksetup.bat --nt32
b, D: \ EDK2> Build
NOTE: In step b may take a little time to build, which is understandable.
c, after build completion, if there is no problem, it should look like this:

        Perhaps you have seen, I build only took 30s, this is not my machine performance is better, it's just because I've already build before. This time the build just check the changes of the previous build. If you look at the generated files, you will find that their modified date is the last time you build done in time. Of course, provided you do not make changes to the file, if changed, will certainly take the time to re-build of.
7, to talk about how to run the simulator NT32
is very simple: build run
, however, note that before you build run, you need to run edksetup.bat to load edkii environment.
8, exit NT32 simulated environment
just use: reset command can!
Third, the use of U disk boot UEFI
        In fact, it is estimated that you have on the Internet or reference books checked how to make, but you still fail, especially in the Legacy BIOS platform. But I am in actual operation, we found that the situation tainted step, the reason should be the version of reasons.
         Talk about here is doing it: also mentioned earlier that some defect in the simulated environment under the NT32, currently I encountered UEFI programming, we will use the protocol, but in a simulated environment NT32 some protocol did not mount devices . That we can not test our program. At this point we need to be tested in native UEFI environment. I also met other cases, not in this list, do not know in front of this situation, I do not really is not the -. -!
1, first introduced in the USB disk production UEFI platform
easy, guess you check in online too simple to say: 1, U disk format FAT (I am FAT32)
    2, U-establish efi \ boot
    3, the program will efi COPY to the top of the directory, rename or bootx64.efi see you bootia32.efi which belong to
the Ok.
In fact, the principle is the UEFI boot file is the boot file in the above path. . . interesting. . .

2, Legacy BIOS platform.

        In fact, we all know to use DUET, me too. But first I use online tutorials, reference books and practices but it's not, then I see DuetPkg folder ReadMe.txt found UDK2015 take one more step, posted the following detailed steps, of course, you can also check out this file .
U disk drive here to e:, depending on your situation changes
A, Duet Build Platform Module
-> CD / DD: \ EDK2
-> edksetup.bat
-> Build -p DuetPkg \ DuetPkg.dsc -e IA32 Note : 64bit: Build -p DuetPkg \ -e DuetPkg.dsc X64
-> DuetPkg the CD
-> PostBuild.bat the IA32 Note: 64bit: X64 PostBuild.bat
B, the Create Boot disk
-> U disk insertion
-> CreateBootDisk.bat floppy e: FAT12 IA32 Note: 64bit: CreateBootDisk.bat floppy e: FAT12 X64 ( lack of information on the Net this step should be the original version is the final step in the completion of)
-> CreateBootDisk.bat the USB E: FAT32 IA32 Note: 64bit: CreateBootDisk.bat usb e: FAT32 X64 (lack of information on the Net this step should be the original version is the final step in the completion of)
-> pull out the U disk, then plug
-> CreateBootDisk.bat usb e: FAT32 IA32 step2 NOTE: 64bit: CreateBootDisk.bat usb e: FAT32 X64 step2
      After this step, OK. Can restart the test from disk to start entering the UEFI shell U, enter fs0: to get into the root directory of the U disk. . . . interesting
DUET is provided UEFI Legacy BIOS emulator, a UEFI system environment based on the conventional BIOS.
3, in the pit where the struggle for a long time, because my efi program can not run. Now, with this step, you can test your own written procedures of the interesting

Note: Shell command in this environment is that UEFI can run well, you can try, such as
Shell "PCI # This command will list on your machine PCI Device, including BUS DEV FUN VID DID CLASSNAME and other information.
4, summarized
     this, EDKII SETUP are finished. Some time ago sectoral meetings, there is a BIOS leader said a word: "Only by doing the BIOS BIOS can understand people." Indeed, for this before I do not have the software to find out about BIOS / EFI, in this short a few EFI day contact with my big head. No not rare, but the lack of Chinese data, questions remain unanswered, our only keep trying, keep viewing Spec. Headache 60% and about watching the English Spec - -! ! ! . Therefore, this article is mainly for software personnel to write but never had contact with EFI EFI program but need to build EFI environment. Only I hope that you can successfully build environment, write the code, Build successful test OK, to complete the task, then stay away from these things, precious brain cells -. -! ! !
--------------------- 
Author: kaliopensourcextu 
Source: CSDN 
Original: https: //blog.csdn.net/sevensevensevenday/article/details/61414245 
Disclaimer: This article as a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin blog.csdn.net/mao0514/article/details/90210259