-
Notifications
You must be signed in to change notification settings - Fork 31
/
context.h
81 lines (63 loc) · 1.75 KB
/
context.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
#ifndef CONTEXT_H
#define CONTEXT_H
#include "types.h"
#include "env.h"
#ifndef __user
#define __user
#endif
typedef struct {
byte had_exception;
word value;
word func;
word pc;
} exception_t;
typedef struct {
byte word_size : 5;
byte nonblock : 1;
byte l_endian : 1;
byte is_global : 1;
byte version_major;
byte version_minor;
byte error;
word len1;
word len2;
union {
byte __user *uptr1;
byte *ptr1;
word val1;
};
union {
byte __user *uptr2;
byte *ptr2;
word val2;
};
exception_t excep;
} kplugs_command_t;
#define KPLUGS_REPLY define_io(0, kplugs_command_t)
#define KPLUGS_LOAD define_io(1, kplugs_command_t)
#define KPLUGS_EXECUTE define_io(2, kplugs_command_t)
#define KPLUGS_EXECUTE_ANONYMOUS define_io(3, kplugs_command_t)
#define KPLUGS_UNLOAD define_io(4, kplugs_command_t)
#define KPLUGS_UNLOAD_ANONYMOUS define_io(5, kplugs_command_t)
#define KPLUGS_SEND_DATA define_io(6, kplugs_command_t)
#define KPLUGS_SEND_DATA_ANONYMOUS define_io(7, kplugs_command_t)
#define KPLUGS_RECV_DATA define_io(8, kplugs_command_t)
#define KPLUGS_RECV_DATA_ANONYMOUS define_io(9, kplugs_command_t)
typedef struct {
list_head_t funcs;
list_head_t anonym;
spinlock_t lock;
} context_t;
/* create a new context */
int context_create(context_t **cont);
/* delete a context */
void context_free(context_t *cont);
/* lock a context */
unsigned long context_lock(context_t *cont);
/* unlock a context */
void context_unlock(context_t *cont, unsigned long flags);
/* find a function by name */
void *context_find_function(context_t *cont, byte *name);
/* find an anonymous function by address */
void *context_find_anonymous(context_t *cont, byte *ptr);
#endif