Uefi协议:错误:在'Print3Hello'之前预期'=',',',';','asm'或'__attribute__'

时间:2017-10-03 06:17:22

标签: c uefi

我正在尝试编写一个基于Print2协议的简单UEFI协议。

以下是编译的整个错误:

Building ... /home/qwn/src/edk2/Print3/Print3.inf [X64]
"gcc" -g -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=Print3Strings -m64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie -fno-asynchronous-unwind-tables -Wno-address -flto -DUSING_LTO -Os -D DISABLE_NEW_DEPRECATED_INTERFACES -c -o /home/qwn/src/edk2/Build/MdeModule/DEBUG_GCC5/X64/Print3/Print3/OUTPUT/./Print3.obj -I/home/qwn/src/edk2/Print3 -I/home/qwn/src/edk2/Build/MdeModule/DEBUG_GCC5/X64/Print3/Print3/DEBUG -I/home/qwn/src/edk2/MdePkg -I/home/qwn/src/edk2/MdePkg/Include -I/home/qwn/src/edk2/MdePkg/Include/X64 -I/home/qwn/src/edk2/MdeModulePkg -I/home/qwn/src/edk2/MdeModulePkg/Include /home/qwn/src/edk2/Print3/Print3.c
/home/qwn/src/edk2/Print3/Print3.c:5:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Print3Hello’
 Print3Hello()
 ^

/home/qwn/src/edk2/Print3/Print3.c:12:3: error: ‘Print3Hello’ undeclared here (not in a function)
 Print3Hello
 ^

/home/qwn/src/edk2/Print3/Print3.c:20:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Print3Entry’
 Print3Entry(
 ^

GNUmakefile:411: recipe for target '/home/qwn/src/edk2/Build/MdeModule/DEBUG_GCC5/X64/Print3/Print3/OUTPUT/Print3.obj' failed
make: *** [/home/qwn/src/edk2/Build/MdeModule/DEBUG_GCC5/X64/Print3/Print3/OUTPUT/Print3.obj] Error 1

这是主要的.c文件

#include "Print3.h"

EFI_STATUS
EFIAPT
Print3Hello()
{
  Print(L"Hello, self defined print3 protocol \n");
  return EFI_SUCCESS; 
}

EFI_PRINT3_PROTOCOL myPrint3Protocol = {
  Print3Hello
};

//Entry function for the driver, here we install the protocol  
EFI_HANDLE print3ProtocolHandle = NULL;

EFI_STATUS
EFIAPT
Print3Entry(
  EFI_HANDLE       imageHandle,
  EFI_SYSTEM_TABLE *systemTable
)
{
  EFI_STATUS status;

  status = gBS->InstallProtocolInterface(&print3ProtocolHandle,
                                         &gEfiPrint3ProtocolGuid,
                                         &myPrint3Protocol,
                                         NULL
                                         );
  ASSERT_EFI_ERROR (status);
  reutrn status;
}

这是.h

#ifndef _PRINT3_H_
#define _PRINT3_H_

#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>


//Guid for the print 3 protocol.
#define EFI_PRINT3_PROTOCOL_GUI \
  { 0x3b777e4b, 0x93b1, 0x4985, { 0xb0, 0x55, 0x52, 0x55, 0x1b, 0x54, 0xcc, 0xcc }}

typedef
EFI_STATUS
(EFIAPI *EFI_PRINT_STRING)();


typedef struct _EFI_PRINT3_PROTOCOL {
  EFI_PRINT_STRING efiPrintHello;
}EFI_PRINT3_PROTOCOL;

extern EFI_GUID gEfiPrint3ProtocolGuid;
#endif

最后这是inf

[Defines]
 INF_VERSION                    = 1.25
 BASE_NAME                      = Print3
 FILE_GUID                      = f4df2436-242b-4e13-ae42-50c30118eff2
 MODULE_TYPE                    = UEFI_DRIVER
 VERSION_STRING                 = 1.0
 ENTRY_POINT                    = Print3Entry


[Sources]
        Print3.h
        Print3.c

[Packages]
        MdePkg/MdePkg.dec
        MdeModulePkg/MdeModulePkg.dec

[LibraryClasses]
        UefiLib
        UefiDriverEntryPoint
        UefiBootServicesTableLib

[Guids]

[Ppis]

[Protocols]
        gEfiPrint3ProtocolGuid

[FeaturePcd]

[Pcd]

Print3的GUID在MdeModule / MdeModule.dec中定义

## Print3/Print3.h
gEfiPrint3ProtocolGuid = { 0x3b777e4b, 0x93b1, 0x4985, { 0xb0, 0x55, 0x52, 0x55, 0x1b, 0x54, 0xcc, 0xcc }}

我遵循了UEFi库中实现的Print2协议。 inf文件来自print2.inf,除了我生成的GUID,我更改了变量名。

标题已在Print2协议中使用。它一定是非常愚蠢的东西,我错过了

1 个答案:

答案 0 :(得分:1)

好吧,你可能会在以后发现另一个错误,但是你得到的错误看起来是因为没有定义宏EFIAPT。我认为你的意思是EFIAPI。