Rebuild all of waterbox as sysvabi, not msabi

This helps linux at the expense of windows, except it seems like windows gets a nice little speed up as well
This commit is contained in:
nattthebear 2020-07-03 18:21:48 -04:00
parent 35fdec2132
commit 3a18f6356d
30 changed files with 254 additions and 64 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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();
}
/// <summary>
@ -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);
}
}
}
}
}

View File

@ -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)

View File

@ -1,5 +1,6 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {

View File

@ -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;

View File

@ -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

View File

@ -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" \

View File

@ -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" \

View File

@ -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" \

View File

@ -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" \

View File

@ -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 -

@ -1 +1 @@
Subproject commit fc0fd09fa3aad2b9a30d5825caab0259304c5a45
Subproject commit 0aad5d72332a52b2ebd659b56a98fd117aed8d8f

View File

@ -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

View File

@ -195,7 +195,7 @@ impl ElfLoader {
pub fn native_init(&mut self, _b: &mut ActivatedMemoryBlock) {
println!("Calling _start()");
unsafe {
std::mem::transmute::<usize, extern "win64" fn() -> ()>(self.entry_point)();
std::mem::transmute::<usize, extern "sysv64" fn() -> ()>(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::<usize, extern "win64" fn() -> ()>(ptr)();
std::mem::transmute::<usize, extern "sysv64" fn() -> ()>(ptr)();
}
},
}

View File

@ -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 => {

View File

@ -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