aboutgitcodelistschat:MatrixIRC
path: root/cooker/gluten.h
blob: 46595839fcd0f52db8fa8c3140abc848b6c88a30 (plain) (blame)
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
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright 2023 Red Hat GmbH
 * Author: Stefano Brivio <sbrivio@redhat.com>
 */

#ifndef GLUTEN_H
#define GLUTEN_H

#define COOKER
#include <gluten.h>

enum scmp_mode {
	SCMP_FILTER,
	SCMP_PROFILE,
};

struct gluten_arg_data {
	struct gluten_offset offset;
	size_t len;
};

struct gluten_tag_data {
	const char *name;
	struct gluten_offset offset;
	size_t len;
};

struct gluten_ctx {
	struct gluten_offset ip;
	struct gluten_offset lr;
	struct gluten_offset mr;
	struct gluten_offset cp;
	struct gluten_offset dp;

	struct gluten g;

	struct gluten_arg_data match_dst[CALL_ARGS];
	struct gluten_arg_data call_src[CALL_ARGS];

	struct gluten_tag_data tags[TAGS_MAX];

	struct attr attrs[ATTRS_MAX];

	struct arg *selected_arg[6];

	enum scmp_mode mode;
};

/**
 * enum jump_type - Indicate direction of jump before linking phase
 */
enum jump_type {
	JUMP_NEXT_BLOCK,
	JUMP_NEXT_MATCH,
	JUMP_NEXT_ACTION,
	JUMP_END,
	JUMP_COUNT,
};

struct gluten_offset gluten_rw_alloc(struct gluten_ctx *g, size_t size);
struct gluten_offset gluten_rw_alloc_type(struct gluten_ctx *g, enum type type);
struct gluten_offset gluten_ro_alloc(struct gluten_ctx *g, size_t size);
struct gluten_offset gluten_ro_alloc_type(struct gluten_ctx *g, enum type type);
void gluten_add_tag(struct gluten_ctx *g, const char *name,
		    struct gluten_offset offset);
void gluten_add_tag_post(struct gluten_ctx *g, const char *name,
			 struct gluten_offset offset);
struct gluten_offset gluten_get_tag(struct gluten_ctx *g, const char *name);
void gluten_add_attr(struct gluten_ctx *g, enum attr_type type, intptr_t id,
		     union value v);
union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type,
			    intptr_t id);
void gluten_init(struct gluten_ctx *g);
void gluten_block_init(struct gluten_ctx *g);
void gluten_write(struct gluten_ctx *g, const char *path);

extern size_t gluten_size[TYPE_COUNT];
extern const char *jump_name[JUMP_COUNT];

#endif /* GLUTEN_H */