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