12 #define PROT_READ 0b001
13 #define PROT_WRITE 0b010
14 #define PROT_EXEC 0b100
16 #define MAP_FIXED 0x10
17 #define MAP_ANONYMOUS 0x20
19 #define MAP_FAILED ((void *)-1)
21 #define ALIGNMENT 0x1000
23 static inline void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
28 // match Linux behavior
29 len = (len + ALIGNMENT - 1) & ~(ALIGNMENT - 1);
31 Result rc = svcMapPhysicalMemory(addr, len);
34 //printf("mmap failed\n");
35 addr = aligned_alloc(ALIGNMENT, len);
43 static inline int munmap(void *addr, size_t len)
45 len = (len + ALIGNMENT - 1) & ~(ALIGNMENT - 1);
46 Result rc = svcUnmapPhysicalMemory(addr, len);
49 //printf("munmap failed\n");