]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DevicePathDxe/DevicePath.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePath.c
1 /** @file
2 Device Path Driver to produce DevPathUtilities Protocol, DevPathFromText Protocol
3 and DevPathToText Protocol.
4
5 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include <Uefi.h>
11 #include <Protocol/DevicePathUtilities.h>
12 #include <Protocol/DevicePathToText.h>
13 #include <Protocol/DevicePathFromText.h>
14 #include <Library/UefiDriverEntryPoint.h>
15 #include <Library/UefiBootServicesTableLib.h>
16 #include <Library/DevicePathLib.h>
17 #include <Library/PcdLib.h>
18
19 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_UTILITIES_PROTOCOL mDevicePathUtilities = {
20 GetDevicePathSize,
21 DuplicateDevicePath,
22 AppendDevicePath,
23 AppendDevicePathNode,
24 AppendDevicePathInstance,
25 GetNextDevicePathInstance,
26 IsDevicePathMultiInstance,
27 CreateDeviceNode
28 };
29
30 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_TO_TEXT_PROTOCOL mDevicePathToText = {
31 ConvertDeviceNodeToText,
32 ConvertDevicePathToText
33 };
34
35 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL mDevicePathFromText = {
36 ConvertTextToDeviceNode,
37 ConvertTextToDevicePath
38 };
39
40 /**
41 The user Entry Point for DevicePath module.
42
43 This is the entry point for DevicePath module. It installs the UEFI Device Path Utility Protocol and
44 optionally the Device Path to Text and Device Path from Text protocols based on feature flags.
45
46 @param[in] ImageHandle The firmware allocated handle for the EFI image.
47 @param[in] SystemTable A pointer to the EFI System Table.
48
49 @retval EFI_SUCCESS The entry point is executed successfully.
50 @retval Others Some error occurs when executing this entry point.
51
52 **/
53 EFI_STATUS
54 EFIAPI
55 DevicePathEntryPoint (
56 IN EFI_HANDLE ImageHandle,
57 IN EFI_SYSTEM_TABLE *SystemTable
58 )
59 {
60 EFI_STATUS Status;
61 EFI_HANDLE Handle;
62
63 Handle = NULL;
64 Status = EFI_UNSUPPORTED;
65 if (FeaturePcdGet (PcdDevicePathSupportDevicePathToText)) {
66 if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {
67 Status = gBS->InstallMultipleProtocolInterfaces (
68 &Handle,
69 &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
70 &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText,
71 &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText,
72 NULL
73 );
74 } else {
75 Status = gBS->InstallMultipleProtocolInterfaces (
76 &Handle,
77 &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
78 &gEfiDevicePathToTextProtocolGuid, &mDevicePathToText,
79 NULL
80 );
81 }
82 } else {
83 if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {
84 Status = gBS->InstallMultipleProtocolInterfaces (
85 &Handle,
86 &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
87 &gEfiDevicePathFromTextProtocolGuid, &mDevicePathFromText,
88 NULL
89 );
90 } else {
91 Status = gBS->InstallMultipleProtocolInterfaces (
92 &Handle,
93 &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
94 NULL
95 );
96 }
97 }
98 return Status;
99 }