- 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
This commit is contained in:
Hermès Bélusca-Maïto 2014-01-11 21:45:01 +00:00
parent 40f773b96b
commit f0466501fc
7 changed files with 39 additions and 33 deletions

View file

@ -361,29 +361,30 @@ BOOLEAN BiosInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
* 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;
}

View file

@ -16,20 +16,23 @@
/* 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
{
@ -50,6 +53,7 @@ typedef struct _PIC
VOID PicInterruptRequest(BYTE Number);
BYTE PicGetInterrupt(VOID);
VOID PicInitialize(VOID);
#endif // _PIC_H_

View file

@ -25,6 +25,7 @@
/* FUNCTIONS ******************************************************************/
VOID GenerateKeyboardInterrupts(VOID);
BOOLEAN PS2Initialize(HANDLE ConsoleInput);
VOID PS2Cleanup(VOID);

View file

@ -28,14 +28,14 @@
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;
@ -121,16 +121,18 @@ VOID SpeakerWriteCommand(BYTE Value)
}
}
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;

View file

@ -21,8 +21,6 @@
VOID SpeakerInitialize(VOID);
VOID SpeakerCleanup(VOID);
BYTE SpeakerReadStatus(VOID);
VOID SpeakerWriteCommand(BYTE Value);
#endif // _SPEAKER_H_

View file

@ -20,9 +20,9 @@
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;
@ -69,7 +69,7 @@ VOID PitWriteCommand(BYTE Value)
}
}
BYTE PitReadData(BYTE Channel)
static BYTE PitReadData(BYTE Channel)
{
WORD CurrentValue = PitChannels[Channel].CurrentValue;
BYTE AccessMode = PitChannels[Channel].AccessMode;
@ -119,7 +119,7 @@ BYTE PitReadData(BYTE Channel)
return 0;
}
VOID PitWriteData(BYTE Channel, BYTE Value)
static VOID PitWriteData(BYTE Channel, BYTE Value)
{
BYTE AccessMode = PitChannels[Channel].AccessMode;
@ -184,6 +184,8 @@ static VOID WINAPI PitWritePort(ULONG Port, BYTE Data)
}
}
/* PUBLIC FUNCTIONS ***********************************************************/
VOID PitDecrementCount(DWORD Count)
{
INT i;

View file

@ -47,11 +47,9 @@ extern PPIT_CHANNEL PitChannel2; // Needed for PC Speaker
/* FUNCTIONS ******************************************************************/
VOID PitWriteCommand(BYTE Value);
VOID PitWriteData(BYTE Channel, BYTE Value);
VOID PitDecrementCount(DWORD Count);
DWORD PitGetResolution(VOID);
VOID PitInitialize(VOID);
#endif // _TIMER_H_