您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ AllocatePool函数代码示例

51自学网 2021-06-01 19:46:40
  C++
这篇教程C++ AllocatePool函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中AllocatePool函数的典型用法代码示例。如果您正苦于以下问题:C++ AllocatePool函数的具体用法?C++ AllocatePool怎么用?C++ AllocatePool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了AllocatePool函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: FtwVariableSpace

/**  Writes a buffer to variable storage space, in the working block.  This function writes a buffer to variable storage space into a firmware  volume block device. The destination is specified by parameter  VariableBase. Fault Tolerant Write protocol is used for writing.  @param  VariableBase   Base address of variable to write  @param  Buffer         Point to the data buffer.  @param  BufferSize     The number of bytes of the data Buffer.  @retval EFI_SUCCESS    The function completed successfully.  @retval EFI_NOT_FOUND  Fail to locate Fault Tolerant Write protocol.  @retval EFI_ABORTED    The function could not complete successfully.**/EFI_STATUSFtwVariableSpace (  IN EFI_PHYSICAL_ADDRESS   VariableBase,  IN UINT8                  *Buffer,  IN UINTN                  BufferSize  ){  EFI_STATUS                         Status;  EFI_HANDLE                         FvbHandle;  EFI_LBA                            VarLba;  UINTN                              VarOffset;  UINT8                              *FtwBuffer;  UINTN                              FtwBufferSize;  EFI_FAULT_TOLERANT_WRITE_PROTOCOL  *FtwProtocol;  //  // Locate fault tolerant write protocol.  //  Status = GetFtwProtocol((VOID **) &FtwProtocol);  if (EFI_ERROR (Status)) {    return EFI_NOT_FOUND;  }  //  // Locate Fvb handle by address.  //  Status = GetFvbInfoByAddress (VariableBase, &FvbHandle, NULL);  if (EFI_ERROR (Status)) {    return Status;  }  //  // Get LBA and Offset by address.  //  Status = GetLbaAndOffsetByAddress (VariableBase, &VarLba, &VarOffset);  if (EFI_ERROR (Status)) {    return EFI_ABORTED;  }  //  // Prepare for the variable data.  //  FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size;  FtwBuffer     = AllocatePool (FtwBufferSize);  if (FtwBuffer == NULL) {    return EFI_OUT_OF_RESOURCES;  }  SetMem (FtwBuffer, FtwBufferSize, (UINT8) 0xff);  CopyMem (FtwBuffer, Buffer, BufferSize);  //  // FTW write record.  //  Status = FtwProtocol->Write (                          FtwProtocol,                          VarLba,         // LBA                          VarOffset,      // Offset                          FtwBufferSize,  // NumBytes                          NULL,           // PrivateData NULL                          FvbHandle,      // Fvb Handle                          FtwBuffer       // write buffer                          );  FreePool (FtwBuffer);  return Status;}
开发者ID:etiago,项目名称:vbox,代码行数:80,


示例2: BBTestQueryCapsuleCapabilitiesConformanceTest

EFI_STATUSBBTestQueryCapsuleCapabilitiesConformanceTest (  IN EFI_BB_TEST_PROTOCOL       *This,  IN VOID                       *ClientInterface,  IN EFI_TEST_LEVEL             TestLevel,  IN EFI_HANDLE                 SupportHandle  ){  EFI_STATUS                           Status;  EFI_STANDARD_TEST_LIBRARY_PROTOCOL   *StandardLib;  EFI_TEST_ASSERTION                   AssertionType;  UINT8                                *AllocatedBuffer;  EFI_CAPSULE_HEADER                  *CapsuleHeaderArray[2];  EFI_RESET_TYPE                       ResetType;  //  // Get the Standard Library Interface  //  Status = gtBS->HandleProtocol (                   SupportHandle,                   &gEfiStandardTestLibraryGuid,                   &StandardLib                   );  if (EFI_ERROR(Status)) {    return Status;  }  if (FALSE == CheckBBTestCanRunAndRecordAssertion(                  StandardLib,                   L"RT.QueryCapsuleCapabilities_Conf - QueryCapsuleCapabilities_Conf it's not Supported in EFI",                  __FILE__,                  (UINTN)__LINE__                  )) {    return EFI_SUCCESS;  }  AllocatedBuffer = (UINT8 *)AllocatePool (sizeof(EFI_CAPSULE_HEADER));  if (AllocatedBuffer == NULL) {    StandardLib->RecordAssertion (                   StandardLib,                   EFI_TEST_ASSERTION_FAILED,                   gTestGenericFailureGuid,                   L"RT.QueryCapsuleCapabilities_Conf - Allocate zero pool for EFI_CAPSULE_HEADER",                   L"%a:%d,Status - %r",                   __FILE__,                   (UINTN)__LINE__,                   Status                   );    return Status;  }  CapsuleHeaderArray[0] = (EFI_CAPSULE_HEADER *) (UINTN)AllocatedBuffer;  CapsuleHeaderArray[0]->CapsuleGuid = mEfiCapsuleHeaderGuid;  CapsuleHeaderArray[0]->HeaderSize = sizeof(EFI_CAPSULE_HEADER);  CapsuleHeaderArray[0]->CapsuleImageSize = sizeof(EFI_CAPSULE_HEADER);  CapsuleHeaderArray[1] = NULL;// When the flag is CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE and CAPSULE_FLAGS_PERSIST_ACROSS_RESET, platform will ignore the CapsuleGuid     CapsuleHeaderArray[0]->Flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE;  Status = gtRT->QueryCapsuleCapabilities(  	               CapsuleHeaderArray,   	               1,   	               NULL, //invalid  	               &ResetType);  if ((Status == EFI_INVALID_PARAMETER) || (Status == EFI_UNSUPPORTED)) {  	AssertionType = EFI_TEST_ASSERTION_PASSED;  } else {    AssertionType = EFI_TEST_ASSERTION_FAILED;  }  StandardLib->RecordAssertion (                 StandardLib,                 AssertionType,                 gMiscRuntimeServicesBBTestConformanceAssertionGuid004,                 L"RT.QueryCapsuleCapabilities - invoke QueryCapsuleCapabilities with invalid MaxiumCapsuleSize",                 L"%a:%d:Status - %r",                 __FILE__,                 (UINTN)__LINE__,                 Status                 );  FreePool (AllocatedBuffer);  return EFI_SUCCESS;}
开发者ID:JackNine,项目名称:2ndProject,代码行数:85,


示例3: FileOpen

EFI_STATUSFileOpen (  IN  EFI_FILE    *File,  OUT EFI_FILE    **NewHandle,  IN  CHAR16      *FileName,  IN  UINT64      OpenMode,  IN  UINT64      Attributes  ){  SEMIHOST_FCB  *FileFcb = NULL;  EFI_STATUS    Status   = EFI_SUCCESS;  UINTN         SemihostHandle;  CHAR8         *AsciiFileName;  UINT32        SemihostMode;  BOOLEAN       IsRoot;  if ((FileName == NULL) || (NewHandle == NULL)) {    return EFI_INVALID_PARAMETER;  }  // Semihost interface requires ASCII filenames  AsciiFileName = AllocatePool ((StrLen (FileName) + 1) * sizeof (CHAR8));  if (AsciiFileName == NULL) {    return EFI_OUT_OF_RESOURCES;  }  UnicodeStrToAsciiStr (FileName, AsciiFileName);  if ((AsciiStrCmp (AsciiFileName, "//") == 0) ||      (AsciiStrCmp (AsciiFileName, "/")  == 0) ||      (AsciiStrCmp (AsciiFileName, "")   == 0) ||      (AsciiStrCmp (AsciiFileName, ".")  == 0)) {    // Opening '/', '/', '.', or the NULL pathname is trying to open the root directory    IsRoot = TRUE;    // Root directory node doesn't have a name.    FreePool (AsciiFileName);    AsciiFileName = NULL;  } else {    // Translate EFI_FILE_MODE into Semihosting mode    if (OpenMode & EFI_FILE_MODE_WRITE) {      SemihostMode = SEMIHOST_FILE_MODE_WRITE | SEMIHOST_FILE_MODE_BINARY;    } else if (OpenMode & EFI_FILE_MODE_READ) {      SemihostMode = SEMIHOST_FILE_MODE_READ  | SEMIHOST_FILE_MODE_BINARY;    } else {      return EFI_UNSUPPORTED;    }    // Add the creation flag if necessary    if (OpenMode & EFI_FILE_MODE_CREATE) {      SemihostMode |= SEMIHOST_FILE_MODE_CREATE;    }    // Call the semihosting interface to open the file.    Status = SemihostFileOpen (AsciiFileName, SemihostMode, &SemihostHandle);    if (EFI_ERROR(Status)) {      return Status;    }        IsRoot = FALSE;  }  // Allocate a control block and fill it  FileFcb = AllocateFCB ();  if (FileFcb == NULL) {    return EFI_OUT_OF_RESOURCES;  }  FileFcb->FileName       = AsciiFileName;  FileFcb->SemihostHandle = SemihostHandle;  FileFcb->Position       = 0;  FileFcb->IsRoot         = IsRoot;  InsertTailList (&gFileList, &FileFcb->Link);  *NewHandle = &FileFcb->File;  return Status;}
开发者ID:Cutty,项目名称:edk2,代码行数:78,


示例4: PartitionInstallMbrChildHandles

/**  Install child handles if the Handle supports MBR format.  @param[in]  This              Calling context.  @param[in]  Handle            Parent Handle.  @param[in]  DiskIo            Parent DiskIo interface.  @param[in]  BlockIo           Parent BlockIo interface.  @param[in]  BlockIo2          Parent BlockIo2 interface.  @param[in]  DevicePath        Parent Device Path.  @retval EFI_SUCCESS       A child handle was added.  @retval EFI_MEDIA_CHANGED Media change was detected.  @retval Others            MBR partition was not found.**/EFI_STATUSPartitionInstallMbrChildHandles (  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,  IN  EFI_HANDLE                   Handle,  IN  EFI_DISK_IO_PROTOCOL         *DiskIo,  IN  EFI_BLOCK_IO_PROTOCOL        *BlockIo,  IN  EFI_BLOCK_IO2_PROTOCOL       *BlockIo2,  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath  ){  EFI_STATUS                Status;  MASTER_BOOT_RECORD        *Mbr;  UINT32                    ExtMbrStartingLba;  UINTN                     Index;  HARDDRIVE_DEVICE_PATH     HdDev;  HARDDRIVE_DEVICE_PATH     ParentHdDev;  EFI_STATUS                Found;  UINT32                    PartitionNumber;  EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode;  EFI_DEVICE_PATH_PROTOCOL  *LastDevicePathNode;  UINT32                    BlockSize;  UINT32                    MediaId;  EFI_LBA                   LastBlock;  Found           = EFI_NOT_FOUND;  BlockSize = BlockIo->Media->BlockSize;  MediaId   = BlockIo->Media->MediaId;  LastBlock = BlockIo->Media->LastBlock;  VBoxLogFlowFuncMarkDP(DevicePath);  Mbr = AllocatePool (BlockSize);  if (Mbr == NULL) {    return Found;  }  Status = DiskIo->ReadDisk (                     DiskIo,                     MediaId,                     0,                     BlockSize,                     Mbr                     );  if (EFI_ERROR (Status)) {    Found = Status;    goto Done;  }  if (!PartitionValidMbr (Mbr, LastBlock)) {    goto Done;  }  //  // We have a valid mbr - add each partition  //  //  // Get starting and ending LBA of the parent block device.  //  LastDevicePathNode = NULL;  ZeroMem (&ParentHdDev, sizeof (ParentHdDev));  DevicePathNode = DevicePath;  while (!IsDevicePathEnd (DevicePathNode)) {    LastDevicePathNode  = DevicePathNode;    DevicePathNode      = NextDevicePathNode (DevicePathNode);  }  if (LastDevicePathNode != NULL) {    if (DevicePathType (LastDevicePathNode) == MEDIA_DEVICE_PATH &&        DevicePathSubType (LastDevicePathNode) == MEDIA_HARDDRIVE_DP        ) {      CopyMem (&ParentHdDev, LastDevicePathNode, sizeof (ParentHdDev));    } else {      LastDevicePathNode = NULL;    }  }  PartitionNumber = 1;  ZeroMem (&HdDev, sizeof (HdDev));  HdDev.Header.Type     = MEDIA_DEVICE_PATH;  HdDev.Header.SubType  = MEDIA_HARDDRIVE_DP;  SetDevicePathNodeLength (&HdDev.Header, sizeof (HdDev));  HdDev.MBRType         = MBR_TYPE_PCAT;  HdDev.SignatureType   = SIGNATURE_TYPE_MBR;  if (LastDevicePathNode == NULL) {    ////.........这里部分代码省略.........
开发者ID:bayasist,项目名称:vbox,代码行数:101,


示例5: TruncateFile

/**  Worker function that truncate a file specified by its name to a given size.  @param[in]  FileName  The Null-terminated string of the name of the file to be opened.  @param[in]  Size      The target size for the file.  @retval  EFI_SUCCESS       The file was truncated.  @retval  EFI_DEVICE_ERROR  The last issued semi-hosting operation failed.**/STATICEFI_STATUSTruncateFile (  IN CHAR8  *FileName,  IN UINTN   Size  ){  EFI_STATUS     Status;  RETURN_STATUS  Return;  UINTN          FileHandle;  UINT8          *Buffer;  UINTN          Remaining;  UINTN          Read;  UINTN          ToRead;  Status     = EFI_DEVICE_ERROR;  FileHandle = 0;  Buffer     = NULL;  Return = SemihostFileOpen (             FileName,             SEMIHOST_FILE_MODE_READ | SEMIHOST_FILE_MODE_BINARY,             &FileHandle             );  if (RETURN_ERROR (Return)) {    goto Error;  }  Buffer = AllocatePool (Size);  if (Buffer == NULL) {    Status = EFI_OUT_OF_RESOURCES;    goto Error;  }  Read = 0;  Remaining = Size;  while (Remaining > 0) {    ToRead = Remaining;    Return = SemihostFileRead (FileHandle, &ToRead, Buffer + Read);    if (RETURN_ERROR (Return)) {      goto Error;    }    Remaining -= ToRead;    Read      += ToRead;  }  Return = SemihostFileClose (FileHandle);  FileHandle = 0;  if (RETURN_ERROR (Return)) {    goto Error;  }  Return = SemihostFileOpen (             FileName,             SEMIHOST_FILE_MODE_WRITE | SEMIHOST_FILE_MODE_BINARY,             &FileHandle             );  if (RETURN_ERROR (Return)) {    goto Error;  }  if (Size > 0) {    Return = SemihostFileWrite (FileHandle, &Size, Buffer);    if (RETURN_ERROR (Return)) {      goto Error;    }  }  Status = EFI_SUCCESS;Error:  if (FileHandle != 0) {    SemihostFileClose (FileHandle);  }  if (Buffer != NULL) {    FreePool (Buffer);  }  return (Status);}
开发者ID:AbnerChang,项目名称:edk2-staging,代码行数:92,


示例6: HttpBootSetHeader

/**  Set or update a HTTP header with the field name and corresponding value.  @param[in]  HttpIoHeader       Point to the HTTP header holder.  @param[in]  FieldName          Null terminated string which describes a field name.  @param[in]  FieldValue         Null terminated string which describes the corresponding field value.  @retval  EFI_SUCCESS           The HTTP header has been set or updated.  @retval  EFI_INVALID_PARAMETER Any input parameter is invalid.  @retval  EFI_OUT_OF_RESOURCES  Insufficient resource to complete the operation.  @retval  Other                 Unexpected error happened.  **/EFI_STATUSHttpBootSetHeader (  IN  HTTP_IO_HEADER       *HttpIoHeader,  IN  CHAR8                *FieldName,  IN  CHAR8                *FieldValue  ){  EFI_HTTP_HEADER       *Header;  UINTN                 StrSize;  CHAR8                 *NewFieldValue;    if (HttpIoHeader == NULL || FieldName == NULL || FieldValue == NULL) {    return EFI_INVALID_PARAMETER;  }  Header = HttpFindHeader (HttpIoHeader->HeaderCount, HttpIoHeader->Headers, FieldName);  if (Header == NULL) {    //    // Add a new header.    //    if (HttpIoHeader->HeaderCount >= HttpIoHeader->MaxHeaderCount) {      return EFI_OUT_OF_RESOURCES;    }    Header = &HttpIoHeader->Headers[HttpIoHeader->HeaderCount];    StrSize = AsciiStrSize (FieldName);    Header->FieldName = AllocatePool (StrSize);    if (Header->FieldName == NULL) {      return EFI_OUT_OF_RESOURCES;    }    CopyMem (Header->FieldName, FieldName, StrSize);    Header->FieldName[StrSize -1] = '/0';    StrSize = AsciiStrSize (FieldValue);    Header->FieldValue = AllocatePool (StrSize);    if (Header->FieldValue == NULL) {      FreePool (Header->FieldName);      return EFI_OUT_OF_RESOURCES;    }    CopyMem (Header->FieldValue, FieldValue, StrSize);    Header->FieldValue[StrSize -1] = '/0';    HttpIoHeader->HeaderCount++;  } else {    //    // Update an existing one.    //    StrSize = AsciiStrSize (FieldValue);    NewFieldValue = AllocatePool (StrSize);    if (NewFieldValue == NULL) {      return EFI_OUT_OF_RESOURCES;    }    CopyMem (NewFieldValue, FieldValue, StrSize);    NewFieldValue[StrSize -1] = '/0';        if (Header->FieldValue != NULL) {      FreePool (Header->FieldValue);    }    Header->FieldValue = NewFieldValue;  }  return EFI_SUCCESS;}
开发者ID:kraxel,项目名称:edk2,代码行数:76,


示例7: BootMenuUpdateBootOption

//.........这里部分代码省略.........          InitrdPath = AppendDevicePath (TempInitrdPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);          FreePool (TempInitrdPath);          // Free the InitrdPathNodes created by Support->CreateDevicePathNode()          FreePool (InitrdPathNodes);          if (InitrdPath == NULL) {            Status = EFI_OUT_OF_RESOURCES;            goto EXIT;          }          InitrdSize = GetDevicePathSize (InitrdPath);        } else {          InitrdPath = NULL;        }      }    } else {      InitrdSize = 0;    }    Print(L"Arguments to pass to the binary: ");    if (CmdLineSize > 0) {      AsciiStrnCpy (CmdLine, (CONST CHAR8*)(LinuxArguments + 1), sizeof (CmdLine));      CmdLine[sizeof (CmdLine) - 1] = '/0';    } else {      CmdLine[0] = '/0';    }    Status = EditHIInputAscii (CmdLine, BOOT_DEVICE_OPTION_MAX);    if (EFI_ERROR(Status)) {      Status = EFI_ABORTED;      goto FREE_DEVICE_PATH;    }    CmdLineSize = AsciiStrSize (CmdLine);    OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize;    BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);    BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;    BootArguments->LinuxArguments.InitrdSize = InitrdSize;    CopyMem (&BootArguments->LinuxArguments + 1, CmdLine, CmdLineSize);    CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);    OptionalData = (UINT8*)BootArguments;  } else {    Print (L"Arguments to pass to the EFI Application: ");    if (BootOption->OptionalDataSize > 0) {      IsPrintable = IsPrintableString (BootOption->OptionalData, &IsUnicode);      if (IsPrintable) {          //          // The size in bytes of the string, final zero included, should          // be equal to or at least lower than "BootOption->OptionalDataSize"          // and the "IsPrintableString()" has already tested that the length          // in number of characters is smaller than BOOT_DEVICE_OPTION_MAX,          // final '/0' included. We can thus copy the string for editing          // using "CopyMem()". Furthermore, note that in the case of an Unicode          // string "StrnCpy()" and "StrCpy()" can not be used to copy the          // string because the data pointed to by "BootOption->OptionalData"          // is not necessarily 2-byte aligned.          //        if (IsUnicode) {          CopyMem (            UnicodeCmdLine, BootOption->OptionalData,            MIN (sizeof (UnicodeCmdLine),                 BootOption->OptionalDataSize)            );        } else {          CopyMem (            CmdLine, BootOption->OptionalData,
开发者ID:FishYu1222,项目名称:edk2,代码行数:67,


示例8: DevicePathUtilitiesAppendDevicePathConformanceTest

//// TDS 3.4.3//EFI_STATUSDevicePathUtilitiesAppendDevicePathConformanceTest (  IN EFI_BB_TEST_PROTOCOL       *This,  IN VOID                       *ClientInterface,  IN EFI_TEST_LEVEL             TestLevel,  IN EFI_HANDLE                 SupportHandle  ){  EFI_STANDARD_TEST_LIBRARY_PROTOCOL  *StandardLib;  EFI_STATUS                          Status;  EFI_DEVICE_PATH_UTILITIES_PROTOCOL  *DevicePathUtilities;  EFI_TEST_ASSERTION                  AssertionType;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath1;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath2;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath3;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath4;  UINTN                               DevicePathLen1;  UINTN                               DevicePathLen2;  UINTN                               DevicePathLen3;  //  // Get the Standard Library Interface  //  Status = gtBS->HandleProtocol (                  SupportHandle,                  &gEfiStandardTestLibraryGuid,                  &StandardLib                  );  if (EFI_ERROR (Status)) {    return Status;  }  DevicePathUtilities = (EFI_DEVICE_PATH_UTILITIES_PROTOCOL *) ClientInterface;  //  // TDS 3.4.3.2.1  //  pDevicePath1 = (EFI_DEVICE_PATH *) AllocatePool (END_DEVICE_PATH_LENGTH);  SetDevicePathEndNode (pDevicePath1);  pDevicePath3  = DevicePathUtilities->CreateDeviceNode (USBNodeType, USBNodeSubType, USBNodeLength);  pDevicePath4  = DevicePathUtilities->AppendDeviceNode (pDevicePath1, pDevicePath3);  FreePool (pDevicePath1);  FreePool (pDevicePath3);  DevicePathLen2  = DevicePathUtilities->GetDevicePathSize (pDevicePath4);  pDevicePath1    = DevicePathUtilities->AppendDevicePath (NULL, pDevicePath4);  FreePool (pDevicePath4);  DevicePathLen3 = DevicePathUtilities->GetDevicePathSize (pDevicePath1);  FreePool (pDevicePath1);  if (DevicePathLen2 == DevicePathLen3) {    AssertionType = EFI_TEST_ASSERTION_PASSED;  } else {    AssertionType = EFI_TEST_ASSERTION_FAILED;  }  StandardLib->RecordAssertion (                StandardLib,                AssertionType,                gDevicePathUtilitiesBBTestFunctionAssertionGuid059,                L"EFI_DEVICE_PATH_UTILITIES_PROTOCOL - AppendDevicePath should ignore Src1 when it is set NULL",                L"%a:%d:Status - %r",                __FILE__,                (UINTN)__LINE__                );  //  // TDS 3.4.3.2.2  //  pDevicePath1 = (EFI_DEVICE_PATH *) AllocatePool (END_DEVICE_PATH_LENGTH);  if (pDevicePath1 == NULL) {    return EFI_OUT_OF_RESOURCES;  }  SetDevicePathEndNode (pDevicePath1);  DevicePathLen1  = DevicePathUtilities->GetDevicePathSize (pDevicePath1);  pDevicePath2    = DevicePathUtilities->CreateDeviceNode (PCIRootNodeType, PCIRootNodeSubType, PCIRootNodeLength);  pDevicePath3    = DevicePathUtilities->AppendDeviceNode (pDevicePath1, pDevicePath2);  FreePool (pDevicePath1);  FreePool (pDevicePath2);  pDevicePath1  = DevicePathUtilities->CreateDeviceNode (PCINodeType, PCINodeSubType, PCINodeLength);  pDevicePath2  = DevicePathUtilities->AppendDeviceNode (pDevicePath3, pDevicePath1);  FreePool (pDevicePath3);  FreePool (pDevicePath1);  DevicePathLen1  = DevicePathUtilities->GetDevicePathSize (pDevicePath2);  pDevicePath1    = DevicePathUtilities->AppendDevicePath (pDevicePath2, NULL);  FreePool (pDevicePath2);  DevicePathLen3 = DevicePathUtilities->GetDevicePathSize (pDevicePath1);  FreePool (pDevicePath1);  if (DevicePathLen1 == DevicePathLen3) {    AssertionType = EFI_TEST_ASSERTION_PASSED;  } else {    AssertionType = EFI_TEST_ASSERTION_FAILED;//.........这里部分代码省略.........
开发者ID:JackNine,项目名称:2ndProject,代码行数:101,


示例9: DevicePathUtilitiesAppendDevicePathInstanceConformanceTest

//// TDS 3.4.4//EFI_STATUSDevicePathUtilitiesAppendDevicePathInstanceConformanceTest (  IN EFI_BB_TEST_PROTOCOL       *This,  IN VOID                       *ClientInterface,  IN EFI_TEST_LEVEL             TestLevel,  IN EFI_HANDLE                 SupportHandle  ){  EFI_STANDARD_TEST_LIBRARY_PROTOCOL  *StandardLib;  EFI_STATUS                          Status;  EFI_DEVICE_PATH_UTILITIES_PROTOCOL  *DevicePathUtilities;  EFI_TEST_ASSERTION                  AssertionType;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath1;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath2;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath3;  //  // Get the Standard Library Interface  //  Status = gtBS->HandleProtocol (                  SupportHandle,                  &gEfiStandardTestLibraryGuid,                  &StandardLib                  );  if (EFI_ERROR (Status)) {    return Status;  }  DevicePathUtilities = (EFI_DEVICE_PATH_UTILITIES_PROTOCOL *) ClientInterface;  //  // TDS 3.4.4.2.1  //  pDevicePath1 = (EFI_DEVICE_PATH *) AllocatePool (END_DEVICE_PATH_LENGTH);  if (pDevicePath1 == NULL) {    return EFI_OUT_OF_RESOURCES;  }  SetDevicePathEndNode (pDevicePath1);  pDevicePath2  = DevicePathUtilities->CreateDeviceNode (PCIRootNodeType, PCIRootNodeSubType, PCIRootNodeLength);  pDevicePath3  = DevicePathUtilities->AppendDeviceNode (pDevicePath1, pDevicePath2);  FreePool (pDevicePath1);  FreePool (pDevicePath2);  pDevicePath1  = DevicePathUtilities->CreateDeviceNode (PCINodeType, PCINodeSubType, PCINodeLength);  pDevicePath2  = DevicePathUtilities->AppendDeviceNode (pDevicePath3, pDevicePath1);  FreePool (pDevicePath3);  FreePool (pDevicePath1);  pDevicePath1 = DevicePathUtilities->AppendDevicePathInstance (pDevicePath2, NULL);  FreePool (pDevicePath2);  if (pDevicePath1 == NULL) {    AssertionType = EFI_TEST_ASSERTION_PASSED;  } else {    AssertionType = EFI_TEST_ASSERTION_FAILED;  }  StandardLib->RecordAssertion (                StandardLib,                AssertionType,                gDevicePathUtilitiesBBTestFunctionAssertionGuid062,                L"EFI_DEVICE_PATH_UTILITIES_PROTOCOL - AppendDevicePathInstance should not succeed with DevicePathInstance set to be NULL",                L"%a:%d:Status - %r",                __FILE__,                (UINTN)__LINE__                );  return EFI_SUCCESS;}
开发者ID:JackNine,项目名称:2ndProject,代码行数:74,


示例10: IpSecCryptoIoHash

/**  Digests the Payload and store the result into the OutData.  This function calls relevant Hash interface from CryptoLib according to  the input alogrithm ID. It computes all datas from InDataFragment and output  the result into the OutData buffer. If the OutDataSize is larger than the related  Hash alogrithm output size, return EFI_INVALID_PARAMETER.  @param[in]      AlgorithmId     The authentication Identification.  @param[in]      InDataFragment  A list contains all data to be authenticated.  @param[in]      FragmentCount   The size of the InDataFragment.  @param[out]     OutData         For in, the buffer to receive the output data.                                  For out, the buffer contains the authenticated data.  @param[in]      OutDataSize     The size of the buffer of OutData.  @retval EFI_UNSUPPORTED       If the AuthAlg is not in the support list.  @retval EFI_SUCCESS           Authenticated the payload successfully.  @retval EFI_INVALID_PARAMETER If the OutDataSize is larger than the related Hash                                algorithm could handle.  @retval otherwise             Authentication of the payload failed.**/EFI_STATUSIpSecCryptoIoHash (  IN     CONST UINT8              AlgorithmId,  IN           HASH_DATA_FRAGMENT *InDataFragment,  IN           UINTN              FragmentCount,     OUT       UINT8              *OutData,  IN           UINTN              OutDataSize  ){  UINTN        ContextSize;  UINTN        Index;  UINT8        FragmentIndex;  UINT8        *HashContext;  EFI_STATUS   Status;  UINT8        *OutHashData;  UINTN        OutHashSize;  Status      = EFI_UNSUPPORTED;  OutHashData = NULL;  OutHashSize = IpSecGetHmacDigestLength (AlgorithmId);  //  // If the expected hash data size is larger than the related Hash algorithm  // output length, return EFI_INVALID_PARAMETER.  //  if (OutDataSize > OutHashSize) {    return EFI_INVALID_PARAMETER;  }  OutHashData = AllocatePool (OutHashSize);  if (OutHashData == NULL) {    return EFI_OUT_OF_RESOURCES;  }  switch (AlgorithmId) {  case IKE_AALG_NONE:  case IKE_AALG_NULL:    return EFI_SUCCESS;  case IKE_AALG_SHA1HMAC:    Index = IpSecGetIndexFromAuthList (AlgorithmId);    if (Index == -1) {      return Status;    }    //    // Get Context Size    //    ContextSize = mIpsecHashAlgorithmList[Index].HashGetContextSize();    HashContext = AllocateZeroPool (ContextSize);    if (HashContext == NULL) {      Status = EFI_OUT_OF_RESOURCES;      goto Exit;    }    //    // Initiate Hash context and hash the input data.    //    if (mIpsecHashAlgorithmList[Index].HashInitiate(HashContext)) {      for (FragmentIndex = 0; FragmentIndex < FragmentCount; FragmentIndex++) {        if (!mIpsecHashAlgorithmList[Index].HashUpdate (                HashContext,                InDataFragment[FragmentIndex].Data,                InDataFragment[FragmentIndex].DataSize                )          ) {          goto Exit;        }      }      if (mIpsecHashAlgorithmList[Index].HashFinal (HashContext, OutHashData)) {        //        // In some cases, like the Icv computing, the Icv size might be less than        // the key length size, so copy the part of hash data to the OutData.        //        CopyMem (OutData, OutHashData, OutDataSize);        Status = EFI_SUCCESS;      }      goto Exit;//.........这里部分代码省略.........
开发者ID:jeppeter,项目名称:vbox,代码行数:101,


示例11: DevicePathUtilitiesAppendDeviceNodeConformanceTest

//// TDS 3.4.2//EFI_STATUSDevicePathUtilitiesAppendDeviceNodeConformanceTest (  IN EFI_BB_TEST_PROTOCOL       *This,  IN VOID                       *ClientInterface,  IN EFI_TEST_LEVEL             TestLevel,  IN EFI_HANDLE                 SupportHandle  ){  EFI_STANDARD_TEST_LIBRARY_PROTOCOL  *StandardLib;  EFI_STATUS                          Status;  EFI_DEVICE_PATH_UTILITIES_PROTOCOL  *DevicePathUtilities;  EFI_TEST_ASSERTION                  AssertionType;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath1;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath2;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath3;  EFI_DEVICE_PATH_PROTOCOL            *pDevicePath4;  //  // Get the Standard Library Interface  //  Status = gtBS->HandleProtocol (                  SupportHandle,                  &gEfiStandardTestLibraryGuid,                  &StandardLib                  );  if (EFI_ERROR (Status)) {    return Status;  }  DevicePathUtilities = (EFI_DEVICE_PATH_UTILITIES_PROTOCOL *) ClientInterface;  //  // TDS 3.4.2.2.1  //  pDevicePath1 = (EFI_DEVICE_PATH *) AllocatePool (END_DEVICE_PATH_LENGTH);  if (pDevicePath1 == NULL) {    return EFI_OUT_OF_RESOURCES;  }  SetDevicePathEndNode (pDevicePath1);  pDevicePath2  = DevicePathUtilities->CreateDeviceNode (PCIRootNodeType, PCIRootNodeSubType, PCIRootNodeLength);  pDevicePath4  = DevicePathUtilities->AppendDeviceNode (pDevicePath1, pDevicePath2);  pDevicePath3  = DevicePathUtilities->AppendDeviceNode (NULL, pDevicePath2);  if ((pDevicePath3 != NULL) && (EfiCompareMem(pDevicePath3, pDevicePath4, DevicePathUtilities->GetDevicePathSize (pDevicePath3)) == 0)) {    AssertionType = EFI_TEST_ASSERTION_PASSED;  } else {    AssertionType = EFI_TEST_ASSERTION_FAILED;  }  if (pDevicePath3 != NULL) {    FreePool (pDevicePath3);  }  StandardLib->RecordAssertion (                StandardLib,                AssertionType,                gDevicePathUtilitiesBBTestFunctionAssertionGuid054,                L"EFI_DEVICE_PATH_UTILITIES_PROTOCOL - AppendDeviceNode should return a copy of DeviceNode if DevicePath is NULL",                L"%a:%d",                __FILE__,                (UINTN)__LINE__                );  //  // TDS 3.4.2.2.2  //  pDevicePath3 = DevicePathUtilities->AppendDeviceNode (pDevicePath4, NULL);  if ((pDevicePath3 != NULL) && (EfiCompareMem(pDevicePath3, pDevicePath4, DevicePathUtilities->GetDevicePathSize (pDevicePath3)) == 0)) {    AssertionType = EFI_TEST_ASSERTION_PASSED;  } else {    AssertionType = EFI_TEST_ASSERTION_FAILED;  }  if (pDevicePath2 != NULL) {    FreePool(pDevicePath2);  }  if (pDevicePath3 != NULL) {    FreePool(pDevicePath3);  }  if (pDevicePath4 != NULL) {    FreePool(pDevicePath4);  }  StandardLib->RecordAssertion (                StandardLib,                AssertionType,                gDevicePathUtilitiesBBTestFunctionAssertionGuid055,                L"EFI_DEVICE_PATH_UTILITIES_PROTOCOL - AppendDeviceNode should return a copy of DevicePath if DeviceNode is NULL",                L"%a:%d",                __FILE__,                (UINTN)__LINE__                );  pDevicePath3 = DevicePathUtilities->AppendDeviceNode (NULL, NULL);  if ((pDevicePath3 != NULL) && (EfiCompareMem(pDevicePath3, pDevicePath1, DevicePathUtilities->GetDevicePathSize (pDevicePath3)) == 0)) {//.........这里部分代码省略.........
开发者ID:JackNine,项目名称:2ndProject,代码行数:101,


示例12: CreateNestedFmp

/**  Append a capsule header on top of current image.  This function follows Windows UEFI Firmware Update Platform document.  @retval EFI_SUCCESS            The capsule header is appended.  @retval EFI_UNSUPPORTED        Input parameter is not valid.  @retval EFI_OUT_OF_RESOURCES   No enough resource to append capsule header.**/EFI_STATUSCreateNestedFmp (  VOID  ){  CHAR16                                        *OutputCapsuleName;  VOID                                          *CapsuleBuffer;  UINTN                                         FileSize;  CHAR16                                        *CapsuleName;  UINT8                                         *FullCapsuleBuffer;  UINTN                                         FullCapsuleBufferSize;  EFI_CAPSULE_HEADER                            *NestedCapsuleHeader;  EFI_GUID                                      *ImageTypeId;  UINT32                                        FwType;  EFI_STATUS                                    Status;  if (Argc != 5) {    Print(L"CapsuleApp: Incorrect parameter count./n");    return EFI_UNSUPPORTED;  }  if (StrCmp(Argv[3], L"-O") != 0) {    Print(L"CapsuleApp: NO output capsule name./n");    return EFI_UNSUPPORTED;  }  OutputCapsuleName = Argv[4];  CapsuleBuffer = NULL;  FileSize = 0;  FullCapsuleBuffer = NULL;  CapsuleName = Argv[2];  Status = ReadFileToBuffer(CapsuleName, &FileSize, &CapsuleBuffer);  if (EFI_ERROR(Status)) {    Print(L"CapsuleApp: Capsule image (%s) is not found./n", CapsuleName);    goto Done;  }  ImageTypeId = GetCapsuleImageTypeId(CapsuleBuffer);  if (ImageTypeId == NULL) {    Print(L"CapsuleApp: Capsule ImageTypeId is not found./n");    goto Done;  }  FwType = GetEsrtFwType(ImageTypeId);  if ((FwType != ESRT_FW_TYPE_SYSTEMFIRMWARE) && (FwType != ESRT_FW_TYPE_DEVICEFIRMWARE)) {    Print(L"CapsuleApp: Capsule FwType is invalid./n");    goto Done;  }  FullCapsuleBufferSize = NESTED_CAPSULE_HEADER_SIZE + FileSize;  FullCapsuleBuffer = AllocatePool(FullCapsuleBufferSize);  if (FullCapsuleBuffer == NULL) {    Print(L"CapsuleApp: Capsule Buffer size (0x%x) too big./n", FullCapsuleBufferSize);    Status = EFI_OUT_OF_RESOURCES;    goto Done;  }  NestedCapsuleHeader = (EFI_CAPSULE_HEADER *)FullCapsuleBuffer;  ZeroMem(NestedCapsuleHeader, NESTED_CAPSULE_HEADER_SIZE);  CopyGuid(&NestedCapsuleHeader->CapsuleGuid, ImageTypeId);  NestedCapsuleHeader->HeaderSize = NESTED_CAPSULE_HEADER_SIZE;  NestedCapsuleHeader->Flags = (FwType == ESRT_FW_TYPE_SYSTEMFIRMWARE) ? SYSTEM_FIRMWARE_FLAG : DEVICE_FIRMWARE_FLAG;  NestedCapsuleHeader->CapsuleImageSize = (UINT32)FullCapsuleBufferSize;  CopyMem((UINT8 *)NestedCapsuleHeader + NestedCapsuleHeader->HeaderSize, CapsuleBuffer, FileSize);  Status = WriteFileFromBuffer(OutputCapsuleName, FullCapsuleBufferSize, FullCapsuleBuffer);  Print(L"CapsuleApp: Write %s %r/n", OutputCapsuleName, Status);Done:  if (CapsuleBuffer != NULL) {    FreePool(CapsuleBuffer);  }  if (FullCapsuleBuffer != NULL) {    FreePool(FullCapsuleBuffer);  }  return Status;}
开发者ID:b-man,项目名称:edk2,代码行数:88,


示例13: CreateBmpFmp

/**  Create UX capsule.  @retval EFI_SUCCESS            The capsule header is appended.  @retval EFI_UNSUPPORTED        Input parameter is not valid.  @retval EFI_OUT_OF_RESOURCES   No enough resource to create UX capsule.**/EFI_STATUSCreateBmpFmp (  VOID  ){  CHAR16                                        *OutputCapsuleName;  VOID                                          *BmpBuffer;  UINTN                                         FileSize;  CHAR16                                        *BmpName;  UINT8                                         *FullCapsuleBuffer;  UINTN                                         FullCapsuleBufferSize;  EFI_DISPLAY_CAPSULE                           *DisplayCapsule;  EFI_STATUS                                    Status;  EFI_GRAPHICS_OUTPUT_PROTOCOL                  *Gop;  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION          *Info;  EFI_GRAPHICS_OUTPUT_BLT_PIXEL                 *GopBlt;  UINTN                                         GopBltSize;  UINTN                                         Height;  UINTN                                         Width;  Status = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&Gop);  if (EFI_ERROR(Status)) {    Print(L"CapsuleApp: NO GOP is found./n");    return EFI_UNSUPPORTED;  }  Info = Gop->Mode->Info;  Print(L"Current GOP: Mode - %d, ", Gop->Mode->Mode);  Print(L"HorizontalResolution - %d, ", Info->HorizontalResolution);  Print(L"VerticalResolution - %d/n", Info->VerticalResolution);  // HorizontalResolution >= BMP_IMAGE_HEADER.PixelWidth  // VerticalResolution   >= BMP_IMAGE_HEADER.PixelHeight  if (Argc != 5) {    Print(L"CapsuleApp: Incorrect parameter count./n");    return EFI_UNSUPPORTED;  }  if (StrCmp(Argv[3], L"-O") != 0) {    Print(L"CapsuleApp: NO output capsule name./n");    return EFI_UNSUPPORTED;  }  OutputCapsuleName = Argv[4];  BmpBuffer = NULL;  FileSize = 0;  FullCapsuleBuffer = NULL;  BmpName = Argv[2];  Status = ReadFileToBuffer(BmpName, &FileSize, &BmpBuffer);  if (EFI_ERROR(Status)) {    Print(L"CapsuleApp: BMP image (%s) is not found./n", BmpName);    goto Done;  }  GopBlt = NULL;  Status = TranslateBmpToGopBlt (             BmpBuffer,             FileSize,             &GopBlt,             &GopBltSize,             &Height,             &Width             );  if (EFI_ERROR(Status)) {    Print(L"CapsuleApp: BMP image (%s) is not valid./n", BmpName);    goto Done;  }  if (GopBlt != NULL) {    FreePool (GopBlt);  }  Print(L"BMP image (%s), Width - %d, Height - %d/n", BmpName, Width, Height);  if (Height > Info->VerticalResolution) {    Status = EFI_INVALID_PARAMETER;    Print(L"CapsuleApp: BMP image (%s) height is larger than current resolution./n", BmpName);    goto Done;  }  if (Width > Info->HorizontalResolution) {    Status = EFI_INVALID_PARAMETER;    Print(L"CapsuleApp: BMP image (%s) width is larger than current resolution./n", BmpName);    goto Done;  }  FullCapsuleBufferSize = sizeof(EFI_DISPLAY_CAPSULE) + FileSize;  FullCapsuleBuffer = AllocatePool(FullCapsuleBufferSize);  if (FullCapsuleBuffer == NULL) {    Print(L"CapsuleApp: Capsule Buffer size (0x%x) too big./n", FullCapsuleBufferSize);    Status = EFI_OUT_OF_RESOURCES;    goto Done;  }  DisplayCapsule = (EFI_DISPLAY_CAPSULE *)FullCapsuleBuffer;  CopyGuid(&DisplayCapsule->CapsuleHeader.CapsuleGuid, &gWindowsUxCapsuleGuid);//.........这里部分代码省略.........
开发者ID:b-man,项目名称:edk2,代码行数:101,


示例14: EfiBootManagerLoadOptionToVariable

/**  Create the Boot####, Driver####, SysPrep####, PlatformRecovery#### variable  from the load option.  @param  LoadOption      Pointer to the load option.  @retval EFI_SUCCESS     The variable was created.  @retval Others          Error status returned by RT->SetVariable.**/EFI_STATUSEFIAPIEfiBootManagerLoadOptionToVariable (  IN CONST EFI_BOOT_MANAGER_LOAD_OPTION     *Option  ){  EFI_STATUS                       Status;  UINTN                            VariableSize;  UINT8                            *Variable;  UINT8                            *Ptr;  CHAR16                           OptionName[BM_OPTION_NAME_LEN];  CHAR16                           *Description;  CHAR16                           NullChar;  EDKII_VARIABLE_LOCK_PROTOCOL     *VariableLock;  UINT32                           VariableAttributes;  if ((Option->OptionNumber == LoadOptionNumberUnassigned) ||      (Option->FilePath == NULL) ||      ((UINT32) Option->OptionType >= LoadOptionTypeMax)     ) {    return EFI_INVALID_PARAMETER;  }  //  // Convert NULL description to empty description  //  NullChar    = L'/0';  Description = Option->Description;  if (Description == NULL) {    Description = &NullChar;  }  /*  UINT32                      Attributes;  UINT16                      FilePathListLength;  CHAR16                      Description[];  EFI_DEVICE_PATH_PROTOCOL    FilePathList[];  UINT8                       OptionalData[];TODO: FilePathList[] IS:A packed array of UEFI device paths.  The first element of thearray is a device path that describes the device and location of theImage for this load option.  The FilePathList[0] is specificto the device type.  Other device paths may optionally exist in theFilePathList, but their usage is OSV specific. Each elementin the array is variable length, and ends at the device path endstructure.  */  VariableSize = sizeof (Option->Attributes)               + sizeof (UINT16)               + StrSize (Description)               + GetDevicePathSize (Option->FilePath)               + Option->OptionalDataSize;  Variable     = AllocatePool (VariableSize);  ASSERT (Variable != NULL);  Ptr             = Variable;  WriteUnaligned32 ((UINT32 *) Ptr, Option->Attributes);  Ptr            += sizeof (Option->Attributes);  WriteUnaligned16 ((UINT16 *) Ptr, (UINT16) GetDevicePathSize (Option->FilePath));  Ptr            += sizeof (UINT16);  CopyMem (Ptr, Description, StrSize (Description));  Ptr            += StrSize (Description);  CopyMem (Ptr, Option->FilePath, GetDevicePathSize (Option->FilePath));  Ptr            += GetDevicePathSize (Option->FilePath);  CopyMem (Ptr, Option->OptionalData, Option->OptionalDataSize);  UnicodeSPrint (OptionName, sizeof (OptionName), L"%s%04x", mBmLoadOptionName[Option->OptionType], Option->OptionNumber);  VariableAttributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE;  if (Option->OptionType == LoadOptionTypePlatformRecovery) {    //    // Lock the PlatformRecovery####    //    Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);    if (!EFI_ERROR (Status)) {      Status = VariableLock->RequestToLock (VariableLock, OptionName, &gEfiGlobalVariableGuid);      ASSERT_EFI_ERROR (Status);    }    VariableAttributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;  }  Status = gRT->SetVariable (                  OptionName,                  &gEfiGlobalVariableGuid,                  VariableAttributes,                  VariableSize,//.........这里部分代码省略.........
开发者ID:shijunjing,项目名称:edk2,代码行数:101,


示例15: PartitionRestoreGptTable

/**  Restore Partition Table to its alternate place  (Primary -> Backup or Backup -> Primary).  @param[in]  BlockIo     Parent BlockIo interface.  @param[in]  DiskIo      Disk Io Protocol.  @param[in]  PartHeader  Partition table header structure.  @retval TRUE      Restoring succeeds  @retval FALSE     Restoring failed**/BOOLEANPartitionRestoreGptTable (  IN  EFI_BLOCK_IO_PROTOCOL       *BlockIo,  IN  EFI_DISK_IO_PROTOCOL        *DiskIo,  IN  EFI_PARTITION_TABLE_HEADER  *PartHeader  ){  EFI_STATUS                  Status;  UINTN                       BlockSize;  EFI_PARTITION_TABLE_HEADER  *PartHdr;  EFI_LBA                     PEntryLBA;  UINT8                       *Ptr;  UINT32                      MediaId;  PartHdr   = NULL;  Ptr       = NULL;  BlockSize = BlockIo->Media->BlockSize;  MediaId   = BlockIo->Media->MediaId;  PartHdr   = AllocateZeroPool (BlockSize);  if (PartHdr == NULL) {    DEBUG ((EFI_D_ERROR, "Allocate pool error/n"));    return FALSE;  }  PEntryLBA = (PartHeader->MyLBA == PRIMARY_PART_HEADER_LBA) ? /                             (PartHeader->LastUsableLBA + 1) : /                             (PRIMARY_PART_HEADER_LBA + 1);  CopyMem (PartHdr, PartHeader, sizeof (EFI_PARTITION_TABLE_HEADER));  PartHdr->MyLBA              = PartHeader->AlternateLBA;  PartHdr->AlternateLBA       = PartHeader->MyLBA;  PartHdr->PartitionEntryLBA  = PEntryLBA;  PartitionSetCrc ((EFI_TABLE_HEADER *) PartHdr);  Status = DiskIo->WriteDisk (                     DiskIo,                     MediaId,                     MultU64x32 (PartHdr->MyLBA, (UINT32) BlockSize),                     BlockSize,                     PartHdr                     );  if (EFI_ERROR (Status)) {    goto Done;  }  Ptr = AllocatePool (PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry);  if (Ptr == NULL) {    DEBUG ((EFI_D_ERROR, " Allocate pool error/n"));    Status = EFI_OUT_OF_RESOURCES;    goto Done;  }  Status = DiskIo->ReadDisk (                    DiskIo,                    MediaId,                    MultU64x32(PartHeader->PartitionEntryLBA, (UINT32) BlockSize),                    PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry,                    Ptr                    );  if (EFI_ERROR (Status)) {    goto Done;  }  Status = DiskIo->WriteDisk (                    DiskIo,                    MediaId,                    MultU64x32(PEntryLBA, (UINT32) BlockSize),                    PartHeader->NumberOfPartitionEntries * PartHeader->SizeOfPartitionEntry,                    Ptr                    );Done:  FreePool (PartHdr);  if (Ptr != NULL) {    FreePool (Ptr);  }  if (EFI_ERROR (Status)) {    return FALSE;  }  return TRUE;}
开发者ID:etiago,项目名称:vbox,代码行数:100,


示例16: QemuVideoGraphicsOutputSetMode

EFI_STATUSEFIAPIQemuVideoGraphicsOutputSetMode (  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL *This,  IN  UINT32                       ModeNumber  )/*++Routine Description:  Graphics Output protocol interface to set video mode  Arguments:    This             - Protocol instance pointer.    ModeNumber       - The mode number to be set.  Returns:    EFI_SUCCESS      - Graphics mode was changed.    EFI_DEVICE_ERROR - The device had an error and could not complete the request.    EFI_UNSUPPORTED  - ModeNumber is not supported by this device.--*/{  QEMU_VIDEO_PRIVATE_DATA    *Private;  QEMU_VIDEO_MODE_DATA       *ModeData;//  UINTN                             Count;  Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);  if (ModeNumber >= This->Mode->MaxMode) {    return EFI_UNSUPPORTED;  }  ModeData = &Private->ModeData[ModeNumber];  if (Private->LineBuffer) {    gBS->FreePool (Private->LineBuffer);  }  Private->LineBuffer = AllocatePool (4 * ModeData->HorizontalResolution);  if (Private->LineBuffer == NULL) {    return EFI_OUT_OF_RESOURCES;  }  switch (Private->Variant) {  case QEMU_VIDEO_CIRRUS_5430:  case QEMU_VIDEO_CIRRUS_5446:    InitializeCirrusGraphicsMode (Private, &QemuVideoCirrusModes[ModeData->InternalModeIndex]);    break;  case QEMU_VIDEO_BOCHS_MMIO:  case QEMU_VIDEO_BOCHS:    InitializeBochsGraphicsMode (Private, &QemuVideoBochsModes[ModeData->InternalModeIndex]);    break;  default:    ASSERT (FALSE);    gBS->FreePool (Private->LineBuffer);    Private->LineBuffer = NULL;    return EFI_DEVICE_ERROR;  }  This->Mode->Mode = ModeNumber;  This->Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;  This->Mode->Info->VerticalResolution = ModeData->VerticalResolution;  This->Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);  QemuVideoCompleteModeData (Private, This->Mode);  BltLibConfigure (    (VOID*)(UINTN) This->Mode->FrameBufferBase,    This->Mode->Info    );  return EFI_SUCCESS;}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:74,


示例17: HttpBootDns

/**  Retrieve the host address using the EFI_DNS6_PROTOCOL.  @param[in]  Private             The pointer to the driver's private data.  @param[in]  HostName            Pointer to buffer containing hostname.  @param[out] IpAddress           On output, pointer to buffer containing IPv6 address.  @retval EFI_SUCCESS             Operation succeeded.  @retval EFI_DEVICE_ERROR        An unexpected network error occurred.  @retval Others                  Other errors as indicated.  **/EFI_STATUSHttpBootDns (  IN     HTTP_BOOT_PRIVATE_DATA   *Private,  IN     CHAR16                   *HostName,     OUT EFI_IPv6_ADDRESS         *IpAddress   ){  EFI_STATUS                      Status;  EFI_DNS6_PROTOCOL               *Dns6;  EFI_DNS6_CONFIG_DATA            Dns6ConfigData;  EFI_DNS6_COMPLETION_TOKEN       Token;  EFI_HANDLE                      Dns6Handle;  EFI_IP6_CONFIG_PROTOCOL         *Ip6Config;  EFI_IPv6_ADDRESS                *DnsServerList;  UINTN                           DnsServerListCount;  UINTN                           DataSize;  BOOLEAN                         IsDone;      DnsServerList       = NULL;  DnsServerListCount  = 0;  Dns6                = NULL;  Dns6Handle          = NULL;  ZeroMem (&Token, sizeof (EFI_DNS6_COMPLETION_TOKEN));    //  // Get DNS server list from EFI IPv6 Configuration protocol.  //  Status = gBS->HandleProtocol (Private->Controller, &gEfiIp6ConfigProtocolGuid, (VOID **) &Ip6Config);  if (!EFI_ERROR (Status)) {    //    // Get the required size.    //    DataSize = 0;    Status = Ip6Config->GetData (Ip6Config, Ip6ConfigDataTypeDnsServer, &DataSize, NULL);    if (Status == EFI_BUFFER_TOO_SMALL) {      DnsServerList = AllocatePool (DataSize);      if (DnsServerList == NULL) {        return EFI_OUT_OF_RESOURCES;      }        Status = Ip6Config->GetData (Ip6Config, Ip6ConfigDataTypeDnsServer, &DataSize, DnsServerList);      if (EFI_ERROR (Status)) {        FreePool (DnsServerList);        DnsServerList = NULL;      } else {        DnsServerListCount = DataSize / sizeof (EFI_IPv6_ADDRESS);      }    }  }  //  // Create a DNSv6 child instance and get the protocol.  //  Status = NetLibCreateServiceChild (             Private->Controller,             Private->Ip6Nic->ImageHandle,             &gEfiDns6ServiceBindingProtocolGuid,             &Dns6Handle             );  if (EFI_ERROR (Status)) {    goto Exit;  }     Status = gBS->OpenProtocol (                  Dns6Handle,                  &gEfiDns6ProtocolGuid,                  (VOID **) &Dns6,                  Private->Ip6Nic->ImageHandle,                  Private->Controller,                  EFI_OPEN_PROTOCOL_BY_DRIVER                  );  if (EFI_ERROR (Status)) {    goto Exit;  }  //  // Configure DNS6 instance for the DNS server address and protocol.  //  ZeroMem (&Dns6ConfigData, sizeof (EFI_DNS6_CONFIG_DATA));  Dns6ConfigData.DnsServerCount = (UINT32)DnsServerListCount;  Dns6ConfigData.DnsServerList  = DnsServerList;  Dns6ConfigData.EnableDnsCache = TRUE;  Dns6ConfigData.Protocol       = EFI_IP_PROTO_UDP;  IP6_COPY_ADDRESS (&Dns6ConfigData.StationIp,&Private->StationIp.v6);  Status = Dns6->Configure (                    Dns6,                    &Dns6ConfigData                    );  if (EFI_ERROR (Status)) {    goto Exit;//.........这里部分代码省略.........
开发者ID:kraxel,项目名称:edk2,代码行数:101,


示例18: UtilIterateVariables

EFI_STATUSUtilIterateVariables (  IN VARIABLE_ITERATION_CALLBACK CallbackFunction,  IN VOID                        *Context){  RETURN_STATUS               Status;  UINTN                       VariableNameBufferSize;  UINTN                       VariableNameSize;  CHAR16                      *VariableName;  EFI_GUID                    VendorGuid;  UINTN                       VariableDataBufferSize;  UINTN                       VariableDataSize;  VOID                        *VariableData;  UINT32                      VariableAttributes;  VOID                        *NewBuffer;  //  // Initialize the variable name and data buffer variables.  //  VariableNameBufferSize = sizeof (CHAR16);  VariableName = AllocateZeroPool (VariableNameBufferSize);  VariableDataBufferSize = 0;  VariableData = NULL;  for (;;) {    //    // Get the next variable name and guid    //    VariableNameSize = VariableNameBufferSize;    Status = gRT->GetNextVariableName (                    &VariableNameSize,                    VariableName,                    &VendorGuid                    );    if (Status == EFI_BUFFER_TOO_SMALL) {      //      // The currently allocated VariableName buffer is too small,      // so we allocate a larger buffer, and copy the old buffer      // to it.      //      NewBuffer = AllocatePool (VariableNameSize);      if (NewBuffer == NULL) {        Status = EFI_OUT_OF_RESOURCES;        break;      }      CopyMem (NewBuffer, VariableName, VariableNameBufferSize);      if (VariableName != NULL) {        FreePool (VariableName);      }      VariableName = NewBuffer;      VariableNameBufferSize = VariableNameSize;      //      // Try to get the next variable name again with the larger buffer.      //      Status = gRT->GetNextVariableName (                      &VariableNameSize,                      VariableName,                      &VendorGuid                      );    }    if (EFI_ERROR (Status)) {      if (Status == EFI_NOT_FOUND) {        Status = EFI_SUCCESS;      }      break;    }    //    // Get the variable data and attributes    //    VariableDataSize = VariableDataBufferSize;    Status = gRT->GetVariable (                    VariableName,                    &VendorGuid,                    &VariableAttributes,                    &VariableDataSize,                    VariableData                    );    if (Status == EFI_BUFFER_TOO_SMALL) {      //      // The currently allocated VariableData buffer is too small,      // so we allocate a larger buffer.      //      if (VariableDataBufferSize != 0) {        FreePool (VariableData);        VariableData = NULL;        VariableDataBufferSize = 0;      }      VariableData = AllocatePool (VariableDataSize);      if (VariableData == NULL) {        Status = EFI_OUT_OF_RESOURCES;        break;      }      VariableDataBufferSize = VariableDataSize;      ////.........这里部分代码省略.........
开发者ID:sndnvaps,项目名称:uefi_apps_EFIDroidUi,代码行数:101,


示例19: BootMenuAddBootOption

//.........这里部分代码省略.........  }  if (SupportedBootDevice->Support->RequestBootType) {    Status = BootDeviceGetType (DevicePath, &BootType, &Attributes);    if (EFI_ERROR(Status)) {      Status = EFI_ABORTED;      goto EXIT;    }  } else {    BootType = BDS_LOADER_EFI_APPLICATION;  }  if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {    Print(L"Add an initrd: ");    Status = GetHIInputBoolean (&InitrdSupport);    if (EFI_ERROR(Status)) {      Status = EFI_ABORTED;      goto EXIT;    }    if (InitrdSupport) {      // Create the specific device path node      Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes);      if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd        Status = EFI_ABORTED;        goto EXIT;      }      if (InitrdPathNodes != NULL) {        // Append the Device Path to the selected device path        InitrdPath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);        // Free the InitrdPathNodes created by Support->CreateDevicePathNode()        FreePool (InitrdPathNodes);        if (InitrdPath == NULL) {          Status = EFI_OUT_OF_RESOURCES;          goto EXIT;        }      } else {        InitrdPath = NULL;      }    } else {      InitrdPath = NULL;    }    Print(L"Arguments to pass to the binary: ");    Status = GetHIInputAscii (AsciiCmdLine, BOOT_DEVICE_OPTION_MAX);    if (EFI_ERROR(Status)) {      Status = EFI_ABORTED;      goto FREE_DEVICE_PATH;    }    CmdLineSize = AsciiStrSize (AsciiCmdLine);    InitrdSize = GetDevicePathSize (InitrdPath);    OptionalDataSize = sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize;    BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (OptionalDataSize);    BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;    BootArguments->LinuxArguments.InitrdSize = InitrdSize;    CopyMem ((VOID*)(&BootArguments->LinuxArguments + 1), AsciiCmdLine, CmdLineSize);    CopyMem ((VOID*)((UINTN)(&BootArguments->LinuxArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);    OptionalData = (UINT8*)BootArguments;  } else {    Print (L"Arguments to pass to the EFI Application: ");    Status = GetHIInputStr (CmdLine, BOOT_DEVICE_OPTION_MAX);    if (EFI_ERROR (Status)) {      Status = EFI_ABORTED;      goto EXIT;    }    OptionalData = (UINT8*)CmdLine;    OptionalDataSize = StrSize (CmdLine);  }  Print(L"Description for this new Entry: ");  Status = GetHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX);  if (EFI_ERROR(Status)) {    Status = EFI_ABORTED;    goto FREE_DEVICE_PATH;  }  // Create new entry  BdsLoadOptionEntry = (BDS_LOAD_OPTION_ENTRY*)AllocatePool (sizeof(BDS_LOAD_OPTION_ENTRY));  Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, OptionalData, OptionalDataSize, &BdsLoadOptionEntry->BdsLoadOption);  if (!EFI_ERROR(Status)) {    InsertTailList (BootOptionsList, &BdsLoadOptionEntry->Link);  }FREE_DEVICE_PATH:  FreePool (DevicePath);EXIT:  if (Status == EFI_ABORTED) {    Print(L"/n");  }  FreePool(SupportedBootDevice);  return Status;}
开发者ID:FishYu1222,项目名称:edk2,代码行数:101,


示例20: handle

/**  Install child handles if the Handle supports El Torito format.  @param[in]  This        Calling context.  @param[in]  Handle      Parent Handle.  @param[in]  DiskIo      Parent DiskIo interface.  @param[in]  BlockIo     Parent BlockIo interface.  @param[in]  BlockIo2    Parent BlockIo2 interface.  @param[in]  DevicePath  Parent Device Path  @retval EFI_SUCCESS         Child handle(s) was added.  @retval EFI_MEDIA_CHANGED   Media changed Detected.  @retval other               no child handle was added.**/EFI_STATUSPartitionInstallElToritoChildHandles (  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,  IN  EFI_HANDLE                   Handle,  IN  EFI_DISK_IO_PROTOCOL         *DiskIo,  IN  EFI_BLOCK_IO_PROTOCOL        *BlockIo,  IN  EFI_BLOCK_IO2_PROTOCOL       *BlockIo2,  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath  ){  EFI_STATUS              Status;  UINT32                  VolDescriptorLba;  UINT32                  Lba;  EFI_BLOCK_IO_MEDIA      *Media;  CDROM_VOLUME_DESCRIPTOR *VolDescriptor;  ELTORITO_CATALOG        *Catalog;  UINTN                   Check;  UINTN                   Index;  UINTN                   BootEntry;  UINTN                   MaxIndex;  UINT16                  *CheckBuffer;  CDROM_DEVICE_PATH       CdDev;  UINT32                  SubBlockSize;  UINT32                  SectorCount;  EFI_STATUS              Found;  UINT32                  VolSpaceSize;#ifdef VBOX  VBoxLogFlowFuncMarkDP(DevicePath);#endif  Found         = EFI_NOT_FOUND;  Media         = BlockIo->Media;  VolSpaceSize  = 0;  //  // CD_ROM has the fixed block size as 2048 bytes  //  if (Media->BlockSize != 2048) {    return EFI_NOT_FOUND;  }  VolDescriptor = AllocatePool ((UINTN) Media->BlockSize);  if (VolDescriptor == NULL) {    return EFI_NOT_FOUND;  }  Catalog = (ELTORITO_CATALOG *) VolDescriptor;  //  // the ISO-9660 volume descriptor starts at 32k on the media  // and CD_ROM has the fixed block size as 2048 bytes, so...  //  //  // ((16*2048) / Media->BlockSize) - 1;  //  VolDescriptorLba = 15;  //  // Loop: handle one volume descriptor per time  //  while (TRUE) {    VolDescriptorLba += 1;    if (VolDescriptorLba > Media->LastBlock) {      //      // We are pointing past the end of the device so exit      //      break;    }    Status = DiskIo->ReadDisk (                       DiskIo,                       Media->MediaId,                       MultU64x32 (VolDescriptorLba, Media->BlockSize),                       Media->BlockSize,                       VolDescriptor                       );    if (EFI_ERROR (Status)) {      Found = Status;      break;    }    //    // Check for valid volume descriptor signature//.........这里部分代码省略.........
开发者ID:jeppeter,项目名称:vbox,代码行数:101,


示例21: console_print_box_at

voidconsole_print_box_at(CHAR16 *str_arr[], int highlight, int start_col, int start_row, int size_cols, int size_rows, int offset, int lines){	int i;	SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut;	UINTN rows, cols;	CHAR16 *Line;	if (lines == 0)		return;	uefi_call_wrapper(co->QueryMode, 4, co, co->Mode->Mode, &cols, &rows);	/* last row on screen is unusable without scrolling, so ignore it */	rows--;	if (size_rows < 0)		size_rows = rows + size_rows + 1;	if (size_cols < 0)		size_cols = cols + size_cols + 1;	if (start_col < 0)		start_col = (cols + start_col + 2)/2;	if (start_row < 0)		start_row = (rows + start_row + 2)/2;	if (start_col < 0)		start_col = 0;	if (start_row < 0)		start_row = 0;	if (start_col > cols || start_row > rows) {		Print(L"Starting Position (%d,%d) is off screen/n",		      start_col, start_row);		return;	}	if (size_cols + start_col > cols)		size_cols = cols - start_col;	if (size_rows + start_row > rows)		size_rows = rows - start_row;	       	if (lines > size_rows - 2)		lines = size_rows - 2;	Line = AllocatePool((size_cols+1)*sizeof(CHAR16));	if (!Line) {		Print(L"Failed Allocation/n");		return;	}	SetMem16 (Line, size_cols * 2, BOXDRAW_HORIZONTAL);	Line[0] = BOXDRAW_DOWN_RIGHT;	Line[size_cols - 1] = BOXDRAW_DOWN_LEFT;	Line[size_cols] = L'/0';	uefi_call_wrapper(co->SetCursorPosition, 3, co, start_col, start_row);	uefi_call_wrapper(co->OutputString, 2, co, Line);	int start;	if (offset == 0)		/* middle */		start = (size_rows - lines)/2 + start_row + offset;	else if (offset < 0)		/* from bottom */		start = start_row + size_rows - lines + offset - 1;	else		/* from top */		start = start_row + offset;			for (i = start_row + 1; i < size_rows + start_row - 1; i++) {		int line = i - start;		SetMem16 (Line, size_cols*2, L' ');		Line[0] = BOXDRAW_VERTICAL;		Line[size_cols - 1] = BOXDRAW_VERTICAL;		Line[size_cols] = L'/0';		if (line >= 0 && line < lines) {			CHAR16 *s = str_arr[line];			int len = StrLen(s);			int col = (size_cols - 2 - len)/2;			if (col < 0)				col = 0;			CopyMem(Line + col + 1, s, min(len, size_cols - 2)*2);		}		if (line >= 0 && line == highlight) 			uefi_call_wrapper(co->SetAttribute, 2, co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLACK);		uefi_call_wrapper(co->SetCursorPosition, 3, co, start_col, i);		uefi_call_wrapper(co->OutputString, 2, co, Line);		if (line >= 0 && line == highlight) 			uefi_call_wrapper(co->SetAttribute, 2, co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE);	}	SetMem16 (Line, size_cols * 2, BOXDRAW_HORIZONTAL);	Line[0] = BOXDRAW_UP_RIGHT;	Line[size_cols - 1] = BOXDRAW_UP_LEFT;	Line[size_cols] = L'/0';	uefi_call_wrapper(co->SetCursorPosition, 3, co, start_col, i);	uefi_call_wrapper(co->OutputString, 2, co, Line);//.........这里部分代码省略.........
开发者ID:mjg59,项目名称:efitools,代码行数:101,


示例22: EblGetCmd

EFI_STATUSEblGetCmd (  IN UINTN  Argc,  IN CHAR8  **Argv  ){  EFI_STATUS        Status = EFI_INVALID_PARAMETER;  UINTN       Size;  VOID*       Value;  CHAR8*      AsciiVariableName = NULL;  CHAR16*     VariableName;  UINT32      Index;  if (Argc == 1) {    AsciiPrint("Variable name is missing./n");    return Status;  }  for (Index = 1; Index < Argc; Index++) {    if (Argv[Index][0] == '-') {      AsciiPrint("Warning: '%a' not recognized./n",Argv[Index]);    } else {      AsciiVariableName = Argv[Index];    }  }  if (AsciiVariableName == NULL) {    AsciiPrint("Variable name is missing./n");    return Status;  } else {    VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));    AsciiStrToUnicodeStr (AsciiVariableName,VariableName);  }  // Try to get the variable size.  Value = NULL;  Size = 0;  Status = gRT->GetVariable (VariableName, &gEfiGlobalVariableGuid, NULL, &Size, Value);  if (Status == EFI_NOT_FOUND) {    AsciiPrint("Variable name '%s' not found./n",VariableName);  } else if (Status == EFI_BUFFER_TOO_SMALL) {    // Get the environment variable value    Value = AllocatePool (Size);    if (Value == NULL) {      return EFI_OUT_OF_RESOURCES;    }    Status = gRT->GetVariable ((CHAR16 *)VariableName, &gEfiGlobalVariableGuid, NULL, &Size, Value);    if (EFI_ERROR (Status)) {      AsciiPrint("Error: '%r'/n",Status);    } else {      AsciiPrint("%a=%a/n",AsciiVariableName,Value);    }    FreePool(Value);  } else {    AsciiPrint("Error: '%r'/n",Status);  }  FreePool(VariableName);  return Status;}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:61,


示例23: FileOpen

/**  Open a file on the host system by means of the semihosting interface.  @param[in]   This        A pointer to the EFI_FILE_PROTOCOL instance that is                           the file handle to source location.  @param[out]  NewHandle   A pointer to the location to return the opened                           handle for the new file.  @param[in]   FileName    The Null-terminated string of the name of the file                           to be opened.  @param[in]   OpenMode    The mode to open the file : Read or Read/Write or                           Read/Write/Create  @param[in]   Attributes  Only valid for EFI_FILE_MODE_CREATE, in which case these                           are the attribute bits for the newly created file. The                           mnemonics of the attribute bits are : EFI_FILE_READ_ONLY,                           EFI_FILE_HIDDEN, EFI_FILE_SYSTEM, EFI_FILE_RESERVED,                           EFI_FILE_DIRECTORY and EFI_FILE_ARCHIVE.  @retval  EFI_SUCCESS            The file was open.  @retval  EFI_NOT_FOUND          The specified file could not be found.  @retval  EFI_DEVICE_ERROR       The last issued semi-hosting operation failed.  @retval  EFI_WRITE_PROTECTED    Attempt to create a directory. This is not possible                                  with the semi-hosting interface.  @retval  EFI_OUT_OF_RESOURCES   Not enough resources were available to open the file.  @retval  EFI_INVALID_PARAMETER  At least one of the parameters is invalid.**/EFI_STATUSFileOpen (  IN  EFI_FILE  *This,  OUT EFI_FILE  **NewHandle,  IN  CHAR16    *FileName,  IN  UINT64    OpenMode,  IN  UINT64    Attributes  ){  SEMIHOST_FCB   *FileFcb;  RETURN_STATUS  Return;  EFI_STATUS     Status;  UINTN          SemihostHandle;  CHAR8          *AsciiFileName;  UINT32         SemihostMode;  UINTN          Length;  if ((FileName == NULL) || (NewHandle == NULL)) {    return EFI_INVALID_PARAMETER;  }  if ( (OpenMode != EFI_FILE_MODE_READ) &&       (OpenMode != (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE)) &&       (OpenMode != (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE)) ) {    return EFI_INVALID_PARAMETER;  }  if ((OpenMode & EFI_FILE_MODE_CREATE) &&      (Attributes & EFI_FILE_DIRECTORY)    ) {    return EFI_WRITE_PROTECTED;  }  AsciiFileName = AllocatePool (StrLen (FileName) + 1);  if (AsciiFileName == NULL) {    return EFI_OUT_OF_RESOURCES;  }  UnicodeStrToAsciiStr (FileName, AsciiFileName);  // Opening '/', '/', '.', or the NULL pathname is trying to open the root directory  if ((AsciiStrCmp (AsciiFileName, "//") == 0) ||      (AsciiStrCmp (AsciiFileName, "/")  == 0) ||      (AsciiStrCmp (AsciiFileName, "")   == 0) ||      (AsciiStrCmp (AsciiFileName, ".")  == 0)    ) {    FreePool (AsciiFileName);    return (VolumeOpen (&gSemihostFs, NewHandle));  }  //  // No control is done here concerning the file path. It is passed  // as it is to the host operating system through the semi-hosting  // interface. We first try to open the file in the read or update  // mode even if the file creation has been asked for. That way, if  // the file already exists, it is not truncated to zero length. In  // write mode (bit SEMIHOST_FILE_MODE_WRITE up), if the file already  // exists, it is reset to an empty file.  //  if (OpenMode == EFI_FILE_MODE_READ) {    SemihostMode = SEMIHOST_FILE_MODE_READ | SEMIHOST_FILE_MODE_BINARY;  } else {    SemihostMode = SEMIHOST_FILE_MODE_READ | SEMIHOST_FILE_MODE_BINARY | SEMIHOST_FILE_MODE_UPDATE;  }  Return = SemihostFileOpen (AsciiFileName, SemihostMode, &SemihostHandle);  if (RETURN_ERROR (Return)) {    if (OpenMode & EFI_FILE_MODE_CREATE) {      //      // In the create if does not exist case, if the opening in update      // mode failed, create it and open it in update mode. The update      // mode allows for both read and write from and to the file.      //      Return = SemihostFileOpen (                 AsciiFileName,                 SEMIHOST_FILE_MODE_WRITE | SEMIHOST_FILE_MODE_BINARY | SEMIHOST_FILE_MODE_UPDATE,                 &SemihostHandle//.........这里部分代码省略.........
开发者ID:AbnerChang,项目名称:edk2-staging,代码行数:101,


示例24: EblSetCmd

EFI_STATUSEblSetCmd (  IN UINTN  Argc,  IN CHAR8  **Argv  ){  EFI_STATUS    Status = EFI_INVALID_PARAMETER;  CHAR8*        AsciiVariableSetting = NULL;  CHAR8*        AsciiVariableName;  CHAR8*        AsciiValue;  UINT32        AsciiValueLength;  CHAR16*       VariableName;  UINT32        Index;  UINT32        EscapedQuotes = 0;  BOOLEAN       Volatile = FALSE;  if (Argc == 1) {    AsciiPrint("Variable name is missing./n");    return Status;  }  for (Index = 1; Index < Argc; Index++) {    if (AsciiStrCmp(Argv[Index],"-v") == 0) {      Volatile = 0;    } else if (Argv[Index][0] == '-') {      AsciiPrint("Warning: '%a' not recognized./n",Argv[Index]);    } else {      AsciiVariableSetting = Argv[Index];    }  }  if (AsciiVariableSetting == NULL) {    AsciiPrint("Variable name is missing./n");    return Status;  }    // Check if it is a valid variable setting  AsciiValue = AsciiStrStr (AsciiVariableSetting,"=");  if (AsciiValue == NULL) {    //    // There is no value. It means this variable will be deleted    //    // Convert VariableName into Unicode    VariableName = AllocatePool((AsciiStrLen (AsciiVariableSetting) + 1) * sizeof (CHAR16));    AsciiStrToUnicodeStr (AsciiVariableSetting,VariableName);    Status = gRT->SetVariable (                          VariableName,                          &gEfiGlobalVariableGuid,                          ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) |                          EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,                          0,                          NULL                          );    if (!EFI_ERROR(Status)) {      AsciiPrint("Variable '%s' deleted/n",VariableName);    } else {      AsciiPrint("Variable setting is incorrect. It should be VariableName=Value/n");    }    return Status;  }  AsciiValue[0] = '/0';  AsciiVariableName = AsciiVariableSetting;  AsciiValue++;  // Clean AsciiValue from quote  if (AsciiValue[0] == '"') {    AsciiValue++;  }  AsciiValueLength = AsciiStrLen (AsciiValue);  if ((AsciiValue[AsciiValueLength-2] != '//') && (AsciiValue[AsciiValueLength-1] == '"')) {    AsciiValue[AsciiValueLength-1] = '/0';  }  // Clean AsciiValue from escaped quotes  for (Index = 0; Index < AsciiValueLength; Index++) {    if ((Index > 0) && (AsciiValue[Index-1] == '//') && (AsciiValue[Index] == '"')) {      EscapedQuotes++;    }    AsciiValue[Index-EscapedQuotes] = AsciiValue[Index];  }  // Fill the end of the value with '/0'  for (Index = 0; Index < EscapedQuotes; Index++) {    AsciiValue[AsciiValueLength-1-Index] = '/0';  }  // Convert VariableName into Unicode  VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));  AsciiStrToUnicodeStr (AsciiVariableName,VariableName);  Status = gRT->SetVariable (                      VariableName,                      &gEfiGlobalVariableGuid,                      ( !Volatile ? EFI_VARIABLE_NON_VOLATILE : 0) |                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,                      AsciiStrLen (AsciiValue)+1,                      AsciiValue                      );//.........这里部分代码省略.........
开发者ID:hsienchieh,项目名称:uefilab,代码行数:101,


示例25: SetFileInfo

/**  Set information about a file.  @param[in]  Fcb   A pointer to the description of the open file.  @param[in]  Info  A pointer to the file information to write.  @retval  EFI_SUCCESS           The information was set.  @retval  EFI_ACCESS_DENIED     An attempt is made to change the name of a file                                 to a file that is already present.  @retval  EFI_ACCESS_DENIED     An attempt is being made to change the                                 EFI_FILE_DIRECTORY Attribute.  @retval  EFI_ACCESS_DENIED     The file is a read-only file or has been                                 opened in read-only mode and an attempt is                                 being made to modify a field other than                                 Attribute.  @retval  EFI_WRITE_PROTECTED   An attempt is being made to modify a                                 read-only attribute.  @retval  EFI_DEVICE_ERROR      The last issued semi-hosting operation failed.  @retval  EFI_OUT_OF_RESOURCES  A allocation needed to process the request failed.**/STATICEFI_STATUSSetFileInfo (  IN  SEMIHOST_FCB   *Fcb,  IN  EFI_FILE_INFO  *Info  ){  EFI_STATUS     Status;  RETURN_STATUS  Return;  BOOLEAN        FileSizeIsDifferent;  BOOLEAN        FileNameIsDifferent;  BOOLEAN        ReadOnlyIsDifferent;  CHAR8          *AsciiFileName;  UINTN          FileSize;  UINTN          Length;  UINTN          SemihostHandle;  //  // A directory can not be changed to a file and a file can  // not be changed to a directory.  //  if (((Info->Attribute & EFI_FILE_DIRECTORY) != 0) != Fcb->IsRoot) {    return EFI_ACCESS_DENIED;  }  AsciiFileName = AllocatePool (StrLen (Info->FileName) + 1);  if (AsciiFileName == NULL) {    return EFI_OUT_OF_RESOURCES;  }  UnicodeStrToAsciiStr (Info->FileName, AsciiFileName);  FileSizeIsDifferent = (Info->FileSize != Fcb->Info.FileSize);  FileNameIsDifferent = (AsciiStrCmp (AsciiFileName, Fcb->FileName) != 0);  ReadOnlyIsDifferent = CompareMem (                          &Info->CreateTime,                          &Fcb->Info.CreateTime,                          3 * sizeof (EFI_TIME)                          ) != 0;  //  // For a read-only file or a file opened in read-only mode, only  // the Attribute field can be modified. As the root directory is  // read-only (i.e. VolumeOpen()), this protects the root directory  // description.  //  if ((Fcb->OpenMode == EFI_FILE_MODE_READ)     ||      (Fcb->Info.Attribute & EFI_FILE_READ_ONLY)  ) {    if (FileSizeIsDifferent || FileNameIsDifferent || ReadOnlyIsDifferent) {      Status = EFI_ACCESS_DENIED;      goto Error;    }  }  if (ReadOnlyIsDifferent) {    Status = EFI_WRITE_PROTECTED;    goto Error;  }  Status = EFI_DEVICE_ERROR;  if (FileSizeIsDifferent) {    FileSize = Info->FileSize;    if (Fcb->Info.FileSize < FileSize) {      Status = ExtendFile (Fcb, FileSize - Fcb->Info.FileSize);      if (EFI_ERROR (Status)) {        goto Error;      }      //      // The read/write position from the host file system point of view      // is at the end of the file. If the position from this module      // point of view is smaller than the new file size, then      // ask the host file system to move to that position.      //      if (Fcb->Position < FileSize) {        FileSetPosition (&Fcb->File, Fcb->Position);      }    }    Fcb->Info.FileSize = FileSize;//.........这里部分代码省略.........
开发者ID:AbnerChang,项目名称:edk2-staging,代码行数:101,


示例26: handle

/**  Install child handles if the Handle supports Apple partition table format.  @param[in]  This        Calling context.  @param[in]  Handle      Parent Handle  @param[in]  DiskIo      Parent DiskIo interface  @param[in]  BlockIo     Parent BlockIo interface  @param[in]  DevicePath  Parent Device Path  @retval EFI_SUCCESS         Child handle(s) was added  @retval EFI_MEDIA_CHANGED   Media changed Detected  @retval other               no child handle was added**/EFI_STATUSPartitionInstallAppleChildHandles (  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,  IN  EFI_HANDLE                   Handle,  IN  EFI_DISK_IO_PROTOCOL         *DiskIo,  IN  EFI_BLOCK_IO_PROTOCOL        *BlockIo,  IN  EFI_BLOCK_IO2_PROTOCOL       *BlockIo2,  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath  ){  EFI_STATUS                Status;  UINT32                    Lba;  EFI_BLOCK_IO_MEDIA       *Media;  VOID                     *Block;  //UINTN                   MaxIndex;  /** @todo: wrong, as this PT can be on both HDD or CD */  CDROM_DEVICE_PATH         CdDev;  //EFI_DEVICE_PATH_PROTOCOL  Dev;  EFI_STATUS                Found;  UINT32                    Partition;  UINT32                    PartitionEntries;  UINT32                    VolSpaceSize;  UINT32                    SubBlockSize;  UINT32                    BlkPerSec;  VBoxLogFlowFuncMarkDP(DevicePath);  Found         = EFI_NOT_FOUND;  Media         = BlockIo->Media;  VolSpaceSize  = 0;  Block = AllocatePool ((UINTN) Media->BlockSize);  if (Block == NULL) {    return EFI_NOT_FOUND;  }  do {      APPLE_PT_HEADER * Header;      /* read PT header first */      Lba = 0;      Status = DiskIo->ReadDisk (                       DiskIo,                       Media->MediaId,                       MultU64x32 (Lba, Media->BlockSize),                       Media->BlockSize,                       Block                       );      if (EFI_ERROR (Status))      {          Found = Status;          break;      }      Header = (APPLE_PT_HEADER *)Block;      if (be16_to_cpu(Header->sbSig) != 0x4552)      {          break;      }      SubBlockSize = be16_to_cpu(Header->sbBlkSize);      BlkPerSec    = Media->BlockSize / SubBlockSize;      /* Fail if media block size isn't an exact multiple */      if (Media->BlockSize != SubBlockSize * BlkPerSec)      {          break;      }      /* Now iterate over PT entries and install child handles */      PartitionEntries = 1;      for (Partition = 1; Partition <= PartitionEntries; Partition++)      {          APPLE_PT_ENTRY * Entry;          UINT32 StartLba;          UINT32 SizeLbs;          Status = DiskIo->ReadDisk (                       DiskIo,                       Media->MediaId,                       MultU64x32 (Partition, SubBlockSize),                       SubBlockSize,                       Block                       );//.........这里部分代码省略.........
开发者ID:bayasist,项目名称:vbox,代码行数:101,


示例27: BBTestUpdateCapsuleConformanceTest

EFI_STATUSBBTestUpdateCapsuleConformanceTest (  IN EFI_BB_TEST_PROTOCOL       *This,  IN VOID                       *ClientInterface,  IN EFI_TEST_LEVEL             TestLevel,  IN EFI_HANDLE                 SupportHandle  ){  EFI_STATUS                           Status;  EFI_STANDARD_TEST_LIBRARY_PROTOCOL   *StandardLib;  EFI_TEST_ASSERTION                   AssertionType;  UINT8                                *AllocatedBuffer;  EFI_CAPSULE_HEADER                  *CapsuleHeaderArray[2];  //  // Get the Standard Library Interface  //  Status = gtBS->HandleProtocol (                   SupportHandle,                   &gEfiStandardTestLibraryGuid,                   &StandardLib                   );  if (EFI_ERROR(Status)) {    return Status;  }  if (FALSE == CheckBBTestCanRunAndRecordAssertion (                  StandardLib,                   L"RT.UpdateCapsule_Conf- UpdateCapsule_Conf it's not Supported in EFI",                  __FILE__,                  (UINTN)__LINE__                  )) {    return EFI_SUCCESS;  }  AllocatedBuffer = (UINT8 *)AllocatePool (sizeof(EFI_CAPSULE_HEADER));  if (EFI_ERROR(Status)) {    StandardLib->RecordAssertion (                   StandardLib,                   EFI_TEST_ASSERTION_FAILED,                   gTestGenericFailureGuid,                   L"RT.UpdateCapsule_conf - Allocate pages for EFI_CAPSULE_HEADER",                   L"%a:%d,Status - %r",                   __FILE__,                   (UINTN)__LINE__,                   Status                   );    return Status;  }  CapsuleHeaderArray[0] = (EFI_CAPSULE_HEADER *) (UINTN)AllocatedBuffer;  CapsuleHeaderArray[0]->CapsuleGuid = mEfiCapsuleHeaderGuid;  CapsuleHeaderArray[0]->HeaderSize = sizeof(EFI_CAPSULE_HEADER);  CapsuleHeaderArray[0]->CapsuleImageSize = sizeof(EFI_CAPSULE_HEADER);  CapsuleHeaderArray[1] = NULL;  CapsuleHeaderArray[0]->Flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET;  // When CapsuleCount is 0, the return status code should be EFI_INVALID_PARAMETER  Status = gtRT->UpdateCapsule(  	             CapsuleHeaderArray,  	             0, // invaild  	             (EFI_PHYSICAL_ADDRESS ) 0  	             );  if (Status == EFI_INVALID_PARAMETER) {  	AssertionType = EFI_TEST_ASSERTION_PASSED;  } else {    AssertionType = EFI_TEST_ASSERTION_FAILED;  }  StandardLib->RecordAssertion (                 StandardLib,                 AssertionType,                 gMiscRuntimeServicesBBTestConformanceAssertionGuid001,                 L"RT.UpdateCapsule - invoke UpdateCapsule with invalid CapsuleCount - 0",                 L"%a:%d:Status - %r",                 __FILE__,                 __LINE__,                 Status                 );                  //  // when the flag is CAPSULE_FLAGS_PERSIST_ACROSS_RESET, ScatterGatherList can't be NULL.  //  CapsuleHeaderArray[0] = (EFI_CAPSULE_HEADER *) (UINTN)AllocatedBuffer;  CapsuleHeaderArray[0]->CapsuleGuid = mEfiCapsuleHeaderGuid;  CapsuleHeaderArray[0]->HeaderSize = sizeof(EFI_CAPSULE_HEADER);  CapsuleHeaderArray[0]->CapsuleImageSize = sizeof(EFI_CAPSULE_HEADER);  CapsuleHeaderArray[1] = NULL;  CapsuleHeaderArray[0]->Flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE;  Status = gtRT->UpdateCapsule(  	             CapsuleHeaderArray,  	             1,  	             (EFI_PHYSICAL_ADDRESS ) 0  	             );  if (Status == EFI_INVALID_PARAMETER) {  	AssertionType = EFI_TEST_ASSERTION_PASSED;//.........这里部分代码省略.........
开发者ID:JackNine,项目名称:2ndProject,代码行数:101,


示例28: PartitionInstallGptChildHandles

/**  Install child handles if the Handle supports GPT partition structure.  @param[in]  This       Calling context.  @param[in]  Handle     Parent Handle.  @param[in]  DiskIo     Parent DiskIo interface.  @param[in]  BlockIo    Parent BlockIo interface.  @param[in]  BlockIo2   Parent BlockIo2 interface.  @param[in]  DevicePath Parent Device Path.  @retval EFI_SUCCESS           Valid GPT disk.  @retval EFI_MEDIA_CHANGED     Media changed Detected.  @retval other                 Not a valid GPT disk.**/EFI_STATUSPartitionInstallGptChildHandles (  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,  IN  EFI_HANDLE                   Handle,  IN  EFI_DISK_IO_PROTOCOL         *DiskIo,  IN  EFI_BLOCK_IO_PROTOCOL        *BlockIo,  IN  EFI_BLOCK_IO2_PROTOCOL       *BlockIo2,  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath  ){  EFI_STATUS                  Status;  UINT32                      BlockSize;  EFI_LBA                     LastBlock;  MASTER_BOOT_RECORD          *ProtectiveMbr;  EFI_PARTITION_TABLE_HEADER  *PrimaryHeader;  EFI_PARTITION_TABLE_HEADER  *BackupHeader;  EFI_PARTITION_ENTRY         *PartEntry;  EFI_PARTITION_ENTRY         *Entry;  EFI_PARTITION_ENTRY_STATUS  *PEntryStatus;  UINTN                       Index;  EFI_STATUS                  GptValidStatus;  HARDDRIVE_DEVICE_PATH       HdDev;  UINT32                      MediaId;  VBoxLogFlowFuncMarkDP(DevicePath);  ProtectiveMbr = NULL;  PrimaryHeader = NULL;  BackupHeader  = NULL;  PartEntry     = NULL;  PEntryStatus  = NULL;  BlockSize     = BlockIo->Media->BlockSize;  LastBlock     = BlockIo->Media->LastBlock;  MediaId       = BlockIo->Media->MediaId;  DEBUG ((EFI_D_INFO, " BlockSize : %d /n", BlockSize));  DEBUG ((EFI_D_INFO, " LastBlock : %lx /n", LastBlock));  GptValidStatus = EFI_NOT_FOUND;  //  // Allocate a buffer for the Protective MBR  //  ProtectiveMbr = AllocatePool (BlockSize);  if (ProtectiveMbr == NULL) {    return EFI_NOT_FOUND;  }  //  // Read the Protective MBR from LBA #0  //  Status = DiskIo->ReadDisk (                     DiskIo,                     MediaId,                     0,                     BlockSize,                     ProtectiveMbr                     );  if (EFI_ERROR (Status)) {    GptValidStatus = Status;    goto Done;  }  //  // Verify that the Protective MBR is valid  //  for (Index = 0; Index < MAX_MBR_PARTITIONS; Index++) {    if (ProtectiveMbr->Partition[Index].BootIndicator == 0x00 &&        ProtectiveMbr->Partition[Index].OSIndicator == PMBR_GPT_PARTITION &&        UNPACK_UINT32 (ProtectiveMbr->Partition[Index].StartingLBA) == 1        ) {      break;    }  }  if (Index == MAX_MBR_PARTITIONS) {    goto Done;  }  //  // Allocate the GPT structures  //  PrimaryHeader = AllocateZeroPool (sizeof (EFI_PARTITION_TABLE_HEADER));  if (PrimaryHeader == NULL) {    goto Done;  }//.........这里部分代码省略.........
开发者ID:etiago,项目名称:vbox,代码行数:101,


示例29: VirtioRngGetRNG

/**  Produces and returns an RNG value using either the default or specified RNG  algorithm.  @param[in]  This                    A pointer to the EFI_RNG_PROTOCOL                                      instance.  @param[in]  RNGAlgorithm            A pointer to the EFI_RNG_ALGORITHM that                                      identifies the RNG algorithm to use. May                                      be NULL in which case the function will                                      use its default RNG algorithm.  @param[in]  RNGValueLength          The length in bytes of the memory buffer                                      pointed to by RNGValue. The driver shall                                      return exactly this numbers of bytes.  @param[out] RNGValue                A caller-allocated memory buffer filled                                      by the driver with the resulting RNG                                      value.  @retval EFI_SUCCESS                 The RNG value was returned successfully.  @retval EFI_UNSUPPORTED             The algorithm specified by RNGAlgorithm                                      is not supported by this driver.  @retval EFI_DEVICE_ERROR            An RNG value could not be retrieved due                                      to a hardware or firmware error.  @retval EFI_NOT_READY               There is not enough random data available                                      to satisfy the length requested by                                      RNGValueLength.  @retval EFI_INVALID_PARAMETER       RNGValue is NULL or RNGValueLength is                                      zero.**/STATICEFI_STATUSEFIAPIVirtioRngGetRNG (  IN EFI_RNG_PROTOCOL            *This,  IN EFI_RNG_ALGORITHM           *RNGAlgorithm, OPTIONAL  IN UINTN                       RNGValueLength,  OUT UINT8                      *RNGValue  ){  VIRTIO_RNG_DEV            *Dev;  DESC_INDICES              Indices;  volatile UINT8            *Buffer;  UINTN                     Index;  UINT32                    Len;  UINT32                    BufferSize;  EFI_STATUS                Status;  EFI_PHYSICAL_ADDRESS      DeviceAddress;  VOID                      *Mapping;  if (This == NULL || RNGValueLength == 0 || RNGValue == NULL) {    return EFI_INVALID_PARAMETER;  }  //  // We only support the raw algorithm, so reject requests for anything else  //  if (RNGAlgorithm != NULL &&      !CompareGuid (RNGAlgorithm, &gEfiRngAlgorithmRaw)) {    return EFI_UNSUPPORTED;  }  Buffer = (volatile UINT8 *)AllocatePool (RNGValueLength);  if (Buffer == NULL) {    return EFI_DEVICE_ERROR;  }  Dev = VIRTIO_ENTROPY_SOURCE_FROM_RNG (This);  //  // Map Buffer's system phyiscal address to device address  //  Status = VirtioMapAllBytesInSharedBuffer (             Dev->VirtIo,             VirtioOperationBusMasterWrite,             (VOID *)Buffer,             RNGValueLength,             &DeviceAddress,             &Mapping             );  if (EFI_ERROR (Status)) {    Status = EFI_DEVICE_ERROR;    goto FreeBuffer;  }  //  // The Virtio RNG device may return less data than we asked it to, and can  // only return MAX_UINT32 bytes per invocation. So loop as long as needed to  // get all the entropy we were asked for.  //  for (Index = 0; Index < RNGValueLength; Index += Len) {    BufferSize = (UINT32)MIN (RNGValueLength - Index, (UINTN)MAX_UINT32);    VirtioPrepare (&Dev->Ring, &Indices);    VirtioAppendDesc (&Dev->Ring,      DeviceAddress + Index,      BufferSize,      VRING_DESC_F_WRITE,      &Indices);    if (VirtioFlush (Dev->VirtIo, 0, &Dev->Ring, &Indices, &Len) !=        EFI_SUCCESS) {//.........这里部分代码省略.........
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:101,


示例30: WinNtBusDriverBindingStart

EFI_STATUSEFIAPIWinNtBusDriverBindingStart (  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,  IN  EFI_HANDLE                   ControllerHandle,  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  )/*++Routine Description:Arguments:Returns:  None--*/// TODO:    This - add argument and description to function comment// TODO:    ControllerHandle - add argument and description to function comment// TODO:    RemainingDevicePath - add argument and description to function comment// TODO:    EFI_OUT_OF_RESOURCES - add return value to function comment// TODO:    EFI_OUT_OF_RESOURCES - add return value to function comment// TODO:    EFI_SUCCESS - add return value to function comment{  EFI_STATUS                      Status;  EFI_WIN_NT_THUNK_PROTOCOL       *WinNtThunk;  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;  WIN_NT_BUS_DEVICE               *WinNtBusDevice;  WIN_NT_IO_DEVICE                *WinNtDevice;  UINTN                           Index;  CHAR16                          *StartString;  CHAR16                          *SubString;  UINT16                          Count;  UINTN                           StringSize;  UINT16                          ComponentName[MAX_NT_ENVIRNMENT_VARIABLE_LENGTH];  WIN_NT_VENDOR_DEVICE_PATH_NODE  *Node;  BOOLEAN                         CreateDevice;  CHAR16                          *TempStr;  CHAR16                          *PcdTempStr;  UINTN                           TempStrSize;  Status = EFI_UNSUPPORTED;  //  // Grab the protocols we need  //  Status = gBS->OpenProtocol (                  ControllerHandle,                  &gEfiDevicePathProtocolGuid,                  (VOID **) &ParentDevicePath,                  This->DriverBindingHandle,                  ControllerHandle,                  EFI_OPEN_PROTOCOL_BY_DRIVER                  );  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {    return Status;  }  Status = gBS->OpenProtocol (                  ControllerHandle,                  &gEfiWinNtThunkProtocolGuid,                  (VOID **) &WinNtThunk,                  This->DriverBindingHandle,                  ControllerHandle,                  EFI_OPEN_PROTOCOL_BY_DRIVER                  );  if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {    return Status;  }  if (Status != EFI_ALREADY_STARTED) {    WinNtBusDevice = AllocatePool (sizeof (WIN_NT_BUS_DEVICE));    if (WinNtBusDevice == NULL) {      return EFI_OUT_OF_RESOURCES;    }    WinNtBusDevice->Signature           = WIN_NT_BUS_DEVICE_SIGNATURE;    WinNtBusDevice->ControllerNameTable = NULL;    AddUnicodeString2 (      "eng",      gWinNtBusDriverComponentName.SupportedLanguages,      &WinNtBusDevice->ControllerNameTable,      L"Windows Bus Controller",      TRUE      );    AddUnicodeString2 (      "en",      gWinNtBusDriverComponentName2.SupportedLanguages,      &WinNtBusDevice->ControllerNameTable,      L"Windows Bus Controller",      FALSE      );    Status = gBS->InstallMultipleProtocolInterfaces (                    &ControllerHandle,                    &gWinNtBusDriverGuid,                    WinNtBusDevice,//.........这里部分代码省略.........
开发者ID:shijunjing,项目名称:edk2,代码行数:101,



注:本文中的AllocatePool函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ AllocateWorkSpace函数代码示例
C++ AllocatePages函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。