-
Notifications
You must be signed in to change notification settings - Fork 1
/
helper.h
65 lines (59 loc) · 1.26 KB
/
helper.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
#pragma once
#define _GNU_SOURCE
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "modules/helper.h"
static int fd;
int timer_read_count_hash(size_t uaddr, size_t timer_id)
{
msg_t msg = {
.timer_rd = {
.timer_id = timer_id,
.uaddr = uaddr,
}
};
return ioctl(fd, TIMER_READ_CNT_HASH, (unsigned long)&msg);
}
int timer_read_index_hash(size_t uaddr, size_t timer_id)
{
msg_t msg = {
.timer_rd = {
.timer_id = timer_id,
.uaddr = uaddr,
}
};
return ioctl(fd, TIMER_READ_INDEX_HASH, (unsigned long)&msg);
}
int key_read_index(size_t uaddr, size_t key_id)
{
msg_t msg = {
.key_rd = {
.key_id = key_id,
.uaddr = uaddr,
}
};
return ioctl(fd, KEY_READ_CNT, (unsigned long)&msg);
}
int futex_read_count(size_t uaddr, size_t futex_addr)
{
msg_t msg = {
.futex_rd = {
.futex_addr = futex_addr,
.uaddr = uaddr,
}
};
return ioctl(fd, FUTEX_READ_CNT, (unsigned long)&msg);
}
void helper_init(void)
{
fd = open("/dev/helper", O_RDWR);
if (fd < 0) {
perror("open: ");
exit(-1);
}
}