From 6c3720686bbf8fd527ea69838fa797ae46b33f18 Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 7 Apr 2002 13:42:45 +0000 Subject: [PATCH] First test plugin git-svn-id: svn://svn.cc65.org/cc65/trunk@1221 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/sim65/chip.c | 24 ++++++++----- src/sim65/chip.h | 2 +- src/sim65/chipif.h | 51 ++++++++++++++++++++++++++++ src/sim65/chippath.c | 2 +- src/sim65/chippath.h | 2 +- src/sim65/chips/.cvsignore | 2 ++ src/sim65/chips/make/gcc.mak | 45 ++++++++++++++++++++++++ src/sim65/chips/ram.c | 66 ++++++++++++++++++++++++++++++++++++ src/sim65/main.c | 6 +++- src/sim65/make/gcc.mak | 3 +- src/sim65/simdata.c | 54 +++++++++++++++++++++++++++++ src/sim65/simdata.h | 64 ++++++++++++++++++++++++++++++++++ 12 files changed, 308 insertions(+), 13 deletions(-) create mode 100644 src/sim65/chipif.h create mode 100644 src/sim65/chips/.cvsignore create mode 100644 src/sim65/chips/make/gcc.mak create mode 100644 src/sim65/chips/ram.c create mode 100644 src/sim65/simdata.c create mode 100644 src/sim65/simdata.h diff --git a/src/sim65/chip.c b/src/sim65/chip.c index b73b7f0e7..19a1c29aa 100644 --- a/src/sim65/chip.c +++ b/src/sim65/chip.c @@ -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. */ diff --git a/src/sim65/chip.h b/src/sim65/chip.h index 6b594638d..72f7b5ee8 100644 --- a/src/sim65/chip.h +++ b/src/sim65/chip.h @@ -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 index 000000000..8359a6f55 --- /dev/null +++ b/src/sim65/chipif.h @@ -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 + + + diff --git a/src/sim65/chippath.c b/src/sim65/chippath.c index 0e983fece..f39431fcd 100644 --- a/src/sim65/chippath.c +++ b/src/sim65/chippath.c @@ -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. */ diff --git a/src/sim65/chippath.h b/src/sim65/chippath.h index 5bf28e4a7..82560bb21 100644 --- a/src/sim65/chippath.h +++ b/src/sim65/chippath.h @@ -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 index 000000000..f1e0738d6 --- /dev/null +++ b/src/sim65/chips/.cvsignore @@ -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 index 000000000..eb0f48814 --- /dev/null +++ b/src/sim65/chips/make/gcc.mak @@ -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 index 000000000..36df2ea37 --- /dev/null +++ b/src/sim65/chips/ram.c @@ -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; +} + + + diff --git a/src/sim65/main.c b/src/sim65/main.c index 58ffd7686..5b7d44f9e 100644 --- a/src/sim65/main.c +++ b/src/sim65/main.c @@ -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 (); diff --git a/src/sim65/make/gcc.mak b/src/sim65/make/gcc.mak index 37aa8cd1b..d04e0e01c 100644 --- a/src/sim65/make/gcc.mak +++ b/src/sim65/make/gcc.mak @@ -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 index 000000000..4f8321c05 --- /dev/null +++ b/src/sim65/simdata.c @@ -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 index 000000000..cac6da7aa --- /dev/null +++ b/src/sim65/simdata.h @@ -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 + + + -- 2.39.5