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