]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DevicePathDxe/DevicePathUtilities.c
a78a24d9f5798e4ef9703bc53dc798c93292ba63
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathUtilities.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 DevicePathUtilities.c
15
16 Abstract:
17
18 Implementation file for Device Path Utilities Protocol
19
20 --*/
21
22 //
23 // Include common header file for this module.
24 //
25 #include "CommonHeader.h"
26
27 #include "DevicePath.h"
28
29 UINTN
30 GetDevicePathSizeProtocolInterface (
31 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
32 )
33 /*++
34
35 Routine Description:
36 Returns the size of the device path, in bytes.
37
38 Arguments:
39 DevicePath - Points to the start of the EFI device path.
40
41 Returns:
42 Size - Size of the specified device path, in bytes, including the end-of-path tag.
43
44 --*/
45 {
46 return GetDevicePathSize (DevicePath);
47 }
48
49 EFI_DEVICE_PATH_PROTOCOL *
50 DuplicateDevicePathProtocolInterface (
51 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
52 )
53 /*++
54
55 Routine Description:
56 Create a duplicate of the specified path.
57
58 Arguments:
59 DevicePath - Points to the source EFI device path.
60
61 Returns:
62 Pointer - A pointer to the duplicate device path.
63 NULL - Insufficient memory.
64
65 --*/
66 {
67 return DuplicateDevicePath (DevicePath);
68 }
69
70 EFI_DEVICE_PATH_PROTOCOL *
71 AppendDevicePathProtocolInterface (
72 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
73 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
74 )
75 /*++
76
77 Routine Description:
78 Create a new path by appending the second device path to the first.
79
80 Arguments:
81 Src1 - Points to the first device path. If NULL, then it is ignored.
82 Src2 - Points to the second device path. If NULL, then it is ignored.
83
84 Returns:
85 Pointer - A pointer to the newly created device path.
86 NULL - Memory could not be allocated
87 or either DevicePath or DeviceNode is NULL.
88
89 --*/
90 {
91 return AppendDevicePath (Src1, Src2);
92 }
93
94 EFI_DEVICE_PATH_PROTOCOL *
95 AppendDeviceNodeProtocolInterface (
96 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
97 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
98 )
99 /*++
100
101 Routine Description:
102 Creates a new path by appending the device node to the device path.
103
104 Arguments:
105 DevicePath - Points to the device path.
106 DeviceNode - Points to the device node.
107
108 Returns:
109 Pointer - A pointer to the allocated device node.
110 NULL - Memory could not be allocated
111 or either DevicePath or DeviceNode is NULL.
112
113 --*/
114 {
115 return AppendDevicePathNode (DevicePath, DeviceNode);
116 }
117
118 EFI_DEVICE_PATH_PROTOCOL *
119 AppendDevicePathInstanceProtocolInterface (
120 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
121 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
122 )
123 /*++
124
125 Routine Description:
126 Creates a new path by appending the specified device path instance to the specified device path.
127
128 Arguments:
129 DevicePath - Points to the device path. If NULL, then ignored.
130 DevicePathInstance - Points to the device path instance.
131
132 Returns:
133 Pointer - A pointer to the newly created device path
134 NULL - Memory could not be allocated or DevicePathInstance is NULL.
135
136 --*/
137 {
138 return AppendDevicePathInstance (DevicePath, DevicePathInstance);
139 }
140
141 EFI_DEVICE_PATH_PROTOCOL *
142 GetNextDevicePathInstanceProtocolInterface (
143 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
144 OUT UINTN *DevicePathInstanceSize
145 )
146 /*++
147
148 Routine Description:
149 Creates a copy of the current device path instance and returns a pointer to the next device path instance.
150
151 Arguments:
152 DevicePathInstance - On input, this holds the pointer to the current device path
153 instance. On output, this holds the pointer to the next
154 device path instance or NULL if there are no more device
155 path instances in the device path.
156 DevicePathInstanceSize - On output, this holds the size of the device path instance,
157 in bytes or zero, if DevicePathInstance is zero.
158
159 Returns:
160 Pointer - A pointer to the copy of the current device path instance.
161 NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
162
163 --*/
164 {
165 return GetNextDevicePathInstance (DevicePathInstance, DevicePathInstanceSize);
166 }
167
168 BOOLEAN
169 IsDevicePathMultiInstanceProtocolInterface (
170 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
171 )
172 /*++
173
174 Routine Description:
175 Returns whether a device path is multi-instance.
176
177 Arguments:
178 DevicePath - Points to the device path. If NULL, then ignored.
179
180 Returns:
181 TRUE - The device path has more than one instance
182 FALSE - The device path is empty or contains only a single instance.
183
184 --*/
185 {
186 return IsDevicePathMultiInstance (DevicePath);
187 }
188
189 EFI_DEVICE_PATH_PROTOCOL *
190 CreateDeviceNodeProtocolInterface (
191 IN UINT8 NodeType,
192 IN UINT8 NodeSubType,
193 IN UINT16 NodeLength
194 )
195 /*++
196
197 Routine Description:
198 Creates a device node
199
200 Arguments:
201 NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
202 the new device node.
203 NodeSubType - NodeSubType is the device node sub-type
204 EFI_DEVICE_PATH.SubType) for the new device node.
205 NodeLength - NodeLength is the length of the device node
206 (EFI_DEVICE_PATH.Length) for the new device node.
207
208 Returns:
209 Pointer - A pointer to the newly created device node.
210 NULL - NodeLength is less than
211 the size of the header or there was insufficient memory.
212
213 --*/
214 {
215 return CreateDeviceNode (NodeType, NodeSubType, NodeLength);
216 }