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