[分享] 开发 uefi 程式

楼主: descent (“雄辩是银,沉默是金”)   2016-04-10 16:25:47
读过《UEFI 原理与程》后, 我终于有点概念了怎么开发 uefi 程式。 需要对 .dsc,
.dec, .inf 有点概念, 《UEFI 原理与程》第三章在讲这个, 请自行参阅, 书上有的东西
我就不重复了。
env:
linux/debian
X64
gcc
安装所需要的开发套件:
apt-get install build-essential subversion uuid-dev iasl nasm
要先搞定 edk2, 这是 uefi 开发工具。
git clone https://github.com/tianocore/edk2.git
编译 edk2 工具:
make -C BaseTools/
设定环境变量
. edksetup.sh
修改 Conf/target.txt
TARGET_ARCH = X64
TOOL_CHAIN_TAG = GCC49
虽然我选的是 GCC49, 不过其实我系统中的 gcc 是 5.3。
开始编译 edk2 的程式
build -p OvmfPkg/OvmfPkgX64.dsc
build -p MdeModulePkg/MdeModulePkg.dsc
build -p AppPkg/AppPkg.dsc
build 相当于 make, 启动后就会开始一系列的 gcc/ld 命令。
编译出来的档案在
edk2/Build
ex:
Build/OvmfX64/DEBUG_GCC49/FV/OVMF.fd
这个可以用 qemu 来跑, 模拟 uefi。
qemu-system-x86_64 -fda dos622.img -bios OVMF.fd
MdeModulePkg 里头有个 Hello.efi 可以测试, AppPkg 有个 Main.efi 则是以 main 来
写 uefi 程式的范例。
把这两个档案复制到 dos622.img, 用 qemu-system-x86_64 -fda dos622.img -bios
OVMF.fd 来测试。
( https://goo.gl/6FYHih )
Main.efi source code: edk2/MdeModulePkg/Application/HelloWorld/HelloWorld.c
Hello.efi: edk2/AppPkg/Applications/Hello/Hello.c
Main.efi: edk2/AppPkg/Applications/Main/Main.c
AppPkg obj 档则是在
Build/AppPkg/DEBUG_GCC49/X64/StdLib/LibC/LibC/OUTPUT/
ex:
Build/AppPkg/DEBUG_GCC49/X64/StdLib/LibC/LibC/OUTPUT/Main/Main.obj
source code 档案都告知了, 可以自行参阅, 不过还需要知道各种 uefi 程式种类, 一样
在《UEFI 原理与程》。
ref:
Using EDK II with Native GCC ( https://goo.gl/paZ0oR )
Common instructions for Linux ( https://goo.gl/h40RHv )
How to build OVMF ( https://goo.gl/VThLbD )
// 本文使用 Blog2BBS 自动将Blog文章转成缩址的BBS纯文字 http://goo.gl/TZ4E17 //
blog 原文:
http://descent-incoming.blogspot.tw/2015/03/uefi-qemu.html
作者: nelson210   2016-04-11 10:13:00
感谢

Links booklink

Contact Us: admin [ a t ] ucptt.com