summaryrefslogtreecommitdiff
path: root/mem/vmap.h
blob: 7f8b8bb5b8d30317e15470de78e5ac0497d70830 (plain)
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
#ifndef MEM_VMAP_H
#define MEM_VMAP_H

#include <rt.h>

typedef struct mem_vmap MemVmap;

typedef usize (*MemVmapTranslate)(MemVmap *, usize);
typedef int (*MemVmapMap)(MemVmap *, usize, usize, usize, int);
typedef void (*MemVmapUnmap)(MemVmap *, usize, usize);
typedef void (*MemVmapSwitchTo)(MemVmap *);

/* Structure abstracting the memory mapping facilities of
   the machine */
struct mem_vmap {
	MemVmapTranslate translate;
	MemVmapMap map;
	MemVmapUnmap unmap;
	MemVmapSwitchTo switch_to;

	/* Flag indicating whether the previous translation
	   lead to a miss */
	int miss;
};

usize mem_vmap_translate(MemVmap *inner, usize virt);
int mem_vmap_map(MemVmap *inner, usize phys, usize virt, usize len, int flags);
void mem_vmap_unmap(MemVmap *inner, usize virt, usize len);
void mem_vmap_switch_to(MemVmap *inner);

#endif