summaryrefslogtreecommitdiffstats
path: root/lib/libjove/memory.c
blob: db76528ad9926c750a9c6363e043220c1102f94d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <jove/memory.h>

JoveError 
jove_mem_ensure_w(uintptr_t start, size_t pages)
{
    start &= ~0xFFFULL;
    for(size_t i = 0; i < pages; i++) {
        uintptr_t at = start + (i << 12);
        JoveError e = jove_mem_ensure(at);
        if(e) return e;
    }
    return EJOVE_OK;
}

JoveError
jove_mem_ensure_range(uintptr_t start, uintptr_t end)
{
    start &= ~0xFFFULL;
    if(end & 0xFFF)
        end += 0x1000 - (end & 0xFFF);

    return jove_mem_ensure_w(start, (end - start) >> 12);
}