aboutsummaryrefslogtreecommitdiff
path: root/projects
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2016-06-30 22:10:01 -0400
committerPaul Selkirk <paul@psgd.org>2016-06-30 22:10:01 -0400
commitd7e7dbc990aca690c069060bd39a168ffbd28e64 (patch)
tree3a581bf9322d1790b56659fa389de3b4c5ef154f /projects
parent5e33e972b58aca7955c14aa12a22d715d6a2c239 (diff)
RPC wire format now includes client handle in all requests, and opcode and
client handle in all responses.
Diffstat (limited to 'projects')
-rw-r--r--projects/hsm/hsm.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/projects/hsm/hsm.c b/projects/hsm/hsm.c
index 5758f05..9cc6e9a 100644
--- a/projects/hsm/hsm.c
+++ b/projects/hsm/hsm.c
@@ -148,6 +148,7 @@ static void dispatch_thread(void const *args)
while (1) {
memset(&ibuf, 0, sizeof(ibuf));
memset(&obuf, 0, sizeof(obuf));
+ obuf.len = sizeof(obuf.buf);
/* Wait for access to the uart */
osMutexWait(dispatch_mutex, osWaitForever);
@@ -161,16 +162,12 @@ static void dispatch_thread(void const *args)
/* Let the next thread take the mutex */
osThreadYield();
- /* Copy client ID from request to response */
- memcpy(obuf.buf, ibuf.buf, 4);
- obuf.len = sizeof(obuf.buf) - 4;
-
/* Process the request */
- hal_rpc_server_dispatch(ibuf.buf + 4, ibuf.len - 4, obuf.buf + 4, &obuf.len);
+ hal_rpc_server_dispatch(ibuf.buf, ibuf.len, obuf.buf, &obuf.len);
/* Send the response */
osMutexWait(uart_mutex, osWaitForever);
- hal_error_t ret = hal_rpc_sendto(obuf.buf, obuf.len + 4, NULL);
+ hal_error_t ret = hal_rpc_sendto(obuf.buf, obuf.len, NULL);
osMutexRelease(uart_mutex);
if (ret != HAL_OK)
Error_Handler();
@@ -207,15 +204,6 @@ int main()
{
stm_init();
-#ifdef TARGET_CRYPTECH_DEV_BRIDGE
- /* Wait six seconds to not upset the Novena at boot. */
- led_on(LED_BLUE);
- for (int i = 0; i < 12; i++) {
- osDelay(500);
- led_toggle(LED_BLUE);
- }
- led_off(LED_BLUE);
-#endif
led_on(LED_GREEN);
/* Prepare FMC interface. */
fmc_init();
@@ -232,13 +220,6 @@ int main()
dispatch_mutex = osMutexCreate(osMutex(dispatch_mutex));
rpc_sem = osSemaphoreCreate(osSemaphore(rpc_sem), 0);
-#ifdef TARGET_CRYPTECH_ALPHA
- /* Launch other threads:
- * - admin thread on USART1
- * - csprng warm-up thread?
- */
-#endif
-
if (hal_rpc_server_init() != HAL_OK)
Error_Handler();
@@ -258,5 +239,9 @@ int main()
/* Start the non-blocking receive */
HAL_UART_Receive_IT(&huart_user, (uint8_t *)&uart_rx, 1);
+ /* Launch other threads:
+ * - csprng warm-up thread?
+ */
+
return cli_main();
}