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.

754 lines
26 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. parallel.h
  5. Abstract:
  6. This file defines the services supplied by the ParPort driver.
  7. Author:
  8. norbertk
  9. Revision History:
  10. --*/
  11. #ifndef _PARALLEL_
  12. #define _PARALLEL_
  13. #include <ntddpar.h>
  14. //
  15. // Define the parallel port device name strings.
  16. //
  17. #define DD_PARALLEL_PORT_BASE_NAME_U L"ParallelPort"
  18. //
  19. // IEEE 1284.3 Daisy Chain (DC) Device ID's range from 0 to 3. Devices
  20. // are identified based on their connection order in the daisy chain
  21. // relative to the other 1284.3 DC devices. Device 0 is the 1284.3 DC
  22. // device that is closest to host port.
  23. //
  24. #define IEEE_1284_3_DAISY_CHAIN_MAX_ID 3
  25. //
  26. // NtDeviceIoControlFile internal IoControlCode values for parallel device.
  27. //
  28. // Legacy - acquires entire parallel "bus"
  29. #define IOCTL_INTERNAL_PARALLEL_PORT_ALLOCATE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
  30. #define IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
  31. #define IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
  32. #define IOCTL_INTERNAL_PARALLEL_DISCONNECT_INTERRUPT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 14, METHOD_BUFFERED, FILE_ANY_ACCESS)
  33. #define IOCTL_INTERNAL_RELEASE_PARALLEL_PORT_INFO CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  34. #define IOCTL_INTERNAL_GET_MORE_PARALLEL_PORT_INFO CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 17, METHOD_BUFFERED, FILE_ANY_ACCESS)
  35. // Saves current chipset mode - puts the chipset into Specified mode (implemented in filter)
  36. #define IOCTL_INTERNAL_PARCHIP_CONNECT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)
  37. #define IOCTL_INTERNAL_PARALLEL_SET_CHIP_MODE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 19, METHOD_BUFFERED, FILE_ANY_ACCESS)
  38. #define IOCTL_INTERNAL_PARALLEL_CLEAR_CHIP_MODE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
  39. // New parport IOCTLs
  40. #define IOCTL_INTERNAL_GET_PARALLEL_PNP_INFO CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
  41. #define IOCTL_INTERNAL_INIT_1284_3_BUS CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 22, METHOD_BUFFERED, FILE_ANY_ACCESS)
  42. // Takes a flat namespace Id for the device, also acquires the port
  43. #define IOCTL_INTERNAL_SELECT_DEVICE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
  44. // Takes a flat namespace Id for the device, also releases the port
  45. #define IOCTL_INTERNAL_DESELECT_DEVICE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 24, METHOD_BUFFERED, FILE_ANY_ACCESS)
  46. // New parclass IOCTLs
  47. #define IOCTL_INTERNAL_GET_PARPORT_FDO CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 29, METHOD_BUFFERED, FILE_ANY_ACCESS)
  48. #define IOCTL_INTERNAL_PARCLASS_CONNECT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
  49. #define IOCTL_INTERNAL_PARCLASS_DISCONNECT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 31, METHOD_BUFFERED, FILE_ANY_ACCESS)
  50. #define IOCTL_INTERNAL_DISCONNECT_IDLE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 32, METHOD_BUFFERED, FILE_ANY_ACCESS)
  51. #define IOCTL_INTERNAL_LOCK_PORT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 37, METHOD_BUFFERED, FILE_ANY_ACCESS)
  52. #define IOCTL_INTERNAL_UNLOCK_PORT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 38, METHOD_BUFFERED, FILE_ANY_ACCESS)
  53. // IOCTL version of call to ParPort's FreePort function
  54. #define IOCTL_INTERNAL_PARALLEL_PORT_FREE CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 40, METHOD_BUFFERED, FILE_ANY_ACCESS)
  55. // IOCTLs for IEEE1284.3
  56. #define IOCTL_INTERNAL_PARDOT3_CONNECT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 41, METHOD_BUFFERED, FILE_ANY_ACCESS)
  57. #define IOCTL_INTERNAL_PARDOT3_DISCONNECT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
  58. #define IOCTL_INTERNAL_PARDOT3_RESET CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 43, METHOD_BUFFERED, FILE_ANY_ACCESS)
  59. #define IOCTL_INTERNAL_PARDOT3_SIGNAL CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 44, METHOD_BUFFERED, FILE_ANY_ACCESS)
  60. //
  61. // IOCTLs for registering/unregistering for ParPort's RemovalRelations
  62. //
  63. // - A device object should register for removal relations with a
  64. // parport device if the device is physically connected to the
  65. // parallel port.
  66. //
  67. // - Parport will report all devices that have registered with it for
  68. // removal relations in response to a PnP QUERY_DEVICE_RELATIONS of
  69. // type RemovalRelations. This allows PnP to remove all device stacks
  70. // that depend on the parport device prior to removing the parport
  71. // device itself.
  72. //
  73. // - The single Input parameter is a PARPORT_REMOVAL_RELATIONS
  74. // structure that is defined below
  75. //
  76. #define IOCTL_INTERNAL_REGISTER_FOR_REMOVAL_RELATIONS CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 50, METHOD_BUFFERED, FILE_ANY_ACCESS)
  77. #define IOCTL_INTERNAL_UNREGISTER_FOR_REMOVAL_RELATIONS CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 51, METHOD_BUFFERED, FILE_ANY_ACCESS)
  78. typedef struct _PARPORT_REMOVAL_RELATIONS {
  79. PDEVICE_OBJECT DeviceObject; // device object that is registering w/Parport
  80. ULONG Flags; // Flags - reserved - set to 0 for now
  81. PUNICODE_STRING DeviceName; // DeviceName identifier of device registering for removal relations - used for debugging
  82. // - printed in parport's debug spew - convention is to use same DeviceName that was passed to
  83. // IoCreateDevice
  84. } PARPORT_REMOVAL_RELATIONS, *PPARPORT_REMOVAL_RELATIONS;
  85. #define IOCTL_INTERNAL_LOCK_PORT_NO_SELECT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 52, METHOD_BUFFERED, FILE_ANY_ACCESS)
  86. #define IOCTL_INTERNAL_UNLOCK_PORT_NO_DESELECT CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 53, METHOD_BUFFERED, FILE_ANY_ACCESS)
  87. #define IOCTL_INTERNAL_DISABLE_END_OF_CHAIN_BUS_RESCAN CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 54, METHOD_BUFFERED, FILE_ANY_ACCESS)
  88. #define IOCTL_INTERNAL_ENABLE_END_OF_CHAIN_BUS_RESCAN CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 55, METHOD_BUFFERED, FILE_ANY_ACCESS)
  89. // Define 1284.3 command qualifiers
  90. #define MODE_LEN_1284_3 7 // # of magic sequence bytes
  91. static UCHAR ModeQualifier[MODE_LEN_1284_3] = { 0xAA, 0x55, 0x00, 0xFF, 0x87, 0x78, 0xFF };
  92. #define LEGACYZIP_MODE_LEN 3
  93. static UCHAR LegacyZipModeQualifier[LEGACYZIP_MODE_LEN] = { 0x00, 0x3c, 0x20 };
  94. typedef enum {
  95. P12843DL_OFF,
  96. P12843DL_DOT3_DL,
  97. P12843DL_MLC_DL,
  98. P12843DL_DOT4_DL
  99. } P12843_DL_MODES;
  100. // Define 1284.3 Commands
  101. #define CPP_ASSIGN_ADDR 0x00
  102. #define CPP_SELECT 0xE0
  103. #define CPP_DESELECT 0x30
  104. #define CPP_QUERY_INT 0x08
  105. #define CPP_DISABLE_INT 0x40
  106. #define CPP_ENABLE_INT 0x48
  107. #define CPP_CLEAR_INT_LAT 0x50
  108. #define CPP_SET_INT_LAT 0x58
  109. #define CPP_COMMAND_FILTER 0xF8
  110. typedef
  111. BOOLEAN
  112. (*PPARALLEL_TRY_ALLOCATE_ROUTINE) (
  113. IN PVOID TryAllocateContext
  114. );
  115. typedef
  116. VOID
  117. (*PPARALLEL_FREE_ROUTINE) (
  118. IN PVOID FreeContext
  119. );
  120. typedef
  121. ULONG
  122. (*PPARALLEL_QUERY_WAITERS_ROUTINE) (
  123. IN PVOID QueryAllocsContext
  124. );
  125. typedef
  126. NTSTATUS
  127. (*PPARALLEL_SET_CHIP_MODE) (
  128. IN PVOID SetChipContext,
  129. IN UCHAR ChipMode
  130. );
  131. typedef
  132. NTSTATUS
  133. (*PPARALLEL_CLEAR_CHIP_MODE) (
  134. IN PVOID ClearChipContext,
  135. IN UCHAR ChipMode
  136. );
  137. typedef
  138. NTSTATUS
  139. (*PPARALLEL_TRY_SELECT_ROUTINE) (
  140. IN PVOID TrySelectContext,
  141. IN PVOID TrySelectCommand
  142. );
  143. typedef
  144. NTSTATUS
  145. (*PPARALLEL_DESELECT_ROUTINE) (
  146. IN PVOID DeselectContext,
  147. IN PVOID DeselectCommand
  148. );
  149. typedef
  150. NTSTATUS
  151. (*PPARCHIP_SET_CHIP_MODE) (
  152. IN PVOID SetChipContext,
  153. IN UCHAR ChipMode
  154. );
  155. typedef
  156. NTSTATUS
  157. (*PPARCHIP_CLEAR_CHIP_MODE) (
  158. IN PVOID ClearChipContext,
  159. IN UCHAR ChipMode
  160. );
  161. //
  162. // Hardware Capabilities
  163. //
  164. #define PPT_NO_HARDWARE_PRESENT 0x00000000
  165. #define PPT_ECP_PRESENT 0x00000001
  166. #define PPT_EPP_PRESENT 0x00000002
  167. #define PPT_EPP_32_PRESENT 0x00000004
  168. #define PPT_BYTE_PRESENT 0x00000008
  169. #define PPT_BIDI_PRESENT 0x00000008 // deprecated - will be removed soon! dvdf
  170. #define PPT_1284_3_PRESENT 0x00000010
  171. // Added DVDR 10-6-98
  172. // Structure passed to the ParChip Filter when calling it
  173. // with the IOCTL_INTERNAL_CHIP_FILTER_CONNECT ioctl
  174. typedef struct _PARALLEL_PARCHIP_INFO {
  175. PUCHAR Controller;
  176. PUCHAR EcrController;
  177. ULONG HardwareModes;
  178. PPARCHIP_SET_CHIP_MODE ParChipSetMode;
  179. PPARCHIP_CLEAR_CHIP_MODE ParChipClearMode;
  180. PVOID Context;
  181. BOOLEAN success;
  182. } PARALLEL_PARCHIP_INFO, *PPARALLEL_PARCHIP_INFO;
  183. // End Added by DVDR 10-6-1998
  184. typedef struct _PARALLEL_PORT_INFORMATION {
  185. PHYSICAL_ADDRESS OriginalController;
  186. PUCHAR Controller;
  187. ULONG SpanOfController;
  188. PPARALLEL_TRY_ALLOCATE_ROUTINE TryAllocatePort; // nonblocking callback to allocate port
  189. PPARALLEL_FREE_ROUTINE FreePort; // callback to free port
  190. PPARALLEL_QUERY_WAITERS_ROUTINE QueryNumWaiters; // callback to query number of waiters for port allocation
  191. PVOID Context; // context for callbacks to ParPort device
  192. } PARALLEL_PORT_INFORMATION, *PPARALLEL_PORT_INFORMATION;
  193. typedef struct _PARALLEL_PNP_INFORMATION {
  194. PHYSICAL_ADDRESS OriginalEcpController;
  195. PUCHAR EcpController;
  196. ULONG SpanOfEcpController;
  197. ULONG PortNumber; // deprecated - do not use
  198. ULONG HardwareCapabilities;
  199. PPARALLEL_SET_CHIP_MODE TrySetChipMode;
  200. PPARALLEL_CLEAR_CHIP_MODE ClearChipMode;
  201. ULONG FifoDepth;
  202. ULONG FifoWidth;
  203. PHYSICAL_ADDRESS EppControllerPhysicalAddress;
  204. ULONG SpanOfEppController;
  205. ULONG Ieee1284_3DeviceCount; // number of .3 daisy chain devices connected to this ParPort
  206. PPARALLEL_TRY_SELECT_ROUTINE TrySelectDevice;
  207. PPARALLEL_DESELECT_ROUTINE DeselectDevice;
  208. PVOID Context;
  209. ULONG CurrentMode;
  210. PWSTR PortName; // symbolic link name for legacy device object
  211. } PARALLEL_PNP_INFORMATION, *PPARALLEL_PNP_INFORMATION;
  212. // Start Added by DVDR 2-19-1998
  213. //
  214. // PARALLEL_1284_COMMAND CommandFlags
  215. //
  216. // this flag is deprecated - use 1284.3 daisy chain ID == 4 to indicate End-Of-Chain device
  217. #define PAR_END_OF_CHAIN_DEVICE ((ULONG)0x00000001) // The target device for this command
  218. // is an End-Of-Chain device, the
  219. // contents of the ID field are
  220. // undefined and should be ignored
  221. #define PAR_HAVE_PORT_KEEP_PORT ((ULONG)0x00000002) // Indicates that the requesting driver
  222. // has previously acquired the parallel port
  223. // and does is not ready to release it yet.
  224. //
  225. // On a SELECT_DEVICE ParPort should NOT
  226. // try to acquire the port before selecting
  227. // the device.
  228. //
  229. // On a DESELECT_DEVICE ParPort should NOT
  230. // free the port after deselecting the device.
  231. #define PAR_LEGACY_ZIP_DRIVE ((ULONG)0x00000004) // The target device for this command
  232. // is a Legacy Iomega Zip drive, the
  233. // contents of the ID field are
  234. // undefined and should be ignored
  235. #define PAR_LEGACY_ZIP_DRIVE_STD_MODE ((ULONG)0x00000010) // The target device for these commands
  236. #define PAR_LEGACY_ZIP_DRIVE_EPP_MODE ((ULONG)0x00000020) // are a Legacy Iomega Zip drive, the
  237. // contents of the ID field are
  238. // undefined and should be ignored
  239. // This will select the Zip into DISK or EPP Mode
  240. #define DOT3_END_OF_CHAIN_ID 4 // this ID used in a 1284.3 SELECT or DESELECT means the End-Of-Chain device
  241. #define DOT3_LEGACY_ZIP_ID 5 // this ID used in a 1284.3 SELECT or DESELECT means Legacy Zip drive
  242. //
  243. // The following structure is passed in on an
  244. // IOCTL_INTERNAL_SELECT_DEVICE and on an
  245. // IOCTL_INTERNAL_DESELECT_DEVICE
  246. typedef struct _PARALLEL_1284_COMMAND {
  247. UCHAR ID; // 0..3 for 1284.3 daisy chain device, 4 for End-Of-Chain device, 5 for Legacy Zip
  248. UCHAR Port; // reserved ( set == 0 )
  249. ULONG CommandFlags; // see above
  250. } PARALLEL_1284_COMMAND, *PPARALLEL_1284_COMMAND;
  251. //
  252. // Hardware Modes
  253. //
  254. #define INITIAL_MODE 0x00000000
  255. // Disable Parchip and ECR arbitrator
  256. // 0 - Parchip and ecr arbritrator is off
  257. // 1 - Parchip and ecr arbitrator is on
  258. #define PARCHIP_ECR_ARBITRATOR 1
  259. //
  260. // The following structure is passed in on an
  261. // IOCTL_INTERNAL_PARALLEL_SET_CHIP_MODE and on an
  262. // IOCTL_INTERNAL_PARALLEL_CLEAR_CHIP_MODE
  263. //
  264. typedef struct _PARALLEL_CHIP_MODE {
  265. UCHAR ModeFlags;
  266. BOOLEAN success;
  267. } PARALLEL_CHIP_MODE, *PPARALLEL_CHIP_MODE;
  268. // End Added by DVDR 2-19-1998
  269. //
  270. // The following structure is passed in on an
  271. // IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT and on an
  272. // IOCTL_INTERNAL_PARALLEL_DISCONNECT_INTERRUPT request.
  273. //
  274. typedef
  275. VOID
  276. (*PPARALLEL_DEFERRED_ROUTINE) (
  277. IN PVOID DeferredContext
  278. );
  279. typedef struct _PARALLEL_INTERRUPT_SERVICE_ROUTINE {
  280. PKSERVICE_ROUTINE InterruptServiceRoutine;
  281. PVOID InterruptServiceContext;
  282. PPARALLEL_DEFERRED_ROUTINE DeferredPortCheckRoutine; /* OPTIONAL */
  283. PVOID DeferredPortCheckContext; /* OPTIONAL */
  284. } PARALLEL_INTERRUPT_SERVICE_ROUTINE, *PPARALLEL_INTERRUPT_SERVICE_ROUTINE;
  285. //
  286. // The following structure is returned on an
  287. // IOCTL_INTERNAL_PARALLEL_CONNECT_INTERRUPT request;
  288. //
  289. typedef struct _PARALLEL_INTERRUPT_INFORMATION {
  290. PKINTERRUPT InterruptObject;
  291. PPARALLEL_TRY_ALLOCATE_ROUTINE TryAllocatePortAtInterruptLevel;
  292. PPARALLEL_FREE_ROUTINE FreePortFromInterruptLevel;
  293. PVOID Context;
  294. } PARALLEL_INTERRUPT_INFORMATION, *PPARALLEL_INTERRUPT_INFORMATION;
  295. //
  296. // The following structure is returned on an
  297. // IOCTL_INTERNAL_GET_MORE_PARALLEL_PORT_INFO.
  298. //
  299. typedef struct _MORE_PARALLEL_PORT_INFORMATION {
  300. INTERFACE_TYPE InterfaceType;
  301. ULONG BusNumber;
  302. ULONG InterruptLevel;
  303. ULONG InterruptVector;
  304. KAFFINITY InterruptAffinity;
  305. KINTERRUPT_MODE InterruptMode;
  306. } MORE_PARALLEL_PORT_INFORMATION, *PMORE_PARALLEL_PORT_INFORMATION;
  307. typedef enum {
  308. SAFE_MODE,
  309. UNSAFE_MODE // Available only through kernel. Your driver
  310. // will be humiliated if you choose UNSAFE_MODE and
  311. // then "make a mistake". - dvrh (PCized by dvdf)
  312. } PARALLEL_SAFETY;
  313. //
  314. // The following structure is returned by
  315. // IOCTL_INTERNAL_PARCLASS_CONNECT.
  316. //
  317. typedef
  318. USHORT
  319. (*PDETERMINE_IEEE_MODES) (
  320. IN PVOID Context
  321. );
  322. #define OLD_PARCLASS 0
  323. #if OLD_PARCLASS
  324. typedef
  325. NTSTATUS
  326. (*PNEGOTIATE_IEEE_MODE) (
  327. IN PVOID Extension,
  328. IN UCHAR Extensibility
  329. );
  330. #else
  331. typedef
  332. NTSTATUS
  333. (*PNEGOTIATE_IEEE_MODE) (
  334. IN PVOID Context,
  335. IN USHORT ModeMaskFwd,
  336. IN USHORT ModeMaskRev,
  337. IN PARALLEL_SAFETY ModeSafety,
  338. IN BOOLEAN IsForward
  339. );
  340. #endif
  341. typedef
  342. NTSTATUS
  343. (*PTERMINATE_IEEE_MODE) (
  344. IN PVOID Context
  345. );
  346. typedef
  347. NTSTATUS
  348. (*PPARALLEL_IEEE_FWD_TO_REV)(
  349. IN PVOID Context
  350. );
  351. typedef
  352. NTSTATUS
  353. (*PPARALLEL_IEEE_REV_TO_FWD)(
  354. IN PVOID Context
  355. );
  356. typedef
  357. NTSTATUS
  358. (*PPARALLEL_READ) (
  359. IN PVOID Context,
  360. OUT PVOID Buffer,
  361. IN ULONG NumBytesToRead,
  362. OUT PULONG NumBytesRead,
  363. IN UCHAR Channel
  364. );
  365. typedef
  366. NTSTATUS
  367. (*PPARALLEL_WRITE) (
  368. IN PVOID Context,
  369. OUT PVOID Buffer,
  370. IN ULONG NumBytesToWrite,
  371. OUT PULONG NumBytesWritten,
  372. IN UCHAR Channel
  373. );
  374. typedef
  375. NTSTATUS
  376. (*PPARALLEL_TRYSELECT_DEVICE) (
  377. IN PVOID Context,
  378. IN PARALLEL_1284_COMMAND Command
  379. );
  380. typedef
  381. NTSTATUS
  382. (*PPARALLEL_DESELECT_DEVICE) (
  383. IN PVOID Context,
  384. IN PARALLEL_1284_COMMAND Command
  385. );
  386. typedef struct _PARCLASS_INFORMATION {
  387. PUCHAR Controller;
  388. PUCHAR EcrController;
  389. ULONG SpanOfController;
  390. PDETERMINE_IEEE_MODES DetermineIeeeModes;
  391. PNEGOTIATE_IEEE_MODE NegotiateIeeeMode;
  392. PTERMINATE_IEEE_MODE TerminateIeeeMode;
  393. PPARALLEL_IEEE_FWD_TO_REV IeeeFwdToRevMode;
  394. PPARALLEL_IEEE_REV_TO_FWD IeeeRevToFwdMode;
  395. PPARALLEL_READ ParallelRead;
  396. PPARALLEL_WRITE ParallelWrite;
  397. PVOID ParclassContext;
  398. ULONG HardwareCapabilities;
  399. ULONG FifoDepth;
  400. ULONG FifoWidth;
  401. PPARALLEL_TRYSELECT_DEVICE ParallelTryselect;
  402. PPARALLEL_DESELECT_DEVICE ParallelDeSelect;
  403. } PARCLASS_INFORMATION, *PPARCLASS_INFORMATION;
  404. //
  405. // Standard and ECP parallel port offsets.
  406. //
  407. #define DATA_OFFSET 0
  408. #define OFFSET_ECP_AFIFO 0x0000 // ECP Mode Address FIFO
  409. #define AFIFO_OFFSET OFFSET_ECP_AFIFO // ECP Mode Address FIFO
  410. #define DSR_OFFSET 1
  411. #define DCR_OFFSET 2
  412. #define EPP_OFFSET 4
  413. // default to the old defines - note that the old defines break on PCI cards
  414. #ifndef DVRH_USE_PARPORT_ECP_ADDR
  415. #define DVRH_USE_PARPORT_ECP_ADDR 0
  416. #endif
  417. // DVRH_USE_PARPORT_ECP_ADDR settings
  418. // 0 - ECP registers are hardcoded to
  419. // Controller + 0x400
  420. // 1 - ECP registers are pulled from
  421. // Parport which hopefully got
  422. // them from PnP.
  423. #if (0 == DVRH_USE_PARPORT_ECP_ADDR)
  424. // ***Note: These do not hold for PCI parallel ports
  425. #define ECP_OFFSET 0x400
  426. #define CNFGB_OFFSET 0x401
  427. #define ECR_OFFSET 0x402
  428. #else
  429. #define ECP_OFFSET 0x0
  430. #define CNFGB_OFFSET 0x1
  431. #define ECR_OFFSET 0x2
  432. #endif
  433. #define FIFO_OFFSET ECP_OFFSET
  434. #define CFIFO_OFFSET ECP_OFFSET
  435. #define CNFGA_OFFSET ECP_OFFSET
  436. #define ECP_DFIFO_OFFSET ECP_OFFSET // ECP Mode Data FIFO
  437. #define TFIFO_OFFSET ECP_OFFSET
  438. #define OFFSET_ECP_DFIFO ECP_OFFSET // ECP Mode Data FIFO
  439. #define OFFSET_TFIFO ECP_OFFSET // Test FIFO
  440. #define OFFSET_CFIFO ECP_OFFSET // Fast Centronics Data FIFO
  441. #define OFFSET_ECR ECR_OFFSET // Extended Control Register
  442. #define OFFSET_PARALLEL_REGISTER_SPAN 0x0003
  443. #define ECP_SPAN 3
  444. #define EPP_SPAN 4
  445. //
  446. // Bit definitions for the DSR.
  447. //
  448. #define DSR_NOT_BUSY 0x80
  449. #define DSR_NOT_ACK 0x40
  450. #define DSR_PERROR 0x20
  451. #define DSR_SELECT 0x10
  452. #define DSR_NOT_FAULT 0x08
  453. //
  454. // More bit definitions for the DSR.
  455. //
  456. #define DSR_NOT_PTR_BUSY 0x80
  457. #define DSR_NOT_PERIPH_ACK 0x80
  458. #define DSR_WAIT 0x80
  459. #define DSR_PTR_CLK 0x40
  460. #define DSR_PERIPH_CLK 0x40
  461. #define DSR_INTR 0x40
  462. #define DSR_ACK_DATA_REQ 0x20
  463. #define DSR_NOT_ACK_REVERSE 0x20
  464. #define DSR_XFLAG 0x10
  465. #define DSR_NOT_DATA_AVAIL 0x08
  466. #define DSR_NOT_PERIPH_REQUEST 0x08
  467. //
  468. // Bit definitions for the DCR.
  469. //
  470. #define DCR_RESERVED 0xC0
  471. #define DCR_DIRECTION 0x20
  472. #define DCR_ACKINT_ENABLED 0x10
  473. #define DCR_SELECT_IN 0x08
  474. #define DCR_NOT_INIT 0x04
  475. #define DCR_AUTOFEED 0x02
  476. #define DCR_STROBE 0x01
  477. //
  478. // More bit definitions for the DCR.
  479. //
  480. #define DCR_NOT_1284_ACTIVE 0x08
  481. #define DCR_ASTRB 0x08
  482. #define DCR_NOT_REVERSE_REQUEST 0x04
  483. #define DCR_NULL 0x04
  484. #define DCR_NOT_HOST_BUSY 0x02
  485. #define DCR_NOT_HOST_ACK 0x02
  486. #define DCR_DSTRB 0x02
  487. #define DCR_NOT_HOST_CLK 0x01
  488. #define DCR_WRITE 0x01
  489. //
  490. // Bit definitions for configuration register A.
  491. //
  492. #define CNFGA_IMPID_MASK 0x70
  493. #define CNFGA_IMPID_16BIT 0x00
  494. #define CNFGA_IMPID_8BIT 0x10
  495. #define CNFGA_IMPID_32BIT 0x20
  496. #define CNFGA_NO_TRANS_BYTE 0x04
  497. ////////////////////////////////////////////////////////////////////////////////
  498. // ECR values that establish basic hardware modes. In each case, the default
  499. // is to disable error interrupts, DMA, and service interrupts.
  500. ////////////////////////////////////////////////////////////////////////////////
  501. #if (0 == PARCHIP_ECR_ARBITRATOR)
  502. #define DEFAULT_ECR_PS2 0x34
  503. #define DEFAULT_ECR_ECP 0x74
  504. #endif
  505. //
  506. // Bit definitions for ECR register.
  507. //
  508. #define ECR_ERRINT_DISABLED 0x10
  509. #define ECR_DMA_ENABLED 0x08
  510. #define ECR_SVC_INT_DISABLED 0x04
  511. #define ECR_MODE_MASK 0x1F
  512. #define ECR_SPP_MODE 0x00
  513. #define ECR_BYTE_MODE 0x20 // PS/2
  514. #define ECR_BYTE_PIO_MODE (ECR_BYTE_MODE | ECR_ERRINT_DISABLED | ECR_SVC_INT_DISABLED)
  515. #define ECR_FASTCENT_MODE 0x40
  516. #define ECR_ECP_MODE 0x60
  517. #define ECR_ECP_PIO_MODE (ECR_ECP_MODE | ECR_ERRINT_DISABLED | ECR_SVC_INT_DISABLED)
  518. #define ECR_EPP_MODE 0x80
  519. #define ECR_EPP_PIO_MODE (ECR_EPP_MODE | ECR_ERRINT_DISABLED | ECR_SVC_INT_DISABLED)
  520. #define ECR_RESERVED_MODE 0x10
  521. #define ECR_TEST_MODE 0xC0
  522. #define ECR_CONFIG_MODE 0xE0
  523. #define DEFAULT_ECR_TEST 0xD4
  524. #define DEFAULT_ECR_COMPATIBILITY 0x14
  525. #define DEFAULT_ECR_CONFIGURATION 0xF4
  526. #define ECR_FIFO_MASK 0x03 // Mask to isolate FIFO bits
  527. #define ECR_FIFO_FULL 0x02 // FIFO completely full
  528. #define ECR_FIFO_EMPTY 0x01 // FIFO completely empty
  529. #define ECR_FIFO_SOME_DATA 0x00 // FIFO has some data in it
  530. #define ECP_MAX_FIFO_DEPTH 4098 // Likely max for ECP HW FIFO size
  531. //------------------------------------------------------------------------
  532. // Mask and test values for extracting the Implementation ID from the
  533. // ConfigA register
  534. //------------------------------------------------------------------------
  535. #define CNFGA_IMPID_MASK 0x70
  536. #define CNFGA_IMPID_SHIFT 4
  537. #define FIFO_PWORD_8BIT 1
  538. #define FIFO_PWORD_16BIT 0
  539. #define FIFO_PWORD_32BIT 2
  540. #define TEST_ECR_FIFO(registerValue,testValue) \
  541. ( ( (registerValue) & ECR_FIFO_MASK ) == testValue )
  542. //////////////////////////////////////////////////////////////////////////////
  543. // The following BIT_x definitions provide a generic bit shift value
  544. // based upon the bit's position in a hardware register or byte of
  545. // memory. These constants are used by some of the macros that are
  546. // defined below.
  547. //////////////////////////////////////////////////////////////////////////////
  548. #define BIT_7 7
  549. #define BIT_6 6
  550. #define BIT_5 5
  551. #define BIT_4 4
  552. #define BIT_3 3
  553. #define BIT_2 2
  554. #define BIT_1 1
  555. #define BIT_0 0
  556. #define BIT_7_SET 0x80
  557. #define BIT_6_SET 0x40
  558. #define BIT_5_SET 0x20
  559. #define BIT_4_SET 0x10
  560. #define BIT_3_SET 0x8
  561. #define BIT_2_SET 0x4
  562. #define BIT_1_SET 0x2
  563. #define BIT_0_SET 0x1
  564. //////////////////////////////////////////////////////////////////////////////
  565. // The following defines and macros may be used to set, test, and
  566. // update the Device Control Register (DCR).
  567. //////////////////////////////////////////////////////////////////////////////
  568. #define DIR_READ 1
  569. #define DIR_WRITE 0
  570. #define IRQEN_ENABLE 1
  571. #define IRQEN_DISABLE 0
  572. #define ACTIVE 1
  573. #define INACTIVE 0
  574. #define DONT_CARE 2
  575. #define DVRH_USE_FAST_MACROS 1
  576. #define DVRH_USE_NIBBLE_MACROS 1
  577. //////////////////////////////////////////////////////////////////////////////
  578. // The following defines may be used generically in any of the SET_xxx,
  579. // TEST_xxx, or UPDATE_xxx macros that follow.
  580. //////////////////////////////////////////////////////////////////////////////
  581. #if (1 == DVRH_USE_FAST_MACROS)
  582. #define SET_DCR(b5,b4,b3,b2,b1,b0) \
  583. ((UCHAR)((b5==ACTIVE? BIT_5_SET : 0) | \
  584. (b4==ACTIVE? BIT_4_SET : 0) | \
  585. (b3==ACTIVE? 0 : BIT_3_SET) | \
  586. (b2==ACTIVE? BIT_2_SET : 0) | \
  587. (b1==ACTIVE? 0 : BIT_1_SET) | \
  588. (b0==ACTIVE? 0 : BIT_0_SET) ) )
  589. #else
  590. #define SET_DCR(b5,b4,b3,b2,b1,b0) \
  591. ((UCHAR)(((b5==ACTIVE?1:0)<<BIT_5) | \
  592. ((b4==ACTIVE?1:0)<<BIT_4) | \
  593. ((b3==ACTIVE?0:1)<<BIT_3) | \
  594. ((b2==ACTIVE?1:0)<<BIT_2) | \
  595. ((b1==ACTIVE?0:1)<<BIT_1) | \
  596. ((b0==ACTIVE?0:1)<<BIT_0) ) )
  597. #endif
  598. typedef enum {
  599. PHASE_UNKNOWN,
  600. PHASE_NEGOTIATION,
  601. PHASE_SETUP, // Used in ECP mode only
  602. PHASE_FORWARD_IDLE,
  603. PHASE_FORWARD_XFER,
  604. PHASE_FWD_TO_REV,
  605. PHASE_REVERSE_IDLE,
  606. PHASE_REVERSE_XFER,
  607. PHASE_REV_TO_FWD,
  608. PHASE_TERMINATE,
  609. PHASE_DATA_AVAILABLE, // Used in nibble and byte modes only
  610. PHASE_DATA_NOT_AVAIL, // Used in nibble and byte modes only
  611. PHASE_INTERRUPT_HOST // Used in nibble and byte modes only
  612. } P1284_PHASE;
  613. typedef enum {
  614. HW_MODE_COMPATIBILITY,
  615. HW_MODE_PS2,
  616. HW_MODE_FAST_CENTRONICS,
  617. HW_MODE_ECP,
  618. HW_MODE_EPP,
  619. HW_MODE_RESERVED,
  620. HW_MODE_TEST,
  621. HW_MODE_CONFIGURATION
  622. } P1284_HW_MODE;
  623. #endif // _PARALLEL_