]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/DevicePath/Dxe/DevicePathUtilities.c
Check in patch to refine DevicePath Module and USB2HostController Module.
[mirror_edk2.git] / EdkModulePkg / Universal / DevicePath / Dxe / DevicePathUtilities.c
CommitLineData
562d2849 1/*++
2
3Copyright (c) 2006, Intel Corporation
4All rights reserved. This program and the accompanying materials
5are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14 DevicePathUtilities.c
15
16Abstract:
17
18 Implementation file for Device Path Utilities Protocol
19
20--*/
21
562d2849 22#include "DevicePath.h"
23
24UINTN
ffac4bcb 25GetDevicePathSizeProtocolInterface (
562d2849 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{
ffac4bcb 41 return GetDevicePathSize (DevicePath);
562d2849 42}
43
44EFI_DEVICE_PATH_PROTOCOL *
ffac4bcb 45DuplicateDevicePathProtocolInterface (
562d2849 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{
ffac4bcb 62 return DuplicateDevicePath (DevicePath);
562d2849 63}
64
65EFI_DEVICE_PATH_PROTOCOL *
ffac4bcb 66AppendDevicePathProtocolInterface (
562d2849 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{
ffac4bcb 86 return AppendDevicePath (Src1, Src2);
562d2849 87}
88
89EFI_DEVICE_PATH_PROTOCOL *
ffac4bcb 90AppendDeviceNodeProtocolInterface (
562d2849 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{
ffac4bcb 110 return AppendDevicePathNode (DevicePath, DeviceNode);
562d2849 111}
112
113EFI_DEVICE_PATH_PROTOCOL *
ffac4bcb 114AppendDevicePathInstanceProtocolInterface (
562d2849 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{
ffac4bcb 133 return AppendDevicePathInstance (DevicePath, DevicePathInstance);
562d2849 134}
135
136EFI_DEVICE_PATH_PROTOCOL *
ffac4bcb 137GetNextDevicePathInstanceProtocolInterface (
562d2849 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{
ffac4bcb 160 return GetNextDevicePathInstance (DevicePathInstance, DevicePathInstanceSize);
562d2849 161}
162
163BOOLEAN
ffac4bcb 164IsDevicePathMultiInstanceProtocolInterface (
562d2849 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{
ffac4bcb 181 return IsDevicePathMultiInstance (DevicePath);
562d2849 182}
183
184EFI_DEVICE_PATH_PROTOCOL *
ffac4bcb 185CreateDeviceNodeProtocolInterface (
562d2849 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{
ffac4bcb 210 return CreateDeviceNode (NodeType, NodeSubType, NodeLength);
562d2849 211}