1.安装Quem
window x64 qemu安装包下载地址: QEMU for Windows – Installers (64 bit)
2.设置环境变量
3.测试环境设置成功
4,编译好的路径下,打开命令行:EDK编译OvmfPkg 注意参数-a IA32 -a X64 5.编译成功后OVMF.FD 文件,qemu加载该rom方式:
qemu-system-x86_64.exe -pflash OVMF.fd -net none //-net none 不启动PXE,启动成功
6.在学习UEFI的过程中给使用的EDK2代码编译有Emulator与OvmfPkg。EmulatorPkg比较方便可以直接显示DEBUG函数的输出信息,但是Emulator会缺少很多东西,导致很多Protocol无法使用。
Winhost.exe下的Log直接打印:
qemu-system-x86_64.exe 如何抓取log呢?
-pflash 】:FD文件存放目录
【-hda fat:】:efi文件存放目录(模拟一个硬盘)
【-debugcon file:debug.log】:将DEBUG打印的log存到debug.log里面,在qemu的安装目录下。
添加参数后运行可以获取串口日志
>qemu-system-x86_64.exe -bios OVMF.fd -hda fat:rw:hda-contents -net none -m 256 -nic none -boot order=dc -D DEBUG_ON_SERIAL_PORT -debugcon file:stdio -global isa-debugcon.iobase=0x402
运行效果: