zoukankan      html  css  js  c++  java
  • UEFI---(NT32)的第一个代码

    暑期实习,找到一份做固件的实习。跟我一直所追求的还是有一些差距。不过正是以前的积累,能够对我学习新的知识有很大帮助。

    第一个代码依然还是拥抱世界 hello world 啦

    我们需要修改三个文件

    text1.c

    text1.inf

    Nt32Pkg.dsc

    /** @file
      This is a simple shell application
    
      Copyright (c) 2008 - 2010, 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.
    
    **/
    
    #include <Uefi.h>
    #include <Library/UefiApplicationEntryPoint.h>
    #include <Library/UefiLib.h>
    
    /**
      as the real entry point for the application.
    
      @param[in] ImageHandle    The firmware allocated handle for the EFI image.
      @param[in] SystemTable    A pointer to the EFI System Table.
    
      @retval EFI_SUCCESS       The entry point is executed successfully.
      @retval other             Some error occurs when executing this entry point.
    
    **/
    EFI_STATUS
    EFIAPI
    main (
      IN EFI_HANDLE        ImageHandle,
      IN EFI_SYSTEM_TABLE  *SystemTable
      )
    {
      Print(L"hello world
    ");
      return EFI_SUCCESS;
    }
    text1.c
    ## @file
    #  Sample UEFI Application Reference EDKII Module
    #
    #  This is a simple shell application
    #
    #  Copyright (c) 2009 - 2010, 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                    = 0x00010005
      BASE_NAME                      = text1
      FILE_GUID                      = 1D73FF57-579C-40F2-BA4F-851DFE50B614
      MODULE_TYPE                    = UEFI_APPLICATION
      VERSION_STRING                 = 1.0
      ENTRY_POINT                    = main
    
    #
    # The following information is for reference only and not required by the build tools.
    #
    #  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
    #
    
    [Sources]
      text1.c
    
    [Packages]
      MdePkg/MdePkg.dec
    
    [LibraryClasses]
      UefiApplicationEntryPoint
      UefiLib
    text1.inf

    其实就编写的基本流程来说,分为一下几个步骤

    1.  复制要编写的程序模板,其中至少包括  *.c  *.inf 文件
    2. *.C 文件中,我们要做两件事情
      1.   修改想要的入口函数名
      2.        在主函数中实现想要的功能
    3.  *.inf 文件中,我们做以下事情
      1.   在defines中,
        1.        修改BASE_NAME --> 生成的模块名字
        2.        修改GUID标识(使用VS自带工具)
        3.        修改ENTRY_POINT  --> 入口函数名 (与 *.c 文件对应)
      2.      在sources中, 声明所包含的子文件。在本次实验中只包含 text1.c 一个文件
    4.   在NT32Pkg目录下找到Nt32Pkg.dsc ,将我们需要新编译的*.inf文件添加在 Components 之中完成声明。

    在编译过程中,出现了一点小问题。就是在根目录下采用 build -p Nt32PkgNt32Pkg.dsc  编译后并不能编译出新的可执行的 *.elf 文件

    只能采用build -p Nt32PkgNt32Pkg.dsc -a IA32 -m ShellPkgApplication ext1 ext1.inf  进入文件目录后编译才可以。

    另外一个问题就是如果在*.c文件中输出字符串后面不加 。 会导致字符输出不全,我的只显示   orld    四个字符。询问前辈得知是由于被覆盖,具体不详

  • 相关阅读:
    select2使用
    Jquery DataTables相关示例
    基于Cef内核的多店铺登录器(含源码)
    Navi.Soft31.产品.登录器(永久免费)
    基于JQuery EasyUI的WebMVC控件封装(含源码)
    EntityFrameWork实现部分字段获取和修改(含源码)
    基于Ado.Net的日志组件
    C#实现七牛云存储
    局域网内手机播放视频
    基于微软企业库的AOP组件(含源码)
  • 原文地址:https://www.cnblogs.com/chu-yi/p/11227457.html
Copyright © 2011-2022 走看看