Porting R8's PI-enabled ScsiBus driver
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiBusDxe / 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 // The package level header files this module uses
22 //
23 #include <PiDxe.h>
24
25 //
26 // The protocols, PPI and GUID defintions for this module
27 //
28 #include <Protocol/ScsiPassThru.h>
29 #include <Protocol/ScsiPassThruExt.h>
30 #include <Protocol/ScsiIo.h>
31 #include <Protocol/ComponentName.h>
32 #include <Protocol/DriverBinding.h>
33 #include <Protocol/DevicePath.h>
34 //
35 // The Library classes this module consumes
36 //
37 #include <Library/DebugLib.h>
38 #include <Library/UefiDriverEntryPoint.h>
39 #include <Library/UefiLib.h>
40 #include <Library/BaseMemoryLib.h>
41 #include <Library/ScsiLib.h>
42 #include <Library/UefiBootServicesTableLib.h>
43 #include <Library/DevicePathLib.h>
44
45
46 #include "ScsiBus.h"
47
48 //
49 // EFI Component Name Protocol
50 //
51 EFI_COMPONENT_NAME_PROTOCOL gScsiBusComponentName = {
52 ScsiBusComponentNameGetDriverName,
53 ScsiBusComponentNameGetControllerName,
54 "eng"
55 };
56
57 static EFI_UNICODE_STRING_TABLE mScsiBusDriverNameTable[] = {
58 { "eng", (CHAR16 *) L"SCSI Bus Driver" },
59 { NULL , NULL }
60 };
61
62 EFI_STATUS
63 EFIAPI
64 ScsiBusComponentNameGetDriverName (
65 IN EFI_COMPONENT_NAME_PROTOCOL *This,
66 IN CHAR8 *Language,
67 OUT CHAR16 **DriverName
68 )
69 /*++
70
71 Routine Description:
72 Retrieves a Unicode string that is the user readable name of the EFI Driver.
73
74 Arguments:
75 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
76 Language - A pointer to a three character ISO 639-2 language identifier.
77 This is the language of the driver name that that the caller
78 is requesting, and it must match one of the languages specified
79 in SupportedLanguages. The number of languages supported by a
80 driver is up to the driver writer.
81 DriverName - A pointer to the Unicode string to return. This Unicode string
82 is the name of the driver specified by This in the language
83 specified by Language.
84
85 Returns:
86 EFI_SUCCESS - The Unicode string for the Driver specified by This
87 and the language specified by Language was returned
88 in DriverName.
89 EFI_INVALID_PARAMETER - Language is NULL.
90 EFI_INVALID_PARAMETER - DriverName is NULL.
91 EFI_UNSUPPORTED - The driver specified by This does not support the
92 language specified by Language.
93
94 --*/
95 {
96 return LookupUnicodeString (
97 Language,
98 gScsiBusComponentName.SupportedLanguages,
99 mScsiBusDriverNameTable,
100 DriverName
101 );
102 }
103
104 EFI_STATUS
105 EFIAPI
106 ScsiBusComponentNameGetControllerName (
107 IN EFI_COMPONENT_NAME_PROTOCOL *This,
108 IN EFI_HANDLE ControllerHandle,
109 IN EFI_HANDLE ChildHandle OPTIONAL,
110 IN CHAR8 *Language,
111 OUT CHAR16 **ControllerName
112 )
113 /*++
114
115 Routine Description:
116 Retrieves a Unicode string that is the user readable name of the controller
117 that is being managed by an EFI Driver.
118
119 Arguments:
120 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
121 ControllerHandle - The handle of a controller that the driver specified by
122 This is managing. This handle specifies the controller
123 whose name is to be returned.
124 ChildHandle - The handle of the child controller to retrieve the name
125 of. This is an optional parameter that may be NULL. It
126 will be NULL for device drivers. It will also be NULL
127 for a bus drivers that wish to retrieve the name of the
128 bus controller. It will not be NULL for a bus driver
129 that wishes to retrieve the name of a child controller.
130 Language - A pointer to a three character ISO 639-2 language
131 identifier. This is the language of the controller name
132 that that the caller is requesting, and it must match one
133 of the languages specified in SupportedLanguages. The
134 number of languages supported by a driver is up to the
135 driver writer.
136 ControllerName - A pointer to the Unicode string to return. This Unicode
137 string is the name of the controller specified by
138 ControllerHandle and ChildHandle in the language
139 specified by Language from the point of view of the
140 driver specified by This.
141
142 Returns:
143 EFI_SUCCESS - The Unicode string for the user readable name in the
144 language specified by Language for the driver
145 specified by This was returned in DriverName.
146 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
147 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
148 EFI_HANDLE.
149 EFI_INVALID_PARAMETER - Language is NULL.
150 EFI_INVALID_PARAMETER - ControllerName is NULL.
151 EFI_UNSUPPORTED - The driver specified by This is not currently
152 managing the controller specified by
153 ControllerHandle and ChildHandle.
154 EFI_UNSUPPORTED - The driver specified by This does not support the
155 language specified by Language.
156
157 --*/
158 {
159 return EFI_UNSUPPORTED;
160 }