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
12 // EFI Component Name Protocol
14 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName
= {
15 ScsiDiskComponentNameGetDriverName
,
16 ScsiDiskComponentNameGetControllerName
,
21 // EFI Component Name 2 Protocol
23 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2
= {
24 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
)ScsiDiskComponentNameGetDriverName
,
25 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
)ScsiDiskComponentNameGetControllerName
,
29 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable
[] = {
30 { "eng;en", (CHAR16
*)L
"Scsi Disk Driver" },
35 Retrieves a Unicode string that is the user readable name of the driver.
37 This function retrieves the user readable name of a driver in the form of a
38 Unicode string. If the driver specified by This has a user readable name in
39 the language specified by Language, then a pointer to the driver name is
40 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
41 by This does not support the language specified by Language,
42 then EFI_UNSUPPORTED is returned.
44 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
45 EFI_COMPONENT_NAME_PROTOCOL instance.
47 @param Language A pointer to a Null-terminated ASCII string
48 array indicating the language. This is the
49 language of the driver name that the caller is
50 requesting, and it must match one of the
51 languages specified in SupportedLanguages. The
52 number of languages supported by a driver is up
53 to the driver writer. Language is specified
54 in RFC 4646 or ISO 639-2 language code format.
56 @param DriverName A pointer to the Unicode string to return.
57 This Unicode string is the name of the
58 driver specified by This in the language
59 specified by Language.
61 @retval EFI_SUCCESS The Unicode string for the Driver specified by
62 This and the language specified by Language was
63 returned in DriverName.
65 @retval EFI_INVALID_PARAMETER Language is NULL.
67 @retval EFI_INVALID_PARAMETER DriverName is NULL.
69 @retval EFI_UNSUPPORTED The driver specified by This does not support
70 the language specified by Language.
75 ScsiDiskComponentNameGetDriverName (
76 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
78 OUT CHAR16
**DriverName
81 return LookupUnicodeString2 (
83 This
->SupportedLanguages
,
84 mScsiDiskDriverNameTable
,
86 (BOOLEAN
)(This
== &gScsiDiskComponentName
)
91 Retrieves a Unicode string that is the user readable name of the controller
92 that is being managed by a driver.
94 This function retrieves the user readable name of the controller specified by
95 ControllerHandle and ChildHandle in the form of a Unicode string. If the
96 driver specified by This has a user readable name in the language specified by
97 Language, then a pointer to the controller name is returned in ControllerName,
98 and EFI_SUCCESS is returned. If the driver specified by This is not currently
99 managing the controller specified by ControllerHandle and ChildHandle,
100 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
101 support the language specified by Language, then EFI_UNSUPPORTED is returned.
103 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
104 EFI_COMPONENT_NAME_PROTOCOL instance.
106 @param ControllerHandle The handle of a controller that the driver
107 specified by This is managing. This handle
108 specifies the controller whose name is to be
111 @param ChildHandle The handle of the child controller to retrieve
112 the name of. This is an optional parameter that
113 may be NULL. It will be NULL for device
114 drivers. It will also be NULL for a bus drivers
115 that wish to retrieve the name of the bus
116 controller. It will not be NULL for a bus
117 driver that wishes to retrieve the name of a
120 @param Language A pointer to a Null-terminated ASCII string
121 array indicating the language. This is the
122 language of the driver name that the caller is
123 requesting, and it must match one of the
124 languages specified in SupportedLanguages. The
125 number of languages supported by a driver is up
126 to the driver writer. Language is specified in
127 RFC 4646 or ISO 639-2 language code format.
129 @param ControllerName A pointer to the Unicode string to return.
130 This Unicode string is the name of the
131 controller specified by ControllerHandle and
132 ChildHandle in the language specified by
133 Language from the point of view of the driver
136 @retval EFI_SUCCESS The Unicode string for the user readable name in
137 the language specified by Language for the
138 driver specified by This was returned in
141 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
143 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
146 @retval EFI_INVALID_PARAMETER Language is NULL.
148 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
150 @retval EFI_UNSUPPORTED The driver specified by This is not currently
151 managing the controller specified by
152 ControllerHandle and ChildHandle.
154 @retval EFI_UNSUPPORTED The driver specified by This does not support
155 the language specified by Language.
160 ScsiDiskComponentNameGetControllerName (
161 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
162 IN EFI_HANDLE ControllerHandle
,
163 IN EFI_HANDLE ChildHandle OPTIONAL
,
165 OUT CHAR16
**ControllerName
169 SCSI_DISK_DEV
*ScsiDiskDevice
;
170 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
173 // This is a device driver, so ChildHandle must be NULL.
175 if (ChildHandle
!= NULL
) {
176 return EFI_UNSUPPORTED
;
180 // Make sure this driver is currently managing ControllerHandle
182 Status
= EfiTestManagedDevice (
184 gScsiDiskDriverBinding
.DriverBindingHandle
,
185 &gEfiScsiIoProtocolGuid
187 if (EFI_ERROR (Status
)) {
192 // Get the device context
194 Status
= gBS
->OpenProtocol (
196 &gEfiBlockIoProtocolGuid
,
198 gScsiDiskDriverBinding
.DriverBindingHandle
,
200 EFI_OPEN_PROTOCOL_GET_PROTOCOL
203 if (EFI_ERROR (Status
)) {
207 ScsiDiskDevice
= SCSI_DISK_DEV_FROM_BLKIO (BlockIo
);
209 return LookupUnicodeString2 (
211 This
->SupportedLanguages
,
212 ScsiDiskDevice
->ControllerNameTable
,
214 (BOOLEAN
)(This
== &gScsiDiskComponentName
)