ReactOS 0.4.16-dev-311-g9382aa2
ppi.c
Go to the documentation of this file.
1/*
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 -
6 * i8255A-5 compatible
7 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 *
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.
12 */
13
14/* INCLUDES *******************************************************************/
15
16#include "ntvdm.h"
17
18#define NDEBUG
19#include <debug.h>
20
21#include "emulator.h"
22#include "ppi.h"
23
24#include "hardware/pit.h"
26
27#include "io.h"
28
29/* PRIVATE VARIABLES **********************************************************/
30
31/*static*/ BYTE Port61hState = 0x00; // Used in emulator.c
32static BYTE Port62hState = 0x00;
33
34/* PRIVATE FUNCTIONS **********************************************************/
35
37{
38 if (Port == PPI_PORT_61H)
39 return Port61hState;
40 else if (Port == PPI_PORT_62H)
41 return Port62hState;
42
43 return 0x00;
44}
45
47{
48 // BOOLEAN SpeakerStateChange = FALSE;
49 BYTE OldPort61hState = Port61hState;
50
51 /* Only the four lowest bytes can be written */
52 Port61hState = (Port61hState & 0xF0) | (Data & 0x0F);
53
54 if ((OldPort61hState ^ Port61hState) & 0x01)
55 {
56 DPRINT("PIT 2 Gate %s\n", Port61hState & 0x01 ? "on" : "off");
57 PitSetGate(2, !!(Port61hState & 0x01));
58 // SpeakerStateChange = TRUE;
59 }
60
61 if ((OldPort61hState ^ Port61hState) & 0x02)
62 {
63 /* There were some change for the speaker... */
64 DPRINT("Speaker %s\n", Port61hState & 0x02 ? "on" : "off");
65 // SpeakerStateChange = TRUE;
66 }
67 // if (SpeakerStateChange) SpeakerChange(Port61hState);
69}
70
72{
74}
75
76/* PUBLIC FUNCTIONS ***********************************************************/
77
79{
80 /* Register the I/O Ports */
81 // Port 0x60 is now used by the PS/2 controller
84 // Port 0x63 is unused
85}
86
87/* EOF */
CPPORT Port[4]
Definition: headless.c:35
unsigned short USHORT
Definition: pedump.c:61
VOID PitSetGate(BYTE Channel, BOOLEAN State)
Definition: pit.c:484
VOID PpiInitialize(VOID)
Definition: ppi.c:78
BYTE Port61hState
Definition: ppi.c:31
static VOID WINAPI Port61hWrite(USHORT Port, BYTE Data)
Definition: ppi.c:46
static VOID WINAPI Port62hWrite(USHORT Port, BYTE Data)
Definition: ppi.c:71
static BYTE WINAPI PpiReadPort(USHORT Port)
Definition: ppi.c:36
static BYTE Port62hState
Definition: ppi.c:32
#define PPI_PORT_62H
Definition: ppi.h:16
#define PPI_PORT_61H
Definition: ppi.h:15
#define DPRINT
Definition: sndvol32.h:73
VOID SpeakerChange(UCHAR Port61hValue)
Definition: speaker.c:196
VOID RegisterIoPort(USHORT Port, EMULATOR_INB_PROC InHandler, EMULATOR_OUTB_PROC OutHandler)
Definition: io.c:320
#define WINAPI
Definition: msvc.h:6
unsigned char BYTE
Definition: xxhash.c:193