Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

559 lines
15 KiB

  1. #ifndef _PARSTL_H_
  2. #define _PARSTL_H_
  3. // Define 1284 Commands
  4. #define CPP_QUERY_PRODID 0x10
  5. // 1284 related SHTL prod id equates
  6. #define SHTL_EPAT_PRODID 0xAAFF
  7. #define SHTL_EPST_PRODID 0xA8FF
  8. // typedefs for device type
  9. typedef unsigned char DEVICE_STATE ;
  10. typedef unsigned int STL_DEVICE_TYPE ;
  11. typedef unsigned int IMPACT_DEVICE_TYPE ;
  12. // device type equates
  13. #define DEVICE_TYPE_AUTO_DETECT -1
  14. #define TRUE 1
  15. #define FALSE 0
  16. #define DEVICE_TYPE_NONE 0x0000
  17. #define DEVICE_TYPE_ATA 0x0001
  18. #define DEVICE_TYPE_ATAPI 0x0002
  19. #define DEVICE_TYPE_SCSI 0x0003
  20. #define DEVICE_TYPE_SSFDC 0x0004
  21. #define DEVICE_TYPE_MMC 0x0005
  22. #define DEVICE_TYPE_FLASH 0x0006
  23. #define DEVICE_TYPE_EPP_DEVICE 0x0007
  24. #define DEVICE_TYPE_SOUND 0x0008
  25. #define DEVICE_TYPE_HIFD 0x0009
  26. #define DEVICE_TYPE_LS120 0x000A
  27. #define DEVICE_TYPE_PCMCIA_CF 0x000B
  28. #define DEVICE_TYPE_FLP_TAPE_DSK 0x000C
  29. #define DEVICE_TYPE_ATA_ATAPI_8BIT 0x000D
  30. #define DEVICE_TYPE_UMAX 0x000E
  31. #define DEVICE_TYPE_AVISION 0x000F
  32. #define DEVICE_TYPE_DAZZLE 0x0010
  33. #define DEVICE_TYPE_EXT_HWDETECT 0x40000000 // to OR with expected pers.
  34. #define DEVICE_TYPE_ATA_BIT 1 << ( DEVICE_TYPE_ATA - 1 )
  35. #define DEVICE_TYPE_ATAPI_BIT 1 << ( DEVICE_TYPE_ATAPI - 1 )
  36. #define DEVICE_TYPE_SCSI_BIT 1 << ( DEVICE_TYPE_SCSI - 1 )
  37. #define DEVICE_TYPE_SSFDC_BIT 1 << ( DEVICE_TYPE_SSFDC - 1 )
  38. #define DEVICE_TYPE_MMC_BIT 1 << ( DEVICE_TYPE_MMC - 1 )
  39. #define DEVICE_TYPE_FLASH_BIT 1 << ( DEVICE_TYPE_FLASH - 1 )
  40. #define DEVICE_TYPE_EPP_DEVICE_BIT 1 << ( DEVICE_TYPE_EPP_DEVICE - 1 )
  41. #define DEVICE_TYPE_SOUND_BIT 1 << ( DEVICE_TYPE_SOUND - 1 )
  42. #define DEVICE_TYPE_HIFD_BIT 1 << ( DEVICE_TYPE_HIFD - 1 )
  43. #define DEVICE_TYPE_LS120_BIT 1 << ( DEVICE_TYPE_LS120 - 1 )
  44. #define DEVICE_TYPE_PCMCIA_CF_BIT 1 << ( DEVICE_TYPE_PCMCIA_CF - 1 )
  45. #define DEVICE_TYPE_FLP_TAPE_DSK_BIT 1 << ( DEVICE_TYPE_FLP_TAPE_DSK - 1 )
  46. #define DEVICE_TYPE_ATA_ATAPI_8BIT_BIT 1 << ( DEVICE_TYPE_ATA_ATAPI_8BIT - 1 )
  47. #define DEVICE_TYPE_UMAX_BIT 1 << ( DEVICE_TYPE_UMAX - 1 )
  48. #define DEVICE_TYPE_AVISION_BIT 1 << ( DEVICE_TYPE_AVISION - 1 )
  49. #define DEVICE_TYPE_DAZZLE_BIT 1 << ( DEVICE_TYPE_DAZZLE - 1 )
  50. // possible Device states
  51. #define DEVICE_STATE_INVALID 0
  52. #define DEVICE_STATE_VALID 1
  53. #define DEVICE_STATE_ATAPI 2
  54. // epp dev equates
  55. #define EPPDEV_SIGN 0x03
  56. #define PERSONALITY_MASK 0x03
  57. // flash related equates
  58. #define FLASH_SIGN 0x01
  59. #define FLASH_PERSONALITY_MASK 0x03
  60. // dazzle related equates
  61. #define DAZ_SELECT_BLK 0x18
  62. #define DAZ_BLK0 0x00
  63. #define DAZ_REG1 0x19
  64. #define DAZ_CONFIGURED 0x5A
  65. #define DAZ_NOT_CONFIGURED 0xBC
  66. // umax related equates
  67. #define BUSY 0x20
  68. #define PE 0x08
  69. #define DATAPORT 0x18
  70. #define STATUSPORT 0x19
  71. #define CONTROLPORT 0x1A
  72. #define EPPADDRPORT 0x1B
  73. #define EPPDATA0PORT 0x1C
  74. #define EPPDATA1PORT 0x1D
  75. #define EPPDATA2PORT 0x1E
  76. #define EPPDATA3PORT 0x1F
  77. // HIFD related equates
  78. #define HIFD_CONTROLLER_READY_STATUS 0x80
  79. #define HIFD_DIGITAL_OUTPUT_REGISTER 0x02
  80. #define HIFD_DOR_RESET_BIT 0x04
  81. #define HIFD_ENABLE_DMA_BIT 0x08
  82. #define HIFD_MAIN_STATUS_REGISTER 0x04
  83. #define HIFD_DATA_RATE_SELECT_REGISTER 0x04
  84. #define HIFD_STATUS_REGISTER_A 0x00
  85. #define HIFD_STATUS_REGISTER_B 0x01
  86. #define HIFD_COMMAND_TO_CONTROLLER 0x55
  87. #define HIFD_TERMINATE_SEQUENCE 0xAA
  88. #define HIFD_CTL_REG_0D 0x0D
  89. #define HIFD_CTL_REG_03 0x03
  90. #define HIFD_WAIT_10_MILLISEC 10000 // 10 * 1000
  91. #define HIFD_WAIT_1_MILLISEC 1000 // 1 * 1000
  92. #define SMC_ENABLE_MODE2 0x72
  93. #define SMC_DEVICE_ID 0x78
  94. // LS120 related equates
  95. #define LS120_ENGINE_VERSION 0xE2
  96. #define LS120_ENGINE_VERSION_REGISTER 0x07
  97. // MMC engine specific equates
  98. #define MMC_ENGINE_INDEX 0x1E
  99. #define MMC_ENGINE_DATA 0x1F
  100. #define MMC_FREQ_SELECT_REG 0x00
  101. #define MMC_BLOCK_SIZE_REG 0x06
  102. // Though these are test patterns, they may be possible commands
  103. // for ATA/ATAPI devices, as they are written to a possible
  104. // ATA/ATAPI command register. These values have been fixed
  105. // carefully, to minimize, if not eliminate, possible failure.
  106. #define MMC_TEST_PATTERN_1 0x00 // ATA Nop commands for ATA/ATAPI type devices.
  107. #define MMC_TEST_PATTERN_2 0xA1 // ATAPI Ident. command for ATAPI type devices.
  108. #define MMC_TEST_PATTERN_3 0x00 // ATA Nop commands for ATA/ATAPI type devices.
  109. // some IO register equates that are inevitable
  110. #define CYLLOW_REG 0x0004
  111. #define CYLHIGH_REG 0x0005
  112. // ATAPI signature equates
  113. #define ATAPI_SIGN_LOW 0x14
  114. #define ATAPI_SIGN_HI 0xEB
  115. // delay equates
  116. #define MAX_RETRIES_FOR_5_SECS 5 * 1000 // 5 secs
  117. #define MAX_RETRIES_FOR_10_SECS 10 * 1000 // 10 secs
  118. #define DELAY_10MICROSECONDS 10 // 10 mu sec.
  119. #define DELAY_1MILLISECONDS 1000 // 1 milli sec.
  120. #define DELAY_1SECOND 1000*1000 // 1 sec.
  121. // ATA/ATAPI command opcodes
  122. #define ATA_NOP_COMMAND 0x00
  123. #define ATAPI_IDENTIFY 0xA1
  124. // ATA/ATAPI drive select values
  125. #define ATAPI_MASTER 0xA0
  126. #define ATAPI_SLAVE 0xB0
  127. #define ATAPI_MAX_DRIVES 2
  128. // ATA register definitions
  129. #define ATA_DATA_REG 0x0000
  130. #define ATA_ERROR_REG 0x0001
  131. #define ATA_PRECOMP_REG 0x0001
  132. #define ATA_SECCNT_REG 0x0002
  133. #define ATA_SECNUM_REG 0x0003
  134. #define ATA_CYLLOW_REG 0x0004
  135. #define ATA_CYLHIGH_REG 0x0005
  136. #define ATA_DRVHD_REG 0x0006
  137. #define ATA_TASK_STAT_REG 0x0007
  138. #define ATA_TASK_CMD_REG 0x0007
  139. #define ATA_ALT_STAT_REG 0x0008
  140. // ATA status register equates
  141. #define ATA_ST_ERROR 0x01
  142. #define ATA_ST_INDEX 0x02
  143. #define ATA_ST_CORRCTD 0x04
  144. #define ATA_ST_DRQ 0x08
  145. #define ATA_ST_SEEK_COMPL 0x10
  146. #define ATA_ST_WRT_FLT 0x20
  147. #define ATA_ST_READY 0x40
  148. #define ATA_ST_BUSY 0x80
  149. // ATA error register equates
  150. #define ATA_ERROR_ABORTED_COMMAND 0x04
  151. // miscellaneous equates
  152. #define BUS_LINES_IN_HIGH_IMPEDANCE 0xFF
  153. #define SKIP_MEMORY_ADDRESS ((unsigned long)(-1L))
  154. #define SHTL_NO_ERROR 0x0000
  155. #define IsShtlError(x) (x & 0x8000)
  156. #define IsImpactPresent() ( IMPACT_VERSION == ParStlReadReg ( Extension, VERSION_REGISTER ) )
  157. #define IsImpactSPresent() ( IMPACTS_VERSION <= ParStlReadReg ( Extension, VERSION_REGISTER ) )
  158. #define IsEp1284Present() ( EP1284_VERSION == ParStlReadReg ( Extension, VERSION_REGISTER ) )
  159. #define IsEpatPlusPresent() ( EPATP_VERSION == ParStlReadReg ( Extension, VERSION_REGISTER ) )
  160. #define IsEpezPresent() ( EPEZ_VERSION == ParStlReadReg ( Extension, VERSION_REGISTER ) )
  161. #define IsEpatPresent() ( EPAT_VERSION == ParStlReadReg ( Extension, VERSION_REGISTER ) )
  162. #define IsEpstPresent() ( EPST_VERSION == ParStlReadReg ( Extension, VERSION_REGISTER ) )
  163. #define NeedToEnableIoPads() ( EP1284_VERSION <= ParStlReadReg ( Extension, VERSION_REGISTER ) )
  164. // Identify command processing related defines..
  165. #define ATAPI_IDENTIFY_LENGTH 512
  166. #define ATAPI_NAME_LENGTH 10
  167. #define ATAPI_NAME_OFFSET 84
  168. // EP1284 related equates
  169. #define EP1284_BLK_ADDR_REGISTER 0x0A
  170. #define EP1284_MODE_REGISTER 0x0C
  171. #define VERSION_REGISTER 0x0B
  172. #define EP1284_TRANSFER_CONTROL_REG 0x12
  173. #define EP1284_PERSONALITY_REG 0x01
  174. #define EPAT_MODE_REGISTER 0x0C
  175. #define SOCKET_CONTROL_REGISTER 0x0C
  176. #define ISA_CONTROL_REGISTER 0x0D
  177. #define CONFIG_INDEX_REGISTER 0x0E
  178. #define CONFIG_DATA_REGISTER 0x0F
  179. #define SHTL_CARD_INSERTED_STATUS 0x02
  180. #define XFER_IRQ_BIT 0x20
  181. #define EP1284_POWER_CONTROL_REG 0x0F
  182. #define ENABLE_IOPADS 0x04
  183. // IMPACT related equates
  184. #define IMPACT_PERSONALITY_REG 0x01
  185. // IMPACT-S related equates
  186. #define IMPACTS_EXT_PERSONALITY_PRESENT 0x0A // 0xA0 >> 4
  187. #define IMPACTS_EXT_PERSONALITY_XREG 0x29
  188. // shuttle version number related equates
  189. #define EPST_VERSION 0xB2
  190. #define EPAT_VERSION 0xC3
  191. #define EPEZ_VERSION 0xC5
  192. #define EPATP_VERSION 0xC6
  193. #define EP1284_VERSION 0xC7
  194. #define IMPACT_VERSION 0xC8
  195. #define IMPACTS_VERSION 0xC9
  196. #define EP1284_ENABLE_16BIT 0x10
  197. #define EPAT_RESET_POLARITY 0x20
  198. #define ISA_IO_SWAP 0x20
  199. #define SOCKET_0 0x00
  200. #define SOCKET_1 0x01
  201. #define PERIPHERAL_RESET_1 0x20
  202. #define PERIPHERAL_RESET_0 0x10
  203. // block xfer related op-codes
  204. #define OP_NIBBLE_BLOCK_READ 0x07
  205. // test pattern equates
  206. #define TEST_PATTERN_1 0x55
  207. #define TEST_PATTERN_2 0xAA
  208. // Memory detection related equates
  209. #define SELECT_DRAM 0x80
  210. #define SELECT_SRAM 0x7F
  211. #define RESET_PTR 0x01
  212. #define ENABLE_MEM 0x04
  213. #define EP1284_CONTROL_REG 0x13
  214. #define EP1284_BUFFER_DATA_REG 0x10
  215. // IMPACT device type defines
  216. #define IMPACT_DEVICE_TYPE_NONE 0
  217. #define IMPACT_DEVICE_TYPE_ATA_ATAPI 1
  218. #define IMPACT_DEVICE_TYPE_PCMCIA_CF 2
  219. #define IMPACT_DEVICE_TYPE_SSFDC 3
  220. #define IMPACT_DEVICE_TYPE_MMC 4
  221. #define IMPACT_DEVICE_TYPE_HIFD 5
  222. #define IMPACT_DEVICE_TYPE_SOUND 6
  223. #define IMPACT_DEVICE_TYPE_FLP_TAPE_DSK 7
  224. #define IMPACT_DEVICE_TYPE_CF 8
  225. #define IMPACT_DEVICE_TYPE_ATA_ATAPI_8BIT 9
  226. // parallel port signal equates
  227. #define SLCT_IN_DISABLE 0x04
  228. #define SLCT_IN_ENABLE 0x0C
  229. #define STB_INIT_LOW 0x01
  230. #define STB_INIT_AFXT_LO 0x03
  231. #define INIT_AFXT_HIGH 0x05
  232. #define STB_INIT_AFXT_HI 0x04
  233. #define STB_INIT_HIGH 0x04
  234. #define AFXT_HI_STB_HI 0x04
  235. #define AFXT_LO_STB_HI 0x06
  236. #define AFXT_HI_STB_LO 0x05
  237. #define AFXT_LO_STB_LO 0x07
  238. // structure definitions
  239. typedef struct _ATAPI_PARAMS{
  240. DEVICE_STATE dsDeviceState[ATAPI_MAX_DRIVES];
  241. char szAtapiNameString [ ATAPI_NAME_LENGTH ] ;
  242. } ATAPIPARAMS, *PATAPIPARAMS ;
  243. // function prototypes
  244. BOOLEAN
  245. ParStlCheckIfStl(
  246. IN PDEVICE_EXTENSION Extension,
  247. IN ULONG ulDaisyIndex
  248. ) ;
  249. BOOLEAN
  250. ParStlCheckIfNon1284_3Present(
  251. IN PDEVICE_EXTENSION Extension
  252. ) ;
  253. BOOLEAN
  254. ParStlCheckIfStl1284_3(
  255. IN PDEVICE_EXTENSION Extension,
  256. IN ULONG ulDaisyIndex,
  257. IN BOOLEAN bNoStrobe
  258. ) ;
  259. BOOLEAN
  260. ParStlCheckIfStlProductId(
  261. IN PDEVICE_EXTENSION Extension,
  262. IN ULONG ulDaisyIndex
  263. ) ;
  264. PCHAR
  265. ParQueryStlDeviceId(
  266. IN PDEVICE_EXTENSION Extension,
  267. OUT PCHAR CallerDeviceIdBuffer, OPTIONAL
  268. IN ULONG CallerBufferSize,
  269. OUT PULONG DeviceIdSize,
  270. IN BOOLEAN bReturnRawString
  271. ) ;
  272. PCHAR
  273. ParBuildStlDeviceId(
  274. IN PDEVICE_EXTENSION Extension
  275. ) ;
  276. STL_DEVICE_TYPE __cdecl
  277. ParStlGetDeviceType (
  278. IN PDEVICE_EXTENSION Extension,
  279. IN int nPreferredDeviceType
  280. ) ;
  281. VOID
  282. ParStlSet16BitOperation (
  283. IN PDEVICE_EXTENSION Extension
  284. ) ;
  285. BOOLEAN
  286. ParStlCheckDrivePresent (
  287. IN PDEVICE_EXTENSION Extension,
  288. IN OUT PATAPIPARAMS atapiParams
  289. ) ;
  290. BOOLEAN
  291. ParStlWaitForBusyToClear (
  292. IN PDEVICE_EXTENSION Extension,
  293. IN int nRegisterToWaitOn
  294. ) ;
  295. BOOLEAN
  296. ParStlWaitForDrq (
  297. IN PDEVICE_EXTENSION Extension
  298. ) ;
  299. BOOLEAN
  300. ParStlWaitForIrq (
  301. IN PDEVICE_EXTENSION Extension
  302. ) ;
  303. BOOLEAN
  304. ParStlCheckIfAtaAtapiDevice (
  305. IN PDEVICE_EXTENSION Extension,
  306. IN OUT PATAPIPARAMS atapiParams
  307. ) ;
  308. BOOLEAN
  309. ParStlAtapiInitialize (
  310. IN PDEVICE_EXTENSION Extension,
  311. IN OUT PATAPIPARAMS atapiParams
  312. );
  313. BOOLEAN
  314. ParStlAtaInitialize (
  315. IN PDEVICE_EXTENSION Extension,
  316. IN OUT PATAPIPARAMS atapiParams
  317. ) ;
  318. BOOLEAN
  319. ParStlCheckIfScsiDevice (
  320. IN PDEVICE_EXTENSION Extension
  321. ) ;
  322. BOOLEAN
  323. ParStlCheckIfSSFDC (
  324. IN PDEVICE_EXTENSION Extension
  325. ) ;
  326. BOOLEAN
  327. ParStlCheckIfMMC (
  328. IN PDEVICE_EXTENSION Extension,
  329. IN OUT PATAPIPARAMS atapiParams
  330. ) ;
  331. BOOLEAN
  332. ParStlCheckIfFlash (
  333. IN PDEVICE_EXTENSION Extension
  334. ) ;
  335. BOOLEAN
  336. ParStlCheckIfDazzle (
  337. IN PDEVICE_EXTENSION Extension
  338. ) ;
  339. BOOLEAN
  340. ParStlCheckIfAtapiDevice (
  341. IN PDEVICE_EXTENSION Extension,
  342. IN OUT PATAPIPARAMS atapiParams
  343. ) ;
  344. BOOLEAN
  345. ParStlCheckIfLS120 (
  346. IN PDEVICE_EXTENSION Extension
  347. ) ;
  348. BOOLEAN
  349. ParStlCheckIfImpactLS120 (
  350. IN PDEVICE_EXTENSION Extension,
  351. IN OUT PATAPIPARAMS atapiParams
  352. ) ;
  353. BOOLEAN
  354. ParStlCheckIfHiFD (
  355. IN PDEVICE_EXTENSION Extension
  356. ) ;
  357. BOOLEAN
  358. ParStlCheckIfAtaDevice (
  359. IN PDEVICE_EXTENSION Extension,
  360. IN OUT PATAPIPARAMS atapiParams
  361. ) ;
  362. BOOLEAN
  363. ParStlCheckCardInsertionStatus (
  364. IN PDEVICE_EXTENSION Extension
  365. ) ;
  366. BOOLEAN
  367. ParStlSelectAdapterSocket (
  368. IN PDEVICE_EXTENSION Extension,
  369. int nSocketNumber
  370. ) ;
  371. VOID
  372. ParStlWaitForMicroSeconds (
  373. int nMicroSecondsToWait
  374. ) ;
  375. STL_DEVICE_TYPE
  376. ParStlGetImpactDeviceType (
  377. IN PDEVICE_EXTENSION Extension,
  378. IN OUT PATAPIPARAMS atapiParams,
  379. IN int nPreferredDeviceType
  380. ) ;
  381. STL_DEVICE_TYPE
  382. ParStlGetImpactSDeviceType (
  383. IN PDEVICE_EXTENSION Extension,
  384. IN OUT PATAPIPARAMS atapiParams,
  385. IN int nPreferredDeviceType
  386. ) ;
  387. BOOLEAN
  388. ParStlCheckIfEppDevice (
  389. IN PDEVICE_EXTENSION Extension
  390. ) ;
  391. BOOLEAN
  392. ParStlCheckPersonalityForEppDevice (
  393. IN PDEVICE_EXTENSION Extension
  394. ) ;
  395. BOOLEAN
  396. ParStlCheckFlashPersonality (
  397. IN PDEVICE_EXTENSION Extension
  398. ) ;
  399. BOOLEAN
  400. ParStlHIFDCheckIfControllerReady (
  401. IN PDEVICE_EXTENSION Extension
  402. ) ;
  403. BOOLEAN
  404. ParStlHIFDCheckSMCController (
  405. IN PDEVICE_EXTENSION Extension
  406. ) ;
  407. BOOLEAN
  408. ParStlIsMMCEnginePresent(
  409. IN PDEVICE_EXTENSION Extension
  410. );
  411. VOID
  412. ParStlAssertIdleState (
  413. IN PDEVICE_EXTENSION Extension
  414. ) ;
  415. BOOLEAN
  416. ParStlCheckUMAXScannerPresence(
  417. IN PDEVICE_EXTENSION Extension
  418. ) ;
  419. BOOLEAN
  420. ParStlCheckAvisionScannerPresence(
  421. IN PDEVICE_EXTENSION Extension
  422. ) ;
  423. BOOLEAN
  424. ParStlSetEPPMode(
  425. IN PDEVICE_EXTENSION Extension
  426. ) ;
  427. USHORT
  428. ParStlEPPWrite(
  429. IN PDEVICE_EXTENSION Extension,
  430. IN UCHAR value
  431. ) ;
  432. USHORT
  433. ParStlEPPRead(
  434. IN PDEVICE_EXTENSION
  435. ) ;
  436. int __cdecl
  437. ParStlReadReg(
  438. IN PDEVICE_EXTENSION Extension,
  439. IN unsigned int reg
  440. ) ;
  441. int __cdecl
  442. ParStlWriteReg(
  443. IN PDEVICE_EXTENSION Extension,
  444. IN unsigned int reg,
  445. IN int databyte
  446. ) ;
  447. int __cdecl
  448. ParStlReadIoPort(
  449. IN PDEVICE_EXTENSION Extension,
  450. IN unsigned int reg
  451. ) ;
  452. int __cdecl
  453. ParStlWriteIoPort(
  454. IN PDEVICE_EXTENSION Extension,
  455. IN unsigned int reg,
  456. IN int databyte
  457. ) ;
  458. int __cdecl
  459. ParStlReceiveData(
  460. IN PDEVICE_EXTENSION Extension,
  461. OUT void *hostBufferPointer,
  462. IN long shuttleMemoryAddress,
  463. IN unsigned count
  464. ) ;
  465. int __cdecl
  466. ParStlGetMemorySize (
  467. IN PDEVICE_EXTENSION Extension
  468. ) ;
  469. #endif // for _PARSTL_H_