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