]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/LsiScsiDxe/LsiScsi.c
62daa3ab99bf2cfdd2eb495b9423dc2dd28525a2
[mirror_edk2.git] / OvmfPkg / LsiScsiDxe / LsiScsi.c
1 /** @file
2
3 This driver produces Extended SCSI Pass Thru Protocol instances for
4 LSI 53C895A SCSI devices.
5
6 Copyright (C) 2020, SUSE LLC.
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #include <Library/UefiLib.h>
13 #include <Uefi/UefiSpec.h>
14
15 #include "LsiScsi.h"
16
17 //
18 // Probe, start and stop functions of this driver, called by the DXE core for
19 // specific devices.
20 //
21 // The following specifications document these interfaces:
22 // - Driver Writer's Guide for UEFI 2.3.1 v1.01, 9 Driver Binding Protocol
23 // - UEFI Spec 2.3.1 + Errata C, 10.1 EFI Driver Binding Protocol
24 //
25
26 EFI_STATUS
27 EFIAPI
28 LsiScsiControllerSupported (
29 IN EFI_DRIVER_BINDING_PROTOCOL *This,
30 IN EFI_HANDLE ControllerHandle,
31 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
32 )
33 {
34 return EFI_UNSUPPORTED;
35 }
36
37 EFI_STATUS
38 EFIAPI
39 LsiScsiControllerStart (
40 IN EFI_DRIVER_BINDING_PROTOCOL *This,
41 IN EFI_HANDLE ControllerHandle,
42 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
43 )
44 {
45 return EFI_SUCCESS;
46 }
47
48 EFI_STATUS
49 EFIAPI
50 LsiScsiControllerStop (
51 IN EFI_DRIVER_BINDING_PROTOCOL *This,
52 IN EFI_HANDLE ControllerHandle,
53 IN UINTN NumberOfChildren,
54 IN EFI_HANDLE *ChildHandleBuffer
55 )
56 {
57 return EFI_SUCCESS;
58 }
59
60 //
61 // The static object that groups the Supported() (ie. probe), Start() and
62 // Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata
63 // C, 10.1 EFI Driver Binding Protocol.
64 //
65 STATIC
66 EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {
67 &LsiScsiControllerSupported,
68 &LsiScsiControllerStart,
69 &LsiScsiControllerStop,
70 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers
71 NULL, // ImageHandle, to be overwritten by
72 // EfiLibInstallDriverBindingComponentName2() in LsiScsiEntryPoint()
73 NULL // DriverBindingHandle, ditto
74 };
75
76
77 //
78 // The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and
79 // EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name
80 // in English, for display on standard console devices. This is recommended for
81 // UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's
82 // Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.
83 //
84 // Device type names ("LSI 53C895A SCSI Controller") are not formatted because
85 // the driver supports only that device type. Therefore the driver name
86 // suffices for unambiguous identification.
87 //
88
89 STATIC
90 EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {
91 { "eng;en", L"LSI 53C895A SCSI Controller Driver" },
92 { NULL, NULL }
93 };
94
95 STATIC
96 EFI_COMPONENT_NAME_PROTOCOL gComponentName;
97
98 EFI_STATUS
99 EFIAPI
100 LsiScsiGetDriverName (
101 IN EFI_COMPONENT_NAME_PROTOCOL *This,
102 IN CHAR8 *Language,
103 OUT CHAR16 **DriverName
104 )
105 {
106 return LookupUnicodeString2 (
107 Language,
108 This->SupportedLanguages,
109 mDriverNameTable,
110 DriverName,
111 (BOOLEAN)(This == &gComponentName) // Iso639Language
112 );
113 }
114
115 EFI_STATUS
116 EFIAPI
117 LsiScsiGetDeviceName (
118 IN EFI_COMPONENT_NAME_PROTOCOL *This,
119 IN EFI_HANDLE DeviceHandle,
120 IN EFI_HANDLE ChildHandle,
121 IN CHAR8 *Language,
122 OUT CHAR16 **ControllerName
123 )
124 {
125 return EFI_UNSUPPORTED;
126 }
127
128 STATIC
129 EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
130 &LsiScsiGetDriverName,
131 &LsiScsiGetDeviceName,
132 "eng" // SupportedLanguages, ISO 639-2 language codes
133 };
134
135 STATIC
136 EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
137 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &LsiScsiGetDriverName,
138 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &LsiScsiGetDeviceName,
139 "en" // SupportedLanguages, RFC 4646 language codes
140 };
141
142 //
143 // Entry point of this driver
144 //
145 EFI_STATUS
146 EFIAPI
147 LsiScsiEntryPoint (
148 IN EFI_HANDLE ImageHandle,
149 IN EFI_SYSTEM_TABLE *SystemTable
150 )
151 {
152 return EfiLibInstallDriverBindingComponentName2 (
153 ImageHandle,
154 SystemTable,
155 &gDriverBinding,
156 ImageHandle, // The handle to install onto
157 &gComponentName,
158 &gComponentName2
159 );
160 }