]> git.proxmox.com Git - mirror_edk2.git/blame - CorebootModulePkg/SataControllerDxe/ComponentName.c
CorebootModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / CorebootModulePkg / SataControllerDxe / ComponentName.c
CommitLineData
81a23a0f
LL
1/** @file
2 UEFI Component Name(2) protocol implementation for Sata Controller driver.
3
4 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
f3342b7a 5 SPDX-License-Identifier: BSD-2-Clause-Patent
81a23a0f
LL
6
7**/
8
9#include "SataController.h"
10
11//
12/// EFI Component Name Protocol
13///
14GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gSataControllerComponentName = {
15 SataControllerComponentNameGetDriverName,
16 SataControllerComponentNameGetControllerName,
17 "eng"
18};
19
20//
21/// EFI Component Name 2 Protocol
22///
23GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2 = {
24 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) SataControllerComponentNameGetDriverName,
25 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) SataControllerComponentNameGetControllerName,
26 "en"
27};
28
29//
30/// Driver Name Strings
31///
32GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerDriverNameTable[] = {
33 {
34 "eng;en",
35 (CHAR16 *)L"Sata Controller Init Driver"
36 },
37 {
38 NULL,
39 NULL
40 }
41};
42
43///
44/// Controller Name Strings
45///
46GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerControllerNameTable[] = {
47 {
48 "eng;en",
49 (CHAR16 *)L"Sata Controller"
50 },
51 {
52 NULL,
53 NULL
54 }
55};
56
57/**
58 Retrieves a Unicode string that is the user readable name of the UEFI Driver.
59
60 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
61 @param Language A pointer to a three character ISO 639-2 language identifier.
62 This is the language of the driver name that that the caller
63 is requesting, and it must match one of the languages specified
64 in SupportedLanguages. The number of languages supported by a
65 driver is up to the driver writer.
66 @param DriverName A pointer to the Unicode string to return. This Unicode string
67 is the name of the driver specified by This in the language
68 specified by Language.
69
70 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
71 and the language specified by Language was returned
72 in DriverName.
73 @retval EFI_INVALID_PARAMETER Language is NULL.
74 @retval EFI_INVALID_PARAMETER DriverName is NULL.
75 @retval EFI_UNSUPPORTED The driver specified by This does not support the
76 language specified by Language.
77**/
78EFI_STATUS
79EFIAPI
80SataControllerComponentNameGetDriverName (
81 IN EFI_COMPONENT_NAME_PROTOCOL *This,
82 IN CHAR8 *Language,
83 OUT CHAR16 **DriverName
84 )
85{
86 return LookupUnicodeString2 (
87 Language,
88 This->SupportedLanguages,
89 mSataControllerDriverNameTable,
90 DriverName,
91 (BOOLEAN)(This == &gSataControllerComponentName)
92 );
93}
94
95/**
96 Retrieves a Unicode string that is the user readable name of the controller
97 that is being managed by an UEFI Driver.
98
99 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
100 @param ControllerHandle The handle of a controller that the driver specified by
101 This is managing. This handle specifies the controller
102 whose name is to be returned.
103 @param ChildHandle OPTIONAL The handle of the child controller to retrieve the name
104 of. This is an optional parameter that may be NULL. It
105 will be NULL for device drivers. It will also be NULL
106 for a bus drivers that wish to retrieve the name of the
107 bus controller. It will not be NULL for a bus driver
108 that wishes to retrieve the name of a child controller.
109 @param Language A pointer to a three character ISO 639-2 language
110 identifier. This is the language of the controller name
111 that that the caller is requesting, and it must match one
112 of the languages specified in SupportedLanguages. The
113 number of languages supported by a driver is up to the
114 driver writer.
115 @param ControllerName A pointer to the Unicode string to return. This Unicode
116 string is the name of the controller specified by
117 ControllerHandle and ChildHandle in the language
118 specified by Language from the point of view of the
119 driver specified by This.
120
121 @retval EFI_SUCCESS The Unicode string for the user readable name in the
122 language specified by Language for the driver
123 specified by This was returned in DriverName.
124 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
125 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
126 EFI_HANDLE.
127 @retval EFI_INVALID_PARAMETER Language is NULL.
128 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
129 @retval EFI_UNSUPPORTED The driver specified by This is not currently
130 managing the controller specified by
131 ControllerHandle and ChildHandle.
132 @retval EFI_UNSUPPORTED The driver specified by This does not support the
133 language specified by Language.
134**/
135EFI_STATUS
136EFIAPI
137SataControllerComponentNameGetControllerName (
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 EFI_STATUS Status;
146
147 //
148 // Make sure this driver is currently managing ControllHandle
149 //
150 Status = EfiTestManagedDevice (
151 ControllerHandle,
152 gSataControllerDriverBinding.DriverBindingHandle,
153 &gEfiPciIoProtocolGuid
154 );
155 if (EFI_ERROR (Status)) {
156 return Status;
157 }
158
159 if (ChildHandle != NULL) {
160 return EFI_UNSUPPORTED;
161 }
162
163 return LookupUnicodeString2 (
164 Language,
165 This->SupportedLanguages,
166 mSataControllerControllerNameTable,
167 ControllerName,
168 (BOOLEAN)(This == &gSataControllerComponentName)
169 );
170}