3 Copyright (c) 2006, 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
,
47 static EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable
[] = {
48 { "eng", (CHAR16
*) L
"Scsi Disk Driver" },
54 ScsiDiskComponentNameGetDriverName (
55 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
57 OUT CHAR16
**DriverName
62 Retrieves a Unicode string that is the user readable name of the EFI Driver.
65 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
66 Language - A pointer to a three character ISO 639-2 language identifier.
67 This is the language of the driver name that that the caller
68 is requesting, and it must match one of the languages specified
69 in SupportedLanguages. The number of languages supported by a
70 driver is up to the driver writer.
71 DriverName - A pointer to the Unicode string to return. This Unicode string
72 is the name of the driver specified by This in the language
73 specified by Language.
76 EFI_SUCCESS - The Unicode string for the Driver specified by This
77 and the language specified by Language was returned
79 EFI_INVALID_PARAMETER - Language is NULL.
80 EFI_INVALID_PARAMETER - DriverName is NULL.
81 EFI_UNSUPPORTED - The driver specified by This does not support the
82 language specified by Language.
86 return LookupUnicodeString (
88 gScsiDiskComponentName
.SupportedLanguages
,
89 mScsiDiskDriverNameTable
,
96 ScsiDiskComponentNameGetControllerName (
97 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
98 IN EFI_HANDLE ControllerHandle
,
99 IN EFI_HANDLE ChildHandle OPTIONAL
,
101 OUT CHAR16
**ControllerName
106 Retrieves a Unicode string that is the user readable name of the controller
107 that is being managed by an EFI Driver.
110 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
111 ControllerHandle - The handle of a controller that the driver specified by
112 This is managing. This handle specifies the controller
113 whose name is to be returned.
114 ChildHandle - The handle of the child controller to retrieve the name
115 of. This is an optional parameter that may be NULL. It
116 will be NULL for device drivers. It will also be NULL
117 for a bus drivers that wish to retrieve the name of the
118 bus controller. It will not be NULL for a bus driver
119 that wishes to retrieve the name of a child controller.
120 Language - A pointer to a three character ISO 639-2 language
121 identifier. This is the language of the controller name
122 that that the caller is requesting, and it must match one
123 of the languages specified in SupportedLanguages. The
124 number of languages supported by a driver is up to the
126 ControllerName - A pointer to the Unicode string to return. This Unicode
127 string is the name of the controller specified by
128 ControllerHandle and ChildHandle in the language
129 specified by Language from the point of view of the
130 driver specified by This.
133 EFI_SUCCESS - The Unicode string for the user readable name in the
134 language specified by Language for the driver
135 specified by This was returned in DriverName.
136 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
137 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
139 EFI_INVALID_PARAMETER - Language is NULL.
140 EFI_INVALID_PARAMETER - ControllerName is NULL.
141 EFI_UNSUPPORTED - The driver specified by This is not currently
142 managing the controller specified by
143 ControllerHandle and ChildHandle.
144 EFI_UNSUPPORTED - The driver specified by This does not support the
145 language specified by Language.
150 SCSI_DISK_DEV
*ScsiDiskDevice
;
151 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
154 // This is a device driver, so ChildHandle must be NULL.
156 if (ChildHandle
!= NULL
) {
157 return EFI_UNSUPPORTED
;
161 // Make sure this driver is currently managing ControllerHandle
163 Status
= EfiTestManagedDevice (
165 gScsiDiskDriverBinding
.DriverBindingHandle
,
166 &gEfiScsiIoProtocolGuid
168 if (EFI_ERROR (Status
)) {
172 // Get the device context
174 Status
= gBS
->OpenProtocol (
176 &gEfiBlockIoProtocolGuid
,
178 gScsiDiskDriverBinding
.DriverBindingHandle
,
180 EFI_OPEN_PROTOCOL_GET_PROTOCOL
183 if (EFI_ERROR (Status
)) {
187 ScsiDiskDevice
= SCSI_DISK_DEV_FROM_THIS (BlockIo
);
189 return LookupUnicodeString (
191 gScsiDiskComponentName
.SupportedLanguages
,
192 ScsiDiskDevice
->ControllerNameTable
,