]>
Commit | Line | Data |
---|---|---|
de671da8 AP |
1 | /** @file\r |
2 | Component Name functions implementation for XenPvBlk driver.\r | |
3 | \r | |
4 | Copyright (C) 2014, Citrix Ltd.\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "XenPvBlkDxe.h"\r | |
17 | \r | |
18 | ///\r | |
19 | /// Component Name Protocol instance\r | |
20 | ///\r | |
21 | GLOBAL_REMOVE_IF_UNREFERENCED\r | |
22 | EFI_COMPONENT_NAME_PROTOCOL gXenPvBlkDxeComponentName = {\r | |
23 | (EFI_COMPONENT_NAME_GET_DRIVER_NAME) XenPvBlkDxeComponentNameGetDriverName,\r | |
24 | (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)XenPvBlkDxeComponentNameGetControllerName,\r | |
25 | "eng"\r | |
26 | };\r | |
27 | \r | |
28 | ///\r | |
29 | /// Component Name 2 Protocol instance\r | |
30 | ///\r | |
31 | GLOBAL_REMOVE_IF_UNREFERENCED\r | |
32 | EFI_COMPONENT_NAME2_PROTOCOL gXenPvBlkDxeComponentName2 = {\r | |
33 | XenPvBlkDxeComponentNameGetDriverName,\r | |
34 | XenPvBlkDxeComponentNameGetControllerName,\r | |
35 | "en"\r | |
36 | };\r | |
37 | \r | |
38 | ///\r | |
39 | /// Table of driver names\r | |
40 | ///\r | |
41 | GLOBAL_REMOVE_IF_UNREFERENCED\r | |
42 | EFI_UNICODE_STRING_TABLE mXenPvBlkDxeDriverNameTable[] = {\r | |
43 | { "eng;en", (CHAR16 *)L"Xen PV Block Driver" },\r | |
44 | { NULL, NULL }\r | |
45 | };\r | |
46 | \r | |
47 | ///\r | |
48 | /// Table of controller names\r | |
49 | ///\r | |
50 | GLOBAL_REMOVE_IF_UNREFERENCED\r | |
51 | EFI_UNICODE_STRING_TABLE mXenPvBlkDxeControllerNameTable[] = {\r | |
52 | { "eng;en", (CHAR16 *)L"Xen PV Block Device" },\r | |
53 | { NULL, NULL }\r | |
54 | };\r | |
55 | \r | |
56 | /**\r | |
57 | Retrieves a Unicode string that is the user-readable name of the EFI Driver.\r | |
58 | \r | |
59 | @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
60 | @param Language A pointer to a three-character ISO 639-2 language identifier.\r | |
61 | This is the language of the driver name that that the caller\r | |
62 | is requesting, and it must match one of the languages specified\r | |
63 | in SupportedLanguages. The number of languages supported by a\r | |
64 | driver is up to the driver writer.\r | |
65 | @param DriverName A pointer to the Unicode string to return. This Unicode string\r | |
66 | is the name of the driver specified by This in the language\r | |
67 | specified by Language.\r | |
68 | \r | |
69 | @retval EFI_SUCCESS The Unicode string for the Driver specified by This\r | |
70 | and the language specified by Language was returned\r | |
71 | in DriverName.\r | |
72 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
73 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
74 | @retval EFI_UNSUPPORTED The driver specified by This does not support the\r | |
75 | language specified by Language.\r | |
76 | \r | |
77 | **/\r | |
78 | EFI_STATUS\r | |
79 | EFIAPI\r | |
80 | XenPvBlkDxeComponentNameGetDriverName (\r | |
81 | IN EFI_COMPONENT_NAME2_PROTOCOL *This,\r | |
82 | IN CHAR8 *Language,\r | |
83 | OUT CHAR16 **DriverName\r | |
84 | )\r | |
85 | {\r | |
86 | return LookupUnicodeString2 (\r | |
87 | Language,\r | |
88 | This->SupportedLanguages,\r | |
89 | mXenPvBlkDxeDriverNameTable,\r | |
90 | DriverName,\r | |
91 | (BOOLEAN)(This != &gXenPvBlkDxeComponentName2)\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 an EFI Driver.\r | |
98 | \r | |
99 | @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
100 | @param ControllerHandle The handle of a controller that the driver specified by\r | |
101 | This is managing. This handle specifies the controller\r | |
102 | whose name is to be returned.\r | |
103 | @param ChildHandle The handle of the child controller to retrieve the name\r | |
104 | of. This is an optional parameter that may be NULL. It\r | |
105 | will be NULL for device drivers. It will also be NULL\r | |
106 | for a bus drivers that wish to retrieve the name of the\r | |
107 | bus controller. It will not be NULL for a bus driver\r | |
108 | that wishes to retrieve the name of a child controller.\r | |
109 | @param Language A pointer to a three character ISO 639-2 language\r | |
110 | identifier. This is the language of the controller name\r | |
111 | that the caller is requesting, and it must match one\r | |
112 | of the languages specified in SupportedLanguages. The\r | |
113 | number of languages supported by a driver is up to the\r | |
114 | driver writer.\r | |
115 | @param ControllerName A pointer to the Unicode string to return. This Unicode\r | |
116 | string is the name of the controller specified by\r | |
117 | ControllerHandle and ChildHandle in the language specified\r | |
118 | by Language, from the point of view of the driver specified\r | |
119 | by This.\r | |
120 | \r | |
121 | @retval EFI_SUCCESS The Unicode string for the user-readable name in the\r | |
122 | language specified by Language for the driver\r | |
123 | specified by This was returned in DriverName.\r | |
124 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r | |
125 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r | |
126 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
127 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
128 | @retval EFI_UNSUPPORTED The driver specified by This is not currently managing\r | |
129 | the controller specified by ControllerHandle and\r | |
130 | ChildHandle.\r | |
131 | @retval EFI_UNSUPPORTED The driver specified by This does not support the\r | |
132 | language specified by Language.\r | |
133 | \r | |
134 | **/\r | |
135 | EFI_STATUS\r | |
136 | EFIAPI\r | |
137 | XenPvBlkDxeComponentNameGetControllerName (\r | |
138 | IN EFI_COMPONENT_NAME2_PROTOCOL *This,\r | |
139 | IN EFI_HANDLE ControllerHandle,\r | |
140 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
141 | IN CHAR8 *Language,\r | |
142 | OUT CHAR16 **ControllerName\r | |
143 | )\r | |
144 | {\r | |
145 | EFI_STATUS Status;\r | |
146 | \r | |
147 | //\r | |
148 | // ChildHandle must be NULL for a Device Driver\r | |
149 | //\r | |
150 | if (ChildHandle != NULL) {\r | |
151 | return EFI_UNSUPPORTED;\r | |
152 | }\r | |
153 | \r | |
154 | //\r | |
155 | // Make sure this driver is currently managing ControllerHandle\r | |
156 | //\r | |
157 | Status = EfiTestManagedDevice (\r | |
158 | ControllerHandle,\r | |
159 | gXenPvBlkDxeDriverBinding.DriverBindingHandle,\r | |
160 | &gXenBusProtocolGuid\r | |
161 | );\r | |
162 | if (EFI_ERROR (Status)) {\r | |
163 | return Status;\r | |
164 | }\r | |
165 | \r | |
166 | //\r | |
167 | // Lookup name of controller specified by ControllerHandle\r | |
168 | //\r | |
169 | return LookupUnicodeString2 (\r | |
170 | Language,\r | |
171 | This->SupportedLanguages,\r | |
172 | mXenPvBlkDxeControllerNameTable,\r | |
173 | ControllerName,\r | |
174 | (BOOLEAN)(This != &gXenPvBlkDxeComponentName2)\r | |
175 | );\r | |
176 | }\r |