diff options
author | Alex Auvolat <alex@adnab.me> | 2015-03-11 11:51:01 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2015-03-11 11:51:01 +0100 |
commit | bde334e6393b142d9953328e9ea2881ce88a1a7b (patch) | |
tree | f3ed7bbc6c8a534fccbd2cf653e7ecb1f24b9fd4 /src/lib/include/gip.h | |
parent | aa5e2760711c092e1235105ebf097ac594512370 (diff) | |
download | kogata-bde334e6393b142d9953328e9ea2881ce88a1a7b.tar.gz kogata-bde334e6393b142d9953328e9ea2881ce88a1a7b.zip |
Begin work on GIP (Graphics Initiation Protocol)
Diffstat (limited to 'src/lib/include/gip.h')
-rw-r--r-- | src/lib/include/gip.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/lib/include/gip.h b/src/lib/include/gip.h new file mode 100644 index 0000000..98b4655 --- /dev/null +++ b/src/lib/include/gip.h @@ -0,0 +1,55 @@ +#pragma once + +// Not thread safe + +#include <hashtbl.h> + +#include <proto/gip.h> +#include <mainloop.h> + +typedef struct gip_handler gip_handler_t; + +typedef void (*noarg_gip_callback_t)(gip_handler_t *s, gip_msg_header *m); +typedef void (*gip_reply_callback_t)(gip_handler_t *s, gip_msg_header *m, void* data); + +typedef struct { + noarg_gip_callback_t + reset, initiate, ok, failure, + enable_features, disable_features, + query_mode, set_mode, switch_buffer; + void (*buffer_info)(gip_handler_t *s, gip_msg_header *m, gip_buffer_info_msg *i); + void (*mode_info)(gip_handler_t *s, gip_msg_header *m, gip_mode_info_msg *i); + void (*buffer_damage)(gip_handler_t *s, gip_msg_header *m, gip_buffer_damage_msg *i); + void (*unknown_msg)(gip_handler_t *s, gip_msg_header *m); + void (*fd_error)(gip_handler_t *s); +} gip_handler_callbacks_t; + +typedef struct gip_handler { + gip_handler_callbacks_t* cb; + void* data; + + gip_msg_header msg_buf; + gip_buffer_info_msg buffer_info_msg_buf; + gip_mode_info_msg mode_info_msg_buf; + gip_buffer_damage_msg buffer_damage_msg_buf; + + hashtbl_t *requests_in_progress; + uint32_t next_req_id; + + mainloop_fd_t mainloop_item; +} gip_handler_t; + +gip_handler_t *new_gip_handler(gip_handler_callbacks_t *cb, void* data); +void delete_gip_handler(gip_handler_t *h); + +// GIP send messages + +bool gip_cmd(gip_handler_t *h, gip_msg_header *msg, void* msg_data, gip_reply_callback_t cb, void* cb_data); + +bool gip_reply(gip_handler_t *h, gip_msg_header *orig_request, gip_msg_header *msg, void* msg_data); +bool gip_reply_fail(gip_handler_t *h, gip_msg_header *o); +bool gip_reply_ok(gip_handler_t *h, gip_msg_header *o); + +bool gip_notify(gip_handler_t *h, gip_msg_header *msg, void* msg_data); + +/* vim: set ts=4 sw=4 tw=0 noet :*/ |