3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 #include <Protocol/ScsiIo.h>
25 #include <Protocol/ComponentName.h>
26 #include <Protocol/BlockIo.h>
27 #include <Protocol/DriverBinding.h>
29 #include <Library/DebugLib.h>
30 #include <Library/UefiDriverEntryPoint.h>
31 #include <Library/UefiLib.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/ScsiLib.h>
34 #include <Library/UefiBootServicesTableLib.h>
39 // EFI Component Name Protocol
41 EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName
= {
42 ScsiDiskComponentNameGetDriverName
,
43 ScsiDiskComponentNameGetControllerName
,
48 // EFI Component Name 2 Protocol
50 EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2
= {
51 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) ScsiDiskComponentNameGetDriverName
,
52 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) ScsiDiskComponentNameGetControllerName
,
57 static EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable
[] = {
58 { "eng;en", (CHAR16
*) L
"Scsi Disk Driver" },
63 Retrieves a Unicode string that is the user readable name of the driver.
65 This function retrieves the user readable name of a driver in the form of a
66 Unicode string. If the driver specified by This has a user readable name in
67 the language specified by Language, then a pointer to the driver name is
68 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
69 by This does not support the language specified by Language,
70 then EFI_UNSUPPORTED is returned.
72 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
73 EFI_COMPONENT_NAME_PROTOCOL instance.
75 @param Language[in] A pointer to a Null-terminated ASCII string
76 array indicating the language. This is the
77 language of the driver name that the caller is
78 requesting, and it must match one of the
79 languages specified in SupportedLanguages. The
80 number of languages supported by a driver is up
81 to the driver writer. Language is specified
82 in RFC 3066 or ISO 639-2 language code format.
84 @param DriverName[out] A pointer to the Unicode string to return.
85 This Unicode string is the name of the
86 driver specified by This in the language
87 specified by Language.
89 @retval EFI_SUCCESS The Unicode string for the Driver specified by
90 This and the language specified by Language was
91 returned in DriverName.
93 @retval EFI_INVALID_PARAMETER Language is NULL.
95 @retval EFI_INVALID_PARAMETER DriverName is NULL.
97 @retval EFI_UNSUPPORTED The driver specified by This does not support
98 the language specified by Language.
103 ScsiDiskComponentNameGetDriverName (
104 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
106 OUT CHAR16
**DriverName
109 return LookupUnicodeString2 (
111 This
->SupportedLanguages
,
112 mScsiDiskDriverNameTable
,
114 (BOOLEAN
)(This
== &gScsiDiskComponentName
)
119 Retrieves a Unicode string that is the user readable name of the controller
120 that is being managed by a driver.
122 This function retrieves the user readable name of the controller specified by
123 ControllerHandle and ChildHandle in the form of a Unicode string. If the
124 driver specified by This has a user readable name in the language specified by
125 Language, then a pointer to the controller name is returned in ControllerName,
126 and EFI_SUCCESS is returned. If the driver specified by This is not currently
127 managing the controller specified by ControllerHandle and ChildHandle,
128 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
129 support the language specified by Language, then EFI_UNSUPPORTED is returned.
131 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
132 EFI_COMPONENT_NAME_PROTOCOL instance.
134 @param ControllerHandle[in] The handle of a controller that the driver
135 specified by This is managing. This handle
136 specifies the controller whose name is to be
139 @param ChildHandle[in] The handle of the child controller to retrieve
140 the name of. This is an optional parameter that
141 may be NULL. It will be NULL for device
142 drivers. It will also be NULL for a bus drivers
143 that wish to retrieve the name of the bus
144 controller. It will not be NULL for a bus
145 driver that wishes to retrieve the name of a
148 @param Language[in] A pointer to a Null-terminated ASCII string
149 array indicating the language. This is the
150 language of the driver name that the caller is
151 requesting, and it must match one of the
152 languages specified in SupportedLanguages. The
153 number of languages supported by a driver is up
154 to the driver writer. Language is specified in
155 RFC 3066 or ISO 639-2 language code format.
157 @param ControllerName[out] A pointer to the Unicode string to return.
158 This Unicode string is the name of the
159 controller specified by ControllerHandle and
160 ChildHandle in the language specified by
161 Language from the point of view of the driver
164 @retval EFI_SUCCESS The Unicode string for the user readable name in
165 the language specified by Language for the
166 driver specified by This was returned in
169 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
171 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
174 @retval EFI_INVALID_PARAMETER Language is NULL.
176 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
178 @retval EFI_UNSUPPORTED The driver specified by This is not currently
179 managing the controller specified by
180 ControllerHandle and ChildHandle.
182 @retval EFI_UNSUPPORTED The driver specified by This does not support
183 the language specified by Language.
188 ScsiDiskComponentNameGetControllerName (
189 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
190 IN EFI_HANDLE ControllerHandle
,
191 IN EFI_HANDLE ChildHandle OPTIONAL
,
193 OUT CHAR16
**ControllerName
197 SCSI_DISK_DEV
*ScsiDiskDevice
;
198 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
201 // This is a device driver, so ChildHandle must be NULL.
203 if (ChildHandle
!= NULL
) {
204 return EFI_UNSUPPORTED
;
208 // Make sure this driver is currently managing ControllerHandle
210 Status
= EfiTestManagedDevice (
212 gScsiDiskDriverBinding
.DriverBindingHandle
,
213 &gEfiScsiIoProtocolGuid
215 if (EFI_ERROR (Status
)) {
219 // Get the device context
221 Status
= gBS
->OpenProtocol (
223 &gEfiBlockIoProtocolGuid
,
225 gScsiDiskDriverBinding
.DriverBindingHandle
,
227 EFI_OPEN_PROTOCOL_GET_PROTOCOL
230 if (EFI_ERROR (Status
)) {
234 ScsiDiskDevice
= SCSI_DISK_DEV_FROM_THIS (BlockIo
);
236 return LookupUnicodeString2 (
238 This
->SupportedLanguages
,
239 ScsiDiskDevice
->ControllerNameTable
,
241 (BOOLEAN
)(This
== &gScsiDiskComponentName
)