TianoCore EDK2 master
Loading...
Searching...
No Matches
AtaAtapiPassThru.h
Go to the documentation of this file.
1
9#ifndef __ATA_ATAPI_PASS_THRU_H__
10#define __ATA_ATAPI_PASS_THRU_H__
11
12#include <Uefi.h>
13
17
18#include <Protocol/PciIo.h>
23
24#include <Library/DebugLib.h>
25#include <Library/BaseLib.h>
29#include <Library/UefiLib.h>
30#include <Library/PciLib.h>
31#include <Library/PcdLib.h>
32#include <Library/TimerLib.h>
36
37#include "IdeMode.h"
38#include "AhciMode.h"
39
40extern EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding;
41extern EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComponentName;
42extern EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2;
43
44extern EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy;
45
46#define ATA_ATAPI_PASS_THRU_SIGNATURE SIGNATURE_32 ('a', 'a', 'p', 't')
47#define ATA_ATAPI_DEVICE_SIGNATURE SIGNATURE_32 ('a', 'd', 'e', 'v')
48#define ATA_NONBLOCKING_TASK_SIGNATURE SIGNATURE_32 ('a', 't', 's', 'k')
49
51
52typedef enum {
53 EfiAtaIdeMode,
54 EfiAtaAhciMode,
55 EfiAtaRaidMode,
56 EfiAtaUnknownMode
57} EFI_ATA_HC_WORK_MODE;
58
59typedef enum {
60 EfiIdeCdrom, /* ATAPI CDROM */
61 EfiIdeHarddisk, /* Hard Disk */
62 EfiPortMultiplier, /* Port Multiplier */
63 EfiIdeUnknown
64} EFI_ATA_DEVICE_TYPE;
65
66//
67// Ahci mode device info
68//
69typedef struct {
70 UINT32 Signature;
71 LIST_ENTRY Link;
72
73 UINT16 Port;
74 UINT16 PortMultiplier;
75 EFI_ATA_DEVICE_TYPE Type;
76
77 EFI_IDENTIFY_DATA *IdentifyData;
79
80typedef struct {
81 UINT32 Signature;
82
83 EFI_HANDLE ControllerHandle;
85 EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;
86
87 EFI_ATA_PASS_THRU_MODE AtaPassThruMode;
89 EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;
90 EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru;
91
92 EFI_ATA_HC_WORK_MODE Mode;
93
94 EFI_IDE_REGISTERS IdeRegisters[EfiIdeMaxChannel];
95 EFI_AHCI_REGISTERS AhciRegisters;
96
97 //
98 // The attached device list
99 //
100 LIST_ENTRY DeviceList;
101 UINT64 EnabledPciAttributes;
102 UINT64 OriginalPciAttributes;
103
104 //
105 // For AtaPassThru protocol, using the following bytes to record the previous call in
106 // GetNextPort()/GetNextDevice().
107 //
108 UINT16 PreviousPort;
109 UINT16 PreviousPortMultiplier;
110 //
111 // For ExtScsiPassThru protocol, using the following bytes to record the previous call in
112 // GetNextTarget()/GetNextTargetLun().
113 //
114 UINT16 PreviousTargetId;
115 UINT64 PreviousLun;
116
117 //
118 // For Non-blocking.
119 //
120 EFI_EVENT TimerEvent;
121 LIST_ENTRY NonBlockingTaskList;
123
124//
125// Task for Non-blocking mode.
126//
128 UINT32 Signature;
129 LIST_ENTRY Link;
130
131 UINT16 Port;
132 UINT16 PortMultiplier;
134 BOOLEAN IsStart;
135 EFI_EVENT Event;
136 UINT64 RetryTimes;
137 BOOLEAN InfiniteWait;
138 VOID *Map; // Pointer to map.
139 VOID *TableMap; // Pointer to PRD table map.
140 EFI_ATA_DMA_PRD *MapBaseAddress; // Pointer to range Base address for Map.
141 UINTN PageCount; // The page numbers used by PCIO freebuffer.
142};
143
144//
145// Timeout value which uses 100ns as a unit.
146// It means 3 second span.
147//
148#define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3)
149#define ATA_SPINUP_TIMEOUT EFI_TIMER_PERIOD_SECONDS(10)
150
151#define ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
152 CR (a, \
153 ATA_ATAPI_PASS_THRU_INSTANCE, \
154 AtaPassThru, \
155 ATA_ATAPI_PASS_THRU_SIGNATURE \
156 )
157
158#define EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
159 CR (a, \
160 ATA_ATAPI_PASS_THRU_INSTANCE, \
161 ExtScsiPassThru, \
162 ATA_ATAPI_PASS_THRU_SIGNATURE \
163 )
164
165#define ATA_ATAPI_DEVICE_INFO_FROM_THIS(a) \
166 CR (a, \
167 EFI_ATA_DEVICE_INFO, \
168 Link, \
169 ATA_ATAPI_DEVICE_SIGNATURE \
170 );
171
172#define ATA_NON_BLOCK_TASK_FROM_ENTRY(a) \
173 CR (a, \
174 ATA_NONBLOCK_TASK, \
175 Link, \
176 ATA_NONBLOCKING_TASK_SIGNATURE \
177 );
178
219EFIAPI
222 IN CHAR8 *Language,
223 OUT CHAR16 **DriverName
224 );
225
295EFIAPI
298 IN EFI_HANDLE ControllerHandle,
299 IN EFI_HANDLE ChildHandle OPTIONAL,
300 IN CHAR8 *Language,
301 OUT CHAR16 **ControllerName
302 );
303
347EFIAPI
350 IN EFI_HANDLE Controller,
351 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
352 );
353
390EFIAPI
393 IN EFI_HANDLE Controller,
394 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
395 );
396
424EFIAPI
427 IN EFI_HANDLE Controller,
428 IN UINTN NumberOfChildren,
429 IN EFI_HANDLE *ChildHandleBuffer
430 );
431
445EFIAPI
448 IN UINT16 Port,
449 IN UINT16 PortMultiplier,
450 IN EFI_ATA_DEVICE_TYPE DeviceType
451 );
452
469EFIAPI
472 IN UINT16 Port,
473 IN UINT16 PortMultiplier,
474 IN EFI_ATA_DEVICE_TYPE DeviceType,
475 IN EFI_IDENTIFY_DATA *IdentifyData
476 );
477
484VOID
485EFIAPI
488 );
489
498VOID
499EFIAPI
502 IN BOOLEAN IsSigEvent
503 );
504
517EFIAPI
520 );
521
530VOID
531EFIAPI
533 EFI_EVENT Event,
534 VOID *Context
535 );
536
567EFIAPI
570 IN UINT16 Port,
571 IN UINT16 PortMultiplierPort,
573 IN EFI_EVENT Event OPTIONAL
574 );
575
608EFIAPI
611 IN OUT UINT16 *Port
612 );
613
657EFIAPI
660 IN UINT16 Port,
661 IN OUT UINT16 *PortMultiplierPort
662 );
663
697EFIAPI
700 IN UINT16 Port,
701 IN UINT16 PortMultiplierPort,
702 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
703 );
704
743EFIAPI
746 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
747 OUT UINT16 *Port,
748 OUT UINT16 *PortMultiplierPort
749 );
750
776EFIAPI
779 IN UINT16 Port
780 );
781
814EFIAPI
817 IN UINT16 Port,
818 IN UINT16 PortMultiplierPort
819 );
820
863EFIAPI
866 IN UINT8 *Target,
867 IN UINT64 Lun,
869 IN EFI_EVENT Event OPTIONAL
870 );
871
899EFIAPI
902 IN OUT UINT8 **Target,
903 IN OUT UINT64 *Lun
904 );
905
934EFIAPI
937 IN UINT8 *Target,
938 IN UINT64 Lun,
939 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
940 );
941
962EFIAPI
965 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
966 OUT UINT8 **Target,
967 OUT UINT64 *Lun
968 );
969
982EFIAPI
985 );
986
1007EFIAPI
1010 IN UINT8 *Target,
1011 IN UINT64 Lun
1012 );
1013
1037EFIAPI
1040 IN OUT UINT8 **Target
1041 );
1042
1052EFIAPI
1055 );
1056
1066EFIAPI
1069 );
1070
1094EFIAPI
1096 IN EFI_PCI_IO_PROTOCOL *PciIo,
1097 IN EFI_AHCI_REGISTERS *AhciRegisters,
1098 IN UINT8 Port,
1099 IN UINT8 PortMultiplier,
1100 IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
1101 IN UINT8 AtapiCommandLength,
1102 IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
1103 IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
1104 IN UINT64 Timeout,
1105 IN ATA_NONBLOCK_TASK *Task
1106 );
1107
1134EFIAPI
1137 IN EFI_AHCI_REGISTERS *AhciRegisters,
1138 IN UINT8 Port,
1139 IN UINT8 PortMultiplier,
1140 IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
1141 IN UINT8 AtapiCommandLength,
1142 IN BOOLEAN Read,
1143 IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
1144 IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
1145 IN OUT VOID *MemoryAddr,
1146 IN UINT32 DataCount,
1147 IN UINT64 Timeout,
1148 IN ATA_NONBLOCK_TASK *Task
1149 );
1150
1177EFIAPI
1179 IN EFI_PCI_IO_PROTOCOL *PciIo,
1180 IN EFI_AHCI_REGISTERS *AhciRegisters,
1181 IN UINT8 Port,
1182 IN UINT8 PortMultiplier,
1183 IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
1184 IN UINT8 AtapiCommandLength,
1185 IN BOOLEAN Read,
1186 IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
1187 IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
1188 IN OUT VOID *MemoryAddr,
1189 IN UINT32 DataCount,
1190 IN UINT64 Timeout,
1191 IN ATA_NONBLOCK_TASK *Task
1192 );
1193
1213EFIAPI
1215 IN EFI_PCI_IO_PROTOCOL *PciIo,
1216 IN EFI_IDE_REGISTERS *IdeRegisters,
1217 IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
1218 IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
1219 IN UINT64 Timeout,
1220 IN ATA_NONBLOCK_TASK *Task
1221 );
1222
1248EFIAPI
1251 IN EFI_IDE_REGISTERS *IdeRegisters,
1252 IN BOOLEAN Read,
1253 IN VOID *DataBuffer,
1254 IN UINT64 DataLength,
1255 IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
1256 IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
1257 IN UINT64 Timeout,
1258 IN ATA_NONBLOCK_TASK *Task
1259 );
1260
1284EFIAPI
1286 IN EFI_PCI_IO_PROTOCOL *PciIo,
1287 IN EFI_IDE_REGISTERS *IdeRegisters,
1288 IN OUT VOID *Buffer,
1289 IN UINT64 ByteCount,
1290 IN BOOLEAN Read,
1291 IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
1292 IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
1293 IN UINT64 Timeout,
1294 IN ATA_NONBLOCK_TASK *Task
1295 );
1296
1297#endif
UINT64 UINTN
EFI_STATUS EFIAPI AtaPioDataInOut(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN OUT VOID *Buffer, IN UINT64 ByteCount, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
Definition: IdeMode.c:934
VOID EFIAPI AsyncNonBlockingTransferRoutine(EFI_EVENT Event, VOID *Context)
EFI_STATUS EFIAPI ExtScsiPassThruGetTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINT8 **Target, OUT UINT64 *Lun)
EFI_STATUS EFIAPI AtaAtapiPassThruSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI ExtScsiPassThruResetTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun)
EFI_STATUS EFIAPI ExtScsiPassThruBuildDevicePath(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun, IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
EFI_STATUS EFIAPI ExtScsiPassThruGetNextTargetLun(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target, IN OUT UINT64 *Lun)
EFI_STATUS EFIAPI AhciModeInitialization(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance)
Definition: AhciMode.c:2863
EFI_STATUS EFIAPI AhciDmaTransfer(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL, IN UINT8 AtapiCommandLength, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN OUT VOID *MemoryAddr, IN UINT32 DataCount, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
Definition: AhciMode.c:1158
EFI_STATUS EFIAPI AtaPassThruGetNextDevice(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port, IN OUT UINT16 *PortMultiplierPort)
EFI_STATUS EFIAPI AtaPassThruPassThru(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet, IN EFI_EVENT Event OPTIONAL)
EFI_STATUS EFIAPI AtaAtapiPassThruStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI AtaNonDataCommandIn(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
Definition: IdeMode.c:1069
EFI_STATUS EFIAPI AtaPassThruResetPort(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port)
EFI_STATUS EFIAPI AhciPioTransfer(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL, IN UINT8 AtapiCommandLength, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN OUT VOID *MemoryAddr, IN UINT32 DataCount, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
Definition: AhciMode.c:983
EFI_STATUS EFIAPI ExtScsiPassThruResetChannel(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This)
EFI_STATUS EFIAPI AtaAtapiPassThruComponentNameGetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
VOID EFIAPI DestroyDeviceInfoList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance)
EFI_STATUS EFIAPI EnumerateAttachedDevice(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance)
VOID EFIAPI DestroyAsynTaskList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN BOOLEAN IsSigEvent)
EFI_STATUS EFIAPI ExtScsiPassThruGetNextTarget(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN OUT UINT8 **Target)
EFI_STATUS EFIAPI AtaAtapiPassThruComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
Definition: ComponentName.c:91
EFI_STATUS EFIAPI AtaPassThruBuildDevicePath(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
EFI_STATUS EFIAPI AtaPassThruGetNextPort(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN OUT UINT16 *Port)
EFI_STATUS EFIAPI AtaUdmaInOut(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN EFI_IDE_REGISTERS *IdeRegisters, IN BOOLEAN Read, IN VOID *DataBuffer, IN UINT64 DataLength, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
Definition: IdeMode.c:1263
EFI_STATUS EFIAPI CreateNewDeviceInfo(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT16 Port, IN UINT16 PortMultiplier, IN EFI_ATA_DEVICE_TYPE DeviceType, IN EFI_IDENTIFY_DATA *IdentifyData)
EFI_STATUS EFIAPI AtaAtapiPassThruStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI IdeModeInitialization(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance)
Definition: IdeMode.c:2601
EFI_STATUS EFIAPI AtaPassThruGetDevice(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINT16 *Port, OUT UINT16 *PortMultiplierPort)
EFI_STATUS EFIAPI AtaPassThruResetDevice(IN EFI_ATA_PASS_THRU_PROTOCOL *This, IN UINT16 Port, IN UINT16 PortMultiplierPort)
LIST_ENTRY *EFIAPI SearchDeviceInfoList(IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT16 Port, IN UINT16 PortMultiplier, IN EFI_ATA_DEVICE_TYPE DeviceType)
EFI_STATUS EFIAPI AhciNonDataTransfer(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_AHCI_REGISTERS *AhciRegisters, IN UINT8 Port, IN UINT8 PortMultiplier, IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL, IN UINT8 AtapiCommandLength, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
Definition: AhciMode.c:1424
EFI_STATUS EFIAPI ExtScsiPassThruPassThru(IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, IN UINT8 *Target, IN UINT64 Lun, IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, IN EFI_EVENT Event OPTIONAL)
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33