aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2016-03-29 16:48:07 -0400
committerPaul Selkirk <paul@psgd.org>2016-03-29 16:48:07 -0400
commit438b50688ca6e4acd641ab568adb66f18fdd362e (patch)
tree03bc9b3e6c9786546de31134247a46dad5c5aa40
parent14465a488fafbfb4837bad5652508784c8941f38 (diff)
Enable 'mixed' mode, with client-side hashing.
-rw-r--r--hash.c18
-rw-r--r--rpc_client.c2
2 files changed, 19 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index a371f48..daa7e3a 100644
--- a/hash.c
+++ b/hash.c
@@ -48,6 +48,10 @@
* for use when the Verilog cores aren't available.
*/
+#if RPC_CLIENT == RPC_CLIENT_MIXED
+#define HAL_ENABLE_SOFTWARE_HASH_CORES 1
+#endif
+
#ifndef HAL_ENABLE_SOFTWARE_HASH_CORES
#define HAL_ENABLE_SOFTWARE_HASH_CORES 0
#endif
@@ -355,7 +359,11 @@ static inline hal_error_t check_core(const hal_core_t **core,
{
assert(descriptor != NULL && descriptor->driver != NULL);
+#if RPC_CLIENT == RPC_CLIENT_MIXED
+ hal_error_t err = HAL_ERROR_CORE_NOT_FOUND;
+#else
hal_error_t err = hal_core_check_name(core, descriptor->core_name);
+#endif
#if HAL_ENABLE_SOFTWARE_HASH_CORES
@@ -430,6 +438,8 @@ void hal_hash_cleanup(hal_hash_state_t **state_)
*state_ = NULL;
}
+#if RPC_CLIENT != RPC_CLIENT_MIXED
+
/*
* Read hash result from core. At least for now, this also serves to
* read current hash state from core.
@@ -469,6 +479,8 @@ static hal_error_t hash_write_digest(const hal_core_t *core,
return hal_io_write(core, driver->digest_addr, digest, digest_length);
}
+#endif
+
/*
* Send one block to a core.
*/
@@ -487,6 +499,9 @@ static hal_error_t hash_write_block(hal_hash_state_t * const state)
if (debug)
fprintf(stderr, "[ %s ]\n", state->block_count == 0 ? "init" : "next");
+#if RPC_CLIENT == RPC_CLIENT_MIXED
+ return state->driver->sw_core(state);
+#else
if (HAL_ENABLE_SOFTWARE_HASH_CORES && (state->flags & STATE_FLAG_SOFTWARE_CORE) != 0)
return state->driver->sw_core(state);
@@ -516,6 +531,7 @@ static hal_error_t hash_write_block(hal_hash_state_t * const state)
return err;
return hal_io_wait_valid(state->core);
+#endif
}
/*
@@ -648,7 +664,9 @@ hal_error_t hal_hash_finalize(hal_hash_state_t *state, /* Opaqu
/* All data pushed to core, now we just need to read back the result */
if (HAL_ENABLE_SOFTWARE_HASH_CORES && (state->flags & STATE_FLAG_SOFTWARE_CORE) != 0)
swytebop(digest_buffer, state->core_state, state->descriptor->digest_length, state->driver->sw_word_size);
+#if RPC_CLIENT != RPC_CLIENT_MIXED
else if ((err = hash_read_digest(state->core, state->driver, digest_buffer, state->descriptor->digest_length)) != HAL_OK)
+#endif
return err;
return HAL_OK;
diff --git a/rpc_client.c b/rpc_client.c
index 5903895..ae7e7e2 100644
--- a/rpc_client.c
+++ b/rpc_client.c
@@ -782,7 +782,7 @@ const hal_rpc_hash_dispatch_t * hal_rpc_hash_dispatch = &hal_rpc_remote_hash_dis
const hal_rpc_pkey_dispatch_t * hal_rpc_pkey_dispatch = &hal_rpc_remote_pkey_dispatch;
#elif RPC_CLIENT == RPC_CLIENT_MIXED
const hal_rpc_misc_dispatch_t * hal_rpc_misc_dispatch = &hal_rpc_remote_misc_dispatch;
-const hal_rpc_hash_dispatch_t * hal_rpc_hash_dispatch = &hal_rpc_remote_hash_dispatch; //mixed?
+const hal_rpc_hash_dispatch_t * hal_rpc_hash_dispatch = &hal_rpc_local_hash_dispatch;
const hal_rpc_pkey_dispatch_t * hal_rpc_pkey_dispatch = &hal_rpc_mixed_pkey_dispatch;
#endif