]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/DevicePath/Dxe/DevicePathUtilities.c
a702595225fe8f81375c86e0075e86e58541d44f
[mirror_edk2.git] / EdkModulePkg / Universal / DevicePath / Dxe / 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 #include "DevicePath.h"
23
24 UINTN
25 GetDevicePathSizeProtocolInterface (
26 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
27 )
28 /*++
29
30 Routine Description:
31 Returns the size of the device path, in bytes.
32
33 Arguments:
34 DevicePath - Points to the start of the EFI device path.
35
36 Returns:
37 Size - Size of the specified device path, in bytes, including the end-of-path tag.
38
39 --*/
40 {
41 return GetDevicePathSize (DevicePath);
42 }
43
44 EFI_DEVICE_PATH_PROTOCOL *
45 DuplicateDevicePathProtocolInterface (
46 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
47 )
48 /*++
49
50 Routine Description:
51 Create a duplicate of the specified path.
52
53 Arguments:
54 DevicePath - Points to the source EFI device path.
55
56 Returns:
57 Pointer - A pointer to the duplicate device path.
58 NULL - Insufficient memory.
59
60 --*/
61 {
62 return DuplicateDevicePath (DevicePath);
63 }
64
65 EFI_DEVICE_PATH_PROTOCOL *
66 AppendDevicePathProtocolInterface (
67 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
68 IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
69 )
70 /*++
71
72 Routine Description:
73 Create a new path by appending the second device path to the first.
74
75 Arguments:
76 Src1 - Points to the first device path. If NULL, then it is ignored.
77 Src2 - Points to the second device path. If NULL, then it is ignored.
78
79 Returns:
80 Pointer - A pointer to the newly created device path.
81 NULL - Memory could not be allocated
82 or either DevicePath or DeviceNode is NULL.
83
84 --*/
85 {
86 return AppendDevicePath (Src1, Src2);
87 }
88
89 EFI_DEVICE_PATH_PROTOCOL *
90 AppendDeviceNodeProtocolInterface (
91 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
92 IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
93 )
94 /*++
95
96 Routine Description:
97 Creates a new path by appending the device node to the device path.
98
99 Arguments:
100 DevicePath - Points to the device path.
101 DeviceNode - Points to the device node.
102
103 Returns:
104 Pointer - A pointer to the allocated device node.
105 NULL - Memory could not be allocated
106 or either DevicePath or DeviceNode is NULL.
107
108 --*/
109 {
110 return AppendDevicePathNode (DevicePath, DeviceNode);
111 }
112
113 EFI_DEVICE_PATH_PROTOCOL *
114 AppendDevicePathInstanceProtocolInterface (
115 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
116 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
117 )
118 /*++
119
120 Routine Description:
121 Creates a new path by appending the specified device path instance to the specified device path.
122
123 Arguments:
124 DevicePath - Points to the device path. If NULL, then ignored.
125 DevicePathInstance - Points to the device path instance.
126
127 Returns:
128 Pointer - A pointer to the newly created device path
129 NULL - Memory could not be allocated or DevicePathInstance is NULL.
130
131 --*/
132 {
133 return AppendDevicePathInstance (DevicePath, DevicePathInstance);
134 }
135
136 EFI_DEVICE_PATH_PROTOCOL *
137 GetNextDevicePathInstanceProtocolInterface (
138 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
139 OUT UINTN *DevicePathInstanceSize
140 )
141 /*++
142
143 Routine Description:
144 Creates a copy of the current device path instance and returns a pointer to the next device path instance.
145
146 Arguments:
147 DevicePathInstance - On input, this holds the pointer to the current device path
148 instance. On output, this holds the pointer to the next
149 device path instance or NULL if there are no more device
150 path instances in the device path.
151 DevicePathInstanceSize - On output, this holds the size of the device path instance,
152 in bytes or zero, if DevicePathInstance is zero.
153
154 Returns:
155 Pointer - A pointer to the copy of the current device path instance.
156 NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
157
158 --*/
159 {
160 return GetNextDevicePathInstance (DevicePathInstance, DevicePathInstanceSize);
161 }
162
163 BOOLEAN
164 IsDevicePathMultiInstanceProtocolInterface (
165 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
166 )
167 /*++
168
169 Routine Description:
170 Returns whether a device path is multi-instance.
171
172 Arguments:
173 DevicePath - Points to the device path. If NULL, then ignored.
174
175 Returns:
176 TRUE - The device path has more than one instance
177 FALSE - The device path is empty or contains only a single instance.
178
179 --*/
180 {
181 return IsDevicePathMultiInstance (DevicePath);
182 }
183
184 EFI_DEVICE_PATH_PROTOCOL *
185 CreateDeviceNodeProtocolInterface (
186 IN UINT8 NodeType,
187 IN UINT8 NodeSubType,
188 IN UINT16 NodeLength
189 )
190 /*++
191
192 Routine Description:
193 Creates a device node
194
195 Arguments:
196 NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
197 the new device node.
198 NodeSubType - NodeSubType is the device node sub-type
199 EFI_DEVICE_PATH.SubType) for the new device node.
200 NodeLength - NodeLength is the length of the device node
201 (EFI_DEVICE_PATH.Length) for the new device node.
202
203 Returns:
204 Pointer - A pointer to the newly created device node.
205 NULL - NodeLength is less than
206 the size of the header or there was insufficient memory.
207
208 --*/
209 {
210 return CreateDeviceNode (NodeType, NodeSubType, NodeLength);
211 }