]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c
Adjust directory structures.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / ComponentName.c
CommitLineData
95276127 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
95276127 20#include "Terminal.h"\r
21\r
22//\r
23// EFI Component Name Protocol\r
24//\r
25EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName = {\r
26 TerminalComponentNameGetDriverName,\r
27 TerminalComponentNameGetControllerName,\r
28 "eng"\r
29};\r
30\r
31static EFI_UNICODE_STRING_TABLE mTerminalDriverNameTable[] = {\r
32 {\r
33 "eng",\r
34 (CHAR16 *) L"Serial Terminal Driver"\r
35 },\r
36 {\r
37 NULL,\r
38 NULL\r
39 }\r
40};\r
41\r
42EFI_STATUS\r
43EFIAPI\r
44TerminalComponentNameGetDriverName (\r
45 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
46 IN CHAR8 *Language,\r
47 OUT CHAR16 **DriverName\r
48 )\r
49/*++\r
50\r
51 Routine Description:\r
52 Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
53\r
54 Arguments:\r
55 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
56 Language - A pointer to a three character ISO 639-2 language identifier.\r
57 This is the language of the driver name that that the caller \r
58 is requesting, and it must match one of the languages specified\r
59 in SupportedLanguages. The number of languages supported by a \r
60 driver is up to the driver writer.\r
61 DriverName - A pointer to the Unicode string to return. This Unicode string\r
62 is the name of the driver specified by This in the language \r
63 specified by Language.\r
64\r
65 Returns:\r
66 EFI_SUCCESS - The Unicode string for the Driver specified by This\r
67 and the language specified by Language was returned \r
68 in DriverName.\r
69 EFI_INVALID_PARAMETER - Language is NULL.\r
70 EFI_INVALID_PARAMETER - DriverName is NULL.\r
71 EFI_UNSUPPORTED - The driver specified by This does not support the \r
72 language specified by Language.\r
73\r
74--*/\r
75{\r
76 return LookupUnicodeString (\r
77 Language,\r
78 gTerminalComponentName.SupportedLanguages,\r
79 mTerminalDriverNameTable,\r
80 DriverName\r
81 );\r
82}\r
83\r
84EFI_STATUS\r
85EFIAPI\r
86TerminalComponentNameGetControllerName (\r
87 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
88 IN EFI_HANDLE ControllerHandle,\r
89 IN EFI_HANDLE ChildHandle OPTIONAL,\r
90 IN CHAR8 *Language,\r
91 OUT CHAR16 **ControllerName\r
92 )\r
93/*++\r
94\r
95 Routine Description:\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 Arguments:\r
100 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
101 ControllerHandle - The handle of a controller that the driver specified by \r
102 This is managing. This handle specifies the controller \r
103 whose name is to be returned.\r
104 ChildHandle - The handle of the child controller to retrieve the name \r
105 of. This is an optional parameter that may be NULL. It \r
106 will be NULL for device drivers. It will also be NULL \r
107 for a bus drivers that wish to retrieve the name of the \r
108 bus controller. It will not be NULL for a bus driver \r
109 that wishes to retrieve the name of a child controller.\r
110 Language - A pointer to a three character ISO 639-2 language \r
111 identifier. This is the language of the controller name \r
112 that that the caller is requesting, and it must match one\r
113 of the languages specified in SupportedLanguages. The \r
114 number of languages supported by a driver is up to the \r
115 driver writer.\r
116 ControllerName - A pointer to the Unicode string to return. This Unicode\r
117 string is the name of the controller specified by \r
118 ControllerHandle and ChildHandle in the language \r
119 specified by Language from the point of view of the \r
120 driver specified by This. \r
121\r
122 Returns:\r
123 EFI_SUCCESS - The Unicode string for the user readable name in the\r
124 language specified by Language for the driver \r
125 specified by This was returned in DriverName.\r
126 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
127 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
128 EFI_HANDLE.\r
129 EFI_INVALID_PARAMETER - Language is NULL.\r
130 EFI_INVALID_PARAMETER - ControllerName is NULL.\r
131 EFI_UNSUPPORTED - The driver specified by This is not currently \r
132 managing the controller specified by \r
133 ControllerHandle and ChildHandle.\r
134 EFI_UNSUPPORTED - The driver specified by This does not support the \r
135 language specified by Language.\r
136\r
137--*/\r
138{\r
139 EFI_STATUS Status;\r
140 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;\r
141 TERMINAL_DEV *TerminalDevice;\r
142\r
143 //\r
144 // Make sure this driver is currently managing ControllHandle\r
145 //\r
146 Status = EfiTestManagedDevice (\r
147 ControllerHandle,\r
148 gTerminalDriverBinding.DriverBindingHandle,\r
149 &gEfiSerialIoProtocolGuid\r
150 );\r
151 if (EFI_ERROR (Status)) {\r
152 return Status;\r
153 }\r
154\r
155 //\r
156 // This is a bus driver, so ChildHandle can not be NULL.\r
157 //\r
158 if (ChildHandle == NULL) {\r
159 return EFI_UNSUPPORTED;\r
160 }\r
161\r
162 Status = EfiTestChildHandle (\r
163 ControllerHandle,\r
164 ChildHandle,\r
165 &gEfiSerialIoProtocolGuid\r
166 );\r
167 if (EFI_ERROR (Status)) {\r
168 return Status;\r
169 }\r
170\r
171 //\r
172 // Get our context back\r
173 //\r
174 Status = gBS->OpenProtocol (\r
175 ChildHandle,\r
176 &gEfiSimpleTextOutProtocolGuid,\r
177 (VOID **) &SimpleTextOutput,\r
178 gTerminalDriverBinding.DriverBindingHandle,\r
179 ChildHandle,\r
180 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
181 );\r
182 if (EFI_ERROR (Status)) {\r
183 return EFI_UNSUPPORTED;\r
184 }\r
185\r
186 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);\r
187\r
188 return LookupUnicodeString (\r
189 Language,\r
190 gTerminalComponentName.SupportedLanguages,\r
191 TerminalDevice->ControllerNameTable,\r
192 ControllerName\r
193 );\r
194}\r