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