2 Definition for Device Path Tool.
4 Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "UefiDevicePathLib.h"
14 #define UTILITY_NAME "DevicePath"
17 // Utility version information
19 #define UTILITY_MAJOR_VERSION 0
20 #define UTILITY_MINOR_VERSION 1
22 EFI_GUID gEfiDebugPortProtocolGuid
= DEVICE_PATH_MESSAGING_DEBUGPORT
;
23 EFI_GUID gEfiPcAnsiGuid
= EFI_PC_ANSI_GUID
;
24 EFI_GUID gEfiVT100Guid
= EFI_VT_100_GUID
;
25 EFI_GUID gEfiVT100PlusGuid
= EFI_VT_100_PLUS_GUID
;
26 EFI_GUID gEfiVTUTF8Guid
= EFI_VT_UTF8_GUID
;
27 EFI_GUID gEfiUartDevicePathGuid
= EFI_UART_DEVICE_PATH_GUID
;
28 EFI_GUID gEfiSasDevicePathGuid
= EFI_SAS_DEVICE_PATH_GUID
;
29 EFI_GUID gEfiVirtualDiskGuid
= EFI_VIRTUAL_DISK_GUID
;
30 EFI_GUID gEfiVirtualCdGuid
= EFI_VIRTUAL_CD_GUID
;
31 EFI_GUID gEfiPersistentVirtualDiskGuid
= EFI_PERSISTENT_VIRTUAL_DISK_GUID
;
32 EFI_GUID gEfiPersistentVirtualCdGuid
= EFI_PERSISTENT_VIRTUAL_CD_GUID
;
43 Displays the standard utility information to SDTOUT
55 fprintf (stdout
, "%s Version %d.%d %s \n", UTILITY_NAME
, UTILITY_MAJOR_VERSION
, UTILITY_MINOR_VERSION
, __BUILD_VERSION
);
67 Displays the utility usage syntax to STDOUT
82 fprintf (stdout
, "\nUsage: %s [options]\n\n", UTILITY_NAME
);
85 // Copyright declaration
87 fprintf (stdout
, "Copyright (c) 2017, Intel Corporation. All rights reserved.\n\n");
91 fprintf (stdout
, "Options:\n");
92 fprintf (stdout
, " DevicePathString Device Path string is specified, no space character.\n"
93 " Example: \"PciRoot(0)/Pci(0,0)\"\n");
95 fprintf (stdout
, " --version Show program's version number and exit.\n");
96 fprintf (stdout
, " -h, --help Show this help message and exit.\n");
111 for (Idx
= 0; Idx
< Count
; Idx
++) {
112 printf("0x%02x ", Bytes
[Idx
]);
117 Ascii2UnicodeString (
125 Write ascii string as unicode string format to FILE
129 String - Pointer to string that is written to FILE.
130 UniString - Pointer to unicode string
138 while (*String
!= '\0') {
139 *(UniString
++) = (CHAR16
) *(String
++);
142 // End the UniString with a NULL.
147 int main(int argc
, CHAR8
*argv
[])
151 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
154 Error (NULL
, 0, 1001, "Missing options", "No input options specified.");
158 if ((stricmp (argv
[1], "-h") == 0) || (stricmp (argv
[1], "--help") == 0)) {
161 return STATUS_SUCCESS
;
164 if (stricmp (argv
[1], "--version") == 0) {
166 return STATUS_SUCCESS
;
170 fprintf(stderr
, "Invalid option value, Device Path can't be NULL");
173 Str16
= (CHAR16
*)malloc((strlen (Str
) + 1) * sizeof (CHAR16
));
175 fprintf(stderr
, "Resource, memory cannot be allocated");
178 Ascii2UnicodeString(Str
, Str16
);
179 DevicePath
= UefiDevicePathLibConvertTextToDevicePath(Str16
);
180 if (DevicePath
== NULL
) {
181 fprintf(stderr
, "Convert fail, Cannot convert text to a device path");
185 while (!((DevicePath
->Type
== END_DEVICE_PATH_TYPE
) && (DevicePath
->SubType
== END_ENTIRE_DEVICE_PATH_SUBTYPE
)) )
187 PrintMem (DevicePath
, DevicePath
->Length
[0] | DevicePath
->Length
[1] << 8);
188 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*)((UINT8
*)DevicePath
+ (DevicePath
->Length
[0] | DevicePath
->Length
[1] << 8));
190 PrintMem (DevicePath
, DevicePath
->Length
[0] | DevicePath
->Length
[1] << 8);
193 return STATUS_SUCCESS
;