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