1 /** @file
2 This portion is to register the IDE Controller Driver name:
3 "IDE Controller Init Driver"
4
5 Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include "IdeController.h"
11
12 //
13 /// EFI Component Name Protocol
14 ///
15 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIdeControllerComponentName = {
16 IdeControllerComponentNameGetDriverName,
17 IdeControllerComponentNameGetControllerName,
18 "eng"
19 };
20
21 //
22 /// EFI Component Name 2 Protocol
23 ///
24 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerComponentName2 = {
25 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IdeControllerComponentNameGetDriverName,
26 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IdeControllerComponentNameGetControllerName,
27 "en"
28 };
29
30 //
31 /// Driver Name Strings
32 ///
33 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIdeControllerDriverNameTable[] = {
34 {
35 "eng;en",
36 (CHAR16 *)L"IDE Controller Init Driver"
37 },
38 {
39 NULL,
40 NULL
41 }
42 };
43
44 ///
45 /// Controller Name Strings
46 ///
47 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIdeControllerControllerNameTable[] = {
48 {
49 "eng;en",
50 (CHAR16 *)L"PCAT IDE Controller"
51 },
52 {
53 NULL,
54 NULL
55 }
56 };
57
58 /**
59 Retrieves a Unicode string that is the user readable name of the EFI Driver.
60
61 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
62 @param Language A pointer to a three character ISO 639-2 language identifier.
63 This is the language of the driver name that that the caller
64 is requesting, and it must match one of the languages specified
65 in SupportedLanguages. The number of languages supported by a
66 driver is up to the driver writer.
67 @param DriverName A pointer to the Unicode string to return. This Unicode string
68 is the name of the driver specified by This in the language
69 specified by Language.
70
71 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
72 and the language specified by Language was returned
73 in DriverName.
74 @retval EFI_INVALID_PARAMETER Language is NULL.
75 @retval EFI_INVALID_PARAMETER DriverName is NULL.
76 @retval EFI_UNSUPPORTED The driver specified by This does not support the
77 language specified by Language.
78 **/
79 EFI_STATUS
80 EFIAPI
IdeControllerComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL * This,IN CHAR8 * Language,OUT CHAR16 ** DriverName)81 IdeControllerComponentNameGetDriverName (
82 IN EFI_COMPONENT_NAME_PROTOCOL *This,
83 IN CHAR8 *Language,
84 OUT CHAR16 **DriverName
85 )
86 {
87 return LookupUnicodeString2 (
88 Language,
89 This->SupportedLanguages,
90 mIdeControllerDriverNameTable,
91 DriverName,
92 (BOOLEAN)(This == &gIdeControllerComponentName)
93 );
94 }
95
96 /**
97 Retrieves a Unicode string that is the user readable name of the controller
98 that is being managed by an EFI Driver.
99
100 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
101 @param 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 @param ChildHandle OPTIONAL 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 @param 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 @param 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 @retval EFI_SUCCESS The Unicode string for the user readable name in the
123 language specified by Language for the driver
124 specified by This was returned in DriverName.
125 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
126 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
127 EFI_HANDLE.
128 @retval EFI_INVALID_PARAMETER Language is NULL.
129 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
130 @retval EFI_UNSUPPORTED The driver specified by This is not currently
131 managing the controller specified by
132 ControllerHandle and ChildHandle.
133 @retval EFI_UNSUPPORTED The driver specified by This does not support the
134 language specified by Language.
135 **/
136 EFI_STATUS
137 EFIAPI
IdeControllerComponentNameGetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL * This,IN EFI_HANDLE ControllerHandle,IN EFI_HANDLE ChildHandle OPTIONAL,IN CHAR8 * Language,OUT CHAR16 ** ControllerName)138 IdeControllerComponentNameGetControllerName (
139 IN EFI_COMPONENT_NAME_PROTOCOL *This,
140 IN EFI_HANDLE ControllerHandle,
141 IN EFI_HANDLE ChildHandle OPTIONAL,
142 IN CHAR8 *Language,
143 OUT CHAR16 **ControllerName
144 )
145 {
146 EFI_STATUS Status;
147
148 //
149 // Make sure this driver is currently managing ControllHandle
150 //
151 Status = EfiTestManagedDevice (
152 ControllerHandle,
153 gIdeControllerDriverBinding.DriverBindingHandle,
154 &gEfiPciIoProtocolGuid
155 );
156 if (EFI_ERROR (Status)) {
157 return Status;
158 }
159
160 if (ChildHandle != NULL) {
161 return EFI_UNSUPPORTED;
162 }
163
164 return LookupUnicodeString2 (
165 Language,
166 This->SupportedLanguages,
167 mIdeControllerControllerNameTable,
168 ControllerName,
169 (BOOLEAN)(This == &gIdeControllerComponentName)
170 );
171 }
172