diff options
Diffstat (limited to 'include/ratp_bb.h')
-rw-r--r-- | include/ratp_bb.h | 47 |
1 files changed, 47 insertions, 0 deletions
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 */ |