- Do not export (for the PIC/PIT/Speaker) the port functions but use instead the common port interface.
- In bios.c : IOWriteB(PIC_MASTER_DATA, PIC_ICW4_8086 /* | PIC_ICW4_AEOI */); (line 377) : in NXVM they add PIC_ICW4_AEOI; [TheFlash], can you have a look at this and see whether it is required for the master PIC only, otherwise remove this comment.
svn path=/branches/ntvdm/; revision=61590
* The POST (Power On-Self Test)
*/
- /* Initialize the PIC */
+ /* Initialize the master and the slave PICs */
IOWriteB(PIC_MASTER_CMD, PIC_ICW1 | PIC_ICW1_ICW4);
IOWriteB(PIC_SLAVE_CMD , PIC_ICW1 | PIC_ICW1_ICW4);
/* Set the interrupt offsets */
IOWriteB(PIC_MASTER_DATA, BIOS_PIC_MASTER_INT);
- IOWriteB(PIC_SLAVE_DATA , BIOS_PIC_SLAVE_INT);
+ IOWriteB(PIC_SLAVE_DATA , BIOS_PIC_SLAVE_INT );
/* Tell the master PIC there is a slave at IRQ 2 */
IOWriteB(PIC_MASTER_DATA, 1 << 2);
IOWriteB(PIC_SLAVE_DATA , 2);
- /* Make sure the PIC is in 8086 mode */
- IOWriteB(PIC_MASTER_DATA, PIC_ICW4_8086);
+ /* Make sure both PICs are in 8086 mode */
+ IOWriteB(PIC_MASTER_DATA, PIC_ICW4_8086 /* | PIC_ICW4_AEOI */);
IOWriteB(PIC_SLAVE_DATA , PIC_ICW4_8086);
/* Clear the masks for both PICs */
IOWriteB(PIC_MASTER_DATA, 0x00);
IOWriteB(PIC_SLAVE_DATA , 0x00);
- PitWriteCommand(0x34);
- PitWriteData(0, 0x00);
- PitWriteData(0, 0x00);
+ /* Initialize the PIT */
+ IOWriteB(PIT_COMMAND_PORT, 0x34);
+ IOWriteB(PIT_DATA_PORT(0), 0x00);
+ IOWriteB(PIT_DATA_PORT(0), 0x00);
return TRUE;
}
/* DEFINES ********************************************************************/
-#define PIC_MASTER_CMD 0x20
+#define PIC_MASTER_CMD 0x20
#define PIC_MASTER_DATA 0x21
-#define PIC_SLAVE_CMD 0xA0
-#define PIC_SLAVE_DATA 0xA1
-#define PIC_ICW1 0x10
-#define PIC_ICW1_ICW4 (1 << 0)
+#define PIC_SLAVE_CMD 0xA0
+#define PIC_SLAVE_DATA 0xA1
+
+#define PIC_ICW1 0x10
+#define PIC_ICW1_ICW4 (1 << 0)
#define PIC_ICW1_SINGLE (1 << 1)
-#define PIC_ICW4_8086 (1 << 0)
-#define PIC_ICW4_AEOI (1 << 1)
-#define PIC_OCW2_NUM_MASK 0x07
-#define PIC_OCW2_EOI (1 << 5)
-#define PIC_OCW2_SL (1 << 6)
-#define PIC_OCW3 (1 << 3)
-#define PIC_OCW3_READ_ISR 0x0B
+#define PIC_ICW4_8086 (1 << 0)
+#define PIC_ICW4_AEOI (1 << 1)
+
+#define PIC_OCW2_NUM_MASK 0x07
+#define PIC_OCW2_EOI (1 << 5)
+#define PIC_OCW2_SL (1 << 6)
+
+#define PIC_OCW3 (1 << 3)
+#define PIC_OCW3_READ_ISR 0x0B
typedef struct _PIC
{
VOID PicInterruptRequest(BYTE Number);
BYTE PicGetInterrupt(VOID);
+
VOID PicInitialize(VOID);
#endif // _PIC_H_
/* FUNCTIONS ******************************************************************/
VOID GenerateKeyboardInterrupts(VOID);
+
BOOLEAN PS2Initialize(HANDLE ConsoleInput);
VOID PS2Cleanup(VOID);
static BYTE Port61hState = 0x00;
HANDLE hBeep = NULL;
-/* PUBLIC FUNCTIONS ***********************************************************/
+/* PRIVATE FUNCTIONS **********************************************************/
-BYTE SpeakerReadStatus(VOID)
+static BYTE SpeakerReadStatus(VOID)
{
return Port61hState;
}
-VOID SpeakerWriteCommand(BYTE Value)
+static VOID SpeakerWriteCommand(BYTE Value)
{
BOOLEAN IsConnectedToPITChannel2;
UCHAR SpeakerData;
}
}
-BYTE WINAPI SpeakerReadPort(ULONG Port)
+static BYTE WINAPI SpeakerReadPort(ULONG Port)
{
return SpeakerReadStatus();
}
-VOID WINAPI SpeakerWritePort(ULONG Port, BYTE Data)
+static VOID WINAPI SpeakerWritePort(ULONG Port, BYTE Data)
{
SpeakerWriteCommand(Data);
}
+/* PUBLIC FUNCTIONS ***********************************************************/
+
VOID SpeakerInitialize(VOID)
{
NTSTATUS Status;
VOID SpeakerInitialize(VOID);
VOID SpeakerCleanup(VOID);
-BYTE SpeakerReadStatus(VOID);
-VOID SpeakerWriteCommand(BYTE Value);
#endif // _SPEAKER_H_
static PIT_CHANNEL PitChannels[PIT_CHANNELS];
PPIT_CHANNEL PitChannel2 = &PitChannels[2];
-/* PUBLIC FUNCTIONS ***********************************************************/
+/* PRIVATE FUNCTIONS **********************************************************/
-VOID PitWriteCommand(BYTE Value)
+static VOID PitWriteCommand(BYTE Value)
{
BYTE Channel = Value >> 6;
BYTE Mode = (Value >> 1) & 0x07;
}
}
-BYTE PitReadData(BYTE Channel)
+static BYTE PitReadData(BYTE Channel)
{
WORD CurrentValue = PitChannels[Channel].CurrentValue;
BYTE AccessMode = PitChannels[Channel].AccessMode;
return 0;
}
-VOID PitWriteData(BYTE Channel, BYTE Value)
+static VOID PitWriteData(BYTE Channel, BYTE Value)
{
BYTE AccessMode = PitChannels[Channel].AccessMode;
}
}
+/* PUBLIC FUNCTIONS ***********************************************************/
+
VOID PitDecrementCount(DWORD Count)
{
INT i;
/* FUNCTIONS ******************************************************************/
-VOID PitWriteCommand(BYTE Value);
-VOID PitWriteData(BYTE Channel, BYTE Value);
-
VOID PitDecrementCount(DWORD Count);
DWORD PitGetResolution(VOID);
+
VOID PitInitialize(VOID);
#endif // _TIMER_H_