]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Universal/Console/Terminal/Dxe/ComponentName.c
Make EdkModulePkg pass Intel IPF compiler with /W4 /WX switches, solving warning...
[mirror_edk2.git] / EdkModulePkg / Universal / Console / Terminal / Dxe / ComponentName.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 ComponentName.c\r
15\r
16Abstract:\r
17\r
18--*/\r
19\r
20\r
21#include "Terminal.h"\r
22\r
878ddf1f 23//\r
24// EFI Component Name Protocol\r
25//\r
26EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName = {\r
27 TerminalComponentNameGetDriverName,\r
28 TerminalComponentNameGetControllerName,\r
29 "eng"\r
30};\r
31\r
32static EFI_UNICODE_STRING_TABLE mTerminalDriverNameTable[] = {\r
33 {\r
34 "eng",\r
35 (CHAR16 *) L"Serial Terminal Driver"\r
36 },\r
37 {\r
38 NULL,\r
39 NULL\r
40 }\r
41};\r
42\r
43EFI_STATUS\r
44EFIAPI\r
45TerminalComponentNameGetDriverName (\r
46 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
47 IN CHAR8 *Language,\r
48 OUT CHAR16 **DriverName\r
49 )\r
50/*++\r
51\r
52 Routine Description:\r
53 Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
54\r
55 Arguments:\r
56 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
57 Language - A pointer to a three character ISO 639-2 language identifier.\r
58 This is the language of the driver name that that the caller \r
59 is requesting, and it must match one of the languages specified\r
60 in SupportedLanguages. The number of languages supported by a \r
61 driver is up to the driver writer.\r
62 DriverName - A pointer to the Unicode string to return. This Unicode string\r
63 is the name of the driver specified by This in the language \r
64 specified by Language.\r
65\r
66 Returns:\r
67 EFI_SUCCESS - The Unicode string for the Driver specified by This\r
68 and the language specified by Language was returned \r
69 in DriverName.\r
70 EFI_INVALID_PARAMETER - Language is NULL.\r
71 EFI_INVALID_PARAMETER - DriverName is NULL.\r
72 EFI_UNSUPPORTED - The driver specified by This does not support the \r
73 language specified by Language.\r
74\r
75--*/\r
76{\r
77 return LookupUnicodeString (\r
78 Language,\r
79 gTerminalComponentName.SupportedLanguages,\r
80 mTerminalDriverNameTable,\r
81 DriverName\r
82 );\r
83}\r
84\r
85EFI_STATUS\r
86EFIAPI\r
87TerminalComponentNameGetControllerName (\r
88 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
89 IN EFI_HANDLE ControllerHandle,\r
90 IN EFI_HANDLE ChildHandle OPTIONAL,\r
91 IN CHAR8 *Language,\r
92 OUT CHAR16 **ControllerName\r
93 )\r
94/*++\r
95\r
96 Routine Description:\r
97 Retrieves a Unicode string that is the user readable name of the controller\r
98 that is being managed by an EFI Driver.\r
99\r
100 Arguments:\r
101 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
102 ControllerHandle - The handle of a controller that the driver specified by \r
103 This is managing. This handle specifies the controller \r
104 whose name is to be returned.\r
105 ChildHandle - The handle of the child controller to retrieve the name \r
106 of. This is an optional parameter that may be NULL. It \r
107 will be NULL for device drivers. It will also be NULL \r
108 for a bus drivers that wish to retrieve the name of the \r
109 bus controller. It will not be NULL for a bus driver \r
110 that wishes to retrieve the name of a child controller.\r
111 Language - A pointer to a three character ISO 639-2 language \r
112 identifier. This is the language of the controller name \r
113 that that the caller is requesting, and it must match one\r
114 of the languages specified in SupportedLanguages. The \r
115 number of languages supported by a driver is up to the \r
116 driver writer.\r
117 ControllerName - A pointer to the Unicode string to return. This Unicode\r
118 string is the name of the controller specified by \r
119 ControllerHandle and ChildHandle in the language \r
120 specified by Language from the point of view of the \r
121 driver specified by This. \r
122\r
123 Returns:\r
124 EFI_SUCCESS - The Unicode string for the user readable name in the\r
125 language specified by Language for the driver \r
126 specified by This was returned in DriverName.\r
127 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
128 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
129 EFI_HANDLE.\r
130 EFI_INVALID_PARAMETER - Language is NULL.\r
131 EFI_INVALID_PARAMETER - ControllerName is NULL.\r
132 EFI_UNSUPPORTED - The driver specified by This is not currently \r
133 managing the controller specified by \r
134 ControllerHandle and ChildHandle.\r
135 EFI_UNSUPPORTED - The driver specified by This does not support the \r
136 language specified by Language.\r
137\r
138--*/\r
139{\r
140 EFI_STATUS Status;\r
141 EFI_SIMPLE_TEXT_OUT_PROTOCOL *SimpleTextOutput;\r
142 TERMINAL_DEV *TerminalDevice;\r
143\r
61fb1657 144 //\r
145 // Make sure this driver is currently managing ControllHandle\r
146 //\r
147 Status = EfiTestManagedDevice (\r
148 ControllerHandle,\r
149 gTerminalDriverBinding.DriverBindingHandle,\r
150 &gEfiSerialIoProtocolGuid\r
151 );\r
152 if (EFI_ERROR (Status)) {\r
153 return Status;\r
154 }\r
155\r
878ddf1f 156 //\r
157 // This is a bus driver, so ChildHandle can not be NULL.\r
158 //\r
159 if (ChildHandle == NULL) {\r
160 return EFI_UNSUPPORTED;\r
161 }\r
61fb1657 162\r
163 Status = EfiTestChildHandle (\r
164 ControllerHandle,\r
165 ChildHandle,\r
166 &gEfiSerialIoProtocolGuid\r
167 );\r
168 if (EFI_ERROR (Status)) {\r
169 return Status;\r
170 }\r
171\r
878ddf1f 172 //\r
173 // Get our context back\r
174 //\r
175 Status = gBS->OpenProtocol (\r
176 ChildHandle,\r
177 &gEfiSimpleTextOutProtocolGuid,\r
178 (VOID **) &SimpleTextOutput,\r
179 gTerminalDriverBinding.DriverBindingHandle,\r
180 ChildHandle,\r
181 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
182 );\r
183 if (EFI_ERROR (Status)) {\r
184 return EFI_UNSUPPORTED;\r
185 }\r
186\r
187 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);\r
188\r
189 return LookupUnicodeString (\r
190 Language,\r
191 gTerminalComponentName.SupportedLanguages,\r
192 TerminalDevice->ControllerNameTable,\r
193 ControllerName\r
194 );\r
195}\r