2016-03-30 1 views
0

OpenProtocolが返されました2 OpenProtocolを使用してLocateHandleBufferによって返されたハンドルを開くとき。OpenProtocolが返されました2 OpenProtocolを使用してハンドルを開くとき

メインコードを以下に示した:

//Entry Point for this application 
EFI_STATUS UefiMain (IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable)//ImageHandle and system table 
{ 
    //Define and initialize all the variables. 
    EFI_STATUS Status=EFI_SUCCESS;//zero 
    UINTN HandleIndex=0,HandleCount=0;//the index for handle buffer and the num of handle elem 
    EFI_HANDLE* DiskControllerHandles=NULL;//NULL 
    EFI_DISK_IO_PROTOCOL* DiskIOProtocol=NULL;//NULL 
    EFI_DEVICE_PATH_PROTOCOL* DiskDevicePathProtocol=NULL;//NULL 
    //the return result 
    Status=gBS->LocateHandleBuffer(ByProtocol,&gEfiDiskIoProtocolGuid,NULL,&HandleCount,&DiskControllerHandles);//Get all handles which support EFI_DISK_IO_PROTOCOL into the buffer. 
    if(EFI_ERROR(Status))//LocateHandleBuffer failed. 
    { 
     Print(L"UefiMain:gBS->LocateHandleBuffer failed,error=%d.\r\n",Status); 
     return EFI_SUCCESS;//failed 
    } 

    //Open the handle which supports EFI_DEVICE_PATH_TO_TEXT_PROTOCOL and was returned by LocateHandleBuffer previously. 
    //Loop 
    for(HandleIndex=0;HandleIndex<HandleCount;HandleIndex++) 
    { 
     DiskIOProtocol=NULL; 
     DiskDevicePathProtocol=NULL; 

     //Open each handle which supports EFI_DEVICE_PATH_PROTOCOL. 
     Status=gBS->OpenProtocol(DiskControllerHandles[HandleIndex],&gEfiDevicePathProtocolGuid,(VOID**)DiskDevicePathProtocol, 
     ImageHandle,NULL,EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);//EFI_OPEN_PROTOCOL_GET_PROTOCOL);//Here 2 was returned. I haven't known why 2 was returned here after looking up Unified Extensible Firmware Interface 2.6 
    } 

    return EFI_SUCCESS;//return 
} 

答えて

0

第三のパラメータが正しくありませんでしたので、正しいコードは以下のようにすべきである:

Status=gBS->OpenProtocol(DiskControllerHandles[HandleIndex],&gEfiDevicePathProtocolGuid,(VOID**)&DiskDevicePathProtocol, 
     ImageHandle,NULL,EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); 
関連する問題