marged Jagmn's patch

https://emaculation.com/forum/viewtopic.php?p=70121#p70121
This commit is contained in:
kanjitalk755 2021-04-23 10:19:48 +09:00
parent a39eff553c
commit 20d2de95ce
10 changed files with 33 additions and 28 deletions

View File

@ -229,6 +229,13 @@ void *vm_acquire_reserved(size_t size) {
return reserved_buf && size <= RESERVED_SIZE ? reserved_buf : VM_MAP_FAILED; return reserved_buf && size <= RESERVED_SIZE ? reserved_buf : VM_MAP_FAILED;
} }
int vm_init_reserved(void *hostAddress) {
int result = vm_acquire_fixed(hostAddress, RESERVED_SIZE);
if (result >= 0)
reserved_buf = hostAddress;
return result;
}
/* Allocate zero-filled memory of SIZE bytes. The mapping is private /* Allocate zero-filled memory of SIZE bytes. The mapping is private
and default protection bits are read / write. The return value and default protection bits are read / write. The return value
is the actual mapping address chosen or VM_MAP_FAILED for errors. */ is the actual mapping address chosen or VM_MAP_FAILED for errors. */

View File

@ -87,7 +87,7 @@ static int get_dns_addr(struct in_addr *pdns_addr)
static int get_dns_addr(struct in_addr *pdns_addr) static int get_dns_addr(struct in_addr *pdns_addr)
{ {
char buff[512]; char buff[512];
char buff2[256]; char buff2[257];
FILE *f; FILE *f;
int found = 0; int found = 0;
struct in_addr tmp_addr; struct in_addr tmp_addr;

View File

@ -39,10 +39,6 @@
<string>@PACKAGE_VERSION@</string> <string>@PACKAGE_VERSION@</string>
<key>CSResourcesFileMapped</key> <key>CSResourcesFileMapped</key>
<true/> <true/>
<key>LSArchitecturePriority</key>
<array>
<string>x86_64</string>
</array>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>10.7.0</string> <string>10.7.0</string>
<key>NSHighResolutionCapable</key> <key>NSHighResolutionCapable</key>

View File

@ -1210,7 +1210,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.7; MACOSX_DEPLOYMENT_TARGET = 10.7;
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
PRODUCT_NAME = kpx_cpu; PRODUCT_NAME = kpx_cpu;
VALID_ARCHS = x86_64; VALID_ARCHS = "x86_64 arm64";
}; };
name = Debug; name = Debug;
}; };
@ -1249,7 +1249,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.7; MACOSX_DEPLOYMENT_TARGET = 10.7;
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
PRODUCT_NAME = kpx_cpu; PRODUCT_NAME = kpx_cpu;
VALID_ARCHS = x86_64; VALID_ARCHS = "x86_64 arm64";
}; };
name = Release; name = Release;
}; };
@ -1328,15 +1328,11 @@
MACOSX_DEPLOYMENT_TARGET = 10.7; MACOSX_DEPLOYMENT_TARGET = 10.7;
OTHER_CFLAGS = ""; OTHER_CFLAGS = "";
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = ( OTHER_LDFLAGS = "-lkpx_cpu";
"-pagezero_size",
0x3000,
"-lkpx_cpu",
);
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO; PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
PRODUCT_BUNDLE_IDENTIFIER = net.cebix.sheepshaver; PRODUCT_BUNDLE_IDENTIFIER = net.cebix.sheepshaver;
PRODUCT_NAME = SheepShaver; PRODUCT_NAME = SheepShaver;
VALID_ARCHS = x86_64; VALID_ARCHS = "x86_64 arm64";
WARNING_LDFLAGS = ""; WARNING_LDFLAGS = "";
}; };
name = Debug; name = Debug;
@ -1394,15 +1390,11 @@
MACOSX_DEPLOYMENT_TARGET = 10.7; MACOSX_DEPLOYMENT_TARGET = 10.7;
OTHER_CFLAGS = ""; OTHER_CFLAGS = "";
OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)";
OTHER_LDFLAGS = ( OTHER_LDFLAGS = "-lkpx_cpu";
"-pagezero_size",
0x3000,
"-lkpx_cpu",
);
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO; PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;
PRODUCT_BUNDLE_IDENTIFIER = net.cebix.sheepshaver; PRODUCT_BUNDLE_IDENTIFIER = net.cebix.sheepshaver;
PRODUCT_NAME = SheepShaver; PRODUCT_NAME = SheepShaver;
VALID_ARCHS = x86_64; VALID_ARCHS = "x86_64 arm64";
}; };
name = Release; name = Release;
}; };

View File

@ -405,8 +405,8 @@
ordering is the same as for multi-word integers. */ ordering is the same as for multi-word integers. */
/* #undef HOST_FLOAT_WORDS_BIG_ENDIAN */ /* #undef HOST_FLOAT_WORDS_BIG_ENDIAN */
/* Define constant offset for Mac address translation */ /* Define constant offset for Mac address translation: macosx-aarch64 is always 64bit */
/* #undef NATMEM_OFFSET */ #define NATMEM_OFFSET 0x400000000000
/* Define to the address where bug reports for this package should be sent. */ /* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "Christian.Bauer@uni-mainz.de" #define PACKAGE_BUGREPORT "Christian.Bauer@uni-mainz.de"
@ -428,7 +428,7 @@
/* Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this /* Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this
system. */ system. */
#define PAGEZERO_HACK 1 /* #define PAGEZERO_HACK 1 */
/* Define as the return type of signal handlers (`int' or `void'). */ /* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void #define RETSIGTYPE void

View File

@ -1640,13 +1640,13 @@ if [[ "x$EMULATED_PPC" = "xyes" ]]; then
esac esac
fi fi
if [[ "x$have_dyngen_gcc3" = "xyes" ]]; then if [[ "x$have_dyngen_gcc3" = "xyes" ]]; then
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-align-functions" DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-align-functions -fno-stack-protector"
else else
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0" DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
fi fi
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-functions -finline-limit=10000 -fno-exceptions -g0" DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-functions -finline-limit=10000 -fno-exceptions -g0"
if [[ "x$have_dyngen_gcc3" = "xyes" ]]; then if [[ "x$have_dyngen_gcc3" = "xyes" ]]; then
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls" DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls -fno-reorder-blocks-and-partition"
fi fi
if [[ "x$DYNGEN_CC" != "x$CXX" ]]; then if [[ "x$DYNGEN_CC" != "x$CXX" ]]; then
DYNGEN_CFLAGS="-O2 $CFLAGS" DYNGEN_CFLAGS="-O2 $CFLAGS"

View File

@ -2210,6 +2210,7 @@ rti:;
} }
#endif #endif
extern int vm_init_reserved(void *hostAddress);
/* /*
* Helpers to share 32-bit addressable data with MacOS * Helpers to share 32-bit addressable data with MacOS
@ -2221,7 +2222,15 @@ bool SheepMem::Init(void)
page_size = getpagesize(); page_size = getpagesize();
// Allocate SheepShaver globals // Allocate SheepShaver globals
#ifdef NATMEM_OFFSET
if (vm_mac_acquire_fixed(ROM_BASE + ROM_AREA_SIZE + SIG_STACK_SIZE, size) < 0)
return false;
uint8 *adr = Mac2HostAddr(ROM_BASE + ROM_AREA_SIZE + SIG_STACK_SIZE);
if (vm_init_reserved(adr + size) < 0)
return false;
#else
uint8 *adr = vm_mac_acquire(size); uint8 *adr = vm_mac_acquire(size);
#endif
if (adr == VM_MAP_FAILED) if (adr == VM_MAP_FAILED)
return false; return false;
proc = base = Host2MacAddr(adr); proc = base = Host2MacAddr(adr);

View File

@ -85,7 +85,7 @@ static inline void do_invrect(uint8 *dest, uint32 length)
} }
// Align on 32-bit boundaries // Align on 32-bit boundaries
if (bpp < 32 && (((uintptr)dest) & 2)) { if (bpp < 32 && (((uintptr)dest) & 2) && length >= 2) {
INVERT_2(dest, 0); INVERT_2(dest, 0);
dest += 2; length -= 2; dest += 2; length -= 2;
} }
@ -198,7 +198,7 @@ static inline void do_fillrect(uint8 *dest, uint32 color, uint32 length)
} }
// Align on 32-bit boundaries // Align on 32-bit boundaries
if (bpp < 32 && (((uintptr)dest) & 2)) { if (bpp < 32 && (((uintptr)dest) & 2) && length >= 2) {
FILL_2(dest, 0, color); FILL_2(dest, 0, color);
dest += 2; length -= 2; dest += 2; length -= 2;
} }

View File

@ -2396,6 +2396,7 @@ void patch_relocations(FILE *outfile, const char *name, host_ulong size, host_ul
fprintf(outfile, " *(uint32_t *)(code_ptr() + %d) = (int32_t)%s + %d;\n", slide, final_sym_name, addend); fprintf(outfile, " *(uint32_t *)(code_ptr() + %d) = (int32_t)%s + %d;\n", slide, final_sym_name, addend);
break; break;
case R_X86_64_PC32: case R_X86_64_PC32:
case R_X86_64_PLT32:
fprintf(outfile, " *(uint32_t *)(code_ptr() + %d) = %s - (long)(code_ptr() + %d) + %d;\n", fprintf(outfile, " *(uint32_t *)(code_ptr() + %d) = %s - (long)(code_ptr() + %d) + %d;\n",
slide, final_sym_name, slide, addend); slide, final_sym_name, slide, addend);
break; break;

View File

@ -205,13 +205,13 @@ const uintptr VMBaseDiff = NATMEM_OFFSET;
#if REAL_ADDRESSING || DIRECT_ADDRESSING #if REAL_ADDRESSING || DIRECT_ADDRESSING
static inline uint8 * vm_do_get_real_address(vm_addr_t addr) static inline uint8 * vm_do_get_real_address(vm_addr_t addr)
{ {
uintptr a = vm_wrap_address(VMBaseDiff + addr); uintptr a = vm_wrap_address(addr);
#if defined(__APPLE__) && defined(__x86_64__) #if defined(__APPLE__) && defined(__x86_64__)
extern uint8 gZeroPage[0x3000], gKernelData[0x2000]; extern uint8 gZeroPage[0x3000], gKernelData[0x2000];
if (a < 0x3000) return &gZeroPage[a]; if (a < 0x3000) return &gZeroPage[a];
else if ((a & ~0x1fff) == 0x68ffe000 || (a & ~0x1fff) == 0x5fffe000) return &gKernelData[a & 0x1fff]; else if ((a & ~0x1fff) == 0x68ffe000 || (a & ~0x1fff) == 0x5fffe000) return &gKernelData[a & 0x1fff];
#endif #endif
return (uint8 *)a; return (uint8 *)(VMBaseDiff + a);
} }
static inline vm_addr_t vm_do_get_virtual_address(uint8 *addr) static inline vm_addr_t vm_do_get_virtual_address(uint8 *addr)
{ {