本文整理汇总了C++中DevicePathNodeLength函数的典型用法代码示例。如果您正苦于以下问题:C++ DevicePathNodeLength函数的具体用法?C++ DevicePathNodeLength怎么用?C++ DevicePathNodeLength使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DevicePathNodeLength函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BmGetDevicePathSizeEx
/**
Returns the size of a device path in bytes.
This function returns the size, in bytes, of the device path data structure
specified by DevicePath including the end of device path node. If DevicePath
is NULL, then 0 is returned. If the length of the device path is bigger than
MaxSize, also return 0 to indicate this is an invalidate device path.
@param DevicePath A pointer to a device path data structure.
@param MaxSize Max valid device path size. If big than this size,
return error.
@retval 0 An invalid device path.
@retval Others The size of a device path in bytes.
**/
UINTN
BmGetDevicePathSizeEx (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINTN MaxSize
)
{
UINTN Size;
UINTN NodeSize;
if (DevicePath == NULL) {
return 0;
}
//
// Search for the end of the device path structure
//
Size = 0;
while (!IsDevicePathEnd (DevicePath)) {
NodeSize = DevicePathNodeLength (DevicePath);
if (NodeSize == 0) {
return 0;
}
Size += NodeSize;
if (Size > MaxSize) {
return 0;
}
DevicePath = NextDevicePathNode (DevicePath);
}
Size += DevicePathNodeLength (DevicePath);
if (Size > MaxSize) {
return 0;
}
return Size;
}
示例2: UnpackDevicePath
EFI_DEVICE_PATH *
UnpackDevicePath (
IN EFI_DEVICE_PATH *DevPath
)
{
EFI_DEVICE_PATH *Src, *Dest, *NewPath;
UINTN Size;
//
// Walk device path and round sizes to valid boundries
//
Src = DevPath;
Size = 0;
for (; ;) {
Size += DevicePathNodeLength(Src);
Size += ALIGN_SIZE(Size);
if (IsDevicePathEnd(Src)) {
break;
}
Src = NextDevicePathNode(Src);
}
//
// Allocate space for the unpacked path
//
NewPath = AllocateZeroPool (Size);
if (NewPath) {
ASSERT (((UINTN)NewPath) % MIN_ALIGNMENT_SIZE == 0);
//
// Copy each node
//
Src = DevPath;
Dest = NewPath;
for (; ;) {
Size = DevicePathNodeLength(Src);
CopyMem (Dest, Src, Size);
Size += ALIGN_SIZE(Size);
SetDevicePathNodeLength (Dest, Size);
Dest->Type |= EFI_DP_TYPE_UNPACKED;
Dest = (EFI_DEVICE_PATH *) (((UINT8 *) Dest) + Size);
if (IsDevicePathEnd(Src)) {
break;
}
Src = NextDevicePathNode(Src);
}
}
return NewPath;
}
示例3: ASSERT
/**
Determine whether a given device path is valid.
If DevicePath is NULL, then ASSERT().
@param DevicePath A pointer to a device path data structure.
@param MaxSize The maximum size of the device path data structure.
@retval TRUE DevicePath is valid.
@retval FALSE The length of any node node in the DevicePath is less
than sizeof (EFI_DEVICE_PATH_PROTOCOL).
@retval FALSE If MaxSize is not zero, the size of the DevicePath
exceeds MaxSize.
@retval FALSE If PcdMaximumDevicePathNodeCount is not zero, the node
count of the DevicePath exceeds PcdMaximumDevicePathNodeCount.
**/
BOOLEAN
EFIAPI
IsDevicePathValid (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINTN MaxSize
)
{
UINTN Count;
UINTN Size;
UINTN NodeLength;
ASSERT (DevicePath != NULL);
if (MaxSize == 0) {
MaxSize = MAX_UINTN;
}
//
// Validate the input size big enough to touch the first node.
//
if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
return FALSE;
}
for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
NodeLength = DevicePathNodeLength (DevicePath);
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
return FALSE;
}
if (NodeLength > MAX_UINTN - Size) {
return FALSE;
}
Size += NodeLength;
//
// Validate next node before touch it.
//
if (Size > MaxSize - END_DEVICE_PATH_LENGTH ) {
return FALSE;
}
if (PcdGet32 (PcdMaximumDevicePathNodeCount) > 0) {
Count++;
if (Count >= PcdGet32 (PcdMaximumDevicePathNodeCount)) {
return FALSE;
}
}
}
//
// Only return TRUE when the End Device Path node is valid.
//
return (BOOLEAN) (DevicePathNodeLength (DevicePath) == END_DEVICE_PATH_LENGTH);
}
示例4: HttpBootParseFilePath
/**
Get the URI address string from the input device path.
Caller need to free the buffer in the UriAddress pointer.
@param[in] FilePath Pointer to the device path which contains a URI device path node.
@param[out] UriAddress The URI address string extract from the device path.
@retval EFI_SUCCESS The URI string is returned.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
HttpBootParseFilePath (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
OUT CHAR8 **UriAddress
)
{
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
URI_DEVICE_PATH *UriDevicePath;
CHAR8 *Uri;
UINTN UriStrLength;
if (FilePath == NULL) {
return EFI_INVALID_PARAMETER;
}
*UriAddress = NULL;
//
// Extract the URI address from the FilePath
//
TempDevicePath = FilePath;
while (!IsDevicePathEnd (TempDevicePath)) {
if ((DevicePathType (TempDevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (TempDevicePath) == MSG_URI_DP)) {
UriDevicePath = (URI_DEVICE_PATH*) TempDevicePath;
//
// UEFI Spec doesn't require the URI to be a NULL-terminated string
// So we allocate a new buffer and always append a '\0' to it.
//
UriStrLength = DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
if (UriStrLength == 0) {
//
// return a NULL UriAddress if it's a empty URI device path node.
//
break;
}
Uri = AllocatePool (UriStrLength + 1);
if (Uri == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (Uri, UriDevicePath->Uri, DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL));
Uri[DevicePathNodeLength (UriDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL)] = '\0';
*UriAddress = Uri;
}
TempDevicePath = NextDevicePathNode (TempDevicePath);
}
return EFI_SUCCESS;
}
示例5: GetSlotNumber
/**
This function retrieves an SD card slot number based on the input device path.
The GetSlotNumber() function retrieves slot number for the SD card specified by
the DevicePath node. If DevicePath is NULL, EFI_INVALID_PARAMETER is returned.
If DevicePath is not a device path node type that the SD Pass Thru driver supports,
EFI_UNSUPPORTED is returned.
@param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.
@param[in] DevicePath A pointer to the device path node that describes a SD
card on the SD controller.
@param[out] Slot On return, points to the slot number of an SD card on
the SD controller.
@retval EFI_SUCCESS SD card slot number is returned in Slot.
@retval EFI_INVALID_PARAMETER Slot or DevicePath is NULL.
@retval EFI_UNSUPPORTED DevicePath is not a device path node type that the SD
Pass Thru driver supports.
**/
EFI_STATUS
EFIAPI
SdMmcPassThruGetSlotNumber (
IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
OUT UINT8 *Slot
)
{
SD_MMC_HC_PRIVATE_DATA *Private;
SD_DEVICE_PATH *SdNode;
EMMC_DEVICE_PATH *EmmcNode;
UINT8 SlotNumber;
if ((This == NULL) || (DevicePath == NULL) || (Slot == NULL)) {
return EFI_INVALID_PARAMETER;
}
Private = SD_MMC_HC_PRIVATE_FROM_THIS (This);
//
// Check whether the DevicePath belongs to SD_DEVICE_PATH or EMMC_DEVICE_PATH
//
if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
((DevicePath->SubType != MSG_SD_DP) &&
(DevicePath->SubType != MSG_EMMC_DP)) ||
(DevicePathNodeLength(DevicePath) != sizeof(SD_DEVICE_PATH)) ||
(DevicePathNodeLength(DevicePath) != sizeof(EMMC_DEVICE_PATH))) {
return EFI_UNSUPPORTED;
}
if (DevicePath->SubType == MSG_SD_DP) {
SdNode = (SD_DEVICE_PATH *) DevicePath;
SlotNumber = SdNode->SlotNumber;
} else {
EmmcNode = (EMMC_DEVICE_PATH *) DevicePath;
SlotNumber = EmmcNode->SlotNumber;
}
if (SlotNumber >= SD_MMC_HC_MAX_SLOT) {
return EFI_NOT_FOUND;
}
if (Private->Slot[SlotNumber].Enable) {
*Slot = SlotNumber;
return EFI_SUCCESS;
} else {
return EFI_NOT_FOUND;
}
}
示例6: ASSERT
/**
Determine whether a given device path is valid.
If DevicePath is NULL, then ASSERT().
@param DevicePath A pointer to a device path data structure.
@param MaxSize The maximum size of the device path data structure.
@retval TRUE DevicePath is valid.
@retval FALSE The length of any node node in the DevicePath is less
than sizeof (EFI_DEVICE_PATH_PROTOCOL).
@retval FALSE If MaxSize is not zero, the size of the DevicePath
exceeds MaxSize.
@retval FALSE If PcdMaximumDevicePathNodeCount is not zero, the node
count of the DevicePath exceeds PcdMaximumDevicePathNodeCount.
**/
BOOLEAN
EFIAPI
IsDevicePathValid (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINTN MaxSize
)
{
UINTN Count;
UINTN Size;
UINTN NodeLength;
ASSERT (DevicePath != NULL);
if (MaxSize == 0){
MaxSize = MAX_UINTN;
}
Size = 0;
Count = 0;
while (MaxSize >= sizeof (EFI_DEVICE_PATH_PROTOCOL) &&
(MaxSize - sizeof (EFI_DEVICE_PATH_PROTOCOL) >= Size) &&
!IsDevicePathEnd (DevicePath)) {
NodeLength = DevicePathNodeLength (DevicePath);
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
return FALSE;
}
if (NodeLength > MAX_UINTN - Size) {
return FALSE;
}
Size += NodeLength;
if (PcdGet32 (PcdMaximumDevicePathNodeCount) > 0) {
Count++;
if (Count >= PcdGet32 (PcdMaximumDevicePathNodeCount)) {
return FALSE;
}
}
DevicePath = NextDevicePathNode (DevicePath);
}
//
// Only return TRUE when the End Device Path node is valid.
//
return (BOOLEAN) (DevicePathNodeLength (DevicePath) == END_DEVICE_PATH_LENGTH);
}
示例7: _DevPathIPv6
static VOID
_DevPathIPv6 (
IN OUT POOL_PRINT *Str,
IN VOID *DevPath
)
{
IPv6_DEVICE_PATH *IP;
IP = DevPath;
CatPrint( Str , L"IPv6(") ;
CatPrintIPv6( Str , & IP-> RemoteIpAddress ) ;
CatPrint( Str , L",") ;
CatPrintNetworkProtocol( Str, IP-> Protocol ) ;
CatPrint( Str , L",%s," , IP-> IPAddressOrigin ?
( IP-> IPAddressOrigin == 1 ? L"StatelessAutoConfigure" :
L"StatefulAutoConfigure" ) : L"Static" ) ;
CatPrintIPv6( Str , & IP-> LocalIpAddress ) ;
if ( DevicePathNodeLength( & IP-> Header ) == sizeof( IPv6_DEVICE_PATH ) ) {
CatPrint( Str , L",") ;
CatPrintIPv6( Str , & IP-> GatewayIpAddress ) ;
CatPrint( Str , L",") ;
CatPrint( Str , L"%d" , & IP-> PrefixLength ) ;
}
CatPrint( Str , L")") ;
}
示例8: _DevPathMacAddr
static VOID
_DevPathMacAddr (
IN OUT POOL_PRINT *Str,
IN VOID *DevPath
)
{
MAC_ADDR_DEVICE_PATH *MAC;
UINTN HwAddressSize;
UINTN Index;
MAC = DevPath;
/* HwAddressSize = sizeof(EFI_MAC_ADDRESS); */
HwAddressSize = DevicePathNodeLength( & MAC-> Header ) ;
HwAddressSize -= sizeof( MAC-> Header ) ;
HwAddressSize -= sizeof( MAC-> IfType ) ;
if (MAC->IfType == 0x01 || MAC->IfType == 0x00) {
HwAddressSize = 6;
}
CatPrint(Str, L"Mac(");
for(Index = 0; Index < HwAddressSize; Index++) {
CatPrint(Str, L"%02x",MAC->MacAddress.Addr[Index]);
}
if ( MAC-> IfType != 0 ) {
CatPrint(Str, L",%d" , MAC-> IfType ) ;
}
CatPrint(Str, L")");
}
示例9: UefiDevicePathLibGetDevicePathSize
/**
Returns the size of a device path in bytes.
This function returns the size, in bytes, of the device path data structure
specified by DevicePath including the end of device path node.
If DevicePath is NULL or invalid, then 0 is returned.
@param DevicePath A pointer to a device path data structure.
@retval 0 If DevicePath is NULL or invalid.
@retval Others The size of a device path in bytes.
**/
UINTN
EFIAPI
UefiDevicePathLibGetDevicePathSize (
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
CONST EFI_DEVICE_PATH_PROTOCOL *Start;
if (DevicePath == NULL) {
return 0;
}
if (!IsDevicePathValid (DevicePath, 0)) {
return 0;
}
//
// Search for the end of the device path structure
//
Start = DevicePath;
while (!IsDevicePathEnd (DevicePath)) {
DevicePath = NextDevicePathNode (DevicePath);
}
//
// Compute the size and add back in the size of the end device path structure
//
return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);
}
示例10: AppendDevicePathNode
EFI_DEVICE_PATH *
AppendDevicePathNode (
IN EFI_DEVICE_PATH *Src1,
IN EFI_DEVICE_PATH *Src2
)
// Src1 may have multiple "instances" and each instance is appended
// Src2 is a signal device path node (without a terminator) that is
// appended to each instance is Src1.
{
EFI_DEVICE_PATH *Temp, *Eop;
UINTN Length;
//
// Build a Src2 that has a terminator on it
//
Length = DevicePathNodeLength(Src2);
Temp = AllocatePool (Length + sizeof(EFI_DEVICE_PATH));
if (!Temp) {
return NULL;
}
CopyMem (Temp, Src2, Length);
Eop = NextDevicePathNode(Temp);
SetDevicePathEndNode(Eop);
//
// Append device paths
//
Src1 = AppendDevicePath (Src1, Temp);
FreePool (Temp);
return Src1;
}
示例11: BusDriver1BindingSupported
EFI_STATUS
BusDriver1BindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
EFI_DEV_PATH *Node;
if (RemainingDevicePath != NULL) {
Node = (EFI_DEV_PATH *)RemainingDevicePath;
if (Node->DevPath.Type != HARDWARE_DEVICE_PATH ||
Node->DevPath.SubType != HW_VENDOR_DP ||
DevicePathNodeLength(&Node->DevPath) != sizeof(VENDOR_DEVICE_PATH)) {
return EFI_UNSUPPORTED;
}
}
Status = gtBS->OpenProtocol (
Controller,
&mInterfaceFunctionTestProtocol1Guid,
NULL,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
if (EFI_ERROR(Status)) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
示例12: NextDevicePathNode
EFIAPI
NextDevicePathNode (
IN CONST VOID *Node
)
{
ASSERT (Node != NULL);
return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node));
}
示例13: CompareDevicePaths
// Compare device paths
static INTN CompareDevicePaths(CONST EFI_DEVICE_PATH *dp1, CONST EFI_DEVICE_PATH *dp2)
{
if (dp1 == NULL || dp2 == NULL)
return -1;
while (1) {
UINT8 type1, type2;
UINT8 subtype1, subtype2;
UINT16 len1, len2;
INTN ret;
type1 = DevicePathType(dp1);
type2 = DevicePathType(dp2);
if (type1 != type2)
return (int) type2 - (int) type1;
subtype1 = DevicePathSubType(dp1);
subtype2 = DevicePathSubType(dp2);
if (subtype1 != subtype2)
return (int) subtype1 - (int) subtype2;
len1 = DevicePathNodeLength(dp1);
len2 = DevicePathNodeLength(dp2);
if (len1 != len2)
return (int) len1 - (int) len2;
ret = CompareMem(dp1, dp2, len1);
if (ret != 0)
return ret;
if (IsDevicePathEnd(dp1))
break;
dp1 = (EFI_DEVICE_PATH*) ((char *)dp1 + len1);
dp2 = (EFI_DEVICE_PATH*) ((char *)dp2 + len2);
}
return 0;
}
示例14: _DevPathIPv4
static VOID
_DevPathIPv4 (
IN OUT POOL_PRINT *Str,
IN VOID *DevPath
)
{
IPv4_DEVICE_PATH *IP;
BOOLEAN show ;
IP = DevPath;
CatPrint( Str , L"IPv4(") ;
CatPrintIPv4( Str , & IP-> RemoteIpAddress ) ;
CatPrint( Str , L",") ;
CatPrintNetworkProtocol( Str , IP-> Protocol ) ;
CatPrint( Str , L",%s" , IP-> StaticIpAddress ? L"Static" : L"DHCP" ) ;
show = IsNotNullIPv4( & IP-> LocalIpAddress ) ;
if ( ! show && DevicePathNodeLength( & IP-> Header ) == sizeof( IPv4_DEVICE_PATH ) ) {
/* only version 2 includes gateway and netmask */
show |= IsNotNullIPv4( & IP-> GatewayIpAddress ) ;
show |= IsNotNullIPv4( & IP-> SubnetMask ) ;
}
if ( show ) {
CatPrint( Str , L"," ) ;
CatPrintIPv4( Str , & IP-> LocalIpAddress ) ;
if ( DevicePathNodeLength( & IP-> Header ) == sizeof( IPv4_DEVICE_PATH ) ) {
/* only version 2 includes gateway and netmask */
show = IsNotNullIPv4( & IP-> GatewayIpAddress ) ;
show |= IsNotNullIPv4( & IP-> SubnetMask ) ;
if ( show ) {
CatPrint( Str , L",") ;
CatPrintIPv4( Str , & IP-> GatewayIpAddress ) ;
if ( IsNotNullIPv4( & IP-> SubnetMask ) ) {
CatPrint( Str , L",") ;
CatPrintIPv4( Str , & IP-> SubnetMask ) ;
}
}
}
}
CatPrint( Str , L")") ;
}
示例15: SerialControllerDriverSupported
/**
Check to see if this driver supports the given controller
@param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
@param Controller The handle of the controller to test.
@param RemainingDevicePath A pointer to the remaining portion of a device path.
@return EFI_SUCCESS This driver can support the given controller
**/
EFI_STATUS
EFIAPI
SerialControllerDriverSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
UART_DEVICE_PATH *Uart;
UART_FLOW_CONTROL_DEVICE_PATH *FlowControl;
//
// Test RemainingDevicePath
//
if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {
Status = EFI_UNSUPPORTED;
Uart = SkipControllerDevicePathNode (RemainingDevicePath, NULL, NULL);
if (DevicePathType (Uart) != MESSAGING_DEVICE_PATH ||
DevicePathSubType (Uart) != MSG_UART_DP ||
DevicePathNodeLength (Uart) != sizeof (UART_DEVICE_PATH)
) {
return EFI_UNSUPPORTED;
}
//
// Do a rough check because Clock Rate is unknown until DriverBindingStart()
//
if (!VerifyUartParameters (0, Uart->BaudRate, Uart->DataBits, Uart->Parity, Uart->StopBits, NULL, NULL)) {
return EFI_UNSUPPORTED;
}
FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Uart);
if (IsUartFlowControlDevicePathNode (FlowControl)) {
//
// If the second node is Flow Control Node,
// return error when it request other than hardware flow control.
//
if ((ReadUnaligned32 (&FlowControl->FlowControlMap) & ~UART_FLOW_CONTROL_HARDWARE) != 0) {
return EFI_UNSUPPORTED;
}
}
}
Status = IsSioSerialController (Controller);
if (EFI_ERROR (Status)) {
Status = IsPciSerialController (Controller);
}
return Status;
}