在运行EDK2的入口函数时,根据《UEFI编程实战》出现了如下报错,环境里面的文件也都存在,环境应该没有问题,当用简单的输出可以正常运行,但是使用复杂一点或者输出时间就会报错
这样的代码可以运行
#include <Uefi.h>
EFI_STATUS UefiMain(IN EFI_HANDLE Imagehandle, IN EFI_SYSTEM_TABLE *SystemTable) {
SystemTable->ConOut->OutputString(SystemTable->ConOut, L"My First UEFI HelloWorld\n");
return EFI_SUCCESS;
}
但是加一些时间或者使用全局变量就会报错 (很多我注释了,测试是否能够运行)
有没有那位小伙伴也遇见过类似的情况,求解答:
#include <Uefi.h>
#include <Library/UefiLib.h>
//#include <Library/ShellCEntryLib.h>
// #include <Library/UefiBootServicesTableLib.h> //gST,gBs
//#include <Library/UefiRuntimeServicesTableLib.h> //gRT
/***
Print a welcoming message.
Establishes the main structure of the application.
@retval 0 The application exited normally.
@retval Other An error occurred.
***/
INTN
EFIAPI
ShellAppMain (
IN UINTN Argc,
IN CHAR16 **Argv
)
{
//EFI_TIME curTime;
Print(L"Hello,this is Entry of ShellAppMain!\n");
//使用BootService和RuntimeService
// gST->BootServices->Stall(2000); //延时2秒
//gBS->Stall(2000);
// gST->RuntimeServices->GetTime(&curTime,NULL);
//gRT->GetTime(&curTime,NULL);
//Print(L"Current Time: %d-%d-%d %02d:%02d:%02d\n",curTime.Year,curTime.Month,curTime.Day,curTime.Hour,curTime.Minute,curTime.Second);
//使用SystemTable
//gST->ConOut->OutputString(gST->ConOut,L"Test SystemTable...\n\r");
return(0);
}