]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c
1. Set the Target array to zero before fill the target id.
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ComponentName.c
CommitLineData
6ad55b15 1/*++\r
2\r
f36d6e66 3Copyright (c) 2004 - 2007, Intel Corporation \r
6ad55b15 4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 ComponentName.c\r
15\r
16Abstract:\r
17\r
18--*/\r
19\r
ed7748fe 20\r
6ad55b15 21#include <PiDxe.h>\r
22\r
ed7748fe 23\r
6ad55b15 24#include <Protocol/ScsiIo.h>\r
25#include <Protocol/ComponentName.h>\r
26#include <Protocol/BlockIo.h>\r
27#include <Protocol/DriverBinding.h>\r
ed7748fe 28\r
6ad55b15 29#include <Library/DebugLib.h>\r
30#include <Library/UefiDriverEntryPoint.h>\r
31#include <Library/UefiLib.h>\r
32#include <Library/BaseMemoryLib.h>\r
33#include <Library/ScsiLib.h>\r
34#include <Library/UefiBootServicesTableLib.h>\r
35\r
36#include "ScsiDisk.h"\r
37\r
38//\r
39// EFI Component Name Protocol\r
40//\r
41EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName = {\r
42 ScsiDiskComponentNameGetDriverName,\r
43 ScsiDiskComponentNameGetControllerName,\r
44 "eng"\r
45};\r
46\r
47static EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable[] = {\r
48 { "eng", (CHAR16 *) L"Scsi Disk Driver" },\r
49 { NULL , NULL }\r
50};\r
51\r
52EFI_STATUS\r
53EFIAPI\r
54ScsiDiskComponentNameGetDriverName (\r
55 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
56 IN CHAR8 *Language,\r
57 OUT CHAR16 **DriverName\r
58 )\r
59/*++\r
60\r
61 Routine Description:\r
62 Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
63\r
64 Arguments:\r
65 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
66 Language - A pointer to a three character ISO 639-2 language identifier.\r
67 This is the language of the driver name that that the caller \r
68 is requesting, and it must match one of the languages specified\r
69 in SupportedLanguages. The number of languages supported by a \r
70 driver is up to the driver writer.\r
71 DriverName - A pointer to the Unicode string to return. This Unicode string\r
72 is the name of the driver specified by This in the language \r
73 specified by Language.\r
74\r
75 Returns:\r
76 EFI_SUCCESS - The Unicode string for the Driver specified by This\r
77 and the language specified by Language was returned \r
78 in DriverName.\r
79 EFI_INVALID_PARAMETER - Language is NULL.\r
80 EFI_INVALID_PARAMETER - DriverName is NULL.\r
81 EFI_UNSUPPORTED - The driver specified by This does not support the \r
82 language specified by Language.\r
83\r
84--*/\r
85{\r
86 return LookupUnicodeString (\r
87 Language,\r
88 gScsiDiskComponentName.SupportedLanguages,\r
89 mScsiDiskDriverNameTable,\r
90 DriverName\r
91 );\r
92}\r
93\r
94EFI_STATUS\r
95EFIAPI\r
96ScsiDiskComponentNameGetControllerName (\r
97 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
98 IN EFI_HANDLE ControllerHandle,\r
99 IN EFI_HANDLE ChildHandle OPTIONAL,\r
100 IN CHAR8 *Language,\r
101 OUT CHAR16 **ControllerName\r
102 )\r
103/*++\r
104\r
105 Routine Description:\r
106 Retrieves a Unicode string that is the user readable name of the controller\r
107 that is being managed by an EFI Driver.\r
108\r
109 Arguments:\r
110 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
111 ControllerHandle - The handle of a controller that the driver specified by \r
112 This is managing. This handle specifies the controller \r
113 whose name is to be returned.\r
114 ChildHandle - The handle of the child controller to retrieve the name \r
115 of. This is an optional parameter that may be NULL. It \r
116 will be NULL for device drivers. It will also be NULL \r
117 for a bus drivers that wish to retrieve the name of the \r
118 bus controller. It will not be NULL for a bus driver \r
119 that wishes to retrieve the name of a child controller.\r
120 Language - A pointer to a three character ISO 639-2 language \r
121 identifier. This is the language of the controller name \r
122 that that the caller is requesting, and it must match one\r
123 of the languages specified in SupportedLanguages. The \r
124 number of languages supported by a driver is up to the \r
125 driver writer.\r
126 ControllerName - A pointer to the Unicode string to return. This Unicode\r
127 string is the name of the controller specified by \r
128 ControllerHandle and ChildHandle in the language \r
129 specified by Language from the point of view of the \r
130 driver specified by This. \r
131\r
132 Returns:\r
133 EFI_SUCCESS - The Unicode string for the user readable name in the\r
134 language specified by Language for the driver \r
135 specified by This was returned in DriverName.\r
136 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
137 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
138 EFI_HANDLE.\r
139 EFI_INVALID_PARAMETER - Language is NULL.\r
140 EFI_INVALID_PARAMETER - ControllerName is NULL.\r
141 EFI_UNSUPPORTED - The driver specified by This is not currently \r
142 managing the controller specified by \r
143 ControllerHandle and ChildHandle.\r
144 EFI_UNSUPPORTED - The driver specified by This does not support the \r
145 language specified by Language.\r
146\r
147--*/\r
148{\r
149 EFI_STATUS Status;\r
150 SCSI_DISK_DEV *ScsiDiskDevice;\r
151 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
152\r
153 //\r
154 // This is a device driver, so ChildHandle must be NULL.\r
155 //\r
156 if (ChildHandle != NULL) {\r
157 return EFI_UNSUPPORTED;\r
158 }\r
159 \r
160 //\r
161 // Make sure this driver is currently managing ControllerHandle\r
162 //\r
163 Status = EfiTestManagedDevice (\r
164 ControllerHandle,\r
165 gScsiDiskDriverBinding.DriverBindingHandle,\r
166 &gEfiScsiIoProtocolGuid\r
167 );\r
168 if (EFI_ERROR (Status)) {\r
169 return Status;\r
170 }\r
171 //\r
172 // Get the device context\r
173 //\r
174 Status = gBS->OpenProtocol (\r
175 ControllerHandle,\r
176 &gEfiBlockIoProtocolGuid,\r
177 (VOID **) &BlockIo,\r
178 gScsiDiskDriverBinding.DriverBindingHandle,\r
179 ControllerHandle,\r
180 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
181 );\r
182\r
183 if (EFI_ERROR (Status)) {\r
184 return Status;\r
185 }\r
186\r
187 ScsiDiskDevice = SCSI_DISK_DEV_FROM_THIS (BlockIo);\r
188\r
189 return LookupUnicodeString (\r
190 Language,\r
191 gScsiDiskComponentName.SupportedLanguages,\r
192 ScsiDiskDevice->ControllerNameTable,\r
193 ControllerName\r
194 );\r
195\r
196}\r