Update of /cvsroot/arcem/arcem
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19643

Modified Files:
        armdefs.h arminit.c hostfs.c 
Log Message:
Move FastMap array out of the ARMul_State structure in order to reduce the size 
of state, with a view to allocating it in faster memory.  State can now be 
allocated by the platform code if necessary and is propagated down into 
functions that were erstwhile using &statestr.  Added some support for 
allocating the state in on-chip memory on the PPC460ex, however disabled by 
default as not working correctly at present.


Index: arminit.c
===================================================================
RCS file: /cvsroot/arcem/arcem/arminit.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- arminit.c   12 May 2012 17:34:51 -0000      1.10
+++ arminit.c   6 Mar 2013 19:07:29 -0000       1.11
@@ -21,6 +21,8 @@
 #include "armarc.h"
 #include "hostfs.h"
 
+FastMapEntry FastMap[FASTMAP_SIZE];
+
 /***************************************************************************\
 *                 Definitions for the emulator architecture                 *
 \***************************************************************************/
@@ -96,7 +98,7 @@
 {ARMul_State *state;
  unsigned i, j;
 
- state = &statestr;
+ state = state_alloc(sizeof(ARMul_State));
 
  for (i = 0; i < 16; i++) {
     state->Reg[i] = 0;
@@ -105,9 +107,9 @@
     }
 
  state->Aborted = FALSE;
-
  state->Display = NULL;
-
+ state->FastMap = FastMap;
+ 
  ARMul_Reset(state);
  EventQ_Init(state);
  return(state);
@@ -148,7 +150,7 @@
 
 void ARMul_Abort(ARMul_State *state, ARMword vector) {
   ARMword temp;
-
+  int exit_code;
   state->Aborted = FALSE;
 
 #ifdef DEBUG
@@ -191,10 +193,9 @@
          if ((instr & 0xfdffc0) == ARCEM_SWI_CHUNK) {
            switch (instr & 0x3f) {
            case ARCEM_SWI_SHUTDOWN-ARCEM_SWI_CHUNK:
-#ifdef AMIGA
-             cleanup();
-#endif
-             exit(state->Reg[0] & 0xff);
+             exit_code = state->Reg[0] & 0xff;
+                        state_free(state);
+             exit(exit_code);
              break;
 #ifdef HOSTFS_SUPPORT
            case ARCEM_SWI_HOSTFS-ARCEM_SWI_CHUNK:

Index: armdefs.h
===================================================================
RCS file: /cvsroot/arcem/arcem/armdefs.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- armdefs.h   12 May 2012 17:34:51 -0000      1.7
+++ armdefs.h   6 Mar 2013 19:07:29 -0000       1.8
@@ -241,7 +241,7 @@
    /* Fastmap stuff */
    FastMapUInt FastMapMode;   /* Current access mode flags */
    FastMapUInt FastMapInstrFuncOfs; /* Offset between the RAM/ROM data and the 
ARMEmuFunc data */
-   FastMapEntry FastMap[FASTMAP_SIZE];
+   FastMapEntry *FastMap;
 
    /* Less common stuff */   
    ARMword RegBank[4][16];    /* all the registers */
@@ -262,7 +262,24 @@
 
  };
 
+#ifdef AMIGA
+extern void *state_alloc(int s);
+extern void state_free(void *p);
+#else
+/* If you need special allocation for the state rather than
+ * using the usual static global, you can override these functions
+ * and provide your own.
+ */
+static inline void *state_alloc(int s)
+{
+       return &statestr;
+}
 
+static inline void state_free(void *p)
+{
+}
+#endif
+ 
 /***************************************************************************\
 *                  Definitons of things in the emulator                     *
 \***************************************************************************/

Index: hostfs.c
===================================================================
RCS file: /cvsroot/arcem/arcem/hostfs.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- hostfs.c    21 Oct 2012 16:59:31 -0000      1.22
+++ hostfs.c    6 Mar 2013 19:07:29 -0000       1.23
@@ -1036,7 +1036,7 @@
 
   fseeko64(f, (off64_t) state->Reg[4], SEEK_SET);
 
-  File_ReadRAM(f, ptr, state->Reg[3]);
+  File_ReadRAM(state, f, ptr, state->Reg[3]);
 }
 
 static void
@@ -1056,7 +1056,7 @@
 
   fseeko64(f, (off64_t) state->Reg[4], SEEK_SET);
 
-  File_WriteRAM(f, ptr, state->Reg[3]);
+  File_WriteRAM(state, f, ptr, state->Reg[3]);
 }
 
 static void
@@ -1283,7 +1283,7 @@
   }
 
   if (with_data) {
-    bytes_written = File_WriteRAM(f,ptr,length);
+    bytes_written = File_WriteRAM(state,f,ptr,length);
   } else {
     /* Fill the data buffer with 0's if we are not saving supplied data */
     hostfs_ensure_buffer_size(BUFSIZE);
@@ -1556,7 +1556,7 @@
     return;
   }
 
-  bytes_read = File_ReadRAM(f,ptr,state->Reg[4]);
+  bytes_read = File_ReadRAM(state, f,ptr,state->Reg[4]);
   if(bytes_read != state->Reg[4])
   {
     fprintf(stderr,"hostfs_file_255_load_file(): Failed to read full extent of 
file\n");


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
-- 
arcem-cvs mailing list
arcem-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/arcem-cvs

Reply via email to