about summary refs log tree commit diff stats
path: root/src/emu
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2025-04-03 21:48:04 +0800
committerGitHub <noreply@github.com>2025-04-03 15:48:04 +0200
commit8cba915bca8d48a7ac4d9571004975320f71a7ff (patch)
tree259c7742564658696da8f75f421e29c1ceb9bf7e /src/emu
parentcd3163a78585c35d41a18f248cb9575c46ffab38 (diff)
downloadbox64-8cba915bca8d48a7ac4d9571004975320f71a7ff.tar.gz
box64-8cba915bca8d48a7ac4d9571004975320f71a7ff.zip
Moved more functions to os.h (#2497)
* Removed some unused function declarations

* Moved more functions to os.h

* review
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/x64int3.c4
-rw-r--r--src/emu/x64int_private.h10
-rw-r--r--src/emu/x64run.c11
-rw-r--r--src/emu/x64run0f.c2
-rw-r--r--src/emu/x64run_private.c2
-rw-r--r--src/emu/x64run_private.h6
-rwxr-xr-xsrc/emu/x86int3.c3
7 files changed, 18 insertions, 20 deletions
diff --git a/src/emu/x64int3.c b/src/emu/x64int3.c
index 5520ce83..82bfcb26 100644
--- a/src/emu/x64int3.c
+++ b/src/emu/x64int3.c
@@ -20,6 +20,7 @@
 #include "box64cpu.h"
 #include "x64emu_private.h"
 #include "x64run_private.h"
+#include "x64int_private.h"
 #include "x87emu_private.h"
 #include "x64primop.h"
 #include "x64trace.h"
@@ -95,8 +96,7 @@ void x64Int3(x64emu_t* emu, uintptr_t* addr)
         return;
     }
     onebridge_t* bridge = (onebridge_t*)(*addr-1);
-    if(bridge->S=='S' && bridge->C=='C') // Signature for "Out of x86 door"
-    {
+    if (IsBridgeSignature(bridge->S, bridge->C)) { // Signature for "Out of x86 door"
         *addr += 2;
         uintptr_t a = F64(addr);
         if(a==0) {
diff --git a/src/emu/x64int_private.h b/src/emu/x64int_private.h
new file mode 100644
index 00000000..97e81025
--- /dev/null
+++ b/src/emu/x64int_private.h
@@ -0,0 +1,10 @@
+#ifndef __X64INT_PRIVATE_H_
+#define __X64INT_PRIVATE_H_
+
+void x64Syscall(x64emu_t *emu);
+void x64Int3(x64emu_t* emu, uintptr_t* addr);
+x64emu_t* x64emu_fork(x64emu_t* e, int forktype);
+void x86Syscall(x64emu_t *emu); //32bits syscall
+void x86Int3(x64emu_t* emu, uintptr_t* addr);
+
+#endif // __X64INT_PRIVATE_H_
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index 7ba98455..59b3a9ea 100644
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -27,11 +27,6 @@
 
 #include "modrm.h"
 
-int my_setcontext(x64emu_t* emu, void* ucp);
-#ifdef BOX32
-int my32_setcontext(x64emu_t* emu, void* ucp);
-#endif
-
 #ifdef TEST_INTERPRETER
 int RunTest(x64test_t *test)
 #else
@@ -1529,7 +1524,7 @@ x64emurun:
         case 0xCC:                      /* INT 3 */
             R_RIP = addr;   // update RIP
             #ifndef TEST_INTERPRETER
-            x64Int3(emu, &addr);
+            EmuInt3(emu, &addr);
             if(emu->quit) goto fini;    // R_RIP is up to date when returning from x64Int3
             addr = R_RIP;
             #endif
@@ -1554,7 +1549,7 @@ x64emurun:
                     tf_next = 1;
                 // 32bits syscall
                 #ifndef TEST_INTERPRETER
-                x86Syscall(emu);
+                EmuX86Syscall(emu);
                 STEP2;
                 #endif
             } else if (tmp8u==0x03) {
@@ -2303,7 +2298,7 @@ if(emu->segs[_CS]!=0x33 && emu->segs[_CS]!=0x23) printf_log(LOG_NONE, "Warning,
         int forktype = emu->fork;
         emu->quit = 0;
         emu->fork = 0;
-        emu = x64emu_fork(emu, forktype);
+        emu = EmuFork(emu, forktype);
         if(step)
             return 0;
         goto x64emurun;
diff --git a/src/emu/x64run0f.c b/src/emu/x64run0f.c
index 4a52bec3..cd0affa8 100644
--- a/src/emu/x64run0f.c
+++ b/src/emu/x64run0f.c
@@ -164,7 +164,7 @@ uintptr_t Run0F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
         case 0x05:                      /* SYSCALL */

             #ifndef TEST_INTERPRETER

             R_RIP = addr;

-            x64Syscall(emu);

+            EmuX64Syscall(emu);

             #endif

             break;

         case 0x06:                      /* CLTS */

diff --git a/src/emu/x64run_private.c b/src/emu/x64run_private.c
index 05d01966..74070784 100644
--- a/src/emu/x64run_private.c
+++ b/src/emu/x64run_private.c
@@ -1260,7 +1260,7 @@ void PrintTrace(x64emu_t* emu, uintptr_t ip, int dynarec)
             mutex_unlock(&my_context->mutex_trace);
             return;
         }
-        if(PK(0)==0xcc && PK(1)=='S' && PK(2)=='C') {
+        if (PK(0) == 0xcc && IsBridgeSignature(PK(1), PK(2))) {
             uint64_t a = *(uint64_t*)(ip+3);
             if(a==0) {
                 printf_log(LOG_NONE, "%p: Exit x86emu\n", (void*)ip);
diff --git a/src/emu/x64run_private.h b/src/emu/x64run_private.h
index 53b1bf74..e7645a87 100644
--- a/src/emu/x64run_private.h
+++ b/src/emu/x64run_private.h
@@ -178,12 +178,6 @@ uintptr_t TestAVX_F20F3A(x64test_t *test, vex_t vex, uintptr_t addr, int *step);
 uintptr_t TestAVX_F30F38(x64test_t *test, vex_t vex, uintptr_t addr, int *step);
 uintptr_t TestAVX_F30F3A(x64test_t *test, vex_t vex, uintptr_t addr, int *step);
 
-void x64Syscall(x64emu_t *emu);
-void x64Int3(x64emu_t* emu, uintptr_t* addr);
-x64emu_t* x64emu_fork(x64emu_t* e, int forktype);
-void x86Syscall(x64emu_t *emu); //32bits syscall
-void x86Int3(x64emu_t* emu, uintptr_t* addr);
-
 uintptr_t GetSegmentBaseEmu(x64emu_t* emu, int seg);
 #define GetGSBaseEmu(emu)    GetSegmentBaseEmu(emu, _GS)
 #define GetFSBaseEmu(emu)    GetSegmentBaseEmu(emu, _FS)
diff --git a/src/emu/x86int3.c b/src/emu/x86int3.c
index fea71a00..c9e5d190 100755
--- a/src/emu/x86int3.c
+++ b/src/emu/x86int3.c
@@ -47,8 +47,7 @@ extern int errno;
 void x86Int3(x64emu_t* emu, uintptr_t* addr)
 {
     onebridge_t* bridge = (onebridge_t*)(*addr-1);
-    if(Peek8(*addr, 0)=='S' && Peek8(*addr, 1)=='C') // Signature for "Out of x86 door"
-    {
+    if (IsBridgeSignature(Peek8(*addr, 0), Peek8(*addr, 1))) { // Signature for "Out of x86 door"
         *addr += 2;
         uintptr_t a = F64(addr);
         if(a==0) {