From e164eecc55dd96efc98d2c723e96aaaecdcfda13 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 4 Oct 2015 15:39:08 -0400 Subject: off_t => hal_addr_t. --- modexp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modexp.c') diff --git a/modexp.c b/modexp.c index 11a8d21..b82f1ff 100644 --- a/modexp.c +++ b/modexp.c @@ -76,7 +76,7 @@ void hal_modexp_set_debug(const int onoff) * Set an ordinary register. */ -static hal_error_t set_register(const off_t addr, +static hal_error_t set_register(const hal_addr_t addr, uint32_t value) { uint8_t w[4]; @@ -96,7 +96,7 @@ static hal_error_t set_register(const off_t addr, * expects. */ -static hal_error_t get_buffer(const off_t data_addr, +static hal_error_t get_buffer(const hal_addr_t data_addr, uint8_t *value, const size_t length) { @@ -116,7 +116,7 @@ static hal_error_t get_buffer(const off_t data_addr, * expects. */ -static hal_error_t set_buffer(const off_t data_addr, +static hal_error_t set_buffer(const hal_addr_t data_addr, const uint8_t * const value, const size_t length) { -- cgit v1.2.3 From b3bbd3dbccef8c499e980490203cd5085dd13a98 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 4 Oct 2015 22:31:47 -0400 Subject: Whack libhal API to use current configure_core_selector mechanism. Compiles, not yet tested. --- modexp.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'modexp.c') diff --git a/modexp.c b/modexp.c index b82f1ff..f008064 100644 --- a/modexp.c +++ b/modexp.c @@ -46,6 +46,7 @@ #include #include "hal.h" +#include "verilog_constants.h" /* * Whether we want debug output. @@ -76,7 +77,8 @@ void hal_modexp_set_debug(const int onoff) * Set an ordinary register. */ -static hal_error_t set_register(const hal_addr_t addr, +static hal_error_t set_register(const hal_core_t *core, + const hal_addr_t addr, uint32_t value) { uint8_t w[4]; @@ -87,7 +89,7 @@ static hal_error_t set_register(const hal_addr_t addr, value >>= 8; } - return hal_io_write(addr, w, sizeof(w)); + return hal_io_write(core, addr, w, sizeof(w)); } /* @@ -96,7 +98,8 @@ static hal_error_t set_register(const hal_addr_t addr, * expects. */ -static hal_error_t get_buffer(const hal_addr_t data_addr, +static hal_error_t get_buffer(const hal_core_t *core, + const hal_addr_t data_addr, uint8_t *value, const size_t length) { @@ -105,7 +108,7 @@ static hal_error_t get_buffer(const hal_addr_t data_addr, assert(value != NULL && length % 4 == 0); for (i = 0; i < length; i += 4) - check(hal_io_read(data_addr + i/4, &value[length - 4 - i], 4)); + check(hal_io_read(core, data_addr + i/4, &value[length - 4 - i], 4)); return HAL_OK; } @@ -116,7 +119,8 @@ static hal_error_t get_buffer(const hal_addr_t data_addr, * expects. */ -static hal_error_t set_buffer(const hal_addr_t data_addr, +static hal_error_t set_buffer(const hal_core_t *core, + const hal_addr_t data_addr, const uint8_t * const value, const size_t length) { @@ -125,7 +129,7 @@ static hal_error_t set_buffer(const hal_addr_t data_addr, assert(value != NULL && length % 4 == 0); for (i = 0; i < length; i += 4) - check(hal_io_write(data_addr + i/4, &value[length - 4 - i], 4)); + check(hal_io_write(core, data_addr + i/4, &value[length - 4 - i], 4)); return HAL_OK; } @@ -134,7 +138,8 @@ static hal_error_t set_buffer(const hal_addr_t data_addr, * Run one modexp operation. */ -hal_error_t hal_modexp(const uint8_t * const msg, const size_t msg_len, /* Message */ +hal_error_t hal_modexp(const hal_core_t *core, + const uint8_t * const msg, const size_t msg_len, /* Message */ const uint8_t * const exp, const size_t exp_len, /* Exponent */ const uint8_t * const mod, const size_t mod_len, /* Modulus */ uint8_t *result, const size_t result_len) @@ -171,37 +176,37 @@ hal_error_t hal_modexp(const uint8_t * const msg, const size_t msg_len, /* Messa */ /* Select mode (1 = fast, 0 = safe) */ - check(set_register(MODEXPS6_ADDR_MODE, (exp_len <= 4))); + check(set_register(core, MODEXPS6_ADDR_MODE, (exp_len <= 4))); /* Set modulus size in bits */ - check(set_register(MODEXPS6_ADDR_MODULUS_WIDTH, mod_len * 8)); + check(set_register(core, MODEXPS6_ADDR_MODULUS_WIDTH, mod_len * 8)); /* Write new modulus */ - check(set_buffer(MODEXPS6_ADDR_MODULUS, mod, mod_len)); + check(set_buffer(core, MODEXPS6_ADDR_MODULUS, mod, mod_len)); /* Pre-calcuate speed-up coefficient */ - check(hal_io_init(MODEXPS6_ADDR_CTRL)); + check(hal_io_init(core)); /* Wait for calculation to complete */ - check(hal_io_wait_ready(MODEXPS6_ADDR_STATUS)); + check(hal_io_wait_ready(core)); /* Write new message */ - check(set_buffer(MODEXPS6_ADDR_MESSAGE, msg, msg_len)); + check(set_buffer(core, MODEXPS6_ADDR_MESSAGE, msg, msg_len)); /* Set new exponent length in bits */ - check(set_register(MODEXPS6_ADDR_EXPONENT_WIDTH, exp_len * 8)); + check(set_register(core, MODEXPS6_ADDR_EXPONENT_WIDTH, exp_len * 8)); /* Set new exponent */ - check(set_buffer(MODEXPS6_ADDR_EXPONENT, exp, exp_len)); + check(set_buffer(core, MODEXPS6_ADDR_EXPONENT, exp, exp_len)); /* Start calculation */ - check(hal_io_next(MODEXPS6_ADDR_CTRL)); + check(hal_io_next(core)); /* Wait for result */ - check(hal_io_wait_valid(MODEXPS6_ADDR_STATUS)); + check(hal_io_wait_valid(core)); /* Extract result */ - check(get_buffer(MODEXPS6_ADDR_RESULT, result, mod_len)); + check(get_buffer(core, MODEXPS6_ADDR_RESULT, result, mod_len)); return HAL_OK; } -- cgit v1.2.3