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