11 static void *code
= NULL
;
12 static void *data
= NULL
;
13 static void *RAM
= NULL
;
15 static size_t code_len
= 0;
16 static size_t RAM_len
= 0;
19 * Allocate memory for kickstart's .code and .rodata. We allocate is as writable
20 * because we will load the kickstart into it. We will enable execution later in SetRO().
21 * We have to use mmap() and not posix_memalign() here because posix_memalign()
22 * does not pad the allocated memory up to next page boundary. As a result, setting
23 * it read-only will affect the whole page, but the page will still have some unallocated
24 * space which can be reused by malloc().
25 * This causes DisplayError() function to crash on iOS. This also may cause similar effects
28 void *AllocateRO(size_t len
)
30 /* There's no sense to set MAP_SHARED for ROM */
31 void *ret
= mmap(NULL
, len
, PROT_READ
|PROT_WRITE
, MAP_ANON
|MAP_PRIVATE
|MAP_32BIT
, -1, 0);
33 if (ret
== MAP_FAILED
)
44 * Disable write and enable execution.
45 * We actually have to do this in two steps because some systems
46 * (Apple iOS) do not allow read-write-execute permissions.
48 int SetRO(void *addr
, size_t len
)
50 return mprotect(addr
, len
, PROT_READ
|PROT_EXEC
);
54 * Allocate kickstart's .data and .bss. Nothing is executed from there, so we
55 * don't have to take some special care about it. Simple malloc() is enough here.
57 void *AllocateRW(size_t len
)
64 * This routine allocates memory usable as AROS ram. This means it
65 * needs to have full permissions.
66 * Yes, iOS will silently mask out PROT_EXEC here. This is bad.
67 * Well, iOS will be a little bit special story in InternalLoadSeg()...
69 void *AllocateRAM(size_t len
)
71 void *ret
= mmap(NULL
, len
, PROT_READ
|PROT_WRITE
|PROT_EXEC
, MAP_ANON
|MAP_SHARED
|MAP_32BIT
, -1, 0);
73 if (ret
== MAP_FAILED
)
83 void Host_FreeMem(void)
85 munmap(code
, code_len
);