Perfected MSA files.
[mirror_edk2.git] / EdkModulePkg / Bus / Scsi / ScsiDisk / Dxe / ComponentName.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
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
20#include "ScsiDisk.h"\r
21\r
878ddf1f 22//\r
23// EFI Component Name Protocol\r
24//\r
25EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName = {\r
26 ScsiDiskComponentNameGetDriverName,\r
27 ScsiDiskComponentNameGetControllerName,\r
28 "eng"\r
29};\r
30\r
31static EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable[] = {\r
32 { "eng", (CHAR16 *) L"Scsi Disk Driver" },\r
33 { NULL , NULL }\r
34};\r
35\r
36EFI_STATUS\r
37EFIAPI\r
38ScsiDiskComponentNameGetDriverName (\r
39 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
40 IN CHAR8 *Language,\r
41 OUT CHAR16 **DriverName\r
42 )\r
43/*++\r
44\r
45 Routine Description:\r
46 Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
47\r
48 Arguments:\r
49 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
50 Language - A pointer to a three character ISO 639-2 language identifier.\r
51 This is the language of the driver name that that the caller \r
52 is requesting, and it must match one of the languages specified\r
53 in SupportedLanguages. The number of languages supported by a \r
54 driver is up to the driver writer.\r
55 DriverName - A pointer to the Unicode string to return. This Unicode string\r
56 is the name of the driver specified by This in the language \r
57 specified by Language.\r
58\r
59 Returns:\r
60 EFI_SUCCESS - The Unicode string for the Driver specified by This\r
61 and the language specified by Language was returned \r
62 in DriverName.\r
63 EFI_INVALID_PARAMETER - Language is NULL.\r
64 EFI_INVALID_PARAMETER - DriverName is NULL.\r
65 EFI_UNSUPPORTED - The driver specified by This does not support the \r
66 language specified by Language.\r
67\r
68--*/\r
69{\r
70 return LookupUnicodeString (\r
71 Language,\r
72 gScsiDiskComponentName.SupportedLanguages,\r
73 mScsiDiskDriverNameTable,\r
74 DriverName\r
75 );\r
76}\r
77\r
78EFI_STATUS\r
79EFIAPI\r
80ScsiDiskComponentNameGetControllerName (\r
81 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
82 IN EFI_HANDLE ControllerHandle,\r
83 IN EFI_HANDLE ChildHandle OPTIONAL,\r
84 IN CHAR8 *Language,\r
85 OUT CHAR16 **ControllerName\r
86 )\r
87/*++\r
88\r
89 Routine Description:\r
90 Retrieves a Unicode string that is the user readable name of the controller\r
91 that is being managed by an EFI Driver.\r
92\r
93 Arguments:\r
94 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
95 ControllerHandle - The handle of a controller that the driver specified by \r
96 This is managing. This handle specifies the controller \r
97 whose name is to be returned.\r
98 ChildHandle - The handle of the child controller to retrieve the name \r
99 of. This is an optional parameter that may be NULL. It \r
100 will be NULL for device drivers. It will also be NULL \r
101 for a bus drivers that wish to retrieve the name of the \r
102 bus controller. It will not be NULL for a bus driver \r
103 that wishes to retrieve the name of a child controller.\r
104 Language - A pointer to a three character ISO 639-2 language \r
105 identifier. This is the language of the controller name \r
106 that that the caller is requesting, and it must match one\r
107 of the languages specified in SupportedLanguages. The \r
108 number of languages supported by a driver is up to the \r
109 driver writer.\r
110 ControllerName - A pointer to the Unicode string to return. This Unicode\r
111 string is the name of the controller specified by \r
112 ControllerHandle and ChildHandle in the language \r
113 specified by Language from the point of view of the \r
114 driver specified by This. \r
115\r
116 Returns:\r
117 EFI_SUCCESS - The Unicode string for the user readable name in the\r
118 language specified by Language for the driver \r
119 specified by This was returned in DriverName.\r
120 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
121 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
122 EFI_HANDLE.\r
123 EFI_INVALID_PARAMETER - Language is NULL.\r
124 EFI_INVALID_PARAMETER - ControllerName is NULL.\r
125 EFI_UNSUPPORTED - The driver specified by This is not currently \r
126 managing the controller specified by \r
127 ControllerHandle and ChildHandle.\r
128 EFI_UNSUPPORTED - The driver specified by This does not support the \r
129 language specified by Language.\r
130\r
131--*/\r
132{\r
133 EFI_STATUS Status;\r
134 SCSI_DISK_DEV *ScsiDiskDevice;\r
135 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
136\r
137 //\r
138 // This is a device driver, so ChildHandle must be NULL.\r
139 //\r
140 if (ChildHandle != NULL) {\r
141 return EFI_UNSUPPORTED;\r
142 }\r
143 \r
61fb1657 144 //\r
145 // Make sure this driver is currently managing ControllerHandle\r
146 //\r
147 Status = EfiTestManagedDevice (\r
148 ControllerHandle,\r
149 gScsiDiskDriverBinding.DriverBindingHandle,\r
150 &gEfiScsiIoProtocolGuid\r
151 );\r
152 if (EFI_ERROR (Status)) {\r
153 return Status;\r
154 }\r
878ddf1f 155 //\r
156 // Get the device context\r
157 //\r
158 Status = gBS->OpenProtocol (\r
159 ControllerHandle,\r
160 &gEfiBlockIoProtocolGuid,\r
161 (VOID **) &BlockIo,\r
162 gScsiDiskDriverBinding.DriverBindingHandle,\r
163 ControllerHandle,\r
164 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
165 );\r
166\r
167 if (EFI_ERROR (Status)) {\r
168 return Status;\r
169 }\r
170\r
171 ScsiDiskDevice = SCSI_DISK_DEV_FROM_THIS (BlockIo);\r
172\r
173 return LookupUnicodeString (\r
174 Language,\r
175 gScsiDiskComponentName.SupportedLanguages,\r
176 ScsiDiskDevice->ControllerNameTable,\r
177 ControllerName\r
178 );\r
179\r
180}\r