]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c
remove some comments introduced by tools.
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ComponentName.c
1 /*++
2
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
8
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.
11
12 Module Name:
13
14 ComponentName.c
15
16 Abstract:
17
18 --*/
19
20
21 #include <PiDxe.h>
22
23
24 #include <Protocol/ScsiIo.h>
25 #include <Protocol/ComponentName.h>
26 #include <Protocol/BlockIo.h>
27 #include <Protocol/DriverBinding.h>
28
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>
35
36 #include "ScsiDisk.h"
37
38 //
39 // EFI Component Name Protocol
40 //
41 EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName = {
42 ScsiDiskComponentNameGetDriverName,
43 ScsiDiskComponentNameGetControllerName,
44 "eng"
45 };
46
47 static EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable[] = {
48 { "eng", (CHAR16 *) L"Scsi Disk Driver" },
49 { NULL , NULL }
50 };
51
52 EFI_STATUS
53 EFIAPI
54 ScsiDiskComponentNameGetDriverName (
55 IN EFI_COMPONENT_NAME_PROTOCOL *This,
56 IN CHAR8 *Language,
57 OUT CHAR16 **DriverName
58 )
59 /*++
60
61 Routine Description:
62 Retrieves a Unicode string that is the user readable name of the EFI Driver.
63
64 Arguments:
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.
74
75 Returns:
76 EFI_SUCCESS - The Unicode string for the Driver specified by This
77 and the language specified by Language was returned
78 in DriverName.
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.
83
84 --*/
85 {
86 return LookupUnicodeString (
87 Language,
88 gScsiDiskComponentName.SupportedLanguages,
89 mScsiDiskDriverNameTable,
90 DriverName
91 );
92 }
93
94 EFI_STATUS
95 EFIAPI
96 ScsiDiskComponentNameGetControllerName (
97 IN EFI_COMPONENT_NAME_PROTOCOL *This,
98 IN EFI_HANDLE ControllerHandle,
99 IN EFI_HANDLE ChildHandle OPTIONAL,
100 IN CHAR8 *Language,
101 OUT CHAR16 **ControllerName
102 )
103 /*++
104
105 Routine Description:
106 Retrieves a Unicode string that is the user readable name of the controller
107 that is being managed by an EFI Driver.
108
109 Arguments:
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
125 driver writer.
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.
131
132 Returns:
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
138 EFI_HANDLE.
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.
146
147 --*/
148 {
149 EFI_STATUS Status;
150 SCSI_DISK_DEV *ScsiDiskDevice;
151 EFI_BLOCK_IO_PROTOCOL *BlockIo;
152
153 //
154 // This is a device driver, so ChildHandle must be NULL.
155 //
156 if (ChildHandle != NULL) {
157 return EFI_UNSUPPORTED;
158 }
159
160 //
161 // Make sure this driver is currently managing ControllerHandle
162 //
163 Status = EfiTestManagedDevice (
164 ControllerHandle,
165 gScsiDiskDriverBinding.DriverBindingHandle,
166 &gEfiScsiIoProtocolGuid
167 );
168 if (EFI_ERROR (Status)) {
169 return Status;
170 }
171 //
172 // Get the device context
173 //
174 Status = gBS->OpenProtocol (
175 ControllerHandle,
176 &gEfiBlockIoProtocolGuid,
177 (VOID **) &BlockIo,
178 gScsiDiskDriverBinding.DriverBindingHandle,
179 ControllerHandle,
180 EFI_OPEN_PROTOCOL_GET_PROTOCOL
181 );
182
183 if (EFI_ERROR (Status)) {
184 return Status;
185 }
186
187 ScsiDiskDevice = SCSI_DISK_DEV_FROM_THIS (BlockIo);
188
189 return LookupUnicodeString (
190 Language,
191 gScsiDiskComponentName.SupportedLanguages,
192 ScsiDiskDevice->ControllerNameTable,
193 ControllerName
194 );
195
196 }