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.

560 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 PPDO_EXTENSION Extension,
  247. IN ULONG ulDaisyIndex
  248. ) ;
  249. BOOLEAN
  250. ParStlCheckIfNon1284_3Present(
  251. IN PPDO_EXTENSION Extension
  252. ) ;
  253. BOOLEAN
  254. ParStlCheckIfStl1284_3(
  255. IN PPDO_EXTENSION Extension,
  256. IN ULONG ulDaisyIndex,
  257. IN BOOLEAN bNoStrobe
  258. ) ;
  259. BOOLEAN
  260. ParStlCheckIfStlProductId(
  261. IN PPDO_EXTENSION Extension,
  262. IN ULONG ulDaisyIndex
  263. ) ;
  264. PCHAR
  265. ParQueryStlDeviceId(
  266. IN PPDO_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 PPDO_EXTENSION Extension,
  275. IN BOOLEAN bReturnRawString
  276. ) ;
  277. STL_DEVICE_TYPE __cdecl
  278. ParStlGetDeviceType (
  279. IN PPDO_EXTENSION Extension,
  280. IN int nPreferredDeviceType
  281. ) ;
  282. VOID
  283. ParStlSet16BitOperation (
  284. IN PPDO_EXTENSION Extension
  285. ) ;
  286. BOOLEAN
  287. ParStlCheckDrivePresent (
  288. IN PPDO_EXTENSION Extension,
  289. IN OUT PATAPIPARAMS atapiParams
  290. ) ;
  291. BOOLEAN
  292. ParStlWaitForBusyToClear (
  293. IN PPDO_EXTENSION Extension,
  294. IN int nRegisterToWaitOn
  295. ) ;
  296. BOOLEAN
  297. ParStlWaitForDrq (
  298. IN PPDO_EXTENSION Extension
  299. ) ;
  300. BOOLEAN
  301. ParStlWaitForIrq (
  302. IN PPDO_EXTENSION Extension
  303. ) ;
  304. BOOLEAN
  305. ParStlCheckIfAtaAtapiDevice (
  306. IN PPDO_EXTENSION Extension,
  307. IN OUT PATAPIPARAMS atapiParams
  308. ) ;
  309. BOOLEAN
  310. ParStlAtapiInitialize (
  311. IN PPDO_EXTENSION Extension,
  312. IN OUT PATAPIPARAMS atapiParams
  313. );
  314. BOOLEAN
  315. ParStlAtaInitialize (
  316. IN PPDO_EXTENSION Extension,
  317. IN OUT PATAPIPARAMS atapiParams
  318. ) ;
  319. BOOLEAN
  320. ParStlCheckIfScsiDevice (
  321. IN PPDO_EXTENSION Extension
  322. ) ;
  323. BOOLEAN
  324. ParStlCheckIfSSFDC (
  325. IN PPDO_EXTENSION Extension
  326. ) ;
  327. BOOLEAN
  328. ParStlCheckIfMMC (
  329. IN PPDO_EXTENSION Extension,
  330. IN OUT PATAPIPARAMS atapiParams
  331. ) ;
  332. BOOLEAN
  333. ParStlCheckIfFlash (
  334. IN PPDO_EXTENSION Extension
  335. ) ;
  336. BOOLEAN
  337. ParStlCheckIfDazzle (
  338. IN PPDO_EXTENSION Extension
  339. ) ;
  340. BOOLEAN
  341. ParStlCheckIfAtapiDevice (
  342. IN PPDO_EXTENSION Extension,
  343. IN OUT PATAPIPARAMS atapiParams
  344. ) ;
  345. BOOLEAN
  346. ParStlCheckIfLS120 (
  347. IN PPDO_EXTENSION Extension
  348. ) ;
  349. BOOLEAN
  350. ParStlCheckIfImpactLS120 (
  351. IN PPDO_EXTENSION Extension,
  352. IN OUT PATAPIPARAMS atapiParams
  353. ) ;
  354. BOOLEAN
  355. ParStlCheckIfHiFD (
  356. IN PPDO_EXTENSION Extension
  357. ) ;
  358. BOOLEAN
  359. ParStlCheckIfAtaDevice (
  360. IN PPDO_EXTENSION Extension,
  361. IN OUT PATAPIPARAMS atapiParams
  362. ) ;
  363. BOOLEAN
  364. ParStlCheckCardInsertionStatus (
  365. IN PPDO_EXTENSION Extension
  366. ) ;
  367. BOOLEAN
  368. ParStlSelectAdapterSocket (
  369. IN PPDO_EXTENSION Extension,
  370. int nSocketNumber
  371. ) ;
  372. VOID
  373. ParStlWaitForMicroSeconds (
  374. int nMicroSecondsToWait
  375. ) ;
  376. STL_DEVICE_TYPE
  377. ParStlGetImpactDeviceType (
  378. IN PPDO_EXTENSION Extension,
  379. IN OUT PATAPIPARAMS atapiParams,
  380. IN int nPreferredDeviceType
  381. ) ;
  382. STL_DEVICE_TYPE
  383. ParStlGetImpactSDeviceType (
  384. IN PPDO_EXTENSION Extension,
  385. IN OUT PATAPIPARAMS atapiParams,
  386. IN int nPreferredDeviceType
  387. ) ;
  388. BOOLEAN
  389. ParStlCheckIfEppDevice (
  390. IN PPDO_EXTENSION Extension
  391. ) ;
  392. BOOLEAN
  393. ParStlCheckPersonalityForEppDevice (
  394. IN PPDO_EXTENSION Extension
  395. ) ;
  396. BOOLEAN
  397. ParStlCheckFlashPersonality (
  398. IN PPDO_EXTENSION Extension
  399. ) ;
  400. BOOLEAN
  401. ParStlHIFDCheckIfControllerReady (
  402. IN PPDO_EXTENSION Extension
  403. ) ;
  404. BOOLEAN
  405. ParStlHIFDCheckSMCController (
  406. IN PPDO_EXTENSION Extension
  407. ) ;
  408. BOOLEAN
  409. ParStlIsMMCEnginePresent(
  410. IN PPDO_EXTENSION Extension
  411. );
  412. VOID
  413. ParStlAssertIdleState (
  414. IN PPDO_EXTENSION Extension
  415. ) ;
  416. BOOLEAN
  417. ParStlCheckUMAXScannerPresence(
  418. IN PPDO_EXTENSION Extension
  419. ) ;
  420. BOOLEAN
  421. ParStlCheckAvisionScannerPresence(
  422. IN PPDO_EXTENSION Extension
  423. ) ;
  424. BOOLEAN
  425. ParStlSetEPPMode(
  426. IN PPDO_EXTENSION Extension
  427. ) ;
  428. USHORT
  429. ParStlEPPWrite(
  430. IN PPDO_EXTENSION Extension,
  431. IN UCHAR value
  432. ) ;
  433. USHORT
  434. ParStlEPPRead(
  435. IN PPDO_EXTENSION
  436. ) ;
  437. int __cdecl
  438. ParStlReadReg(
  439. IN PPDO_EXTENSION Extension,
  440. IN unsigned int reg
  441. ) ;
  442. int __cdecl
  443. ParStlWriteReg(
  444. IN PPDO_EXTENSION Extension,
  445. IN unsigned int reg,
  446. IN int databyte
  447. ) ;
  448. int __cdecl
  449. ParStlReadIoPort(
  450. IN PPDO_EXTENSION Extension,
  451. IN unsigned int reg
  452. ) ;
  453. int __cdecl
  454. ParStlWriteIoPort(
  455. IN PPDO_EXTENSION Extension,
  456. IN unsigned int reg,
  457. IN int databyte
  458. ) ;
  459. int __cdecl
  460. ParStlReceiveData(
  461. IN PPDO_EXTENSION Extension,
  462. OUT void *hostBufferPointer,
  463. IN long shuttleMemoryAddress,
  464. IN unsigned count
  465. ) ;
  466. int __cdecl
  467. ParStlGetMemorySize (
  468. IN PPDO_EXTENSION Extension
  469. ) ;
  470. #endif // for _PARSTL_H_