UEFI(WIN10+VS2015+EDK2018)应用开发第一例

1.edksetup.bat

 

2.build -p AppPkg\AppPkg/dsc  -a  X64

main.c如下:

//#include  
//#include  
//#include  

#include  

/***
  Demonstrates basic workings of the main() function by displaying a
  welcoming message.

  Note that the UEFI command line is composed of 16-bit UCS2 wide characters.
  The easiest way to access the command line parameters is to cast Argv as:
      wchar_t **wArgv = (wchar_t **)Argv;

  @param[in]  Argc    Number of argument tokens pointed to by Argv.
  @param[in]  Argv    Array of Argc pointers to command line tokens.

  @retval  0         The application exited normally.
  @retval  Other     An error occurred.
***/
int
main (
  IN int Argc,
  IN char **Argv
  )
{

  puts("Hello there fellow Programmer.");
  puts("Welcome to the world of EDK II.");

  return 0;
}

main.inf如下:

## @file
#   A simple, basic, application showing how the Hello application could be
#   built using the "Standard C Libraries" from StdLib.
#
#  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
# 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. # # 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 = 0x00010006 BASE_NAME = Main FILE_GUID = 4ea97c46-7491-4dfd-b442-747010f3ce5f MODULE_TYPE = UEFI_APPLICATION VERSION_STRING = 0.1 ENTRY_POINT = ShellCEntryLib # # VALID_ARCHITECTURES = IA32 X64 # [Sources] Main.c [Packages] StdLib/StdLib.dec MdePkg/MdePkg.dec ShellPkg/ShellPkg.dec [LibraryClasses] LibC LibStdio

 

3.在boot目录下,生成main.efi文件

 

 

 

 

:为了像C一样使用main函数,那么我需要用到LibC。 LibC 中提供了ShellAppMain函数,我们要提供 int main(int Argc, char** Argv) 供其调用。

如果程序中用到了printf(...)等等标准C的库函数,那么一定要使用此种类型的application。 因为 ShellCEntryLib 函数中会调用ShellAppMain(...), StdLib的ShellAppMain(...) 会对stdlib 进行初始化。 然后才可以调用stdlib的函数。

 

 

 

 

 

 

 

 

你可能感兴趣的:(X86/X64汇编,memTest,UEFI)