static int InitChip (const struct SimData* Data);
/* Initialize the chip, return an error code */
-static void* InitInstance (unsigned Addr, unsigned Range, void* CfgInfo);
-/* Initialize a new chip instance */
+static void* CreateInstance (unsigned Addr, unsigned Range, void* CfgInfo);
+/* Create a new chip instance */
+
+static void DestroyInstance (void* Data);
+/* Destroy a chip instance */
static void WriteCtrl (void* Data, unsigned Offs, unsigned char Val);
/* Write control data */
/* Control data passed to the main program */
-static const struct ChipData ROMData[1] = {
+static const struct ChipData CData[1] = {
{
"ROM", /* Name of the chip */
CHIPDATA_TYPE_CHIP, /* Type of the chip */
/* -- Exported functions -- */
InitChip,
- InitInstance,
+ CreateInstance,
+ DestroyInstance,
WriteCtrl,
Write,
ReadCtrl,
int GetChipData (const ChipData** Data, unsigned* Count)
{
/* Pass the control structure to the caller */
- *Data = ROMData;
- *Count = sizeof (Data) / sizeof (Data[0]);
+ *Data = CData;
+ *Count = sizeof (CData) / sizeof (CData[0]);
/* Call was successful */
return 0;
-static void* InitInstance (unsigned Addr, unsigned Range, void* CfgInfo)
-/* Initialize a new chip instance */
+static void* CreateInstance (unsigned Addr, unsigned Range, void* CfgInfo)
+/* Create a new chip instance */
{
char* Name;
FILE* F;
+static void DestroyInstance (void* Data)
+/* Destroy a chip instance */
+{
+ /* Cast the data pointer */
+ InstanceData* D = (InstanceData*) Data;
+
+ /* Free the ROM memory */
+ Sim->Free (D->Mem);
+
+ /* Free the instance data itself */
+ free (D);
+}
+
+
+
static void WriteCtrl (void* Data, unsigned Offs, unsigned char Val)
/* Write control data */
{