]>
Commit | Line | Data |
---|---|---|
48555339 FT |
1 | /** @file\r |
2 | UEFI Component Name(2) protocol implementation for SD/MMC host controller driver.\r | |
3 | \r | |
4 | Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r | |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
48555339 FT |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include "SdMmcPciHcDxe.h"\r | |
10 | \r | |
11 | //\r | |
12 | // EFI Component Name Protocol\r | |
13 | //\r | |
1436aea4 | 14 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSdMmcPciHcComponentName = {\r |
48555339 FT |
15 | SdMmcPciHcComponentNameGetDriverName,\r |
16 | SdMmcPciHcComponentNameGetControllerName,\r | |
17 | "eng"\r | |
18 | };\r | |
19 | \r | |
20 | //\r | |
21 | // EFI Component Name 2 Protocol\r | |
22 | //\r | |
1436aea4 MK |
23 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSdMmcPciHcComponentName2 = {\r |
24 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)SdMmcPciHcComponentNameGetDriverName,\r | |
25 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)SdMmcPciHcComponentNameGetControllerName,\r | |
48555339 FT |
26 | "en"\r |
27 | };\r | |
28 | \r | |
1436aea4 | 29 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSdMmcPciHcDriverNameTable[] = {\r |
48555339 | 30 | { "eng;en", L"Edkii Sd/Mmc Host Controller Driver" },\r |
1436aea4 | 31 | { NULL, NULL }\r |
48555339 FT |
32 | };\r |
33 | \r | |
1436aea4 | 34 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSdMmcPciHcControllerNameTable[] = {\r |
48555339 | 35 | { "eng;en", L"Edkii Sd/Mmc Host Controller" },\r |
1436aea4 | 36 | { NULL, NULL }\r |
48555339 FT |
37 | };\r |
38 | \r | |
39 | /**\r | |
40 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
41 | \r | |
42 | This function retrieves the user readable name of a driver in the form of a\r | |
43 | Unicode string. If the driver specified by This has a user readable name in\r | |
44 | the language specified by Language, then a pointer to the driver name is\r | |
45 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
46 | by This does not support the language specified by Language,\r | |
47 | then EFI_UNSUPPORTED is returned.\r | |
48 | \r | |
49 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
50 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
51 | \r | |
52 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
53 | array indicating the language. This is the\r | |
54 | language of the driver name that the caller is\r | |
55 | requesting, and it must match one of the\r | |
56 | languages specified in SupportedLanguages. The\r | |
57 | number of languages supported by a driver is up\r | |
58 | to the driver writer. Language is specified\r | |
59 | in RFC 4646 or ISO 639-2 language code format.\r | |
60 | \r | |
61 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
62 | This Unicode string is the name of the\r | |
63 | driver specified by This in the language\r | |
64 | specified by Language.\r | |
65 | \r | |
66 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
67 | This and the language specified by Language was\r | |
68 | returned in DriverName.\r | |
69 | \r | |
70 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
71 | \r | |
72 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
73 | \r | |
74 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
75 | the language specified by Language.\r | |
76 | \r | |
77 | **/\r | |
78 | EFI_STATUS\r | |
79 | EFIAPI\r | |
80 | SdMmcPciHcComponentNameGetDriverName (\r | |
1436aea4 MK |
81 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
82 | IN CHAR8 *Language,\r | |
83 | OUT CHAR16 **DriverName\r | |
48555339 FT |
84 | )\r |
85 | {\r | |
86 | return LookupUnicodeString2 (\r | |
87 | Language,\r | |
88 | This->SupportedLanguages,\r | |
89 | mSdMmcPciHcDriverNameTable,\r | |
90 | DriverName,\r | |
91 | (BOOLEAN)(This == &gSdMmcPciHcComponentName)\r | |
92 | );\r | |
93 | }\r | |
94 | \r | |
95 | /**\r | |
96 | Retrieves a Unicode string that is the user readable name of the controller\r | |
97 | that is being managed by a driver.\r | |
98 | \r | |
99 | This function retrieves the user readable name of the controller specified by\r | |
100 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
101 | driver specified by This has a user readable name in the language specified by\r | |
102 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
103 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
104 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
105 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
106 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
107 | \r | |
108 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
109 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
110 | \r | |
111 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
112 | specified by This is managing. This handle\r | |
113 | specifies the controller whose name is to be\r | |
114 | returned.\r | |
115 | \r | |
116 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
117 | the name of. This is an optional parameter that\r | |
118 | may be NULL. It will be NULL for device\r | |
119 | drivers. It will also be NULL for a bus drivers\r | |
120 | that wish to retrieve the name of the bus\r | |
121 | controller. It will not be NULL for a bus\r | |
122 | driver that wishes to retrieve the name of a\r | |
123 | child controller.\r | |
124 | \r | |
125 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
126 | array indicating the language. This is the\r | |
127 | language of the driver name that the caller is\r | |
128 | requesting, and it must match one of the\r | |
129 | languages specified in SupportedLanguages. The\r | |
130 | number of languages supported by a driver is up\r | |
131 | to the driver writer. Language is specified in\r | |
132 | RFC 4646 or ISO 639-2 language code format.\r | |
133 | \r | |
134 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
135 | This Unicode string is the name of the\r | |
136 | controller specified by ControllerHandle and\r | |
137 | ChildHandle in the language specified by\r | |
138 | Language from the point of view of the driver\r | |
139 | specified by This.\r | |
140 | \r | |
141 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
142 | the language specified by Language for the\r | |
143 | driver specified by This was returned in\r | |
144 | DriverName.\r | |
145 | \r | |
146 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
147 | \r | |
148 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
149 | EFI_HANDLE.\r | |
150 | \r | |
151 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
152 | \r | |
153 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
154 | \r | |
155 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
156 | managing the controller specified by\r | |
157 | ControllerHandle and ChildHandle.\r | |
158 | \r | |
159 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
160 | the language specified by Language.\r | |
161 | \r | |
162 | **/\r | |
163 | EFI_STATUS\r | |
164 | EFIAPI\r | |
165 | SdMmcPciHcComponentNameGetControllerName (\r | |
1436aea4 MK |
166 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
167 | IN EFI_HANDLE ControllerHandle,\r | |
168 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
169 | IN CHAR8 *Language,\r | |
170 | OUT CHAR16 **ControllerName\r | |
48555339 FT |
171 | )\r |
172 | {\r | |
1436aea4 | 173 | EFI_STATUS Status;\r |
48555339 | 174 | \r |
1436aea4 | 175 | if ((Language == NULL) || (ControllerName == NULL)) {\r |
48555339 FT |
176 | return EFI_INVALID_PARAMETER;\r |
177 | }\r | |
178 | \r | |
179 | //\r | |
180 | // This is a device driver, so ChildHandle must be NULL.\r | |
181 | //\r | |
182 | if (ChildHandle != NULL) {\r | |
183 | return EFI_UNSUPPORTED;\r | |
184 | }\r | |
185 | \r | |
186 | //\r | |
187 | // Make sure this driver is currently managing ControllerHandle\r | |
188 | //\r | |
189 | Status = EfiTestManagedDevice (\r | |
190 | ControllerHandle,\r | |
191 | gSdMmcPciHcDriverBinding.DriverBindingHandle,\r | |
192 | &gEfiPciIoProtocolGuid\r | |
193 | );\r | |
194 | if (EFI_ERROR (Status)) {\r | |
195 | return Status;\r | |
196 | }\r | |
197 | \r | |
198 | return LookupUnicodeString2 (\r | |
199 | Language,\r | |
200 | This->SupportedLanguages,\r | |
201 | mSdMmcPciHcControllerNameTable,\r | |
202 | ControllerName,\r | |
203 | (BOOLEAN)(This == &gSdMmcPciHcComponentName)\r | |
204 | );\r | |
205 | }\r |