diff options
Diffstat (limited to 'projects/hsm')
-rw-r--r-- | projects/hsm/hsm.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/projects/hsm/hsm.c b/projects/hsm/hsm.c index c9d8d28..29509e8 100644 --- a/projects/hsm/hsm.c +++ b/projects/hsm/hsm.c @@ -99,7 +99,7 @@ typedef struct rpc_buffer_s { } rpc_buffer_t; /* RPC input (requst) buffers */ -static rpc_buffer_t ibufs[NUM_RPC_TASK]; +static rpc_buffer_t *ibufs; /* ibuf queue structure */ typedef struct { @@ -439,6 +439,12 @@ task_mutex_t ks_mutex = { 0 }; void hal_ks_lock(void) { task_mutex_lock(&ks_mutex); } void hal_ks_unlock(void) { task_mutex_unlock(&ks_mutex); } +/* A mutex to arbitrary concurrent access to the RSA blinding factors cache. + */ +task_mutex_t rsa_bf_mutex = { 0 }; +void hal_rsa_bf_lock(void) { task_mutex_lock(&rsa_bf_mutex); } +void hal_rsa_bf_unlock(void) { task_mutex_unlock(&rsa_bf_mutex); } + /* Sleep for specified number of seconds. */ void hal_sleep(const unsigned seconds) { task_delay(seconds * 1000); } @@ -455,9 +461,13 @@ int main(void) Error_Handler(); /* Initialize the ibuf queues. */ + ibufs = (rpc_buffer_t *)sdram_malloc(NUM_RPC_TASK * sizeof(rpc_buffer_t)); + if (ibufs == NULL) + Error_Handler(); + memset(ibufs, 0, NUM_RPC_TASK * sizeof(rpc_buffer_t)); memset(&ibuf_waiting, 0, sizeof(ibuf_waiting)); memset(&ibuf_ready, 0, sizeof(ibuf_ready)); - for (size_t i = 0; i < sizeof(ibufs)/sizeof(ibufs[0]); ++i) + for (size_t i = 0; i < NUM_RPC_TASK; ++i) ibuf_put(&ibuf_waiting, &ibufs[i]); /* Create the rpc dispatch worker tasks. */ |