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

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

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

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

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

示例1: EfiHttpResponse

/**  The work function of EfiHttpResponse().  @param[in]  Wrap                Pointer to HTTP token's wrap data.  @retval EFI_SUCCESS             Allocation succeeded.  @retval EFI_OUT_OF_RESOURCES    Failed to complete the opration due to lack of resources.  @retval EFI_NOT_READY           Can't find a corresponding Tx4Token/Tx6Token or                                   the EFI_HTTP_UTILITIES_PROTOCOL is not available.**/EFI_STATUSHttpResponseWorker (  IN  HTTP_TOKEN_WRAP           *Wrap  ){  EFI_STATUS                    Status;  EFI_HTTP_MESSAGE              *HttpMsg;  CHAR8                         *EndofHeader;  CHAR8                         *HttpHeaders;  UINTN                         SizeofHeaders;  UINTN                         BufferSize;  UINTN                         StatusCode;  CHAR8                         *Tmp;  CHAR8                         *HeaderTmp;  CHAR8                         *StatusCodeStr;  UINTN                         BodyLen;  HTTP_PROTOCOL                 *HttpInstance;  EFI_HTTP_TOKEN                *Token;  NET_MAP_ITEM                  *Item;  HTTP_TOKEN_WRAP               *ValueInItem;  UINTN                         HdrLen;  if (Wrap == NULL || Wrap->HttpInstance == NULL) {    return EFI_INVALID_PARAMETER;  }    HttpInstance = Wrap->HttpInstance;  Token = Wrap->HttpToken;  HttpMsg = Token->Message;  HttpInstance->EndofHeader = NULL;  HttpInstance->HttpHeaders = NULL;  HttpMsg->Headers          = NULL;  HttpHeaders               = NULL;  SizeofHeaders             = 0;  BufferSize                = 0;  EndofHeader               = NULL;   if (HttpMsg->Data.Response != NULL) {    //    // Need receive the HTTP headers, prepare buffer.    //    Status = HttpCreateTcpRxEventForHeader (HttpInstance);    if (EFI_ERROR (Status)) {      goto Error;    }    //    // Check whether we have cached header from previous call.    //    if ((HttpInstance->CacheBody != NULL) && (HttpInstance->NextMsg != NULL)) {      //      // The data is stored at [NextMsg, CacheBody + CacheLen].      //      HdrLen = HttpInstance->CacheBody + HttpInstance->CacheLen - HttpInstance->NextMsg;      HttpHeaders = AllocateZeroPool (HdrLen);      if (HttpHeaders == NULL) {        Status = EFI_OUT_OF_RESOURCES;        goto Error;      }      CopyMem (HttpHeaders, HttpInstance->NextMsg, HdrLen);      FreePool (HttpInstance->CacheBody);      HttpInstance->CacheBody   = NULL;      HttpInstance->NextMsg     = NULL;      HttpInstance->CacheOffset = 0;      SizeofHeaders = HdrLen;      BufferSize = HttpInstance->CacheLen;      //      // Check whether we cached the whole HTTP headers.      //      EndofHeader = AsciiStrStr (HttpHeaders, HTTP_END_OF_HDR_STR);     }       HttpInstance->EndofHeader = &EndofHeader;    HttpInstance->HttpHeaders = &HttpHeaders;    if (HttpInstance->TimeoutEvent == NULL) {      //      // Create TimeoutEvent for response      //      Status = gBS->CreateEvent (                      EVT_TIMER,                      TPL_CALLBACK,                      NULL,                      NULL,                      &HttpInstance->TimeoutEvent//.........这里部分代码省略.........
开发者ID:niruiyu,项目名称:edk2,代码行数:101,


示例2: Console

/**  This function delete and build multi-instance device path for  specified type of console device.  This function clear the EFI variable defined by ConsoleName and  gEfiGlobalVariableGuid. It then build the multi-instance device  path by appending the device path of the Console (In/Out/Err) instance   in ConsoleMenu. Then it scan all corresponding console device by  scanning Terminal (built from device supporting Serial I/O instances)  devices in TerminalMenu. At last, it save a EFI variable specifed  by ConsoleName and gEfiGlobalVariableGuid.  @param ConsoleName     The name for the console device type. They are                         usually "ConIn", "ConOut" and "ErrOut".  @param ConsoleMenu     The console memu which is a list of console devices.  @param UpdatePageId    The flag specifying which type of console device                         to be processed.  @retval EFI_SUCCESS    The function complete successfully.  @return The EFI variable can not be saved. See gRT->SetVariable for detail return information.**/EFI_STATUSVar_UpdateConsoleOption (  IN UINT16                     *ConsoleName,  IN BM_MENU_OPTION             *ConsoleMenu,  IN UINT16                     UpdatePageId  ){  EFI_DEVICE_PATH_PROTOCOL  *ConDevicePath;  BM_MENU_ENTRY             *NewMenuEntry;  BM_CONSOLE_CONTEXT        *NewConsoleContext;  BM_TERMINAL_CONTEXT       *NewTerminalContext;  EFI_STATUS                Status;  VENDOR_DEVICE_PATH        Vendor;  EFI_DEVICE_PATH_PROTOCOL  *TerminalDevicePath;  UINTN                     Index;  ConDevicePath = EfiLibGetVariable (ConsoleName, &gEfiGlobalVariableGuid);  if (ConDevicePath != NULL) {    EfiLibDeleteVariable (ConsoleName, &gEfiGlobalVariableGuid);    FreePool (ConDevicePath);    ConDevicePath = NULL;  };  //  // First add all console input device from console input menu  //  for (Index = 0; Index < ConsoleMenu->MenuNumber; Index++) {    NewMenuEntry = BOpt_GetMenuEntry (ConsoleMenu, Index);    NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;    if (NewConsoleContext->IsActive) {      ConDevicePath = AppendDevicePathInstance (                        ConDevicePath,                        NewConsoleContext->DevicePath                        );    }  }  for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {    NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);    NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;    if (((NewTerminalContext->IsConIn != 0) && (UpdatePageId == FORM_CON_IN_ID)) ||        ((NewTerminalContext->IsConOut != 0)  && (UpdatePageId == FORM_CON_OUT_ID)) ||        ((NewTerminalContext->IsStdErr  != 0) && (UpdatePageId == FORM_CON_ERR_ID))        ) {      Vendor.Header.Type    = MESSAGING_DEVICE_PATH;      Vendor.Header.SubType = MSG_VENDOR_DP;            ASSERT (NewTerminalContext->TerminalType < (sizeof (TerminalTypeGuid) / sizeof (TerminalTypeGuid[0])));      CopyMem (        &Vendor.Guid,        &TerminalTypeGuid[NewTerminalContext->TerminalType],        sizeof (EFI_GUID)        );      SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));      TerminalDevicePath = AppendDevicePathNode (                            NewTerminalContext->DevicePath,                            (EFI_DEVICE_PATH_PROTOCOL *) &Vendor                            );      ASSERT (TerminalDevicePath != NULL);      ChangeTerminalDevicePath (&TerminalDevicePath, TRUE);      ConDevicePath = AppendDevicePathInstance (                        ConDevicePath,                        TerminalDevicePath                        );    }  }  if (ConDevicePath != NULL) {    Status = gRT->SetVariable (                    ConsoleName,                    &gEfiGlobalVariableGuid,                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,                    GetDevicePathSize (ConDevicePath),                    ConDevicePath                    );    if (EFI_ERROR (Status)) {//.........这里部分代码省略.........
开发者ID:B-Rich,项目名称:edk2,代码行数:101,


示例3: SaveLockBox

/**  This function will save confidential information to lockbox.  @param Guid       the guid to identify the confidential information  @param Buffer     the address of the confidential information  @param Length     the length of the confidential information  @retval RETURN_SUCCESS            the information is saved successfully.  @retval RETURN_INVALID_PARAMETER  the Guid is NULL, or Buffer is NULL, or Length is 0  @retval RETURN_ALREADY_STARTED    the requested GUID already exist.  @retval RETURN_OUT_OF_RESOURCES   no enough resource to save the information.  @retval RETURN_ACCESS_DENIED      it is too late to invoke this interface  @retval RETURN_NOT_STARTED        it is too early to invoke this interface  @retval RETURN_UNSUPPORTED        the service is not supported by implementaion.**/RETURN_STATUSEFIAPISaveLockBox (    IN  GUID                        *Guid,    IN  VOID                        *Buffer,    IN  UINTN                       Length){    SMM_LOCK_BOX_DATA           *LockBox;    EFI_PHYSICAL_ADDRESS        SmramBuffer;    EFI_STATUS                  Status;    LIST_ENTRY                  *LockBoxQueue;    DEBUG ((EFI_D_INFO, "SmmLockBoxSmmLib SaveLockBox - Enter/n"));    //    // Basic check    //    if ((Guid == NULL) || (Buffer == NULL) || (Length == 0)) {        DEBUG ((EFI_D_INFO, "SmmLockBoxSmmLib SaveLockBox - Exit (%r)/n", EFI_INVALID_PARAMETER));        return EFI_INVALID_PARAMETER;    }    //    // Find LockBox    //    LockBox = InternalFindLockBoxByGuid (Guid);    if (LockBox != NULL) {        DEBUG ((EFI_D_INFO, "SmmLockBoxSmmLib SaveLockBox - Exit (%r)/n", EFI_ALREADY_STARTED));        return EFI_ALREADY_STARTED;    }    //    // Allocate SMRAM buffer    //    Status = gSmst->SmmAllocatePages (                 AllocateAnyPages,                 EfiRuntimeServicesData,                 EFI_SIZE_TO_PAGES (Length),                 &SmramBuffer             );    ASSERT_EFI_ERROR (Status);    if (EFI_ERROR (Status)) {        DEBUG ((EFI_D_INFO, "SmmLockBoxSmmLib SaveLockBox - Exit (%r)/n", EFI_OUT_OF_RESOURCES));        return EFI_OUT_OF_RESOURCES;    }    //    // Allocate LockBox    //    Status = gSmst->SmmAllocatePool (                 EfiRuntimeServicesData,                 sizeof(*LockBox),                 (VOID **)&LockBox             );    ASSERT_EFI_ERROR (Status);    if (EFI_ERROR (Status)) {        gSmst->SmmFreePages (SmramBuffer, EFI_SIZE_TO_PAGES (Length));        DEBUG ((EFI_D_INFO, "SmmLockBoxSmmLib SaveLockBox - Exit (%r)/n", EFI_OUT_OF_RESOURCES));        return EFI_OUT_OF_RESOURCES;    }    //    // Save data    //    CopyMem ((VOID *)(UINTN)SmramBuffer, (VOID *)(UINTN)Buffer, Length);    //    // Insert LockBox to queue    //    LockBox->Signature   = SMM_LOCK_BOX_DATA_SIGNATURE;    CopyMem (&LockBox->Guid, Guid, sizeof(EFI_GUID));    LockBox->Buffer      = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;    LockBox->Length      = (UINT64)Length;    LockBox->Attributes  = 0;    LockBox->SmramBuffer = SmramBuffer;    DEBUG ((               EFI_D_INFO,               "LockBoxGuid - %g, SmramBuffer - 0x%lx, Length - 0x%lx/n",               &LockBox->Guid,               LockBox->SmramBuffer,               LockBox->Length           ));//.........这里部分代码省略.........
开发者ID:EvanLloyd,项目名称:tianocore,代码行数:101,


示例4: TcgMeasureGptTable

//.........这里部分代码省略.........  if (EFI_ERROR (Status)) {    DEBUG ((EFI_D_ERROR, "Failed to Read Partition Table Header!/n"));    FreePool (PrimaryHeader);    return EFI_DEVICE_ERROR;  }    //  // Read the partition entry.  //  EntryPtr = (UINT8 *)AllocatePool (PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry);  if (EntryPtr == NULL) {    FreePool (PrimaryHeader);    return EFI_OUT_OF_RESOURCES;  }  Status = DiskIo->ReadDisk (                     DiskIo,                     BlockIo->Media->MediaId,                     MultU64x32(PrimaryHeader->PartitionEntryLBA, BlockIo->Media->BlockSize),                     PrimaryHeader->NumberOfPartitionEntries * PrimaryHeader->SizeOfPartitionEntry,                     EntryPtr                     );  if (EFI_ERROR (Status)) {    FreePool (PrimaryHeader);    FreePool (EntryPtr);    return EFI_DEVICE_ERROR;  }    //  // Count the valid partition  //  PartitionEntry    = (EFI_PARTITION_ENTRY *)EntryPtr;  NumberOfPartition = 0;  for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) {    if (!CompareGuid (&PartitionEntry->PartitionTypeGUID, &mZeroGuid)) {      NumberOfPartition++;      }    PartitionEntry++;  }  //  // Parepare Data for Measurement  //   EventSize = (UINT32)(sizeof (EFI_GPT_DATA) - sizeof (GptData->Partitions)                         + NumberOfPartition * PrimaryHeader->SizeOfPartitionEntry);  TcgEvent = (TCG_PCR_EVENT *) AllocateZeroPool (EventSize + sizeof (TCG_PCR_EVENT));  if (TcgEvent == NULL) {    FreePool (PrimaryHeader);    FreePool (EntryPtr);    return EFI_OUT_OF_RESOURCES;  }  TcgEvent->PCRIndex   = 5;  TcgEvent->EventType  = EV_EFI_GPT_EVENT;  TcgEvent->EventSize  = EventSize;  GptData = (EFI_GPT_DATA *) TcgEvent->Event;    //  // Copy the EFI_PARTITION_TABLE_HEADER and NumberOfPartition  //    CopyMem ((UINT8 *)GptData, (UINT8*)PrimaryHeader, sizeof (EFI_PARTITION_TABLE_HEADER));  GptData->NumberOfPartitions = NumberOfPartition;  //  // Copy the valid partition entry  //  PartitionEntry    = (EFI_PARTITION_ENTRY*)EntryPtr;  NumberOfPartition = 0;  for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) {    if (!CompareGuid (&PartitionEntry->PartitionTypeGUID, &mZeroGuid)) {      CopyMem (        (UINT8 *)&GptData->Partitions + NumberOfPartition * sizeof (EFI_PARTITION_ENTRY),        (UINT8 *)PartitionEntry,        sizeof (EFI_PARTITION_ENTRY)        );      NumberOfPartition++;    }    PartitionEntry++;  }  //  // Measure the GPT data  //  EventNumber = 1;  Status = TcgProtocol->HashLogExtendEvent (             TcgProtocol,             (EFI_PHYSICAL_ADDRESS) (UINTN) (VOID *) GptData,             (UINT64) TcgEvent->EventSize,             TPM_ALG_SHA,             TcgEvent,             &EventNumber,             &EventLogLastEntry             );  if (!EFI_ERROR (Status)) {    mMeasureGptCount++;  }  FreePool (PrimaryHeader);  FreePool (EntryPtr);  FreePool (TcgEvent);  return Status;}
开发者ID:AshleyDeSimone,项目名称:edk2,代码行数:101,


示例5: EfiOpen

//.........这里部分代码省略.........    }    // if there's no number after the second colon, default    // the end of memory    if (File->Size == 0) {      File->Size =  (UINTN)(0 - (UINTN)File->Buffer);    }    File->MaxPosition = File->Size;    File->BaseOffset = (UINTN)File->Buffer;  } else if (*PathName== 'l' || *PathName == 'L') {    if (DevNumber >= mLoadFileCount) {      goto ErrorExit;    }    File->Type = EfiOpenLoadFile;    File->EfiHandle = mLoadFile[DevNumber];    Status = gBS->HandleProtocol (File->EfiHandle, &gEfiLoadFileProtocolGuid, (VOID **)&File->LoadFile);    if (EFI_ERROR (Status)) {      goto ErrorExit;    }    Status = gBS->HandleProtocol (File->EfiHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);    if (EFI_ERROR (Status)) {      goto ErrorExit;    }    File->DevicePath = DuplicateDevicePath (DevicePath);  } else if (*PathName == 'b' || *PathName == 'B') {    // Handle b#:0x10000000:0x1234 address form b#:ADDRESS:SIZE    if (DevNumber >= mBlkIoCount) {      goto ErrorExit;    }    File->Type = EfiOpenBlockIo;    File->EfiHandle = mBlkIo[DevNumber];    EblFileDevicePath (File, "", OpenMode);    // 1st colon is at PathName[FileStart - 1]    File->DiskOffset = AsciiStrHexToUintn (&PathName[FileStart]);    // Find 2nd colon    while ((PathName[FileStart] != ':') && (PathName[FileStart] != '/0')) {      FileStart++;    }    // If we ran out of string, there's no extra data    if (PathName[FileStart] == '/0') {      Size = 0;    } else {      Size = AsciiStrHexToUintn (&PathName[FileStart + 1]);    }    // if a zero size is passed in (or the size is left out entirely),    // go to the end of the device.    if (Size == 0) {      File->Size = File->Size - File->DiskOffset;    } else {      File->Size = Size;    }    File->MaxPosition = File->Size;    File->BaseOffset = File->DiskOffset;  } else if ((*PathName) >= '0' && (*PathName <= '9')) {    // Get current IP address    Status = EblGetCurrentIpAddress (&Ip);    if (EFI_ERROR(Status)) {      AsciiPrint("Device IP Address is not configured./n");      goto ErrorExit;    }    // Parse X.X.X.X:Filename, only support IPv4 TFTP for now...    File->Type = EfiOpenTftp;    File->IsDirty = FALSE;    File->IsBufferValid = FALSE;    Status = ConvertIpStringToEfiIp (PathName, &File->ServerIp);  }  if (EFI_ERROR (Status)) {    goto ErrorExit;  }  GuardFile = (EFI_OPEN_FILE_GUARD *)AllocateZeroPool (sizeof (EFI_OPEN_FILE_GUARD));  if (GuardFile == NULL) {    goto ErrorExit;  }  GuardFile->Header = EFI_OPEN_FILE_GUARD_HEADER;  CopyMem (&(GuardFile->File), &FileData, sizeof (EFI_OPEN_FILE));  GuardFile->Footer = EFI_OPEN_FILE_GUARD_FOOTER;  return &(GuardFile->File);ErrorExit:  FreePool (File->DeviceName);  return NULL;}
开发者ID:wensunshine,项目名称:VisualUefi,代码行数:101,


示例6: Image

//.........这里部分代码省略.........              if (DataSizeFromFile1 == 1) {                DataFromFile1[InsertPosition1++] = OneByteFromFile1;              }              if (DataSizeFromFile2 == 1) {                DataFromFile2[InsertPosition2++] = OneByteFromFile2;              }            }          } else if (ReadStatus == InDiffPoint) {            if (DataSizeFromFile1 == 1) {              DataFromFile1[InsertPosition1++] = OneByteFromFile1;            }            if (DataSizeFromFile2 == 1) {              DataFromFile2[InsertPosition2++] = OneByteFromFile2;            }          } else if (ReadStatus == InPrevDiffPoint) {            if (OneByteFromFile1 == OneByteFromFile2) {              ReadStatus = OutOfDiffPoint;            }          }          //          // ReadStatus should be always equal InDiffPoint.          //          if ( InsertPosition1 == DifferentBytes ||               InsertPosition2 == DifferentBytes ||               (DataSizeFromFile1 == 0 && DataSizeFromFile2 == 0)             ) {            ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_DIFFERENCE_POINT), gShellDebug1HiiHandle, ++DiffPointNumber);            PrintDifferentPoint (FileName1, L"File1", DataFromFile1, InsertPosition1, DiffPointAddress, DifferentBytes);            PrintDifferentPoint (FileName2, L"File2", DataFromFile2, InsertPosition2, DiffPointAddress, DifferentBytes);            //            // One of two buffuers is empty, it means this is the last different point.            //            if (InsertPosition1 == 0 || InsertPosition2 == 0) {              break;            }            for (Index = 1; Index < InsertPosition1 && Index < InsertPosition2; Index++) {              if (DataFromFile1[Index] == DataFromFile2[Index]) {                ReadStatus = OutOfDiffPoint;                break;              }            }            if (ReadStatus == OutOfDiffPoint) {              //              // Try to find a new different point in the rest of DataFromFile.              //              for (; Index < MAX (InsertPosition1,InsertPosition2); Index++) {                if (DataFromFile1[Index] != DataFromFile2[Index]) {                  ReadStatus = InDiffPoint;                  DiffPointAddress += Index;                  break;                }              }            } else {              //              // Doesn't find a new different point, still in the same different point.              //              ReadStatus = InPrevDiffPoint;            }            CopyMem (DataFromFile1, DataFromFile1 + Index, InsertPosition1 - Index);            CopyMem (DataFromFile2, DataFromFile2 + Index, InsertPosition2 - Index);            SetMem (DataFromFile1 + InsertPosition1 - Index, (UINTN)DifferentBytes - InsertPosition1 + Index, 0);            SetMem (DataFromFile2 + InsertPosition2 - Index, (UINTN)DifferentBytes - InsertPosition2 + Index, 0);            InsertPosition1 -= Index;            InsertPosition2 -= Index;          }        }        SHELL_FREE_NON_NULL (DataFromFile1);        SHELL_FREE_NON_NULL (DataFromFile2);        if (DiffPointNumber == 0) {          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS), gShellDebug1HiiHandle);        } else {          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL), gShellDebug1HiiHandle);        }      }    }    ShellCommandLineFreeVarList (Package);  }  SHELL_FREE_NON_NULL(FileName1);  SHELL_FREE_NON_NULL(FileName2);  if (FileHandle1 != NULL) {    gEfiShellProtocol->CloseFile(FileHandle1);  }  if (FileHandle2 != NULL) {    gEfiShellProtocol->CloseFile(FileHandle2);  }  return (ShellStatus);}
开发者ID:jief666,项目名称:clover,代码行数:101,


示例7: Tpm2NvDefineSpace

/**  This command defines the attributes of an NV Index and causes the TPM to  reserve space to hold the data associated with the index.  If a definition already exists at the index, the TPM will return TPM_RC_NV_DEFINED.  @param[in]  AuthHandle         TPM_RH_OWNER or TPM_RH_PLATFORM+{PP}.  @param[in]  AuthSession        Auth Session context  @param[in]  Auth               The authorization data.  @param[in]  NvPublic           The public area of the index.    @retval EFI_SUCCESS            Operation completed successfully.  @retval EFI_DEVICE_ERROR       The command was unsuccessful.  @retval EFI_ALREADY_STARTED    The command was returned successfully, but NvIndex is already defined.**/EFI_STATUSEFIAPITpm2NvDefineSpace (  IN      TPMI_RH_PROVISION         AuthHandle,  IN      TPMS_AUTH_COMMAND         *AuthSession, OPTIONAL  IN      TPM2B_AUTH                *Auth,  IN      TPM2B_NV_PUBLIC           *NvPublic  ){  EFI_STATUS                        Status;  TPM2_NV_DEFINESPACE_COMMAND       SendBuffer;  TPM2_NV_DEFINESPACE_RESPONSE      RecvBuffer;  UINT32                            SendBufferSize;  UINT32                            RecvBufferSize;  UINT16                            NvPublicSize;  UINT8                             *Buffer;  UINT32                            SessionInfoSize;  TPM_RC                            ResponseCode;  //  // Construct command  //  SendBuffer.Header.tag = SwapBytes16(TPM_ST_SESSIONS);  SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_DefineSpace);  SendBuffer.AuthHandle = SwapBytes32 (AuthHandle);  //  // Add in Auth session  //  Buffer = (UINT8 *)&SendBuffer.AuthSession;  // sessionInfoSize  SessionInfoSize = CopyAuthSessionCommand (AuthSession, Buffer);  Buffer += SessionInfoSize;  SendBuffer.AuthSessionSize = SwapBytes32(SessionInfoSize);  //  // IndexAuth  //  WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16(Auth->size));  Buffer += sizeof(UINT16);  CopyMem(Buffer, Auth->buffer, Auth->size);  Buffer += Auth->size;  //  // NvPublic  //  NvPublicSize = NvPublic->size;  WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (NvPublicSize));  Buffer += sizeof(UINT16);  WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32 (NvPublic->nvPublic.nvIndex));  Buffer += sizeof(UINT32);  WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (NvPublic->nvPublic.nameAlg));  Buffer += sizeof(UINT16);  WriteUnaligned32 ((UINT32 *)Buffer, SwapBytes32 (ReadUnaligned32 ((UINT32 *)&NvPublic->nvPublic.attributes)));  Buffer += sizeof(UINT32);  WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (NvPublic->nvPublic.authPolicy.size));  Buffer += sizeof(UINT16);  CopyMem (Buffer, NvPublic->nvPublic.authPolicy.buffer, NvPublic->nvPublic.authPolicy.size);  Buffer += NvPublic->nvPublic.authPolicy.size;  WriteUnaligned16 ((UINT16 *)Buffer, SwapBytes16 (NvPublic->nvPublic.dataSize));  Buffer += sizeof(UINT16);  SendBufferSize = (UINT32)(Buffer - (UINT8 *)&SendBuffer);  SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);  //  // send Tpm command  //  RecvBufferSize = sizeof (RecvBuffer);  Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);  if (EFI_ERROR (Status)) {    return Status;  }  if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {    DEBUG ((EFI_D_ERROR, "Tpm2NvDefineSpace - RecvBufferSize Error - %x/n", RecvBufferSize));    return EFI_DEVICE_ERROR;  }  ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);  if (ResponseCode != TPM_RC_SUCCESS) {    DEBUG ((EFI_D_ERROR, "Tpm2NvDefineSpace - responseCode - %x/n", SwapBytes32(RecvBuffer.Header.responseCode)));  }  switch (ResponseCode) {//.........这里部分代码省略.........
开发者ID:B-Rich,项目名称:edk2,代码行数:101,


示例8: InitializeDebugAgent

/**  Initialize debug agent.  This function is used to set up debug enviroment for source level debug  in SMM code.  If InitFlag is DEBUG_AGENT_INIT_SMM, it will overirde IDT table entries  and initialize debug port. It will get debug agent Mailbox from GUIDed HOB,  it it exists, debug agent wiil copied it into the local Mailbox in SMM space.  it will overirde IDT table entries and initialize debug port. Context will be  NULL.  If InitFlag is DEBUG_AGENT_INIT_ENTER_SMI, debug agent will save Debug  Registers and get local Mailbox in SMM space. Context will be NULL.  If InitFlag is DEBUG_AGENT_INIT_EXIT_SMI, debug agent will restore Debug  Registers. Context will be NULL.  @param[in] InitFlag     Init flag is used to decide initialize process.  @param[in] Context      Context needed according to InitFlag.  @param[in] Function     Continue function called by debug agent library; it was                          optional.**/VOIDEFIAPIInitializeDebugAgent (  IN UINT32                InitFlag,  IN VOID                  *Context, OPTIONAL  IN DEBUG_AGENT_CONTINUE  Function  OPTIONAL  ){  EFI_STATUS                    Status;  UINT64                        DebugPortHandle;  IA32_IDT_GATE_DESCRIPTOR      IdtEntry[33];  IA32_DESCRIPTOR               IdtDescriptor;  IA32_DESCRIPTOR               *Ia32Idtr;  IA32_IDT_ENTRY                *Ia32IdtEntry;  IA32_DESCRIPTOR               Idtr;  UINT16                        IdtEntryCount;  DEBUG_AGENT_MAILBOX           *Mailbox;  UINT64                        *MailboxLocation;  switch (InitFlag) {  case DEBUG_AGENT_INIT_SMM:    //    // Install configuration table for persisted vector handoff info    //    Status = gSmst->SmmInstallConfigurationTable (                      gSmst,                      &gEfiVectorHandoffTableGuid,                      (VOID *) &mVectorHandoffInfoDebugAgent[0],                      sizeof (EFI_VECTOR_HANDOFF_INFO) * mVectorHandoffInfoCount                      );    if (EFI_ERROR (Status)) {      DEBUG ((EFI_D_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!/n"));      CpuDeadLoop ();    }    //    // Check if Debug Agent initialized in DXE phase    //    Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **) &Mailbox);    if (Status == EFI_SUCCESS && Mailbox != NULL) {      VerifyMailboxChecksum (Mailbox);      mMailboxPointer = Mailbox;      break;    }    //    // Check if Debug Agent initialized in SEC/PEI phase    //    Mailbox = GetMailboxFromHob ();    if (Mailbox != NULL) {      mMailboxPointer = Mailbox;      break;    }    //    // Debug Agent was not initialized before, use the local mailbox.    //    ZeroMem (&mLocalMailbox, sizeof (DEBUG_AGENT_MAILBOX));    Mailbox = &mLocalMailbox;    //    // Save original IDT entries    //    AsmReadIdtr (&IdtDescriptor);    CopyMem (&IdtEntry, (VOID *)IdtDescriptor.Base, 33 * sizeof(IA32_IDT_GATE_DESCRIPTOR));    //    // Initialized Debug Agent    //    InitializeDebugIdt ();    DebugPortHandle = (UINT64) (UINTN)DebugPortInitialize ((DEBUG_PORT_HANDLE) (UINTN)Mailbox->DebugPortHandle, NULL);    UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, DebugPortHandle);    mMailboxPointer = Mailbox;    //    // Trigger one software interrupt to inform HOST    //    TriggerSoftInterrupt (SYSTEM_RESET_SIGNATURE);    SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);    //    // Memory has been ready    //    if (IsHostAttached ()) {//.........这里部分代码省略.........
开发者ID:jeppeter,项目名称:vbox,代码行数:101,


示例9: freed

/**   function to insert string items into a list in the correct alphabetical place   the resultant list is a double NULL terminated list of NULL terminated strings.   upon successful return the memory must be caller freed (unless passed back in    via a loop where it will get reallocated).   @param[in,out] DestList    double pointer to the list. may be NULL.   @param[in,out] DestSize    pointer to the size of list. may be 0, if DestList is NULL.   @param[in]     Item        the item to insert.   @retval EFI_SUCCESS        the operation was successful.**/EFI_STATUSEFIAPILexicalInsertIntoList(  IN OUT   CHAR16 **DestList,   IN OUT   UINTN  *DestSize,  IN CONST CHAR16 *Item  ){  CHAR16                              *NewList;  INTN                                LexicalMatchValue;  CHAR16                              *LexicalSpot;  UINTN                               SizeOfAddedNameInBytes;  //  // If there are none, then just return with success  //  if (Item == NULL || *Item == CHAR_NULL || StrLen(Item)==0) {    return (EFI_SUCCESS);  }  NewList = *DestList;  SizeOfAddedNameInBytes = StrSize(Item);  NewList = ReallocatePool(*DestSize, (*DestSize) + SizeOfAddedNameInBytes, NewList);  (*DestSize) = (*DestSize) + SizeOfAddedNameInBytes;  //  // Find the correct spot in the list  //  for (LexicalSpot = NewList    ; LexicalSpot != NULL && LexicalSpot < NewList + (*DestSize)    ; LexicalSpot += StrLen(LexicalSpot) + 1    ) {    //    // Get Lexical Comparison Value between PrevCommand and Command list entry    //    LexicalMatchValue = gUnicodeCollation->StriColl (                                              gUnicodeCollation,                                              (CHAR16 *)LexicalSpot,                                              (CHAR16 *)Item                                              );    //    // The new item goes before this one.    //    if (LexicalMatchValue > 0 || StrLen(LexicalSpot) == 0) {      if (StrLen(LexicalSpot) != 0) {        //        // Move this and all other items out of the way        //        CopyMem(          LexicalSpot + (SizeOfAddedNameInBytes/sizeof(CHAR16)),          LexicalSpot,          (*DestSize) - SizeOfAddedNameInBytes - ((LexicalSpot - NewList) * sizeof(CHAR16))          );      }      //      // Stick this one in place      //      StrCpyS(LexicalSpot, SizeOfAddedNameInBytes/sizeof(CHAR16), Item);      break;    }  }  *DestList = NewList;  return (EFI_SUCCESS);}
开发者ID:OznOg,项目名称:edk2,代码行数:81,


示例10: CbPeiEntryPoint

//.........这里部分代码省略.........  //  AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);  if (RegEax >= 0x80000008) {    AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);    PhysicalAddressBits = (UINT8) RegEax;  } else {    PhysicalAddressBits  = 36;  }  //  // Create a CPU hand-off information  //  BuildCpuHob (PhysicalAddressBits, 16);  //  // Report Local APIC range  //  BuildMemoryMappedIoRangeHob (0xFEC80000, SIZE_512KB);  //  // Boot mode  //  Status = PeiServicesSetBootMode (BOOT_WITH_FULL_CONFIGURATION);  ASSERT_EFI_ERROR (Status);  Status = PeiServicesInstallPpi (mPpiBootMode);  ASSERT_EFI_ERROR (Status);   //  // Set pcd to save the upper coreboot header in case the dxecore will  // erase 0~4k memory  //  pCbHeader = NULL;  if ((CbParseGetCbHeader (1, &pCbHeader) == RETURN_SUCCESS)    && ((UINTN)pCbHeader > BASE_4KB)) {    DEBUG((EFI_D_ERROR, "Actual Coreboot header: %p./n", pCbHeader));    PcdSet32 (PcdCbHeaderPointer, (UINT32)(UINTN)pCbHeader);  }  //  // Create guid hob for system tables like acpi table and smbios table  //  pAcpiTable = NULL;  AcpiTableSize = 0;  pSmbiosTable = NULL;  SmbiosTableSize = 0;  Status = CbParseAcpiTable (&pAcpiTable, &AcpiTableSize);  if (EFI_ERROR (Status)) {    // ACPI table is oblidgible    DEBUG ((EFI_D_ERROR, "Failed to find the required acpi table/n"));    ASSERT (FALSE);  }  CbParseSmbiosTable (&pSmbiosTable, &SmbiosTableSize);  pSystemTableInfo = NULL;  pSystemTableInfo = BuildGuidHob (&gUefiSystemTableInfoGuid, sizeof (SYSTEM_TABLE_INFO));  ASSERT (pSystemTableInfo != NULL);  pSystemTableInfo->AcpiTableBase = (UINT64) (UINTN)pAcpiTable;  pSystemTableInfo->AcpiTableSize = AcpiTableSize;  pSystemTableInfo->SmbiosTableBase = (UINT64) (UINTN)pSmbiosTable;  pSystemTableInfo->SmbiosTableSize = SmbiosTableSize;  DEBUG ((EFI_D_ERROR, "Detected Acpi Table at 0x%lx, length 0x%x/n", pSystemTableInfo->AcpiTableBase, pSystemTableInfo->AcpiTableSize));  DEBUG ((EFI_D_ERROR, "Detected Smbios Table at 0x%lx, length 0x%x/n", pSystemTableInfo->SmbiosTableBase, pSystemTableInfo->SmbiosTableSize));  DEBUG ((EFI_D_ERROR, "Create system table info guid hob/n"));  //  // Create guid hob for acpi board information  //  Status = CbParseFadtInfo (&PmCtrlRegBase, &PmTimerRegBase, &ResetRegAddress, &ResetValue, &PmEvtBase, &PmGpeEnBase);  ASSERT_EFI_ERROR (Status);  pAcpiBoardInfo = NULL;  pAcpiBoardInfo = BuildGuidHob (&gUefiAcpiBoardInfoGuid, sizeof (ACPI_BOARD_INFO));  ASSERT (pAcpiBoardInfo != NULL);  pAcpiBoardInfo->PmCtrlRegBase = (UINT64)PmCtrlRegBase;  pAcpiBoardInfo->PmTimerRegBase = (UINT64)PmTimerRegBase;  pAcpiBoardInfo->ResetRegAddress = (UINT64)ResetRegAddress;  pAcpiBoardInfo->ResetValue = (UINT8)ResetValue;  pAcpiBoardInfo->PmEvtBase = (UINT64)PmEvtBase;  pAcpiBoardInfo->PmGpeEnBase = (UINT64)PmGpeEnBase;  DEBUG ((EFI_D_ERROR, "Create acpi board info guid hob/n"));  //  // Create guid hob for frame buffer information  //  ZeroMem (&FbInfo, sizeof (FRAME_BUFFER_INFO));  Status = CbParseFbInfo (&FbInfo);  if (!EFI_ERROR (Status)) {    pFbInfo = BuildGuidHob (&gUefiFrameBufferInfoGuid, sizeof (FRAME_BUFFER_INFO));    ASSERT (pSystemTableInfo != NULL);    CopyMem (pFbInfo, &FbInfo, sizeof (FRAME_BUFFER_INFO));    DEBUG ((EFI_D_ERROR, "Create frame buffer info guid hob/n"));  }  //  // Mask off all legacy 8259 interrupt sources  //  IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);  IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE,  0xFF);  return EFI_SUCCESS;}
开发者ID:Gshoe2006,项目名称:edk2,代码行数:101,


示例11: DxePcdGetNextTokenSpace

/**  Get next token space in PCD database according to given token space guid.    @param Guid            Given token space guid. If NULL, then Guid will be set to                          the first PCD token space in PCD database, If not NULL, then                         Guid will be set to next PCD token space.  @retval EFI_UNSUPPORTED   @retval EFI_NOT_FOUND   If PCD database has no token space table or can not find given                          token space in PCD database.  @retval EFI_SUCCESS     Success to get next token space guid.**/EFI_STATUSEFIAPIDxePcdGetNextTokenSpace (  IN OUT CONST EFI_GUID               **Guid  ){  UINTN               Idx;  UINTN               Idx2;  UINTN               Idx3;  UINTN               PeiTokenSpaceTableSize;  UINTN               DxeTokenSpaceTableSize;  EFI_GUID            **PeiTokenSpaceTable;  EFI_GUID            **DxeTokenSpaceTable;  BOOLEAN             Match;  BOOLEAN             PeiExMapTableEmpty;  BOOLEAN             DxeExMapTableEmpty;  ASSERT (Guid != NULL);    PeiExMapTableEmpty = PEI_EXMAP_TABLE_EMPTY;  DxeExMapTableEmpty = DXE_EXMAP_TABLE_EMPTY;  if (PeiExMapTableEmpty && DxeExMapTableEmpty) {    if (*Guid != NULL) {      return EFI_NOT_FOUND;    } else {      return EFI_SUCCESS;    }  }      if (TmpTokenSpaceBuffer[0] == NULL) {    PeiTokenSpaceTableSize = 0;    if (!PeiExMapTableEmpty) {      PeiTokenSpaceTableSize = PEI_EXMAPPING_TABLE_SIZE;      PeiTokenSpaceTable = GetDistinctTokenSpace (&PeiTokenSpaceTableSize,                            mPcdDatabase->PeiDb.Init.ExMapTable,                            mPcdDatabase->PeiDb.Init.GuidTable                            );      CopyMem (TmpTokenSpaceBuffer, PeiTokenSpaceTable, sizeof (EFI_GUID*) * PeiTokenSpaceTableSize);    }    if (!DxeExMapTableEmpty) {      DxeTokenSpaceTableSize = DXE_EXMAPPING_TABLE_SIZE;      DxeTokenSpaceTable = GetDistinctTokenSpace (&DxeTokenSpaceTableSize,                            mPcdDatabase->DxeDb.Init.ExMapTable,                            mPcdDatabase->DxeDb.Init.GuidTable                            );      //      // Make sure EFI_GUID in DxeTokenSpaceTable does not exist in PeiTokenSpaceTable      //      for (Idx2 = 0, Idx3 = PeiTokenSpaceTableSize; Idx2 < DxeTokenSpaceTableSize; Idx2++) {        Match = FALSE;        for (Idx = 0; Idx < PeiTokenSpaceTableSize; Idx++) {          if (CompareGuid (TmpTokenSpaceBuffer[Idx], DxeTokenSpaceTable[Idx2])) {            Match = TRUE;            break;          }        }        if (!Match) {          TmpTokenSpaceBuffer[Idx3++] = DxeTokenSpaceTable[Idx2];        }      }    }  }  if (*Guid == NULL) {    *Guid = TmpTokenSpaceBuffer[0];    return EFI_SUCCESS;  }    for (Idx = 0; Idx < (PEI_EXMAPPING_TABLE_SIZE + DXE_EXMAPPING_TABLE_SIZE); Idx++) {    if(CompareGuid (*Guid, TmpTokenSpaceBuffer[Idx])) {      Idx++;      *Guid = TmpTokenSpaceBuffer[Idx];      return EFI_SUCCESS;    }  }  return EFI_NOT_FOUND;}
开发者ID:etiago,项目名称:vbox,代码行数:95,


示例12: 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:VirtualMonitor,项目名称:VirtualMonitor,代码行数:100,


示例13: PartitionInstallGptChildHandles

//.........这里部分代码省略.........                     PartEntry                     );  if (EFI_ERROR (Status)) {    GptValidStatus = Status;    DEBUG ((EFI_D_ERROR, " Partition Entry ReadDisk error/n"));    goto Done;  }  DEBUG ((EFI_D_INFO, " Partition entries read block success/n"));  DEBUG ((EFI_D_INFO, " Number of partition entries: %d/n", PrimaryHeader->NumberOfPartitionEntries));  PEntryStatus = AllocateZeroPool (PrimaryHeader->NumberOfPartitionEntries * sizeof (EFI_PARTITION_ENTRY_STATUS));  if (PEntryStatus == NULL) {    DEBUG ((EFI_D_ERROR, "Allocate pool error/n"));    goto Done;  }  //  // Check the integrity of partition entries  //  PartitionCheckGptEntry (PrimaryHeader, PartEntry, PEntryStatus);  //  // If we got this far the GPT layout of the disk is valid and we should return true  //  GptValidStatus = EFI_SUCCESS;  //  // Create child device handles  //  for (Index = 0; Index < PrimaryHeader->NumberOfPartitionEntries; Index++) {    Entry = (EFI_PARTITION_ENTRY *) ((UINT8 *) PartEntry + Index * PrimaryHeader->SizeOfPartitionEntry);    if (CompareGuid (&Entry->PartitionTypeGUID, &gEfiPartTypeUnusedGuid) ||        PEntryStatus[Index].OutOfRange ||        PEntryStatus[Index].Overlap ||        PEntryStatus[Index].OsSpecific        ) {      //      // Don't use null EFI Partition Entries, Invalid Partition Entries or OS specific      // partition Entries      //      continue;    }    ZeroMem (&HdDev, sizeof (HdDev));    HdDev.Header.Type     = MEDIA_DEVICE_PATH;    HdDev.Header.SubType  = MEDIA_HARDDRIVE_DP;    SetDevicePathNodeLength (&HdDev.Header, sizeof (HdDev));    HdDev.PartitionNumber = (UINT32) Index + 1;    HdDev.MBRType         = MBR_TYPE_EFI_PARTITION_TABLE_HEADER;    HdDev.SignatureType   = SIGNATURE_TYPE_GUID;    HdDev.PartitionStart  = Entry->StartingLBA;    HdDev.PartitionSize   = Entry->EndingLBA - Entry->StartingLBA + 1;    CopyMem (HdDev.Signature, &Entry->UniquePartitionGUID, sizeof (EFI_GUID));    DEBUG ((EFI_D_INFO, " Index : %d/n", (UINT32) Index));    DEBUG ((EFI_D_INFO, " Start LBA : %lx/n", (UINT64) HdDev.PartitionStart));    DEBUG ((EFI_D_INFO, " End LBA : %lx/n", (UINT64) Entry->EndingLBA));    DEBUG ((EFI_D_INFO, " Partition size: %lx/n", (UINT64) HdDev.PartitionSize));    DEBUG ((EFI_D_INFO, " Start : %lx", MultU64x32 (Entry->StartingLBA, BlockSize)));    DEBUG ((EFI_D_INFO, " End : %lx/n", MultU64x32 (Entry->EndingLBA, BlockSize)));    Status = PartitionInstallChildHandle (               This,               Handle,               DiskIo,               BlockIo,               BlockIo2,               DevicePath,               (EFI_DEVICE_PATH_PROTOCOL *) &HdDev,               Entry->StartingLBA,               Entry->EndingLBA,               BlockSize,               CompareGuid(&Entry->PartitionTypeGUID, &gEfiPartTypeSystemPartGuid)               );  }  DEBUG ((EFI_D_INFO, "Prepare to Free Pool/n"));Done:  if (ProtectiveMbr != NULL) {    FreePool (ProtectiveMbr);  }  if (PrimaryHeader != NULL) {    FreePool (PrimaryHeader);  }  if (BackupHeader != NULL) {    FreePool (BackupHeader);  }  if (PartEntry != NULL) {    FreePool (PartEntry);  }  if (PEntryStatus != NULL) {    FreePool (PEntryStatus);  }  return GptValidStatus;}
开发者ID:VirtualMonitor,项目名称:VirtualMonitor,代码行数:101,


示例14: WinNtSerialIoSetAttributes

//.........这里部分代码省略.........    gBS->RestoreTPL (Tpl);    return EFI_DEVICE_ERROR;  }  //  // Map EFI com setting to NT  //  Private->NtDCB.BaudRate         = ConvertBaud2Nt (BaudRate);  Private->NtDCB.ByteSize         = ConvertData2Nt (DataBits);  Private->NtDCB.Parity           = ConvertParity2Nt (Parity);  Private->NtDCB.StopBits         = ConvertStop2Nt (StopBits);  Private->NtDCB.fBinary          = TRUE;  Private->NtDCB.fParity          = Private->NtDCB.Parity == NOPARITY ? FALSE : TRUE;  Private->NtDCB.fOutxCtsFlow     = FALSE;  Private->NtDCB.fOutxDsrFlow     = FALSE;  Private->NtDCB.fDtrControl      = DTR_CONTROL_ENABLE;  Private->NtDCB.fDsrSensitivity  = FALSE;  Private->NtDCB.fOutX            = FALSE;  Private->NtDCB.fInX             = FALSE;  Private->NtDCB.fRtsControl      = RTS_CONTROL_ENABLE;  Private->NtDCB.fNull            = FALSE;  //  //  Set new values  //  Result = Private->WinNtThunk->SetCommState (Private->NtHandle, &Private->NtDCB);  if (!Result) {    Private->NtError = Private->WinNtThunk->GetLastError ();    DEBUG ((EFI_D_ERROR, "SerialSetAttributes: SetCommState %d/n", Private->NtError));    gBS->RestoreTPL (Tpl);    return EFI_DEVICE_ERROR;  }  //  //  Set com port read/write timeout values  //  ConvertedTime = ConvertTime2Nt (Timeout);  PortTimeOuts.ReadIntervalTimeout = MAXDWORD;  PortTimeOuts.ReadTotalTimeoutMultiplier = 0;  PortTimeOuts.ReadTotalTimeoutConstant = ConvertedTime;  PortTimeOuts.WriteTotalTimeoutMultiplier = ConvertedTime == 0 ? 1 : ConvertedTime;  PortTimeOuts.WriteTotalTimeoutConstant = 0;  if (!Private->WinNtThunk->SetCommTimeouts (Private->NtHandle, &PortTimeOuts)) {    Private->NtError = Private->WinNtThunk->GetLastError ();    DEBUG ((EFI_D_ERROR, "SerialSetAttributes: SetCommTimeouts %d/n", Private->NtError));    gBS->RestoreTPL (Tpl);    return EFI_DEVICE_ERROR;  }  //  //  Update mode  //  Private->SerialIoMode.BaudRate          = BaudRate;  Private->SerialIoMode.ReceiveFifoDepth  = ReceiveFifoDepth;  Private->SerialIoMode.Timeout           = Timeout;  Private->SerialIoMode.Parity            = Parity;  Private->SerialIoMode.DataBits          = DataBits;  Private->SerialIoMode.StopBits          = StopBits;  //  // See if Device Path Node has actually changed  //  if (Private->UartDevicePath.BaudRate     == BaudRate &&      Private->UartDevicePath.DataBits     == DataBits &&      Private->UartDevicePath.Parity       == Parity   &&      Private->UartDevicePath.StopBits     == StopBits    ) {    gBS->RestoreTPL(Tpl);    return EFI_SUCCESS;  }  //  // Update the device path  //  Private->UartDevicePath.BaudRate  = BaudRate;  Private->UartDevicePath.DataBits  = DataBits;  Private->UartDevicePath.Parity    = (UINT8) Parity;  Private->UartDevicePath.StopBits  = (UINT8) StopBits;  Status = EFI_SUCCESS;  if (Private->Handle != NULL) {    Uart = (UART_DEVICE_PATH *) (             (UINTN) Private->DevicePath             + GetDevicePathSize (Private->ParentDevicePath)             - END_DEVICE_PATH_LENGTH             );    CopyMem (Uart, &Private->UartDevicePath, sizeof (UART_DEVICE_PATH));    Status = gBS->ReinstallProtocolInterface (                    Private->Handle,                    &gEfiDevicePathProtocolGuid,                    Private->DevicePath,                    Private->DevicePath                    );  }  gBS->RestoreTPL (Tpl);  return Status;}
开发者ID:EvanLloyd,项目名称:tianocore,代码行数:101,


示例15: GetSmramProfileData

/**  Get and dump SMRAM profile data.  @return EFI_SUCCESS   Get the SMRAM profile data successfully.  @return other         Fail to get the SMRAM profile data.**/EFI_STATUSGetSmramProfileData (  VOID  ){  EFI_STATUS                                    Status;  UINTN                                         CommSize;  UINT8                                         *CommBuffer;  EFI_SMM_COMMUNICATE_HEADER                    *CommHeader;  SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO      *CommGetProfileInfo;  SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA      *CommGetProfileData;  UINT64                                        ProfileSize;  PHYSICAL_ADDRESS                              ProfileBuffer;  EFI_SMM_COMMUNICATION_PROTOCOL                *SmmCommunication;  Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &SmmCommunication);  if (EFI_ERROR (Status)) {    DEBUG ((EFI_D_ERROR, "SmramProfile: Locate SmmCommunication protocol - %r/n", Status));    return Status;  }  CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA);  CommBuffer = AllocateZeroPool (CommSize);  if (CommBuffer == NULL) {    Status = EFI_OUT_OF_RESOURCES;    Print (L"SmramProfile: AllocateZeroPool (0x%x) for comm buffer - %r/n", CommSize, Status);    return Status;  }  //  // Get Size  //  CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0];  CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof (gEdkiiMemoryProfileGuid));  CommHeader->MessageLength = sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO);  CommGetProfileInfo = (SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO *) &CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];  CommGetProfileInfo->Header.Command      = SMRAM_PROFILE_COMMAND_GET_PROFILE_INFO;  CommGetProfileInfo->Header.DataLength   = sizeof (*CommGetProfileInfo);  CommGetProfileInfo->Header.ReturnStatus = (UINT64)-1;  CommGetProfileInfo->ProfileSize         = 0;  CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength;  Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize);  if (EFI_ERROR (Status)) {    FreePool (CommBuffer);    DEBUG ((EFI_D_ERROR, "SmramProfile: SmmCommunication - %r/n", Status));    return Status;  }  if (CommGetProfileInfo->Header.ReturnStatus != 0) {    Print (L"SmramProfile: GetProfileInfo - 0x%0x/n", CommGetProfileInfo->Header.ReturnStatus);    return EFI_SUCCESS;  }  ProfileSize = CommGetProfileInfo->ProfileSize;  //  // Get Data  //  ProfileBuffer = (PHYSICAL_ADDRESS) (UINTN) AllocateZeroPool ((UINTN) ProfileSize);  if (ProfileBuffer == 0) {    FreePool (CommBuffer);    Status = EFI_OUT_OF_RESOURCES;    Print (L"SmramProfile: AllocateZeroPool (0x%x) for profile buffer - %r/n", (UINTN) ProfileSize, Status);    return Status;  }  CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0];  CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof(gEdkiiMemoryProfileGuid));  CommHeader->MessageLength = sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA);  CommGetProfileData = (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA *) &CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];  CommGetProfileData->Header.Command      = SMRAM_PROFILE_COMMAND_GET_PROFILE_DATA;  CommGetProfileData->Header.DataLength   = sizeof (*CommGetProfileData);  CommGetProfileData->Header.ReturnStatus = (UINT64)-1;  CommGetProfileData->ProfileSize         = ProfileSize;  CommGetProfileData->ProfileBuffer       = ProfileBuffer;  CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength;  Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize);  ASSERT_EFI_ERROR (Status);  if (CommGetProfileData->Header.ReturnStatus != 0) {    FreePool ((VOID *) (UINTN) CommGetProfileData->ProfileBuffer);    FreePool (CommBuffer);    Print (L"GetProfileData - 0x%x/n", CommGetProfileData->Header.ReturnStatus);    return EFI_SUCCESS;  }  Print (L"SmramProfileSize - 0x%x/n", CommGetProfileData->ProfileSize);  Print (L"======= SmramProfile begin =======/n");//.........这里部分代码省略.........
开发者ID:wensunshine,项目名称:VisualUefi,代码行数:101,


示例16: bytes

/**  Used to allocate and build a device path node for a SCSI device on a SCSI channel.  @param[in]      This        A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.  @param[in]      Target      The Target is an array of size TARGET_MAX_BYTES and it specifies the                              Target ID of the SCSI device for which a device path node is to be                              allocated and built. Transport drivers may chose to utilize a subset of                              this size to suit the representation of targets. For example, a Fibre                              Channel driver may use only 8 bytes (WWN) in the array to represent a                              FC target.  @param[in]       Lun        The LUN of the SCSI device for which a device path node is to be                              allocated and built.  @param[in, out]  DevicePath A pointer to a single device path node that describes the SCSI device                              specified by Target and Lun. This function is responsible for                              allocating the buffer DevicePath with the boot service                              AllocatePool(). It is the caller's responsibility to free                              DevicePath when the caller is finished with DevicePath.  @retval EFI_SUCCESS           The device path node that describes the SCSI device specified by                                Target and Lun was allocated and returned in                                DevicePath.  @retval EFI_INVALID_PARAMETER DevicePath is NULL.  @retval EFI_NOT_FOUND         The SCSI devices specified by Target and Lun does not exist                                on the SCSI channel.  @retval EFI_OUT_OF_RESOURCES  There are not enough resources to allocate DevicePath.**/EFI_STATUSEFIAPIIScsiExtScsiPassThruBuildDevicePath (  IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL  *This,  IN UINT8                            *Target,  IN UINT64                           Lun,  IN OUT EFI_DEVICE_PATH_PROTOCOL     **DevicePath  ){  ISCSI_DRIVER_DATA             *Private;  ISCSI_SESSION                 *Session;  ISCSI_SESSION_CONFIG_NVDATA   *ConfigNvData;  ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;  EFI_DEV_PATH                  *Node;  UINTN                         DevPathNodeLen;  if (DevicePath == NULL) {    return EFI_INVALID_PARAMETER;  }  if (Target[0] != 0) {    return EFI_NOT_FOUND;  }  Private       = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);  Session       = &Private->Session;  ConfigNvData  = &Session->ConfigData.NvData;  AuthConfig    = &Session->AuthData.AuthConfig;  if (CompareMem (&Lun, ConfigNvData->BootLun, sizeof (UINT64)) != 0) {    return EFI_NOT_FOUND;  }  DevPathNodeLen  = sizeof (ISCSI_DEVICE_PATH) + AsciiStrLen (ConfigNvData->TargetName) + 1;  Node            = AllocatePool (DevPathNodeLen);  if (Node == NULL) {    return EFI_OUT_OF_RESOURCES;  }  Node->DevPath.Type    = MESSAGING_DEVICE_PATH;  Node->DevPath.SubType = MSG_ISCSI_DP;  SetDevicePathNodeLength (&Node->DevPath, (UINT16)DevPathNodeLen);  //  // 0 for TCP, others are reserved.  //  Node->Iscsi.NetworkProtocol = 0;  Node->Iscsi.LoginOption     = 0;  switch (AuthConfig->CHAPType) {  case ISCSI_CHAP_NONE:    Node->Iscsi.LoginOption |= 0x0800;    break;  case ISCSI_CHAP_UNI:    Node->Iscsi.LoginOption |= 0x1000;    break;  default:    break;  }  CopyMem (&Node->Iscsi.Lun, ConfigNvData->BootLun, sizeof (UINT64));  Node->Iscsi.TargetPortalGroupTag = Session->TargetPortalGroupTag;  AsciiStrCpy ((CHAR8 *) Node + sizeof (ISCSI_DEVICE_PATH), ConfigNvData->TargetName);  *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node;  return EFI_SUCCESS;}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:97,


示例17: NvmeCreatePrpList

/**  Create PRP lists for Data transfer which is larger than 2 memory pages.  @param[in] Private          The pointer to the PEI_NVME_CONTROLLER_PRIVATE_DATA data structure.  @param[in] PhysicalAddr     The physical base address of Data Buffer.  @param[in] Pages            The number of pages to be transfered.  @retval The pointer Value to the first PRP List of the PRP lists.**/UINT64NvmeCreatePrpList (  IN     PEI_NVME_CONTROLLER_PRIVATE_DATA    *Private,  IN     EFI_PHYSICAL_ADDRESS                PhysicalAddr,  IN     UINTN                               Pages  ){  UINTN                   PrpEntryNo;  UINTN                   PrpListNo;  UINT64                  PrpListBase;  VOID                    *PrpListHost;  UINTN                   PrpListIndex;  UINTN                   PrpEntryIndex;  UINT64                  Remainder;  EFI_PHYSICAL_ADDRESS    PrpListPhyAddr;  UINTN                   Bytes;  UINT8                   *PrpEntry;  EFI_PHYSICAL_ADDRESS    NewPhyAddr;  //  // The number of Prp Entry in a memory page.  //  PrpEntryNo = EFI_PAGE_SIZE / sizeof (UINT64);  //  // Calculate total PrpList number.  //  PrpListNo = (UINTN) DivU64x64Remainder ((UINT64)Pages, (UINT64)PrpEntryNo, &Remainder);  if (Remainder != 0) {    PrpListNo += 1;  }  if (PrpListNo > NVME_PRP_SIZE) {    DEBUG ((      DEBUG_ERROR,      "%a: The implementation only supports PrpList number up to 4."      " But %d are needed here./n",      __FUNCTION__,      PrpListNo      ));    return 0;  }  PrpListHost = (VOID *)(UINTN) NVME_PRP_BASE (Private);  Bytes = EFI_PAGES_TO_SIZE (PrpListNo);  PrpListPhyAddr = (UINT64)(UINTN)(PrpListHost);  //  // Fill all PRP lists except of last one.  //  ZeroMem (PrpListHost, Bytes);  for (PrpListIndex = 0; PrpListIndex < PrpListNo - 1; ++PrpListIndex) {    PrpListBase = (UINTN)PrpListHost + PrpListIndex * EFI_PAGE_SIZE;    for (PrpEntryIndex = 0; PrpEntryIndex < PrpEntryNo; ++PrpEntryIndex) {      PrpEntry = (UINT8 *)(UINTN) (PrpListBase + PrpEntryIndex * sizeof(UINT64));      if (PrpEntryIndex != PrpEntryNo - 1) {        //        // Fill all PRP entries except of last one.        //        CopyMem (PrpEntry, (VOID *)(UINTN) (&PhysicalAddr), sizeof (UINT64));        PhysicalAddr += EFI_PAGE_SIZE;      } else {        //        // Fill last PRP entries with next PRP List pointer.        //        NewPhyAddr = (PrpListPhyAddr + (PrpListIndex + 1) * EFI_PAGE_SIZE);        CopyMem (PrpEntry, (VOID *)(UINTN) (&NewPhyAddr), sizeof (UINT64));      }    }  }  //  // Fill last PRP list.  //  PrpListBase = (UINTN)PrpListHost + PrpListIndex * EFI_PAGE_SIZE;  for (PrpEntryIndex = 0; PrpEntryIndex < ((Remainder != 0) ? Remainder : PrpEntryNo); ++PrpEntryIndex) {    PrpEntry = (UINT8 *)(UINTN) (PrpListBase + PrpEntryIndex * sizeof(UINT64));    CopyMem (PrpEntry, (VOID *)(UINTN) (&PhysicalAddr), sizeof (UINT64));    PhysicalAddr += EFI_PAGE_SIZE;  }  return PrpListPhyAddr;}
开发者ID:MattDevo,项目名称:edk2,代码行数:95,


示例18: Tpm2NvReadPublic

/**  This command is used to read the public area and Name of an NV Index.  @param[in]  NvIndex            The NV Index.  @param[out] NvPublic           The public area of the index.  @param[out] NvName             The Name of the nvIndex.    @retval EFI_SUCCESS            Operation completed successfully.  @retval EFI_DEVICE_ERROR       The command was unsuccessful.  @retval EFI_NOT_FOUND          The command was returned successfully, but NvIndex is not found.**/EFI_STATUSEFIAPITpm2NvReadPublic (  IN      TPMI_RH_NV_INDEX          NvIndex,  OUT     TPM2B_NV_PUBLIC           *NvPublic,  OUT     TPM2B_NAME                *NvName  ){  EFI_STATUS                        Status;  TPM2_NV_READPUBLIC_COMMAND        SendBuffer;  TPM2_NV_READPUBLIC_RESPONSE       RecvBuffer;  UINT32                            SendBufferSize;  UINT32                            RecvBufferSize;  UINT16                            NvPublicSize;  UINT16                            NvNameSize;  UINT8                             *Buffer;  TPM_RC                            ResponseCode;  //  // Construct command  //  SendBuffer.Header.tag = SwapBytes16(TPM_ST_NO_SESSIONS);  SendBuffer.Header.commandCode = SwapBytes32(TPM_CC_NV_ReadPublic);  SendBuffer.NvIndex = SwapBytes32 (NvIndex);   SendBufferSize = (UINT32) sizeof (SendBuffer);  SendBuffer.Header.paramSize = SwapBytes32 (SendBufferSize);  //  // send Tpm command  //  RecvBufferSize = sizeof (RecvBuffer);  Status = Tpm2SubmitCommand (SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);  if (EFI_ERROR (Status)) {    return Status;  }  if (RecvBufferSize < sizeof (TPM2_RESPONSE_HEADER)) {    DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - %x/n", RecvBufferSize));    return EFI_DEVICE_ERROR;  }  ResponseCode = SwapBytes32(RecvBuffer.Header.responseCode);  if (ResponseCode != TPM_RC_SUCCESS) {    DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - responseCode - %x/n", SwapBytes32(RecvBuffer.Header.responseCode)));  }  switch (ResponseCode) {  case TPM_RC_SUCCESS:    // return data    break;  case TPM_RC_HANDLE + RC_NV_ReadPublic_nvIndex: // TPM_RC_NV_DEFINED:    return EFI_NOT_FOUND;  case TPM_RC_VALUE + RC_NV_ReadPublic_nvIndex:    return EFI_INVALID_PARAMETER;  default:    return EFI_DEVICE_ERROR;  }  if (RecvBufferSize <= sizeof (TPM2_RESPONSE_HEADER) + sizeof (UINT16) + sizeof(UINT16)) {    DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - %x/n", RecvBufferSize));    return EFI_NOT_FOUND;  }  //  // Basic check  //  NvPublicSize = SwapBytes16 (RecvBuffer.NvPublic.size);  NvNameSize = SwapBytes16 (ReadUnaligned16 ((UINT16 *)((UINT8 *)&RecvBuffer + sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + NvPublicSize)));  if (RecvBufferSize != sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + NvPublicSize + sizeof(UINT16) + NvNameSize) {    DEBUG ((EFI_D_ERROR, "Tpm2NvReadPublic - RecvBufferSize Error - NvPublicSize %x, NvNameSize %x/n", RecvBufferSize, NvNameSize));    return EFI_NOT_FOUND;  }  //  // Return the response  //  CopyMem (NvPublic, &RecvBuffer.NvPublic, sizeof(UINT16) + NvPublicSize);  NvPublic->size = NvPublicSize;  NvPublic->nvPublic.nvIndex = SwapBytes32 (NvPublic->nvPublic.nvIndex);  NvPublic->nvPublic.nameAlg = SwapBytes16 (NvPublic->nvPublic.nameAlg);  WriteUnaligned32 ((UINT32 *)&NvPublic->nvPublic.attributes, SwapBytes32 (ReadUnaligned32 ((UINT32 *)&NvPublic->nvPublic.attributes)));  NvPublic->nvPublic.authPolicy.size = SwapBytes16 (NvPublic->nvPublic.authPolicy.size);  Buffer = (UINT8 *)&NvPublic->nvPublic.authPolicy;  Buffer += sizeof(UINT16) + NvPublic->nvPublic.authPolicy.size;  NvPublic->nvPublic.dataSize = SwapBytes16 (ReadUnaligned16 ((UINT16 *)Buffer));  CopyMem (NvName, (UINT8 *)&RecvBuffer + sizeof(TPM2_RESPONSE_HEADER) + sizeof(UINT16) + NvPublicSize, NvNameSize);  NvName->size = NvNameSize;//.........这里部分代码省略.........
开发者ID:B-Rich,项目名称:edk2,代码行数:101,


示例19: NvmePassThru

//.........这里部分代码省略.........  } else if ((Offset + Bytes) > EFI_PAGE_SIZE) {    Sq->Prp[1] = (Sq->Prp[0] + EFI_PAGE_SIZE) & ~(EFI_PAGE_SIZE - 1);  }  if (Packet->NvmeCmd->Flags & CDW10_VALID) {    Sq->Payload.Raw.Cdw10 = Packet->NvmeCmd->Cdw10;  }  if (Packet->NvmeCmd->Flags & CDW11_VALID) {    Sq->Payload.Raw.Cdw11 = Packet->NvmeCmd->Cdw11;  }  if (Packet->NvmeCmd->Flags & CDW12_VALID) {    Sq->Payload.Raw.Cdw12 = Packet->NvmeCmd->Cdw12;  }  if (Packet->NvmeCmd->Flags & CDW13_VALID) {    Sq->Payload.Raw.Cdw13 = Packet->NvmeCmd->Cdw13;  }  if (Packet->NvmeCmd->Flags & CDW14_VALID) {    Sq->Payload.Raw.Cdw14 = Packet->NvmeCmd->Cdw14;  }  if (Packet->NvmeCmd->Flags & CDW15_VALID) {    Sq->Payload.Raw.Cdw15 = Packet->NvmeCmd->Cdw15;  }  //  // Ring the submission queue doorbell.  //  Private->SqTdbl[QueueId].Sqt++;  if (Private->SqTdbl[QueueId].Sqt == SqSize) {    Private->SqTdbl[QueueId].Sqt = 0;  }  Data32 = ReadUnaligned32 ((UINT32 *)&Private->SqTdbl[QueueId]);  Status = NVME_SET_SQTDBL (Private, QueueId, &Data32);  if (EFI_ERROR (Status)) {    DEBUG ((DEBUG_ERROR, "%a: NVME_SET_SQTDBL fail, Status - %r/n", __FUNCTION__, Status));    goto Exit;  }  //  // Wait for completion queue to get filled in.  //  Status = EFI_TIMEOUT;  Timer  = 0;  while (Timer < Packet->CommandTimeout) {    if (Cq->Pt != Private->Pt[QueueId]) {      Status = EFI_SUCCESS;      break;    }    MicroSecondDelay (NVME_POLL_INTERVAL);    Timer += NVME_POLL_INTERVAL;  }  if (Status == EFI_TIMEOUT) {    //    // Timeout occurs for an NVMe command, reset the controller to abort the outstanding command    //    DEBUG ((DEBUG_ERROR, "%a: Timeout occurs for the PassThru command./n", __FUNCTION__));    Status = NvmeControllerInit (Private);    if (EFI_ERROR (Status)) {      Status = EFI_DEVICE_ERROR;    } else {      //      // Return EFI_TIMEOUT to indicate a timeout occurs for PassThru command      //      Status = EFI_TIMEOUT;    }    goto Exit;  }  //  // Move forward the Completion Queue head  //  Private->CqHdbl[QueueId].Cqh++;  if (Private->CqHdbl[QueueId].Cqh == CqSize) {    Private->CqHdbl[QueueId].Cqh = 0;    Private->Pt[QueueId] ^= 1;  }  //  // Copy the Respose Queue entry for this command to the callers response buffer  //  CopyMem (Packet->NvmeCompletion, Cq, sizeof (EDKII_PEI_NVM_EXPRESS_COMPLETION));  //  // Check the NVMe cmd execution result  //  Status = NvmeCheckCqStatus (Cq);  NVME_SET_CQHDBL (Private, QueueId, &Private->CqHdbl[QueueId]);Exit:  if (MapMeta != NULL) {    IoMmuUnmap (MapMeta);  }  if (MapData != NULL) {    IoMmuUnmap (MapData);  }  return Status;}
开发者ID:MattDevo,项目名称:edk2,代码行数:101,


示例20: TcgMeasurePeImage

/**  Measure PE image into TPM log based on the authenticode image hashing in  PE/COFF Specification 8.0 Appendix A.  @param[in] TcgProtocol    Pointer to the located TCG protocol instance.  @param[in] ImageAddress   Start address of image buffer.  @param[in] ImageSize      Image size  @param[in] LinkTimeBase   Address that the image is loaded into memory.  @param[in] ImageType      Image subsystem type.  @param[in] FilePath       File path is corresponding to the input image.  @retval EFI_SUCCESS            Successfully measure image.  @retval EFI_OUT_OF_RESOURCES   No enough resource to measure image.  @retval other error value**/EFI_STATUSEFIAPITcgMeasurePeImage (  IN  EFI_TCG_PROTOCOL          *TcgProtocol,  IN  EFI_PHYSICAL_ADDRESS      ImageAddress,  IN  UINTN                     ImageSize,  IN  UINTN                     LinkTimeBase,  IN  UINT16                    ImageType,  IN  EFI_DEVICE_PATH_PROTOCOL  *FilePath  ){  EFI_STATUS                        Status;  TCG_PCR_EVENT                     *TcgEvent;  EFI_IMAGE_LOAD_EVENT              *ImageLoad;  UINT32                            FilePathSize;  VOID                              *Sha1Ctx;  UINTN                             CtxSize;  EFI_IMAGE_DOS_HEADER              *DosHdr;  UINT32                            PeCoffHeaderOffset;  EFI_IMAGE_SECTION_HEADER          *Section;  UINT8                             *HashBase;  UINTN                             HashSize;  UINTN                             SumOfBytesHashed;  EFI_IMAGE_SECTION_HEADER          *SectionHeader;  UINTN                             Index, Pos;  UINT16                            Magic;  UINT32                            EventSize;  UINT32                            EventNumber;  EFI_PHYSICAL_ADDRESS              EventLogLastEntry;  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION  Hdr;  Status        = EFI_SUCCESS;  ImageLoad     = NULL;  SectionHeader = NULL;  Sha1Ctx       = NULL;  FilePathSize  = (UINT32) GetDevicePathSize (FilePath);  //  // Determine destination PCR by BootPolicy  //  EventSize = sizeof (*ImageLoad) - sizeof (ImageLoad->DevicePath) + FilePathSize;  TcgEvent = AllocateZeroPool (EventSize + sizeof (TCG_PCR_EVENT));  if (TcgEvent == NULL) {    return EFI_OUT_OF_RESOURCES;  }  TcgEvent->EventSize = EventSize;  ImageLoad           = (EFI_IMAGE_LOAD_EVENT *) TcgEvent->Event;  switch (ImageType) {    case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION:      TcgEvent->EventType = EV_EFI_BOOT_SERVICES_APPLICATION;      TcgEvent->PCRIndex  = 4;      break;    case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:      TcgEvent->EventType = EV_EFI_BOOT_SERVICES_DRIVER;      TcgEvent->PCRIndex  = 2;      break;    case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:      TcgEvent->EventType = EV_EFI_RUNTIME_SERVICES_DRIVER;      TcgEvent->PCRIndex  = 2;      break;    default:      DEBUG ((        EFI_D_ERROR,        "TcgMeasurePeImage: Unknown subsystem type %d",        ImageType        ));      Status = EFI_UNSUPPORTED;      goto Finish;  }  ImageLoad->ImageLocationInMemory = ImageAddress;  ImageLoad->ImageLengthInMemory   = ImageSize;  ImageLoad->ImageLinkTimeAddress  = LinkTimeBase;  ImageLoad->LengthOfDevicePath    = FilePathSize;  CopyMem (ImageLoad->DevicePath, FilePath, FilePathSize);  //  // Check PE/COFF image  //  DosHdr = (EFI_IMAGE_DOS_HEADER *) (UINTN) ImageAddress;  PeCoffHeaderOffset = 0;  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {    PeCoffHeaderOffset = DosHdr->e_lfanew;//.........这里部分代码省略.........
开发者ID:AshleyDeSimone,项目名称:edk2,代码行数:101,


示例21: CreateDMFontPkg

EFI_STATUS CreateDMFontPkg(CHAR16* FontName, UINT16 FontWidth, UINT16 FontHeight,          EFI_NARROW_GLYPH* NarrowGlyph, UINT32 NrSizeInBytes, CHAR16 NrStart, CHAR16 NrCharNum,        EFI_WIDE_GLYPH* WideGlyph, UINT32 SizeInBytes, CHAR16 Start, CHAR16 CharNum){    EFI_HII_FONT_PACKAGE_HDR *FontPkgHeader;     UINT32 PackageLength;     UINT8 *Package;     UINTN BlockLength = 0;    UINT8 *pCurrent = 0;     CHAR16 NextChar = 0;    EFI_HII_GLYPH_INFO Cell = {FontWidth, FontHeight, 10, 10, (INT16)FontWidth};    UINT16 FontNameLen = StrLen(FontName);    PackageLength = 4 + sizeof (EFI_HII_FONT_PACKAGE_HDR) + (FontNameLen*2 /*Max Length of Font Name*/) +         sizeof(EFI_HII_GIBT_SKIP2_BLOCK) +         sizeof(EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK) -1 + CharNum * WideGlyphBytes +         sizeof(EFI_HII_GIBT_SKIP2_BLOCK) +         sizeof(EFI_HII_GIBT_GLYPHS_BLOCK) -1 + NrCharNum * NrGlyphBytes  +        sizeof(EFI_GLYPH_GIBT_END_BLOCK) ;    Package = (UINT8*)AllocateZeroPool (PackageLength);     //ASSERT (Package != NULL);     // Header    WriteUnaligned32((UINT32 *) Package,PackageLength);     FontPkgHeader = (EFI_HII_FONT_PACKAGE_HDR *) (Package + 4);     FontPkgHeader->Header.Length = (UINT32) (PackageLength - 4);     FontPkgHeader->Header.Type = EFI_HII_PACKAGE_FONTS;     FontPkgHeader->HdrSize = sizeof(EFI_HII_FONT_PACKAGE_HDR) + (FontNameLen)*2;    FontPkgHeader->GlyphBlockOffset = sizeof(EFI_HII_FONT_PACKAGE_HDR) + (FontNameLen*2);     FontPkgHeader->Cell = Cell;    FontPkgHeader->FontStyle = EFI_HII_FONT_STYLE_NORMAL;    CopyMem((FontPkgHeader->FontFamily), FontName, StrLen(FontName)*2 +2);    pCurrent = (UINT8 *) (Package + 4 + FontPkgHeader->GlyphBlockOffset);     //CHAR 0...255    BlockLength = FillNarrowGLYPH(pCurrent, NarrowGlyph, NrSizeInBytes, 1, NrStart, NrCharNum);    pCurrent += BlockLength;    NextChar = NrStart + NrCharNum;    // EFI_HII_GIBT_GLYPHS_DEFAULT    BlockLength = FillWideGLYPH(pCurrent, WideGlyph, SizeInBytes, NextChar, Start, CharNum);    pCurrent += BlockLength;    // END BLOCK    EFI_GLYPH_GIBT_END_BLOCK* FontEndBlock = (EFI_GLYPH_GIBT_END_BLOCK*)(pCurrent);    FontEndBlock->Header.BlockType = (UINT8)EFI_HII_GIBT_END;    //     // Add this simplified font package to a package list then install it.     //     {        EFI_HANDLE gFontHiiHandle = HiiAddPackages (                 &gDMFontPackageListGuid ,                NULL,                 Package,                 NULL                 );         (void)gFontHiiHandle;        //ASSERT (gFontHiiHandle != NULL);     }    FreePool (Package);     return EFI_SUCCESS;}
开发者ID:GarethNelson,项目名称:uefi-programming,代码行数:63,


示例22: EblFileDevicePath

/**Internal work function to fill in EFI_OPEN_FILE information for the Fs and BlkIo@param  File        Open file handle@param  FileName    Name of file after device stripped off**/EFI_STATUSEblFileDevicePath (  IN OUT EFI_OPEN_FILE  *File,  IN  CHAR8             *FileName,  IN  CONST UINT64      OpenMode  ){  EFI_STATUS                        Status;  UINTN                             Size;  FILEPATH_DEVICE_PATH              *FilePath;  EFI_DEVICE_PATH_PROTOCOL          *FileDevicePath;  CHAR16                            UnicodeFileName[MAX_PATHNAME];  EFI_BLOCK_IO_PROTOCOL             *BlkIo;  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL   *Fs;  EFI_FILE_HANDLE                   Root;  if ( *FileName != 0 ) {    AsciiStrToUnicodeStr (FileName, UnicodeFileName);  } else {    AsciiStrToUnicodeStr ("//", UnicodeFileName);  }  Size = StrSize (UnicodeFileName);  FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL));  if (FileDevicePath != NULL) {    FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;    FilePath->Header.Type    = MEDIA_DEVICE_PATH;    FilePath->Header.SubType = MEDIA_FILEPATH_DP;    CopyMem (&FilePath->PathName, UnicodeFileName, Size);    SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);    SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header));    if (File->EfiHandle != NULL) {      File->DevicePath = DevicePathFromHandle (File->EfiHandle);    }    File->DevicePath = AppendDevicePath (File->DevicePath, FileDevicePath);    FreePool (FileDevicePath);  }  Status = gBS->HandleProtocol (File->EfiHandle, &gEfiBlockIoProtocolGuid, (VOID **)&BlkIo);  if (!EFI_ERROR (Status)) {    File->FsBlockIoMedia = BlkIo->Media;    File->FsBlockIo = BlkIo;    // If we are not opening the device this will get over written with file info    File->MaxPosition = MultU64x32 (BlkIo->Media->LastBlock + 1, BlkIo->Media->BlockSize);  }  if (File->Type == EfiOpenFileSystem) {    Status = gBS->HandleProtocol (File->EfiHandle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);    if (!EFI_ERROR (Status)) {      Status = Fs->OpenVolume (Fs, &Root);      if (!EFI_ERROR (Status)) {        // Get information about the volume        Size = 0;        Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, File->FsInfo);        if (Status == EFI_BUFFER_TOO_SMALL) {          File->FsInfo = AllocatePool (Size);          Status = Root->GetInfo (Root, &gEfiFileSystemInfoGuid, &Size, File->FsInfo);        }        // Get information about the file        Status = Root->Open (Root, &File->FsFileHandle, UnicodeFileName, OpenMode, 0);        if (!EFI_ERROR (Status)) {          Size = 0;          Status = File->FsFileHandle->GetInfo (File->FsFileHandle, &gEfiFileInfoGuid, &Size, NULL);          if (Status == EFI_BUFFER_TOO_SMALL) {            File->FsFileInfo = AllocatePool (Size);            Status = File->FsFileHandle->GetInfo (File->FsFileHandle, &gEfiFileInfoGuid, &Size, File->FsFileInfo);            if (!EFI_ERROR (Status)) {              File->Size = (UINTN)File->FsFileInfo->FileSize;              File->MaxPosition = (UINT64)File->Size;            }          }        }        Root->Close (Root);      }    }  } else if (File->Type == EfiOpenBlockIo) {    File->Size = (UINTN)File->MaxPosition;  }  return Status;}
开发者ID:wensunshine,项目名称:VisualUefi,代码行数:95,


示例23: Var_UpdateBBSOption

//.........这里部分代码省略.........    FreePool (OriginalPtr);    return EFI_NOT_FOUND;  }  NewOrder = AllocateZeroPool (DevOrder->Length - sizeof (DevOrder->Length));  if (NewOrder == NULL) {    FreePool (OriginalPtr);    return EFI_OUT_OF_RESOURCES;  }  for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {    if (0xFF == LegacyDev[Index]) {      break;    }    NewOrder[Index] = LegacyDev[Index];  }  //  // Only the enable/disable state of each boot device with same device type can be changed,  // so we can count on the index information in DevOrder.  // DisMap bit array is the only reliable source to check a device's en/dis state,  // so we use DisMap to set en/dis state of each item in NewOrder array  //  for (Index2 = 0; Index2 < OptionMenu->MenuNumber; Index2++) {    Tmp = (UINT16) (DevOrder->Data[Index2] & 0xFF);    Pos = Tmp / 8;    Bit = 7 - (Tmp % 8);    if ((DisMap[Pos] & (1 << Bit)) != 0) {      NewOrder[Index] = (UINT16) (0xFF00 | Tmp);      Index++;    }  }  CopyMem (    DevOrder->Data,    NewOrder,    DevOrder->Length - sizeof (DevOrder->Length)    );  FreePool (NewOrder);  Status = gRT->SetVariable (                  VAR_LEGACY_DEV_ORDER,                  &gEfiLegacyDevOrderVariableGuid,                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,                  VarSize,                  OriginalPtr                  );  //  // Update BootOrder and Boot####.Attribute  //  // 1. Re-order the Option Number in BootOrder according to Legacy Dev Order  //  ASSERT (OptionMenu->MenuNumber == DevOrder->Length / sizeof (UINT16) - 1);  OrderLegacyBootOption4SameType (    DevOrder->Data,    DevOrder->Length / sizeof (UINT16) - 1,    &EnBootOption,    &EnBootOptionCount,    &DisBootOption,    &DisBootOptionCount    );  //
开发者ID:B-Rich,项目名称:edk2,代码行数:67,


示例24: Var_UpdateBootOption

/**  This function create a currently loaded Boot Option from   the BMM. It then appends this Boot Option to the end of   the "BootOrder" list. It also append this Boot Opotion to the end  of BootOptionMenu.  @param CallbackData    The BMM context data.  @param NvRamMap        The file explorer formset internal state.  @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.  @retval EFI_SUCCESS          If function completes successfully.**/EFI_STATUSVar_UpdateBootOption (  IN  BMM_CALLBACK_DATA                   *CallbackData,  IN  FILE_EXPLORER_NV_DATA               *NvRamMap  ){  UINT16          *BootOrderList;  UINT16          *NewBootOrderList;  UINTN           BootOrderListSize;  UINT16          BootString[10];  VOID            *Buffer;  UINTN           BufferSize;  UINT8           *Ptr;  UINT16          Index;  BM_MENU_ENTRY   *NewMenuEntry;  BM_LOAD_CONTEXT *NewLoadContext;  BOOLEAN         OptionalDataExist;  EFI_STATUS      Status;  OptionalDataExist = FALSE;  Index = BOpt_GetBootOptionNumber () ;  UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", Index);  if (NvRamMap->DescriptionData[0] == 0x0000) {    StrCpy (NvRamMap->DescriptionData, BootString);  }  BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (NvRamMap->DescriptionData);  BufferSize += GetDevicePathSize (CallbackData->LoadContext->FilePathList);  if (NvRamMap->OptionalData[0] != 0x0000) {    OptionalDataExist = TRUE;    BufferSize += StrSize (NvRamMap->OptionalData);  }  Buffer = AllocateZeroPool (BufferSize);  if (NULL == Buffer) {    return EFI_OUT_OF_RESOURCES;  }  NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);  if (NULL == NewMenuEntry) {    return EFI_OUT_OF_RESOURCES;  }  NewLoadContext                  = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;  NewLoadContext->Deleted         = FALSE;  NewLoadContext->LoadOptionSize  = BufferSize;  Ptr = (UINT8 *) Buffer;  NewLoadContext->LoadOption = Ptr;  *((UINT32 *) Ptr) = LOAD_OPTION_ACTIVE;  NewLoadContext->Attributes = *((UINT32 *) Ptr);  NewLoadContext->IsActive = TRUE;  NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);  Ptr += sizeof (UINT32);  *((UINT16 *) Ptr) = (UINT16) GetDevicePathSize (CallbackData->LoadContext->FilePathList);  NewLoadContext->FilePathListLength = *((UINT16 *) Ptr);  Ptr += sizeof (UINT16);  CopyMem (    Ptr,    NvRamMap->DescriptionData,    StrSize (NvRamMap->DescriptionData)    );  NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->DescriptionData));  ASSERT (NewLoadContext->Description != NULL);  NewMenuEntry->DisplayString = NewLoadContext->Description;  CopyMem (    NewLoadContext->Description,    (VOID *) Ptr,    StrSize (NvRamMap->DescriptionData)    );  Ptr += StrSize (NvRamMap->DescriptionData);  CopyMem (    Ptr,    CallbackData->LoadContext->FilePathList,    GetDevicePathSize (CallbackData->LoadContext->FilePathList)    );  NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));  ASSERT (NewLoadContext->FilePathList != NULL);//.........这里部分代码省略.........
开发者ID:B-Rich,项目名称:edk2,代码行数:101,


示例25: WinNtSerialIoDriverBindingStart

//.........这里部分代码省略.........          }        }        break;      }    }    FreePool (OpenInfoBuffer);    return Status;  }  FlowControl    = NULL;  FlowControlMap = 0;  if (RemainingDevicePath == NULL) {    //    // Build the device path by appending the UART node to the ParentDevicePath    // from the WinNtIo handle. The Uart setings are zero here, since    // SetAttribute() will update them to match the default setings.    //    ZeroMem (&UartNode, sizeof (UART_DEVICE_PATH));    UartNode.Header.Type     = MESSAGING_DEVICE_PATH;    UartNode.Header.SubType  = MSG_UART_DP;    SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &UartNode, sizeof (UART_DEVICE_PATH));  } else if (!IsDevicePathEnd (RemainingDevicePath)) {    //    // If RemainingDevicePath isn't the End of Device Path Node,     // only scan the specified device by RemainingDevicePath    //    //    // Match the configuration of the RemainingDevicePath. IsHandleSupported()    // already checked to make sure the RemainingDevicePath contains settings    // that we can support.    //    CopyMem (&UartNode, RemainingDevicePath, sizeof (UART_DEVICE_PATH));    FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (RemainingDevicePath);    if (IsUartFlowControlNode (FlowControl)) {      FlowControlMap = FlowControl->FlowControlMap;    } else {      FlowControl    = NULL;    }  } else {    //    // If RemainingDevicePath is the End of Device Path Node,    // skip enumerate any device and return EFI_SUCESSS    //     return EFI_SUCCESS;  }  //  // Check to see if we can access the hardware device. If it's Open in NT we  // will not get access.  //  NtHandle = WinNtIo->WinNtThunk->CreateFile (                                    WinNtIo->EnvString,                                    GENERIC_READ | GENERIC_WRITE,                                    0,                                    NULL,                                    OPEN_EXISTING,                                    0,                                    NULL                                    );  if (NtHandle == INVALID_HANDLE_VALUE) {    Status = EFI_DEVICE_ERROR;    goto Error;  }
开发者ID:EvanLloyd,项目名称:tianocore,代码行数:67,


示例26: Ext2DirOpen

//.........这里部分代码省略.........    Status = Ext2InodeHandleReopen(BaseDirInode, &CurrentInodeHandle);    if (EFI_ERROR(Status))        return Status;        // loop over the path    // loop invariant: CurrentInodeHandle is an open, rewinded handle to the current inode    for (; *PathElement != 0; PathElement = NextPathElement) {        // parse next path element        PathElementEnd = PathElement;        while (*PathElementEnd != 0 && *PathElementEnd != '//')            PathElementEnd++;        PathElementLength = PathElementEnd - PathElement;        NextPathElement = PathElementEnd;        while (*NextPathElement == '//')            NextPathElement++;                // check that this actually is a directory        if (!S_ISDIR(CurrentInodeHandle.Inode->RawInode->i_mode)) {#if DEBUG_LEVEL == 2            Print(L"Ext2DirOpen: NOT FOUND (not a directory)/n");#endif            Status = EFI_NOT_FOUND;            goto bailout;        }                // check for . and ..        NextInodeNo = 0;        if (PathElementLength == 1 && PathElement[0] == '.') {            NextInodeNo = CurrentInodeHandle.Inode->InodeNo;        } else if (PathElementLength == 2 && PathElement[0] == '.' && PathElement[1] == '.') {            if (CurrentInodeHandle.Inode->ParentDirInode == NULL) {                // EFI spec says: there is no parent for the root                // NOTE: the EFI shell relies on this!                                Status = EFI_NOT_FOUND;                goto bailout;            }            NextInodeNo = CurrentInodeHandle.Inode->ParentDirInode->InodeNo;        }                // scan the directory for the file        while (NextInodeNo == 0) {            // read next entry            Status = Ext2DirReadEntry(&CurrentInodeHandle, &DirEntry);            if (EFI_ERROR(Status))                goto bailout;            if (DirEntry.inode == 0) {                // end of directory reached#if DEBUG_LEVEL == 2                Print(L"Ext2DirOpen: NOT FOUND (no match)/n");#endif                Status = EFI_NOT_FOUND;                goto bailout;            }                        // compare name            if (DirEntry.name_len == PathElementLength) {                NamesEqual = TRUE;                for (i = 0; i < DirEntry.name_len; i++) {                    if (DirEntry.name[i] != PathElement[i]) {                        NamesEqual = FALSE;                        break;                    }                }                if (NamesEqual)                    NextInodeNo = DirEntry.inode;            }        }        #if DEBUG_LEVEL == 2        Print(L"Ext2DirOpen: found inode %d/n", NextInodeNo);#endif                // open the inode we found in the directory        Status = Ext2InodeHandleOpen(Volume, NextInodeNo, CurrentInodeHandle.Inode, &DirEntry, &NextInodeHandle);        if (EFI_ERROR(Status))            goto bailout;                // TODO: resolve symbolic links somehow                // close the previous inode handle and replace it with the new one        Status = Ext2InodeHandleClose(&CurrentInodeHandle);        CopyMem(&CurrentInodeHandle, &NextInodeHandle, sizeof(EXT2_INODE_HANDLE));    }        // wrap the current inode into a file handle    Status = Ext2FileFromInodeHandle(&CurrentInodeHandle, NewHandle);    if (EFI_ERROR(Status))        return Status;    // NOTE: file handle takes ownership of inode handle    #if DEBUG_LEVEL == 2    Print(L"Ext2DirOpen: returning/n");#endif    return Status;    bailout:    Ext2InodeHandleClose(&CurrentInodeHandle);    return Status;}
开发者ID:JackieXie168,项目名称:rEFIt,代码行数:101,


示例27: Configure

/**  Initialize or brutally reset the operational parameters for this EFI HTTP instance.  The Configure() function does the following:  When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring  timeout, local address, port, etc.  When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active  connections with remote hosts, canceling all asynchronous tokens, and flush request  and response buffers without informing the appropriate hosts.  No other EFI HTTP function can be executed by this instance until the Configure()  function is executed and returns successfully.  @param[in]  This                Pointer to EFI_HTTP_PROTOCOL instance.  @param[in]  HttpConfigData      Pointer to the configure data to configure the instance.  @retval EFI_SUCCESS             Operation succeeded.  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:                                  This is NULL.                                  HttpConfigData is NULL.                                  HttpConfigData->LocalAddressIsIPv6 is FALSE and                                  HttpConfigData->IPv4Node is NULL.                                  HttpConfigData->LocalAddressIsIPv6 is TRUE and                                  HttpConfigData->IPv6Node is NULL.  @retval EFI_ALREADY_STARTED     Reinitialize this HTTP instance without calling                                  Configure() with NULL to reset it.  @retval EFI_DEVICE_ERROR        An unexpected system or network error occurred.  @retval EFI_OUT_OF_RESOURCES    Could not allocate enough system resources when                                  executing Configure().  @retval EFI_UNSUPPORTED         One or more options in HttpConfigData are not supported                                  in the implementation.**/EFI_STATUSEFIAPIEfiHttpConfigure (  IN  EFI_HTTP_PROTOCOL         *This,  IN  EFI_HTTP_CONFIG_DATA      *HttpConfigData  ) {  HTTP_PROTOCOL                 *HttpInstance;  EFI_STATUS                    Status;    //  // Check input parameters.  //  if (This == NULL ||      HttpConfigData == NULL ||     ((HttpConfigData->LocalAddressIsIPv6 && HttpConfigData->AccessPoint.IPv6Node == NULL) ||     (!HttpConfigData->LocalAddressIsIPv6 && HttpConfigData->AccessPoint.IPv4Node == NULL))) {    return EFI_INVALID_PARAMETER;  }  HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);  ASSERT (HttpInstance != NULL && HttpInstance->Service != NULL);  if (HttpConfigData != NULL) {    //    // Now configure this HTTP instance.    //    if (HttpInstance->State != HTTP_STATE_UNCONFIGED) {      return EFI_ALREADY_STARTED;    }    HttpInstance->HttpVersion        = HttpConfigData->HttpVersion;    HttpInstance->TimeOutMillisec    = HttpConfigData->TimeOutMillisec;    HttpInstance->LocalAddressIsIPv6 = HttpConfigData->LocalAddressIsIPv6;        if (HttpConfigData->LocalAddressIsIPv6) {       CopyMem (        &HttpInstance->Ipv6Node,        HttpConfigData->AccessPoint.IPv6Node,        sizeof (HttpInstance->Ipv6Node)        );    } else {      CopyMem (        &HttpInstance->IPv4Node,        HttpConfigData->AccessPoint.IPv4Node,        sizeof (HttpInstance->IPv4Node)        );    }        //    // Creat Tcp child    //    Status = HttpInitProtocol (HttpInstance, HttpInstance->LocalAddressIsIPv6);    if (EFI_ERROR (Status)) {      return Status;    }        HttpInstance->State = HTTP_STATE_HTTP_CONFIGED;    return EFI_SUCCESS;  } else {    //    // Reset all the resources related to HttpInsance.    //    HttpCleanProtocol (HttpInstance);    HttpInstance->State = HTTP_STATE_UNCONFIGED;    return EFI_SUCCESS;//.........这里部分代码省略.........
开发者ID:niruiyu,项目名称:edk2,代码行数:101,



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


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