2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: subsystems/mvdm/ntvdm/hardware/ppi.c
5 * PURPOSE: Programmable Peripheral Interface emulation -
7 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
9 * NOTES: - Most of its functionality as keyboard controller is replaced
10 * by the PS/2 controller.
11 * - This controller is here only for having ports 61h and 62h working.
14 /* INCLUDES *******************************************************************/
24 #include "hardware/pit.h"
25 #include "hardware/sound/speaker.h"
29 /* PRIVATE VARIABLES **********************************************************/
31 /*static*/ BYTE Port61hState
= 0x00; // Used in emulator.c
32 static BYTE Port62hState
= 0x00;
34 /* PRIVATE FUNCTIONS **********************************************************/
36 static BYTE WINAPI
PpiReadPort(USHORT Port
)
38 if (Port
== PPI_PORT_61H
)
40 else if (Port
== PPI_PORT_62H
)
46 static VOID WINAPI
Port61hWrite(USHORT Port
, BYTE Data
)
48 // BOOLEAN SpeakerStateChange = FALSE;
49 BYTE OldPort61hState
= Port61hState
;
51 /* Only the four lowest bytes can be written */
52 Port61hState
= (Port61hState
& 0xF0) | (Data
& 0x0F);
54 if ((OldPort61hState
^ Port61hState
) & 0x01)
56 DPRINT("PIT 2 Gate %s\n", Port61hState
& 0x01 ? "on" : "off");
57 PitSetGate(2, !!(Port61hState
& 0x01));
58 // SpeakerStateChange = TRUE;
61 if ((OldPort61hState
^ Port61hState
) & 0x02)
63 /* There were some change for the speaker... */
64 DPRINT("Speaker %s\n", Port61hState
& 0x02 ? "on" : "off");
65 // SpeakerStateChange = TRUE;
67 // if (SpeakerStateChange) SpeakerChange(Port61hState);
68 SpeakerChange(Port61hState
);
71 static VOID WINAPI
Port62hWrite(USHORT Port
, BYTE Data
)
76 /* PUBLIC FUNCTIONS ***********************************************************/
78 VOID
PpiInitialize(VOID
)
80 /* Register the I/O Ports */
81 // Port 0x60 is now used by the PS/2 controller
82 RegisterIoPort(PPI_PORT_61H
, PpiReadPort
, Port61hWrite
);
83 RegisterIoPort(PPI_PORT_62H
, PpiReadPort
, Port62hWrite
);
84 // Port 0x63 is unused