10d1ba665SWarner Losh /** @file 20d1ba665SWarner Losh EFI_DEVICE_PATH_UTILITIES_PROTOCOL as defined in UEFI 2.0. 30d1ba665SWarner Losh Use to create and manipulate device paths and device nodes. 40d1ba665SWarner Losh 5*3245fa21SMitchell Horne Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 6*3245fa21SMitchell Horne SPDX-License-Identifier: BSD-2-Clause-Patent 70d1ba665SWarner Losh 80d1ba665SWarner Losh **/ 90d1ba665SWarner Losh 100d1ba665SWarner Losh #ifndef __DEVICE_PATH_UTILITIES_PROTOCOL_H__ 110d1ba665SWarner Losh #define __DEVICE_PATH_UTILITIES_PROTOCOL_H__ 120d1ba665SWarner Losh 130d1ba665SWarner Losh /// 140d1ba665SWarner Losh /// Device Path Utilities protocol 150d1ba665SWarner Losh /// 160d1ba665SWarner Losh #define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \ 170d1ba665SWarner Losh { \ 180d1ba665SWarner Losh 0x379be4e, 0xd706, 0x437d, {0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \ 190d1ba665SWarner Losh } 200d1ba665SWarner Losh 210d1ba665SWarner Losh /** 220d1ba665SWarner Losh Returns the size of the device path, in bytes. 230d1ba665SWarner Losh 240d1ba665SWarner Losh @param DevicePath Points to the start of the EFI device path. 250d1ba665SWarner Losh 260d1ba665SWarner Losh @return Size Size of the specified device path, in bytes, including the end-of-path tag. 270d1ba665SWarner Losh @retval 0 DevicePath is NULL 280d1ba665SWarner Losh 290d1ba665SWarner Losh **/ 300d1ba665SWarner Losh typedef 310d1ba665SWarner Losh UINTN 320d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE)( 330d1ba665SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath 340d1ba665SWarner Losh ); 350d1ba665SWarner Losh 360d1ba665SWarner Losh 370d1ba665SWarner Losh /** 380d1ba665SWarner Losh Create a duplicate of the specified path. 390d1ba665SWarner Losh 400d1ba665SWarner Losh @param DevicePath Points to the source EFI device path. 410d1ba665SWarner Losh 420d1ba665SWarner Losh @retval Pointer A pointer to the duplicate device path. 430d1ba665SWarner Losh @retval NULL insufficient memory or DevicePath is NULL 440d1ba665SWarner Losh 450d1ba665SWarner Losh **/ 460d1ba665SWarner Losh typedef 470d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL* 480d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH)( 490d1ba665SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath 500d1ba665SWarner Losh ); 510d1ba665SWarner Losh 520d1ba665SWarner Losh /** 530d1ba665SWarner Losh Create a new path by appending the second device path to the first. 540d1ba665SWarner Losh If Src1 is NULL and Src2 is non-NULL, then a duplicate of Src2 is returned. 550d1ba665SWarner Losh If Src1 is non-NULL and Src2 is NULL, then a duplicate of Src1 is returned. 560d1ba665SWarner Losh If Src1 and Src2 are both NULL, then a copy of an end-of-device-path is returned. 570d1ba665SWarner Losh 580d1ba665SWarner Losh @param Src1 Points to the first device path. 590d1ba665SWarner Losh @param Src2 Points to the second device path. 600d1ba665SWarner Losh 610d1ba665SWarner Losh @retval Pointer A pointer to the newly created device path. 620d1ba665SWarner Losh @retval NULL Memory could not be allocated 630d1ba665SWarner Losh 640d1ba665SWarner Losh **/ 650d1ba665SWarner Losh typedef 660d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL* 670d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH)( 680d1ba665SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1, 690d1ba665SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2 700d1ba665SWarner Losh ); 710d1ba665SWarner Losh 720d1ba665SWarner Losh /** 730d1ba665SWarner Losh Creates a new path by appending the device node to the device path. 740d1ba665SWarner Losh If DeviceNode is NULL then a copy of DevicePath is returned. 750d1ba665SWarner Losh If DevicePath is NULL then a copy of DeviceNode, followed by an end-of-device path device node is returned. 760d1ba665SWarner Losh If both DeviceNode and DevicePath are NULL then a copy of an end-of-device-path device node is returned. 770d1ba665SWarner Losh 780d1ba665SWarner Losh @param DevicePath Points to the device path. 790d1ba665SWarner Losh @param DeviceNode Points to the device node. 800d1ba665SWarner Losh 810d1ba665SWarner Losh @retval Pointer A pointer to the allocated device node. 820d1ba665SWarner Losh @retval NULL There was insufficient memory. 830d1ba665SWarner Losh 840d1ba665SWarner Losh **/ 850d1ba665SWarner Losh typedef 860d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL* 870d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE)( 880d1ba665SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, 890d1ba665SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode 900d1ba665SWarner Losh ); 910d1ba665SWarner Losh 920d1ba665SWarner Losh /** 930d1ba665SWarner Losh Creates a new path by appending the specified device path instance to the specified device path. 940d1ba665SWarner Losh 950d1ba665SWarner Losh @param DevicePath Points to the device path. If NULL, then ignored. 960d1ba665SWarner Losh @param DevicePathInstance Points to the device path instance. 970d1ba665SWarner Losh 980d1ba665SWarner Losh @retval Pointer A pointer to the newly created device path 990d1ba665SWarner Losh @retval NULL Memory could not be allocated or DevicePathInstance is NULL. 1000d1ba665SWarner Losh 1010d1ba665SWarner Losh **/ 1020d1ba665SWarner Losh typedef 1030d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL* 1040d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE)( 1050d1ba665SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, 1060d1ba665SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance 1070d1ba665SWarner Losh ); 1080d1ba665SWarner Losh 1090d1ba665SWarner Losh /** 1100d1ba665SWarner Losh Creates a copy of the current device path instance and returns a pointer to the next device path 1110d1ba665SWarner Losh instance. 1120d1ba665SWarner Losh 1130d1ba665SWarner Losh @param DevicePathInstance On input, this holds the pointer to the current device path 1140d1ba665SWarner Losh instance. On output, this holds the pointer to the next 1150d1ba665SWarner Losh device path instance or NULL if there are no more device 1160d1ba665SWarner Losh path instances in the device path. 1170d1ba665SWarner Losh @param DevicePathInstanceSize On output, this holds the size of the device path instance, 1180d1ba665SWarner Losh in bytes or zero, if DevicePathInstance is NULL. 1190d1ba665SWarner Losh If NULL, then the instance size is not output. 1200d1ba665SWarner Losh 1210d1ba665SWarner Losh @retval Pointer A pointer to the copy of the current device path instance. 1220d1ba665SWarner Losh @retval NULL DevicePathInstace was NULL on entry or there was insufficient memory. 1230d1ba665SWarner Losh 1240d1ba665SWarner Losh **/ 1250d1ba665SWarner Losh typedef 1260d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL* 1270d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE)( 1280d1ba665SWarner Losh IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance, 1290d1ba665SWarner Losh OUT UINTN *DevicePathInstanceSize 1300d1ba665SWarner Losh ); 1310d1ba665SWarner Losh 1320d1ba665SWarner Losh /** 1330d1ba665SWarner Losh Creates a device node 1340d1ba665SWarner Losh 1350d1ba665SWarner Losh @param NodeType NodeType is the device node type (EFI_DEVICE_PATH.Type) for 1360d1ba665SWarner Losh the new device node. 1370d1ba665SWarner Losh @param NodeSubType NodeSubType is the device node sub-type 1380d1ba665SWarner Losh EFI_DEVICE_PATH.SubType) for the new device node. 1390d1ba665SWarner Losh @param NodeLength NodeLength is the length of the device node 1400d1ba665SWarner Losh (EFI_DEVICE_PATH.Length) for the new device node. 1410d1ba665SWarner Losh 1420d1ba665SWarner Losh @retval Pointer A pointer to the newly created device node. 1430d1ba665SWarner Losh @retval NULL NodeLength is less than 1440d1ba665SWarner Losh the size of the header or there was insufficient memory. 1450d1ba665SWarner Losh 1460d1ba665SWarner Losh **/ 1470d1ba665SWarner Losh typedef 1480d1ba665SWarner Losh EFI_DEVICE_PATH_PROTOCOL* 1490d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_CREATE_NODE)( 1500d1ba665SWarner Losh IN UINT8 NodeType, 1510d1ba665SWarner Losh IN UINT8 NodeSubType, 1520d1ba665SWarner Losh IN UINT16 NodeLength 1530d1ba665SWarner Losh ); 1540d1ba665SWarner Losh 1550d1ba665SWarner Losh /** 1560d1ba665SWarner Losh Returns whether a device path is multi-instance. 1570d1ba665SWarner Losh 1580d1ba665SWarner Losh @param DevicePath Points to the device path. If NULL, then ignored. 1590d1ba665SWarner Losh 1600d1ba665SWarner Losh @retval TRUE The device path has more than one instance 1610d1ba665SWarner Losh @retval FALSE The device path is empty or contains only a single instance. 1620d1ba665SWarner Losh 1630d1ba665SWarner Losh **/ 1640d1ba665SWarner Losh typedef 1650d1ba665SWarner Losh BOOLEAN 1660d1ba665SWarner Losh (EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE)( 1670d1ba665SWarner Losh IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath 1680d1ba665SWarner Losh ); 1690d1ba665SWarner Losh 1700d1ba665SWarner Losh /// 1710d1ba665SWarner Losh /// This protocol is used to creates and manipulates device paths and device nodes. 1720d1ba665SWarner Losh /// 1730d1ba665SWarner Losh typedef struct { 1740d1ba665SWarner Losh EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize; 1750d1ba665SWarner Losh EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH DuplicateDevicePath; 1760d1ba665SWarner Losh EFI_DEVICE_PATH_UTILS_APPEND_PATH AppendDevicePath; 1770d1ba665SWarner Losh EFI_DEVICE_PATH_UTILS_APPEND_NODE AppendDeviceNode; 1780d1ba665SWarner Losh EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE AppendDevicePathInstance; 1790d1ba665SWarner Losh EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE GetNextDevicePathInstance; 1800d1ba665SWarner Losh EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE IsDevicePathMultiInstance; 1810d1ba665SWarner Losh EFI_DEVICE_PATH_UTILS_CREATE_NODE CreateDeviceNode; 1820d1ba665SWarner Losh } EFI_DEVICE_PATH_UTILITIES_PROTOCOL; 1830d1ba665SWarner Losh 1840d1ba665SWarner Losh extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid; 1850d1ba665SWarner Losh 1860d1ba665SWarner Losh #endif 187