本文整理匯總了C++中AppendDevicePathNode函數的典型用法代碼示例。如果您正苦於以下問題:C++ AppendDevicePathNode函數的具體用法?C++ AppendDevicePathNode怎麽用?C++ AppendDevicePathNode使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AppendDevicePathNode函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: SetBiosInitBlockIoDevicePath
/**
Build device path for device.
@param BaseDevicePath Base device path.
@param Drive Legacy drive.
@param DevicePath Device path for output.
**/
VOID
SetBiosInitBlockIoDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *BaseDevicePath,
IN BIOS_LEGACY_DRIVE *Drive,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
EFI_STATUS Status;
BLOCKIO_VENDOR_DEVICE_PATH VendorNode;
Status = EFI_UNSUPPORTED;
//
// BugBug: Check for memory leaks!
//
if (Drive->EddVersion == EDD_VERSION_30) {
//
// EDD 3.0 case.
//
Status = BuildEdd30DevicePath (BaseDevicePath, Drive, DevicePath);
}
if (EFI_ERROR (Status)) {
//
// EDD 1.1 device case or it is unrecognized EDD 3.0 device
//
ZeroMem (&VendorNode, sizeof (VendorNode));
VendorNode.DevicePath.Header.Type = HARDWARE_DEVICE_PATH;
VendorNode.DevicePath.Header.SubType = HW_VENDOR_DP;
SetDevicePathNodeLength (&VendorNode.DevicePath.Header, sizeof (VendorNode));
CopyMem (&VendorNode.DevicePath.Guid, &gBlockIoVendorGuid, sizeof (EFI_GUID));
VendorNode.LegacyDriveLetter = Drive->Number;
*DevicePath = AppendDevicePathNode (BaseDevicePath, &VendorNode.DevicePath.Header);
}
}
示例2: CreatePciDevicePath
EFI_DEVICE_PATH_PROTOCOL *
CreatePciDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
IN PCI_IO_DEVICE *PciIoDevice
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
{
PCI_DEVICE_PATH PciNode;
//
// Create PCI device path
//
PciNode.Header.Type = HARDWARE_DEVICE_PATH;
PciNode.Header.SubType = HW_PCI_DP;
SetDevicePathNodeLength (&PciNode.Header, sizeof (PciNode));
PciNode.Device = PciIoDevice->DeviceNumber;
PciNode.Function = PciIoDevice->FunctionNumber;
PciIoDevice->DevicePath = AppendDevicePathNode (ParentDevicePath, &PciNode.Header);
return PciIoDevice->DevicePath;
}
示例3: SasV1ExtScsiPassThruBuildDevicePath
STATIC
EFI_STATUS
EFIAPI
SasV1ExtScsiPassThruBuildDevicePath (
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
IN UINT8 *Target,
IN UINT64 Lun,
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
EFI_DEV_PATH EndNode;
EFI_DEV_PATH Node;
ZeroMem (&Node, sizeof (Node));
Node.DevPath.Type = HARDWARE_DEVICE_PATH;
Node.DevPath.SubType = HW_PCI_DP;
SetDevicePathNodeLength (&Node.DevPath, sizeof (PCI_DEVICE_PATH));
SetDevicePathEndNode (&EndNode.DevPath);
NewDevicePathNode = AppendDevicePathNode (&EndNode.DevPath, &Node.DevPath);
*DevicePath = NewDevicePathNode;
return EFI_SUCCESS;
}
示例4: AppendDeviceNodeProtocolInterface
EFIAPI
AppendDeviceNodeProtocolInterface (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode
)
{
return AppendDevicePathNode (DevicePath, DevicePathNode);
}
示例5: GetHIDevicePath
EFIAPI
GetHIDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
UINTN NonHIDevicePathNodeCount;
UINTN Index;
EFI_DEV_PATH Node;
EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
ASSERT(DevicePath != NULL);
NonHIDevicePathNodeCount = 0;
HIDevicePath = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));
SetDevicePathEndNode (HIDevicePath);
Node.DevPath.Type = END_DEVICE_PATH_TYPE;
Node.DevPath.SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
Node.DevPath.Length[0] = (UINT8)sizeof (EFI_DEVICE_PATH_PROTOCOL);
Node.DevPath.Length[1] = 0;
while (!IsDevicePathEnd (DevicePath)) {
if (IsHIDevicePathNode (DevicePath)) {
for (Index = 0; Index < NonHIDevicePathNodeCount; Index++) {
TempDevicePath = AppendDevicePathNode (HIDevicePath, &Node.DevPath);
FreePool (HIDevicePath);
HIDevicePath = TempDevicePath;
}
TempDevicePath = AppendDevicePathNode (HIDevicePath, DevicePath);
FreePool (HIDevicePath);
HIDevicePath = TempDevicePath;
} else {
NonHIDevicePathNodeCount++;
}
//
// Next device path node
//
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (DevicePath);
}
return HIDevicePath;
}
示例6: PreparePciSerialDevicePath
EFI_STATUS
PreparePciSerialDevicePath (
IN EFI_HANDLE DeviceHandle
)
/*++
Routine Description:
Add PCI Serial to ConOut, ConIn, ErrOut.
PCI Serial: 07 00 02
Arguments:
DeviceHandle - Handle of PCIIO protocol.
Returns:
EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.
EFI_STATUS - No PCI Serial device is added.
--*/
{
EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
DevicePath = NULL;
Status = gBS->HandleProtocol (
DeviceHandle,
&gEfiDevicePathProtocolGuid,
(VOID*)&DevicePath
);
if (EFI_ERROR (Status)) {
return Status;
}
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);
BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);
BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);
return EFI_SUCCESS;
}
示例7: BdsLoadOptionFileSystemUpdateDevicePath
EFI_STATUS
BdsLoadOptionFileSystemUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath,
IN CHAR16* FileName,
OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath
)
{
EFI_STATUS Status;
CHAR16 BootFilePath[BOOT_DEVICE_FILEPATH_MAX];
UINTN BootFilePathSize;
FILEPATH_DEVICE_PATH* EndingDevicePath;
FILEPATH_DEVICE_PATH* FilePathDevicePath;
EFI_DEVICE_PATH* DevicePath;
DevicePath = DuplicateDevicePath (OldDevicePath);
EndingDevicePath = (FILEPATH_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);
Print(L"File path of the %s: ", FileName);
StrnCpy (BootFilePath, EndingDevicePath->PathName, BOOT_DEVICE_FILEPATH_MAX);
Status = EditHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);
if (EFI_ERROR(Status)) {
return Status;
}
BootFilePathSize = StrSize(BootFilePath);
if (BootFilePathSize == 2) {
*NewDevicePath = NULL;
return EFI_NOT_FOUND;
}
// Create the FilePath Device Path node
FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
if (NULL == FilePathDevicePath)
{
return EFI_INVALID_PARAMETER;
}
FilePathDevicePath->Header.Type = MEDIA_DEVICE_PATH;
FilePathDevicePath->Header.SubType = MEDIA_FILEPATH_DP;
SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);
CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);
// Generate the new Device Path by replacing the last node by the updated node
SetDevicePathEndNode (EndingDevicePath);
*NewDevicePath = AppendDevicePathNode (DevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *)FilePathDevicePath);
FreePool(DevicePath);
return EFI_SUCCESS;
}
示例8: FvFileDevicePath
EFI_DEVICE_PATH *
FvFileDevicePath (
IN EFI_HANDLE FvHandle,
IN EFI_GUID *NameGuid
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH NewNode;
DevicePath = DevicePathFromHandle (FvHandle);
EfiInitializeFwVolDevicepathNode (&NewNode, NameGuid);
return AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&NewNode);
}
示例9: WinNtBusCreateDevicePath
EFI_DEVICE_PATH_PROTOCOL *
WinNtBusCreateDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL *RootDevicePath,
IN EFI_GUID *Guid,
IN UINT16 InstanceNumber
)
/*++
Routine Description:
Create a device path node using Guid and InstanceNumber and append it to
the passed in RootDevicePath
Arguments:
RootDevicePath - Root of the device path to return.
Guid - GUID to use in vendor device path node.
InstanceNumber - Instance number to use in the vendor device path. This
argument is needed to make sure each device path is unique.
Returns:
EFI_DEVICE_PATH_PROTOCOL
--*/
{
WIN_NT_VENDOR_DEVICE_PATH_NODE DevicePath;
DevicePath.VendorDevicePath.Header.Type = HARDWARE_DEVICE_PATH;
DevicePath.VendorDevicePath.Header.SubType = HW_VENDOR_DP;
SetDevicePathNodeLength (&DevicePath.VendorDevicePath.Header, sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE));
//
// The GUID defines the Class
//
CopyMem (&DevicePath.VendorDevicePath.Guid, Guid, sizeof (EFI_GUID));
//
// Add an instance number so we can make sure there are no Device Path
// duplication.
//
DevicePath.Instance = InstanceNumber;
return AppendDevicePathNode (
RootDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &DevicePath
);
}
示例10: PlatformRegisterFvBootOption
VOID
PlatformRegisterFvBootOption (
EFI_GUID *FileGuid,
CHAR16 *Description,
UINT32 Attributes
)
{
EFI_STATUS Status;
UINTN OptionIndex;
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
UINTN BootOptionCount;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
ASSERT_EFI_ERROR (Status);
EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
DevicePath = AppendDevicePathNode (
DevicePathFromHandle (LoadedImage->DeviceHandle),
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
);
Status = EfiBootManagerInitializeLoadOption (
&NewOption,
LoadOptionNumberUnassigned,
LoadOptionTypeBoot,
Attributes,
Description,
DevicePath,
NULL,
0
);
if (!EFI_ERROR (Status)) {
BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount);
if (OptionIndex == -1) {
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1);
ASSERT_EFI_ERROR (Status);
}
EfiBootManagerFreeLoadOption (&NewOption);
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
}
}
示例11: CreatePlatformBootOptionFromGuid
STATIC
EFI_STATUS
CreatePlatformBootOptionFromGuid (
IN EFI_GUID *FileGuid,
IN CHAR16 *Description,
IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH *DevicePath;
EFI_DEVICE_PATH *TempDevicePath;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
Status = gBS->HandleProtocol (
gImageHandle,
&gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImage
);
ASSERT_EFI_ERROR (Status);
EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
TempDevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
ASSERT (TempDevicePath != NULL);
DevicePath = AppendDevicePathNode (
TempDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
);
ASSERT (DevicePath != NULL);
Status = EfiBootManagerInitializeLoadOption (
BootOption,
LoadOptionNumberUnassigned,
LoadOptionTypeBoot,
LOAD_OPTION_ACTIVE,
Description,
DevicePath,
NULL,
0
);
FreePool (DevicePath);
return Status;
}
示例12: FvFilePath
/**
Generate device path include the input file guid info.
@param FileGuid Input file guid for the BootManagerMenuApp.
@retval DevicePath for BootManagerMenuApp.
**/
EFI_DEVICE_PATH *
FvFilePath (
EFI_GUID *FileGuid
)
{
EFI_STATUS Status;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
Status = gBS->HandleProtocol (
gImageHandle,
&gEfiLoadedImageProtocolGuid,
(VOID **) &LoadedImage
);
ASSERT_EFI_ERROR (Status);
return AppendDevicePathNode (
DevicePathFromHandle (LoadedImage->DeviceHandle),
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
);
}
示例13: BdsLoadOptionTftpUpdateDevicePath
/**
Update the parameters of a TFTP boot option
The function asks sequentially to update the IPv4 parameters as well as the boot file path,
providing the previously set value if any.
@param[in] OldDevicePath Current complete device path of the Tftp boot option.
This has to be a valid complete Tftp boot option path.
By complete, we mean that it is not only the Tftp
specific end part built by the
"BdsLoadOptionTftpCreateDevicePath()" function.
This path is handled as read only.
@param[in] FileName Description of the file the path is asked for
@param[out] NewDevicePath Pointer to the new complete device path.
@retval EFI_SUCCESS Update completed
@retval EFI_ABORTED Update aborted by the user
@retval EFI_OUT_OF_RESOURCES Fail to perform the update due to lack of resource
**/
EFI_STATUS
BdsLoadOptionTftpUpdateDevicePath (
IN EFI_DEVICE_PATH *OldDevicePath,
IN CHAR16 *FileName,
OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath
)
{
EFI_STATUS Status;
EFI_DEVICE_PATH *DevicePath;
EFI_DEVICE_PATH *DevicePathNode;
UINT8 *Ipv4NodePtr;
IPv4_DEVICE_PATH Ipv4Node;
BOOLEAN IsDHCP;
EFI_IP_ADDRESS OldIp;
EFI_IP_ADDRESS OldSubnetMask;
EFI_IP_ADDRESS OldGatewayIp;
EFI_IP_ADDRESS LocalIp;
EFI_IP_ADDRESS SubnetMask;
EFI_IP_ADDRESS GatewayIp;
EFI_IP_ADDRESS RemoteIp;
UINT8 *FileNodePtr;
CHAR16 BootFilePath[BOOT_DEVICE_FILEPATH_MAX];
UINTN PathSize;
UINTN BootFilePathSize;
FILEPATH_DEVICE_PATH *NewFilePathNode;
Ipv4NodePtr = NULL;
//
// Make a copy of the complete device path that is made of :
// the device path of the device that support the Simple Network protocol
// followed by an IPv4 node (type IPv4_DEVICE_PATH),
// followed by a file path node (type FILEPATH_DEVICE_PATH) and ended up
// by an end node. The IPv6 case is not handled yet.
//
DevicePath = DuplicateDevicePath (OldDevicePath);
if (DevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
//
// Because of the check done by "BdsLoadOptionTftpIsSupported()" prior to the
// call to this function, we know that the device path ends with an IPv4 node
// followed by a file path node and finally an end node. To get the address of
// the last IPv4 node, we loop over the whole device path, noting down the
// address of each encountered IPv4 node.
//
for (DevicePathNode = DevicePath;
!IsDevicePathEnd (DevicePathNode);
DevicePathNode = NextDevicePathNode (DevicePathNode))
{
if (IS_DEVICE_PATH_NODE (DevicePathNode, MESSAGING_DEVICE_PATH, MSG_IPv4_DP)) {
Ipv4NodePtr = (UINT8*)DevicePathNode;
}
}
// Copy for alignment of the IPv4 node data
CopyMem (&Ipv4Node, Ipv4NodePtr, sizeof (IPv4_DEVICE_PATH));
Print (L"Get the IP address from DHCP: ");
Status = GetHIInputBoolean (&IsDHCP);
if (EFI_ERROR (Status)) {
goto ErrorExit;
}
if (!IsDHCP) {
Print (L"Local static IP address: ");
if (Ipv4Node.StaticIpAddress) {
CopyMem (&OldIp.v4, &Ipv4Node.LocalIpAddress, sizeof (EFI_IPv4_ADDRESS));
Status = EditHIInputIP (&OldIp, &LocalIp);
} else {
Status = GetHIInputIP (&LocalIp);
}
if (EFI_ERROR (Status)) {
goto ErrorExit;
}
Print (L"Get the network mask: ");
//.........這裏部分代碼省略.........
示例14: PartitionInstallChildHandle
//.........這裏部分代碼省略.........
Private->BlockIo2.FlushBlocksEx = PartitionFlushBlocksEx;
}
Private->Media.IoAlign = 0;
Private->Media.LogicalPartition = TRUE;
Private->Media.LastBlock = DivU64x32 (
MultU64x32 (
End - Start + 1,
ParentBlockIo->Media->BlockSize
),
BlockSize
) - 1;
Private->Media.BlockSize = (UINT32) BlockSize;
Private->Media2.IoAlign = 0;
Private->Media2.LogicalPartition = TRUE;
Private->Media2.LastBlock = Private->Media.LastBlock;
Private->Media2.BlockSize = (UINT32) BlockSize;
//
// Per UEFI Spec, LowestAlignedLba, LogicalBlocksPerPhysicalBlock and OptimalTransferLengthGranularity must be 0
// for logical partitions.
//
if (Private->BlockIo.Revision >= EFI_BLOCK_IO_PROTOCOL_REVISION2) {
Private->Media.LowestAlignedLba = 0;
Private->Media.LogicalBlocksPerPhysicalBlock = 0;
Private->Media2.LowestAlignedLba = 0;
Private->Media2.LogicalBlocksPerPhysicalBlock = 0;
if (Private->BlockIo.Revision >= EFI_BLOCK_IO_PROTOCOL_REVISION3) {
Private->Media.OptimalTransferLengthGranularity = 0;
Private->Media2.OptimalTransferLengthGranularity = 0;
}
}
Private->DevicePath = AppendDevicePathNode (ParentDevicePath, DevicePathNode);
if (Private->DevicePath == NULL) {
FreePool (Private);
return EFI_OUT_OF_RESOURCES;
}
if (InstallEspGuid) {
Private->EspGuid = &gEfiPartTypeSystemPartGuid;
} else {
//
// If NULL InstallMultipleProtocolInterfaces will ignore it.
//
Private->EspGuid = NULL;
}
//
// Create the new handle.
//
Private->Handle = NULL;
if (Private->DiskIo2 != NULL) {
Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle,
&gEfiDevicePathProtocolGuid,
Private->DevicePath,
&gEfiBlockIoProtocolGuid,
&Private->BlockIo,
&gEfiBlockIo2ProtocolGuid,
&Private->BlockIo2,
Private->EspGuid,
NULL,
NULL
);
} else {
Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle,
&gEfiDevicePathProtocolGuid,
Private->DevicePath,
&gEfiBlockIoProtocolGuid,
&Private->BlockIo,
Private->EspGuid,
NULL,
NULL
);
}
if (!EFI_ERROR (Status)) {
//
// Open the Parent Handle for the child
//
Status = gBS->OpenProtocol (
ParentHandle,
&gEfiDiskIoProtocolGuid,
(VOID **) &ParentDiskIo,
This->DriverBindingHandle,
Private->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
} else {
FreePool (Private->DevicePath);
FreePool (Private);
}
return Status;
}
示例15: VirtioNetDriverBindingStart
STATIC
EFI_STATUS
EFIAPI
VirtioNetDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE DeviceHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
VNET_DEV *Dev;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
MAC_ADDR_DEVICE_PATH MacNode;
VOID *ChildVirtIo;
//
// allocate space for the driver instance
//
Dev = (VNET_DEV *) AllocateZeroPool (sizeof *Dev);
if (Dev == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Dev->Signature = VNET_SIG;
Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
(VOID **)&Dev->VirtIo, This->DriverBindingHandle,
DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
if (EFI_ERROR (Status)) {
goto FreeVirtioNet;
}
//
// now we can run a basic one-shot virtio-net initialization required to
// retrieve the MAC address
//
Status = VirtioNetSnpPopulate (Dev);
if (EFI_ERROR (Status)) {
goto CloseVirtIo;
}
//
// get the device path of the virtio-net device -- one-shot open
//
Status = gBS->OpenProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid,
(VOID **)&DevicePath, This->DriverBindingHandle,
DeviceHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR (Status)) {
goto Evacuate;
}
//
// create another device path that has the MAC address appended
//
MacNode.Header.Type = MESSAGING_DEVICE_PATH;
MacNode.Header.SubType = MSG_MAC_ADDR_DP;
SetDevicePathNodeLength (&MacNode, sizeof MacNode);
CopyMem (&MacNode.MacAddress, &Dev->Snm.CurrentAddress,
sizeof (EFI_MAC_ADDRESS));
MacNode.IfType = Dev->Snm.IfType;
Dev->MacDevicePath = AppendDevicePathNode (DevicePath, &MacNode.Header);
if (Dev->MacDevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Evacuate;
}
//
// create a child handle with the Simple Network Protocol and the new
// device path installed on it
//
Status = gBS->InstallMultipleProtocolInterfaces (&Dev->MacHandle,
&gEfiSimpleNetworkProtocolGuid, &Dev->Snp,
&gEfiDevicePathProtocolGuid, Dev->MacDevicePath,
NULL);
if (EFI_ERROR (Status)) {
goto FreeMacDevicePath;
}
//
// make a note that we keep this device open with VirtIo for the sake of this
// child
//
Status = gBS->OpenProtocol (DeviceHandle, &gVirtioDeviceProtocolGuid,
&ChildVirtIo, This->DriverBindingHandle,
Dev->MacHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER);
if (EFI_ERROR (Status)) {
goto UninstallMultiple;
}
return EFI_SUCCESS;
UninstallMultiple:
gBS->UninstallMultipleProtocolInterfaces (Dev->MacHandle,
&gEfiDevicePathProtocolGuid, Dev->MacDevicePath,
&gEfiSimpleNetworkProtocolGuid, &Dev->Snp,
NULL);
FreeMacDevicePath:
FreePool (Dev->MacDevicePath);
//.........這裏部分代碼省略.........