將C:\EDK2\MdeModulePkg\Application中HelloWorld整個folder複製到C:\EDK2\MyPkg\Application中改名Hello,接下來修改一些地方
1.1 MyPkg\Application\Hello\Hello.inf
=============================================================
[Defines]
#為避免衝突而改
INF_VERSION = 0x00010006
#產生文件名字為 Hello.efi
BASE_NAME = hello
FILE_GUID = ab0f 9969-0a 54-4695-ace7-42fe6bb84a 1d
#模型種類:UEFI_DRIVER, DXE_DRIVER, DXE_RUNTIME_DRIVER, UEFI_APPLICATION, BASE等
MODULE_TYPE = UEFI_APPLICATION
#可自行修改
VERSION_STRING = 1.0
#入口函數
ENTRY_POINT = ShellCEntryLib
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
#主要的編譯文件
[Sources]
Hello.c
# .dec裡面定義include的路徑
[Packages]
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec
#連結的函數庫
[LibraryClasses]
ShellCEntryLib
UefiLib
=============================================================
=============================================================
[LibraryClasses]
#
# Entry point
#
…
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
=============================================================
1.3 Hello.inf 添加到 Nt32Pkg.dsc 或UnixPkg.dsc 的[Components.IA32]部分
=============================================================
[Components.IA32]
…
MdeModulePkg/Application/HelloWorld/HelloWorld.inf
MyPkg/Application/Hello/Hello.inf
1.4 Hello.c
#include <Uefi.h> #include <Library/UefiLib.h> INTN EFIAPI ShellAppMain ( IN UINTN Argc, IN CHAR16 **Argv ) { Print(L"Hello !Welcome to the world of EDK II.\n"); //注意’P’大寫 return(0); }
1.5 再一次執行以下三行指令即可
(1) build cleanall
(2) build
(3) build run
1.6 在Shell中輸入 hello