/* */
/* */
/* */
-/* (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"
/* Initialize the fields */
CI->C = Orig->C;
+ CI->AS = 0;
CI->Addr = Addr;
CI->Size = Orig->Size;
CI->Data = Orig->Data;
/* */
/* */
/* */
-/* (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 */
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 ();
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");
}
/*****************************************************************************/
/* */
-/* 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 */
/*****************************************************************************/
/*****************************************************************************/
/* */
-/* 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 */
-#ifndef CPUCORE_H
-#define CPUCORE_H
+#ifndef CPU_6502_H
+#define CPU_6502_H
-/* End of cpucore.h */
+/* End of cpu-6502.h */
#endif
-/*****************************************************************************/
-/* Data */
-/*****************************************************************************/
-
-
-
-/* The actual CPU instance */
-CPUCore* CPU = 0;
-
-
-
/*****************************************************************************/
/* Code */
/*****************************************************************************/
/* Initialize the data */
C->Handle = 0; /* ### */
- C->AS = NewAddressSpace (AddrSpaceSize);
+ C->AddressSize = AddrSpaceSize;
/* Return the new CPU core */
return C;
/* 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;
+
+};
--- /dev/null
+/*****************************************************************************/
+/* */
+/* 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
+
+
+
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;
{
if (CfgAvail ()) {
Error ("Cannot use -C twice");
- }
+ }
CfgSetName (Arg);
}
/* */
/* */
/* */
-/* (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 */
#include "xmalloc.h"
/* sim65 */
-#include "addrspace.h"
#include "system.h"
-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.
/* Initialize the fields */
Sys->CPU = CPU;
- Sys->AS = 0; /* ### */
+ Sys->AS = NewAddressSpace (CPU->AddressSize);
Sys->ChipInstances = AUTO_COLLECTION_INITIALIZER;
/* Return the new system */
/* */
/* */
/* */
-/* (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.
*/