2 UEFI Component Name(2) protocol implementation for SCSI disk driver.
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 // EFI Component Name Protocol
15 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName
= {
16 ScsiDiskComponentNameGetDriverName
,
17 ScsiDiskComponentNameGetControllerName
,
22 // EFI Component Name 2 Protocol
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
,
31 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable
[] = {
32 { "eng;en", (CHAR16
*) L
"Scsi Disk Driver" },
37 Retrieves a Unicode string that is the user readable name of the driver.
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.
46 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
47 EFI_COMPONENT_NAME_PROTOCOL instance.
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.
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.
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.
67 @retval EFI_INVALID_PARAMETER Language is NULL.
69 @retval EFI_INVALID_PARAMETER DriverName is NULL.
71 @retval EFI_UNSUPPORTED The driver specified by This does not support
72 the language specified by Language.
77 ScsiDiskComponentNameGetDriverName (
78 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
80 OUT CHAR16
**DriverName
83 return LookupUnicodeString2 (
85 This
->SupportedLanguages
,
86 mScsiDiskDriverNameTable
,
88 (BOOLEAN
)(This
== &gScsiDiskComponentName
)
93 Retrieves a Unicode string that is the user readable name of the controller
94 that is being managed by a driver.
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.
105 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
106 EFI_COMPONENT_NAME_PROTOCOL instance.
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
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
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.
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
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
143 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
145 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
148 @retval EFI_INVALID_PARAMETER Language is NULL.
150 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
152 @retval EFI_UNSUPPORTED The driver specified by This is not currently
153 managing the controller specified by
154 ControllerHandle and ChildHandle.
156 @retval EFI_UNSUPPORTED The driver specified by This does not support
157 the language specified by Language.
162 ScsiDiskComponentNameGetControllerName (
163 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
164 IN EFI_HANDLE ControllerHandle
,
165 IN EFI_HANDLE ChildHandle OPTIONAL
,
167 OUT CHAR16
**ControllerName
171 SCSI_DISK_DEV
*ScsiDiskDevice
;
172 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
175 // This is a device driver, so ChildHandle must be NULL.
177 if (ChildHandle
!= NULL
) {
178 return EFI_UNSUPPORTED
;
182 // Make sure this driver is currently managing ControllerHandle
184 Status
= EfiTestManagedDevice (
186 gScsiDiskDriverBinding
.DriverBindingHandle
,
187 &gEfiScsiIoProtocolGuid
189 if (EFI_ERROR (Status
)) {
193 // Get the device context
195 Status
= gBS
->OpenProtocol (
197 &gEfiBlockIoProtocolGuid
,
199 gScsiDiskDriverBinding
.DriverBindingHandle
,
201 EFI_OPEN_PROTOCOL_GET_PROTOCOL
204 if (EFI_ERROR (Status
)) {
208 ScsiDiskDevice
= SCSI_DISK_DEV_FROM_BLKIO (BlockIo
);
210 return LookupUnicodeString2 (
212 This
->SupportedLanguages
,
213 ScsiDiskDevice
->ControllerNameTable
,
215 (BOOLEAN
)(This
== &gScsiDiskComponentName
)