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