2 Definition for Device Path Tool.
4 Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
5 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
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.
15 #include "UefiDevicePathLib.h"
20 #define UTILITY_NAME "DevicePath"
23 // Utility version information
25 #define UTILITY_MAJOR_VERSION 0
26 #define UTILITY_MINOR_VERSION 1
28 EFI_GUID gEfiDebugPortDevicePathGuid
= DEVICE_PATH_MESSAGING_DEBUGPORT
;
29 EFI_GUID gEfiPcAnsiGuid
= EFI_PC_ANSI_GUID
;
30 EFI_GUID gEfiVT100Guid
= EFI_VT_100_GUID
;
31 EFI_GUID gEfiVT100PlusGuid
= EFI_VT_100_PLUS_GUID
;
32 EFI_GUID gEfiVTUTF8Guid
= EFI_VT_UTF8_GUID
;
33 EFI_GUID gEfiUartDevicePathGuid
= EFI_UART_DEVICE_PATH_GUID
;
34 EFI_GUID gEfiSasDevicePathGuid
= EFI_SAS_DEVICE_PATH_GUID
;
35 EFI_GUID gEfiVirtualDiskGuid
= EFI_VIRTUAL_DISK_GUID
;
36 EFI_GUID gEfiVirtualCdGuid
= EFI_VIRTUAL_CD_GUID
;
37 EFI_GUID gEfiPersistentVirtualDiskGuid
= EFI_PERSISTENT_VIRTUAL_DISK_GUID
;
38 EFI_GUID gEfiPersistentVirtualCdGuid
= EFI_PERSISTENT_VIRTUAL_CD_GUID
;
49 Displays the standard utility information to SDTOUT
61 fprintf (stdout
, "%s Version %d.%d %s \n", UTILITY_NAME
, UTILITY_MAJOR_VERSION
, UTILITY_MINOR_VERSION
, __BUILD_VERSION
);
73 Displays the utility usage syntax to STDOUT
88 fprintf (stdout
, "\nUsage: %s [options]\n\n", UTILITY_NAME
);
91 // Copyright declaration
93 fprintf (stdout
, "Copyright (c) 2017, Intel Corporation. All rights reserved.\n\n");
97 fprintf (stdout
, "Options:\n");
98 fprintf (stdout
, " DevicePathString Device Path string is specified, no space character.\n"
99 " Example: \"PciRoot(0)/Pci(0,0)\"\n");
101 fprintf (stdout
, " --version Show program's version number and exit.\n");
102 fprintf (stdout
, " -h, --help Show this help message and exit.\n");
117 for (Idx
= 0; Idx
< Count
; Idx
++) {
118 printf("0x%02x ", Bytes
[Idx
]);
123 Ascii2UnicodeString (
131 Write ascii string as unicode string format to FILE
135 String - Pointer to string that is written to FILE.
136 UniString - Pointer to unicode string
144 while (*String
!= '\0') {
145 *(UniString
++) = (CHAR16
) *(String
++);
148 // End the UniString with a NULL.
153 int main(int argc
, CHAR8
*argv
[])
157 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
160 Error (NULL
, 0, 1001, "Missing options", "No input options specified.");
164 if ((stricmp (argv
[1], "-h") == 0) || (stricmp (argv
[1], "--help") == 0)) {
167 return STATUS_SUCCESS
;
170 if (stricmp (argv
[1], "--version") == 0) {
172 return STATUS_SUCCESS
;
176 fprintf(stderr
, "Invalid option value, Device Path can't be NULL");
179 Str16
= (CHAR16
*)malloc(1024);
181 fprintf(stderr
, "Resource, memory cannot be allcoated");
184 Ascii2UnicodeString(Str
, Str16
);
185 DevicePath
= UefiDevicePathLibConvertTextToDevicePath(Str16
);
186 if (DevicePath
== NULL
) {
187 fprintf(stderr
, "Convert fail, Cannot convert text to a device path");
191 while (!((DevicePath
->Type
== END_DEVICE_PATH_TYPE
) && (DevicePath
->SubType
== END_ENTIRE_DEVICE_PATH_SUBTYPE
)) )
193 PrintMem (DevicePath
, DevicePath
->Length
[0] | DevicePath
->Length
[1] << 8);
194 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*)((UINT8
*)DevicePath
+ (DevicePath
->Length
[0] | DevicePath
->Length
[1] << 8));
196 PrintMem (DevicePath
, DevicePath
->Length
[0] | DevicePath
->Length
[1] << 8);
199 return STATUS_SUCCESS
;