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