Add PCI option to generate OptionRom
[mirror_edk2.git] / OptionRomPkg / AtapiPassThruDxe / AtapiPassThru.h
1 /** @file
2 Copyright (c) 2006, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
7
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11 Module Name: AtapiPassThru.h
12
13 **/
14
15 #ifndef _APT_H
16 #define _APT_H
17
18
19
20 #include <Uefi.h>
21
22 #include <Protocol/ScsiPassThru.h>
23 #include <Protocol/ScsiPassThruExt.h>
24 #include <Protocol/PciIo.h>
25 #include <Protocol/DriverSupportedEfiVersion.h>
26
27 #include <Library/DebugLib.h>
28 #include <Library/UefiDriverEntryPoint.h>
29 #include <Library/BaseLib.h>
30 #include <Library/UefiLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/MemoryAllocationLib.h>
33 #include <Library/UefiBootServicesTableLib.h>
34 #include <Library/PcdLib.h>
35 #include <Library/DevicePathLib.h>
36
37 #include <IndustryStandard/Pci22.h>
38
39
40 ///
41 /// bit definition
42 ///
43 #define bit(a) (1 << (a))
44
45 #define MAX_TARGET_ID 4
46
47 //
48 // IDE Registers
49 //
50 typedef union {
51 UINT16 Command; /* when write */
52 UINT16 Status; /* when read */
53 } IDE_CMD_OR_STATUS;
54
55 typedef union {
56 UINT16 Error; /* when read */
57 UINT16 Feature; /* when write */
58 } IDE_ERROR_OR_FEATURE;
59
60 typedef union {
61 UINT16 AltStatus; /* when read */
62 UINT16 DeviceControl; /* when write */
63 } IDE_AltStatus_OR_DeviceControl;
64
65
66 typedef enum {
67 IdePrimary = 0,
68 IdeSecondary = 1,
69 IdeMaxChannel = 2
70 } EFI_IDE_CHANNEL;
71
72 ///
73
74
75 //
76 // Bit definitions in Programming Interface byte of the Class Code field
77 // in PCI IDE controller's Configuration Space
78 //
79 #define IDE_PRIMARY_OPERATING_MODE BIT0
80 #define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
81 #define IDE_SECONDARY_OPERATING_MODE BIT2
82 #define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
83
84
85 #define ATAPI_MAX_CHANNEL 2
86
87 ///
88 /// IDE registers set
89 ///
90 typedef struct {
91 UINT16 Data;
92 IDE_ERROR_OR_FEATURE Reg1;
93 UINT16 SectorCount;
94 UINT16 SectorNumber;
95 UINT16 CylinderLsb;
96 UINT16 CylinderMsb;
97 UINT16 Head;
98 IDE_CMD_OR_STATUS Reg;
99 IDE_AltStatus_OR_DeviceControl Alt;
100 UINT16 DriveAddress;
101 } IDE_BASE_REGISTERS;
102
103 #define ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE SIGNATURE_32 ('a', 's', 'p', 't')
104
105 typedef struct {
106 UINTN Signature;
107 EFI_HANDLE Handle;
108 EFI_SCSI_PASS_THRU_PROTOCOL ScsiPassThru;
109 EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru;
110 EFI_PCI_IO_PROTOCOL *PciIo;
111 UINT64 OriginalPciAttributes;
112 //
113 // Local Data goes here
114 //
115 IDE_BASE_REGISTERS *IoPort;
116 IDE_BASE_REGISTERS AtapiIoPortRegisters[2];
117 UINT32 LatestTargetId;
118 UINT64 LatestLun;
119 } ATAPI_SCSI_PASS_THRU_DEV;
120
121 //
122 // IDE registers' base addresses
123 //
124 typedef struct {
125 UINT16 CommandBlockBaseAddr;
126 UINT16 ControlBlockBaseAddr;
127 } IDE_REGISTERS_BASE_ADDR;
128
129 #define ATAPI_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
130 CR (a, \
131 ATAPI_SCSI_PASS_THRU_DEV, \
132 ScsiPassThru, \
133 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
134 )
135
136 #define ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
137 CR (a, \
138 ATAPI_SCSI_PASS_THRU_DEV, \
139 ExtScsiPassThru, \
140 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
141 )
142
143 //
144 // Global Variables
145 //
146 extern EFI_DRIVER_BINDING_PROTOCOL gAtapiScsiPassThruDriverBinding;
147 extern EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName;
148 extern EFI_COMPONENT_NAME2_PROTOCOL gAtapiScsiPassThruComponentName2;
149 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gAtapiScsiPassThruDriverSupportedEfiVersion;
150
151 //
152 // ATAPI Command op code
153 //
154 #define OP_INQUIRY 0x12
155 #define OP_LOAD_UNLOAD_CD 0xa6
156 #define OP_MECHANISM_STATUS 0xbd
157 #define OP_MODE_SELECT_10 0x55
158 #define OP_MODE_SENSE_10 0x5a
159 #define OP_PAUSE_RESUME 0x4b
160 #define OP_PLAY_AUDIO_10 0x45
161 #define OP_PLAY_AUDIO_MSF 0x47
162 #define OP_PLAY_CD 0xbc
163 #define OP_PLAY_CD_MSF 0xb4
164 #define OP_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
165 #define OP_READ_10 0x28
166 #define OP_READ_12 0xa8
167 #define OP_READ_CAPACITY 0x25
168 #define OP_READ_CD 0xbe
169 #define OP_READ_CD_MSF 0xb9
170 #define OP_READ_HEADER 0x44
171 #define OP_READ_SUB_CHANNEL 0x42
172 #define OP_READ_TOC 0x43
173 #define OP_REQUEST_SENSE 0x03
174 #define OP_SCAN 0xba
175 #define OP_SEEK_10 0x2b
176 #define OP_SET_CD_SPEED 0xbb
177 #define OP_STOPPLAY_SCAN 0x4e
178 #define OP_START_STOP_UNIT 0x1b
179 #define OP_TEST_UNIT_READY 0x00
180
181 #define OP_FORMAT_UNIT 0x04
182 #define OP_READ_FORMAT_CAPACITIES 0x23
183 #define OP_VERIFY 0x2f
184 #define OP_WRITE_10 0x2a
185 #define OP_WRITE_12 0xaa
186 #define OP_WRITE_AND_VERIFY 0x2e
187
188 //
189 // ATA Command
190 //
191 #define ATAPI_SOFT_RESET_CMD 0x08
192
193 typedef enum {
194 DataIn = 0,
195 DataOut = 1,
196 DataBi = 2,
197 NoData = 3,
198 End = 0xff
199 } DATA_DIRECTION;
200
201 typedef struct {
202 UINT8 OpCode;
203 DATA_DIRECTION Direction;
204 } SCSI_COMMAND_SET;
205
206 #define MAX_CHANNEL 2
207
208 #define ValidCdbLength(Len) ((Len) == 6 || (Len) == 10 || (Len) == 12) ? 1 : 0
209
210 //
211 // IDE registers bit definitions
212 //
213 // ATA Err Reg bitmap
214 //
215 #define BBK_ERR bit (7) ///< Bad block detected
216 #define UNC_ERR bit (6) ///< Uncorrectable Data
217 #define MC_ERR bit (5) ///< Media Change
218 #define IDNF_ERR bit (4) ///< ID Not Found
219 #define MCR_ERR bit (3) ///< Media Change Requested
220 #define ABRT_ERR bit (2) ///< Aborted Command
221 #define TK0NF_ERR bit (1) ///< Track 0 Not Found
222 #define AMNF_ERR bit (0) ///< Address Mark Not Found
223
224 //
225 // ATAPI Err Reg bitmap
226 //
227 #define SENSE_KEY_ERR (bit (7) | bit (6) | bit (5) | bit (4))
228 #define EOM_ERR bit (1) ///< End of Media Detected
229 #define ILI_ERR bit (0) ///< Illegal Length Indication
230
231 //
232 // Device/Head Reg
233 //
234 #define LBA_MODE bit (6)
235 #define DEV bit (4)
236 #define HS3 bit (3)
237 #define HS2 bit (2)
238 #define HS1 bit (1)
239 #define HS0 bit (0)
240 #define CHS_MODE (0)
241 #define DRV0 (0)
242 #define DRV1 (1)
243 #define MST_DRV DRV0
244 #define SLV_DRV DRV1
245
246 //
247 // Status Reg
248 //
249 #define BSY bit (7) ///< Controller Busy
250 #define DRDY bit (6) ///< Drive Ready
251 #define DWF bit (5) ///< Drive Write Fault
252 #define DSC bit (4) ///< Disk Seek Complete
253 #define DRQ bit (3) ///< Data Request
254 #define CORR bit (2) ///< Corrected Data
255 #define IDX bit (1) ///< Index
256 #define ERR bit (0) ///< Error
257 #define CHECK bit (0) ///< Check bit for ATAPI Status Reg
258
259 //
260 // Device Control Reg
261 //
262 #define SRST bit (2) ///< Software Reset
263 #define IEN_L bit (1) ///< Interrupt Enable
264
265 //
266 // ATAPI Feature Register
267 //
268 #define OVERLAP bit (1)
269 #define DMA bit (0)
270
271 //
272 // ATAPI Interrupt Reason Reson Reg (ATA Sector Count Register)
273 //
274 #define RELEASE bit (2)
275 #define IO bit (1)
276 #define CoD bit (0)
277
278 #define PACKET_CMD 0xA0
279
280 #define DEFAULT_CMD (0xa0)
281 //
282 // default content of device control register, disable INT
283 //
284 #define DEFAULT_CTL (0x0a)
285 #define MAX_ATAPI_BYTE_COUNT (0xfffe)
286
287 //
288 // function prototype
289 //
290
291 EFI_STATUS
292 EFIAPI
293 AtapiScsiPassThruDriverBindingSupported (
294 IN EFI_DRIVER_BINDING_PROTOCOL *This,
295 IN EFI_HANDLE Controller,
296 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
297 );
298
299 EFI_STATUS
300 EFIAPI
301 AtapiScsiPassThruDriverBindingStart (
302 IN EFI_DRIVER_BINDING_PROTOCOL *This,
303 IN EFI_HANDLE Controller,
304 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
305 );
306
307 EFI_STATUS
308 EFIAPI
309 AtapiScsiPassThruDriverBindingStop (
310 IN EFI_DRIVER_BINDING_PROTOCOL *This,
311 IN EFI_HANDLE Controller,
312 IN UINTN NumberOfChildren,
313 IN EFI_HANDLE *ChildHandleBuffer
314 );
315
316 //
317 // EFI Component Name Functions
318 //
319 /**
320 Retrieves a Unicode string that is the user readable name of the driver.
321
322 This function retrieves the user readable name of a driver in the form of a
323 Unicode string. If the driver specified by This has a user readable name in
324 the language specified by Language, then a pointer to the driver name is
325 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
326 by This does not support the language specified by Language,
327 then EFI_UNSUPPORTED is returned.
328
329 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
330 EFI_COMPONENT_NAME_PROTOCOL instance.
331
332 @param Language[in] A pointer to a Null-terminated ASCII string
333 array indicating the language. This is the
334 language of the driver name that the caller is
335 requesting, and it must match one of the
336 languages specified in SupportedLanguages. The
337 number of languages supported by a driver is up
338 to the driver writer. Language is specified
339 in RFC 3066 or ISO 639-2 language code format.
340
341 @param DriverName[out] A pointer to the Unicode string to return.
342 This Unicode string is the name of the
343 driver specified by This in the language
344 specified by Language.
345
346 @retval EFI_SUCCESS The Unicode string for the Driver specified by
347 This and the language specified by Language was
348 returned in DriverName.
349
350 @retval EFI_INVALID_PARAMETER Language is NULL.
351
352 @retval EFI_INVALID_PARAMETER DriverName is NULL.
353
354 @retval EFI_UNSUPPORTED The driver specified by This does not support
355 the language specified by Language.
356
357 **/
358 EFI_STATUS
359 EFIAPI
360 AtapiScsiPassThruComponentNameGetDriverName (
361 IN EFI_COMPONENT_NAME_PROTOCOL *This,
362 IN CHAR8 *Language,
363 OUT CHAR16 **DriverName
364 );
365
366
367 /**
368 Retrieves a Unicode string that is the user readable name of the controller
369 that is being managed by a driver.
370
371 This function retrieves the user readable name of the controller specified by
372 ControllerHandle and ChildHandle in the form of a Unicode string. If the
373 driver specified by This has a user readable name in the language specified by
374 Language, then a pointer to the controller name is returned in ControllerName,
375 and EFI_SUCCESS is returned. If the driver specified by This is not currently
376 managing the controller specified by ControllerHandle and ChildHandle,
377 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
378 support the language specified by Language, then EFI_UNSUPPORTED is returned.
379
380 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
381 EFI_COMPONENT_NAME_PROTOCOL instance.
382
383 @param ControllerHandle[in] The handle of a controller that the driver
384 specified by This is managing. This handle
385 specifies the controller whose name is to be
386 returned.
387
388 @param ChildHandle[in] The handle of the child controller to retrieve
389 the name of. This is an optional parameter that
390 may be NULL. It will be NULL for device
391 drivers. It will also be NULL for a bus drivers
392 that wish to retrieve the name of the bus
393 controller. It will not be NULL for a bus
394 driver that wishes to retrieve the name of a
395 child controller.
396
397 @param Language[in] A pointer to a Null-terminated ASCII string
398 array indicating the language. This is the
399 language of the driver name that the caller is
400 requesting, and it must match one of the
401 languages specified in SupportedLanguages. The
402 number of languages supported by a driver is up
403 to the driver writer. Language is specified in
404 RFC 3066 or ISO 639-2 language code format.
405
406 @param ControllerName[out] A pointer to the Unicode string to return.
407 This Unicode string is the name of the
408 controller specified by ControllerHandle and
409 ChildHandle in the language specified by
410 Language from the point of view of the driver
411 specified by This.
412
413 @retval EFI_SUCCESS The Unicode string for the user readable name in
414 the language specified by Language for the
415 driver specified by This was returned in
416 DriverName.
417
418 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
419
420 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
421 EFI_HANDLE.
422
423 @retval EFI_INVALID_PARAMETER Language is NULL.
424
425 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
426
427 @retval EFI_UNSUPPORTED The driver specified by This is not currently
428 managing the controller specified by
429 ControllerHandle and ChildHandle.
430
431 @retval EFI_UNSUPPORTED The driver specified by This does not support
432 the language specified by Language.
433
434 **/
435 EFI_STATUS
436 EFIAPI
437 AtapiScsiPassThruComponentNameGetControllerName (
438 IN EFI_COMPONENT_NAME_PROTOCOL *This,
439 IN EFI_HANDLE ControllerHandle,
440 IN EFI_HANDLE ChildHandle OPTIONAL,
441 IN CHAR8 *Language,
442 OUT CHAR16 **ControllerName
443 );
444
445
446 EFI_STATUS
447 EFIAPI
448 AtapiScsiPassThruDriverEntryPoint (
449 IN EFI_HANDLE ImageHandle,
450 IN EFI_SYSTEM_TABLE *SystemTable
451 )
452 /*++
453
454 Routine Description:
455
456 Entry point for EFI drivers.
457
458 Arguments:
459
460 ImageHandle - EFI_HANDLE
461 SystemTable - EFI_SYSTEM_TABLE
462
463 Returns:
464
465 EFI_SUCCESS
466 Others
467
468 --*/
469 ;
470
471 EFI_STATUS
472 RegisterAtapiScsiPassThru (
473 IN EFI_DRIVER_BINDING_PROTOCOL *This,
474 IN EFI_HANDLE Controller,
475 IN EFI_PCI_IO_PROTOCOL *PciIo,
476 IN UINT64 OriginalPciAttributes
477 )
478 /*++
479
480 Routine Description:
481 Attaches SCSI Pass Thru Protocol for specified IDE channel.
482
483 Arguments:
484 This - Protocol instance pointer.
485 Controller - Parent device handle to the IDE channel.
486 PciIo - PCI I/O protocol attached on the "Controller".
487
488 Returns:
489 Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.
490
491 --*/
492 ;
493
494 EFI_STATUS
495 EFIAPI
496 AtapiScsiPassThruFunction (
497 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,
498 IN UINT32 Target,
499 IN UINT64 Lun,
500 IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
501 IN EFI_EVENT Event OPTIONAL
502 )
503 /*++
504
505 Routine Description:
506
507 Implements EFI_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
508
509 Arguments:
510
511 This: The EFI_SCSI_PASS_THRU_PROTOCOL instance.
512 Target: The Target ID of the ATAPI device to send the SCSI
513 Request Packet. To ATAPI devices attached on an IDE
514 Channel, Target ID 0 indicates Master device;Target
515 ID 1 indicates Slave device.
516 Lun: The LUN of the ATAPI device to send the SCSI Request
517 Packet. To the ATAPI device, Lun is always 0.
518 Packet: The SCSI Request Packet to send to the ATAPI device
519 specified by Target and Lun.
520 Event: If non-blocking I/O is not supported then Event is ignored,
521 and blocking I/O is performed.
522 If Event is NULL, then blocking I/O is performed.
523 If Event is not NULL and non blocking I/O is supported,
524 then non-blocking I/O is performed, and Event will be signaled
525 when the SCSI Request Packet completes.
526
527 Returns:
528
529 EFI_STATUS
530
531 --*/
532 ;
533
534 EFI_STATUS
535 EFIAPI
536 AtapiScsiPassThruGetNextDevice (
537 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,
538 IN OUT UINT32 *Target,
539 IN OUT UINT64 *Lun
540 )
541 /*++
542
543 Routine Description:
544
545 Used to retrieve the list of legal Target IDs for SCSI devices
546 on a SCSI channel.
547
548 Arguments:
549
550 This - Protocol instance pointer.
551 Target - On input, a pointer to the Target ID of a SCSI
552 device present on the SCSI channel. On output,
553 a pointer to the Target ID of the next SCSI device
554 present on a SCSI channel. An input value of
555 0xFFFFFFFF retrieves the Target ID of the first
556 SCSI device present on a SCSI channel.
557 Lun - On input, a pointer to the LUN of a SCSI device
558 present on the SCSI channel. On output, a pointer
559 to the LUN of the next SCSI device present on
560 a SCSI channel.
561 Returns:
562
563 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
564 on the SCSI channel was returned in Target and Lun.
565 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
566 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
567 returned on a previous call to GetNextDevice().
568
569 --*/
570 ;
571
572 EFI_STATUS
573 EFIAPI
574 AtapiScsiPassThruBuildDevicePath (
575 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,
576 IN UINT32 Target,
577 IN UINT64 Lun,
578 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
579 )
580 /*++
581
582 Routine Description:
583
584 Used to allocate and build a device path node for a SCSI device
585 on a SCSI channel. Would not build device path for a SCSI Host Controller.
586
587 Arguments:
588
589 This - Protocol instance pointer.
590 Target - The Target ID of the SCSI device for which
591 a device path node is to be allocated and built.
592 Lun - The LUN of the SCSI device for which a device
593 path node is to be allocated and built.
594 DevicePath - A pointer to a single device path node that
595 describes the SCSI device specified by
596 Target and Lun. This function is responsible
597 for allocating the buffer DevicePath with the boot
598 service AllocatePool(). It is the caller's
599 responsibility to free DevicePath when the caller
600 is finished with DevicePath.
601 Returns:
602 EFI_SUCCESS - The device path node that describes the SCSI device
603 specified by Target and Lun was allocated and
604 returned in DevicePath.
605 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
606 not exist on the SCSI channel.
607 EFI_INVALID_PARAMETER - DevicePath is NULL.
608 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
609 DevicePath.
610
611 --*/
612 ;
613
614 EFI_STATUS
615 EFIAPI
616 AtapiScsiPassThruGetTargetLun (
617 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,
618 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
619 OUT UINT32 *Target,
620 OUT UINT64 *Lun
621 )
622 /*++
623
624 Routine Description:
625
626 Used to translate a device path node to a Target ID and LUN.
627
628 Arguments:
629
630 This - Protocol instance pointer.
631 DevicePath - A pointer to the device path node that
632 describes a SCSI device on the SCSI channel.
633 Target - A pointer to the Target ID of a SCSI device
634 on the SCSI channel.
635 Lun - A pointer to the LUN of a SCSI device on
636 the SCSI channel.
637 Returns:
638
639 EFI_SUCCESS - DevicePath was successfully translated to a
640 Target ID and LUN, and they were returned
641 in Target and Lun.
642 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
643 EFI_UNSUPPORTED - This driver does not support the device path
644 node type in DevicePath.
645 EFI_NOT_FOUND - A valid translation from DevicePath to a
646 Target ID and LUN does not exist.
647
648 --*/
649 ;
650
651 EFI_STATUS
652 EFIAPI
653 AtapiScsiPassThruResetChannel (
654 IN EFI_SCSI_PASS_THRU_PROTOCOL *This
655 )
656 /*++
657
658 Routine Description:
659
660 Resets a SCSI channel.This operation resets all the
661 SCSI devices connected to the SCSI channel.
662
663 Arguments:
664
665 This - Protocol instance pointer.
666
667 Returns:
668
669 EFI_SUCCESS - The SCSI channel was reset.
670 EFI_UNSUPPORTED - The SCSI channel does not support
671 a channel reset operation.
672 EFI_DEVICE_ERROR - A device error occurred while
673 attempting to reset the SCSI channel.
674 EFI_TIMEOUT - A timeout occurred while attempting
675 to reset the SCSI channel.
676
677 --*/
678 ;
679
680 EFI_STATUS
681 EFIAPI
682 AtapiScsiPassThruResetTarget (
683 IN EFI_SCSI_PASS_THRU_PROTOCOL *This,
684 IN UINT32 Target,
685 IN UINT64 Lun
686 )
687 /*++
688
689 Routine Description:
690
691 Resets a SCSI device that is connected to a SCSI channel.
692
693 Arguments:
694
695 This - Protocol instance pointer.
696 Target - The Target ID of the SCSI device to reset.
697 Lun - The LUN of the SCSI device to reset.
698
699 Returns:
700
701 EFI_SUCCESS - The SCSI device specified by Target and
702 Lun was reset.
703 EFI_UNSUPPORTED - The SCSI channel does not support a target
704 reset operation.
705 EFI_INVALID_PARAMETER - Target or Lun are invalid.
706 EFI_DEVICE_ERROR - A device error occurred while attempting
707 to reset the SCSI device specified by Target
708 and Lun.
709 EFI_TIMEOUT - A timeout occurred while attempting to reset
710 the SCSI device specified by Target and Lun.
711
712 --*/
713 ;
714
715 EFI_STATUS
716 EFIAPI
717 AtapiExtScsiPassThruFunction (
718 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
719 IN UINT8 *Target,
720 IN UINT64 Lun,
721 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
722 IN EFI_EVENT Event OPTIONAL
723 )
724 /*++
725
726 Routine Description:
727
728 Implements EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
729
730 Arguments:
731
732 This: The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
733 Target: The Target ID of the ATAPI device to send the SCSI
734 Request Packet. To ATAPI devices attached on an IDE
735 Channel, Target ID 0 indicates Master device;Target
736 ID 1 indicates Slave device.
737 Lun: The LUN of the ATAPI device to send the SCSI Request
738 Packet. To the ATAPI device, Lun is always 0.
739 Packet: The SCSI Request Packet to send to the ATAPI device
740 specified by Target and Lun.
741 Event: If non-blocking I/O is not supported then Event is ignored,
742 and blocking I/O is performed.
743 If Event is NULL, then blocking I/O is performed.
744 If Event is not NULL and non blocking I/O is supported,
745 then non-blocking I/O is performed, and Event will be signaled
746 when the SCSI Request Packet completes.
747
748 Returns:
749
750 EFI_STATUS
751
752 --*/
753 ;
754
755 EFI_STATUS
756 EFIAPI
757 AtapiExtScsiPassThruGetNextTargetLun (
758 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
759 IN OUT UINT8 **Target,
760 IN OUT UINT64 *Lun
761 )
762 /*++
763
764 Routine Description:
765
766 Used to retrieve the list of legal Target IDs for SCSI devices
767 on a SCSI channel.
768
769 Arguments:
770
771 This - Protocol instance pointer.
772 Target - On input, a pointer to the Target ID of a SCSI
773 device present on the SCSI channel. On output,
774 a pointer to the Target ID of the next SCSI device
775 present on a SCSI channel. An input value of
776 0xFFFFFFFF retrieves the Target ID of the first
777 SCSI device present on a SCSI channel.
778 Lun - On input, a pointer to the LUN of a SCSI device
779 present on the SCSI channel. On output, a pointer
780 to the LUN of the next SCSI device present on
781 a SCSI channel.
782 Returns:
783
784 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
785 on the SCSI channel was returned in Target and Lun.
786 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
787 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
788 returned on a previous call to GetNextDevice().
789
790 --*/
791 ;
792
793 EFI_STATUS
794 EFIAPI
795 AtapiExtScsiPassThruBuildDevicePath (
796 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
797 IN UINT8 *Target,
798 IN UINT64 Lun,
799 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
800 )
801 /*++
802
803 Routine Description:
804
805 Used to allocate and build a device path node for a SCSI device
806 on a SCSI channel. Would not build device path for a SCSI Host Controller.
807
808 Arguments:
809
810 This - Protocol instance pointer.
811 Target - The Target ID of the SCSI device for which
812 a device path node is to be allocated and built.
813 Lun - The LUN of the SCSI device for which a device
814 path node is to be allocated and built.
815 DevicePath - A pointer to a single device path node that
816 describes the SCSI device specified by
817 Target and Lun. This function is responsible
818 for allocating the buffer DevicePath with the boot
819 service AllocatePool(). It is the caller's
820 responsibility to free DevicePath when the caller
821 is finished with DevicePath.
822 Returns:
823 EFI_SUCCESS - The device path node that describes the SCSI device
824 specified by Target and Lun was allocated and
825 returned in DevicePath.
826 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
827 not exist on the SCSI channel.
828 EFI_INVALID_PARAMETER - DevicePath is NULL.
829 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
830 DevicePath.
831
832 --*/
833 ;
834
835 EFI_STATUS
836 EFIAPI
837 AtapiExtScsiPassThruGetTargetLun (
838 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
839 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
840 OUT UINT8 **Target,
841 OUT UINT64 *Lun
842 )
843 /*++
844
845 Routine Description:
846
847 Used to translate a device path node to a Target ID and LUN.
848
849 Arguments:
850
851 This - Protocol instance pointer.
852 DevicePath - A pointer to the device path node that
853 describes a SCSI device on the SCSI channel.
854 Target - A pointer to the Target ID of a SCSI device
855 on the SCSI channel.
856 Lun - A pointer to the LUN of a SCSI device on
857 the SCSI channel.
858 Returns:
859
860 EFI_SUCCESS - DevicePath was successfully translated to a
861 Target ID and LUN, and they were returned
862 in Target and Lun.
863 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
864 EFI_UNSUPPORTED - This driver does not support the device path
865 node type in DevicePath.
866 EFI_NOT_FOUND - A valid translation from DevicePath to a
867 Target ID and LUN does not exist.
868
869 --*/
870 ;
871
872 EFI_STATUS
873 EFIAPI
874 AtapiExtScsiPassThruResetChannel (
875 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
876 )
877 /*++
878
879 Routine Description:
880
881 Resets a SCSI channel.This operation resets all the
882 SCSI devices connected to the SCSI channel.
883
884 Arguments:
885
886 This - Protocol instance pointer.
887
888 Returns:
889
890 EFI_SUCCESS - The SCSI channel was reset.
891 EFI_UNSUPPORTED - The SCSI channel does not support
892 a channel reset operation.
893 EFI_DEVICE_ERROR - A device error occurred while
894 attempting to reset the SCSI channel.
895 EFI_TIMEOUT - A timeout occurred while attempting
896 to reset the SCSI channel.
897
898 --*/
899 ;
900
901 EFI_STATUS
902 EFIAPI
903 AtapiExtScsiPassThruResetTarget (
904 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
905 IN UINT8 *Target,
906 IN UINT64 Lun
907 )
908 /*++
909
910 Routine Description:
911
912 Resets a SCSI device that is connected to a SCSI channel.
913
914 Arguments:
915
916 This - Protocol instance pointer.
917 Target - The Target ID of the SCSI device to reset.
918 Lun - The LUN of the SCSI device to reset.
919
920 Returns:
921
922 EFI_SUCCESS - The SCSI device specified by Target and
923 Lun was reset.
924 EFI_UNSUPPORTED - The SCSI channel does not support a target
925 reset operation.
926 EFI_INVALID_PARAMETER - Target or Lun are invalid.
927 EFI_DEVICE_ERROR - A device error occurred while attempting
928 to reset the SCSI device specified by Target
929 and Lun.
930 EFI_TIMEOUT - A timeout occurred while attempting to reset
931 the SCSI device specified by Target and Lun.
932
933 --*/
934 ;
935
936 EFI_STATUS
937 EFIAPI
938 AtapiExtScsiPassThruGetNextTarget (
939 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
940 IN OUT UINT8 **Target
941 )
942 /*++
943
944 Routine Description:
945 Used to retrieve the list of legal Target IDs for SCSI devices
946 on a SCSI channel.
947
948 Arguments:
949 This - Protocol instance pointer.
950 Target - On input, a pointer to the Target ID of a SCSI
951 device present on the SCSI channel. On output,
952 a pointer to the Target ID of the next SCSI device
953 present on a SCSI channel. An input value of
954 0xFFFFFFFF retrieves the Target ID of the first
955 SCSI device present on a SCSI channel.
956 Lun - On input, a pointer to the LUN of a SCSI device
957 present on the SCSI channel. On output, a pointer
958 to the LUN of the next SCSI device present on
959 a SCSI channel.
960
961 Returns:
962 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
963 on the SCSI channel was returned in Target and Lun.
964 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
965 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
966 returned on a previous call to GetNextDevice().
967
968 --*/
969 ;
970
971 EFI_STATUS
972 CheckSCSIRequestPacket (
973 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
974 )
975 /*++
976
977 Routine Description:
978
979 Checks the parameters in the SCSI Request Packet to make sure
980 they are valid for a SCSI Pass Thru request.
981
982 Arguments:
983
984 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
985
986 Returns:
987
988 EFI_STATUS
989
990 --*/
991 ;
992
993 EFI_STATUS
994 SubmitBlockingIoCommand (
995 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
996 UINT32 Target,
997 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
998 )
999 /*++
1000
1001 Routine Description:
1002
1003 Performs blocking I/O request.
1004
1005 Arguments:
1006
1007 AtapiScsiPrivate: Private data structure for the specified channel.
1008 Target: The Target ID of the ATAPI device to send the SCSI
1009 Request Packet. To ATAPI devices attached on an IDE
1010 Channel, Target ID 0 indicates Master device;Target
1011 ID 1 indicates Slave device.
1012 Packet: The SCSI Request Packet to send to the ATAPI device
1013 specified by Target.
1014
1015 Returns: EFI_STATUS
1016
1017 --*/
1018 ;
1019
1020 BOOLEAN
1021 IsCommandValid (
1022 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
1023 )
1024 /*++
1025
1026 Routine Description:
1027
1028 Checks the requested SCSI command:
1029 Is it supported by this driver?
1030 Is the Data transfer direction reasonable?
1031
1032 Arguments:
1033
1034 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1035
1036 Returns:
1037
1038 EFI_STATUS
1039
1040 --*/
1041 ;
1042
1043 EFI_STATUS
1044 CheckExtSCSIRequestPacket (
1045 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
1046 )
1047 /*++
1048
1049 Routine Description:
1050
1051 Checks the parameters in the SCSI Request Packet to make sure
1052 they are valid for a SCSI Pass Thru request.
1053
1054 Arguments:
1055
1056 Packet - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1057
1058 Returns:
1059
1060 EFI_STATUS
1061
1062 --*/
1063 ;
1064
1065
1066 BOOLEAN
1067 IsExtCommandValid (
1068 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
1069 )
1070 /*++
1071
1072 Routine Description:
1073
1074 Checks the requested SCSI command:
1075 Is it supported by this driver?
1076 Is the Data transfer direction reasonable?
1077
1078 Arguments:
1079
1080 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1081
1082 Returns:
1083
1084 EFI_STATUS
1085
1086 --*/
1087 ;
1088
1089 EFI_STATUS
1090 SubmitExtBlockingIoCommand (
1091 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1092 UINT8 Target,
1093 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet
1094 )
1095 /*++
1096
1097 Routine Description:
1098
1099 Performs blocking I/O request.
1100
1101 Arguments:
1102
1103 AtapiScsiPrivate: Private data structure for the specified channel.
1104 Target: The Target ID of the ATAPI device to send the SCSI
1105 Request Packet. To ATAPI devices attached on an IDE
1106 Channel, Target ID 0 indicates Master device;Target
1107 ID 1 indicates Slave device.
1108 Packet: The SCSI Request Packet to send to the ATAPI device
1109 specified by Target.
1110
1111 Returns: EFI_STATUS
1112
1113 --*/
1114 ;
1115
1116 EFI_STATUS
1117 RequestSenseCommand (
1118 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1119 UINT32 Target,
1120 UINT64 Timeout,
1121 VOID *SenseData,
1122 UINT8 *SenseDataLength
1123 )
1124 /*++
1125
1126 Routine Description:
1127
1128 Sumbit request sense command
1129
1130 Arguments:
1131
1132 AtapiScsiPrivate - The pionter of ATAPI_SCSI_PASS_THRU_DEV
1133 Target - The target ID
1134 Timeout - The time to complete the command
1135 SenseData - The buffer to fill in sense data
1136 SenseDataLength - The length of buffer
1137
1138 Returns:
1139
1140 EFI_STATUS
1141
1142 --*/
1143 ;
1144
1145 EFI_STATUS
1146 AtapiPacketCommand (
1147 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1148 UINT32 Target,
1149 UINT8 *PacketCommand,
1150 VOID *Buffer,
1151 UINT32 *ByteCount,
1152 DATA_DIRECTION Direction,
1153 UINT64 TimeOutInMicroSeconds
1154 )
1155 /*++
1156
1157 Routine Description:
1158
1159 Submits ATAPI command packet to the specified ATAPI device.
1160
1161 Arguments:
1162
1163 AtapiScsiPrivate: Private data structure for the specified channel.
1164 Target: The Target ID of the ATAPI device to send the SCSI
1165 Request Packet. To ATAPI devices attached on an IDE
1166 Channel, Target ID 0 indicates Master device;Target
1167 ID 1 indicates Slave device.
1168 PacketCommand: Points to the ATAPI command packet.
1169 Buffer: Points to the transferred data.
1170 ByteCount: When input,indicates the buffer size; when output,
1171 indicates the actually transferred data size.
1172 Direction: Indicates the data transfer direction.
1173 TimeoutInMicroSeconds:
1174 The timeout, in micro second units, to use for the
1175 execution of this ATAPI command.
1176 A TimeoutInMicroSeconds value of 0 means that
1177 this function will wait indefinitely for the ATAPI
1178 command to execute.
1179 If TimeoutInMicroSeconds is greater than zero, then
1180 this function will return EFI_TIMEOUT if the time
1181 required to execute the ATAPI command is greater
1182 than TimeoutInMicroSeconds.
1183
1184 Returns:
1185
1186 EFI_STATUS
1187
1188 --*/
1189 ;
1190
1191
1192 UINT8
1193 ReadPortB (
1194 IN EFI_PCI_IO_PROTOCOL *PciIo,
1195 IN UINT16 Port
1196 )
1197 /*++
1198
1199 Routine Description:
1200
1201 Read one byte from a specified I/O port.
1202
1203 Arguments:
1204
1205 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1206 Port - IO port
1207
1208 Returns:
1209
1210 A byte read out
1211
1212 --*/
1213 ;
1214
1215
1216 UINT16
1217 ReadPortW (
1218 IN EFI_PCI_IO_PROTOCOL *PciIo,
1219 IN UINT16 Port
1220 )
1221 /*++
1222
1223 Routine Description:
1224
1225 Read one word from a specified I/O port.
1226
1227 Arguments:
1228
1229 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1230 Port - IO port
1231
1232 Returns:
1233
1234 A word read out
1235
1236 --*/
1237 ;
1238
1239
1240 VOID
1241 WritePortB (
1242 IN EFI_PCI_IO_PROTOCOL *PciIo,
1243 IN UINT16 Port,
1244 IN UINT8 Data
1245 )
1246 /*++
1247
1248 Routine Description:
1249
1250 Write one byte to a specified I/O port.
1251
1252 Arguments:
1253
1254 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1255 Port - IO port
1256 Data - The data to write
1257
1258 Returns:
1259
1260 NONE
1261
1262 --*/
1263 ;
1264
1265
1266 VOID
1267 WritePortW (
1268 IN EFI_PCI_IO_PROTOCOL *PciIo,
1269 IN UINT16 Port,
1270 IN UINT16 Data
1271 )
1272 /*++
1273
1274 Routine Description:
1275
1276 Write one word to a specified I/O port.
1277
1278 Arguments:
1279
1280 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1281 Port - IO port
1282 Data - The data to write
1283
1284 Returns:
1285
1286 NONE
1287
1288 --*/
1289 ;
1290
1291 EFI_STATUS
1292 StatusDRQClear (
1293 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1294 UINT64 TimeOutInMicroSeconds
1295 )
1296 /*++
1297
1298 Routine Description:
1299
1300 Check whether DRQ is clear in the Status Register. (BSY must also be cleared)
1301 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1302 DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1303 elapsed.
1304
1305 Arguments:
1306
1307 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1308 TimeoutInMicroSeconds - The time to wait for
1309
1310 Returns:
1311
1312 EFI_STATUS
1313
1314 --*/
1315 ;
1316
1317 EFI_STATUS
1318 AltStatusDRQClear (
1319 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1320 UINT64 TimeOutInMicroSeconds
1321 )
1322 /*++
1323
1324 Routine Description:
1325
1326 Check whether DRQ is clear in the Alternate Status Register.
1327 (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should
1328 wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1329 elapsed.
1330
1331 Arguments:
1332
1333 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1334 TimeoutInMicroSeconds - The time to wait for
1335
1336 Returns:
1337
1338 EFI_STATUS
1339
1340 --*/
1341 ;
1342
1343 EFI_STATUS
1344 StatusDRQReady (
1345 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1346 UINT64 TimeOutInMicroSeconds
1347 )
1348 /*++
1349
1350 Routine Description:
1351
1352 Check whether DRQ is ready in the Status Register. (BSY must also be cleared)
1353 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1354 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1355 elapsed.
1356
1357 Arguments:
1358
1359 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1360 TimeoutInMicroSeconds - The time to wait for
1361
1362 Returns:
1363
1364 EFI_STATUS
1365
1366 --*/
1367 ;
1368
1369 EFI_STATUS
1370 AltStatusDRQReady (
1371 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1372 UINT64 TimeOutInMicroSeconds
1373 )
1374 /*++
1375
1376 Routine Description:
1377
1378 Check whether DRQ is ready in the Alternate Status Register.
1379 (BSY must also be cleared)
1380 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1381 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1382 elapsed.
1383
1384 Arguments:
1385
1386 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1387 TimeoutInMicroSeconds - The time to wait for
1388
1389 Returns:
1390
1391 EFI_STATUS
1392
1393 --*/
1394 ;
1395
1396 EFI_STATUS
1397 StatusWaitForBSYClear (
1398 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1399 UINT64 TimeoutInMicroSeconds
1400 )
1401 /*++
1402
1403 Routine Description:
1404
1405 Check whether BSY is clear in the Status Register.
1406 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1407 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1408 elapsed.
1409
1410 Arguments:
1411
1412 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1413 TimeoutInMicroSeconds - The time to wait for
1414
1415 Returns:
1416
1417 EFI_STATUS
1418
1419 --*/
1420 ;
1421
1422 EFI_STATUS
1423 AltStatusWaitForBSYClear (
1424 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1425 UINT64 TimeoutInMicroSeconds
1426 )
1427 /*++
1428
1429 Routine Description:
1430
1431 Check whether BSY is clear in the Alternate Status Register.
1432 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1433 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1434 elapsed.
1435
1436 Arguments:
1437
1438 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1439 TimeoutInMicroSeconds - The time to wait for
1440
1441 Returns:
1442
1443 EFI_STATUS
1444
1445 --*/
1446 ;
1447
1448 EFI_STATUS
1449 StatusDRDYReady (
1450 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1451 UINT64 TimeoutInMicroSeconds
1452 )
1453 /*++
1454
1455 Routine Description:
1456
1457 Check whether DRDY is ready in the Status Register.
1458 (BSY must also be cleared)
1459 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1460 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1461 elapsed.
1462
1463 Arguments:
1464
1465 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1466 TimeoutInMicroSeconds - The time to wait for
1467
1468 Returns:
1469
1470 EFI_STATUS
1471
1472 --*/
1473 ;
1474
1475 EFI_STATUS
1476 AltStatusDRDYReady (
1477 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1478 UINT64 TimeoutInMicroSeconds
1479 )
1480 /*++
1481
1482 Routine Description:
1483
1484 Check whether DRDY is ready in the Alternate Status Register.
1485 (BSY must also be cleared)
1486 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1487 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1488 elapsed.
1489
1490 Arguments:
1491
1492 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1493 TimeoutInMicroSeconds - The time to wait for
1494
1495 Returns:
1496
1497 EFI_STATUS
1498
1499 --*/
1500 ;
1501
1502 EFI_STATUS
1503 AtapiPassThruPioReadWriteData (
1504 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1505 UINT16 *Buffer,
1506 UINT32 *ByteCount,
1507 DATA_DIRECTION Direction,
1508 UINT64 TimeOutInMicroSeconds
1509 )
1510 /*++
1511
1512 Routine Description:
1513
1514 Performs data transfer between ATAPI device and host after the
1515 ATAPI command packet is sent.
1516
1517 Arguments:
1518
1519 AtapiScsiPrivate: Private data structure for the specified channel.
1520 Buffer: Points to the transferred data.
1521 ByteCount: When input,indicates the buffer size; when output,
1522 indicates the actually transferred data size.
1523 Direction: Indicates the data transfer direction.
1524 TimeoutInMicroSeconds:
1525 The timeout, in micro second units, to use for the
1526 execution of this ATAPI command.
1527 A TimeoutInMicroSeconds value of 0 means that
1528 this function will wait indefinitely for the ATAPI
1529 command to execute.
1530 If TimeoutInMicroSeconds is greater than zero, then
1531 this function will return EFI_TIMEOUT if the time
1532 required to execute the ATAPI command is greater
1533 than TimeoutInMicroSeconds.
1534 Returns:
1535
1536 EFI_STATUS
1537
1538 --*/
1539 ;
1540
1541 EFI_STATUS
1542 AtapiPassThruCheckErrorStatus (
1543 ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate
1544 )
1545 /*++
1546
1547 Routine Description:
1548
1549 Check Error Register for Error Information.
1550
1551 Arguments:
1552
1553 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1554
1555 Returns:
1556
1557 EFI_STATUS
1558
1559 --*/
1560 ;
1561
1562
1563 EFI_STATUS
1564 GetIdeRegistersBaseAddr (
1565 IN EFI_PCI_IO_PROTOCOL *PciIo,
1566 OUT IDE_REGISTERS_BASE_ADDR *IdeRegsBaseAddr
1567 )
1568 /*++
1569
1570 Routine Description:
1571 Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
1572 use fixed addresses. In Native-PCI mode, get base addresses from BARs in
1573 the PCI IDE controller's Configuration Space.
1574
1575 Arguments:
1576 PciIo - Pointer to the EFI_PCI_IO_PROTOCOL instance
1577 IdeRegsBaseAddr - Pointer to IDE_REGISTERS_BASE_ADDR to
1578 receive IDE IO port registers' base addresses
1579
1580 Returns:
1581
1582 EFI_STATUS
1583
1584 --*/
1585 ;
1586
1587
1588 VOID
1589 InitAtapiIoPortRegisters (
1590 IN ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate,
1591 IN IDE_REGISTERS_BASE_ADDR *IdeRegsBaseAddr
1592 )
1593 /*++
1594
1595 Routine Description:
1596
1597 Initialize each Channel's Base Address of CommandBlock and ControlBlock.
1598
1599 Arguments:
1600
1601 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1602 IdeRegsBaseAddr - The pointer of IDE_REGISTERS_BASE_ADDR
1603
1604 Returns:
1605
1606 None
1607
1608 --*/
1609 ;
1610
1611 /**
1612 Installs Scsi Pass Thru and/or Ext Scsi Pass Thru
1613 protocols based on feature flags.
1614
1615 @param Controller The controller handle to
1616 install these protocols on.
1617 @param AtapiScsiPrivate A pointer to the protocol private
1618 data structure.
1619
1620 @retval EFI_SUCCESS The installation succeeds.
1621 @retval other The installation fails.
1622
1623 **/
1624 EFI_STATUS
1625 InstallScsiPassThruProtocols (
1626 IN EFI_HANDLE *ControllerHandle,
1627 IN ATAPI_SCSI_PASS_THRU_DEV *AtapiScsiPrivate
1628 );
1629
1630 #endif