Author: hbelusca
Date: Mon Oct 13 21:49:01 2014
New Revision: 64739
URL:
http://svn.reactos.org/svn/reactos?rev=64739&view=rev
Log:
[FAST486]
- Add doc for INT instructions,
- Move debug functions to an appropriate file.
Added:
trunk/reactos/lib/fast486/fast486dbg.c
- copied, changed from r64701, trunk/reactos/lib/fast486/fast486.c
Modified:
trunk/reactos/lib/fast486/CMakeLists.txt
trunk/reactos/lib/fast486/fast486.c
trunk/reactos/lib/fast486/opcodes.c
Modified: trunk/reactos/lib/fast486/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/CMakeLists.txt…
==============================================================================
--- trunk/reactos/lib/fast486/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/CMakeLists.txt [iso-8859-1] Mon Oct 13 21:49:01 2014
@@ -3,6 +3,7 @@
list(APPEND SOURCE
fast486.c
+ fast486dbg.c
opcodes.c
opgroups.c
extraops.c
Modified: trunk/reactos/lib/fast486/fast486.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fast486.c?rev=…
==============================================================================
--- trunk/reactos/lib/fast486/fast486.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/fast486.c [iso-8859-1] Mon Oct 13 21:49:01 2014
@@ -43,7 +43,7 @@
/* PRIVATE FUNCTIONS **********************************************************/
-static inline VOID
+VOID
NTAPI
Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command)
{
@@ -279,151 +279,6 @@
VOID
NTAPI
-Fast486DumpState(PFAST486_STATE State)
-{
- DbgPrint("\nFast486DumpState -->\n");
- DbgPrint("\nCPU currently executing in %s mode at %04X:%08X\n",
- (State->ControlRegisters[0] & FAST486_CR0_PE) ? "protected"
: "real",
- State->SegmentRegs[FAST486_REG_CS].Selector,
- State->InstPtr.Long);
- DbgPrint("\nGeneral purpose registers:\n"
- "EAX = %08X\tECX = %08X\tEDX = %08X\tEBX = %08X\n"
- "ESP = %08X\tEBP = %08X\tESI = %08X\tEDI = %08X\n",
- State->GeneralRegs[FAST486_REG_EAX].Long,
- State->GeneralRegs[FAST486_REG_ECX].Long,
- State->GeneralRegs[FAST486_REG_EDX].Long,
- State->GeneralRegs[FAST486_REG_EBX].Long,
- State->GeneralRegs[FAST486_REG_ESP].Long,
- State->GeneralRegs[FAST486_REG_EBP].Long,
- State->GeneralRegs[FAST486_REG_ESI].Long,
- State->GeneralRegs[FAST486_REG_EDI].Long);
- DbgPrint("\nSegment registers:\n"
- "ES = %04X (Base: %08X, Limit: %08X, Dpl: %u)\n"
- "CS = %04X (Base: %08X, Limit: %08X, Dpl: %u)\n"
- "SS = %04X (Base: %08X, Limit: %08X, Dpl: %u)\n"
- "DS = %04X (Base: %08X, Limit: %08X, Dpl: %u)\n"
- "FS = %04X (Base: %08X, Limit: %08X, Dpl: %u)\n"
- "GS = %04X (Base: %08X, Limit: %08X, Dpl: %u)\n",
- State->SegmentRegs[FAST486_REG_ES].Selector,
- State->SegmentRegs[FAST486_REG_ES].Base,
- State->SegmentRegs[FAST486_REG_ES].Limit,
- State->SegmentRegs[FAST486_REG_ES].Dpl,
- State->SegmentRegs[FAST486_REG_CS].Selector,
- State->SegmentRegs[FAST486_REG_CS].Base,
- State->SegmentRegs[FAST486_REG_CS].Limit,
- State->SegmentRegs[FAST486_REG_CS].Dpl,
- State->SegmentRegs[FAST486_REG_SS].Selector,
- State->SegmentRegs[FAST486_REG_SS].Base,
- State->SegmentRegs[FAST486_REG_SS].Limit,
- State->SegmentRegs[FAST486_REG_SS].Dpl,
- State->SegmentRegs[FAST486_REG_DS].Selector,
- State->SegmentRegs[FAST486_REG_DS].Base,
- State->SegmentRegs[FAST486_REG_DS].Limit,
- State->SegmentRegs[FAST486_REG_DS].Dpl,
- State->SegmentRegs[FAST486_REG_FS].Selector,
- State->SegmentRegs[FAST486_REG_FS].Base,
- State->SegmentRegs[FAST486_REG_FS].Limit,
- State->SegmentRegs[FAST486_REG_FS].Dpl,
- State->SegmentRegs[FAST486_REG_GS].Selector,
- State->SegmentRegs[FAST486_REG_GS].Base,
- State->SegmentRegs[FAST486_REG_GS].Limit,
- State->SegmentRegs[FAST486_REG_GS].Dpl);
- DbgPrint("\nFlags: %08X (%s %s %s %s %s %s %s %s %s %s %s %s %s) Iopl:
%u\n",
- State->Flags.Long,
- State->Flags.Cf ? "CF" : "cf",
- State->Flags.Pf ? "PF" : "pf",
- State->Flags.Af ? "AF" : "af",
- State->Flags.Zf ? "ZF" : "zf",
- State->Flags.Sf ? "SF" : "sf",
- State->Flags.Tf ? "TF" : "tf",
- State->Flags.If ? "IF" : "if",
- State->Flags.Df ? "DF" : "df",
- State->Flags.Of ? "OF" : "of",
- State->Flags.Nt ? "NT" : "nt",
- State->Flags.Rf ? "RF" : "rf",
- State->Flags.Vm ? "VM" : "vm",
- State->Flags.Ac ? "AC" : "ac",
- State->Flags.Iopl);
- DbgPrint("\nControl Registers:\n"
- "CR0 = %08X\tCR2 = %08X\tCR3 = %08X\n",
- State->ControlRegisters[FAST486_REG_CR0],
- State->ControlRegisters[FAST486_REG_CR2],
- State->ControlRegisters[FAST486_REG_CR3]);
- DbgPrint("\nDebug Registers:\n"
- "DR0 = %08X\tDR1 = %08X\tDR2 = %08X\n"
- "DR3 = %08X\tDR4 = %08X\tDR5 = %08X\n",
- State->DebugRegisters[FAST486_REG_DR0],
- State->DebugRegisters[FAST486_REG_DR1],
- State->DebugRegisters[FAST486_REG_DR2],
- State->DebugRegisters[FAST486_REG_DR3],
- State->DebugRegisters[FAST486_REG_DR4],
- State->DebugRegisters[FAST486_REG_DR5]);
-
-#ifndef FAST486_NO_FPU
- DbgPrint("\nFPU Registers:\n"
- "ST0 = %04X%016llX\tST1 = %04X%016llX\n"
- "ST2 = %04X%016llX\tST3 = %04X%016llX\n"
- "ST4 = %04X%016llX\tST5 = %04X%016llX\n"
- "ST6 = %04X%016llX\tST7 = %04X%016llX\n"
- "Status: %04X\tControl: %04X\tTag: %04X\n",
- FPU_ST(0).Exponent | ((USHORT)FPU_ST(0).Sign << 15),
- FPU_ST(0).Mantissa,
- FPU_ST(1).Exponent | ((USHORT)FPU_ST(1).Sign << 15),
- FPU_ST(1).Mantissa,
- FPU_ST(2).Exponent | ((USHORT)FPU_ST(2).Sign << 15),
- FPU_ST(2).Mantissa,
- FPU_ST(3).Exponent | ((USHORT)FPU_ST(3).Sign << 15),
- FPU_ST(3).Mantissa,
- FPU_ST(4).Exponent | ((USHORT)FPU_ST(4).Sign << 15),
- FPU_ST(4).Mantissa,
- FPU_ST(5).Exponent | ((USHORT)FPU_ST(5).Sign << 15),
- FPU_ST(5).Mantissa,
- FPU_ST(6).Exponent | ((USHORT)FPU_ST(6).Sign << 15),
- FPU_ST(6).Mantissa,
- FPU_ST(7).Exponent | ((USHORT)FPU_ST(7).Sign << 15),
- FPU_ST(7).Mantissa,
- State->FpuStatus,
- State->FpuControl,
- State->FpuTag);
-#endif
-
- DbgPrint("\n<-- Fast486DumpState\n\n");
-}
-
-VOID
-NTAPI
-Fast486Continue(PFAST486_STATE State)
-{
- /* Call the internal function */
- Fast486ExecutionControl(State, FAST486_CONTINUE);
-}
-
-VOID
-NTAPI
-Fast486StepInto(PFAST486_STATE State)
-{
- /* Call the internal function */
- Fast486ExecutionControl(State, FAST486_STEP_INTO);
-}
-
-VOID
-NTAPI
-Fast486StepOver(PFAST486_STATE State)
-{
- /* Call the internal function */
- Fast486ExecutionControl(State, FAST486_STEP_OVER);
-}
-
-VOID
-NTAPI
-Fast486StepOut(PFAST486_STATE State)
-{
- /* Call the internal function */
- Fast486ExecutionControl(State, FAST486_STEP_OUT);
-}
-
-VOID
-NTAPI
Fast486Interrupt(PFAST486_STATE State, UCHAR Number)
{
/* Set the interrupt status and the number */
Copied: trunk/reactos/lib/fast486/fast486dbg.c (from r64701,
trunk/reactos/lib/fast486/fast486.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fast486dbg.c?p…
==============================================================================
--- trunk/reactos/lib/fast486/fast486.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/fast486dbg.c [iso-8859-1] Mon Oct 13 21:49:01 2014
@@ -1,6 +1,6 @@
/*
* Fast486 386/486 CPU Emulation Library
- * fast486.c
+ * fast486dbg.c
*
* Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
@@ -43,6 +43,7 @@
/* PRIVATE FUNCTIONS **********************************************************/
+#if 0
static inline VOID
NTAPI
Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command)
@@ -109,173 +110,13 @@
(Command == FAST486_STEP_OVER && ProcedureCallCount > 0) ||
(Command == FAST486_STEP_OUT && ProcedureCallCount >= 0));
}
-
-/* DEFAULT CALLBACKS **********************************************************/
-
-static VOID
-NTAPI
-Fast486MemReadCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
-{
- UNREFERENCED_PARAMETER(State);
-
- RtlMoveMemory(Buffer, (PVOID)Address, Size);
-}
-
-static VOID
-NTAPI
-Fast486MemWriteCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
-{
- UNREFERENCED_PARAMETER(State);
-
- RtlMoveMemory((PVOID)Address, Buffer, Size);
-}
-
-static VOID
-NTAPI
-Fast486IoReadCallback(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG DataCount,
UCHAR DataSize)
-{
- UNREFERENCED_PARAMETER(State);
- UNREFERENCED_PARAMETER(Port);
- UNREFERENCED_PARAMETER(Buffer);
- UNREFERENCED_PARAMETER(DataCount);
- UNREFERENCED_PARAMETER(DataSize);
-}
-
-static VOID
-NTAPI
-Fast486IoWriteCallback(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG DataCount,
UCHAR DataSize)
-{
- UNREFERENCED_PARAMETER(State);
- UNREFERENCED_PARAMETER(Port);
- UNREFERENCED_PARAMETER(Buffer);
- UNREFERENCED_PARAMETER(DataCount);
- UNREFERENCED_PARAMETER(DataSize);
-}
-
-static VOID
-NTAPI
-Fast486IdleCallback(PFAST486_STATE State)
-{
- UNREFERENCED_PARAMETER(State);
-}
-
-static VOID
-NTAPI
-Fast486BopCallback(PFAST486_STATE State, UCHAR BopCode)
-{
- UNREFERENCED_PARAMETER(State);
- UNREFERENCED_PARAMETER(BopCode);
-}
-
-static UCHAR
-NTAPI
-Fast486IntAckCallback(PFAST486_STATE State)
-{
- UNREFERENCED_PARAMETER(State);
-
- /* Return something... */
- return 0;
-}
+#else
+VOID
+NTAPI
+Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command);
+#endif
/* PUBLIC FUNCTIONS ***********************************************************/
-
-VOID
-NTAPI
-Fast486Initialize(PFAST486_STATE State,
- FAST486_MEM_READ_PROC MemReadCallback,
- FAST486_MEM_WRITE_PROC MemWriteCallback,
- FAST486_IO_READ_PROC IoReadCallback,
- FAST486_IO_WRITE_PROC IoWriteCallback,
- FAST486_IDLE_PROC IdleCallback,
- FAST486_BOP_PROC BopCallback,
- FAST486_INT_ACK_PROC IntAckCallback,
- PULONG Tlb)
-{
- /* Set the callbacks (or use default ones if some are NULL) */
- State->MemReadCallback = (MemReadCallback ? MemReadCallback :
Fast486MemReadCallback );
- State->MemWriteCallback = (MemWriteCallback ? MemWriteCallback :
Fast486MemWriteCallback);
- State->IoReadCallback = (IoReadCallback ? IoReadCallback :
Fast486IoReadCallback );
- State->IoWriteCallback = (IoWriteCallback ? IoWriteCallback :
Fast486IoWriteCallback );
- State->IdleCallback = (IdleCallback ? IdleCallback :
Fast486IdleCallback );
- State->BopCallback = (BopCallback ? BopCallback :
Fast486BopCallback );
- State->IntAckCallback = (IntAckCallback ? IntAckCallback :
Fast486IntAckCallback );
-
- /* Set the TLB (if given) */
- State->Tlb = Tlb;
-
- /* Reset the CPU */
- Fast486Reset(State);
-}
-
-VOID
-NTAPI
-Fast486Reset(PFAST486_STATE State)
-{
- FAST486_SEG_REGS i;
-
- FAST486_MEM_READ_PROC MemReadCallback = State->MemReadCallback;
- FAST486_MEM_WRITE_PROC MemWriteCallback = State->MemWriteCallback;
- FAST486_IO_READ_PROC IoReadCallback = State->IoReadCallback;
- FAST486_IO_WRITE_PROC IoWriteCallback = State->IoWriteCallback;
- FAST486_IDLE_PROC IdleCallback = State->IdleCallback;
- FAST486_BOP_PROC BopCallback = State->BopCallback;
- FAST486_INT_ACK_PROC IntAckCallback = State->IntAckCallback;
- PULONG Tlb = State->Tlb;
-
- /* Clear the entire structure */
- RtlZeroMemory(State, sizeof(*State));
-
- /* Initialize the registers */
- State->Flags.AlwaysSet = 1;
- State->InstPtr.LowWord = 0xFFF0;
-
- /* Set the CPL to 0 */
- State->Cpl = 0;
-
- /* Initialize segments */
- for (i = 0; i < FAST486_NUM_SEG_REGS; i++)
- {
- State->SegmentRegs[i].Selector = 0;
- State->SegmentRegs[i].Base = 0;
- State->SegmentRegs[i].Limit = 0xFFFF;
- State->SegmentRegs[i].Present = TRUE;
- State->SegmentRegs[i].ReadWrite = TRUE;
- State->SegmentRegs[i].Executable = FALSE;
- State->SegmentRegs[i].DirConf = FALSE;
- State->SegmentRegs[i].SystemType = 1; // Segment descriptor
- State->SegmentRegs[i].Dpl = 0;
- State->SegmentRegs[i].Size = FALSE; // 16-bit
- }
-
- /* Initialize the code segment */
- State->SegmentRegs[FAST486_REG_CS].Executable = TRUE;
- State->SegmentRegs[FAST486_REG_CS].Selector = 0xF000;
- State->SegmentRegs[FAST486_REG_CS].Base = 0xFFFF0000;
-
- /* Initialize the IDT */
- State->Idtr.Size = 0x3FF;
- State->Idtr.Address = 0;
-
-#ifndef FAST486_NO_FPU
- /* Initialize CR0 */
- State->ControlRegisters[FAST486_REG_CR0] |= FAST486_CR0_ET;
-
- /* Initialize the FPU control and tag registers */
- State->FpuControl.Value = FAST486_FPU_DEFAULT_CONTROL;
- State->FpuStatus.Value = 0;
- State->FpuTag = 0xFFFF;
-#endif
-
- /* Restore the callbacks and TLB */
- State->MemReadCallback = MemReadCallback;
- State->MemWriteCallback = MemWriteCallback;
- State->IoReadCallback = IoReadCallback;
- State->IoWriteCallback = IoWriteCallback;
- State->IdleCallback = IdleCallback;
- State->BopCallback = BopCallback;
- State->IntAckCallback = IntAckCallback;
- State->Tlb = Tlb;
-}
VOID
NTAPI
@@ -422,61 +263,4 @@
Fast486ExecutionControl(State, FAST486_STEP_OUT);
}
-VOID
-NTAPI
-Fast486Interrupt(PFAST486_STATE State, UCHAR Number)
-{
- /* Set the interrupt status and the number */
- State->IntStatus = FAST486_INT_EXECUTE;
- State->PendingIntNum = Number;
-}
-
-VOID
-NTAPI
-Fast486InterruptSignal(PFAST486_STATE State)
-{
- /* Set the interrupt status */
- State->IntStatus = FAST486_INT_SIGNAL;
-}
-
-VOID
-NTAPI
-Fast486ExecuteAt(PFAST486_STATE State, USHORT Segment, ULONG Offset)
-{
- /* Load the new CS */
- if (!Fast486LoadSegment(State, FAST486_REG_CS, Segment))
- {
- /* An exception occurred, let the handler execute instead */
- return;
- }
-
- /* Set the new IP */
- State->InstPtr.Long = Offset;
-}
-
-VOID
-NTAPI
-Fast486SetStack(PFAST486_STATE State, USHORT Segment, ULONG Offset)
-{
- /* Load the new SS */
- if (!Fast486LoadSegment(State, FAST486_REG_SS, Segment))
- {
- /* An exception occurred, let the handler execute instead */
- return;
- }
-
- /* Set the new SP */
- State->GeneralRegs[FAST486_REG_ESP].Long = Offset;
-}
-
-VOID
-NTAPI
-Fast486SetSegment(PFAST486_STATE State,
- FAST486_SEG_REGS Segment,
- USHORT Selector)
-{
- /* Call the internal function */
- Fast486LoadSegment(State, Segment, Selector);
-}
-
/* EOF */
Modified: trunk/reactos/lib/fast486/opcodes.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opcodes.c?rev=…
==============================================================================
--- trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] Mon Oct 13 21:49:01 2014
@@ -4630,14 +4630,14 @@
switch (Opcode)
{
- case 0xCC:
+ case 0xCC: // INT 3
{
/* This is the INT3 instruction */
IntNum = 3;
break;
}
- case 0xCD:
+ case 0xCD: // INT xx
{
/* Fetch the interrupt number */
if (!Fast486FetchByte(State, &IntNum))
@@ -4649,7 +4649,7 @@
break;
}
- case 0xCE:
+ case 0xCE: // INTO
{
/* Don't do anything if OF is cleared */
if (!State->Flags.Of) return TRUE;