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