Author: aandrejevic
Date: Fri Nov 29 03:00:59 2013
New Revision: 61141
URL:
http://svn.reactos.org/svn/reactos?rev=61141&view=rev
Log:
[FAST486]
Start implementing the FPU. Stubplement the FPU opcode handlers.
Added:
branches/ntvdm/lib/fast486/fpu.c (with props)
branches/ntvdm/lib/fast486/fpu.h (with props)
Modified:
branches/ntvdm/include/reactos/libs/fast486/fast486.h
branches/ntvdm/lib/fast486/CMakeLists.txt
branches/ntvdm/lib/fast486/opcodes.c
Modified: branches/ntvdm/include/reactos/libs/fast486/fast486.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/include/reactos/libs/fast…
==============================================================================
--- branches/ntvdm/include/reactos/libs/fast486/fast486.h [iso-8859-1] (original)
+++ branches/ntvdm/include/reactos/libs/fast486/fast486.h [iso-8859-1] Fri Nov 29 03:00:59
2013
@@ -34,6 +34,7 @@
#define FAST486_NUM_SEG_REGS 6
#define FAST486_NUM_CTRL_REGS 3
#define FAST486_NUM_DBG_REGS 6
+#define FAST486_NUM_FPU_REGS 8
#define FAST486_CR0_PE (1 << 0)
#define FAST486_CR0_MP (1 << 1)
@@ -376,6 +377,55 @@
ULONG IopbOffset;
} FAST486_TSS, *PFAST486_TSS;
+typedef struct _FAST486_FPU_DATA_REG
+{
+ ULONGLONG Mantissa;
+ USHORT Exponent;
+} FAST486_FPU_DATA_REG, *PFAST486_FPU_DATA_REG;
+
+typedef union _FAST486_FPU_STATUS_REG
+{
+ USHORT Value;
+
+ struct
+ {
+ ULONG Ie : 1;
+ ULONG De : 1;
+ ULONG Ze : 1;
+ ULONG Oe : 1;
+ ULONG Ue : 1;
+ ULONG Pe : 1;
+ ULONG Sf : 1;
+ ULONG Es : 1;
+ ULONG Code0 : 1;
+ ULONG Code1 : 1;
+ ULONG Code2 : 1;
+ ULONG Top : 3;
+ ULONG Code3 : 1;
+ ULONG Busy : 1;
+ };
+} FAST486_FPU_STATUS_REG, *PFAST486_FPU_STATUS_REG;
+
+typedef union _FAST486_FPU_CONTROL_REG
+{
+ USHORT Value;
+
+ struct
+ {
+ ULONG Im : 1;
+ ULONG Dm : 1;
+ ULONG Zm : 1;
+ ULONG Om : 1;
+ ULONG Um : 1;
+ ULONG Pm : 1;
+ ULONG Reserved : 2;
+ ULONG Pc : 2;
+ ULONG Rc : 2;
+ ULONG Inf : 1;
+ // ULONG Reserved1 : 3;
+ };
+} FAST486_FPU_CONTROL_REG, *PFAST486_FPU_CONTROL_REG;
+
struct _FAST486_STATE
{
FAST486_MEM_READ_PROC MemReadCallback;
@@ -399,6 +449,10 @@
FAST486_INT_STATUS IntStatus;
UCHAR PendingIntNum;
PULONG Tlb;
+ FAST486_FPU_DATA_REG FpuRegisters[FAST486_NUM_FPU_REGS];
+ FAST486_FPU_STATUS_REG FpuStatus;
+ FAST486_FPU_CONTROL_REG FpuControl;
+ USHORT FpuTag;
};
/* FUNCTIONS ******************************************************************/
Modified: branches/ntvdm/lib/fast486/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/CMakeLists.tx…
==============================================================================
--- branches/ntvdm/lib/fast486/CMakeLists.txt [iso-8859-1] (original)
+++ branches/ntvdm/lib/fast486/CMakeLists.txt [iso-8859-1] Fri Nov 29 03:00:59 2013
@@ -6,6 +6,7 @@
opcodes.c
opgroups.c
extraops.c
- common.c)
+ common.c
+ fpu.c)
add_library(fast486 ${SOURCE})
Added: branches/ntvdm/lib/fast486/fpu.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/fpu.c?rev=611…
==============================================================================
--- branches/ntvdm/lib/fast486/fpu.c (added)
+++ branches/ntvdm/lib/fast486/fpu.c [iso-8859-1] Fri Nov 29 03:00:59 2013
@@ -0,0 +1,100 @@
+/*
+ * Fast486 386/486 CPU Emulation Library
+ * fpu.c
+ *
+ * Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <windef.h>
+
+// #define NDEBUG
+#include <debug.h>
+
+#include <fast486.h>
+#include "common.h"
+#include "opcodes.h"
+#include "fpu.h"
+
+/* PUBLIC FUNCTIONS ***********************************************************/
+
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD8)
+{
+ // TODO: NOT IMPLEMENTED
+ UNIMPLEMENTED;
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return FALSE;
+}
+
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD9)
+{
+ // TODO: NOT IMPLEMENTED
+ UNIMPLEMENTED;
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return FALSE;
+}
+
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDA)
+{
+ // TODO: NOT IMPLEMENTED
+ UNIMPLEMENTED;
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return FALSE;
+}
+
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDB)
+{
+ // TODO: NOT IMPLEMENTED
+ UNIMPLEMENTED;
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return FALSE;
+}
+
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDC)
+{
+ // TODO: NOT IMPLEMENTED
+ UNIMPLEMENTED;
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return FALSE;
+}
+
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDD)
+{
+ // TODO: NOT IMPLEMENTED
+ UNIMPLEMENTED;
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return FALSE;
+}
+
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDE)
+{
+ // TODO: NOT IMPLEMENTED
+ UNIMPLEMENTED;
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return FALSE;
+}
+
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDF)
+{
+ // TODO: NOT IMPLEMENTED
+ UNIMPLEMENTED;
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return FALSE;
+}
+
+/* EOF */
Propchange: branches/ntvdm/lib/fast486/fpu.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/ntvdm/lib/fast486/fpu.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/fpu.h?rev=611…
==============================================================================
--- branches/ntvdm/lib/fast486/fpu.h (added)
+++ branches/ntvdm/lib/fast486/fpu.h [iso-8859-1] Fri Nov 29 03:00:59 2013
@@ -0,0 +1,55 @@
+/*
+ * Fast486 386/486 CPU Emulation Library
+ * fpu.h
+ *
+ * Copyright (C) 2013 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _FPU_H_
+#define _FPU_H_
+
+#pragma once
+
+/* DEFINES ********************************************************************/
+
+enum
+{
+ FPU_SINGLE_PRECISION = 0,
+ FPU_DOUBLE_PRECISION = 2,
+ FPU_DOUBLE_EXT_PRECISION = 3
+};
+
+enum
+{
+ FPU_TAG_VALID = 0,
+ FPU_TAG_ZERO = 1,
+ FPU_TAG_SPECIAL = 2,
+ FPU_TAG_EMPTY = 3
+};
+
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD8);
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeD9);
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDA);
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDB);
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDC);
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDD);
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDE);
+FAST486_OPCODE_HANDLER(Fast486FpuOpcodeDF);
+
+#endif // _FPU_H_
+
+/* EOF */
Propchange: branches/ntvdm/lib/fast486/fpu.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/ntvdm/lib/fast486/opcodes.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/lib/fast486/opcodes.c?rev…
==============================================================================
--- branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] (original)
+++ branches/ntvdm/lib/fast486/opcodes.c [iso-8859-1] Fri Nov 29 03:00:59 2013
@@ -31,6 +31,7 @@
#include "opgroups.h"
#include "extraops.h"
#include "common.h"
+#include "fpu.h"
/* PUBLIC VARIABLES ***********************************************************/
@@ -253,14 +254,14 @@
Fast486OpcodeAad,
Fast486OpcodeSalc,
Fast486OpcodeXlat,
- NULL, // TODO: OPCODE 0xD8 NOT SUPPORTED
- NULL, // TODO: OPCODE 0xD9 NOT SUPPORTED
- NULL, // TODO: OPCODE 0xDA NOT SUPPORTED
- NULL, // TODO: OPCODE 0xDB NOT SUPPORTED
- NULL, // TODO: OPCODE 0xDC NOT SUPPORTED
- NULL, // TODO: OPCODE 0xDD NOT SUPPORTED
- NULL, // TODO: OPCODE 0xDE NOT SUPPORTED
- NULL, // TODO: OPCODE 0xDF NOT SUPPORTED
+ Fast486FpuOpcodeD8,
+ Fast486FpuOpcodeD9,
+ Fast486FpuOpcodeDA,
+ Fast486FpuOpcodeDB,
+ Fast486FpuOpcodeDC,
+ Fast486FpuOpcodeDD,
+ Fast486FpuOpcodeDE,
+ Fast486FpuOpcodeDF,
Fast486OpcodeLoop,
Fast486OpcodeLoop,
Fast486OpcodeLoop,