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