1 /* 2 * COPYRIGHT: GPL - See COPYING in the top level directory 3 * PROJECT: ReactOS Virtual DOS Machine 4 * FILE: subsystems/mvdm/ntvdm/hardware/pit.h 5 * PURPOSE: Programmable Interval Timer emulation - 6 * i82C54/8254 compatible 7 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org> 8 * Hermes Belusca-Maito (hermes.belusca@sfr.fr) 9 */ 10 11 #ifndef _PIT_H_ 12 #define _PIT_H_ 13 14 /* DEFINES ********************************************************************/ 15 16 #define PIT_CHANNELS 3 17 #define PIT_BASE_FREQUENCY 1193182LL 18 #define PIT_DATA_PORT(x) (0x40 + (x)) 19 #define PIT_COMMAND_PORT 0x43 20 21 #define WRITE_PIT_VALUE(PitChannel, Value) \ 22 (PitChannel).Bcd ? BCD_TO_BINARY(Value) : (Value) 23 24 #define READ_PIT_VALUE(PitChannel, Value) \ 25 (PitChannel).Bcd ? BINARY_TO_BCD(Value) : (Value) 26 27 typedef enum _PIT_MODE 28 { 29 PIT_MODE_INT_ON_TERMINAL_COUNT, 30 PIT_MODE_HARDWARE_ONE_SHOT, 31 PIT_MODE_RATE_GENERATOR, 32 PIT_MODE_SQUARE_WAVE, 33 PIT_MODE_SOFTWARE_STROBE, 34 PIT_MODE_HARDWARE_STROBE 35 } PIT_MODE, *PPIT_MODE; 36 37 typedef VOID (WINAPI *PIT_OUT_FUNCTION)(LPVOID Param, BOOLEAN State); 38 39 typedef struct _PIT_CHANNEL 40 { 41 /* PIT Status fields */ 42 PIT_MODE Mode; 43 BOOLEAN Bcd; 44 BYTE ReadWriteMode; // 0 --> Counter Latch ; 1 --> LSB R/W ; 2 --> MSB R/W ; 3 --> LSB then MSB R/W 45 46 /* For interleaved reading and writing in 2-byte RW mode */ 47 BYTE ReadStatus; // Same convention as ReadWriteMode 48 BYTE WriteStatus; // Same convention as ReadWriteMode 49 50 /* For reading the PIT status byte */ 51 BOOLEAN LatchStatusSet; 52 BYTE StatusLatch; 53 54 /* Counting */ 55 BOOLEAN Gate; 56 57 /**/WORD CountRegister;/**/ // Our ReloadValue ??? 58 WORD OutputLatch; 59 /*******************************/ 60 61 WORD ReloadValue; // Max value of the counter 62 WORD CurrentValue; // Real value of the counter 63 64 /* PIT Output */ 65 BOOLEAN Out; // 0: Low ; 1: High 66 /** HACK!! **/BOOLEAN FlipFlop;/** HACK!! **/ 67 LPVOID OutParam; 68 PIT_OUT_FUNCTION OutFunction; 69 70 } PIT_CHANNEL, *PPIT_CHANNEL; 71 72 /* FUNCTIONS ******************************************************************/ 73 74 VOID PitSetOutFunction(BYTE Channel, LPVOID Param, PIT_OUT_FUNCTION OutFunction); 75 VOID PitSetGate(BYTE Channel, BOOLEAN State); 76 WORD PitGetReloadValue(BYTE Channel); 77 78 VOID PitInitialize(VOID); 79 80 #endif /* _PIT_H_ */ 81