summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-02-24 16:01:13 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-03-01 09:30:57 +0100
commitff612b866f301686fc490d076a138eaa65d79d4e (patch)
tree691f2fcbfabec8f9c11e66ec8f38bad0832fc333 /include
parent1eddb0d3821d7bb368fa6b092b980b89fc47db28 (diff)
downloadbarebox-ff612b866f301686fc490d076a138eaa65d79d4e.tar.gz
barebox-ff612b866f301686fc490d076a138eaa65d79d4e.tar.xz
ratp: implement generic command support
The RATP implementation now allows executing generic commands with a binary interface: binary requests are received and binary responses are returned. Each command can define its own RATP request contents (e.g. to specify command-specific options) as well as its own RATP response contents (if any data is to be returned). Each command is associated with a pair of numeric unique request and response IDs, and for easy reference these IDs are maintained in the common ratp_bb header. Modules may override generic implemented commands or include their own new ones (as long as the numeric IDs introduced are unique). Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/barebox.lds.h2
-rw-r--r--include/ratp_bb.h47
2 files changed, 49 insertions, 0 deletions
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index c8a919b928..74d3ca4a96 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -44,6 +44,8 @@
#define BAREBOX_CMDS KEEP(*(SORT_BY_NAME(.barebox_cmd*)))
+#define BAREBOX_RATP_CMDS KEEP(*(SORT_BY_NAME(.barebox_ratp_cmd*)))
+
#define BAREBOX_SYMS KEEP(*(__usymtab))
#define BAREBOX_MAGICVARS KEEP(*(SORT_BY_NAME(.barebox_magicvar*)))
diff --git a/include/ratp_bb.h b/include/ratp_bb.h
index f485f7d8ac..75aabed55e 100644
--- a/include/ratp_bb.h
+++ b/include/ratp_bb.h
@@ -1,6 +1,24 @@
#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[];
@@ -11,4 +29,33 @@ 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 */