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