about summary refs log tree commit diff stats
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/custommem.h8
-rw-r--r--src/include/dynablock.h2
-rw-r--r--src/include/env.h16
-rw-r--r--src/include/fileutils.h1
-rw-r--r--src/include/os.h1
5 files changed, 27 insertions, 1 deletions
diff --git a/src/include/custommem.h b/src/include/custommem.h
index 17acc1e9..96ebfdd0 100644
--- a/src/include/custommem.h
+++ b/src/include/custommem.h
@@ -32,11 +32,17 @@ size_t customGetUsableSize(void* p);
 #ifdef DYNAREC
 typedef struct dynablock_s dynablock_t;
 typedef struct mmaplist_s mmaplist_t;
+typedef struct DynaCacheBlock_s DynaCacheBlock_t;
 // custom protection flag to mark Page that are Write protected for Dynarec purpose
 uintptr_t AllocDynarecMap(uintptr_t x64_addr, size_t size, int is_new);
 void FreeDynarecMap(uintptr_t addr);
 mmaplist_t* NewMmaplist();
 void DelMmaplist(mmaplist_t* list);
+int MmaplistHasNew(mmaplist_t* list, int clear);
+int MmaplistNBlocks(mmaplist_t* list);
+void MmaplistFillBlocks(mmaplist_t* list, DynaCacheBlock_t* blocks);
+void MmaplistAddNBlocks(mmaplist_t* list, int nblocks);
+int MmaplistAddBlock(mmaplist_t* list, int fd, off_t offset, void* orig, size_t size, intptr_t delta_map, uintptr_t mapping_start);
 
 void addDBFromAddressRange(uintptr_t addr, size_t size);
 // Will return 1 if at least 1 db in the address range
@@ -134,6 +140,8 @@ void fini_custommem_helper(box64context_t* ctx);
 // ---- StrongMemoryModel
 void addLockAddress(uintptr_t addr);    // add an address to the list of "LOCK"able
 int isLockAddress(uintptr_t addr);  // return 1 is the address is used as a LOCK, 0 else
+int nLockAddressRange(uintptr_t start, size_t size);    // gives the number of lock address for a range
+void getLockAddressRange(uintptr_t start, size_t size, uintptr_t addrs[]);   // fill in the array with the lock addresses in the range (array must be of the correct size)
 
 void SetHotPage(uintptr_t addr);
 void CheckHotPage(uintptr_t addr);
diff --git a/src/include/dynablock.h b/src/include/dynablock.h
index 551a223e..650e18cd 100644
--- a/src/include/dynablock.h
+++ b/src/include/dynablock.h
@@ -5,7 +5,7 @@ typedef struct x64emu_s x64emu_t;
 typedef struct dynablock_s dynablock_t;
 
 uint32_t X31_hash_code(void* addr, int len);
-void FreeDynablock(dynablock_t* db, int need_lock);
+void FreeDynablock(dynablock_t* db, int need_lock, int need_remove);
 void MarkDynablock(dynablock_t* db);
 void MarkRangeDynablock(dynablock_t* db, uintptr_t addr, uintptr_t size);
 int FreeRangeDynablock(dynablock_t* db, uintptr_t addr, uintptr_t size);
diff --git a/src/include/env.h b/src/include/env.h
index 1c640091..6e0df8c1 100644
--- a/src/include/env.h
+++ b/src/include/env.h
@@ -127,6 +127,8 @@ extern char* ftrace_name;
     BOOLEAN(BOX64_X11THREADS, x11threads, 0, 0)                               \
     BOOLEAN(BOX64_X87_NO80BITS, x87_no80bits, 0, 1)                           \
     BOOLEAN(BOX64_DYNACACHE, dynacache, 0, 0)                                 \
+    STRING(BOX64_DYNACACHE_FOLDER, dynacache_folder, 0)                       \
+    INTEGER(BOX64_DYNACACHE_MIN, dynacache_min, 350, 0, 10240, 0)             \
 
 #ifdef ARM64
 #define ENVSUPER2() \
@@ -195,6 +197,15 @@ typedef struct box64env_s {
 } box64env_t;
 
 typedef struct mmaplist_s mmaplist_t;
+#ifdef DYNAREC
+typedef struct blocklist_s blocklist_t;
+
+typedef struct DynaCacheBlock_s {
+    blocklist_t*    block;
+    size_t          size;
+    size_t          free_size;
+} DynaCacheBlock_t;
+#endif
 
 void InitializeEnvFiles();
 void ApplyEnvFileEntry(const char* name);
@@ -203,11 +214,16 @@ void InitializeEnv();
 void LoadEnvVariables();
 void PrintEnvVariables(box64env_t* env, int level);
 void RecordEnvMappings(uintptr_t addr, size_t length, int fd);
+void WillRemoveMapping(uintptr_t addr, size_t length);
 void RemoveMapping(uintptr_t addr, size_t length);
 box64env_t* GetCurEnvByAddr(uintptr_t addr);
 int IsAddrFileMapped(uintptr_t addr, const char** filename, uintptr_t* start);
 size_t SizeFileMapped(uintptr_t addr);
 mmaplist_t* GetMmaplistByAddr(uintptr_t addr);
 int IsAddrNeedReloc(uintptr_t addr);
+void SerializeAllMapping();
+void DynaCacheList(const char* name);
+void DynaCacheClean();
+int IsAddrMappingLoadAndClean(uintptr_t addr);
 
 #endif // __ENV_H
diff --git a/src/include/fileutils.h b/src/include/fileutils.h
index 855eb8ff..042ca800 100644
--- a/src/include/fileutils.h
+++ b/src/include/fileutils.h
@@ -12,6 +12,7 @@ char* ResolveFileSoft(const char* filename, path_collection_t* paths);
 int FileIsX86ELF(const char* filename);
 int FileIsX64ELF(const char* filename);
 int FileIsShell(const char* filename);
+size_t FileSize(const char* filename);
 
 // return temp folder (will return /tmp if nothing is correct)
 const char* GetTmpDir(void);
diff --git a/src/include/os.h b/src/include/os.h
index dc3e2c33..7a6c036c 100644
--- a/src/include/os.h
+++ b/src/include/os.h
@@ -107,6 +107,7 @@ void* GetEnv(const char* name);
 
 // 0 : doesn't exist, 1: does exist.
 int FileExist(const char* filename, int flags);
+int MakeDir(const char* folder);    // return 1 for success, 0 else
 
 #ifdef _WIN32
 #define BOXFILE_BUFSIZE 4096