3 This driver produces Extended SCSI Pass Thru Protocol instances for
4 LSI 53C895A SCSI devices.
6 Copyright (C) 2020, SUSE LLC.
8 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <IndustryStandard/LsiScsi.h>
13 #include <IndustryStandard/Pci.h>
14 #include <Library/UefiBootServicesTableLib.h>
15 #include <Library/UefiLib.h>
16 #include <Protocol/PciIo.h>
17 #include <Protocol/PciRootBridgeIo.h>
18 #include <Uefi/UefiSpec.h>
23 // Probe, start and stop functions of this driver, called by the DXE core for
26 // The following specifications document these interfaces:
27 // - Driver Writer's Guide for UEFI 2.3.1 v1.01, 9 Driver Binding Protocol
28 // - UEFI Spec 2.3.1 + Errata C, 10.1 EFI Driver Binding Protocol
33 LsiScsiControllerSupported (
34 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
35 IN EFI_HANDLE ControllerHandle
,
36 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
40 EFI_PCI_IO_PROTOCOL
*PciIo
;
43 Status
= gBS
->OpenProtocol (
45 &gEfiPciIoProtocolGuid
,
47 This
->DriverBindingHandle
,
49 EFI_OPEN_PROTOCOL_BY_DRIVER
51 if (EFI_ERROR (Status
)) {
55 Status
= PciIo
->Pci
.Read (
59 sizeof (Pci
) / sizeof (UINT32
),
62 if (EFI_ERROR (Status
)) {
66 if (Pci
.Hdr
.VendorId
== LSI_LOGIC_PCI_VENDOR_ID
&&
67 Pci
.Hdr
.DeviceId
== LSI_53C895A_PCI_DEVICE_ID
) {
70 Status
= EFI_UNSUPPORTED
;
76 &gEfiPciIoProtocolGuid
,
77 This
->DriverBindingHandle
,
85 LsiScsiControllerStart (
86 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
87 IN EFI_HANDLE ControllerHandle
,
88 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
96 LsiScsiControllerStop (
97 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
98 IN EFI_HANDLE ControllerHandle
,
99 IN UINTN NumberOfChildren
,
100 IN EFI_HANDLE
*ChildHandleBuffer
107 // The static object that groups the Supported() (ie. probe), Start() and
108 // Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata
109 // C, 10.1 EFI Driver Binding Protocol.
112 EFI_DRIVER_BINDING_PROTOCOL gDriverBinding
= {
113 &LsiScsiControllerSupported
,
114 &LsiScsiControllerStart
,
115 &LsiScsiControllerStop
,
116 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers
117 NULL
, // ImageHandle, to be overwritten by
118 // EfiLibInstallDriverBindingComponentName2() in LsiScsiEntryPoint()
119 NULL
// DriverBindingHandle, ditto
124 // The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
125 // EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
126 // in English, for display on standard console devices. This is recommended for
127 // UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
128 // Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
130 // Device type names ("LSI 53C895A SCSI Controller") are not formatted because
131 // the driver supports only that device type. Therefore the driver name
132 // suffices for unambiguous identification.
136 EFI_UNICODE_STRING_TABLE mDriverNameTable
[] = {
137 { "eng;en", L
"LSI 53C895A SCSI Controller Driver" },
142 EFI_COMPONENT_NAME_PROTOCOL gComponentName
;
146 LsiScsiGetDriverName (
147 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
149 OUT CHAR16
**DriverName
152 return LookupUnicodeString2 (
154 This
->SupportedLanguages
,
157 (BOOLEAN
)(This
== &gComponentName
) // Iso639Language
163 LsiScsiGetDeviceName (
164 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
165 IN EFI_HANDLE DeviceHandle
,
166 IN EFI_HANDLE ChildHandle
,
168 OUT CHAR16
**ControllerName
171 return EFI_UNSUPPORTED
;
175 EFI_COMPONENT_NAME_PROTOCOL gComponentName
= {
176 &LsiScsiGetDriverName
,
177 &LsiScsiGetDeviceName
,
178 "eng" // SupportedLanguages, ISO 639-2 language codes
182 EFI_COMPONENT_NAME2_PROTOCOL gComponentName2
= {
183 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME
) &LsiScsiGetDriverName
,
184 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME
) &LsiScsiGetDeviceName
,
185 "en" // SupportedLanguages, RFC 4646 language codes
189 // Entry point of this driver
194 IN EFI_HANDLE ImageHandle
,
195 IN EFI_SYSTEM_TABLE
*SystemTable
198 return EfiLibInstallDriverBindingComponentName2 (
202 ImageHandle
, // The handle to install onto