X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2Fvita%2Fsys%2Fmman.h;h=d2634836fdf429b2e527b1a84b73cba83f23be5e;hb=fa5898eb14e4561615423a39dd759e3bb9a1eede;hp=66467f4092290af4fa47374e9f7c053cabc0457f;hpb=b9c86313f1a99cd8193fbf36ccc08295a9639725;p=pcsx_rearmed.git diff --git a/frontend/vita/sys/mman.h b/frontend/vita/sys/mman.h index 66467f40..d2634836 100644 --- a/frontend/vita/sys/mman.h +++ b/frontend/vita/sys/mman.h @@ -1,13 +1,14 @@ #ifndef MMAN_H #define MMAN_H +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include "stdlib.h" -#include "stdio.h" - #define PROT_READ 0b001 #define PROT_WRITE 0b010 #define PROT_EXEC 0b100 @@ -18,19 +19,32 @@ extern "C" { static inline void* mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) { - (void)addr; (void)prot; (void)flags; (void)fd; (void)offset; - void* addr_out; + int block, ret; + + block = sceKernelAllocMemBlockForVM("code", len); + if(block<=0){ + sceClibPrintf("could not alloc mem block @0x%08X 0x%08X \n", block, len); + exit(1); + } + + // get base address + ret = sceKernelGetMemBlockBase(block, &addr); + if (ret < 0) + { + sceClibPrintf("could get address @0x%08X 0x%08X \n", block, addr); + exit(1); + } - addr_out = malloc(len); - if(!addr_out) + + if(!addr) return MAP_FAILED; - return addr_out; + return addr; } static inline int mprotect(void *addr, size_t len, int prot) @@ -43,8 +57,9 @@ static inline int mprotect(void *addr, size_t len, int prot) static inline int munmap(void *addr, size_t len) { - free(addr); - return 0; + int uid = sceKernelFindMemBlockByAddr(addr, len); + + return sceKernelFreeMemBlock(uid); } @@ -53,4 +68,3 @@ static inline int munmap(void *addr, size_t len) #endif #endif // MMAN_H -