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