]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
IntelFrameworkModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / IdeBusDxe / Ide.h
1 /** @file
2 Header file for IDE Bus Driver, containing the helper functions'
3 prototype.
4
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 @par Revision Reference:
9 2002-6: Add Atapi6 enhancement, support >120GB hard disk, including
10 Add - IDEBlkIoReadBlocksExt() func definition
11 Add - IDEBlkIoWriteBlocksExt() func definition
12
13 **/
14
15 #ifndef _IDE_H_
16 #define _IDE_H_
17
18 //
19 // Helper functions Prototype
20 //
21 /**
22 read a one-byte data from a IDE port.
23
24 @param PciIo The PCI IO protocol instance
25 @param Port the IDE Port number
26
27 return the one-byte data read from IDE port
28 **/
29 UINT8
30 IDEReadPortB (
31 IN EFI_PCI_IO_PROTOCOL *PciIo,
32 IN UINT16 Port
33 );
34
35 /**
36 Reads multiple words of data from the IDE data port.
37 Call the IO abstraction once to do the complete read,
38 not one word at a time.
39
40 @param PciIo Pointer to the EFI_PCI_IO instance
41 @param Port IO port to read
42 @param Count No. of UINT16's to read
43 @param Buffer Pointer to the data buffer for read
44
45 **/
46 VOID
47 IDEReadPortWMultiple (
48 IN EFI_PCI_IO_PROTOCOL *PciIo,
49 IN UINT16 Port,
50 IN UINTN Count,
51 OUT VOID *Buffer
52 );
53
54 /**
55 write a 1-byte data to a specific IDE port.
56
57 @param PciIo PCI IO protocol instance
58 @param Port The IDE port to be writen
59 @param Data The data to write to the port
60 **/
61 VOID
62 IDEWritePortB (
63 IN EFI_PCI_IO_PROTOCOL *PciIo,
64 IN UINT16 Port,
65 IN UINT8 Data
66 );
67
68 /**
69 write a 1-word data to a specific IDE port.
70
71 @param PciIo PCI IO protocol instance
72 @param Port The IDE port to be writen
73 @param Data The data to write to the port
74 **/
75 VOID
76 IDEWritePortW (
77 IN EFI_PCI_IO_PROTOCOL *PciIo,
78 IN UINT16 Port,
79 IN UINT16 Data
80 );
81
82 /**
83 Write multiple words of data to the IDE data port.
84 Call the IO abstraction once to do the complete read,
85 not one word at a time.
86
87 @param PciIo Pointer to the EFI_PCI_IO instance
88 @param Port IO port to read
89 @param Count No. of UINT16's to read
90 @param Buffer Pointer to the data buffer for read
91
92 **/
93 VOID
94 IDEWritePortWMultiple (
95 IN EFI_PCI_IO_PROTOCOL *PciIo,
96 IN UINT16 Port,
97 IN UINTN Count,
98 IN VOID *Buffer
99 );
100
101 /**
102 Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
103 use fixed addresses. In Native-PCI mode, get base addresses from BARs in
104 the PCI IDE controller's Configuration Space.
105
106 The steps to get IDE IO port registers' base addresses for each channel
107 as follows:
108
109 1. Examine the Programming Interface byte of the Class Code fields in PCI IDE
110 controller's Configuration Space to determine the operating mode.
111
112 2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.
113 <pre>
114 ___________________________________________
115 | | Command Block | Control Block |
116 | Channel | Registers | Registers |
117 |___________|_______________|_______________|
118 | Primary | 1F0h - 1F7h | 3F6h - 3F7h |
119 |___________|_______________|_______________|
120 | Secondary | 170h - 177h | 376h - 377h |
121 |___________|_______________|_______________|
122
123 Table 1. Compatibility resource mappings
124 </pre>
125
126 b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs
127 in IDE controller's PCI Configuration Space, shown in the Table 2 below.
128 <pre>
129 ___________________________________________________
130 | | Command Block | Control Block |
131 | Channel | Registers | Registers |
132 |___________|___________________|___________________|
133 | Primary | BAR at offset 0x10| BAR at offset 0x14|
134 |___________|___________________|___________________|
135 | Secondary | BAR at offset 0x18| BAR at offset 0x1C|
136 |___________|___________________|___________________|
137
138 Table 2. BARs for Register Mapping
139 </pre>
140 @note Refer to Intel ICH4 datasheet, Control Block Offset: 03F4h for
141 primary, 0374h for secondary. So 2 bytes extra offset should be
142 added to the base addresses read from BARs.
143
144 For more details, please refer to PCI IDE Controller Specification and Intel
145 ICH4 Datasheet.
146
147 @param PciIo Pointer to the EFI_PCI_IO_PROTOCOL instance
148 @param IdeRegsBaseAddr Pointer to IDE_REGISTERS_BASE_ADDR to
149 receive IDE IO port registers' base addresses
150
151 @retval EFI_UNSUPPORTED return this value when the BARs is not IO type
152 @retval EFI_SUCCESS Get the Base address successfully
153 @retval other read the pci configureation data error
154
155 **/
156 EFI_STATUS
157 GetIdeRegistersBaseAddr (
158 IN EFI_PCI_IO_PROTOCOL *PciIo,
159 OUT IDE_REGISTERS_BASE_ADDR *IdeRegsBaseAddr
160 );
161
162 /**
163 This function is used to requery IDE resources. The IDE controller will
164 probably switch between native and legacy modes during the EFI->CSM->OS
165 transfer. We do this everytime before an BlkIo operation to ensure its
166 succeess.
167
168 @param IdeDev The BLK_IO private data which specifies the IDE device
169
170 @retval EFI_INVALID_PARAMETER return this value when the channel is invalid
171 @retval EFI_SUCCESS reassign the IDE IO resource successfully
172 @retval other get the IDE current base address effor
173
174 **/
175 EFI_STATUS
176 ReassignIdeResources (
177 IN IDE_BLK_IO_DEV *IdeDev
178 );
179
180 /**
181 Detect if there is disk attached to this port.
182
183 @param IdeDev The BLK_IO private data which specifies the IDE device.
184
185 @retval EFI_NOT_FOUND The device or channel is not found
186 @retval EFI_SUCCESS The device is found
187
188 **/
189 EFI_STATUS
190 DiscoverIdeDevice (
191 IN IDE_BLK_IO_DEV *IdeDev
192 );
193
194 /**
195 This interface is used to initialize all state data related to the
196 detection of one channel.
197
198 **/
199 VOID
200 InitializeIDEChannelData (
201 VOID
202 );
203
204 /**
205 This function is used to poll for the DRQ bit clear in the Status
206 Register. DRQ is cleared when the device is finished transferring data.
207 So this function is called after data transfer is finished.
208
209 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
210 to record all the information of the IDE device.
211 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.
212
213 @retval EFI_SUCCESS DRQ bit clear within the time out.
214
215 @retval EFI_TIMEOUT DRQ bit not clear within the time out.
216
217 @note
218 Read Status Register will clear interrupt status.
219
220 **/
221 EFI_STATUS
222 DRQClear (
223 IN IDE_BLK_IO_DEV *IdeDev,
224 IN UINTN TimeoutInMilliSeconds
225 );
226
227 /**
228 This function is used to poll for the DRQ bit clear in the Alternate
229 Status Register. DRQ is cleared when the device is finished
230 transferring data. So this function is called after data transfer
231 is finished.
232
233 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
234 to record all the information of the IDE device.
235
236 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.
237
238 @retval EFI_SUCCESS DRQ bit clear within the time out.
239
240 @retval EFI_TIMEOUT DRQ bit not clear within the time out.
241 @note
242 Read Alternate Status Register will not clear interrupt status.
243
244 **/
245 EFI_STATUS
246 DRQClear2 (
247 IN IDE_BLK_IO_DEV *IdeDev,
248 IN UINTN TimeoutInMilliSeconds
249 );
250
251 /**
252 This function is used to poll for the DRQ bit set in the
253 Status Register.
254 DRQ is set when the device is ready to transfer data. So this function
255 is called after the command is sent to the device and before required
256 data is transferred.
257
258 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to
259 record all the information of the IDE device.
260 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
261
262 @retval EFI_SUCCESS DRQ bit set within the time out.
263 @retval EFI_TIMEOUT DRQ bit not set within the time out.
264 @retval EFI_ABORTED DRQ bit not set caused by the command abort.
265
266 @note Read Status Register will clear interrupt status.
267
268 **/
269 EFI_STATUS
270 DRQReady (
271 IN IDE_BLK_IO_DEV *IdeDev,
272 IN UINTN TimeoutInMilliSeconds
273 );
274
275 /**
276 This function is used to poll for the DRQ bit set in the Alternate Status Register.
277 DRQ is set when the device is ready to transfer data. So this function is called after
278 the command is sent to the device and before required data is transferred.
279
280 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to
281 record all the information of the IDE device.
282
283 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
284
285 @retval EFI_SUCCESS DRQ bit set within the time out.
286 @retval EFI_TIMEOUT DRQ bit not set within the time out.
287 @retval EFI_ABORTED DRQ bit not set caused by the command abort.
288 @note Read Alternate Status Register will not clear interrupt status.
289
290 **/
291 EFI_STATUS
292 DRQReady2 (
293 IN IDE_BLK_IO_DEV *IdeDev,
294 IN UINTN TimeoutInMilliSeconds
295 );
296
297 /**
298 This function is used to poll for the BSY bit clear in the Status Register. BSY
299 is clear when the device is not busy. Every command must be sent after device is not busy.
300
301 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
302 to record all the information of the IDE device.
303 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
304
305 @retval EFI_SUCCESS BSY bit clear within the time out.
306 @retval EFI_TIMEOUT BSY bit not clear within the time out.
307
308 @note Read Status Register will clear interrupt status.
309 **/
310 EFI_STATUS
311 WaitForBSYClear (
312 IN IDE_BLK_IO_DEV *IdeDev,
313 IN UINTN TimeoutInMilliSeconds
314 );
315
316 /**
317 This function is used to poll for the BSY bit clear in the Alternate Status Register.
318 BSY is clear when the device is not busy. Every command must be sent after device is
319 not busy.
320
321 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
322 all the information of the IDE device.
323 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
324
325 @retval EFI_SUCCESS BSY bit clear within the time out.
326 @retval EFI_TIMEOUT BSY bit not clear within the time out.
327 @note Read Alternate Status Register will not clear interrupt status.
328
329 **/
330 EFI_STATUS
331 WaitForBSYClear2 (
332 IN IDE_BLK_IO_DEV *IdeDev,
333 IN UINTN TimeoutInMilliSeconds
334 );
335
336 /**
337 This function is used to poll for the DRDY bit set in the Status Register. DRDY
338 bit is set when the device is ready to accept command. Most ATA commands must be
339 sent after DRDY set except the ATAPI Packet Command.
340
341 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
342 to record all the information of the IDE device.
343 @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.
344
345 @retval EFI_SUCCESS DRDY bit set within the time out.
346 @retval EFI_TIMEOUT DRDY bit not set within the time out.
347
348 @note Read Status Register will clear interrupt status.
349 **/
350 EFI_STATUS
351 DRDYReady (
352 IN IDE_BLK_IO_DEV *IdeDev,
353 IN UINTN DelayInMilliSeconds
354 );
355
356 /**
357 This function is used to poll for the DRDY bit set in the Alternate Status Register.
358 DRDY bit is set when the device is ready to accept command. Most ATA commands must
359 be sent after DRDY set except the ATAPI Packet Command.
360
361 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
362 to record all the information of the IDE device.
363 @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.
364
365 @retval EFI_SUCCESS DRDY bit set within the time out.
366 @retval EFI_TIMEOUT DRDY bit not set within the time out.
367
368 @note Read Alternate Status Register will clear interrupt status.
369
370 **/
371 EFI_STATUS
372 DRDYReady2 (
373 IN IDE_BLK_IO_DEV *IdeDev,
374 IN UINTN DelayInMilliSeconds
375 );
376
377 //
378 // ATA device functions' prototype
379 //
380 /**
381 Sends out an ATA Identify Command to the specified device.
382
383 This function is called by DiscoverIdeDevice() during its device
384 identification. It sends out the ATA Identify Command to the
385 specified device. Only ATA device responses to this command. If
386 the command succeeds, it returns the Identify data structure which
387 contains information about the device. This function extracts the
388 information it needs to fill the IDE_BLK_IO_DEV data structure,
389 including device type, media block size, media capacity, and etc.
390
391 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record
392 all the information of the IDE device.
393
394 @retval EFI_SUCCESS Identify ATA device successfully.
395 @retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.
396 @note parameter IdeDev will be updated in this function.
397
398 **/
399 EFI_STATUS
400 ATAIdentify (
401 IN IDE_BLK_IO_DEV *IdeDev
402 );
403
404 /**
405 This function is called by ATAIdentify() or ATAPIIdentify() to print device's module name.
406
407 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
408 all the information of the IDE device.
409 **/
410 VOID
411 PrintAtaModuleName (
412 IN IDE_BLK_IO_DEV *IdeDev
413 );
414 /**
415 This function is used to send out ATA commands conforms to the PIO Data In Protocol.
416
417 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
418 all the information of the IDE device.
419 @param Buffer buffer contained data transferred from device to host.
420 @param ByteCount data size in byte unit of the buffer.
421 @param AtaCommand value of the Command Register
422 @param Head value of the Head/Device Register
423 @param SectorCount value of the Sector Count Register
424 @param SectorNumber value of the Sector Number Register
425 @param CylinderLsb value of the low byte of the Cylinder Register
426 @param CylinderMsb value of the high byte of the Cylinder Register
427
428 @retval EFI_SUCCESS send out the ATA command and device send required data successfully.
429 @retval EFI_DEVICE_ERROR command sent failed.
430
431 **/
432 EFI_STATUS
433 AtaPioDataIn (
434 IN IDE_BLK_IO_DEV *IdeDev,
435 IN VOID *Buffer,
436 IN UINT32 ByteCount,
437 IN UINT8 AtaCommand,
438 IN UINT8 Head,
439 IN UINT8 SectorCount,
440 IN UINT8 SectorNumber,
441 IN UINT8 CylinderLsb,
442 IN UINT8 CylinderMsb
443 );
444
445 /**
446 This function is used to send out ATA commands conforms to the
447 PIO Data Out Protocol.
448
449 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
450 to record all the information of the IDE device.
451 @param *Buffer buffer contained data transferred from host to device.
452 @param ByteCount data size in byte unit of the buffer.
453 @param AtaCommand value of the Command Register
454 @param Head value of the Head/Device Register
455 @param SectorCount value of the Sector Count Register
456 @param SectorNumber value of the Sector Number Register
457 @param CylinderLsb value of the low byte of the Cylinder Register
458 @param CylinderMsb value of the high byte of the Cylinder Register
459
460 @retval EFI_SUCCESS send out the ATA command and device received required
461 data successfully.
462 @retval EFI_DEVICE_ERROR command sent failed.
463
464 **/
465 EFI_STATUS
466 AtaPioDataOut (
467 IN IDE_BLK_IO_DEV *IdeDev,
468 IN VOID *Buffer,
469 IN UINT32 ByteCount,
470 IN UINT8 AtaCommand,
471 IN UINT8 Head,
472 IN UINT8 SectorCount,
473 IN UINT8 SectorNumber,
474 IN UINT8 CylinderLsb,
475 IN UINT8 CylinderMsb
476 );
477
478 /**
479 This function is used to analyze the Status Register and print out
480 some debug information and if there is ERR bit set in the Status
481 Register, the Error Register's value is also be parsed and print out.
482
483 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to
484 record all the information of the IDE device.
485
486 @retval EFI_SUCCESS No err information in the Status Register.
487 @retval EFI_DEVICE_ERROR Any err information in the Status Register.
488
489 **/
490 EFI_STATUS
491 CheckErrorStatus (
492 IN IDE_BLK_IO_DEV *IdeDev
493 );
494
495 /**
496 This function is used to implement the Soft Reset on the specified device. But,
497 the ATA Soft Reset mechanism is so strong a reset method that it will force
498 resetting on both devices connected to the same cable.
499
500 It is called by IdeBlkIoReset(), a interface function of Block
501 I/O protocol.
502
503 This function can also be used by the ATAPI device to perform reset when
504 ATAPI Reset command is failed.
505
506 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
507 all the information of the IDE device.
508 @retval EFI_SUCCESS Soft reset completes successfully.
509 @retval EFI_DEVICE_ERROR Any step during the reset process is failed.
510
511 @note The registers initial values after ATA soft reset are different
512 to the ATA device and ATAPI device.
513 **/
514 EFI_STATUS
515 AtaSoftReset (
516 IN IDE_BLK_IO_DEV *IdeDev
517 );
518
519 /**
520 This function is the ATA implementation for ReadBlocks in the
521 Block I/O Protocol interface.
522
523 @param IdeBlkIoDevice Indicates the calling context.
524 @param MediaId The media id that the read request is for.
525 @param Lba The starting logical block address to read from on the device.
526 @param BufferSize The size of the Buffer in bytes. This must be a multiple
527 of the intrinsic block size of the device.
528
529 @param Buffer A pointer to the destination buffer for the data. The caller
530 is responsible for either having implicit or explicit ownership
531 of the memory that data is read into.
532
533 @retval EFI_SUCCESS Read Blocks successfully.
534 @retval EFI_DEVICE_ERROR Read Blocks failed.
535 @retval EFI_NO_MEDIA There is no media in the device.
536 @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
537 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
538 intrinsic block size of the device.
539 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
540 or the data buffer is not valid.
541
542 @note If Read Block error because of device error, this function will call
543 AtaSoftReset() function to reset device.
544
545 **/
546 EFI_STATUS
547 AtaBlkIoReadBlocks (
548 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
549 IN UINT32 MediaId,
550 IN EFI_LBA Lba,
551 IN UINTN BufferSize,
552 OUT VOID *Buffer
553 );
554
555 /**
556 This function is the ATA implementation for WriteBlocks in the
557 Block I/O Protocol interface.
558
559 @param IdeBlkIoDevice Indicates the calling context.
560 @param MediaId The media id that the write request is for.
561 @param Lba The starting logical block address to write onto the device.
562 @param BufferSize The size of the Buffer in bytes. This must be a multiple
563 of the intrinsic block size of the device.
564 @param Buffer A pointer to the source buffer for the data.The caller
565 is responsible for either having implicit or explicit
566 ownership of the memory that data is written from.
567
568 @retval EFI_SUCCESS Write Blocks successfully.
569 @retval EFI_DEVICE_ERROR Write Blocks failed.
570 @retval EFI_NO_MEDIA There is no media in the device.
571 @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
572
573 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
574 intrinsic block size of the device.
575 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
576 or the data buffer is not valid.
577
578 @note If Write Block error because of device error, this function will call
579 AtaSoftReset() function to reset device.
580 **/
581 EFI_STATUS
582 AtaBlkIoWriteBlocks (
583 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
584 IN UINT32 MediaId,
585 IN EFI_LBA Lba,
586 IN UINTN BufferSize,
587 OUT VOID *Buffer
588 );
589
590 /**
591 This function is called by DiscoverIdeDevice() during its device
592 identification.
593 Its main purpose is to get enough information for the device media
594 to fill in the Media data structure of the Block I/O Protocol interface.
595
596 There are 5 steps to reach such objective:
597 1. Sends out the ATAPI Identify Command to the specified device.
598 Only ATAPI device responses to this command. If the command succeeds,
599 it returns the Identify data structure which filled with information
600 about the device. Since the ATAPI device contains removable media,
601 the only meaningful information is the device module name.
602 2. Sends out ATAPI Inquiry Packet Command to the specified device.
603 This command will return inquiry data of the device, which contains
604 the device type information.
605 3. Allocate sense data space for future use. We don't detect the media
606 presence here to improvement boot performance, especially when CD
607 media is present. The media detection will be performed just before
608 each BLK_IO read/write
609
610 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
611 to record all the information of the IDE device.
612
613 @retval EFI_SUCCESS Identify ATAPI device successfully.
614 @retval EFI_DEVICE_ERROR ATAPI Identify Device Command failed or device type
615 is not supported by this IDE driver.
616 @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed
617
618 @note Parameter "IdeDev" will be updated in this function.
619 **/
620 EFI_STATUS
621 ATAPIIdentify (
622 IN IDE_BLK_IO_DEV *IdeDev
623 );
624
625 /**
626 This function is used to implement the Soft Reset on the specified
627 ATAPI device. Different from the AtaSoftReset(), here reset is a ATA
628 Soft Reset Command special for ATAPI device, and it only take effects
629 on the specified ATAPI device, not on the whole IDE bus.
630 Since the ATAPI soft reset is needed when device is in exceptional
631 condition (such as BSY bit is always set ), I think the Soft Reset
632 command should be sent without waiting for the BSY clear and DRDY
633 set.
634 This function is called by IdeBlkIoReset(),
635 a interface function of Block I/O protocol.
636
637 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
638 to record all the information of the IDE device.
639
640 @retval EFI_SUCCESS Soft reset completes successfully.
641 @retval EFI_DEVICE_ERROR Any step during the reset process is failed.
642
643 **/
644 EFI_STATUS
645 AtapiSoftReset (
646 IN IDE_BLK_IO_DEV *IdeDev
647 );
648
649 /**
650 This function is the ATAPI implementation for ReadBlocks in the
651 Block I/O Protocol interface.
652
653 @param IdeBlkIoDevice Indicates the calling context.
654 @param MediaId The media id that the read request is for.
655 @param Lba The starting logical block address to read from on the device.
656 @param BufferSize The size of the Buffer in bytes. This must be a multiple
657 of the intrinsic block size of the device.
658 @param Buffer A pointer to the destination buffer for the data. The caller
659 is responsible for either having implicit or explicit
660 ownership of the memory that data is read into.
661
662 @retval EFI_SUCCESS Read Blocks successfully.
663 @retval EFI_DEVICE_ERROR Read Blocks failed.
664 @retval EFI_NO_MEDIA There is no media in the device.
665 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
666 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
667 intrinsic block size of the device.
668 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
669 or the data buffer is not valid.
670 **/
671 EFI_STATUS
672 AtapiBlkIoReadBlocks (
673 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
674 IN UINT32 MediaId,
675 IN EFI_LBA Lba,
676 IN UINTN BufferSize,
677 OUT VOID *Buffer
678 );
679
680 /**
681 This function is the ATAPI implementation for WriteBlocks in the
682 Block I/O Protocol interface.
683
684 @param IdeBlkIoDevice Indicates the calling context.
685 @param MediaId The media id that the write request is for.
686 @param Lba The starting logical block address to write onto the device.
687 @param BufferSize The size of the Buffer in bytes. This must be a multiple
688 of the intrinsic block size of the device.
689 @param Buffer A pointer to the source buffer for the data. The caller
690 is responsible for either having implicit or explicit ownership
691 of the memory that data is written from.
692
693 @retval EFI_SUCCESS Write Blocks successfully.
694 @retval EFI_DEVICE_ERROR Write Blocks failed.
695 @retval EFI_NO_MEDIA There is no media in the device.
696 @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
697 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
698 intrinsic block size of the device.
699 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
700 or the data buffer is not valid.
701
702 @retval EFI_WRITE_PROTECTED The write protected is enabled or the media does not support write
703 **/
704 EFI_STATUS
705 AtapiBlkIoWriteBlocks (
706 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
707 IN UINT32 MediaId,
708 IN EFI_LBA Lba,
709 IN UINTN BufferSize,
710 OUT VOID *Buffer
711 );
712
713 /**
714 Release resources of an IDE device before stopping it.
715
716 @param IdeBlkIoDevice Standard IDE device private data structure
717
718 **/
719 VOID
720 ReleaseIdeResources (
721 IN IDE_BLK_IO_DEV *IdeBlkIoDevice
722 );
723
724 /**
725 Set the calculated Best transfer mode to a detected device
726
727 @param IdeDev Standard IDE device private data structure
728 @param TransferMode The device transfer mode to be set
729 @return Set transfer mode Command execute status.
730 **/
731 EFI_STATUS
732 SetDeviceTransferMode (
733 IN IDE_BLK_IO_DEV *IdeDev,
734 IN ATA_TRANSFER_MODE *TransferMode
735 );
736 /**
737 Send ATA command into device with NON_DATA protocol.
738
739 @param IdeDev Standard IDE device private data structure
740 @param AtaCommand The ATA command to be sent
741 @param Device The value in Device register
742 @param Feature The value in Feature register
743 @param SectorCount The value in SectorCount register
744 @param LbaLow The value in LBA_LOW register
745 @param LbaMiddle The value in LBA_MIDDLE register
746 @param LbaHigh The value in LBA_HIGH register
747
748 @retval EFI_SUCCESS Reading succeed
749 @retval EFI_ABORTED Command failed
750 @retval EFI_DEVICE_ERROR Device status error.
751
752 **/
753 EFI_STATUS
754 AtaNonDataCommandIn (
755 IN IDE_BLK_IO_DEV *IdeDev,
756 IN UINT8 AtaCommand,
757 IN UINT8 Device,
758 IN UINT8 Feature,
759 IN UINT8 SectorCount,
760 IN UINT8 LbaLow,
761 IN UINT8 LbaMiddle,
762 IN UINT8 LbaHigh
763 );
764
765 /**
766 Enable Long Physical Sector Feature for ATA device.
767
768 @param IdeDev The IDE device data
769
770 @retval EFI_SUCCESS The ATA device supports Long Physical Sector feature
771 and corresponding fields in BlockIo structure is updated.
772 @retval EFI_UNSUPPORTED The device is not ATA device or Long Physical Sector
773 feature is not supported.
774 **/
775 EFI_STATUS
776 AtaEnableLongPhysicalSector (
777 IN IDE_BLK_IO_DEV *IdeDev
778 );
779
780 /**
781 Set drive parameters for devices not support PACKETS command.
782
783 @param IdeDev Standard IDE device private data structure
784 @param DriveParameters The device parameters to be set into the disk
785 @return SetParameters Command execute status.
786
787 **/
788 EFI_STATUS
789 SetDriveParameters (
790 IN IDE_BLK_IO_DEV *IdeDev,
791 IN ATA_DRIVE_PARMS *DriveParameters
792 );
793
794 /**
795 Enable Interrupt on IDE controller.
796
797 @param IdeDev Standard IDE device private data structure
798
799 @retval EFI_SUCCESS Enable Interrupt successfully
800 **/
801 EFI_STATUS
802 EnableInterrupt (
803 IN IDE_BLK_IO_DEV *IdeDev
804 );
805 #endif