]> git.sur5r.net Git - cc65/commitdiff
First test plugin
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 7 Apr 2002 13:42:45 +0000 (13:42 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 7 Apr 2002 13:42:45 +0000 (13:42 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1221 b7a2c559-68d2-44c3-8de9-860c34a00d81

12 files changed:
src/sim65/chip.c
src/sim65/chip.h
src/sim65/chipif.h [new file with mode: 0644]
src/sim65/chippath.c
src/sim65/chippath.h
src/sim65/chips/.cvsignore [new file with mode: 0644]
src/sim65/chips/make/gcc.mak [new file with mode: 0644]
src/sim65/chips/ram.c [new file with mode: 0644]
src/sim65/main.c
src/sim65/make/gcc.mak
src/sim65/simdata.c [new file with mode: 0644]
src/sim65/simdata.h [new file with mode: 0644]

index b73b7f0e7f83fd7acfedebaa7daa98f525974043..19a1c29aad7a28f2a6bb1408eb96f494c11f0971 100644 (file)
@@ -38,6 +38,7 @@
 
 /* common */
 #include "coll.h"
+#include "print.h"
 #include "xmalloc.h"
 
 /* sim65 */
@@ -64,7 +65,7 @@ static Collection Chips = STATIC_COLLECTION_INITIALIZER;
 
 
 
-static int CmpChips (void* Data attribute ((unused)), 
+static int CmpChips (void* Data attribute ((unused)),
                     const void* lhs, const void* rhs)
 /* Compare function for CollSort */
 {
@@ -153,9 +154,11 @@ void LoadChip (const char* LibName)
     Chip* C;
     void* H;
     const char* Msg;
+    unsigned Ver;
+    const char* Name;
 
     /* Locate the library */
-    char* PathName = FindChip (LibName);
+    char* PathName = FindChipLib (LibName);
     if (PathName == 0) {
         /* Library not found */
         Error ("Cannot find chip plugin library `%s'", LibName);
@@ -178,16 +181,21 @@ void LoadChip (const char* LibName)
     C = NewChip (H, LibName);
 
     /* Read function pointers */
-    C->InitChip     = GetSym (C, "InitChip");
+/*    C->InitChip     = GetSym (C, "InitChip"); */
     C->GetName      = GetSym (C, "GetName");
     C->GetVersion   = GetSym (C, "GetVersion");
-    C->WriteCtrl    = GetSym (C, "WriteCtrl");
-    C->Write        = GetSym (C, "Write");
-    C->ReadCtrl     = GetSym (C, "ReadCtrl");
-    C->Read         = GetSym (C, "Read");
+/*    C->WriteCtrl    = GetSym (C, "WriteCtrl"); */
+/*    C->Write        = GetSym (C, "Write"); */
+/*    C->ReadCtrl     = GetSym (C, "ReadCtrl"); */
+/*    C->Read         = GetSym (C, "Read"); */
 
     /* Insert the structure into the list of all chips */
     CollAppend (&Chips, C);
+
+    /* Call the functions */
+    Name = C->GetName ();
+    Ver  = C->GetVersion ();
+    printf ("%s version %u\n", Name, Ver);
 }
 
 
@@ -201,7 +209,7 @@ void InitChips (void)
 
 
 
-const Chip* GetChip (const char* Name)
+const Chip* FindChip (const char* Name)
 /* Find a chip by name. Returns the Chip data structure or NULL if the chip
  * could not be found.
  */
index 6b594638d588e273e52f044723a77d78aab27047..72f7b5ee8a3d40f593aed9b2d05655034d55f7ba 100644 (file)
@@ -82,7 +82,7 @@ void LoadChip (const char* LibName);
 void InitChips (void);
 /* Initialize the chips. Must be called *after* all chips are loaded */
 
-const Chip* GetChip (const char* Name);
+const Chip* FindChip (const char* Name);
 /* Find a chip by name. Returns the Chip data structure or NULL if the chip
  * could not be found.
  */
diff --git a/src/sim65/chipif.h b/src/sim65/chipif.h
new file mode 100644 (file)
index 0000000..8359a6f
--- /dev/null
@@ -0,0 +1,51 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                chipif.h                                  */
+/*                                                                           */
+/*           Interface header file for plugins - unused by sim65            */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2002      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
+/*                                                                           */
+/*                                                                           */
+/* 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 CHIPIF_H
+#define CHIPIF_H
+
+
+
+/* sim65 */
+#include "simdata.h"
+
+
+
+/* End of chipif.h */
+
+#endif
+
+
+
index 0e983fecefaf14ff0bf00c3f2db4c22cc4f4ae6f..f39431fcdfc2f05060e0e8980a14771b4c091832 100644 (file)
@@ -166,7 +166,7 @@ void AddChipPath (const char* NewPath)
 
 
 
-char* FindChip (const char* LibName)
+char* FindChipLib (const char* LibName)
 /* Find a chip library. Return a pointer to a malloced area that contains
  * the complete path, if found, return 0 otherwise.
  */
index 5bf28e4a71cfc66b86fd80c6cfc227a34940ddd8..82560bb21e56eb5c80c64b2d82e2c410c2f371f9 100644 (file)
@@ -47,7 +47,7 @@
 void AddChipPath (const char* NewPath);
 /* Add a search path for chips */
 
-char* FindChip (const char* LibName);
+char* FindChipLib (const char* LibName);
 /* Find a chip library. Return a pointer to a malloced area that contains
  * the complete path, if found, return 0 otherwise.
  */
diff --git a/src/sim65/chips/.cvsignore b/src/sim65/chips/.cvsignore
new file mode 100644 (file)
index 0000000..f1e0738
--- /dev/null
@@ -0,0 +1,2 @@
+.depend
+*.so
diff --git a/src/sim65/chips/make/gcc.mak b/src/sim65/chips/make/gcc.mak
new file mode 100644 (file)
index 0000000..eb0f488
--- /dev/null
@@ -0,0 +1,45 @@
+#
+# gcc Makefile for the sim65 chip plugins
+#
+
+# Library dir
+SIM65  = ..
+
+CFLAGS         = -g -O2 -Wall -W -I$(SIM65) -fpic
+CC     = gcc
+EBIND  = emxbind
+LDFLAGS        =
+
+CHIPS          =       ram.so
+
+OBJS   = $(CHIPS:.so=.o)
+
+.PHONY: all
+ifeq (.depend,$(wildcard .depend))
+all:   $(CHIPS)
+include .depend
+else
+all:   depend
+       @$(MAKE) -f make/gcc.mak all
+endif
+
+
+ram.so:         ram.o
+       $(CC) $(CFLAGS) -shared -o $@ $^
+       @if [ $(OS2_SHELL) ] ;  then $(EBIND) $@ ; fi
+
+clean:
+       rm -f *~ core *.lst
+
+zap:   clean
+       rm -f *.o $(EXECS) .depend
+
+# ------------------------------------------------------------------------------
+# Make the dependencies
+
+.PHONY: depend dep
+depend dep:    $(CHIPS:.so=.c)
+       @echo "Creating dependency information"
+       $(CC) -I$(SIM65) -MM $^ > .depend
+
+
diff --git a/src/sim65/chips/ram.c b/src/sim65/chips/ram.c
new file mode 100644 (file)
index 0000000..36df2ea
--- /dev/null
@@ -0,0 +1,66 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                  ram.c                                   */
+/*                                                                           */
+/*                 RAM plugin for the sim65 6502 simulator                  */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2002      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
+/*                                                                           */
+/*                                                                           */
+/* 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.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+/* sim65 */
+#include "chipif.h"
+
+
+
+/*****************************************************************************/
+/*                                     Data                                  */
+/*****************************************************************************/
+
+
+
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+const char* GetName (void)
+{
+    return "RAM";
+}
+
+
+
+unsigned GetVersion (void)
+{
+    return 1;
+}
+
+
+
index 58ffd76867bee727c231b125321a701000c5ff55..5b7d44f9ed32c7a2b7b592be1255c772fc8ec991 100644 (file)
@@ -44,7 +44,9 @@
 #include "print.h"
 #include "version.h"
 
-/* sim65 */
+/* sim65 */         
+#include "chip.h"
+#include "chippath.h"
 #include "cpucore.h"
 #include "cputype.h"
 #include "global.h"
@@ -200,6 +202,8 @@ int main (int argc, char* argv[])
     }
 
     /* Initialize modules */
+    AddChipPath ("chips");
+    LoadChip ("ram.so");
     MemInit ();
     MemLoad ("uz.bin", 0x200, 0);
     CPUInit ();
index 37aa8cd1b4ccb502e113d6139d6ef0e5e7df7028..d04e0e01ce6d3f179e73a44744044c9e6bafad23 100644 (file)
@@ -17,7 +17,8 @@ OBJS =        chip.o          \
         error.o         \
        global.o        \
        main.o          \
-        memory.o
+        memory.o       \
+        simdata.o
 
 LIBS = $(COMMON)/common.a
 
diff --git a/src/sim65/simdata.c b/src/sim65/simdata.c
new file mode 100644 (file)
index 0000000..4f8321c
--- /dev/null
@@ -0,0 +1,54 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                simdata.c                                 */
+/*                                                                           */
+/*                Simulator data passed to the chip plugins                 */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2002      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
+/*                                                                           */
+/*                                                                           */
+/* 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.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+                   
+/* sim65 */
+#include "simdata.h"
+
+
+
+/*****************************************************************************/
+/*                                     Data                                  */
+/*****************************************************************************/
+
+
+
+/* SimData instance */
+const SimData Sim65Data = {
+    1,                 /* MajorVersion */
+    1                  /* MinorVersion */
+};
+
+
+
diff --git a/src/sim65/simdata.h b/src/sim65/simdata.h
new file mode 100644 (file)
index 0000000..cac6da7
--- /dev/null
@@ -0,0 +1,64 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                simdata.h                                 */
+/*                                                                           */
+/*                Simulator data passed to the chip plugins                 */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2002      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
+/*                                                                           */
+/*                                                                           */
+/* 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 SIMDATA_H
+#define SIMDATA_H
+
+
+
+/*****************************************************************************/
+/*                                     Data                                  */
+/*****************************************************************************/
+
+
+
+/* SimData structure */
+typedef struct SimData SimData;
+struct SimData {
+    unsigned   MajorVersion;
+    unsigned   MinorVersion;
+};
+
+/* SimData instance */
+extern const SimData Sim65Data;
+
+
+
+/* End of simdata.h */
+
+#endif
+
+
+