]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/XenBusDxe/ComponentName.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / OvmfPkg / XenBusDxe / ComponentName.c
CommitLineData
e65e8802
AP
1/** @file\r
2 Component Name functions implementation for XenBus Bus driver.\r
3\r
4 Copyright (C) 2014, Citrix Ltd.\r
5\r
b26f0cf9 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
e65e8802
AP
7\r
8**/\r
9\r
10#include "XenBusDxe.h"\r
11\r
12///\r
13/// Component Name Protocol instance\r
14///\r
15GLOBAL_REMOVE_IF_UNREFERENCED\r
16EFI_COMPONENT_NAME_PROTOCOL gXenBusDxeComponentName = {\r
ac0a286f 17 (EFI_COMPONENT_NAME_GET_DRIVER_NAME)XenBusDxeComponentNameGetDriverName,\r
e65e8802
AP
18 (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)XenBusDxeComponentNameGetControllerName,\r
19 "eng"\r
20};\r
21\r
22///\r
23/// Component Name 2 Protocol instance\r
24///\r
25GLOBAL_REMOVE_IF_UNREFERENCED\r
26EFI_COMPONENT_NAME2_PROTOCOL gXenBusDxeComponentName2 = {\r
27 XenBusDxeComponentNameGetDriverName,\r
28 XenBusDxeComponentNameGetControllerName,\r
29 "en"\r
30};\r
31\r
32///\r
33/// Table of driver names\r
34///\r
35GLOBAL_REMOVE_IF_UNREFERENCED\r
ac0a286f 36EFI_UNICODE_STRING_TABLE mXenBusDxeDriverNameTable[] = {\r
e65e8802 37 { "eng;en", (CHAR16 *)L"XenBus Bus Driver" },\r
ac0a286f 38 { NULL, NULL }\r
e65e8802
AP
39};\r
40\r
41///\r
42/// Table of controller names\r
43///\r
44GLOBAL_REMOVE_IF_UNREFERENCED\r
ac0a286f 45EFI_UNICODE_STRING_TABLE mXenBusDxeControllerNameTable[] = {\r
e65e8802 46 { "eng;en", (CHAR16 *)L"XenBus Controller" },\r
ac0a286f 47 { NULL, NULL }\r
e65e8802
AP
48};\r
49\r
50/**\r
51 Retrieves a Unicode string that is the user-readable name of the EFI Driver.\r
52\r
53 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
54 @param Language A pointer to a three-character ISO 639-2 language identifier.\r
e87ac5ef 55 This is the language of the driver name that the caller\r
e65e8802
AP
56 is requesting, and it must match one of the languages specified\r
57 in SupportedLanguages. The number of languages supported by a\r
58 driver is up to the driver writer.\r
59 @param DriverName A pointer to the Unicode string to return. This Unicode string\r
60 is the name of the driver specified by This in the language\r
61 specified by Language.\r
62\r
63 @retval EFI_SUCCESS The Unicode string for the Driver specified by This\r
64 and the language specified by Language was returned\r
65 in DriverName.\r
66 @retval EFI_INVALID_PARAMETER Language is NULL.\r
67 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
68 @retval EFI_UNSUPPORTED The driver specified by This does not support the\r
69 language specified by Language.\r
70\r
71**/\r
72EFI_STATUS\r
73EFIAPI\r
74XenBusDxeComponentNameGetDriverName (\r
75 IN EFI_COMPONENT_NAME2_PROTOCOL *This,\r
76 IN CHAR8 *Language,\r
77 OUT CHAR16 **DriverName\r
78 )\r
79{\r
80 return LookupUnicodeString2 (\r
81 Language,\r
82 This->SupportedLanguages,\r
83 mXenBusDxeDriverNameTable,\r
84 DriverName,\r
85 (BOOLEAN)(This != &gXenBusDxeComponentName2)\r
86 );\r
87}\r
88\r
89/**\r
90 Retrieves a Unicode string that is the user readable name of the controller\r
91 that is being managed by an EFI Driver.\r
92\r
93 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
94 @param ControllerHandle The handle of a controller that the driver specified by\r
95 This is managing. This handle specifies the controller\r
96 whose name is to be returned.\r
97 @param ChildHandle The handle of the child controller to retrieve the name\r
98 of. This is an optional parameter that may be NULL. It\r
99 will be NULL for device drivers. It will also be NULL\r
100 for a bus drivers that wish to retrieve the name of the\r
101 bus controller. It will not be NULL for a bus driver\r
102 that wishes to retrieve the name of a child controller.\r
103 @param Language A pointer to a three character ISO 639-2 language\r
104 identifier. This is the language of the controller name\r
105 that the caller is requesting, and it must match one\r
106 of the languages specified in SupportedLanguages. The\r
107 number of languages supported by a driver is up to the\r
108 driver writer.\r
109 @param ControllerName A pointer to the Unicode string to return. This Unicode\r
110 string is the name of the controller specified by\r
111 ControllerHandle and ChildHandle in the language specified\r
112 by Language, from the point of view of the driver specified\r
113 by This.\r
114\r
115 @retval EFI_SUCCESS The Unicode string for the user-readable name in the\r
116 language specified by Language for the driver\r
117 specified by This was returned in DriverName.\r
118 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
119 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
120 @retval EFI_INVALID_PARAMETER Language is NULL.\r
121 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
122 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing\r
123 the controller specified by ControllerHandle and\r
124 ChildHandle.\r
125 @retval EFI_UNSUPPORTED The driver specified by This does not support the\r
126 language specified by Language.\r
127\r
128**/\r
129EFI_STATUS\r
130EFIAPI\r
131XenBusDxeComponentNameGetControllerName (\r
132 IN EFI_COMPONENT_NAME2_PROTOCOL *This,\r
133 IN EFI_HANDLE ControllerHandle,\r
134 IN EFI_HANDLE ChildHandle OPTIONAL,\r
135 IN CHAR8 *Language,\r
136 OUT CHAR16 **ControllerName\r
137 )\r
138{\r
139 EFI_STATUS Status;\r
140\r
141 if (ChildHandle != NULL) {\r
142 // TODO Get controller name for a child.\r
143 return EFI_UNSUPPORTED;\r
144 }\r
145\r
146 //\r
147 // Make sure this driver is currently managing ControllerHandle\r
148 //\r
149 Status = EfiTestManagedDevice (\r
150 ControllerHandle,\r
151 gXenBusDxeDriverBinding.DriverBindingHandle,\r
d9fdfd85 152 &gXenIoProtocolGuid\r
e65e8802
AP
153 );\r
154 if (EFI_ERROR (Status)) {\r
155 return Status;\r
156 }\r
157\r
158 //\r
159 // Lookup name of controller specified by ControllerHandle\r
160 //\r
161 return LookupUnicodeString2 (\r
162 Language,\r
163 This->SupportedLanguages,\r
164 mXenBusDxeControllerNameTable,\r
165 ControllerName,\r
166 (BOOLEAN)(This != &gXenBusDxeComponentName2)\r
167 );\r
168}\r