]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/IdeControllerDxe/IdeControllerName.c
Add IDE support for edk2 Duet platform.
[mirror_edk2.git] / DuetPkg / IdeControllerDxe / IdeControllerName.c
1 /*++
2
3 Copyright (c) 2006 - 2007 Intel Corporation. All rights reserved
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
13 Module Name:
14
15 IdeControllerName.c
16
17 Abstract:
18
19 This portion is to register the IDE Controller Driver name:
20 "IDE Controller Init Driver"
21
22 Revision History
23 --*/
24
25 #include "IdeController.h"
26
27 EFI_STATUS
28 EFIAPI
29 IdeControllerGetDriverName (
30 IN EFI_COMPONENT_NAME_PROTOCOL *This,
31 IN CHAR8 *Language,
32 OUT CHAR16 **DriverName
33 );
34
35 EFI_STATUS
36 EFIAPI
37 IdeControllerGetControllerName (
38 IN EFI_COMPONENT_NAME_PROTOCOL *This,
39 IN EFI_HANDLE ControllerHandle,
40 IN EFI_HANDLE ChildHandle OPTIONAL,
41 IN CHAR8 *Language,
42 OUT CHAR16 **ControllerName
43 );
44
45 //
46 // EFI Component Name Protocol
47 // This portion declares a gloabl variable of EFI_COMPONENT_NAME_PROTOCOL type.
48 // It initializes the followings:
49 // .GetDriverName() to PlatformIdeGetDriverName() and
50 // SupportedLanguages to LANGUAGE_CODE_ENGLISH (3 char ISO639-2 language indetifier)
51 //
52 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIdeControllerName = {
53 IdeControllerGetDriverName,
54 IdeControllerGetControllerName,
55 "eng" // Egnlish
56 };
57
58 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerName2 = {
59 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IdeControllerGetDriverName,
60 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IdeControllerGetControllerName,
61 "en" // Egnlish
62 };
63
64 //
65 // Define the Driver's unicode name string
66 // IDE controller Driver name string and IDE Controller Name string
67 //
68 static EFI_UNICODE_STRING_TABLE mIdeControllerDriverNameTable[] = {
69 {
70 "eng;en",
71 L"IDE Controller Init Driver"
72 },
73 {
74 NULL,
75 NULL
76 }
77 };
78
79 static EFI_UNICODE_STRING_TABLE mIdeControllerControllerNameTable[] = {
80 {
81 "eng;en",
82 L"ICH IDE Controller"
83 },
84 {
85 NULL,
86 NULL
87 }
88 };
89
90
91 EFI_STATUS
92 EFIAPI
93 IdeControllerGetDriverName (
94 IN EFI_COMPONENT_NAME_PROTOCOL *This,
95 IN CHAR8 *Language,
96 OUT CHAR16 **DriverName
97 )
98 /*++
99
100 Routine Description:
101 Retrieves a Unicode string that is the user readable name of the EFI Driver.
102
103 Arguments:
104 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
105 Language - A pointer to a three character ISO 639-2 language identifier.
106 This is the language of the driver name that that the caller
107 is requesting, and it must match one of the languages specified
108 in SupportedLanguages. The number of languages supported by a
109 driver is up to the driver writer.
110 DriverName - A pointer to the Unicode string to return. This Unicode string
111 is the name of the driver specified by This in the language
112 specified by Language.
113
114 Returns:
115 EFI_SUCCESS - The Unicode string for the Driver specified by This
116 and the language specified by Language was returned
117 in DriverName.
118 EFI_INVALID_PARAMETER - Language is NULL.
119 EFI_INVALID_PARAMETER - DriverName is NULL.
120 EFI_UNSUPPORTED - The driver specified by This does not support the
121 language specified by Language.
122
123 --*/
124 {
125
126 return LookupUnicodeString2 (
127 Language,
128 This->SupportedLanguages,
129 mIdeControllerDriverNameTable,
130 DriverName,
131 (BOOLEAN)(This == &gIdeControllerName)
132 );
133 }
134
135 EFI_STATUS
136 EFIAPI
137 IdeControllerGetControllerName (
138 IN EFI_COMPONENT_NAME_PROTOCOL *This,
139 IN EFI_HANDLE ControllerHandle,
140 IN EFI_HANDLE ChildHandle OPTIONAL,
141 IN CHAR8 *Language,
142 OUT CHAR16 **ControllerName
143 )
144 /*++
145
146 Routine Description:
147 Retrieves a Unicode string that is the user readable name of the controller
148 that is being managed by an EFI Driver.
149
150 Arguments:
151 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
152 ControllerHandle - The handle of a controller that the driver specified by
153 This is managing. This handle specifies the controller
154 whose name is to be returned.
155 ChildHandle - The handle of the child controller to retrieve the name
156 of. This is an optional parameter that may be NULL. It
157 will be NULL for device drivers. It will also be NULL
158 for a bus drivers that wish to retrieve the name of the
159 bus controller. It will not be NULL for a bus driver
160 that wishes to retrieve the name of a child controller.
161 Language - A pointer to a three character ISO 639-2 language
162 identifier. This is the language of the controller name
163 that that the caller is requesting, and it must match one
164 of the languages specified in SupportedLanguages. The
165 number of languages supported by a driver is up to the
166 driver writer.
167 ControllerName - A pointer to the Unicode string to return. This Unicode
168 string is the name of the controller specified by
169 ControllerHandle and ChildHandle in the language
170 specified by Language from the point of view of the
171 driver specified by This.
172
173 Returns:
174 EFI_SUCCESS - The Unicode string for the user readable name in the
175 language specified by Language for the driver
176 specified by This was returned in DriverName.
177 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
178 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
179 EFI_HANDLE.
180 EFI_INVALID_PARAMETER - Language is NULL.
181 EFI_INVALID_PARAMETER - ControllerName is NULL.
182 EFI_UNSUPPORTED - The driver specified by This is not currently
183 managing the controller specified by
184 ControllerHandle and ChildHandle.
185 EFI_UNSUPPORTED - The driver specified by This does not support the
186 language specified by Language.
187
188 --*/
189 {
190 EFI_STATUS Status;
191
192 if (ChildHandle != NULL) {
193 return EFI_UNSUPPORTED;
194 }
195
196 //
197 // Make sure this driver is currently managing ControllHandle
198 //
199 Status = EfiTestManagedDevice (
200 ControllerHandle,
201 gIdeControllerDriverBinding.DriverBindingHandle,
202 &gEfiPciIoProtocolGuid
203 );
204 if (EFI_ERROR (Status)) {
205 return Status;
206 }
207
208 return LookupUnicodeString2 (
209 Language,
210 This->SupportedLanguages,
211 mIdeControllerControllerNameTable,
212 ControllerName,
213 (BOOLEAN)(This == &gIdeControllerName)
214 );
215 }