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