2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
8 #include <aros/config.h>
10 #include <kernel_base.h>
11 #include <kernel_mm.h>
13 /*****************************************************************************
16 #include <proto/kernel.h>
18 AROS_LH3(void *, KrnAllocPages
,
21 AROS_LHA(void *, addr
, A0
),
22 AROS_LHA(uintptr_t, length
, D0
),
23 AROS_LHA(uint32_t, flags
, D1
),
26 struct KernelBase
*, KernelBase
, 27, Kernel
)
29 Allocate physical memory pages
32 addr - Starting address of region which must be included in the
33 allocated region or NULL for the system to choose the
34 starting address. Normally you will supply NULL here.
35 length - Length of the memory region to allocate
36 flags - Flags describing type of needed memory. These are the same
37 flags as passed to exec.library/AllocMem().
40 Real starting address of the allocated region.
43 Since this allocator is page-based, length will always be round up
44 to system's memory page size. The same applies to starting address
45 (if specified), it will be rounded down to page boundary.
47 This function works only on systems with MMU support. Without MMU
48 it will always return NULL.
59 ******************************************************************************/
65 KRN_MapAttr protection
;
67 /* We can't work if MMU is not up */
68 if (!KernelBase
->kb_PageSize
)
72 protection
= MAP_Readable
|MAP_Writable
;
73 if (flags
& MEMF_EXECUTABLE
)
74 protection
|= MAP_Executable
;
76 res
= mm_AllocPages(addr
, length
, flags
, KernelBase
);
79 * The pages we've just allocated have no access rights at all.
80 * Now we need to set requested access rights.
83 KrnSetProtection(res
, length
, protection
);