static FunctionPointer functionPointerForTVector(TransitionVector tvp) { #ifdef __ppc__ const uint32 temp[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420}; uint32 *newGlue = NULL; if (tvp != NULL) { newGlue = (uint32 *)malloc(sizeof(temp)); if (newGlue != NULL) { unsigned i; for (i = 0; i < 6; i++) newGlue[i] = temp[i]; newGlue[0] |= ((UInt32)tvp >> 16); newGlue[1] |= ((UInt32)tvp & 0xFFFF); MakeDataExecutable(newGlue, sizeof(temp)); }
void MachineCache::flush_instruction_cache_range(void* s, void* e) { MakeDataExecutable(s, (char*)e - (char*)s); // Could make this more efficient by depending on cache characteristics, // e.g. I-cache line size. Also, should be a nop on machines without // split I/D caches (everything up to SS-2). const fint cacheLineSize = 8; // a guess char* start = (char*) ((int)s & ~(cacheLineSize - 1)); char* end = (char*) roundTo((int)e, cacheLineSize); for ( ; start < end; start += cacheLineSize) { FlushInstruction(start); // FLUSH inst flushes (at least) a doubleword } }
// // This function allocates a block of CFM glue code which contains the instructions to call CFM routines // static void* NewMachOFunctionPointer(void* cfmfp) { #if TARGET_RT_MAC_CFM static UInt32 CFM_glue[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420}; UInt32 *mfp = (UInt32*) NewPtr(sizeof(CFM_glue)); // Must later dispose of allocated memory if (mfp) { BlockMoveData(CFM_glue, mfp, sizeof(CFM_glue)); mfp[0] |= ((UInt32)cfmfp >> 16); mfp[1] |= ((UInt32)cfmfp & 0xFFFF); MakeDataExecutable(mfp, sizeof(CFM_glue)); } return mfp; #elif TARGET_RT_MAC_MACHO return cfmfp; #endif }
static void* TV2FP(CFMutableDictionaryRef dict, const char* name, void *tvp) { static uint32 glue[6] = { 0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420 }; uint32* newGlue = NULL; if (tvp != NULL) { CFStringRef nameRef = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII); if (nameRef) { CFMutableDataRef glueData = (CFMutableDataRef) CFDictionaryGetValue(dict, nameRef); if (glueData == NULL) { glueData = CFDataCreateMutable(NULL, sizeof(glue)); if (glueData != NULL) { newGlue = (uint32*) CFDataGetMutableBytePtr(glueData); memcpy(newGlue, glue, sizeof(glue)); newGlue[0] |= ((UInt32)tvp >> 16); newGlue[1] |= ((UInt32)tvp & 0xFFFF); MakeDataExecutable(newGlue, sizeof(glue)); CFDictionaryAddValue(dict, nameRef, glueData); CFRelease(glueData); PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("TV2FP: created wrapper for CFM function %s().", name)); } } else {
void MachineCache::flush_instruction_cache_range(void* s, void* e) { MakeDataExecutable(s, (char*)e - (char*)s); }
void MachineCache::flush_instruction_cache_word(void* addr) { MakeDataExecutable(addr, sizeof(int32)); }