当前位置:文档之家› UEFI-HelloWorld

UEFI-HelloWorld

用vs2008创建一个HelloWorld的UEFI程序第一步,创建工程(MakeFile Project)
第二步,创建以下文件
(1)编译命令
32位程序:
打开文件buildx86.bat,写上@call "C:\MyWorkSpace\edksetup.bat"
@call "C:\MyWorkSpace\edksetup.bat"
Build -t VS2008x86 -a IA32 -p MyFirstEfi\MyFirstEfi.dsc -m MyFirstEfi\MyFirstEfi\MyFirstEfi.inf -b DEBUG
64位程序:
打开文件buildx64.bat,写上
@call "C:\MyWorkSpace\edksetup.bat"
Build -t VS2008x86 -a X64 -p MyFirstEfi\MyFirstEfi.dsc -m MyFirstEfi\MyFirstEfi\MyFirstEfi.inf -b RELEASE
配置:
1.打开工程属性
下图中Working Directory为SecMain.exe所在文件夹
我自己的默认为:C:\MyWorkSpace\Build\NT32IA32\DEBUG_VS2008x86\IA32
(2)配置.inf
打开MyFirstEfi.inf文件写上
[Defines]
INF_VERSION = 0x000010005
BASE_NAME = MyFirstEfi
FILE_GUID = B044C901-36CB-46a6-B286-5C432ADF99AB #需要自己生成GUID MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = UefiMain
[Sources]
MyFirstEfi.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
UefiBootServicesTableLib
UefiApplicationEntryPoint
UefiLib
DebugLib
[Protocols]
(3)配置.dsc文件
打开MyFirstEfi.dsc文件写上
[Defines]
PLATFORM_NAME = MyFirstEfi
PLATFORM_GUID = 4BE41459-240C-4a1f-B79A-88F8E1F09490
PLATFORM_VERSION = 0.1
DSC_SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/NT32IA32
SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC|ARM|AARCH64
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
[LibraryClasses]
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTable Lib.inf
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntry Point.inf
UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib. inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeSe rvicesTableLib.inf
[Components]
MyFirstEfi/MyFirstEfi/MyFirstEfi.inf
(4)配置.dec文件
打开MyFirstEfi.dec文件写上
[Defines]
DEC_SPECIFINCATION = 0x00010005
PACKAGE_NAME = MyFirstEfi
PACKAGE_GUID = A39BA0F1-4D01-4304-989D-59797FB03B21 PACKAGE_VERSION = 1.0
[Includes]
Include
[LibraryClasses]
(5)编写.c文件
#include<Uefi.h>
#include<Library/UefiLib.h>
#include<Library/UefiApplicationEntryPoint.h>
#include<Library/UefiBootServicesTableLib.h>
#include<Library/UefiRuntimeServicesTableLib.h>
EFI_STATUS
EFIAPI
UefiMain(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
Status = gST->ConOut->OutputString (gST->ConOut, L"HelloWorld!\n");
return Status;
}。

相关主题