Working on the plugins
git-svn-id: svn://svn.cc65.org/cc65/trunk@1222 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
149
src/sim65/chip.c
149
src/sim65/chip.c
@@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
@@ -42,7 +41,8 @@
|
|||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
|
||||||
/* sim65 */
|
/* sim65 */
|
||||||
#include "chippath.h"
|
#include "chipdata.h"
|
||||||
|
#include "chiplib.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|
||||||
@@ -69,37 +69,12 @@ 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 */
|
||||||
{
|
{
|
||||||
return strcmp (((const Chip*) lhs)->Name, ((const Chip*) rhs)->Name);
|
/* Cast the object pointers */
|
||||||
}
|
const Chip* Left = (const Chip*) rhs;
|
||||||
|
const Chip* Right = (const Chip*) lhs;
|
||||||
|
|
||||||
|
/* Do the compare */
|
||||||
|
return strcmp (Left->Data->ChipName, Right->Data->ChipName);
|
||||||
void* GetSym (const Chip* C, const char* SymName)
|
|
||||||
/* Locate a symbol in a module and return it. Abort on errors (may be modified
|
|
||||||
* later to return NULL).
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
void* Val;
|
|
||||||
const char* Msg;
|
|
||||||
|
|
||||||
/* Fetch the error message and discard it - this will clear pending
|
|
||||||
* errors
|
|
||||||
*/
|
|
||||||
dlerror ();
|
|
||||||
|
|
||||||
/* Fetch the symbol value */
|
|
||||||
Val = dlsym (C->Handle, SymName);
|
|
||||||
|
|
||||||
/* Check the error message */
|
|
||||||
Msg = dlerror ();
|
|
||||||
if (Msg) {
|
|
||||||
/* We had an error */
|
|
||||||
Error ("Error loading `%s' from `%s': %s", SymName, C->LibName, Msg);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the symbol value read */
|
|
||||||
return Val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -110,100 +85,66 @@ void* GetSym (const Chip* C, const char* SymName)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Chip* NewChip (void* Handle, const char* LibName)
|
static Chip* NewChip (ChipLibrary* Library, const ChipData* Data)
|
||||||
/* Allocate a new chip structure, initialize and return it */
|
/* Allocate a new chip structure, initialize and return it */
|
||||||
{
|
{
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
Chip* C = xmalloc (sizeof (Chip));
|
Chip* C = xmalloc (sizeof (Chip));
|
||||||
|
|
||||||
/* Initialize the fields */
|
/* Initialize the fields */
|
||||||
C->Name = 0;
|
C->Library = Library;
|
||||||
C->LibName = xstrdup (LibName);
|
C->Data = Data;
|
||||||
C->Handle = Handle;
|
C->Instances = EmptyCollection;
|
||||||
C->InitChip = 0;
|
|
||||||
C->GetVersion = 0;
|
|
||||||
C->WriteCtrl = 0;
|
|
||||||
C->Write = 0;
|
|
||||||
C->ReadCtrl = 0;
|
|
||||||
C->Read = 0;
|
|
||||||
|
|
||||||
/* Return the structure */
|
/* Return the structure */
|
||||||
return C;
|
return C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FreeChip (Chip* C)
|
#if 0
|
||||||
/* Free the given chip structure */
|
static void FreeChip (Chip* C)
|
||||||
|
/* ## Free the given chip structure */
|
||||||
{
|
{
|
||||||
/* Free the strings */
|
|
||||||
xfree (C->Name);
|
|
||||||
xfree (C->LibName);
|
|
||||||
|
|
||||||
/* Free the structure itself */
|
/* Free the structure itself */
|
||||||
xfree (C);
|
xfree (C);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LoadChip (const char* LibName)
|
void LoadChips (void)
|
||||||
/* Load a chip. This includes loading the shared libary, allocating and
|
/* Load all chips from all libraries */
|
||||||
* initializing the data structure.
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
Chip* C;
|
unsigned I, J;
|
||||||
void* H;
|
|
||||||
const char* Msg;
|
|
||||||
unsigned Ver;
|
|
||||||
const char* Name;
|
|
||||||
|
|
||||||
/* Locate the library */
|
/* Walk through all libraries */
|
||||||
char* PathName = FindChipLib (LibName);
|
for (I = 0; I < CollCount (&ChipLibraries); ++I) {
|
||||||
if (PathName == 0) {
|
|
||||||
/* Library not found */
|
/* Get the library entry */
|
||||||
Error ("Cannot find chip plugin library `%s'", LibName);
|
ChipLibrary* L = CollAt (&ChipLibraries, I);
|
||||||
return;
|
|
||||||
|
/* Create the chips */
|
||||||
|
for (J = 0; J < L->ChipCount; ++J) {
|
||||||
|
|
||||||
|
/* Get a pointer to the chip data */
|
||||||
|
const ChipData* Data = L->Data + J;
|
||||||
|
|
||||||
|
/* Check if the chip data has the correct version */
|
||||||
|
if (Data->MajorVersion != CHIPDATA_VER_MAJOR) {
|
||||||
|
Warning ("Version mismatch for `%s' (%s), expected %u, got %u",
|
||||||
|
Data->ChipName, L->LibName,
|
||||||
|
CHIPDATA_VER_MAJOR, Data->MajorVersion);
|
||||||
|
/* Ignore this chip */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generate a new chip and insert it into the collection */
|
||||||
|
CollAppend (&Chips, NewChip (L, Data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the library */
|
/* Last act: Sort the chips by name */
|
||||||
H = dlopen (PathName, RTLD_GLOBAL | RTLD_LAZY);
|
|
||||||
|
|
||||||
/* Check for errors */
|
|
||||||
Msg = dlerror ();
|
|
||||||
if (Msg) {
|
|
||||||
Error ("Error opening `%s': %s", PathName, Msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free the path to the library since we don't need it any longer */
|
|
||||||
xfree (PathName);
|
|
||||||
|
|
||||||
/* Allocate the chip structure */
|
|
||||||
C = NewChip (H, LibName);
|
|
||||||
|
|
||||||
/* Read function pointers */
|
|
||||||
/* 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"); */
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void InitChips (void)
|
|
||||||
/* Initialize the chips. Must be called *after* all chips are loaded */
|
|
||||||
{
|
|
||||||
/* Sort the chips by name */
|
|
||||||
CollSort (&Chips, CmpChips, 0);
|
CollSort (&Chips, CmpChips, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,32 +38,38 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* common.h */
|
||||||
|
#include "coll.h"
|
||||||
|
|
||||||
|
/* sim65 */
|
||||||
|
#include "chipdata.h"
|
||||||
|
#include "simdata.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Data */
|
/* Data */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Forward */
|
#if 0
|
||||||
struct SimData;
|
typedef struct ChipInstance ChipInstance;
|
||||||
|
struct ChipInstance {
|
||||||
|
Chip* C; /* Pointer to corresponding chip */
|
||||||
|
unsigned Addr; /* Start address of range */
|
||||||
|
unsigned Size; /* Size of range */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Chip structure */
|
/* Chip structure */
|
||||||
typedef struct Chip Chip;
|
typedef struct Chip Chip;
|
||||||
struct Chip {
|
struct Chip {
|
||||||
char* Name; /* Name - must be unique */
|
struct ChipLibrary* Library; /* Pointer to library data structure */
|
||||||
char* LibName; /* Name of the associated library */
|
const ChipData* Data; /* Chip data as given by the library */
|
||||||
void* Handle; /* Library handle or pointer to it */
|
Collection Instances; /* Pointer to chip instances */
|
||||||
|
|
||||||
/* -- Exported functions -- */
|
|
||||||
unsigned (*InitChip) (const struct SimData* Data);
|
|
||||||
const char* (*GetName) (void);
|
|
||||||
unsigned (*GetVersion) (void);
|
|
||||||
|
|
||||||
void (*WriteCtrl) (unsigned Addr, unsigned char Val);
|
|
||||||
void (*Write) (unsigned Addr, unsigned char Val);
|
|
||||||
|
|
||||||
unsigned char (*ReadCtrl) (unsigned Addr);
|
|
||||||
unsigned char (*Read) (unsigned Addr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -74,13 +80,8 @@ struct Chip {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LoadChip (const char* LibName);
|
void LoadChips (void);
|
||||||
/* Load a chip. This includes loading the shared libary, allocating and
|
/* Load all chips from all libraries */
|
||||||
* initializing the data structure.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void InitChips (void);
|
|
||||||
/* Initialize the chips. Must be called *after* all chips are loaded */
|
|
||||||
|
|
||||||
const Chip* FindChip (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
|
||||||
|
|||||||
76
src/sim65/chipdata.h
Normal file
76
src/sim65/chipdata.h
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* chipdata.h */
|
||||||
|
/* */
|
||||||
|
/* Chip description data structure */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* (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 CHIPDATA_H
|
||||||
|
#define CHIPDATA_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Version information. */
|
||||||
|
#define CHIPDATA_VER_MAJOR 1U
|
||||||
|
#define CHIPDATA_VER_MINOR 0U
|
||||||
|
|
||||||
|
/* Forwards */
|
||||||
|
struct SimData;
|
||||||
|
|
||||||
|
/* ChipDesc structure */
|
||||||
|
typedef struct ChipData ChipData;
|
||||||
|
struct ChipData {
|
||||||
|
const char* ChipName; /* Name of the chip */
|
||||||
|
unsigned MajorVersion; /* Version information */
|
||||||
|
unsigned MinorVersion;
|
||||||
|
|
||||||
|
/* -- Exported functions -- */
|
||||||
|
void* (*Init) (const struct SimData* Data, unsigned Addr, unsigned Range);
|
||||||
|
void (*WriteCtrl) (void* Data, unsigned Addr, unsigned char Val);
|
||||||
|
void (*Write) (void* Data, unsigned Addr, unsigned char Val);
|
||||||
|
unsigned char (*ReadCtrl) (void* Data, unsigned Addr);
|
||||||
|
unsigned char (*Read) (void* Data, unsigned Addr);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* End of chipdata.h */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* sim65 */
|
/* sim65 */
|
||||||
|
#include "chipdata.h"
|
||||||
#include "simdata.h"
|
#include "simdata.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
171
src/sim65/chiplib.c
Normal file
171
src/sim65/chiplib.c
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* chiplib.c */
|
||||||
|
/* */
|
||||||
|
/* Chip library handling 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. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "print.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
|
/* sim65 */
|
||||||
|
#include "chippath.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "chiplib.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Forwards */
|
||||||
|
struct ChipData;
|
||||||
|
|
||||||
|
/* A collection containing all libraries */
|
||||||
|
Collection ChipLibraries = STATIC_COLLECTION_INITIALIZER;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Code */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static ChipLibrary* NewChipLibrary (const char* LibName)
|
||||||
|
/* Create, initialize and return a new ChipLibrary structure */
|
||||||
|
{
|
||||||
|
/* Allocate memory */
|
||||||
|
ChipLibrary* L = xmalloc (sizeof (ChipLibrary));
|
||||||
|
|
||||||
|
/* Initialize the fields */
|
||||||
|
L->LibName = xstrdup (LibName);
|
||||||
|
L->PathName = 0;
|
||||||
|
L->Handle = 0;
|
||||||
|
L->Data = 0;
|
||||||
|
L->ChipCount = 0;
|
||||||
|
L->Chips = EmptyCollection;
|
||||||
|
|
||||||
|
/* Return the allocated structure */
|
||||||
|
return L;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void FreeChipLibrary (ChipLibrary* L)
|
||||||
|
/* Free a ChipLibrary structure */
|
||||||
|
{
|
||||||
|
/* Free the names */
|
||||||
|
xfree (L->LibName);
|
||||||
|
xfree (L->PathName);
|
||||||
|
|
||||||
|
/* If the library is open, close it. Discard any errors. */
|
||||||
|
if (L->Handle) {
|
||||||
|
dlclose (L->Handle);
|
||||||
|
(void) dlerror ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We may have to handle the Chip pointers, but currently the function
|
||||||
|
* is never called with a non empty Chips collection, so we don't care
|
||||||
|
* for now.
|
||||||
|
*/
|
||||||
|
xfree (L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void LoadChipLibrary (const char* LibName)
|
||||||
|
/* Load a chip library . This includes loading the shared libary, allocating
|
||||||
|
* and initializing the data structure.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
const char* Msg;
|
||||||
|
int (*GetChipData) (const struct ChipData**, unsigned*);
|
||||||
|
int ErrorCode;
|
||||||
|
|
||||||
|
/* Allocate a new ChipLibrary structure */
|
||||||
|
ChipLibrary* L = NewChipLibrary (LibName);
|
||||||
|
|
||||||
|
/* Locate the library */
|
||||||
|
L->PathName = FindChipLib (LibName);
|
||||||
|
if (L->PathName == 0) {
|
||||||
|
/* Library not found */
|
||||||
|
Error ("Cannot find chip plugin library `%s'", LibName);
|
||||||
|
FreeChipLibrary (L);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open the library */
|
||||||
|
L->Handle = dlopen (L->PathName, RTLD_GLOBAL | RTLD_LAZY);
|
||||||
|
|
||||||
|
/* Check for errors */
|
||||||
|
Msg = dlerror ();
|
||||||
|
if (Msg) {
|
||||||
|
Error ("Cannot open `%s': %s", L->PathName, Msg);
|
||||||
|
FreeChipLibrary (L);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Locate the GetChipData function */
|
||||||
|
GetChipData = dlsym (L->Handle, "GetChipData");
|
||||||
|
|
||||||
|
/* Check the error message */
|
||||||
|
Msg = dlerror ();
|
||||||
|
if (Msg) {
|
||||||
|
/* We had an error */
|
||||||
|
Error ("Cannot find export `GetChipData' in `%s': %s", L->LibName, Msg);
|
||||||
|
FreeChipLibrary (L);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call the function to read the chip data */
|
||||||
|
ErrorCode = GetChipData (&L->Data, &L->ChipCount);
|
||||||
|
if (ErrorCode != 0) {
|
||||||
|
Error ("Function `GetChipData' in `%s' returned error %d", L->LibName, ErrorCode);
|
||||||
|
FreeChipLibrary (L);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remember the library */
|
||||||
|
CollAppend (&ChipLibraries, L);
|
||||||
|
|
||||||
|
/* Print some information */
|
||||||
|
Print (stderr, 1, "Opened plugin library `%s'", L->PathName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
94
src/sim65/chiplib.h
Normal file
94
src/sim65/chiplib.h
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* chiplib.h */
|
||||||
|
/* */
|
||||||
|
/* Chip library handling 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. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CHIPLIB_H
|
||||||
|
#define CHIPLIB_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "coll.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Forward */
|
||||||
|
struct ChipData;
|
||||||
|
|
||||||
|
/* ChipLibrary structure */
|
||||||
|
typedef struct ChipLibrary ChipLibrary;
|
||||||
|
struct ChipLibrary {
|
||||||
|
char* LibName; /* Name of the library as given */
|
||||||
|
char* PathName; /* Name of library including path */
|
||||||
|
void* Handle; /* Pointer to libary handle */
|
||||||
|
const struct ChipData* Data; /* Pointer to chip data */
|
||||||
|
unsigned ChipCount; /* Number of chips in this library */
|
||||||
|
Collection Chips; /* Chips in this library */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* A collection containing all libraries */
|
||||||
|
Collection ChipLibraries;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Code */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void LoadChipLibrary (const char* LibName);
|
||||||
|
/* Load a chip library . This includes loading the shared libary, allocating
|
||||||
|
* and initializing the data structure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void* GetChipLibSym (const ChipLibrary* L, const char* SymName);
|
||||||
|
/* Locate a symbol in a module and return it. Abort on errors (may be modified
|
||||||
|
* later to return NULL).
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* End of chiplib.h */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -50,15 +50,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char* GetName (void)
|
int GetChipData (const ChipData** Data, unsigned* Count)
|
||||||
{
|
|
||||||
return "RAM";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned GetVersion (void)
|
|
||||||
{
|
{
|
||||||
|
*Data = 0;
|
||||||
|
*Count = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,9 @@
|
|||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
/* sim65 */
|
/* sim65 */
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
#include "chiplib.h"
|
||||||
#include "chippath.h"
|
#include "chippath.h"
|
||||||
#include "cpucore.h"
|
#include "cpucore.h"
|
||||||
#include "cputype.h"
|
#include "cputype.h"
|
||||||
@@ -203,7 +204,8 @@ int main (int argc, char* argv[])
|
|||||||
|
|
||||||
/* Initialize modules */
|
/* Initialize modules */
|
||||||
AddChipPath ("chips");
|
AddChipPath ("chips");
|
||||||
LoadChip ("ram.so");
|
LoadChipLibrary ("ram.so");
|
||||||
|
LoadChips ();
|
||||||
MemInit ();
|
MemInit ();
|
||||||
MemLoad ("uz.bin", 0x200, 0);
|
MemLoad ("uz.bin", 0x200, 0);
|
||||||
CPUInit ();
|
CPUInit ();
|
||||||
|
|||||||
@@ -11,13 +11,14 @@ EBIND = emxbind
|
|||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
|
|
||||||
OBJS = chip.o \
|
OBJS = chip.o \
|
||||||
|
chiplib.o \
|
||||||
chippath.o \
|
chippath.o \
|
||||||
cpucore.o \
|
cpucore.o \
|
||||||
cputype.o \
|
cputype.o \
|
||||||
error.o \
|
error.o \
|
||||||
global.o \
|
global.o \
|
||||||
main.o \
|
main.o \
|
||||||
memory.o \
|
memory.o \
|
||||||
simdata.o
|
simdata.o
|
||||||
|
|
||||||
LIBS = $(COMMON)/common.a
|
LIBS = $(COMMON)/common.a
|
||||||
@@ -26,7 +27,7 @@ EXECS = sim65
|
|||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
ifeq (.depend,$(wildcard .depend))
|
ifeq (.depend,$(wildcard .depend))
|
||||||
all : $(EXECS)
|
all: $(EXECS) chips
|
||||||
include .depend
|
include .depend
|
||||||
else
|
else
|
||||||
all: depend
|
all: depend
|
||||||
@@ -34,15 +35,19 @@ all: depend
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sim65: $(OBJS) $(LIBS)
|
sim65: $(OBJS) $(LIBS)
|
||||||
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) -ldl
|
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) -ldl
|
||||||
@if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi
|
@if [ $(OS2_SHELL) ] ; then $(EBIND) $@ ; fi
|
||||||
|
|
||||||
|
.PHONY: chips
|
||||||
|
chips:
|
||||||
|
@$(MAKE) -C chips -f make/gcc.mak
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~ core *.lst
|
rm -f *~ core *.lst
|
||||||
|
|
||||||
zap: clean
|
zap: clean
|
||||||
rm -f *.o $(EXECS) .depend
|
rm -f *.o $(EXECS) .depend
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user