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