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