UEFI基础——测试用例Hello Word
Hello 测试用例
硬件环境:龙芯ls3a6000平台
软件环境:龙芯uefi固件
GUID获取网址:https://guidgen.com
一、创建工程
- mkdir TextPkg/
- 三个文件 Hello.c 、 Hello.inf 、HelloPkg.dsc
1.1 Hello.c
/** @fileThe application to print hello word.Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.phpTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.**/#include <Uefi.h>
#include <Library/UefiLib.h>
//#include <Library/UefiBootServicesTableLib.h>EFI_STATUS
EFIAPI
MyHello(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{Print(L"Hello World!\n");
// gST->ConOut->OutputString(SystemTable->ConOut, L"Hello World!\n");
// SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Hello World!\n"); return EFI_SUCCESS;
}
1.2 Hello.inf
## @file
# The application to print hello word.
#
# The application pops up a menu showing all the boot options referenced by
# BootOrder NV variable and user can choose to boot from one of them.
#
# Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##[Defines]INF_VERSION = 0x00010005BASE_NAME = HelloFILE_GUID = ae9fad76-2e2a-457f-bf1f-90c9c5afe889MODULE_TYPE = UEFI_APPLICATIONVERSION_STRING = 1.0 ENTRY_POINT = MyHello#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#[Sources]Hello.c[Packages]MdePkg/MdePkg.decMdeModulePkg/MdeModulePkg.dec[LibraryClasses]UefiLibUefiApplicationEntryPoint
1.3 HelloPkg.dsc
## @file
# The application to print hello word.
#
# The application pops up a menu showing all the boot options referenced by
# BootOrder NV variable and user can choose to boot from one of them.
#
# Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##[Defines]PLATFORM_NAME = HelloPkgPLATFORM_GUID = 41ee9fe9-c2aa-4f67-a6e5-5bae7560438dPLATFORM_VERSION = 0.1DSC_SPECIFICATION = 0x00010005SUPPORTED_ARCHITECTURES = LOONGARCH64BUILD_TARGETS = DEBUG|RELEASESKUID_IDENTIFIER = DEFAULTPLATFORM_DIRECTORY = LsRefCodePkg/SampleCode/Desktop/CONFIG_FILE = $(PLATFORM_DIRECTORY)/Script/Desktop.cfg!include $(CONFIG_FILE)
!if ($(CPU_TYPE) == 3A5000 || $(CPU_TYPE) == 3B5000)
!include $(PLATFORM_DIRECTORY)/Script/Loongson3a.fdf.incPLATFORM_NAME = Ls3a50007aCPU_TYPE = 3A5000CORES_PRE_NODE = 4TOT_NODE_NUM = 1APPEND_FLAG = -DLOONGSON_3A5000
!elseif ($(CPU_TYPE) == 3A6000)
!include $(PLATFORM_DIRECTORY)/Script/Loongson3a.fdf.incPLATFORM_NAME = Ls3a60007aCPU_TYPE = 3A6000CORES_PRE_NODE = 8TOT_NODE_NUM = 1APPEND_FLAG = -DLOONGSON_3A5000 -DFLAT_MODE
!elseif ($(CPU_TYPE) == 2K2000)
!include $(PLATFORM_DIRECTORY)/Script/Loongson2k.fdf.incPLATFORM_NAME = Ls2k2000CPU_TYPE = 2K2000CORES_PRE_NODE = 2TOT_NODE_NUM = 1APPEND_FLAG = -DLOONGSON_2K2000 -DLS2K2000_GMEM_SIZE="256"
!endifOUTPUT_DIRECTORY = Build/$(PLATFORM_NAME)NODE_OFFSET = 44DEFINE COMMON_BUILD_OPTIONS_FLAGS = -DLS$(CPU_TYPE) -DCLK_BASE=$(BASE_CLK) -DHIGH_MEM_BASE_ADDRESS=$(HIGH_MEM_BASE_ADDRESS) -DHT0_FREQ=$(HT0_FREQ) -DDDR_FREQ=$(MEM_FREQ) -DLS$(SOUTH_BRIDGE) -DCLK_DDR=$(DDR_CLK) -DCLK_REF=$(REF_CLK) -DMPS_ADDR=$(MPS_ADDR) -DMPS_STEP=$(MPS_STEP) -DVOL_LEVEL_HI=$(VOL_LEVEL_HI) -DVOL_LEVEL_MI=$(VOL_LEVEL_MI) -DVOL_LEVEL_LO=$(VOL_LEVEL_LO) -DCACHED_MEMORY_ADDR=$(CACHED_MEMORY_ADDR) -DUNCACHED_MEMORY_ADDR=$(UNCACHED_MEMORY_ADDR) -DTOT_NODE_NUM=$(TOT_NODE_NUM) -DCORES_PER_NODE=$(CORES_PRE_NODE) -DPCIE_CONF_BASE=$(PCIE_CONF_BASE) $(APPEND_FLAG) -DVGA_HOTP_LEVEL=$(VGA_HOTP_LEVEL) -DNODE_OFFSET=$(NODE_OFFSET) -DLS7A_LINK_ID_BUF="0"COMMON_BUILD_OPTIONS_FLAGS = -DTOT_7A_NUM="1" -DBEEP_NEW="1" $(COMMON_BUILD_OPTIONS_FLAGS)!if $(BONITO_100M) == TRUECOMMON_BUILD_OPTIONS_FLAGS = -DBONITO_100M $(COMMON_BUILD_OPTIONS_FLAGS)!elseCOMMON_BUILD_OPTIONS_FLAGS = -DBONITO_25M $(COMMON_BUILD_OPTIONS_FLAGS)!endif!if $(CPU_FREQ)COMMON_BUILD_OPTIONS_FLAGS = -DCPU_FREQ=$(CPU_FREQ) $(COMMON_BUILD_OPTIONS_FLAGS)!endif!if $(SPI_DUAL_LINE) == TRUECOMMON_BUILD_OPTIONS_FLAGS = -DSPI_DUAL_LINE $(COMMON_BUILD_OPTIONS_FLAGS)!endif!if $(COMP_TYPE) == DEBUGCOMMON_BUILD_OPTIONS_FLAGS = -DASM_DEBUG $(COMMON_BUILD_OPTIONS_FLAGS)!endif!if $(PG_MODE) == TRUECOMMON_BUILD_OPTIONS_FLAGS = -DPG_MODE $(COMMON_BUILD_OPTIONS_FLAGS)!endif!if $(GMEM_ENABLE) == TRUECOMMON_BUILD_OPTIONS_FLAGS = -DGMEM_ENABLE='1' $(COMMON_BUILD_OPTIONS_FLAGS)!elseCOMMON_BUILD_OPTIONS_FLAGS = -DGMEM_ENABLE='0' $(COMMON_BUILD_OPTIONS_FLAGS)!endif!if $(LS7A_PHYS48_TO_HT40) == TRUECOMMON_BUILD_OPTIONS_FLAGS = -DLS7A_PHYS48_TO_HT40 $(COMMON_BUILD_OPTIONS_FLAGS)!endif!if $(CODEC_VERBTABLE_SUPPORT) == TRUECOMMON_BUILD_OPTIONS_FLAGS = -DFIX_VERB_TABLE $(COMMON_BUILD_OPTIONS_FLAGS)!endif!if $(EFFICIENT_CORE_DYNAMIC_CONTROL) == TRUECOMMON_BUILD_OPTIONS_FLAGS = -DEFFICIENT_CORE_DYNAMIC_CONTROL $(COMMON_BUILD_OPTIONS_FLAGS)!endif############################################################################
#
# Defines for default states. These can be changed on the command line.
# -D FLAG=VALUE
############################################################################[BuildOptions]GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -DSPEEDUPGCC:*_*_*_CC_FLAGS = $(COMMON_BUILD_OPTIONS_FLAGS)*_*_LOONGARCH64_PP_FLAGS = $(COMMON_BUILD_OPTIONS_FLAGS)*_*_*_ASLPP_FLAGS = $(COMMON_BUILD_OPTIONS_FLAGS)*_*_*_VFRPP_FLAGS = $(COMMON_BUILD_OPTIONS_FLAGS)[LibraryClasses]UefiLib | MdePkg/Library/UefiLib/UefiLib.infUefiApplicationEntryPoint | MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.infUefiBootServicesTableLib | MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.infDebugLib | MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.infBaseLib | MdePkg/Library/BaseLib/BaseLib.infPcdLib | MdePkg/Library/BasePcdLibNull/BasePcdLibNull.infBaseMemoryLib | MdePkg/Library/BaseMemoryLib/BaseMemoryLib.infSerialPortLib | LsRefCodePkg/Library/SerialPortLib/SerialPortLib.infPrintLib | MdePkg/Library/BasePrintLib/BasePrintLib.infDebugPrintErrorLevelLib | MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.infIoLib | MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.infRegisterFilterLib | LsRefCodePkg/Core/Library/RegisterFilterLib/RegisterFilterLib.infMemoryAllocationLib | MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.infDevicePathLib | MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.infUefiRuntimeServicesTableLib | MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf[Components]TextPkg/Hello.inf
二、编译工程
2.1 配置环境变量
- export WORKSPACE=$PWD
- export EDK_TOOLS_PATH=$PWD/BaseTools/
- source edksetup.sh
2.2 执行编译
build -a LOONGARCH64 -t GCC83 -p TextPkg/HelloPkg.dsc -j log.txt
- a 指定架构
- t 指定工具链版本
- p 指定工程路径
- j 编译输出存放位置