#include <pico/pico_int.h>
#include "cmn.h"
-u8 ALIGNED(4096) tcache[DRC_TCACHE_SIZE];
-
+u8 ALIGNED(4096) tcache_default[DRC_TCACHE_SIZE];
+u8 *tcache;
void drc_cmn_init(void)
{
- int ret = plat_mem_set_exec(tcache, sizeof(tcache));
+ int ret;
+
+ tcache = plat_mem_get_for_drc(DRC_TCACHE_SIZE);
+ if (tcache == NULL)
+ tcache = tcache_default;
+
+ ret = plat_mem_set_exec(tcache, DRC_TCACHE_SIZE);
elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d",
- tcache, sizeof(tcache), ret);
+ tcache, DRC_TCACHE_SIZE, ret);
#ifdef __arm__
if (PicoOpt & POPT_EN_DRC)
extern void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed);\r
extern void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);\r
extern void plat_munmap(void *ptr, size_t size);\r
+\r
+// memory for the dynarec; plat_mem_get_for_drc() can just return NULL\r
+extern void *plat_mem_get_for_drc(size_t size);\r
extern int plat_mem_set_exec(void *ptr, size_t size);\r
\r
// this one should handle display mode changes\r
{
#ifdef __arm__
size_t len = (char *)end - (char *)start;
+ (void)len;
#if defined(__BLACKBERRY_QNX__)
msync(start, end - start, MS_SYNC | MS_CACHE_ONLY | MS_INVALIDATE_ICACHE);
#elif defined(__MACH__)
}
#endif
+// if NULL is returned, static buffer is used
+void *plat_mem_get_for_drc(size_t size)
+{
+ void *mem = NULL;
+#ifdef VITA
+ sceKernelGetMemBlockBase(sceBlock, &mem);
+#endif
+ return mem;
+}
+
int plat_mem_set_exec(void *ptr, size_t size)
{
+ int ret = -1;
#ifdef _WIN32
- int ret = VirtualProtect(ptr,size,PAGE_EXECUTE_READWRITE,0);
+ ret = VirtualProtect(ptr, size, PAGE_EXECUTE_READWRITE, 0);
if (ret == 0 && log_cb)
- log_cb(RETRO_LOG_ERROR, "mprotect(%p, %zd) failed: %d\n", ptr, size, 0);
+ log_cb(RETRO_LOG_ERROR, "VirtualProtect(%p, %d) failed: %d\n", ptr, (int)size,
+ GetLastError());
#elif defined(_3DS)
- int ret = -1;
if (ctr_svchack_successful)
{
unsigned int currentHandle;
}
#elif defined(VITA)
- int ret = sceKernelOpenVMDomain();
+ ret = sceKernelOpenVMDomain();
#else
- int ret = mprotect(ptr, size, PROT_READ | PROT_WRITE | PROT_EXEC);
+ ret = mprotect(ptr, size, PROT_READ | PROT_WRITE | PROT_EXEC);
if (ret != 0 && log_cb)
log_cb(RETRO_LOG_ERROR, "mprotect(%p, %zd) failed: %d\n", ptr, size, errno);
#endif
vout_buf = NULL;
PicoExit();
}
+
+// vim:shiftwidth=3:ts=3:expandtab