diff --git a/Assets/libwaterboxhost.so b/Assets/libwaterboxhost.so index 4280de9941..f4d0407d94 100644 Binary files a/Assets/libwaterboxhost.so and b/Assets/libwaterboxhost.so differ diff --git a/output/dll/faust.wbx.gz b/output/dll/faust.wbx.gz index 38e803ad30..4fb29183d9 100644 Binary files a/output/dll/faust.wbx.gz and b/output/dll/faust.wbx.gz differ diff --git a/output/dll/gpgx.wbx.gz b/output/dll/gpgx.wbx.gz index cd2c2e82a3..5687290d83 100644 Binary files a/output/dll/gpgx.wbx.gz and b/output/dll/gpgx.wbx.gz differ diff --git a/output/dll/hyper.wbx.gz b/output/dll/hyper.wbx.gz index 5b8488f2c7..76a8443cbd 100644 Binary files a/output/dll/hyper.wbx.gz and b/output/dll/hyper.wbx.gz differ diff --git a/output/dll/libsnes.wbx.gz b/output/dll/libsnes.wbx.gz index 6ff964e964..5151e7c6ca 100644 Binary files a/output/dll/libsnes.wbx.gz and b/output/dll/libsnes.wbx.gz differ diff --git a/output/dll/ngp.wbx.gz b/output/dll/ngp.wbx.gz index 3694b42566..67a0d3c76c 100644 Binary files a/output/dll/ngp.wbx.gz and b/output/dll/ngp.wbx.gz differ diff --git a/output/dll/pcfx.wbx.gz b/output/dll/pcfx.wbx.gz index e2ad8e43cc..f87798743d 100644 Binary files a/output/dll/pcfx.wbx.gz and b/output/dll/pcfx.wbx.gz differ diff --git a/output/dll/picodrive.wbx.gz b/output/dll/picodrive.wbx.gz index 370fb7c196..eb0812d532 100644 Binary files a/output/dll/picodrive.wbx.gz and b/output/dll/picodrive.wbx.gz differ diff --git a/output/dll/sameboy.wbx.gz b/output/dll/sameboy.wbx.gz index ab490d3f7c..f3d17ea03b 100644 Binary files a/output/dll/sameboy.wbx.gz and b/output/dll/sameboy.wbx.gz differ diff --git a/output/dll/snes9x.wbx.gz b/output/dll/snes9x.wbx.gz index 9a59367c7c..16f02a97ac 100644 Binary files a/output/dll/snes9x.wbx.gz and b/output/dll/snes9x.wbx.gz differ diff --git a/output/dll/ss.wbx.gz b/output/dll/ss.wbx.gz index 17afdf50e7..2950f08b9c 100644 Binary files a/output/dll/ss.wbx.gz and b/output/dll/ss.wbx.gz differ diff --git a/output/dll/turbo.wbx.gz b/output/dll/turbo.wbx.gz index 31ca93022e..9b30c3ff1a 100644 Binary files a/output/dll/turbo.wbx.gz and b/output/dll/turbo.wbx.gz differ diff --git a/output/dll/uzem.wbx.gz b/output/dll/uzem.wbx.gz index 806d67ae9a..73412ef1b0 100644 Binary files a/output/dll/uzem.wbx.gz and b/output/dll/uzem.wbx.gz differ diff --git a/output/dll/vb.wbx.gz b/output/dll/vb.wbx.gz index af0846810b..4ea66d1d5e 100644 Binary files a/output/dll/vb.wbx.gz and b/output/dll/vb.wbx.gz differ diff --git a/output/dll/waterboxhost.dll b/output/dll/waterboxhost.dll index 7e58ad2053..00a7e32113 100644 Binary files a/output/dll/waterboxhost.dll and b/output/dll/waterboxhost.dll differ diff --git a/src/BizHawk.BizInvoke/CallingConventionAdapter.cs b/src/BizHawk.BizInvoke/CallingConventionAdapter.cs index 13278cd8f2..cea5bbca0b 100644 --- a/src/BizHawk.BizInvoke/CallingConventionAdapter.cs +++ b/src/BizHawk.BizInvoke/CallingConventionAdapter.cs @@ -83,8 +83,10 @@ namespace BizHawk.BizInvoke static CallingConventionAdapters() { Waterbox = OSTailoredCode.IsUnixHost - ? (ICallingConventionAdapter)new SysVHostMsGuest() - : new NativeConvention(); + ? new NativeConvention() + : (ICallingConventionAdapter)new MsHostSysVGuest(); + // ? (ICallingConventionAdapter)new SysVHostMsGuest() + // : new NativeConvention(); } /// @@ -277,5 +279,190 @@ namespace BizHawk.BizInvoke } } + private class MsHostSysVGuest : ICallingConventionAdapter + { + private const ulong Placeholder = 0xdeadbeeffeedface; + private const byte Padding = 0x06; + private const int BlockSize = 256; + private static readonly byte[][] Arrive = + { + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x48, 0x83, 0xec, 0x28, 0xff, 0xd0, 0x48, 0x83, 0xc4, 0x28, 0xc3, 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0x83, 0xec, 0x28, 0x48, 0x89, 0xf9, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0xff, 0xd0, 0x48, 0x83, 0xc4, 0x28, 0xc3, 0x0f, 0x1f, 0x40, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0x83, 0xec, 0x28, 0x48, 0x89, 0xf9, 0x48, 0x89, 0xf2, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0xff, 0xd0, 0x48, 0x83, 0xc4, 0x28, 0xc3, 0x90, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0x83, 0xec, 0x28, 0x49, 0x89, 0xd0, 0x48, 0x89, 0xf9, 0x48, 0x89, 0xf2, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0xff, 0xd0, 0x48, 0x83, 0xc4, 0x28, 0xc3, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x1f, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0x83, 0xec, 0x28, 0x49, 0x89, 0xd0, 0x49, 0x89, 0xc9, 0x48, 0x89, 0xf2, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x48, 0x89, 0xf9, 0xff, 0xd0, 0x48, 0x83, 0xc4, 0x28, 0xc3, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0x83, 0xec, 0x10, 0x49, 0x89, 0xc9, 0x48, 0x89, 0xf9, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x41, 0x50, 0x49, 0x89, 0xd0, 0x48, 0x89, 0xf2, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd0, 0x48, 0x83, 0xc4, 0x38, 0xc3, 0x0f, 0x1f, 0x44, 0x00, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x48, 0x83, 0xec, 0x08, 0x41, 0x51, 0x49, 0x89, 0xc9, 0x48, 0x89, 0xf9, 0x41, 0x50, 0x49, 0x89, 0xd0, 0x48, 0x89, 0xf2, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd0, 0x48, 0x83, 0xc4, 0x38, 0xc3, 0x0f, 0x1f, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x48, 0x83, 0xec, 0x10, 0xff, 0x74, 0x24, 0x18, 0x41, 0x51, 0x49, 0x89, 0xc9, 0x48, 0x89, 0xf9, 0x41, 0x50, 0x49, 0x89, 0xd0, 0x48, 0x89, 0xf2, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd0, 0x48, 0x83, 0xc4, 0x48, 0xc3, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x1f, 0x40, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x48, 0x83, 0xec, 0x08, 0xff, 0x74, 0x24, 0x18, 0xff, 0x74, 0x24, 0x18, 0x41, 0x51, 0x49, 0x89, 0xc9, 0x48, 0x89, 0xf9, 0x41, 0x50, 0x49, 0x89, 0xd0, 0x48, 0x89, 0xf2, 0x48, 0x83, 0xec, 0x20, 0xff, 0xd0, 0x48, 0x83, 0xc4, 0x48, 0xc3, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, }, + }; + private static readonly byte[][] Depart = + { + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x57, 0x56, 0x48, 0x81, 0xec, 0xa8, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x34, 0x24, 0x0f, 0x29, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x29, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x29, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x29, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x29, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x29, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x29, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x0f, 0x28, 0x34, 0x24, 0x0f, 0x28, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x28, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x28, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x28, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x28, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x28, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xa8, 0x00, 0x00, 0x00, 0x5e, 0x5f, 0xc3, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x1f, 0x40, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x57, 0x48, 0x89, 0xcf, 0x56, 0x48, 0x81, 0xec, 0xa8, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x34, 0x24, 0x0f, 0x29, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x29, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x29, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x29, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x29, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x29, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x29, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x0f, 0x28, 0x34, 0x24, 0x0f, 0x28, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x28, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x28, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x28, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x28, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x28, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xa8, 0x00, 0x00, 0x00, 0x5e, 0x5f, 0xc3, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x57, 0x48, 0x89, 0xcf, 0x56, 0x48, 0x89, 0xd6, 0x48, 0x81, 0xec, 0xa8, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x34, 0x24, 0x0f, 0x29, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x29, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x29, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x29, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x29, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x29, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x29, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x0f, 0x28, 0x34, 0x24, 0x0f, 0x28, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x28, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x28, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x28, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x28, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x28, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xa8, 0x00, 0x00, 0x00, 0x5e, 0x5f, 0xc3, 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x57, 0x48, 0x89, 0xcf, 0x56, 0x48, 0x89, 0xd6, 0x4c, 0x89, 0xc2, 0x48, 0x81, 0xec, 0xa8, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x34, 0x24, 0x0f, 0x29, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x29, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x29, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x29, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x29, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x29, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x29, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x0f, 0x28, 0x34, 0x24, 0x0f, 0x28, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x28, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x28, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x28, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x28, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x28, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xa8, 0x00, 0x00, 0x00, 0x5e, 0x5f, 0xc3, 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x57, 0x48, 0x89, 0xcf, 0x4c, 0x89, 0xc9, 0x56, 0x48, 0x89, 0xd6, 0x4c, 0x89, 0xc2, 0x48, 0x81, 0xec, 0xa8, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x34, 0x24, 0x0f, 0x29, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x29, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x29, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x29, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x29, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x29, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x29, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x0f, 0x28, 0x34, 0x24, 0x0f, 0x28, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x28, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x28, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x28, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x28, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x28, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xa8, 0x00, 0x00, 0x00, 0x5e, 0x5f, 0xc3, 0x0f, 0x1f, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x57, 0x48, 0x89, 0xcf, 0x4c, 0x89, 0xc9, 0x56, 0x48, 0x89, 0xd6, 0x4c, 0x89, 0xc2, 0x48, 0x81, 0xec, 0xa8, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x34, 0x24, 0x4c, 0x8b, 0x84, 0x24, 0xe0, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x29, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x29, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x29, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x29, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x29, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x29, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x0f, 0x28, 0x34, 0x24, 0x0f, 0x28, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x28, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x28, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x28, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x28, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x28, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xa8, 0x00, 0x00, 0x00, 0x5e, 0x5f, 0xc3, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0x57, 0x48, 0x89, 0xcf, 0x4c, 0x89, 0xc9, 0x56, 0x48, 0x89, 0xd6, 0x4c, 0x89, 0xc2, 0x48, 0x81, 0xec, 0xa8, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x34, 0x24, 0x4c, 0x8b, 0x8c, 0x24, 0xe8, 0x00, 0x00, 0x00, 0x4c, 0x8b, 0x84, 0x24, 0xe0, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x29, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x29, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x29, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x29, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x29, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x29, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0xff, 0xd0, 0x0f, 0x28, 0x34, 0x24, 0x0f, 0x28, 0x7c, 0x24, 0x10, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x20, 0x44, 0x0f, 0x28, 0x4c, 0x24, 0x30, 0x44, 0x0f, 0x28, 0x54, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x5c, 0x24, 0x50, 0x44, 0x0f, 0x28, 0x64, 0x24, 0x60, 0x44, 0x0f, 0x28, 0x6c, 0x24, 0x70, 0x44, 0x0f, 0x28, 0xb4, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbc, 0x24, 0x90, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xa8, 0x00, 0x00, 0x00, 0x5e, 0x5f, 0xc3, 0x0f, 0x1f, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x57, 0x48, 0x89, 0xcf, 0x4c, 0x89, 0xc9, 0x56, 0x48, 0x89, 0xd6, 0x4c, 0x89, 0xc2, 0x48, 0x81, 0xec, 0xb8, 0x00, 0x00, 0x00, 0x48, 0x8b, 0x84, 0x24, 0x00, 0x01, 0x00, 0x00, 0x0f, 0x29, 0x74, 0x24, 0x10, 0x4c, 0x8b, 0x8c, 0x24, 0xf8, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x7c, 0x24, 0x20, 0x4c, 0x8b, 0x84, 0x24, 0xf0, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x30, 0x44, 0x0f, 0x29, 0x4c, 0x24, 0x40, 0x44, 0x0f, 0x29, 0x54, 0x24, 0x50, 0x44, 0x0f, 0x29, 0x5c, 0x24, 0x60, 0x44, 0x0f, 0x29, 0x64, 0x24, 0x70, 0x44, 0x0f, 0x29, 0xac, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xb4, 0x24, 0x90, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbc, 0x24, 0xa0, 0x00, 0x00, 0x00, 0x48, 0x89, 0x04, 0x24, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0xff, 0xd0, 0x0f, 0x28, 0x74, 0x24, 0x10, 0x0f, 0x28, 0x7c, 0x24, 0x20, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x30, 0x44, 0x0f, 0x28, 0x4c, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x54, 0x24, 0x50, 0x44, 0x0f, 0x28, 0x5c, 0x24, 0x60, 0x44, 0x0f, 0x28, 0xac, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0x64, 0x24, 0x70, 0x44, 0x0f, 0x28, 0xb4, 0x24, 0x90, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbc, 0x24, 0xa0, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xb8, 0x00, 0x00, 0x00, 0x5e, 0x5f, 0xc3, 0x66, 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x1f, 0x40, 0x00, }, + new byte[] { 0xf3, 0x0f, 0x1e, 0xfa, 0x57, 0x48, 0x89, 0xcf, 0x4c, 0x89, 0xc9, 0x56, 0x48, 0x89, 0xd6, 0x4c, 0x89, 0xc2, 0x48, 0x81, 0xec, 0xb8, 0x00, 0x00, 0x00, 0x48, 0x8b, 0x84, 0x24, 0x08, 0x01, 0x00, 0x00, 0x0f, 0x29, 0x74, 0x24, 0x10, 0x4c, 0x8b, 0x8c, 0x24, 0xf8, 0x00, 0x00, 0x00, 0x0f, 0x29, 0x7c, 0x24, 0x20, 0x4c, 0x8b, 0x84, 0x24, 0xf0, 0x00, 0x00, 0x00, 0x48, 0x89, 0x44, 0x24, 0x08, 0x48, 0x8b, 0x84, 0x24, 0x00, 0x01, 0x00, 0x00, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x30, 0x44, 0x0f, 0x29, 0x4c, 0x24, 0x40, 0x44, 0x0f, 0x29, 0x54, 0x24, 0x50, 0x44, 0x0f, 0x29, 0x5c, 0x24, 0x60, 0x44, 0x0f, 0x29, 0x64, 0x24, 0x70, 0x44, 0x0f, 0x29, 0xac, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xb4, 0x24, 0x90, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x29, 0xbc, 0x24, 0xa0, 0x00, 0x00, 0x00, 0x48, 0x89, 0x04, 0x24, 0x48, 0xb8, 0xce, 0xfa, 0xed, 0xfe, 0xef, 0xbe, 0xad, 0xde, 0xff, 0xd0, 0x0f, 0x28, 0x74, 0x24, 0x10, 0x0f, 0x28, 0x7c, 0x24, 0x20, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x30, 0x44, 0x0f, 0x28, 0x4c, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x54, 0x24, 0x50, 0x44, 0x0f, 0x28, 0x5c, 0x24, 0x60, 0x44, 0x0f, 0x28, 0xac, 0x24, 0x80, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0x64, 0x24, 0x70, 0x44, 0x0f, 0x28, 0xb4, 0x24, 0x90, 0x00, 0x00, 0x00, 0x44, 0x0f, 0x28, 0xbc, 0x24, 0xa0, 0x00, 0x00, 0x00, 0x48, 0x81, 0xc4, 0xb8, 0x00, 0x00, 0x00, 0x5e, 0x5f, 0xc3, 0x66, 0x90, }, + }; + private static readonly int[] DepartPlaceholderIndices; + private static readonly int[] ArrivePlaceholderIndices; + + private static int FindPlaceholderIndex(byte[] data) + { + return Enumerable.Range(0, data.Length - 7) + .Single(i => BitConverter.ToUInt64(data, i) == Placeholder); + } + + static MsHostSysVGuest() + { + DepartPlaceholderIndices = Depart.Select(FindPlaceholderIndex).ToArray(); + ArrivePlaceholderIndices = Arrive.Select(FindPlaceholderIndex).ToArray(); + if (Depart.Any(b => b.Length > BlockSize) || Arrive.Any(b => b.Length > BlockSize)) + throw new InvalidOperationException(); + } + + private readonly MemoryBlock _memory; + private readonly object _sync = new object(); + private readonly WeakReference[] _refs; + + public MsHostSysVGuest() + { + int size = 4 * 1024 * 1024; + _memory = MemoryBlock.Create(0x36a00000000, (ulong)size); + _memory.Activate(); + _refs = new WeakReference[size / BlockSize]; + } + + private int FindFreeIndex() + { + for (int i = 0; i < _refs.Length; i++) + { + if (_refs[i] == null || !_refs[i].IsAlive) + return i; + } + throw new InvalidOperationException("Out of Thunk memory"); + } + + private int FindUsedIndex(object lifetime) + { + for (int i = 0; i < _refs.Length; i++) + { + if (_refs[i]?.Target == lifetime) + return i; + } + return -1; + } + + private static void VerifyParameter(Type type) + { + if (type == typeof(float) || type == typeof(double)) + throw new NotSupportedException("floating point not supported"); + if (type == typeof(void) || type.IsPrimitive || type.IsEnum) + return; + if (type.IsPointer || typeof(Delegate).IsAssignableFrom(type)) + return; + if (type.IsByRef || type.IsClass) + return; + throw new NotSupportedException($"Unknown type {type}. Possibly supported?"); + } + + private static int VerifyDelegateSignature(ParameterInfo pp) + { + VerifyParameter(pp.ReturnType); + foreach (var ppp in pp.ParameterTypes) + VerifyParameter(ppp); + var ret = pp.ParameterTypes.Count; + if (ret >= Arrive.Length) + throw new InvalidOperationException("Too many parameters to marshal!"); + return ret; + } + + private void WriteThunk(byte[] data, int placeholderIndex, IntPtr p, int index) + { + _memory.Protect(_memory.Start, _memory.Size, MemoryBlock.Protection.RW); + var ss = _memory.GetStream(_memory.Start + (ulong)index * BlockSize, BlockSize, true); + ss.Write(data, 0, data.Length); + for (int i = data.Length; i < BlockSize; i++) + ss.WriteByte(Padding); + ss.Position = placeholderIndex; + var bw = new BinaryWriter(ss); + bw.Write((long)p); + _memory.Protect(_memory.Start, _memory.Size, MemoryBlock.Protection.RX); + } + + private IntPtr GetThunkAddress(int index) + { + return Z.US(_memory.Start + (ulong)index * BlockSize); + } + + private void SetLifetime(int index, object lifetime) + { + if (_refs[index] == null) + _refs[index] = new WeakReference(lifetime); + else + _refs[index].Target = lifetime; + } + + public IntPtr GetFunctionPointerForDelegate(Delegate d) + { + // for this call only, the expectation is that it can be called multiple times + // on the same delegate and not leak extra memory, so the result has to be cached + lock (_sync) + { + var index = FindUsedIndex(d); + if (index != -1) + { + return GetThunkAddress(index); + } + else + { + return GetArrivalFunctionPointer( + Marshal.GetFunctionPointerForDelegate(d), new ParameterInfo(d.GetType()), d); + } + } + } + + public IntPtr GetArrivalFunctionPointer(IntPtr p, ParameterInfo pp, object lifetime) + { + lock (_sync) + { + var index = FindFreeIndex(); + var count = VerifyDelegateSignature(pp); + WriteThunk(Arrive[count], ArrivePlaceholderIndices[count], p, index); + SetLifetime(index, lifetime); + return GetThunkAddress(index); + } + } + + public Delegate GetDelegateForFunctionPointer(IntPtr p, Type delegateType) + { + lock (_sync) + { + var index = FindFreeIndex(); + var count = VerifyDelegateSignature(new ParameterInfo(delegateType)); + WriteThunk(Depart[count], DepartPlaceholderIndices[count], p, index); + var ret = Marshal.GetDelegateForFunctionPointer(GetThunkAddress(index), delegateType); + SetLifetime(index, ret); + return ret; + } + } + + public IntPtr GetDepartureFunctionPointer(IntPtr p, ParameterInfo pp, object lifetime) + { + lock (_sync) + { + var index = FindFreeIndex(); + var count = VerifyDelegateSignature(pp); + WriteThunk(Depart[count], DepartPlaceholderIndices[count], p, index); + SetLifetime(index, lifetime); + return GetThunkAddress(index); + } + } + + } } } diff --git a/waterbox/common.mak b/waterbox/common.mak index a2ed75e7f1..d872fe637f 100644 --- a/waterbox/common.mak +++ b/waterbox/common.mak @@ -23,7 +23,7 @@ print-%: ; #LD_PLUGIN := $(shell gcc --print-file-name=liblto_plugin.so) CC := $(SYSROOT)/bin/musl-gcc -COMMONFLAGS := -mabi=ms -fvisibility=hidden -I$(WATERBOX_DIR)/emulibc -Wall -mcmodel=large \ +COMMONFLAGS := -fvisibility=hidden -I$(WATERBOX_DIR)/emulibc -Wall -mcmodel=large \ -mstack-protector-guard=global -no-pie -fno-pic -fno-pie -fcf-protection=none \ -MD -MP CCFLAGS := $(CCFLAGS) $(COMMONFLAGS) @@ -103,9 +103,12 @@ install-debug: $(TARGET_DEBUG) else +# add fake rules that match the WBX_TARGETS case to ease use of all-cores.mak + .DEFAULT_GOAL = all -.PHONY: all +.PHONY: all release debug install install-debug +release debug install install-debug: all all: $(OBJS) $(DOBJS) diff --git a/waterbox/emulibc/waterboxcore.h b/waterbox/emulibc/waterboxcore.h index 47cd5ef31c..0fa3b84708 100644 --- a/waterbox/emulibc/waterboxcore.h +++ b/waterbox/emulibc/waterboxcore.h @@ -1,5 +1,6 @@ #pragma once #include +#include #ifdef __cplusplus extern "C" { diff --git a/waterbox/libco/amd64.c b/waterbox/libco/amd64.c index 235d04145b..3ce3945404 100644 --- a/waterbox/libco/amd64.c +++ b/waterbox/libco/amd64.c @@ -18,7 +18,15 @@ typedef struct { // used by coswap.s, has to be at the beginning of the struct - uint64_t jmp_buf[32]; + struct { + uint64_t rsp; + uint64_t rbp; + uint64_t rbx; + uint64_t r12; + uint64_t r13; + uint64_t r14; + uint64_t r15; + } jmp_buf; // points to the lowest address in the stack // NB: because of guard space, this is not valid stack void* stack; @@ -97,7 +105,7 @@ cothread_t co_create(unsigned int sz, void (*entrypoint)(void)) uint64_t* p = (uint64_t*)((char*)co->stack + co->stack_size); // seek to top of stack *--p = (uint64_t)crash; // crash if entrypoint returns *--p = (uint64_t)entrypoint; // start of function - co->jmp_buf[0] = (uint64_t)p; // stack pointer + co->jmp_buf.rsp = (uint64_t)p; // stack pointer } return co; diff --git a/waterbox/libco/coswap.s b/waterbox/libco/coswap.s index 56362e8b85..2681840f65 100644 --- a/waterbox/libco/coswap.s +++ b/waterbox/libco/coswap.s @@ -3,49 +3,19 @@ section .text align 16 co_swap: - mov [rdx],rsp - mov rsp,[rcx] + mov [rsi],rsp + mov rsp,[rdi] pop rax - mov [rdx+ 8],rbp - mov [rdx+16],rsi - mov [rdx+24],rdi - mov [rdx+32],rbx - mov [rdx+40],r12 - mov [rdx+48],r13 - mov [rdx+56],r14 - mov [rdx+64],r15 -;#if !defined(LIBCO_NO_SSE) - movaps [rdx+ 80],xmm6 - movaps [rdx+ 96],xmm7 - movaps [rdx+112],xmm8 - add rdx,112 - movaps [rdx+ 16],xmm9 - movaps [rdx+ 32],xmm10 - movaps [rdx+ 48],xmm11 - movaps [rdx+ 64],xmm12 - movaps [rdx+ 80],xmm13 - movaps [rdx+ 96],xmm14 - movaps [rdx+112],xmm15 -;#endif - mov rbp,[rcx+ 8] - mov rsi,[rcx+16] - mov rdi,[rcx+24] - mov rbx,[rcx+32] - mov r12,[rcx+40] - mov r13,[rcx+48] - mov r14,[rcx+56] - mov r15,[rcx+64] -;#if !defined(LIBCO_NO_SSE) - movaps xmm6, [rcx+ 80] - movaps xmm7, [rcx+ 96] - movaps xmm8, [rcx+112] - add rcx,112 - movaps xmm9, [rcx+ 16] - movaps xmm10,[rcx+ 32] - movaps xmm11,[rcx+ 48] - movaps xmm12,[rcx+ 64] - movaps xmm13,[rcx+ 80] - movaps xmm14,[rcx+ 96] - movaps xmm15,[rcx+112] -;#endif + mov [rsi+ 8],rbp + mov [rsi+16],rbx + mov [rsi+24],r12 + mov [rsi+32],r13 + mov [rsi+40],r14 + mov [rsi+48],r15 + mov rbp,[rdi+ 8] + mov rbx,[rdi+16] + mov r12,[rdi+24] + mov r13,[rdi+32] + mov r14,[rdi+40] + mov r15,[rdi+48] jmp rax diff --git a/waterbox/libcxx/configure-for-waterbox-phase-- b/waterbox/libcxx/configure-for-waterbox-phase-- index d9217d2169..4c494a389d 100644 --- a/waterbox/libcxx/configure-for-waterbox-phase-- +++ b/waterbox/libcxx/configure-for-waterbox-phase-- @@ -10,8 +10,8 @@ sed -i -e '13c\' -e '' "$SYSROOT/lib/musl-gcc.specs" rm -rf build- mkdir build- cd build- -export CFLAGS="-mabi=ms -mcmodel=large -mstack-protector-guard=global -no-pie -fno-pic -fno-pie" -export CXXFLAGS="-mabi=ms -mcmodel=large -mstack-protector-guard=global -no-pie -fno-pic -fno-pie" +export CFLAGS="-mcmodel=large -mstack-protector-guard=global -no-pie -fno-pic -fno-pie" +export CXXFLAGS="-mcmodel=large -mstack-protector-guard=global -no-pie -fno-pic -fno-pie" cmake \ -DCMAKE_C_COMPILER="$SYSROOT/bin/musl-gcc" \ -DCMAKE_CXX_COMPILER="$SYSROOT/bin/musl-gcc" \ diff --git a/waterbox/libcxx/configure-for-waterbox-phase-0 b/waterbox/libcxx/configure-for-waterbox-phase-0 index 12b23ea1e9..8bed32f2f4 100644 --- a/waterbox/libcxx/configure-for-waterbox-phase-0 +++ b/waterbox/libcxx/configure-for-waterbox-phase-0 @@ -5,8 +5,8 @@ LLVMDIR="`realpath \"$MYPATH/../llvm-project\"`" rm -rf build0 mkdir build0 cd build0 -export CFLAGS="-mabi=ms -mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie -D_WIN64 -D_LIBUNWIND_IS_BAREMETAL -D_LIBUNWIND_SUPPORT_DWARF_UNWIND" -export CXXFLAGS="-mabi=ms -mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie -D_WIN64 -D_LIBUNWIND_IS_BAREMETAL -D_LIBUNWIND_SUPPORT_DWARF_UNWIND" +export CFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie -D_LIBUNWIND_IS_BAREMETAL -D_LIBUNWIND_SUPPORT_DWARF_UNWIND" +export CXXFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie -D_LIBUNWIND_IS_BAREMETAL -D_LIBUNWIND_SUPPORT_DWARF_UNWIND" cmake \ -DCMAKE_C_COMPILER="$SYSROOT/bin/musl-gcc" \ -DCMAKE_CXX_COMPILER="$SYSROOT/bin/musl-gcc" \ diff --git a/waterbox/libcxx/configure-for-waterbox-phase-1 b/waterbox/libcxx/configure-for-waterbox-phase-1 index 16f903abef..c708937828 100644 --- a/waterbox/libcxx/configure-for-waterbox-phase-1 +++ b/waterbox/libcxx/configure-for-waterbox-phase-1 @@ -5,8 +5,8 @@ LLVMDIR="`realpath \"$MYPATH/../llvm-project\"`" rm -rf build1 mkdir build1 cd build1 -export CFLAGS="-mabi=ms -mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie" -export CXXFLAGS="-mabi=ms -mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie" +export CFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie" +export CXXFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie" cmake \ -DCMAKE_C_COMPILER="$SYSROOT/bin/musl-gcc" \ -DCMAKE_CXX_COMPILER="$SYSROOT/bin/musl-gcc" \ diff --git a/waterbox/libcxx/configure-for-waterbox-phase-2 b/waterbox/libcxx/configure-for-waterbox-phase-2 index 5fafb9d626..402e2e5a42 100644 --- a/waterbox/libcxx/configure-for-waterbox-phase-2 +++ b/waterbox/libcxx/configure-for-waterbox-phase-2 @@ -10,8 +10,8 @@ cp -n "/usr/include/linux/version.h" "$SYSROOT/include/linux" rm -rf build2 mkdir build2 cd build2 -export CFLAGS="-mabi=ms -mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie" -export CXXFLAGS="-mabi=ms -mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie" +export CFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie" +export CXXFLAGS="-mcmodel=large -mstack-protector-guard=global -fno-use-cxa-atexit -no-pie -fno-pic -fno-pie" cmake \ -DCMAKE_C_COMPILER="$SYSROOT/bin/musl-gcc" \ -DCMAKE_CXX_COMPILER="$SYSROOT/bin/musl-gcc" \ diff --git a/waterbox/make-all-cores.sh b/waterbox/make-all-cores.sh new file mode 100644 index 0000000000..ce18fd31ac --- /dev/null +++ b/waterbox/make-all-cores.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +cd emulibc && make -f Makefile $1 -j && cd - +cd libco && make -f Makefile $1 -j && cd - +cd gpgx && make -f Makefile $1 -j && cd - +cd libsnes && make -f Makefile $1 -j && cd - +cd picodrive && make -f Makefile $1 -j && cd - +cd sameboy && make -f Makefile $1 -j && cd - +cd snes9x && make -f Makefile $1 -j && cd - +cd uzem && make -f Makefile $1 -j && cd - +cd vb && make -f Makefile $1 -j && cd - +cd nyma && make -f faust.mak $1 -j && cd - +cd nyma && make -f hyper.mak $1 -j && cd - +#cd nyma && make -f lynx.mak $1 -j && cd - +cd nyma && make -f ngp.mak $1 -j && cd - +cd nyma && make -f pcfx.mak $1 -j && cd - +cd nyma && make -f ss.mak $1 -j && cd - +cd nyma && make -f turbo.mak $1 -j && cd - +#cd nyma && make -f vb.mak $1 -j && cd - +#cd nyma && make -f wswan.mak $1 -j && cd - diff --git a/waterbox/musl b/waterbox/musl index fc0fd09fa3..0aad5d7233 160000 --- a/waterbox/musl +++ b/waterbox/musl @@ -1 +1 @@ -Subproject commit fc0fd09fa3aad2b9a30d5825caab0259304c5a45 +Subproject commit 0aad5d72332a52b2ebd659b56a98fd117aed8d8f diff --git a/waterbox/nyma/zlib/configure-for-waterbox b/waterbox/nyma/zlib/configure-for-waterbox index 81443a1359..8af1bf1a7f 100644 --- a/waterbox/nyma/zlib/configure-for-waterbox +++ b/waterbox/nyma/zlib/configure-for-waterbox @@ -2,5 +2,5 @@ MYPATH="`dirname \"$0\"`" SYSROOT="`realpath \"$MYPATH/../../sysroot\"`" export CC=$SYSROOT/bin/musl-gcc -export CFLAGS="-O3 -mabi=ms -mcmodel=large -mstack-protector-guard=global -no-pie -fno-pic -fno-pie" +export CFLAGS="-O3 -mcmodel=large -mstack-protector-guard=global -no-pie -fno-pic -fno-pie" ./configure --static --prefix=$SYSROOT diff --git a/waterbox/waterboxhost/src/elf.rs b/waterbox/waterboxhost/src/elf.rs index 8c2889770f..19b5780b59 100644 --- a/waterbox/waterboxhost/src/elf.rs +++ b/waterbox/waterboxhost/src/elf.rs @@ -195,7 +195,7 @@ impl ElfLoader { pub fn native_init(&mut self, _b: &mut ActivatedMemoryBlock) { println!("Calling _start()"); unsafe { - std::mem::transmute:: ()>(self.entry_point)(); + std::mem::transmute:: ()>(self.entry_point)(); } } fn run_proc(&mut self, _b: &mut ActivatedMemoryBlock, name: &str) { @@ -204,7 +204,7 @@ impl ElfLoader { ptr => { println!("Calling {}()", name); unsafe { - std::mem::transmute:: ()>(ptr)(); + std::mem::transmute:: ()>(ptr)(); } }, } diff --git a/waterbox/waterboxhost/src/host.rs b/waterbox/waterboxhost/src/host.rs index 890c1fd5c1..f4bd8631f3 100644 --- a/waterbox/waterboxhost/src/host.rs +++ b/waterbox/waterboxhost/src/host.rs @@ -203,7 +203,7 @@ fn arg_to_statbuff<'a>(arg: usize) -> &'a mut KStat { unsafe { &mut *(arg as *mut KStat) } } -pub extern "win64" fn syscall(nr: SyscallNumber, ud: usize, a1: usize, a2: usize, a3: usize, a4: usize, _a5: usize, _a6: usize) -> SyscallReturn { +pub extern "sysv64" fn syscall(nr: SyscallNumber, ud: usize, a1: usize, a2: usize, a3: usize, a4: usize, _a5: usize, _a6: usize) -> SyscallReturn { let h = gethost(ud); match nr { NR_MMAP => { diff --git a/waterbox/waterboxhost/src/lib.rs b/waterbox/waterboxhost/src/lib.rs index b57922a768..ca23c9dae6 100644 --- a/waterbox/waterboxhost/src/lib.rs +++ b/waterbox/waterboxhost/src/lib.rs @@ -105,7 +105,7 @@ impl WbxSysLayout { #[derive(Copy, Clone)] pub struct WbxSysSyscall { pub ud: usize, - pub syscall: extern "win64" fn(nr: SyscallNumber, ud: usize, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize, a6: usize) -> SyscallReturn, + pub syscall: extern "sysv64" fn(nr: SyscallNumber, ud: usize, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize, a6: usize) -> SyscallReturn, } /// Data that is injected into the guest application