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