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 
#include 
#include 
 
//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

EDKII:第一个Helloworld_第1张图片

点击WinHost.exe,运行即可。

你可能感兴趣的:(linux,UEFI,EDKII,windows10)