]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.h
IntelFrameworkModulePkg IdeBusDxe: Remove redundant functions
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / IdeBusDxe / IdeBus.h
1 /** @file
2 Header file for IDE Bus Driver.
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _IDE_BUS_H_
16 #define _IDE_BUS_H_
17
18
19
20 #include <FrameworkDxe.h>
21
22 #include <Protocol/IdeControllerInit.h>
23 #include <Protocol/BlockIo.h>
24 #include <Protocol/PciIo.h>
25 #include <Protocol/DiskInfo.h>
26 #include <Protocol/DevicePath.h>
27
28 #include <Library/DebugLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/BaseLib.h>
31 #include <Library/UefiLib.h>
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/ReportStatusCodeLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/PerformanceLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UefiRuntimeServicesTableLib.h>
38 #include <Library/DevicePathLib.h>
39
40 #include <Guid/EventGroup.h>
41
42 #include <IndustryStandard/Pci.h>
43 #include "IdeData.h"
44
45 //
46 // Global Variables
47 //
48 extern EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding;
49 extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gIDEBusDriverDiagnostics;
50 extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2;
51
52 //
53 // Extra Definition to porting
54 //
55 #define MAX_IDE_DEVICE 4
56 #define MAX_IDE_CHANNELS 2
57 #define MAX_IDE_DRIVES 2
58
59 #define INVALID_DEVICE_TYPE 0xff
60 #define ATA_DEVICE_TYPE 0x00
61 #define ATAPI_DEVICE_TYPE 0x01
62
63 typedef struct {
64 BOOLEAN HaveScannedDevice[MAX_IDE_DEVICE];
65 BOOLEAN DeviceFound[MAX_IDE_DEVICE];
66 BOOLEAN DeviceProcessed[MAX_IDE_DEVICE];
67 } IDE_BUS_DRIVER_PRIVATE_DATA;
68
69 #define IDE_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('i', 'b', 'i', 'd')
70
71 typedef struct {
72 UINT32 Signature;
73
74 EFI_HANDLE Handle;
75 EFI_BLOCK_IO_PROTOCOL BlkIo;
76 EFI_BLOCK_IO_MEDIA BlkMedia;
77 EFI_DISK_INFO_PROTOCOL DiskInfo;
78 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
79 EFI_PCI_IO_PROTOCOL *PciIo;
80 IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
81
82 //
83 // Local Data for IDE interface goes here
84 //
85 EFI_IDE_CHANNEL Channel;
86 EFI_IDE_DEVICE Device;
87 UINT16 Lun;
88 IDE_DEVICE_TYPE Type;
89
90 IDE_BASE_REGISTERS *IoPort;
91 UINT16 AtapiError;
92
93 ATAPI_INQUIRY_DATA *InquiryData;
94 EFI_IDENTIFY_DATA *IdData;
95 ATA_PIO_MODE PioMode;
96 EFI_ATA_MODE UdmaMode;
97 CHAR8 ModelName[41];
98 ATAPI_REQUEST_SENSE_DATA *SenseData;
99 UINT8 SenseDataNumber;
100 UINT8 *Cache;
101
102 //
103 // ExitBootService Event, it is used to clear pending IDE interrupt
104 //
105 EFI_EVENT ExitBootServiceEvent;
106
107 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
108 } IDE_BLK_IO_DEV;
109
110 #include "ComponentName.h"
111
112 #define IDE_BLOCK_IO_DEV_FROM_THIS(a) CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)
113 #define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)
114
115 #include "Ide.h"
116
117
118 /**
119 Supported function of Driver Binding protocol for this driver.
120
121 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
122 @param ControllerHandle The handle of the controller to test.
123 @param RemainingDevicePath A pointer to the remaining portion of a device path.
124
125 @retval EFI_SUCCESS Driver loaded.
126 @retval other Driver not loaded.
127
128 **/
129 EFI_STATUS
130 EFIAPI
131 IDEBusDriverBindingSupported (
132 IN EFI_DRIVER_BINDING_PROTOCOL *This,
133 IN EFI_HANDLE Controller,
134 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
135 );
136
137 /**
138 Start function of Driver binding protocol which start this driver on Controller
139 by detecting all disks and installing BlockIo protocol on them.
140
141 @param This Protocol instance pointer.
142 @param Controller Handle of device to bind driver to.
143 @param RemainingDevicePath produce all possible children.
144
145 @retval EFI_SUCCESS This driver is added to ControllerHandle.
146 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
147 @retval other This driver does not support this device.
148
149 **/
150 EFI_STATUS
151 EFIAPI
152 IDEBusDriverBindingStart (
153 IN EFI_DRIVER_BINDING_PROTOCOL *This,
154 IN EFI_HANDLE Controller,
155 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
156 );
157
158 /**
159 Stop function of Driver Binding Protocol which is to stop the driver on Controller Handle and all
160 child handle attached to the controller handle if there are.
161
162 @param This Protocol instance pointer.
163 @param Controller Handle of device to stop driver on
164 @param NumberOfChildren Not used
165 @param ChildHandleBuffer Not used
166
167 @retval EFI_SUCCESS This driver is removed DeviceHandle
168 @retval other This driver was not removed from this device
169
170 **/
171 EFI_STATUS
172 EFIAPI
173 IDEBusDriverBindingStop (
174 IN EFI_DRIVER_BINDING_PROTOCOL *This,
175 IN EFI_HANDLE Controller,
176 IN UINTN NumberOfChildren,
177 IN EFI_HANDLE *ChildHandleBuffer
178 );
179
180 //
181 // EFI Driver Configuration Functions
182 //
183
184
185
186
187 //
188 // EFI Driver Diagnostics Functions
189 //
190 /**
191 Runs diagnostics on a controller.
192
193 @param This A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOLinstance.
194 @param ControllerHandle The handle of the controller to run diagnostics on.
195 @param ChildHandle The handle of the child controller to run diagnostics on
196 This is an optional parameter that may be NULL. It will
197 be NULL for device drivers. It will also be NULL for a
198 bus drivers that wish to run diagnostics on the bus controller.
199 It will not be NULL for a bus driver that wishes to run
200 diagnostics on one of its child controllers.
201 @param DiagnosticType Indicates type of diagnostics to perform on the controller
202 specified by ControllerHandle and ChildHandle.
203 @param Language A pointer to a three character ISO 639-2 language identifier.
204 This is the language in which the optional error message should
205 be returned in Buffer, and it must match one of the languages
206 specified in SupportedLanguages. The number of languages supported by
207 a driver is up to the driver writer.
208 @param ErrorType A GUID that defines the format of the data returned in Buffer.
209 @param BufferSize The size, in bytes, of the data returned in Buffer.
210 @param Buffer A buffer that contains a Null-terminated Unicode string
211 plus some additional data whose format is defined by ErrorType.
212 Buffer is allocated by this function with AllocatePool(), and
213 it is the caller's responsibility to free it with a call to FreePool().
214
215 @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle passed
216 the diagnostic.
217 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
218 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
219 @retval EFI_INVALID_PARAMETER Language is NULL.
220 @retval EFI_INVALID_PARAMETER ErrorType is NULL.
221 @retval EFI_INVALID_PARAMETER BufferType is NULL.
222 @retval EFI_INVALID_PARAMETER Buffer is NULL.
223 @retval EFI_UNSUPPORTED The driver specified by This does not support running
224 diagnostics for the controller specified by ControllerHandle
225 and ChildHandle.
226 @retval EFI_UNSUPPORTED The driver specified by This does not support the
227 type of diagnostic specified by DiagnosticType.
228 @retval EFI_UNSUPPORTED The driver specified by This does not support the language
229 specified by Language.
230 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to complete the
231 diagnostics.
232 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to return the
233 status information in ErrorType, BufferSize,and Buffer.
234 @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle
235 did not pass the diagnostic.
236 **/
237 EFI_STATUS
238 EFIAPI
239 IDEBusDriverDiagnosticsRunDiagnostics (
240 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
241 IN EFI_HANDLE ControllerHandle,
242 IN EFI_HANDLE ChildHandle OPTIONAL,
243 IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
244 IN CHAR8 *Language,
245 OUT EFI_GUID **ErrorType,
246 OUT UINTN *BufferSize,
247 OUT CHAR16 **Buffer
248 );
249
250 /**
251 issue ATA or ATAPI command to reset a block IO device.
252 @param This Block IO protocol instance pointer.
253 @param ExtendedVerification If FALSE,for ATAPI device, driver will only invoke ATAPI reset method
254 If TRUE, for ATAPI device, driver need invoke ATA reset method after
255 invoke ATAPI reset method
256
257 @retval EFI_DEVICE_ERROR When the device is neighther ATA device or ATAPI device.
258 @retval EFI_SUCCESS The device reset successfully
259
260 **/
261 EFI_STATUS
262 EFIAPI
263 IDEBlkIoReset (
264 IN EFI_BLOCK_IO_PROTOCOL *This,
265 IN BOOLEAN ExtendedVerification
266 );
267
268 /**
269 Read data from a block IO device.
270
271 @param This Block IO protocol instance pointer.
272 @param MediaId The media ID of the device
273 @param Lba Starting LBA address to read data
274 @param BufferSize The size of data to be read
275 @param Buffer Caller supplied buffer to save data
276
277 @retval EFI_DEVICE_ERROR unknown device type
278 @retval EFI_SUCCESS read the data successfully.
279
280 **/
281 EFI_STATUS
282 EFIAPI
283 IDEBlkIoReadBlocks (
284 IN EFI_BLOCK_IO_PROTOCOL *This,
285 IN UINT32 MediaId,
286 IN EFI_LBA Lba,
287 IN UINTN BufferSize,
288 OUT VOID *Buffer
289 );
290
291 /**
292 Write data to block io device
293
294 @param This Protocol instance pointer.
295 @param MediaId The media ID of the device
296 @param Lba Starting LBA address to write data
297 @param BufferSize The size of data to be written
298 @param Buffer Caller supplied buffer to save data
299
300 @retval EFI_DEVICE_ERROR unknown device type
301 @retval other write data status
302
303 **/
304 EFI_STATUS
305 EFIAPI
306 IDEBlkIoWriteBlocks (
307 IN EFI_BLOCK_IO_PROTOCOL *This,
308 IN UINT32 MediaId,
309 IN EFI_LBA Lba,
310 IN UINTN BufferSize,
311 IN VOID *Buffer
312 );
313
314 /**
315 Flushes all modified data to a physical block devices
316
317 @param This Indicates a pointer to the calling context which to sepcify a
318 sepcific block device
319
320 @retval EFI_SUCCESS Always return success.
321 **/
322 EFI_STATUS
323 EFIAPI
324 IDEBlkIoFlushBlocks (
325 IN EFI_BLOCK_IO_PROTOCOL *This
326 );
327 /**
328 This function is used by the IDE bus driver to get inquiry data.
329 Data format of Identify data is defined by the Interface GUID.
330
331 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
332 @param InquiryData Pointer to a buffer for the inquiry data.
333 @param InquiryDataSize Pointer to the value for the inquiry data size.
334
335 @retval EFI_SUCCESS The command was accepted without any errors.
336 @retval EFI_NOT_FOUND Device does not support this data class
337 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
338 @retval EFI_BUFFER_TOO_SMALL IntquiryDataSize not big enough
339
340 **/
341 EFI_STATUS
342 EFIAPI
343 IDEDiskInfoInquiry (
344 IN EFI_DISK_INFO_PROTOCOL *This,
345 IN OUT VOID *InquiryData,
346 IN OUT UINT32 *InquiryDataSize
347 );
348
349 /**
350 This function is used by the IDE bus driver to get identify data.
351 Data format of Identify data is defined by the Interface GUID.
352
353 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
354 @param IdentifyData Pointer to a buffer for the identify data.
355 @param IdentifyDataSize Pointer to the value for the identify data size.
356
357 @retval EFI_SUCCESS The command was accepted without any errors.
358 @retval EFI_NOT_FOUND Device does not support this data class
359 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
360 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
361
362 **/
363 EFI_STATUS
364 EFIAPI
365 IDEDiskInfoIdentify (
366 IN EFI_DISK_INFO_PROTOCOL *This,
367 IN OUT VOID *IdentifyData,
368 IN OUT UINT32 *IdentifyDataSize
369 );
370
371 /**
372 This function is used by the IDE bus driver to get sense data.
373 Data format of Sense data is defined by the Interface GUID.
374
375 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
376 @param SenseData Pointer to the SenseData.
377 @param SenseDataSize Size of SenseData in bytes.
378 @param SenseDataNumber Pointer to the value for the identify data size.
379
380 @retval EFI_SUCCESS The command was accepted without any errors.
381 @retval EFI_NOT_FOUND Device does not support this data class
382 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
383 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough
384
385 **/
386 EFI_STATUS
387 EFIAPI
388 IDEDiskInfoSenseData (
389 IN EFI_DISK_INFO_PROTOCOL *This,
390 IN OUT VOID *SenseData,
391 IN OUT UINT32 *SenseDataSize,
392 OUT UINT8 *SenseDataNumber
393 );
394
395 /**
396 This function is used by the IDE bus driver to get controller information.
397
398 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
399 @param IdeChannel Pointer to the Ide Channel number. Primary or secondary.
400 @param IdeDevice Pointer to the Ide Device number. Master or slave.
401
402 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid
403 @retval EFI_UNSUPPORTED This is not an IDE device
404
405 **/
406 EFI_STATUS
407 EFIAPI
408 IDEDiskInfoWhichIde (
409 IN EFI_DISK_INFO_PROTOCOL *This,
410 OUT UINT32 *IdeChannel,
411 OUT UINT32 *IdeDevice
412 );
413 /**
414 The is an event(generally the event is exitBootService event) call back function.
415 Clear pending IDE interrupt before OS loader/kernel take control of the IDE device.
416
417 @param Event Pointer to this event
418 @param Context Event handler private data
419
420 **/
421 VOID
422 EFIAPI
423 ClearInterrupt (
424 IN EFI_EVENT Event,
425 IN VOID *Context
426 );
427 #endif