summaryrefslogtreecommitdiff
path: root/libddekit/include/ddekit/pgtab.h
blob: 8964b713fb457999fb993c9116c1036b3fdeead7 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * \brief   Virtual page-table facility
 * \author  Thomas Friebel <tf13@os.inf.tu-dresden.de>
 * \author  Christian Helmuth <ch12@os.inf.tu-dresden.de>
 * \date    2006-11-03
 */

#ifndef _ddekit_pgtab_h
#define _ddekit_pgtab_h

#include "ddekit/types.h"

/* FIXME Region types may be defined by pgtab users. Do we really need them
 * here? */
enum ddekit_pgtab_type
{
	PTE_TYPE_OTHER, PTE_TYPE_LARGE, PTE_TYPE_UMA, PTE_TYPE_CONTIG
};


/**
 * Set virtual->physical mapping for VM region
 *
 * \param virt      virtual start address for region
 * \param phys      physical start address for region
 * \param pages     number of pages in region
 * \param type      pgtab type for region
 */
void ddekit_pgtab_set_region(void *virt, ddekit_addr_t phys, int pages, int type);


/**
 * Set virtual->physical mapping for VM region given a specific size in bytes.
 *
 * Internally, DDEKit manages regions with pages. However, DDEs do not need to tangle
 * with the underlying mechanism and therefore can use this function that takes care
 * of translating a size to an amount of pages.
 */
void ddekit_pgtab_set_region_with_size(void *virt, ddekit_addr_t phys, int size, int type);


/**
 * Clear virtual->physical mapping for VM region
 *
 * \param virt      virtual start address for region
 * \param type      pgtab type for region
 */
void ddekit_pgtab_clear_region(void *virt, int type);

/**
 * Get physical address for virtual address
 *
 * \param virt     virtual address
 *
 * \return physical address
 */
ddekit_addr_t ddekit_pgtab_get_physaddr(const void *virt);

/**
 * Get virtual address for physical address
 *
 * \param physical  physical address
 *
 * \return virtual address
 */
ddekit_addr_t ddekit_pgtab_get_virtaddr(const ddekit_addr_t physical);

/**
 * Get type of VM region.
 *
 * \param virt      virtual address

 * \return VM region type
 */
int ddekit_pgtab_get_type(const void *virt);

/**
 * Get size of VM region.
 *
 * \param virt      virtual address
 *
 * \return VM region size (in bytes)
 */
int ddekit_pgtab_get_size(const void *virt);

#endif