]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/DevicePathUtilities.h
Code have been checked with spec
[mirror_edk2.git] / MdePkg / Include / Protocol / DevicePathUtilities.h
1 /** @file
2 EFI_DEVICE_PATH_UTILITIES_PROTOCOL as defined in UEFI 2.0.
3 Use to create and manipulate device paths and device nodes.
4
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __DEVICE_PATH_UTILITIES_PROTOCOL_H__
17 #define __DEVICE_PATH_UTILITIES_PROTOCOL_H__
18
19
20 #include <Protocol/DevicePath.h>
21
22 ///
23 /// Device Path Utilities protocol
24 ///
25 #define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
26 { \
27 0x379be4e, 0xd706, 0x437d, {0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \
28 }
29
30 /**
31 Returns the size of the device path, in bytes.
32
33 @param DevicePath Points to the start of the EFI device path.
34
35 @return Size Size of the specified device path, in bytes, including the end-of-path tag.
36 @retval 0 DevicePath is NULL
37
38 **/
39 typedef
40 UINTN
41 (EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE)(
42 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
43 );
44
45
46 /**
47 Create a duplicate of the specified path.
48
49 @param DevicePath Points to the source EFI device path.
50
51 @retval Pointer A pointer to the duplicate device path.
52 @retval NULL insufficient memory or DevicePath is NULL
53
54 **/
55 typedef
56 EFI_DEVICE_PATH_PROTOCOL*
57 (EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH)(
58 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
59 );
60
61 /**
62 Create a new path by appending the second device path to the first.
63 If Src1 is NULL and Src2 is non-NULL, then a duplicate of Src2 is returned.
64 If Src1 is non-NULL and Src2 is NULL, then a duplicate of Src1 is returned.
65 If Src1 and Src2 are both NULL, then a copy of an end-of-device-path is returned.
66
67 @param Src1 Points to the first device path.
68 @param Src2 Points to the second device path.
69
70 @retval Pointer A pointer to the newly created device path.
71 @retval NULL Memory could not be allocated
72
73 **/
74 typedef
75 EFI_DEVICE_PATH_PROTOCOL*
76 (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH)(
77 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
78 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
79 );
80
81 /**
82 Creates a new path by appending the device node to the device path.
83 If DeviceNode is NULL then a copy of DevicePath is returned.
84 If DevicePath is NULL then a copy of DeviceNode, followed by an end-of-device path device node is returned.
85 If both DeviceNode and DevicePath are NULL then a copy of an end-of-device-path device node is returned.
86
87 @param DevicePath Points to the device path.
88 @param DeviceNode Points to the device node.
89
90 @retval Pointer A pointer to the allocated device node.
91 @retval NULL There was insufficient memory.
92
93 **/
94 typedef
95 EFI_DEVICE_PATH_PROTOCOL*
96 (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE)(
97 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
98 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
99 );
100
101 /**
102 Creates a new path by appending the specified device path instance to the specified device path.
103
104 @param DevicePath Points to the device path. If NULL, then ignored.
105 @param DevicePathInstance Points to the device path instance.
106
107 @retval Pointer A pointer to the newly created device path
108 @retval NULL Memory could not be allocated or DevicePathInstance is NULL.
109
110 **/
111 typedef
112 EFI_DEVICE_PATH_PROTOCOL*
113 (EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE)(
114 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
115 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
116 );
117
118 /**
119 Creates a copy of the current device path instance and returns a pointer to the next device path
120 instance.
121
122 @param DevicePathInstance On input, this holds the pointer to the current device path
123 instance. On output, this holds the pointer to the next
124 device path instance or NULL if there are no more device
125 path instances in the device path.
126 @param DevicePathInstanceSize On output, this holds the size of the device path instance,
127 in bytes or zero, if DevicePathInstance is NULL.
128 If NULL, then the instance size is not output.
129
130 @retval Pointer A pointer to the copy of the current device path instance.
131 @retval NULL DevicePathInstace was NULL on entry or there was insufficient memory.
132
133 **/
134 typedef
135 EFI_DEVICE_PATH_PROTOCOL*
136 (EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE)(
137 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
138 OUT UINTN *DevicePathInstanceSize
139 );
140
141 /**
142 Creates a device node
143
144 @param NodeType NodeType is the device node type (EFI_DEVICE_PATH.Type) for
145 the new device node.
146 @param NodeSubType NodeSubType is the device node sub-type
147 EFI_DEVICE_PATH.SubType) for the new device node.
148 @param NodeLength NodeLength is the length of the device node
149 (EFI_DEVICE_PATH.Length) for the new device node.
150
151 @retval Pointer A pointer to the newly created device node.
152 @retval NULL NodeLength is less than
153 the size of the header or there was insufficient memory.
154
155 **/
156 typedef
157 EFI_DEVICE_PATH_PROTOCOL*
158 (EFIAPI *EFI_DEVICE_PATH_CREATE_NODE)(
159 IN UINT8 NodeType,
160 IN UINT8 NodeSubType,
161 IN UINT16 NodeLength
162 );
163
164 /**
165 Returns whether a device path is multi-instance.
166
167 @param DevicePath Points to the device path. If NULL, then ignored.
168
169 @retval TRUE The device path has more than one instance
170 @retval FALSE The device path is empty or contains only a single instance.
171
172 **/
173 typedef
174 BOOLEAN
175 (EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE)(
176 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
177 );
178
179 ///
180 /// This protocol is used to creates and manipulates device paths and device nodes.
181 ///
182 typedef struct {
183 EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize;
184 EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH DuplicateDevicePath;
185 EFI_DEVICE_PATH_UTILS_APPEND_PATH AppendDevicePath;
186 EFI_DEVICE_PATH_UTILS_APPEND_NODE AppendDeviceNode;
187 EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE AppendDevicePathInstance;
188 EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE GetNextDevicePathInstance;
189 EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE IsDevicePathMultiInstance;
190 EFI_DEVICE_PATH_CREATE_NODE CreateDeviceNode;
191 } EFI_DEVICE_PATH_UTILITIES_PROTOCOL;
192
193 extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid;
194
195 #endif