AtapiPassThru.h 48 KB

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