First test plugin
git-svn-id: svn://svn.cc65.org/cc65/trunk@1221 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
|
#include "print.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
|
||||||
/* sim65 */
|
/* 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)
|
const void* lhs, const void* rhs)
|
||||||
/* Compare function for CollSort */
|
/* Compare function for CollSort */
|
||||||
{
|
{
|
||||||
@@ -153,9 +154,11 @@ void LoadChip (const char* LibName)
|
|||||||
Chip* C;
|
Chip* C;
|
||||||
void* H;
|
void* H;
|
||||||
const char* Msg;
|
const char* Msg;
|
||||||
|
unsigned Ver;
|
||||||
|
const char* Name;
|
||||||
|
|
||||||
/* Locate the library */
|
/* Locate the library */
|
||||||
char* PathName = FindChip (LibName);
|
char* PathName = FindChipLib (LibName);
|
||||||
if (PathName == 0) {
|
if (PathName == 0) {
|
||||||
/* Library not found */
|
/* Library not found */
|
||||||
Error ("Cannot find chip plugin library `%s'", LibName);
|
Error ("Cannot find chip plugin library `%s'", LibName);
|
||||||
@@ -178,16 +181,21 @@ void LoadChip (const char* LibName)
|
|||||||
C = NewChip (H, LibName);
|
C = NewChip (H, LibName);
|
||||||
|
|
||||||
/* Read function pointers */
|
/* Read function pointers */
|
||||||
C->InitChip = GetSym (C, "InitChip");
|
/* C->InitChip = GetSym (C, "InitChip"); */
|
||||||
C->GetName = GetSym (C, "GetName");
|
C->GetName = GetSym (C, "GetName");
|
||||||
C->GetVersion = GetSym (C, "GetVersion");
|
C->GetVersion = GetSym (C, "GetVersion");
|
||||||
C->WriteCtrl = GetSym (C, "WriteCtrl");
|
/* C->WriteCtrl = GetSym (C, "WriteCtrl"); */
|
||||||
C->Write = GetSym (C, "Write");
|
/* C->Write = GetSym (C, "Write"); */
|
||||||
C->ReadCtrl = GetSym (C, "ReadCtrl");
|
/* C->ReadCtrl = GetSym (C, "ReadCtrl"); */
|
||||||
C->Read = GetSym (C, "Read");
|
/* C->Read = GetSym (C, "Read"); */
|
||||||
|
|
||||||
/* Insert the structure into the list of all chips */
|
/* Insert the structure into the list of all chips */
|
||||||
CollAppend (&Chips, C);
|
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
|
/* Find a chip by name. Returns the Chip data structure or NULL if the chip
|
||||||
* could not be found.
|
* could not be found.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void LoadChip (const char* LibName);
|
|||||||
void InitChips (void);
|
void InitChips (void);
|
||||||
/* Initialize the chips. Must be called *after* all chips are loaded */
|
/* 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
|
/* Find a chip by name. Returns the Chip data structure or NULL if the chip
|
||||||
* could not be found.
|
* could not be found.
|
||||||
*/
|
*/
|
||||||
|
|||||||
51
src/sim65/chipif.h
Normal file
51
src/sim65/chipif.h
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
/* Find a chip library. Return a pointer to a malloced area that contains
|
||||||
* the complete path, if found, return 0 otherwise.
|
* the complete path, if found, return 0 otherwise.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
void AddChipPath (const char* NewPath);
|
void AddChipPath (const char* NewPath);
|
||||||
/* Add a search path for chips */
|
/* 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
|
/* Find a chip library. Return a pointer to a malloced area that contains
|
||||||
* the complete path, if found, return 0 otherwise.
|
* the complete path, if found, return 0 otherwise.
|
||||||
*/
|
*/
|
||||||
|
|||||||
2
src/sim65/chips/.cvsignore
Normal file
2
src/sim65/chips/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.depend
|
||||||
|
*.so
|
||||||
45
src/sim65/chips/make/gcc.mak
Normal file
45
src/sim65/chips/make/gcc.mak
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
||||||
66
src/sim65/chips/ram.c
Normal file
66
src/sim65/chips/ram.c
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -44,7 +44,9 @@
|
|||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
/* sim65 */
|
/* sim65 */
|
||||||
|
#include "chip.h"
|
||||||
|
#include "chippath.h"
|
||||||
#include "cpucore.h"
|
#include "cpucore.h"
|
||||||
#include "cputype.h"
|
#include "cputype.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
@@ -200,6 +202,8 @@ int main (int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize modules */
|
/* Initialize modules */
|
||||||
|
AddChipPath ("chips");
|
||||||
|
LoadChip ("ram.so");
|
||||||
MemInit ();
|
MemInit ();
|
||||||
MemLoad ("uz.bin", 0x200, 0);
|
MemLoad ("uz.bin", 0x200, 0);
|
||||||
CPUInit ();
|
CPUInit ();
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ OBJS = chip.o \
|
|||||||
error.o \
|
error.o \
|
||||||
global.o \
|
global.o \
|
||||||
main.o \
|
main.o \
|
||||||
memory.o
|
memory.o \
|
||||||
|
simdata.o
|
||||||
|
|
||||||
LIBS = $(COMMON)/common.a
|
LIBS = $(COMMON)/common.a
|
||||||
|
|
||||||
|
|||||||
54
src/sim65/simdata.c
Normal file
54
src/sim65/simdata.c
Normal file
@@ -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 */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
64
src/sim65/simdata.h
Normal file
64
src/sim65/simdata.h
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user