summaryrefslogtreecommitdiffstats
path: root/include/zone.h
blob: 002d1fce9674b97e78679cf325cc49675e2cb116 (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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef JOVE_MEM_ZONE_H
#define JOVE_MEM_ZONE_H 1

#include <stdint.h>
#include "klib/buddymap.h"

enum {
    MEM_ZONE_STANDARD = 0, /* First GiB of physical memory. */
    MEM_ZONE_HIGHER,
    MEM_ZONE_COUNT
};

#define MEM_ZONE_STANDARD_BASE 0
#define MEM_ZONE_STANDARD_LIMIT (1 * GiB)
#define MEM_ZONE_HIGHER_BASE MEM_ZONE_STANDARD_LIMIT

#define MEM_BUDDY_ORDERS 12
struct PhysicalMemoryZone
{
    const char *name;

    uintptr_t base;
    uintptr_t limit;

    struct BuddyMap freemap;
};

int pm_zone_for(uintptr_t addr);
uintptr_t pm_zone_bound_lower(size_t zone);
uintptr_t pm_zone_bound_upper(size_t zone);
size_t pm_zone_pages_free(size_t zone);
int pm_zone_resv(size_t zone, uintptr_t base, uintptr_t limit);
int pm_zone_free(size_t zone, uintptr_t base, uintptr_t limit);
uintptr_t pm_zone_alloc(size_t zone, size_t pages);

void pm_zone_setup(void);

#endif