EDKII:第一个Helloworld

目录

0 说明

1 步骤

1.1 简介

1.2 创建新文件

1.3 创建printhelloworld.c、printhelloworld.inf:

1.4 修改MdeModulePkg\MdeModulePkg.dsc

1.5 修改EmulatorPkg\EmulatorPkg.dsc

1.6 运行


0 说明

上篇文章记录了如何安装UEFI环境,在这里将会写下如何向MdeModulePkg\Application下添加一个printhelloworld,输出自己的相关信息。(可以参考MdeModulePkg\Application下的其他工程编写,这里主要是参考HelloWorld)

1 步骤

1.1 简介

添加helloworld到MdeModulePkg\Application下,并输出学号和姓名。

1.2 创建新文件

由于EDKII下的MdeModulePkg\Application里自带了一个HelloWorld示例工程,为了和其区分命名为printhelloworld。

在%workspace%\edk2\MdeModulePkg\Application\创建文件夹printhelloworld,

1.3 创建printhelloworld.c、printhelloworld.inf:

printhelloworld.c

#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
 
//ShellCEntryLib call user interface ShellAppMain
EFI_STATUS
EFIAPI
HelloWorldEnrty(
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
)
{   
  EFI_STATUS  Status = EFI_SUCCESS;
    
  Print (L"[Console]  Print HelloWorld \n"); 
  Print (L"[Console]  number \n");
  Print (L"[Console]  name\n");
  return Status;
}

printhelloworld.inf

# 写代码时把注释删掉
[Defines]
INF_VERSION             = 0x00010005   # 注意
BASE_NAME               = printhelloworld   # 注意
# 唯一,可以随便写个,不放心的话可以去guidgen.com生成
FILE_GUID               = 2d61d1f1-52c5-3617-85c4-39d5edc02bb7  
MODULE_TYPE             = UEFI_APPLICATION
VERSION_STRING          = 1.0
ENTRY_POINT             =HelloWorldEnrty  # 注意
​
[Sources]
  printhelloworld.c  # 注意
  
[Packages]
  MdePkg/MdePkg.dec
  MdeModulePkg/MdeModulePkg.dec
  
[LibraryClasses]
  UefiApplicationEntryPoint
  UefiLib

1.4 修改MdeModulePkg\MdeModulePkg.dsc

找到MdeModulePkg\MdeModulePkg.dsc,在其[components]里添加:

MdeModulePkg\Application\printhelloworld.inf\printhelloworld.inf

1.5 修改EmulatorPkg\EmulatorPkg.dsc

找到EmulatorPkg\EmulatorPkg.dsc,在其[components]里添加:(参照其他的就知道在那个位置添加了),其实这个地方我也不清楚为什么但是在target.txt里面的ACTIVE_PLATFORM就是EmulatorPkg\EmulatorPkg.dsc

MdeModulePkg\Application\printhelloworld.inf\printhelloworld.inf

1.6 运行

再次build即可(不放心可以先edksetup.bat rebuild)

之后即可以在文件夹中找到printhelloworld.efi

点击WinHost.exe,运行即可。

  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

B or D

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值