[FAST486][NTVDM]

The behavior of the I/O port bus depends on the data width. In the case
of 16-bit/32-bit access, two/four adjacent ports will be accessed.


svn path=/branches/ntvdm/; revision=60891
This commit is contained in:
Aleksandar Andrejevic 2013-11-09 03:30:27 +00:00
parent e971f67673
commit 43ee57f2f7
4 changed files with 42 additions and 30 deletions

View file

@ -185,7 +185,8 @@ VOID
PFAST486_STATE State, PFAST486_STATE State,
ULONG Port, ULONG Port,
PVOID Buffer, PVOID Buffer,
ULONG Size ULONG Size,
UCHAR Width
); );
typedef typedef
@ -195,7 +196,8 @@ VOID
PFAST486_STATE State, PFAST486_STATE State,
ULONG Port, ULONG Port,
PVOID Buffer, PVOID Buffer,
ULONG Size ULONG Size,
UCHAR Width
); );
typedef typedef

View file

@ -146,22 +146,24 @@ Fast486MemWriteCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG
static VOID static VOID
NTAPI NTAPI
Fast486IoReadCallback(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG Size) Fast486IoReadCallback(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG Size, UCHAR Width)
{ {
UNREFERENCED_PARAMETER(State); UNREFERENCED_PARAMETER(State);
UNREFERENCED_PARAMETER(Port); UNREFERENCED_PARAMETER(Port);
UNREFERENCED_PARAMETER(Buffer); UNREFERENCED_PARAMETER(Buffer);
UNREFERENCED_PARAMETER(Size); UNREFERENCED_PARAMETER(Size);
UNREFERENCED_PARAMETER(Width);
} }
static VOID static VOID
NTAPI NTAPI
Fast486IoWriteCallback(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG Size) Fast486IoWriteCallback(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG Size, UCHAR Width)
{ {
UNREFERENCED_PARAMETER(State); UNREFERENCED_PARAMETER(State);
UNREFERENCED_PARAMETER(Port); UNREFERENCED_PARAMETER(Port);
UNREFERENCED_PARAMETER(Buffer); UNREFERENCED_PARAMETER(Buffer);
UNREFERENCED_PARAMETER(Size); UNREFERENCED_PARAMETER(Size);
UNREFERENCED_PARAMETER(Width);
} }
static VOID static VOID

View file

@ -906,7 +906,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeInByte)
} }
/* Read a byte from the I/O port */ /* Read a byte from the I/O port */
State->IoReadCallback(State, Port, &Data, sizeof(UCHAR)); State->IoReadCallback(State, Port, &Data, 1, sizeof(UCHAR));
/* Store the result in AL */ /* Store the result in AL */
State->GeneralRegs[FAST486_REG_EAX].LowByte = Data; State->GeneralRegs[FAST486_REG_EAX].LowByte = Data;
@ -950,7 +950,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeIn)
ULONG Data; ULONG Data;
/* Read a dword from the I/O port */ /* Read a dword from the I/O port */
State->IoReadCallback(State, Port, &Data, sizeof(ULONG)); State->IoReadCallback(State, Port, &Data, 1, sizeof(ULONG));
/* Store the value in EAX */ /* Store the value in EAX */
State->GeneralRegs[FAST486_REG_EAX].Long = Data; State->GeneralRegs[FAST486_REG_EAX].Long = Data;
@ -960,7 +960,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeIn)
USHORT Data; USHORT Data;
/* Read a word from the I/O port */ /* Read a word from the I/O port */
State->IoReadCallback(State, Port, &Data, sizeof(USHORT)); State->IoReadCallback(State, Port, &Data, 1, sizeof(USHORT));
/* Store the value in AX */ /* Store the value in AX */
State->GeneralRegs[FAST486_REG_EAX].LowWord = Data; State->GeneralRegs[FAST486_REG_EAX].LowWord = Data;
@ -999,7 +999,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeOutByte)
Data = State->GeneralRegs[FAST486_REG_EAX].LowByte; Data = State->GeneralRegs[FAST486_REG_EAX].LowByte;
/* Write the byte to the I/O port */ /* Write the byte to the I/O port */
State->IoWriteCallback(State, Port, &Data, sizeof(UCHAR)); State->IoWriteCallback(State, Port, &Data, 1, sizeof(UCHAR));
return TRUE; return TRUE;
} }
@ -1041,7 +1041,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeOut)
ULONG Data = State->GeneralRegs[FAST486_REG_EAX].Long; ULONG Data = State->GeneralRegs[FAST486_REG_EAX].Long;
/* Write a dword to the I/O port */ /* Write a dword to the I/O port */
State->IoReadCallback(State, Port, &Data, sizeof(ULONG)); State->IoReadCallback(State, Port, &Data, 1, sizeof(ULONG));
} }
else else
{ {
@ -1049,7 +1049,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeOut)
USHORT Data = State->GeneralRegs[FAST486_REG_EAX].LowWord; USHORT Data = State->GeneralRegs[FAST486_REG_EAX].LowWord;
/* Write a word to the I/O port */ /* Write a word to the I/O port */
State->IoWriteCallback(State, Port, &Data, sizeof(USHORT)); State->IoWriteCallback(State, Port, &Data, 1, sizeof(USHORT));
} }
return TRUE; return TRUE;
@ -5997,7 +5997,8 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeIns)
State->IoReadCallback(State, State->IoReadCallback(State,
State->GeneralRegs[FAST486_REG_EDX].LowWord, State->GeneralRegs[FAST486_REG_EDX].LowWord,
Block, Block,
Processed * DataSize); Processed,
DataSize);
if (State->Flags.Df) if (State->Flags.Df)
{ {
@ -6059,6 +6060,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeIns)
State->IoReadCallback(State, State->IoReadCallback(State,
State->GeneralRegs[FAST486_REG_EDX].LowWord, State->GeneralRegs[FAST486_REG_EDX].LowWord,
&Data, &Data,
1,
DataSize); DataSize);
/* Write to the destination operand */ /* Write to the destination operand */
@ -6174,7 +6176,8 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeOuts)
State->IoWriteCallback(State, State->IoWriteCallback(State,
State->GeneralRegs[FAST486_REG_EDX].LowWord, State->GeneralRegs[FAST486_REG_EDX].LowWord,
Block, Block,
Processed * DataSize); Processed,
DataSize);
if (!State->Flags.Df) if (!State->Flags.Df)
{ {
@ -6212,6 +6215,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeOuts)
State->IoWriteCallback(State, State->IoWriteCallback(State,
State->GeneralRegs[FAST486_REG_EDX].LowWord, State->GeneralRegs[FAST486_REG_EDX].LowWord,
&Data, &Data,
1,
DataSize); DataSize);
/* Increment/decrement ESI */ /* Increment/decrement ESI */

View file

@ -82,28 +82,30 @@ static VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOI
} }
} }
static VOID WINAPI EmulatorReadIo(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG Size) static VOID WINAPI EmulatorReadIo(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG Size, UCHAR Width)
{ {
INT i; INT i, j;
LPBYTE Address = (LPBYTE)Buffer; LPBYTE Address = (LPBYTE)Buffer;
UNREFERENCED_PARAMETER(State); UNREFERENCED_PARAMETER(State);
for (i = 0; i < Size; i++) for (i = 0; i < Size; i++) for (j = 0; j < Width; j++)
{ {
switch (Port) ULONG CurrentPort = Port + j;
switch (CurrentPort)
{ {
case PIC_MASTER_CMD: case PIC_MASTER_CMD:
case PIC_SLAVE_CMD: case PIC_SLAVE_CMD:
{ {
*(Address++) = PicReadCommand(Port); *(Address++) = PicReadCommand(CurrentPort);
break; break;
} }
case PIC_MASTER_DATA: case PIC_MASTER_DATA:
case PIC_SLAVE_DATA: case PIC_SLAVE_DATA:
{ {
*(Address++) = PicReadData(Port); *(Address++) = PicReadData(CurrentPort);
break; break;
} }
@ -111,7 +113,7 @@ static VOID WINAPI EmulatorReadIo(PFAST486_STATE State, ULONG Port, PVOID Buffer
case PIT_DATA_PORT(1): case PIT_DATA_PORT(1):
case PIT_DATA_PORT(2): case PIT_DATA_PORT(2):
{ {
*(Address++) = PitReadData(Port - PIT_DATA_PORT(0)); *(Address++) = PitReadData(CurrentPort - PIT_DATA_PORT(0));
break; break;
} }
@ -155,28 +157,30 @@ static VOID WINAPI EmulatorReadIo(PFAST486_STATE State, ULONG Port, PVOID Buffer
case VGA_STAT_MONO: case VGA_STAT_MONO:
case VGA_STAT_COLOR: case VGA_STAT_COLOR:
{ {
*(Address++) = VgaReadPort(Port); *(Address++) = VgaReadPort(CurrentPort);
break; break;
} }
default: default:
{ {
DPRINT1("Read from unknown port: 0x%X\n", Port); DPRINT1("Read from unknown port: 0x%X\n", CurrentPort);
} }
} }
} }
} }
static VOID WINAPI EmulatorWriteIo(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG Size) static VOID WINAPI EmulatorWriteIo(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG Size, UCHAR Width)
{ {
INT i; INT i, j;
LPBYTE Address = (LPBYTE)Buffer; LPBYTE Address = (LPBYTE)Buffer;
UNREFERENCED_PARAMETER(State); UNREFERENCED_PARAMETER(State);
for (i = 0; i < Size; i++) for (i = 0; i < Size; i++) for (j = 0; j < Width; j++)
{ {
switch (Port) ULONG CurrentPort = Port + j;
switch (CurrentPort)
{ {
case PIT_COMMAND_PORT: case PIT_COMMAND_PORT:
{ {
@ -188,21 +192,21 @@ static VOID WINAPI EmulatorWriteIo(PFAST486_STATE State, ULONG Port, PVOID Buffe
case PIT_DATA_PORT(1): case PIT_DATA_PORT(1):
case PIT_DATA_PORT(2): case PIT_DATA_PORT(2):
{ {
PitWriteData(Port - PIT_DATA_PORT(0), *(Address++)); PitWriteData(CurrentPort - PIT_DATA_PORT(0), *(Address++));
break; break;
} }
case PIC_MASTER_CMD: case PIC_MASTER_CMD:
case PIC_SLAVE_CMD: case PIC_SLAVE_CMD:
{ {
PicWriteCommand(Port, *(Address++)); PicWriteCommand(CurrentPort, *(Address++));
break; break;
} }
case PIC_MASTER_DATA: case PIC_MASTER_DATA:
case PIC_SLAVE_DATA: case PIC_SLAVE_DATA:
{ {
PicWriteData(Port, *(Address++)); PicWriteData(CurrentPort, *(Address++));
break; break;
} }
@ -252,13 +256,13 @@ static VOID WINAPI EmulatorWriteIo(PFAST486_STATE State, ULONG Port, PVOID Buffe
case VGA_STAT_MONO: case VGA_STAT_MONO:
case VGA_STAT_COLOR: case VGA_STAT_COLOR:
{ {
VgaWritePort(Port, *(Address++)); VgaWritePort(CurrentPort, *(Address++));
break; break;
} }
default: default:
{ {
DPRINT1("Write to unknown port: 0x%X\n", Port); DPRINT1("Write to unknown port: 0x%X\n", CurrentPort);
} }
} }
} }