-
Notifications
You must be signed in to change notification settings - Fork 12
/
lib_dax.h
executable file
·85 lines (65 loc) · 1.71 KB
/
lib_dax.h
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
#ifndef LIB_DAX_H
#define LIB_DAX_H
#include <pthread.h>
#include <inttypes.h>
#define MAP_SIZE (uint64_t)0x1000<<29
// #define RAM_VER
extern int dax_fd;
#define DAX_MPK_DEFAULT 0
#define DAX_MPK_META 1
#define DAX_MPK_FILE 2
// #define RAM_VER
enum dax_ioctl_types{
DAX_IOCTL_INIT = 16,
DAX_IOCTL_READY,
DAX_IOCTL_RESET,
DAX_IOCTL_PSWAP,
DAX_IOCTL_PREFAULT,
DAX_IOCTL_COW,
DAX_IOCTL_COPYTEST,
};
struct dax_ioctl_pswap {
void* ufirst;
void* usecond;
uint64_t npgs;
uint64_t flag;
};
typedef struct dax_ioctl_pswap dax_ioctl_pswap_t;
struct dax_ioctl_init {
// to kernel: virtual memory size
uint64_t size;
// from kernel: physical space total
uint64_t space_total;
// from kernel: physical space remaining
uint64_t space_remain;
// from kernel: protection tag for metadata
uint8_t mpk_meta;
// from kernel: protection tag for file data
uint8_t mpk_file;
// from kernel: protection tag for default
uint8_t mpk_default;
};
typedef struct dax_ioctl_init dax_ioctl_init_t;
struct dax_ioctl_prefault {
void* addr;
uint64_t n_pmd;
};
typedef struct dax_ioctl_prefault dax_ioctl_prefault_t;
struct dax_cow_frame {
uint64_t src;
uint64_t dest;
uint64_t size;
};
typedef struct dax_cow_frame dax_cow_frame_t;
long dax_reset(const char * path, uint64_t dax_size);
long dax_pswap(dax_ioctl_pswap_t *frame);
long dax_prefault(dax_ioctl_prefault_t * frame);
long dax_init(dax_ioctl_init_t* frame);
long dax_ready();
void* dax_start(const char * path, dax_ioctl_init_t* frame);
void dax_end();
void dax_test_cpy(void * buf);
void dax_stop_access(int key);
void dax_stop_write(int key);
void dax_grant_access(int key);
#endif