TianoCore EDK2 master
Loading...
Searching...
No Matches
IdeController.c
Go to the documentation of this file.
1
11#include "IdeController.h"
12
20 0xa,
21 NULL,
22 NULL
23};
24
35 ICH_IDE_ENUMER_ALL,
37};
38
43 {
44 TRUE,
45 0
46 },
47 {
48 TRUE,
49 0
50 },
51 {
52 FALSE,
53 0
54 },
55 {
56 TRUE,
57 0
58 }
59};
60
74EFIAPI
76 IN EFI_HANDLE ImageHandle,
77 IN EFI_SYSTEM_TABLE *SystemTable
78 )
79{
80 EFI_STATUS Status;
81
82 //
83 // Install driver model protocol(s).
84 //
86 ImageHandle,
87 SystemTable,
89 ImageHandle,
92 );
93 ASSERT_EFI_ERROR (Status);
94
95 return Status;
96}
97
110EFIAPI
113 IN EFI_HANDLE Controller,
114 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
115 )
116{
117 EFI_STATUS Status;
118 EFI_PCI_IO_PROTOCOL *PciIo;
119 UINT8 PciClass;
120 UINT8 PciSubClass;
121
122 //
123 // Attempt to Open PCI I/O Protocol
124 //
125 Status = gBS->OpenProtocol (
126 Controller,
127 &gEfiPciIoProtocolGuid,
128 (VOID **)&PciIo,
129 This->DriverBindingHandle,
130 Controller,
131 EFI_OPEN_PROTOCOL_BY_DRIVER
132 );
133 if (EFI_ERROR (Status)) {
134 return Status;
135 }
136
137 //
138 // Now further check the PCI header: Base class (offset 0x0B) and
139 // Sub Class (offset 0x0A). This controller should be an Ide controller
140 //
141 Status = PciIo->Pci.Read (
142 PciIo,
143 EfiPciIoWidthUint8,
144 PCI_CLASSCODE_OFFSET + 2,
145 1,
146 &PciClass
147 );
148 if (EFI_ERROR (Status)) {
149 goto Done;
150 }
151
152 Status = PciIo->Pci.Read (
153 PciIo,
154 EfiPciIoWidthUint8,
155 PCI_CLASSCODE_OFFSET + 1,
156 1,
157 &PciSubClass
158 );
159 if (EFI_ERROR (Status)) {
160 goto Done;
161 }
162
163 //
164 // Examine Ide PCI Configuration table fields
165 //
166 if ((PciClass != PCI_CLASS_MASS_STORAGE) || (PciSubClass != PCI_CLASS_MASS_STORAGE_IDE)) {
167 Status = EFI_UNSUPPORTED;
168 }
169
170Done:
171 gBS->CloseProtocol (
172 Controller,
173 &gEfiPciIoProtocolGuid,
174 This->DriverBindingHandle,
175 Controller
176 );
177
178 return Status;
179}
180
195EFIAPI
198 IN EFI_HANDLE Controller,
199 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
200 )
201{
202 EFI_STATUS Status;
203 EFI_PCI_IO_PROTOCOL *PciIo;
204
205 //
206 // Now test and open the EfiPciIoProtocol
207 //
208 Status = gBS->OpenProtocol (
209 Controller,
210 &gEfiPciIoProtocolGuid,
211 (VOID **)&PciIo,
212 This->DriverBindingHandle,
213 Controller,
214 EFI_OPEN_PROTOCOL_BY_DRIVER
215 );
216 //
217 // Status == EFI_SUCCESS - A normal execution flow, SUCCESS and the program proceeds.
218 // Status == ALREADY_STARTED - A non-zero Status code returned. It indicates
219 // that the protocol has been opened and should be treated as a
220 // normal condition and the program proceeds. The Protocol will not
221 // opened 'again' by this call.
222 // Status != ALREADY_STARTED - Error status, terminate program execution
223 //
224 if (EFI_ERROR (Status)) {
225 return Status;
226 }
227
228 //
229 // Install IDE_CONTROLLER_INIT protocol
230 //
231 return gBS->InstallMultipleProtocolInterfaces (
232 &Controller,
233 &gEfiIdeControllerInitProtocolGuid,
235 NULL
236 );
237}
238
251EFIAPI
254 IN EFI_HANDLE Controller,
255 IN UINTN NumberOfChildren,
256 IN EFI_HANDLE *ChildHandleBuffer
257 )
258{
259 EFI_STATUS Status;
260 EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;
261
262 //
263 // Open the produced protocol
264 //
265 Status = gBS->OpenProtocol (
266 Controller,
267 &gEfiIdeControllerInitProtocolGuid,
268 (VOID **)&IdeControllerInit,
269 This->DriverBindingHandle,
270 Controller,
271 EFI_OPEN_PROTOCOL_GET_PROTOCOL
272 );
273 if (EFI_ERROR (Status)) {
274 return EFI_UNSUPPORTED;
275 }
276
277 //
278 // Make sure the protocol was produced by this driver
279 //
280 if (IdeControllerInit != &gEfiIdeControllerInit) {
281 return EFI_UNSUPPORTED;
282 }
283
284 //
285 // Uninstall the IDE Controller Init Protocol
286 //
287 Status = gBS->UninstallMultipleProtocolInterfaces (
288 Controller,
289 &gEfiIdeControllerInitProtocolGuid,
291 NULL
292 );
293 if (EFI_ERROR (Status)) {
294 return Status;
295 }
296
297 //
298 // Close protocols opened by Ide controller driver
299 //
300 return gBS->CloseProtocol (
301 Controller,
302 &gEfiPciIoProtocolGuid,
303 This->DriverBindingHandle,
304 Controller
305 );
306}
307
308//
309// Interface functions of IDE_CONTROLLER_INIT protocol
310//
311
349EFIAPI
352 IN UINT8 Channel,
353 OUT BOOLEAN *Enabled,
354 OUT UINT8 *MaxDevices
355 )
356{
357 //
358 // Channel number (0 based, either 0 or 1)
359 //
360 if (Channel < ICH_IDE_MAX_CHANNEL) {
361 *Enabled = TRUE;
362 *MaxDevices = ICH_IDE_MAX_DEVICES;
363 return EFI_SUCCESS;
364 }
365
366 *Enabled = FALSE;
367 return EFI_INVALID_PARAMETER;
368}
369
395EFIAPI
399 IN UINT8 Channel
400 )
401{
402 return EFI_SUCCESS;
403}
404
445EFIAPI
448 IN UINT8 Channel,
449 IN UINT8 Device,
450 IN EFI_IDENTIFY_DATA *IdentifyData
451 )
452{
453 return EFI_SUCCESS;
454}
455
497EFIAPI
500 IN UINT8 Channel,
501 IN UINT8 Device,
503 )
504{
505 return EFI_SUCCESS;
506}
507
563EFIAPI
566 IN UINT8 Channel,
567 IN UINT8 Device,
568 OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes
569 )
570{
571 if ((Channel >= ICH_IDE_MAX_CHANNEL) || (Device >= ICH_IDE_MAX_DEVICES)) {
572 return EFI_INVALID_PARAMETER;
573 }
574
576 if (*SupportedModes == NULL) {
577 return EFI_OUT_OF_RESOURCES;
578 }
579
580 return EFI_SUCCESS;
581}
582
607EFIAPI
610 IN UINT8 Channel,
611 IN UINT8 Device,
613 )
614{
615 return EFI_SUCCESS;
616}
UINT64 UINTN
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS EFIAPI InitializeIdeControllerDriver(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: IdeController.c:75
EFI_STATUS EFIAPI IdeInitNotifyPhase(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase, IN UINT8 Channel)
EFI_STATUS EFIAPI IdeControllerSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_IDE_CONTROLLER_INIT_PROTOCOL gEfiIdeControllerInit
Definition: IdeController.c:28
EFI_ATA_COLLECTIVE_MODE gEfiAtaCollectiveModeTemplate
Definition: IdeController.c:42
EFI_STATUS EFIAPI IdeInitSubmitData(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, IN UINT8 Device, IN EFI_IDENTIFY_DATA *IdentifyData)
EFI_STATUS EFIAPI IdeInitSetTiming(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, IN UINT8 Device, IN EFI_ATA_COLLECTIVE_MODE *Modes)
EFI_STATUS EFIAPI IdeControllerStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_DRIVER_BINDING_PROTOCOL gIdeControllerDriverBinding
Definition: IdeController.c:16
EFI_STATUS EFIAPI IdeControllerStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI IdeInitGetChannelInfo(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, OUT BOOLEAN *Enabled, OUT UINT8 *MaxDevices)
EFI_STATUS EFIAPI IdeInitDisqualifyMode(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, IN UINT8 Device, IN EFI_ATA_COLLECTIVE_MODE *BadModes)
EFI_STATUS EFIAPI IdeInitCalculateMode(IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This, IN UINT8 Channel, IN UINT8 Device, OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes)
#define ICH_IDE_MAX_DEVICES
Definition: IdeController.h:41
#define ICH_IDE_MAX_CHANNEL
Definition: IdeController.h:36
EFI_IDE_CONTROLLER_ENUM_PHASE
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerComponentName2
Definition: ComponentName.c:24
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIdeControllerComponentName
Definition: ComponentName.c:15
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_PCI_IO_PROTOCOL_CONFIG Read
Definition: PciIo.h:232