rework memhandlers to deal with some bus details
[pcsx_rearmed.git] / frontend / vita / sys / mman.h
CommitLineData
f901d0cd 1#ifndef MMAN_H
2#define MMAN_H
3
fa5898eb 4#include <stdlib.h>
5#include <stdio.h>
6#include <psp2/kernel/sysmem.h>
7
f901d0cd 8#ifdef __cplusplus
9extern "C" {
10#endif
11
f901d0cd 12#define PROT_READ 0b001
13#define PROT_WRITE 0b010
14#define PROT_EXEC 0b100
15#define MAP_PRIVATE 2
16#define MAP_ANONYMOUS 0x20
17
18#define MAP_FAILED ((void *)-1)
19
20static inline void* mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
21{
f901d0cd 22 (void)prot;
23 (void)flags;
24 (void)fd;
25 (void)offset;
26
1a5fd794 27 int block, ret;
28
29 block = sceKernelAllocMemBlockForVM("code", len);
30 if(block<=0){
31 sceClibPrintf("could not alloc mem block @0x%08X 0x%08X \n", block, len);
32 exit(1);
33 }
34
35 // get base address
36 ret = sceKernelGetMemBlockBase(block, &addr);
37 if (ret < 0)
38 {
39 sceClibPrintf("could get address @0x%08X 0x%08X \n", block, addr);
40 exit(1);
41 }
42
f901d0cd 43
1a5fd794 44 if(!addr)
f901d0cd 45 return MAP_FAILED;
46
1a5fd794 47 return addr;
f901d0cd 48}
49
50static inline int mprotect(void *addr, size_t len, int prot)
51{
52 (void)addr;
53 (void)len;
54 (void)prot;
55 return 0;
56}
57
58static inline int munmap(void *addr, size_t len)
59{
1a5fd794 60 int uid = sceKernelFindMemBlockByAddr(addr, len);
61
62 return sceKernelFreeMemBlock(uid);
f901d0cd 63
64}
65
66#ifdef __cplusplus
67};
68#endif
69
70#endif // MMAN_H