summaryrefslogtreecommitdiffstats
path: root/include/ratp_bb.h
blob: 75aabed55ee03cbb8b8e4e2d3e85277a4f9b0f9c (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
#ifndef __RATP_BB_H
#define __RATP_BB_H

#include <linux/stringify.h>

#define BB_RATP_TYPE_COMMAND		1
#define BB_RATP_TYPE_COMMAND_RETURN	2
#define BB_RATP_TYPE_CONSOLEMSG		3
#define BB_RATP_TYPE_PING		4
#define BB_RATP_TYPE_PONG		5
#define BB_RATP_TYPE_GETENV		6
#define BB_RATP_TYPE_GETENV_RETURN	7
#define BB_RATP_TYPE_FS			8
#define BB_RATP_TYPE_FS_RETURN		9

struct ratp_bb {
	uint16_t type;
	uint16_t flags;
	uint8_t data[];
};

struct ratp_bb_pkt {
	unsigned int len;
	uint8_t data[];
};

int  barebox_ratp(struct console_device *cdev);
void barebox_ratp_command_run(void);
int  barebox_ratp_fs_call(struct ratp_bb_pkt *tx, struct ratp_bb_pkt **rx);
int  barebox_ratp_fs_mount(const char *path);

/*
 * RATP commands definition
 */

struct ratp_command {
	struct list_head  list;
	uint16_t          request_id;
	uint16_t          response_id;
	int		(*cmd)(const struct ratp_bb *req,
			       int req_len,
			       struct ratp_bb **rsp,
			       int *rsp_len);
}
#ifdef __x86_64__
/* This is required because the linker will put symbols on a 64 bit alignment */
__attribute__((aligned(64)))
#endif
;

#define BAREBOX_RATP_CMD_START(_name)							\
extern const struct ratp_command __barebox_ratp_cmd_##_name;				\
const struct ratp_command __barebox_ratp_cmd_##_name					\
	__attribute__ ((unused,section (".barebox_ratp_cmd_" __stringify(_name)))) = {

#define BAREBOX_RATP_CMD_END								\
};

int register_ratp_command(struct ratp_command *cmd);

#endif /* __RATP_BB_H */