diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2017-06-21 16:42:38 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-06-29 11:56:08 +0100 |
commit | cb6c52b42559a0730cf6d7ae7ed841e31399496f (patch) | |
tree | 7bda0bf6445062f85d2f511dd28336a261067137 /risu.c | |
parent | 471b24f6d36610a143ecdcb851b752d62e7572b0 (diff) |
risu: parameterise send/receive functions
This is a precursor to record/playback support. Instead of passing the
socket fd we now pass helper functions for reading/writing and
responding. This will allow us to do the rest of the record/playback
cleanly outside of the main worker function.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 20170621154244.28309-5-alex.bennee@linaro.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: fixed checkpatch nits]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'risu.c')
-rw-r--r-- | risu.c | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -37,9 +37,28 @@ sigjmp_buf jmpbuf; /* Should we test for FP exception status bits? */ int test_fp_exc; +/* Master functions */ + +int read_sock(void *ptr, size_t bytes) +{ + return recv_data_pkt(master_socket, ptr, bytes); +} + +void respond_sock(int r) +{ + send_response_byte(master_socket, r); +} + +/* Apprentice function */ + +int write_sock(void *ptr, size_t bytes) +{ + return send_data_pkt(apprentice_socket, ptr, bytes); +} + void master_sigill(int sig, siginfo_t *si, void *uc) { - switch (recv_and_compare_register_info(master_socket, uc)) { + switch (recv_and_compare_register_info(read_sock, respond_sock, uc)) { case 0: /* match OK */ advance_pc(uc); @@ -52,7 +71,7 @@ void master_sigill(int sig, siginfo_t *si, void *uc) void apprentice_sigill(int sig, siginfo_t *si, void *uc) { - switch (send_register_info(apprentice_socket, uc)) { + switch (send_register_info(write_sock, uc)) { case 0: /* match OK */ advance_pc(uc); |