Ejemplo n.º 1
0
void _free_vita_heap(void) {
	
	// Destroy the sbrk mutex
	sceKernelDeleteLwMutex((struct SceKernelLwMutexWork*)_newlib_sbrk_mutex);

	// Free the heap memblock to avoid memory leakage.
	sceKernelFreeMemBlock(_newlib_heap_memblock);
  
	if(_newlib_vm_memblock)
  	sceKernelFreeMemBlock(_newlib_vm_memblock);

	_newlib_vm_memblock = 0;
	_newlib_heap_memblock = 0;
	_newlib_heap_base = 0;
	_newlib_heap_cur = 0;
}
Ejemplo n.º 2
0
void fragment_usse_free(SceUID uid)
{
	void *mem = NULL;
	if (sceKernelGetMemBlockBase(uid, &mem) < 0)
		return;
	sceGxmUnmapFragmentUsseMemory(mem);
	sceKernelFreeMemBlock(uid);
}
Ejemplo n.º 3
0
void vertex_usse_free(SceUID uid)
{
	void *mem = NULL;
	if (sceKernelGetMemBlockBase(uid, &mem) < 0)
		return;
	sceGxmUnmapVertexUsseMemory(mem);
	sceKernelFreeMemBlock(uid);
}
Ejemplo n.º 4
0
void gpu_free(SceUID uid)
{
	void *mem = NULL;
	if (sceKernelGetMemBlockBase(uid, &mem) < 0)
		return;
	sceGxmUnmapMemory(mem);
	sceKernelFreeMemBlock(uid);
}
Ejemplo n.º 5
0
code_pool::~code_pool()
{
   #ifdef _3DS
   //ReprotectMemory((unsigned int*)instructions, (instruction_count * 4) / 4096, 3);
   #elif defined(__vita__)
   sceKernelFreeMemBlock(block);
   #else
   mprotect(instructions, instruction_count * 4, PROT_READ | PROT_WRITE);
   free(instructions);
   #endif
}
Ejemplo n.º 6
0
/********************************************//**
 *  \brief Loads a executable at path
 *  
 *  Starts a new thread with the homebrew 
 *  loaded. Waits until the homebrew exits and 
 *  returns.
 *  \returns Thread ID on success, otherwise error
 ***********************************************/
int 
uvl_load (const char *path)
{
    char data_blob[LOADED_INFO_SIZE];
    uvl_loaded_t *loaded;
    int (*start)(int, void *);
    int ret_value;
    PsvUID tid;
    int i;

    loaded = (uvl_loaded_t *)data_blob;
    IF_DEBUG LOG ("Loading homebrew");
    if (uvl_load_exe (path, (void**)&start, loaded) < 0)
    {
        LOG ("Cannot load homebrew.");
        return -1;
    }
    IF_DEBUG LOG ("Starting homebrew: entry at 0x%08X", start);
    tid = sceKernelCreateThread ("homebrew", start, 0, 0x00040000, 0, 0x00070000, NULL);
    if (tid < 0)
    {
        LOG ("Cannot create thread.");
        return -1;
    }
    loaded->tid = tid;
    IF_DEBUG LOG ("Starting new thread.");
    if (sceKernelStartThread (tid, 0, NULL) < 0)
    {
        LOG ("Cannot start thread.");
        return -1;
    }
    IF_DEBUG LOG ("Homebrew running...");
    if (sceKernelWaitThreadEnd (tid, &ret_value, NULL) < 0)
    {
        LOG ("Failed to wait for thread to exit.");
    }
    IF_DEBUG LOG ("Homebrew exited with value 0x%08X", ret_value);

    // free segments
    for (i = 0; i < loaded->numsegs; i++)
    {
        sceKernelFreeMemBlock (loaded->segs[i]);
    }
    
    return 0;
}
Ejemplo n.º 7
0
/********************************************//**
 *  \brief Frees data pointer created by load
 *  
 *  \returns Zero on success, otherwise error
 ***********************************************/
static inline int
uvl_free_data (void *data)      ///< Data allocated by @c uvl_load_file
{
    PsvUID block;

    block = sceKernelFindMemBlockByAddr (data, 0);
    if (block < 0)
    {
        LOG ("Cannot find block id: 0x%08X", block);
    }
    if (sceKernelFreeMemBlock (block) < 0)
    {
        LOG ("Cannot free block: 0x%08X", block);
        return -1;
    }
    return 0;
}
Ejemplo n.º 8
0
 void co_delete(cothread_t handle)
 {
    free(handle);
    sceKernelFreeMemBlock(block);
 }