AtaAtapiPassThru.h 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  1. /** @file
  2. Header file for ATA/ATAPI PASS THRU driver.
  3. Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __ATA_ATAPI_PASS_THRU_H__
  7. #define __ATA_ATAPI_PASS_THRU_H__
  8. #include <Uefi.h>
  9. #include <IndustryStandard/Pci.h>
  10. #include <IndustryStandard/Atapi.h>
  11. #include <IndustryStandard/Scsi.h>
  12. #include <Protocol/PciIo.h>
  13. #include <Protocol/IdeControllerInit.h>
  14. #include <Protocol/AtaPassThru.h>
  15. #include <Protocol/ScsiPassThruExt.h>
  16. #include <Protocol/AtaAtapiPolicy.h>
  17. #include <Library/DebugLib.h>
  18. #include <Library/BaseLib.h>
  19. #include <Library/BaseMemoryLib.h>
  20. #include <Library/UefiDriverEntryPoint.h>
  21. #include <Library/UefiBootServicesTableLib.h>
  22. #include <Library/UefiLib.h>
  23. #include <Library/PciLib.h>
  24. #include <Library/PcdLib.h>
  25. #include <Library/TimerLib.h>
  26. #include <Library/MemoryAllocationLib.h>
  27. #include <Library/ReportStatusCodeLib.h>
  28. #include <Library/DevicePathLib.h>
  29. #include "IdeMode.h"
  30. #include "AhciMode.h"
  31. extern EFI_DRIVER_BINDING_PROTOCOL gAtaAtapiPassThruDriverBinding;
  32. extern EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComponentName;
  33. extern EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2;
  34. extern EDKII_ATA_ATAPI_POLICY_PROTOCOL *mAtaAtapiPolicy;
  35. #define ATA_ATAPI_PASS_THRU_SIGNATURE SIGNATURE_32 ('a', 'a', 'p', 't')
  36. #define ATA_ATAPI_DEVICE_SIGNATURE SIGNATURE_32 ('a', 'd', 'e', 'v')
  37. #define ATA_NONBLOCKING_TASK_SIGNATURE SIGNATURE_32 ('a', 't', 's', 'k')
  38. typedef struct _ATA_NONBLOCK_TASK ATA_NONBLOCK_TASK;
  39. typedef enum {
  40. EfiAtaIdeMode,
  41. EfiAtaAhciMode,
  42. EfiAtaRaidMode,
  43. EfiAtaUnknownMode
  44. } EFI_ATA_HC_WORK_MODE;
  45. typedef enum {
  46. EfiIdeCdrom, /* ATAPI CDROM */
  47. EfiIdeHarddisk, /* Hard Disk */
  48. EfiPortMultiplier, /* Port Multiplier */
  49. EfiIdeUnknown
  50. } EFI_ATA_DEVICE_TYPE;
  51. //
  52. // Ahci mode device info
  53. //
  54. typedef struct {
  55. UINT32 Signature;
  56. LIST_ENTRY Link;
  57. UINT16 Port;
  58. UINT16 PortMultiplier;
  59. EFI_ATA_DEVICE_TYPE Type;
  60. EFI_IDENTIFY_DATA *IdentifyData;
  61. } EFI_ATA_DEVICE_INFO;
  62. typedef struct {
  63. UINT32 Signature;
  64. EFI_HANDLE ControllerHandle;
  65. EFI_PCI_IO_PROTOCOL *PciIo;
  66. EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit;
  67. EFI_ATA_PASS_THRU_MODE AtaPassThruMode;
  68. EFI_ATA_PASS_THRU_PROTOCOL AtaPassThru;
  69. EFI_EXT_SCSI_PASS_THRU_MODE ExtScsiPassThruMode;
  70. EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru;
  71. EFI_ATA_HC_WORK_MODE Mode;
  72. EFI_IDE_REGISTERS IdeRegisters[EfiIdeMaxChannel];
  73. EFI_AHCI_REGISTERS AhciRegisters;
  74. //
  75. // The attached device list
  76. //
  77. LIST_ENTRY DeviceList;
  78. UINT64 EnabledPciAttributes;
  79. UINT64 OriginalPciAttributes;
  80. //
  81. // For AtaPassThru protocol, using the following bytes to record the previous call in
  82. // GetNextPort()/GetNextDevice().
  83. //
  84. UINT16 PreviousPort;
  85. UINT16 PreviousPortMultiplier;
  86. //
  87. // For ExtScsiPassThru protocol, using the following bytes to record the previous call in
  88. // GetNextTarget()/GetNextTargetLun().
  89. //
  90. UINT16 PreviousTargetId;
  91. UINT64 PreviousLun;
  92. //
  93. // For Non-blocking.
  94. //
  95. EFI_EVENT TimerEvent;
  96. LIST_ENTRY NonBlockingTaskList;
  97. } ATA_ATAPI_PASS_THRU_INSTANCE;
  98. //
  99. // Task for Non-blocking mode.
  100. //
  101. struct _ATA_NONBLOCK_TASK {
  102. UINT32 Signature;
  103. LIST_ENTRY Link;
  104. UINT16 Port;
  105. UINT16 PortMultiplier;
  106. EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet;
  107. BOOLEAN IsStart;
  108. EFI_EVENT Event;
  109. UINT64 RetryTimes;
  110. BOOLEAN InfiniteWait;
  111. VOID *Map; // Pointer to map.
  112. VOID *TableMap; // Pointer to PRD table map.
  113. EFI_ATA_DMA_PRD *MapBaseAddress; // Pointer to range Base address for Map.
  114. UINTN PageCount; // The page numbers used by PCIO freebuffer.
  115. };
  116. //
  117. // Timeout value which uses 100ns as a unit.
  118. // It means 3 second span.
  119. //
  120. #define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3)
  121. #define ATA_SPINUP_TIMEOUT EFI_TIMER_PERIOD_SECONDS(10)
  122. #define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
  123. #define ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
  124. CR (a, \
  125. ATA_ATAPI_PASS_THRU_INSTANCE, \
  126. AtaPassThru, \
  127. ATA_ATAPI_PASS_THRU_SIGNATURE \
  128. )
  129. #define EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
  130. CR (a, \
  131. ATA_ATAPI_PASS_THRU_INSTANCE, \
  132. ExtScsiPassThru, \
  133. ATA_ATAPI_PASS_THRU_SIGNATURE \
  134. )
  135. #define ATA_ATAPI_DEVICE_INFO_FROM_THIS(a) \
  136. CR (a, \
  137. EFI_ATA_DEVICE_INFO, \
  138. Link, \
  139. ATA_ATAPI_DEVICE_SIGNATURE \
  140. );
  141. #define ATA_NON_BLOCK_TASK_FROM_ENTRY(a) \
  142. CR (a, \
  143. ATA_NONBLOCK_TASK, \
  144. Link, \
  145. ATA_NONBLOCKING_TASK_SIGNATURE \
  146. );
  147. /**
  148. Retrieves a Unicode string that is the user readable name of the driver.
  149. This function retrieves the user readable name of a driver in the form of a
  150. Unicode string. If the driver specified by This has a user readable name in
  151. the language specified by Language, then a pointer to the driver name is
  152. returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
  153. by This does not support the language specified by Language,
  154. then EFI_UNSUPPORTED is returned.
  155. @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  156. EFI_COMPONENT_NAME_PROTOCOL instance.
  157. @param Language[in] A pointer to a Null-terminated ASCII string
  158. array indicating the language. This is the
  159. language of the driver name that the caller is
  160. requesting, and it must match one of the
  161. languages specified in SupportedLanguages. The
  162. number of languages supported by a driver is up
  163. to the driver writer. Language is specified
  164. in RFC 4646 or ISO 639-2 language code format.
  165. @param DriverName[out] A pointer to the Unicode string to return.
  166. This Unicode string is the name of the
  167. driver specified by This in the language
  168. specified by Language.
  169. @retval EFI_SUCCESS The Unicode string for the Driver specified by
  170. This and the language specified by Language was
  171. returned in DriverName.
  172. @retval EFI_INVALID_PARAMETER Language is NULL.
  173. @retval EFI_INVALID_PARAMETER DriverName is NULL.
  174. @retval EFI_UNSUPPORTED The driver specified by This does not support
  175. the language specified by Language.
  176. **/
  177. EFI_STATUS
  178. EFIAPI
  179. AtaAtapiPassThruComponentNameGetDriverName (
  180. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  181. IN CHAR8 *Language,
  182. OUT CHAR16 **DriverName
  183. );
  184. /**
  185. Retrieves a Unicode string that is the user readable name of the controller
  186. that is being managed by a driver.
  187. This function retrieves the user readable name of the controller specified by
  188. ControllerHandle and ChildHandle in the form of a Unicode string. If the
  189. driver specified by This has a user readable name in the language specified by
  190. Language, then a pointer to the controller name is returned in ControllerName,
  191. and EFI_SUCCESS is returned. If the driver specified by This is not currently
  192. managing the controller specified by ControllerHandle and ChildHandle,
  193. then EFI_UNSUPPORTED is returned. If the driver specified by This does not
  194. support the language specified by Language, then EFI_UNSUPPORTED is returned.
  195. @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  196. EFI_COMPONENT_NAME_PROTOCOL instance.
  197. @param ControllerHandle[in] The handle of a controller that the driver
  198. specified by This is managing. This handle
  199. specifies the controller whose name is to be
  200. returned.
  201. @param ChildHandle[in] The handle of the child controller to retrieve
  202. the name of. This is an optional parameter that
  203. may be NULL. It will be NULL for device
  204. drivers. It will also be NULL for a bus drivers
  205. that wish to retrieve the name of the bus
  206. controller. It will not be NULL for a bus
  207. driver that wishes to retrieve the name of a
  208. child controller.
  209. @param Language[in] A pointer to a Null-terminated ASCII string
  210. array indicating the language. This is the
  211. language of the driver name that the caller is
  212. requesting, and it must match one of the
  213. languages specified in SupportedLanguages. The
  214. number of languages supported by a driver is up
  215. to the driver writer. Language is specified in
  216. RFC 4646 or ISO 639-2 language code format.
  217. @param ControllerName[out] A pointer to the Unicode string to return.
  218. This Unicode string is the name of the
  219. controller specified by ControllerHandle and
  220. ChildHandle in the language specified by
  221. Language from the point of view of the driver
  222. specified by This.
  223. @retval EFI_SUCCESS The Unicode string for the user readable name in
  224. the language specified by Language for the
  225. driver specified by This was returned in
  226. DriverName.
  227. @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
  228. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
  229. EFI_HANDLE.
  230. @retval EFI_INVALID_PARAMETER Language is NULL.
  231. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  232. @retval EFI_UNSUPPORTED The driver specified by This is not currently
  233. managing the controller specified by
  234. ControllerHandle and ChildHandle.
  235. @retval EFI_UNSUPPORTED The driver specified by This does not support
  236. the language specified by Language.
  237. **/
  238. EFI_STATUS
  239. EFIAPI
  240. AtaAtapiPassThruComponentNameGetControllerName (
  241. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  242. IN EFI_HANDLE ControllerHandle,
  243. IN EFI_HANDLE ChildHandle OPTIONAL,
  244. IN CHAR8 *Language,
  245. OUT CHAR16 **ControllerName
  246. );
  247. /**
  248. Tests to see if this driver supports a given controller. If a child device is provided,
  249. it further tests to see if this driver supports creating a handle for the specified child device.
  250. This function checks to see if the driver specified by This supports the device specified by
  251. ControllerHandle. Drivers will typically use the device path attached to
  252. ControllerHandle and/or the services from the bus I/O abstraction attached to
  253. ControllerHandle to determine if the driver supports ControllerHandle. This function
  254. may be called many times during platform initialization. In order to reduce boot times, the tests
  255. performed by this function must be very small, and take as little time as possible to execute. This
  256. function must not change the state of any hardware devices, and this function must be aware that the
  257. device specified by ControllerHandle may already be managed by the same driver or a
  258. different driver. This function must match its calls to AllocatePages() with FreePages(),
  259. AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
  260. Because ControllerHandle may have been previously started by the same driver, if a protocol is
  261. already in the opened state, then it must not be closed with CloseProtocol(). This is required
  262. to guarantee the state of ControllerHandle is not modified by this function.
  263. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
  264. @param[in] ControllerHandle The handle of the controller to test. This handle
  265. must support a protocol interface that supplies
  266. an I/O abstraction to the driver.
  267. @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
  268. parameter is ignored by device drivers, and is optional for bus
  269. drivers. For bus drivers, if this parameter is not NULL, then
  270. the bus driver must determine if the bus controller specified
  271. by ControllerHandle and the child controller specified
  272. by RemainingDevicePath are both supported by this
  273. bus driver.
  274. @retval EFI_SUCCESS The device specified by ControllerHandle and
  275. RemainingDevicePath is supported by the driver specified by This.
  276. @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
  277. RemainingDevicePath is already being managed by the driver
  278. specified by This.
  279. @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
  280. RemainingDevicePath is already being managed by a different
  281. driver or an application that requires exclusive access.
  282. Currently not implemented.
  283. @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
  284. RemainingDevicePath is not supported by the driver specified by This.
  285. **/
  286. EFI_STATUS
  287. EFIAPI
  288. AtaAtapiPassThruSupported (
  289. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  290. IN EFI_HANDLE Controller,
  291. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
  292. );
  293. /**
  294. Starts a device controller or a bus controller.
  295. The Start() function is designed to be invoked from the EFI boot service ConnectController().
  296. As a result, much of the error checking on the parameters to Start() has been moved into this
  297. common boot service. It is legal to call Start() from other locations,
  298. but the following calling restrictions must be followed, or the system behavior will not be deterministic.
  299. 1. ControllerHandle must be a valid EFI_HANDLE.
  300. 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
  301. EFI_DEVICE_PATH_PROTOCOL.
  302. 3. Prior to calling Start(), the Supported() function for the driver specified by This must
  303. have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
  304. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
  305. @param[in] ControllerHandle The handle of the controller to start. This handle
  306. must support a protocol interface that supplies
  307. an I/O abstraction to the driver.
  308. @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
  309. parameter is ignored by device drivers, and is optional for bus
  310. drivers. For a bus driver, if this parameter is NULL, then handles
  311. for all the children of Controller are created by this driver.
  312. If this parameter is not NULL and the first Device Path Node is
  313. not the End of Device Path Node, then only the handle for the
  314. child device specified by the first Device Path Node of
  315. RemainingDevicePath is created by this driver.
  316. If the first Device Path Node of RemainingDevicePath is
  317. the End of Device Path Node, no child handle is created by this
  318. driver.
  319. @retval EFI_SUCCESS The device was started.
  320. @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
  321. @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
  322. @retval Others The driver failded to start the device.
  323. **/
  324. EFI_STATUS
  325. EFIAPI
  326. AtaAtapiPassThruStart (
  327. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  328. IN EFI_HANDLE Controller,
  329. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
  330. );
  331. /**
  332. Stops a device controller or a bus controller.
  333. The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
  334. As a result, much of the error checking on the parameters to Stop() has been moved
  335. into this common boot service. It is legal to call Stop() from other locations,
  336. but the following calling restrictions must be followed, or the system behavior will not be deterministic.
  337. 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
  338. same driver's Start() function.
  339. 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
  340. EFI_HANDLE. In addition, all of these handles must have been created in this driver's
  341. Start() function, and the Start() function must have called OpenProtocol() on
  342. ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
  343. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
  344. @param[in] ControllerHandle A handle to the device being stopped. The handle must
  345. support a bus specific I/O protocol for the driver
  346. to use to stop the device.
  347. @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
  348. @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
  349. if NumberOfChildren is 0.
  350. @retval EFI_SUCCESS The device was stopped.
  351. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
  352. **/
  353. EFI_STATUS
  354. EFIAPI
  355. AtaAtapiPassThruStop (
  356. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  357. IN EFI_HANDLE Controller,
  358. IN UINTN NumberOfChildren,
  359. IN EFI_HANDLE *ChildHandleBuffer
  360. );
  361. /**
  362. Traverse the attached ATA devices list to find out the device to access.
  363. @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
  364. @param[in] Port The port number of the ATA device to send the command.
  365. @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.
  366. If there is no port multiplier, then specify 0xFFFF.
  367. @param[in] DeviceType The device type of the ATA device.
  368. @retval The pointer to the data structure of the device info to access.
  369. **/
  370. LIST_ENTRY *
  371. EFIAPI
  372. SearchDeviceInfoList (
  373. IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
  374. IN UINT16 Port,
  375. IN UINT16 PortMultiplier,
  376. IN EFI_ATA_DEVICE_TYPE DeviceType
  377. );
  378. /**
  379. Allocate device info data structure to contain device info.
  380. And insert the data structure to the tail of device list for tracing.
  381. @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
  382. @param[in] Port The port number of the ATA device to send the command.
  383. @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.
  384. If there is no port multiplier, then specify 0xFFFF.
  385. @param[in] DeviceType The device type of the ATA device.
  386. @param[in] IdentifyData The data buffer to store the output of the IDENTIFY cmd.
  387. @retval EFI_SUCCESS Successfully insert the ata device to the tail of device list.
  388. @retval EFI_OUT_OF_RESOURCES Can not allocate enough resource for use.
  389. **/
  390. EFI_STATUS
  391. EFIAPI
  392. CreateNewDeviceInfo (
  393. IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
  394. IN UINT16 Port,
  395. IN UINT16 PortMultiplier,
  396. IN EFI_ATA_DEVICE_TYPE DeviceType,
  397. IN EFI_IDENTIFY_DATA *IdentifyData
  398. );
  399. /**
  400. Destroy all attached ATA devices info.
  401. @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
  402. **/
  403. VOID
  404. EFIAPI
  405. DestroyDeviceInfoList (
  406. IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
  407. );
  408. /**
  409. Destroy all pending non blocking tasks.
  410. @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
  411. @param[in] IsSigEvent Indicate whether signal the task event when remove the
  412. task.
  413. **/
  414. VOID
  415. EFIAPI
  416. DestroyAsynTaskList (
  417. IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
  418. IN BOOLEAN IsSigEvent
  419. );
  420. /**
  421. Enumerate all attached ATA devices at IDE mode or AHCI mode separately.
  422. The function is designed to enumerate all attached ATA devices.
  423. @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
  424. @retval EFI_SUCCESS Successfully enumerate attached ATA devices.
  425. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
  426. **/
  427. EFI_STATUS
  428. EFIAPI
  429. EnumerateAttachedDevice (
  430. IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
  431. );
  432. /**
  433. Call back funtion when the timer event is signaled.
  434. @param[in] Event The Event this notify function registered to.
  435. @param[in] Context Pointer to the context data registered to the
  436. Event.
  437. **/
  438. VOID
  439. EFIAPI
  440. AsyncNonBlockingTransferRoutine (
  441. EFI_EVENT Event,
  442. VOID* Context
  443. );
  444. /**
  445. Sends an ATA command to an ATA device that is attached to the ATA controller. This function
  446. supports both blocking I/O and non-blocking I/O. The blocking I/O functionality is required,
  447. and the non-blocking I/O functionality is optional.
  448. @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
  449. @param[in] Port The port number of the ATA device to send the command.
  450. @param[in] PortMultiplierPort The port multiplier port number of the ATA device to send the command.
  451. If there is no port multiplier, then specify 0xFFFF.
  452. @param[in, out] Packet A pointer to the ATA command to send to the ATA device specified by Port
  453. and PortMultiplierPort.
  454. @param[in] Event If non-blocking I/O is not supported then Event is ignored, and blocking
  455. I/O is performed. If Event is NULL, then blocking I/O is performed. If
  456. Event is not NULL and non blocking I/O is supported, then non-blocking
  457. I/O is performed, and Event will be signaled when the ATA command completes.
  458. @retval EFI_SUCCESS The ATA command was sent by the host. For bi-directional commands,
  459. InTransferLength bytes were transferred from InDataBuffer. For write and
  460. bi-directional commands, OutTransferLength bytes were transferred by OutDataBuffer.
  461. @retval EFI_BAD_BUFFER_SIZE The ATA command was not executed. The number of bytes that could be transferred
  462. is returned in InTransferLength. For write and bi-directional commands,
  463. OutTransferLength bytes were transferred by OutDataBuffer.
  464. @retval EFI_NOT_READY The ATA command could not be sent because there are too many ATA commands
  465. already queued. The caller may retry again later.
  466. @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the ATA command.
  467. @retval EFI_INVALID_PARAMETER Port, PortMultiplierPort, or the contents of Acb are invalid. The ATA
  468. command was not sent, so no additional status information is available.
  469. **/
  470. EFI_STATUS
  471. EFIAPI
  472. AtaPassThruPassThru (
  473. IN EFI_ATA_PASS_THRU_PROTOCOL *This,
  474. IN UINT16 Port,
  475. IN UINT16 PortMultiplierPort,
  476. IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet,
  477. IN EFI_EVENT Event OPTIONAL
  478. );
  479. /**
  480. Used to retrieve the list of legal port numbers for ATA devices on an ATA controller.
  481. These can either be the list of ports where ATA devices are actually present or the
  482. list of legal port numbers for the ATA controller. Regardless, the caller of this
  483. function must probe the port number returned to see if an ATA device is actually
  484. present at that location on the ATA controller.
  485. The GetNextPort() function retrieves the port number on an ATA controller. If on input
  486. Port is 0xFFFF, then the port number of the first port on the ATA controller is returned
  487. in Port and EFI_SUCCESS is returned.
  488. If Port is a port number that was returned on a previous call to GetNextPort(), then the
  489. port number of the next port on the ATA controller is returned in Port, and EFI_SUCCESS
  490. is returned. If Port is not 0xFFFF and Port was not returned on a previous call to
  491. GetNextPort(), then EFI_INVALID_PARAMETER is returned.
  492. If Port is the port number of the last port on the ATA controller, then EFI_NOT_FOUND is
  493. returned.
  494. @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
  495. @param[in, out] Port On input, a pointer to the port number on the ATA controller.
  496. On output, a pointer to the next port number on the ATA
  497. controller. An input value of 0xFFFF retrieves the first port
  498. number on the ATA controller.
  499. @retval EFI_SUCCESS The next port number on the ATA controller was returned in Port.
  500. @retval EFI_NOT_FOUND There are no more ports on this ATA controller.
  501. @retval EFI_INVALID_PARAMETER Port is not 0xFFFF and Port was not returned on a previous call
  502. to GetNextPort().
  503. **/
  504. EFI_STATUS
  505. EFIAPI
  506. AtaPassThruGetNextPort (
  507. IN EFI_ATA_PASS_THRU_PROTOCOL *This,
  508. IN OUT UINT16 *Port
  509. );
  510. /**
  511. Used to retrieve the list of legal port multiplier port numbers for ATA devices on a port of an ATA
  512. controller. These can either be the list of port multiplier ports where ATA devices are actually
  513. present on port or the list of legal port multiplier ports on that port. Regardless, the caller of this
  514. function must probe the port number and port multiplier port number returned to see if an ATA
  515. device is actually present.
  516. The GetNextDevice() function retrieves the port multiplier port number of an ATA device
  517. present on a port of an ATA controller.
  518. If PortMultiplierPort points to a port multiplier port number value that was returned on a
  519. previous call to GetNextDevice(), then the port multiplier port number of the next ATA device
  520. on the port of the ATA controller is returned in PortMultiplierPort, and EFI_SUCCESS is
  521. returned.
  522. If PortMultiplierPort points to 0xFFFF, then the port multiplier port number of the first
  523. ATA device on port of the ATA controller is returned in PortMultiplierPort and
  524. EFI_SUCCESS is returned.
  525. If PortMultiplierPort is not 0xFFFF and the value pointed to by PortMultiplierPort
  526. was not returned on a previous call to GetNextDevice(), then EFI_INVALID_PARAMETER
  527. is returned.
  528. If PortMultiplierPort is the port multiplier port number of the last ATA device on the port of
  529. the ATA controller, then EFI_NOT_FOUND is returned.
  530. @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
  531. @param[in] Port The port number present on the ATA controller.
  532. @param[in, out] PortMultiplierPort On input, a pointer to the port multiplier port number of an
  533. ATA device present on the ATA controller.
  534. If on input a PortMultiplierPort of 0xFFFF is specified,
  535. then the port multiplier port number of the first ATA device
  536. is returned. On output, a pointer to the port multiplier port
  537. number of the next ATA device present on an ATA controller.
  538. @retval EFI_SUCCESS The port multiplier port number of the next ATA device on the port
  539. of the ATA controller was returned in PortMultiplierPort.
  540. @retval EFI_NOT_FOUND There are no more ATA devices on this port of the ATA controller.
  541. @retval EFI_INVALID_PARAMETER PortMultiplierPort is not 0xFFFF, and PortMultiplierPort was not
  542. returned on a previous call to GetNextDevice().
  543. **/
  544. EFI_STATUS
  545. EFIAPI
  546. AtaPassThruGetNextDevice (
  547. IN EFI_ATA_PASS_THRU_PROTOCOL *This,
  548. IN UINT16 Port,
  549. IN OUT UINT16 *PortMultiplierPort
  550. );
  551. /**
  552. Used to allocate and build a device path node for an ATA device on an ATA controller.
  553. The BuildDevicePath() function allocates and builds a single device node for the ATA
  554. device specified by Port and PortMultiplierPort. If the ATA device specified by Port and
  555. PortMultiplierPort is not present on the ATA controller, then EFI_NOT_FOUND is returned.
  556. If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned. If there are not enough
  557. resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.
  558. Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of
  559. DevicePath are initialized to describe the ATA device specified by Port and PortMultiplierPort,
  560. and EFI_SUCCESS is returned.
  561. @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
  562. @param[in] Port Port specifies the port number of the ATA device for which a
  563. device path node is to be allocated and built.
  564. @param[in] PortMultiplierPort The port multiplier port number of the ATA device for which a
  565. device path node is to be allocated and built. If there is no
  566. port multiplier, then specify 0xFFFF.
  567. @param[in, out] DevicePath A pointer to a single device path node that describes the ATA
  568. device specified by Port and PortMultiplierPort. This function
  569. is responsible for allocating the buffer DevicePath with the
  570. boot service AllocatePool(). It is the caller's responsibility
  571. to free DevicePath when the caller is finished with DevicePath.
  572. @retval EFI_SUCCESS The device path node that describes the ATA device specified by
  573. Port and PortMultiplierPort was allocated and returned in DevicePath.
  574. @retval EFI_NOT_FOUND The ATA device specified by Port and PortMultiplierPort does not
  575. exist on the ATA controller.
  576. @retval EFI_INVALID_PARAMETER DevicePath is NULL.
  577. @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.
  578. **/
  579. EFI_STATUS
  580. EFIAPI
  581. AtaPassThruBuildDevicePath (
  582. IN EFI_ATA_PASS_THRU_PROTOCOL *This,
  583. IN UINT16 Port,
  584. IN UINT16 PortMultiplierPort,
  585. IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
  586. );
  587. /**
  588. Used to translate a device path node to a port number and port multiplier port number.
  589. The GetDevice() function determines the port and port multiplier port number associated with
  590. the ATA device described by DevicePath. If DevicePath is a device path node type that the
  591. ATA Pass Thru driver supports, then the ATA Pass Thru driver will attempt to translate the contents
  592. DevicePath into a port number and port multiplier port number.
  593. If this translation is successful, then that port number and port multiplier port number are returned
  594. in Port and PortMultiplierPort, and EFI_SUCCESS is returned.
  595. If DevicePath, Port, or PortMultiplierPort are NULL, then EFI_INVALID_PARAMETER is returned.
  596. If DevicePath is not a device path node type that the ATA Pass Thru driver supports, then
  597. EFI_UNSUPPORTED is returned.
  598. If DevicePath is a device path node type that the ATA Pass Thru driver supports, but there is not
  599. a valid translation from DevicePath to a port number and port multiplier port number, then
  600. EFI_NOT_FOUND is returned.
  601. @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
  602. @param[in] DevicePath A pointer to the device path node that describes an ATA device on the
  603. ATA controller.
  604. @param[out] Port On return, points to the port number of an ATA device on the ATA controller.
  605. @param[out] PortMultiplierPort On return, points to the port multiplier port number of an ATA device
  606. on the ATA controller.
  607. @retval EFI_SUCCESS DevicePath was successfully translated to a port number and port multiplier
  608. port number, and they were returned in Port and PortMultiplierPort.
  609. @retval EFI_INVALID_PARAMETER DevicePath is NULL.
  610. @retval EFI_INVALID_PARAMETER Port is NULL.
  611. @retval EFI_INVALID_PARAMETER PortMultiplierPort is NULL.
  612. @retval EFI_UNSUPPORTED This driver does not support the device path node type in DevicePath.
  613. @retval EFI_NOT_FOUND A valid translation from DevicePath to a port number and port multiplier
  614. port number does not exist.
  615. **/
  616. EFI_STATUS
  617. EFIAPI
  618. AtaPassThruGetDevice (
  619. IN EFI_ATA_PASS_THRU_PROTOCOL *This,
  620. IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
  621. OUT UINT16 *Port,
  622. OUT UINT16 *PortMultiplierPort
  623. );
  624. /**
  625. Resets a specific port on the ATA controller. This operation also resets all the ATA devices
  626. connected to the port.
  627. The ResetChannel() function resets an a specific port on an ATA controller. This operation
  628. resets all the ATA devices connected to that port. If this ATA controller does not support
  629. a reset port operation, then EFI_UNSUPPORTED is returned.
  630. If a device error occurs while executing that port reset operation, then EFI_DEVICE_ERROR is
  631. returned.
  632. If a timeout occurs during the execution of the port reset operation, then EFI_TIMEOUT is returned.
  633. If the port reset operation is completed, then EFI_SUCCESS is returned.
  634. @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
  635. @param[in] Port The port number on the ATA controller.
  636. @retval EFI_SUCCESS The ATA controller port was reset.
  637. @retval EFI_UNSUPPORTED The ATA controller does not support a port reset operation.
  638. @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA port.
  639. @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA port.
  640. **/
  641. EFI_STATUS
  642. EFIAPI
  643. AtaPassThruResetPort (
  644. IN EFI_ATA_PASS_THRU_PROTOCOL *This,
  645. IN UINT16 Port
  646. );
  647. /**
  648. Resets an ATA device that is connected to an ATA controller.
  649. The ResetDevice() function resets the ATA device specified by Port and PortMultiplierPort.
  650. If this ATA controller does not support a device reset operation, then EFI_UNSUPPORTED is
  651. returned.
  652. If Port or PortMultiplierPort are not in a valid range for this ATA controller, then
  653. EFI_INVALID_PARAMETER is returned.
  654. If a device error occurs while executing that device reset operation, then EFI_DEVICE_ERROR
  655. is returned.
  656. If a timeout occurs during the execution of the device reset operation, then EFI_TIMEOUT is
  657. returned.
  658. If the device reset operation is completed, then EFI_SUCCESS is returned.
  659. @param[in] This A pointer to the EFI_ATA_PASS_THRU_PROTOCOL instance.
  660. @param[in] Port Port represents the port number of the ATA device to be reset.
  661. @param[in] PortMultiplierPort The port multiplier port number of the ATA device to reset.
  662. If there is no port multiplier, then specify 0xFFFF.
  663. @retval EFI_SUCCESS The ATA device specified by Port and PortMultiplierPort was reset.
  664. @retval EFI_UNSUPPORTED The ATA controller does not support a device reset operation.
  665. @retval EFI_INVALID_PARAMETER Port or PortMultiplierPort are invalid.
  666. @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the ATA device
  667. specified by Port and PortMultiplierPort.
  668. @retval EFI_TIMEOUT A timeout occurred while attempting to reset the ATA device
  669. specified by Port and PortMultiplierPort.
  670. **/
  671. EFI_STATUS
  672. EFIAPI
  673. AtaPassThruResetDevice (
  674. IN EFI_ATA_PASS_THRU_PROTOCOL *This,
  675. IN UINT16 Port,
  676. IN UINT16 PortMultiplierPort
  677. );
  678. /**
  679. Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function
  680. supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the
  681. nonblocking I/O functionality is optional.
  682. @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
  683. @param Target The Target is an array of size TARGET_MAX_BYTES and it represents
  684. the id of the SCSI device to send the SCSI Request Packet. Each
  685. transport driver may choose to utilize a subset of this size to suit the needs
  686. of transport target representation. For example, a Fibre Channel driver
  687. may use only 8 bytes (WWN) to represent an FC target.
  688. @param Lun The LUN of the SCSI device to send the SCSI Request Packet.
  689. @param Packet A pointer to the SCSI Request Packet to send to the SCSI device
  690. specified by Target and Lun.
  691. @param Event If nonblocking I/O is not supported then Event is ignored, and blocking
  692. I/O is performed. If Event is NULL, then blocking I/O is performed. If
  693. Event is not NULL and non blocking I/O is supported, then
  694. nonblocking I/O is performed, and Event will be signaled when the
  695. SCSI Request Packet completes.
  696. @retval EFI_SUCCESS The SCSI Request Packet was sent by the host. For bi-directional
  697. commands, InTransferLength bytes were transferred from
  698. InDataBuffer. For write and bi-directional commands,
  699. OutTransferLength bytes were transferred by
  700. OutDataBuffer.
  701. @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was not executed. The number of bytes that
  702. could be transferred is returned in InTransferLength. For write
  703. and bi-directional commands, OutTransferLength bytes were
  704. transferred by OutDataBuffer.
  705. @retval EFI_NOT_READY The SCSI Request Packet could not be sent because there are too many
  706. SCSI Request Packets already queued. The caller may retry again later.
  707. @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SCSI Request
  708. Packet.
  709. @retval EFI_INVALID_PARAMETER Target, Lun, or the contents of ScsiRequestPacket are invalid.
  710. @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet is not supported
  711. by the host adapter. This includes the case of Bi-directional SCSI
  712. commands not supported by the implementation. The SCSI Request
  713. Packet was not sent, so no additional status information is available.
  714. @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI Request Packet to execute.
  715. **/
  716. EFI_STATUS
  717. EFIAPI
  718. ExtScsiPassThruPassThru (
  719. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  720. IN UINT8 *Target,
  721. IN UINT64 Lun,
  722. IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
  723. IN EFI_EVENT Event OPTIONAL
  724. );
  725. /**
  726. Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These
  727. can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal
  728. Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the
  729. Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI
  730. channel.
  731. @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
  732. @param Target On input, a pointer to the Target ID (an array of size
  733. TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
  734. On output, a pointer to the Target ID (an array of
  735. TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
  736. channel. An input value of 0xF(all bytes in the array are 0xF) in the
  737. Target array retrieves the Target ID of the first SCSI device present on a
  738. SCSI channel.
  739. @param Lun On input, a pointer to the LUN of a SCSI device present on the SCSI
  740. channel. On output, a pointer to the LUN of the next SCSI device present
  741. on a SCSI channel.
  742. @retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI
  743. channel was returned in Target and Lun.
  744. @retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were
  745. not returned on a previous call to GetNextTargetLun().
  746. @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
  747. **/
  748. EFI_STATUS
  749. EFIAPI
  750. ExtScsiPassThruGetNextTargetLun (
  751. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  752. IN OUT UINT8 **Target,
  753. IN OUT UINT64 *Lun
  754. );
  755. /**
  756. Used to allocate and build a device path node for a SCSI device on a SCSI channel.
  757. @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
  758. @param Target The Target is an array of size TARGET_MAX_BYTES and it specifies the
  759. Target ID of the SCSI device for which a device path node is to be
  760. allocated and built. Transport drivers may chose to utilize a subset of
  761. this size to suit the representation of targets. For example, a Fibre
  762. Channel driver may use only 8 bytes (WWN) in the array to represent a
  763. FC target.
  764. @param Lun The LUN of the SCSI device for which a device path node is to be
  765. allocated and built.
  766. @param DevicePath A pointer to a single device path node that describes the SCSI device
  767. specified by Target and Lun. This function is responsible for
  768. allocating the buffer DevicePath with the boot service
  769. AllocatePool(). It is the caller's responsibility to free
  770. DevicePath when the caller is finished with DevicePath.
  771. @retval EFI_SUCCESS The device path node that describes the SCSI device specified by
  772. Target and Lun was allocated and returned in
  773. DevicePath.
  774. @retval EFI_INVALID_PARAMETER DevicePath is NULL.
  775. @retval EFI_NOT_FOUND The SCSI devices specified by Target and Lun does not exist
  776. on the SCSI channel.
  777. @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath.
  778. **/
  779. EFI_STATUS
  780. EFIAPI
  781. ExtScsiPassThruBuildDevicePath (
  782. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  783. IN UINT8 *Target,
  784. IN UINT64 Lun,
  785. IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
  786. );
  787. /**
  788. Used to translate a device path node to a Target ID and LUN.
  789. @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
  790. @param DevicePath A pointer to a single device path node that describes the SCSI device
  791. on the SCSI channel.
  792. @param Target A pointer to the Target Array which represents the ID of a SCSI device
  793. on the SCSI channel.
  794. @param Lun A pointer to the LUN of a SCSI device on the SCSI channel.
  795. @retval EFI_SUCCESS DevicePath was successfully translated to a Target ID and
  796. LUN, and they were returned in Target and Lun.
  797. @retval EFI_INVALID_PARAMETER DevicePath or Target or Lun is NULL.
  798. @retval EFI_NOT_FOUND A valid translation from DevicePath to a Target ID and LUN
  799. does not exist.
  800. @retval EFI_UNSUPPORTED This driver does not support the device path node type in
  801. DevicePath.
  802. **/
  803. EFI_STATUS
  804. EFIAPI
  805. ExtScsiPassThruGetTargetLun (
  806. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  807. IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
  808. OUT UINT8 **Target,
  809. OUT UINT64 *Lun
  810. );
  811. /**
  812. Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.
  813. @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
  814. @retval EFI_SUCCESS The SCSI channel was reset.
  815. @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI channel.
  816. @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI channel.
  817. @retval EFI_UNSUPPORTED The SCSI channel does not support a channel reset operation.
  818. **/
  819. EFI_STATUS
  820. EFIAPI
  821. ExtScsiPassThruResetChannel (
  822. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
  823. );
  824. /**
  825. Resets a SCSI logical unit that is connected to a SCSI channel.
  826. @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
  827. @param Target The Target is an array of size TARGET_MAX_BYTE and it represents the
  828. target port ID of the SCSI device containing the SCSI logical unit to
  829. reset. Transport drivers may chose to utilize a subset of this array to suit
  830. the representation of their targets.
  831. @param Lun The LUN of the SCSI device to reset.
  832. @retval EFI_SUCCESS The SCSI device specified by Target and Lun was reset.
  833. @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
  834. @retval EFI_TIMEOUT A timeout occurred while attempting to reset the SCSI device
  835. specified by Target and Lun.
  836. @retval EFI_UNSUPPORTED The SCSI channel does not support a target reset operation.
  837. @retval EFI_DEVICE_ERROR A device error occurred while attempting to reset the SCSI device
  838. specified by Target and Lun.
  839. **/
  840. EFI_STATUS
  841. EFIAPI
  842. ExtScsiPassThruResetTargetLun (
  843. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  844. IN UINT8 *Target,
  845. IN UINT64 Lun
  846. );
  847. /**
  848. Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either
  849. be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs
  850. for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to
  851. see if a SCSI device is actually present at that location on the SCSI channel.
  852. @param This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
  853. @param Target (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
  854. On output, a pointer to the Target ID (an array of
  855. TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
  856. channel. An input value of 0xF(all bytes in the array are 0xF) in the
  857. Target array retrieves the Target ID of the first SCSI device present on a
  858. SCSI channel.
  859. @retval EFI_SUCCESS The Target ID of the next SCSI device on the SCSI
  860. channel was returned in Target.
  861. @retval EFI_INVALID_PARAMETER Target or Lun is NULL.
  862. @retval EFI_TIMEOUT Target array is not all 0xF, and Target was not
  863. returned on a previous call to GetNextTarget().
  864. @retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
  865. **/
  866. EFI_STATUS
  867. EFIAPI
  868. ExtScsiPassThruGetNextTarget (
  869. IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
  870. IN OUT UINT8 **Target
  871. );
  872. /**
  873. Initialize ATA host controller at IDE mode.
  874. The function is designed to initialize ATA host controller.
  875. @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
  876. **/
  877. EFI_STATUS
  878. EFIAPI
  879. IdeModeInitialization (
  880. IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
  881. );
  882. /**
  883. Initialize ATA host controller at AHCI mode.
  884. The function is designed to initialize ATA host controller.
  885. @param[in] Instance A pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.
  886. **/
  887. EFI_STATUS
  888. EFIAPI
  889. AhciModeInitialization (
  890. IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance
  891. );
  892. /**
  893. Start a non data transfer on specific port.
  894. @param[in] PciIo The PCI IO protocol instance.
  895. @param[in] AhciRegisters The pointer to the EFI_AHCI_REGISTERS.
  896. @param[in] Port The number of port.
  897. @param[in] PortMultiplier The timeout value of stop.
  898. @param[in] AtapiCommand The atapi command will be used for the
  899. transfer.
  900. @param[in] AtapiCommandLength The length of the atapi command.
  901. @param[in] AtaCommandBlock The EFI_ATA_COMMAND_BLOCK data.
  902. @param[in, out] AtaStatusBlock The EFI_ATA_STATUS_BLOCK data.
  903. @param[in] Timeout The timeout value of non data transfer, uses 100ns as a unit.
  904. @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK
  905. used by non-blocking mode.
  906. @retval EFI_DEVICE_ERROR The non data transfer abort with error occurs.
  907. @retval EFI_TIMEOUT The operation is time out.
  908. @retval EFI_UNSUPPORTED The device is not ready for transfer.
  909. @retval EFI_SUCCESS The non data transfer executes successfully.
  910. **/
  911. EFI_STATUS
  912. EFIAPI
  913. AhciNonDataTransfer (
  914. IN EFI_PCI_IO_PROTOCOL *PciIo,
  915. IN EFI_AHCI_REGISTERS *AhciRegisters,
  916. IN UINT8 Port,
  917. IN UINT8 PortMultiplier,
  918. IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
  919. IN UINT8 AtapiCommandLength,
  920. IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
  921. IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
  922. IN UINT64 Timeout,
  923. IN ATA_NONBLOCK_TASK *Task
  924. );
  925. /**
  926. Start a DMA data transfer on specific port
  927. @param[in] Instance The ATA_ATAPI_PASS_THRU_INSTANCE protocol instance.
  928. @param[in] AhciRegisters The pointer to the EFI_AHCI_REGISTERS.
  929. @param[in] Port The number of port.
  930. @param[in] PortMultiplier The timeout value of stop.
  931. @param[in] AtapiCommand The atapi command will be used for the
  932. transfer.
  933. @param[in] AtapiCommandLength The length of the atapi command.
  934. @param[in] Read The transfer direction.
  935. @param[in] AtaCommandBlock The EFI_ATA_COMMAND_BLOCK data.
  936. @param[in, out] AtaStatusBlock The EFI_ATA_STATUS_BLOCK data.
  937. @param[in, out] MemoryAddr The pointer to the data buffer.
  938. @param[in] DataCount The data count to be transferred.
  939. @param[in] Timeout The timeout value of non data transfer, uses 100ns as a unit.
  940. @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK
  941. used by non-blocking mode.
  942. @retval EFI_DEVICE_ERROR The DMA data transfer abort with error occurs.
  943. @retval EFI_TIMEOUT The operation is time out.
  944. @retval EFI_UNSUPPORTED The device is not ready for transfer.
  945. @retval EFI_SUCCESS The DMA data transfer executes successfully.
  946. **/
  947. EFI_STATUS
  948. EFIAPI
  949. AhciDmaTransfer (
  950. IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
  951. IN EFI_AHCI_REGISTERS *AhciRegisters,
  952. IN UINT8 Port,
  953. IN UINT8 PortMultiplier,
  954. IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
  955. IN UINT8 AtapiCommandLength,
  956. IN BOOLEAN Read,
  957. IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
  958. IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
  959. IN OUT VOID *MemoryAddr,
  960. IN UINT32 DataCount,
  961. IN UINT64 Timeout,
  962. IN ATA_NONBLOCK_TASK *Task
  963. );
  964. /**
  965. Start a PIO data transfer on specific port.
  966. @param[in] PciIo The PCI IO protocol instance.
  967. @param[in] AhciRegisters The pointer to the EFI_AHCI_REGISTERS.
  968. @param[in] Port The number of port.
  969. @param[in] PortMultiplier The timeout value of stop.
  970. @param[in] AtapiCommand The atapi command will be used for the
  971. transfer.
  972. @param[in] AtapiCommandLength The length of the atapi command.
  973. @param[in] Read The transfer direction.
  974. @param[in] AtaCommandBlock The EFI_ATA_COMMAND_BLOCK data.
  975. @param[in, out] AtaStatusBlock The EFI_ATA_STATUS_BLOCK data.
  976. @param[in, out] MemoryAddr The pointer to the data buffer.
  977. @param[in] DataCount The data count to be transferred.
  978. @param[in] Timeout The timeout value of non data transfer, uses 100ns as a unit.
  979. @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK
  980. used by non-blocking mode.
  981. @retval EFI_DEVICE_ERROR The PIO data transfer abort with error occurs.
  982. @retval EFI_TIMEOUT The operation is time out.
  983. @retval EFI_UNSUPPORTED The device is not ready for transfer.
  984. @retval EFI_SUCCESS The PIO data transfer executes successfully.
  985. **/
  986. EFI_STATUS
  987. EFIAPI
  988. AhciPioTransfer (
  989. IN EFI_PCI_IO_PROTOCOL *PciIo,
  990. IN EFI_AHCI_REGISTERS *AhciRegisters,
  991. IN UINT8 Port,
  992. IN UINT8 PortMultiplier,
  993. IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
  994. IN UINT8 AtapiCommandLength,
  995. IN BOOLEAN Read,
  996. IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
  997. IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
  998. IN OUT VOID *MemoryAddr,
  999. IN UINT32 DataCount,
  1000. IN UINT64 Timeout,
  1001. IN ATA_NONBLOCK_TASK *Task
  1002. );
  1003. /**
  1004. Send ATA command into device with NON_DATA protocol
  1005. @param[in] PciIo A pointer to ATA_ATAPI_PASS_THRU_INSTANCE
  1006. data structure.
  1007. @param[in] IdeRegisters A pointer to EFI_IDE_REGISTERS data structure.
  1008. @param[in] AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK data
  1009. structure.
  1010. @param[in, out] AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK data structure.
  1011. @param[in] Timeout The time to complete the command, uses 100ns as a unit.
  1012. @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK
  1013. used by non-blocking mode.
  1014. @retval EFI_SUCCESS Reading succeed
  1015. @retval EFI_ABORTED Command failed
  1016. @retval EFI_DEVICE_ERROR Device status error.
  1017. **/
  1018. EFI_STATUS
  1019. EFIAPI
  1020. AtaNonDataCommandIn (
  1021. IN EFI_PCI_IO_PROTOCOL *PciIo,
  1022. IN EFI_IDE_REGISTERS *IdeRegisters,
  1023. IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
  1024. IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
  1025. IN UINT64 Timeout,
  1026. IN ATA_NONBLOCK_TASK *Task
  1027. );
  1028. /**
  1029. Perform an ATA Udma operation (Read, ReadExt, Write, WriteExt).
  1030. @param[in] Instance A pointer to ATA_ATAPI_PASS_THRU_INSTANCE data
  1031. structure.
  1032. @param[in] IdeRegisters A pointer to EFI_IDE_REGISTERS data structure.
  1033. @param[in] Read Flag used to determine the data transfer
  1034. direction. Read equals 1, means data transferred
  1035. from device to host;Read equals 0, means data
  1036. transferred from host to device.
  1037. @param[in] DataBuffer A pointer to the source buffer for the data.
  1038. @param[in] DataLength The length of the data.
  1039. @param[in] AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK data structure.
  1040. @param[in, out] AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK data structure.
  1041. @param[in] Timeout The time to complete the command, uses 100ns as a unit.
  1042. @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK
  1043. used by non-blocking mode.
  1044. @retval EFI_SUCCESS the operation is successful.
  1045. @retval EFI_OUT_OF_RESOURCES Build PRD table failed
  1046. @retval EFI_UNSUPPORTED Unknown channel or operations command
  1047. @retval EFI_DEVICE_ERROR Ata command execute failed
  1048. **/
  1049. EFI_STATUS
  1050. EFIAPI
  1051. AtaUdmaInOut (
  1052. IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance,
  1053. IN EFI_IDE_REGISTERS *IdeRegisters,
  1054. IN BOOLEAN Read,
  1055. IN VOID *DataBuffer,
  1056. IN UINT64 DataLength,
  1057. IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
  1058. IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
  1059. IN UINT64 Timeout,
  1060. IN ATA_NONBLOCK_TASK *Task
  1061. );
  1062. /**
  1063. This function is used to send out ATA commands conforms to the PIO Data In Protocol.
  1064. @param[in] PciIo A pointer to ATA_ATAPI_PASS_THRU_INSTANCE data
  1065. structure.
  1066. @param[in] IdeRegisters A pointer to EFI_IDE_REGISTERS data structure.
  1067. @param[in, out] Buffer A pointer to the source buffer for the data.
  1068. @param[in] ByteCount The length of the data.
  1069. @param[in] Read Flag used to determine the data transfer direction.
  1070. Read equals 1, means data transferred from device
  1071. to host;Read equals 0, means data transferred
  1072. from host to device.
  1073. @param[in] AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK data structure.
  1074. @param[in, out] AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK data structure.
  1075. @param[in] Timeout The time to complete the command, uses 100ns as a unit.
  1076. @param[in] Task Optional. Pointer to the ATA_NONBLOCK_TASK
  1077. used by non-blocking mode.
  1078. @retval EFI_SUCCESS send out the ATA command and device send required data successfully.
  1079. @retval EFI_DEVICE_ERROR command sent failed.
  1080. **/
  1081. EFI_STATUS
  1082. EFIAPI
  1083. AtaPioDataInOut (
  1084. IN EFI_PCI_IO_PROTOCOL *PciIo,
  1085. IN EFI_IDE_REGISTERS *IdeRegisters,
  1086. IN OUT VOID *Buffer,
  1087. IN UINT64 ByteCount,
  1088. IN BOOLEAN Read,
  1089. IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
  1090. IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
  1091. IN UINT64 Timeout,
  1092. IN ATA_NONBLOCK_TASK *Task
  1093. );
  1094. #endif