【UEFI实战】在Windows下运行UEFI BIOS(Nt32篇)

综述

EDK2源代码中有一个PKG名称Nt32Pkg:

 

通过这个PKG可以编译出可以在Windows下直接运行的UEFI BIOS程序,因此可以通过它来学习UEFI的一些基础和细节。

本文主要介绍如何编译这个PKG以及如何运行生成的BIOS。

源代码来自:vUDK2017: https://github.com/tianocore/edk2.git Tag vUDK2017.,也可以在GitHub - tianocore/edk2: EDK II官网下载。

编译和运行环境如下:

  • Windows10 VS2015 Community。
  • IDE:VS Code。

编译

1. 下载源代码,根目录是D:\Codes\vUDK2017(可以随意调整);

2. 在该目录打开一个cmd窗口:

3. 运行edksetup.bat --nt32:

4. 这行完成之后在Conf目录会生成新的文件(下图未标绿色钩子的文件):

5. 这里需要编辑的是target.txt文件:

#
#  PROPERTY              Type       Use         Description
#  ----------------      --------   --------    -----------------------------------------------------------
#  ACTIVE_PLATFORM       Filename   Recommended Specify the WORKSPACE relative Path and Filename
#                                               of the platform description file that will be used for the
#                                               build. This line is required if and only if the current
#                                               working directory does not contain one or more description
#                                               files.
ACTIVE_PLATFORM       = Nt32Pkg/Nt32Pkg.dsc

#  TARGET                List       Optional    Zero or more of the following: DEBUG, RELEASE, NOOPT
#                                               UserDefined; separated by a space character.
#                                               If the line is missing or no value is specified, all
#                                               valid targets specified in the platform description file 
#                                               will attempt to be built. The following line will build 
#                                               DEBUG platform target.
TARGET                = DEBUG

#  TARGET_ARCH           List       Optional    What kind of architecture is the binary being target for.
#                                               One, or more, of the following, IA32, IPF, X64, EBC, ARM
#                                               or AArch64.
#                                               Multiple values can be specified on a single line, using
#                                               space charaters to separate the values.  These are used
#                                               during the parsing of a platform description file, 
#                                               restricting the build output target(s.)
#                                               The Build Target ARCH is determined by (precedence high to low):
#                                                 Command-line: -a ARCH option
#                                                 target.txt: TARGET_ARCH values
#                                                 DSC file: [Defines] SUPPORTED_ARCHITECTURES tag
#                                               If not specified, then all valid architectures specified
#                                               in the platform file, for which tools are available, will be
#                                               built.
TARGET_ARCH           = IA32

#  TOOL_DEFINITION_FILE  Filename  Optional   Specify the name of the filename to use for specifying
#                                             the tools to use for the build.  If not specified,
#                                             WORKSPACE/Conf/tools_def.txt will be used for the build.
TOOL_CHAIN_CONF       = Conf/tools_def.txt

#  TAGNAME               List      Optional   Specify the name(s) of the tools_def.txt TagName to use.
#                                             If not specified, all applicable TagName tools will be
#                                             used for the build.  The list uses space character separation.
TOOL_CHAIN_TAG        = VS2015x86

# MAX_CONCURRENT_THREAD_NUMBER  NUMBER  Optional  The number of concurrent threads. Recommend to set this
#                                                 value to one more than the number of your compurter
#                                                 cores or CPUs. Less than 2 means disable multithread build.
MAX_CONCURRENT_THREAD_NUMBER = 1


# BUILD_RULE_CONF  Filename Optional  Specify the file name to use for the build rules that are followed
#                                     when generating Makefiles. If not specified, the file: 
#                                     WORKSPACE/Conf/build_rule.txt will be used
BUILD_RULE_CONF = Conf/build_rule.txt

6. target.txt就是用来确定编译的目标,从上面可以看到默认编译的就是Nt32Pkg,这里需要修改的是TOOL_CHAIN_TAG这一项,因为我们使用的是VS2015 Community,所以这里修改成VS2015x86,具体这个值的来源可以参考同目录下的tools_def.txt文件。

7. 之后运行build进行编译:

8. 编译完成:

使用

编译完成后可以在根目录下找到Build目录,在该目录下可以找到对应的二进制可执行文件:

双击该文件就可以执行:

  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值