diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-02-24 17:02:25 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-02-24 17:02:58 +0000 |
commit | 96d0b66036df61596f6fa5f7a83c6640f8350b23 (patch) | |
tree | 5228a308b68f4f9d15a6b59be3c68c67e983d7e9 /risu_m68k.c | |
parent | 31e34835ebbf98beab46e6d2ae832a1dd6e054de (diff) |
Move recv_and_compare_register_info() and report_match_status() to reginfo.c
Move recv_and_compare_register_info() and report_match_status() to
reginfo.c -- they are essentially the same for all targets so
can be common code. The shared variables they use come with them.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'risu_m68k.c')
-rw-r--r-- | risu_m68k.c | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/risu_m68k.c b/risu_m68k.c index c0e29ff..851487b 100644 --- a/risu_m68k.c +++ b/risu_m68k.c @@ -13,12 +13,6 @@ #include "risu.h" #include "risu_reginfo_m68k.h" -struct reginfo master_ri, apprentice_ri; -static int mem_used = 0; -static int packet_mismatch = 0; - -uint8_t apprentice_memblock[MEMBLOCKLEN]; - void advance_pc(void *vuc) { ucontext_t *uc = (ucontext_t*)vuc; @@ -44,91 +38,3 @@ int get_risuop(struct reginfo *ri) uint32_t risukey = 0x4afc7000; return (key != risukey) ? -1 : op; } - -/* Read register info from the socket and compare it with that from the - * ucontext. Return 0 for match, 1 for end-of-test, 2 for mismatch. - * NB: called from a signal handler. - */ -int recv_and_compare_register_info(int sock, void *uc) -{ - int resp = 0; - int op; - - reginfo_init(&master_ri, uc); - op = get_risuop(&master_ri); - - switch (op) { - case OP_COMPARE: - case OP_TESTEND: - default: - if (recv_data_pkt(sock, &apprentice_ri, sizeof(apprentice_ri))) { - packet_mismatch = 1; - resp = 2; - } else if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { - resp = 2; - } - else if (op == OP_TESTEND) { - resp = 1; - } - send_response_byte(sock, resp); - break; - case OP_SETMEMBLOCK: - memblock = (void *)(uintptr_t)get_reginfo_paramreg(&master_ri); - break; - case OP_GETMEMBLOCK: - set_ucontext_paramreg(uc, get_reginfo_paramreg(&master_ri) + - (uintptr_t)memblock); - break; - case OP_COMPAREMEM: - mem_used = 1; - if (recv_data_pkt(sock, apprentice_memblock, MEMBLOCKLEN)) { - packet_mismatch = 1; - resp = 2; - } else if (memcmp(memblock, apprentice_memblock, MEMBLOCKLEN) != 0) { - resp = 2; - } - send_response_byte(sock, resp); - break; - } - return resp; -} - -/* Print a useful report on the status of the last comparison - * done in recv_and_compare_register_info(). This is called on - * exit, so need not restrict itself to signal-safe functions. - * Should return 0 if it was a good match (ie end of test) - * and 1 for a mismatch. - */ -int report_match_status(void) -{ - int resp = 0; - fprintf(stderr, "match status...\n"); - - if (packet_mismatch) { - fprintf(stderr, "packet mismatch (probably disagreement " - "about UNDEF on load/store)\n"); - fprintf(stderr, "master reginfo:\n"); - reginfo_dump(&master_ri, stderr); - } - if (!reginfo_is_eq(&master_ri, &apprentice_ri)) { - fprintf(stderr, "mismatch on regs!\n"); - resp = 1; - } - if (mem_used && memcmp(memblock, &apprentice_memblock, MEMBLOCKLEN) != 0) { - fprintf(stderr, "mismatch on memory!\n"); - resp = 1; - } - if (!resp) { - fprintf(stderr, "match!\n"); - return 0; - } - - fprintf(stderr, "master reginfo:\n"); - reginfo_dump(&master_ri, stderr); - - fprintf(stderr, "apprentice reginfo:\n"); - reginfo_dump(&apprentice_ri, stderr); - - reginfo_dump_mismatch(&master_ri, &apprentice_ri, stderr); - return resp; -} |