]> git.sur5r.net Git - cc65/commitdiff
One more intermediate state - not compilable.
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 5 Apr 2012 19:55:04 +0000 (19:55 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 5 Apr 2012 19:55:04 +0000 (19:55 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@5644 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/sim65/chip.c
src/sim65/chip.h
src/sim65/config.c
src/sim65/cpu-6502.c
src/sim65/cpu-6502.h
src/sim65/cpucore.c
src/sim65/cpucore.h
src/sim65/cpudata.h [new file with mode: 0644]
src/sim65/main.c
src/sim65/system.c
src/sim65/system.h

index 7d1504bf9d3691c4c6abd1511bde5b5ee36c9187..4a3cc39a18ed2a15132cd667584b302c1c7b3cb0 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2002-2003 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2002-2012, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 /* sim65 */
 #include "cfgdata.h"
+#include "chip.h"
 #include "chipdata.h"
 #include "cpucore.h"
 #include "error.h"
-#include "chip.h"
 
 
 
@@ -301,6 +301,7 @@ ChipInstance* MirrorChipInstance (const ChipInstance* Orig, unsigned Addr)
 
     /* Initialize the fields */
     CI->C    = Orig->C;
+    CI->AS   = 0;
     CI->Addr = Addr;
     CI->Size = Orig->Size;
     CI->Data = Orig->Data;
index f614c0ced045bfe72ba4047c566b8c293850f600..ddfad247597e18d212b1e5869df8d922a484e1d6 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2002-2003 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2003-2012, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
index 7c828026cdee6a028e1f876c520700d1607364c5..36187224c44d9babc2307939afea491973874bdf 100644 (file)
@@ -143,8 +143,8 @@ static void ParseCPU (void)
     AttrCheck (Attr, atType, "TYPE");
     AttrCheck (Attr, atAddrSpace, "ADDRSPACE");
 
-    /* Create the CPU */
-    CPUInstance = NewCPU ("6502", Size);
+    /* Create the system using the specified CPU */
+    System = NewSystem (NewCPU ("6502", Size));
 
     /* Skip the semicolon */
     CfgConsumeSemi ();
@@ -158,7 +158,7 @@ static void ParseAddrSpace (void)
     unsigned I;
 
     /* CPU must be defined before the address space */
-    if (CPUInstance == 0) {
+    if (System == 0) {
         CfgError ("CPU must be defined before address space definitions");
     }
 
index 39929634dac2664b6948473246e1eaf9d6e86221..06ef2cf3feb80285aa071e92ffff31a393f2c1d1 100644 (file)
@@ -1,6 +1,6 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                   cpucore.c                               */
+/*                                cpu-6502.c                                 */
 /*                                                                           */
 /*                        CPU core for the 6502 simulator                    */
 /*                                                                           */
 #include "strbuf.h"
 
 /* sim65 */
+#include "cpu-6502.h"
 #include "cpuregs.h"
 #include "cputype.h"
 #include "error.h"
 #include "global.h"
 #include "memory.h"
-#include "cpucore.h"
 
 
 
 /*****************************************************************************/
-/*                                  Data                                    */
+/*                                  Data                                    */
 /*****************************************************************************/
 
 
index b88617143e9cdd95423baacf097d5bb3d570822d..469cf60c8905854ddadff9e3d5045e09ec6e809d 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                   cpucore.h                               */
+/*                                cpu-6502.h                                 */
 /*                                                                           */
 /*                        CPU core for the 6502 simulator                    */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2002-2003 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2002-2012, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -33,8 +33,8 @@
 
 
 
-#ifndef CPUCORE_H
-#define CPUCORE_H
+#ifndef CPU_6502_H
+#define CPU_6502_H
 
 
 
@@ -80,7 +80,7 @@ void CPURun (void);
 
 
 
-/* End of cpucore.h */
+/* End of cpu-6502.h */
 
 #endif
 
index e4e189f6d1c91c19d53bbeab020a5d6ce91816ee..ad0c708979fa65c53d3adaed8e06e612309197b1 100644 (file)
 
 
 
-/*****************************************************************************/
-/*                                          Data                                    */
-/*****************************************************************************/
-
-
-
-/* The actual CPU instance */
-CPUCore*        CPU = 0;
-
-
-
 /*****************************************************************************/
 /*                                          Code                                    */
 /*****************************************************************************/
@@ -76,7 +65,7 @@ CPUCore* NewCPUCore (const char* Name, unsigned AddrSpaceSize)
 
     /* Initialize the data */
     C->Handle = 0;              /* ### */
-    C->AS     = NewAddressSpace (AddrSpaceSize);
+    C->AddressSize = AddrSpaceSize;
 
     /* Return the new CPU core */
     return C;
index 28b9351ff4fbe21618353c07ef8a8e1c9a2cc1e2..fba8fb835c17eaa21f0b91521a57a579b45c66d6 100644 (file)
 /* CPU core structure */
 typedef struct CPUCore CPUCore;
 struct CPUCore {
-    void*           Handle;             /* Pointer to shared lib handle */
-    AddressSpace*   AS;                 /* Address space */
-};
+    void*       Handle;                 /* Pointer to shared lib handle */
+    unsigned    AddressSize;            /* Size of the address space */
+
+    /* Callback functions */
+
 
-/* The actual CPU instance */
-extern CPUCore*         CPU;
+
+};
 
 
 
diff --git a/src/sim65/cpudata.h b/src/sim65/cpudata.h
new file mode 100644 (file)
index 0000000..b0bde1a
--- /dev/null
@@ -0,0 +1,88 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                cpudata.h                                 */
+/*                                                                           */
+/*                   CPU data passed from the CPU plugins                    */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2012,      Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef CPUDATA_H
+#define CPUDATA_H
+
+
+
+/*****************************************************************************/
+/*                                     Data                                  */
+/*****************************************************************************/
+
+
+
+/* Forwards */
+struct SimData;
+
+/* CPUData structure */
+typedef struct CPUData CPUData;
+struct CPUData {
+    const char* CPUName;                /* Name of the chip */
+    unsigned    MajorVersion;           /* Version information */
+    unsigned    MinorVersion;
+
+    /* -- Exported functions -- */
+
+    void Init (const struct SimData* Data);
+    /* Initialize the CPU module */
+
+    void* (*CreateInstance) (void* CfgInfo);
+    /* Create an instance of the CPU. Return the instance data pointer */
+
+    void (*DestroyInstance) (void* Data);
+    /* Destroy an instance of the CPU */
+
+    void Reset (void* Data);
+    /* Generate a CPU RESET */
+
+    void IRQRequest (void* Data);
+    /* Generate an IRQ */
+
+    void NMIRequest (void* Data);
+    /* Generate an NMI */
+
+    void Run (void* Data);
+    /* Run one CPU instruction */
+};
+
+
+
+/* End of cpudata.h */
+
+#endif
+
+
+
index c0c6c44fd306e33a150fd38774fd3c328a0e309d..f3bb8a112723c2d84a7a19c00d4193f8afe89633 100644 (file)
@@ -111,7 +111,7 @@ static void OptChipDir (const char* Opt attribute ((unused)), const char* Arg)
        char*  Name;
         struct stat S;
 
-       /* ### Ignore anything buy *.so files */
+       /* ### Ignore anything but *.so files */
        unsigned NameLen = strlen (E->d_name);
        if (NameLen <= 3) {
            continue;
@@ -168,7 +168,7 @@ static void OptConfig (const char* Opt attribute ((unused)), const char* Arg)
 {
     if (CfgAvail ()) {
        Error ("Cannot use -C twice");
-    }
+    }                             
     CfgSetName (Arg);
 }
 
index 99bdbee7879d90476b3283b13263b0ebed27614b..d8860a799b731d8fdb753577e716326fb50c31a9 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2003      Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2003-2012, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -37,7 +37,6 @@
 #include "xmalloc.h"
 
 /* sim65 */
-#include "addrspace.h"
 #include "system.h"
 
 
@@ -48,7 +47,7 @@
 
 
 
-System* NewSystem (struct CPUData* CPU)
+System* NewSystem (CPUCore* CPU)
 /* Create and initialize a new System struct. The function will read the size
  * of the address space from the CPU, and also create a new AddressSpace
  * object. No chips are assigned, however.
@@ -59,7 +58,7 @@ System* NewSystem (struct CPUData* CPU)
 
     /* Initialize the fields */
     Sys->CPU      = CPU;
-    Sys->AS       = 0;    /* ### */
+    Sys->AS       = NewAddressSpace (CPU->AddressSize);
     Sys->ChipInstances = AUTO_COLLECTION_INITIALIZER;
 
     /* Return the new system */
index bd2f5eb5c5a71783a36c5ac814f889bd4e2473bd..873a3f7b309fe3adc91ba754acae16013344c78a 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2003      Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2003-2012, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 /* common.h */
 #include "coll.h"
 
+/* sim65 */
+#include "addrspace.h"
+#include "cpucore.h"
+
 
 
 /*****************************************************************************/
 
 
 /* Forwards */
-struct CPUData;
+struct CPUCore;
 
 /* */
 typedef struct System System;
 struct System {
-
-    struct CPUData*       CPU;          /* The CPU in the system */
-    struct AddressSpace*  AS;           /* The CPU address space */
-    Collection            ChipInstances;/* Instances of all the chips */
-
+    CPUCore*            CPU;            /* The CPU in the system */
+    AddressSpace*       AS;             /* The CPU address space */
+    Collection          ChipInstances;  /* Instances of all the chips */
 };
 
+/* Global pointer to simulated system */
+extern System*  System;
+
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                          Code                                    */
 /*****************************************************************************/
 
 
 
-System* NewSystem (struct CPUData* CPU);
-/* Create and initialize a new System struct. The function will read the size 
- * of the address space from the CPU, and also create a new AddressSpace 
+System* NewSystem (CPUCore* CPU);
+/* Create and initialize a new System struct. The function will read the size
+ * of the address space from the CPU, and also create a new AddressSpace
  * object. No chips are assigned, however.
  */