]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ComponentName.c
1 /** @file
2 UEFI Component Name(2) protocol implementation for SCSI disk driver.
3
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9
10 #include "ScsiDisk.h"
11
12 //
13 // EFI Component Name Protocol
14 //
15 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName = {
16 ScsiDiskComponentNameGetDriverName,
17 ScsiDiskComponentNameGetControllerName,
18 "eng"
19 };
20
21 //
22 // EFI Component Name 2 Protocol
23 //
24 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2 = {
25 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ScsiDiskComponentNameGetDriverName,
26 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ScsiDiskComponentNameGetControllerName,
27 "en"
28 };
29
30
31 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable[] = {
32 { "eng;en", (CHAR16 *) L"Scsi Disk Driver" },
33 { NULL , NULL }
34 };
35
36 /**
37 Retrieves a Unicode string that is the user readable name of the driver.
38
39 This function retrieves the user readable name of a driver in the form of a
40 Unicode string. If the driver specified by This has a user readable name in
41 the language specified by Language, then a pointer to the driver name is
42 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
43 by This does not support the language specified by Language,
44 then EFI_UNSUPPORTED is returned.
45
46 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
47 EFI_COMPONENT_NAME_PROTOCOL instance.
48
49 @param Language A pointer to a Null-terminated ASCII string
50 array indicating the language. This is the
51 language of the driver name that the caller is
52 requesting, and it must match one of the
53 languages specified in SupportedLanguages. The
54 number of languages supported by a driver is up
55 to the driver writer. Language is specified
56 in RFC 4646 or ISO 639-2 language code format.
57
58 @param DriverName A pointer to the Unicode string to return.
59 This Unicode string is the name of the
60 driver specified by This in the language
61 specified by Language.
62
63 @retval EFI_SUCCESS The Unicode string for the Driver specified by
64 This and the language specified by Language was
65 returned in DriverName.
66
67 @retval EFI_INVALID_PARAMETER Language is NULL.
68
69 @retval EFI_INVALID_PARAMETER DriverName is NULL.
70
71 @retval EFI_UNSUPPORTED The driver specified by This does not support
72 the language specified by Language.
73
74 **/
75 EFI_STATUS
76 EFIAPI
77 ScsiDiskComponentNameGetDriverName (
78 IN EFI_COMPONENT_NAME_PROTOCOL *This,
79 IN CHAR8 *Language,
80 OUT CHAR16 **DriverName
81 )
82 {
83 return LookupUnicodeString2 (
84 Language,
85 This->SupportedLanguages,
86 mScsiDiskDriverNameTable,
87 DriverName,
88 (BOOLEAN)(This == &gScsiDiskComponentName)
89 );
90 }
91
92 /**
93 Retrieves a Unicode string that is the user readable name of the controller
94 that is being managed by a driver.
95
96 This function retrieves the user readable name of the controller specified by
97 ControllerHandle and ChildHandle in the form of a Unicode string. If the
98 driver specified by This has a user readable name in the language specified by
99 Language, then a pointer to the controller name is returned in ControllerName,
100 and EFI_SUCCESS is returned. If the driver specified by This is not currently
101 managing the controller specified by ControllerHandle and ChildHandle,
102 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
103 support the language specified by Language, then EFI_UNSUPPORTED is returned.
104
105 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
106 EFI_COMPONENT_NAME_PROTOCOL instance.
107
108 @param ControllerHandle The handle of a controller that the driver
109 specified by This is managing. This handle
110 specifies the controller whose name is to be
111 returned.
112
113 @param ChildHandle The handle of the child controller to retrieve
114 the name of. This is an optional parameter that
115 may be NULL. It will be NULL for device
116 drivers. It will also be NULL for a bus drivers
117 that wish to retrieve the name of the bus
118 controller. It will not be NULL for a bus
119 driver that wishes to retrieve the name of a
120 child controller.
121
122 @param Language A pointer to a Null-terminated ASCII string
123 array indicating the language. This is the
124 language of the driver name that the caller is
125 requesting, and it must match one of the
126 languages specified in SupportedLanguages. The
127 number of languages supported by a driver is up
128 to the driver writer. Language is specified in
129 RFC 4646 or ISO 639-2 language code format.
130
131 @param ControllerName A pointer to the Unicode string to return.
132 This Unicode string is the name of the
133 controller specified by ControllerHandle and
134 ChildHandle in the language specified by
135 Language from the point of view of the driver
136 specified by This.
137
138 @retval EFI_SUCCESS The Unicode string for the user readable name in
139 the language specified by Language for the
140 driver specified by This was returned in
141 DriverName.
142
143 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
144
145 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
146 EFI_HANDLE.
147
148 @retval EFI_INVALID_PARAMETER Language is NULL.
149
150 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
151
152 @retval EFI_UNSUPPORTED The driver specified by This is not currently
153 managing the controller specified by
154 ControllerHandle and ChildHandle.
155
156 @retval EFI_UNSUPPORTED The driver specified by This does not support
157 the language specified by Language.
158
159 **/
160 EFI_STATUS
161 EFIAPI
162 ScsiDiskComponentNameGetControllerName (
163 IN EFI_COMPONENT_NAME_PROTOCOL *This,
164 IN EFI_HANDLE ControllerHandle,
165 IN EFI_HANDLE ChildHandle OPTIONAL,
166 IN CHAR8 *Language,
167 OUT CHAR16 **ControllerName
168 )
169 {
170 EFI_STATUS Status;
171 SCSI_DISK_DEV *ScsiDiskDevice;
172 EFI_BLOCK_IO_PROTOCOL *BlockIo;
173
174 //
175 // This is a device driver, so ChildHandle must be NULL.
176 //
177 if (ChildHandle != NULL) {
178 return EFI_UNSUPPORTED;
179 }
180
181 //
182 // Make sure this driver is currently managing ControllerHandle
183 //
184 Status = EfiTestManagedDevice (
185 ControllerHandle,
186 gScsiDiskDriverBinding.DriverBindingHandle,
187 &gEfiScsiIoProtocolGuid
188 );
189 if (EFI_ERROR (Status)) {
190 return Status;
191 }
192 //
193 // Get the device context
194 //
195 Status = gBS->OpenProtocol (
196 ControllerHandle,
197 &gEfiBlockIoProtocolGuid,
198 (VOID **) &BlockIo,
199 gScsiDiskDriverBinding.DriverBindingHandle,
200 ControllerHandle,
201 EFI_OPEN_PROTOCOL_GET_PROTOCOL
202 );
203
204 if (EFI_ERROR (Status)) {
205 return Status;
206 }
207
208 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (BlockIo);
209
210 return LookupUnicodeString2 (
211 Language,
212 This->SupportedLanguages,
213 ScsiDiskDevice->ControllerNameTable,
214 ControllerName,
215 (BOOLEAN)(This == &gScsiDiskComponentName)
216 );
217
218 }