diff options
author | Rob Austein <sra@hactrn.net> | 2018-05-20 18:18:40 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2018-05-20 18:18:40 -0400 |
commit | e6bdf57820121b6eac9f35c8ef53a4e7a76205e1 (patch) | |
tree | b8701157fa06ea8f873b1c330d9599e4eb7384cf /hal.h | |
parent | 76edd86d940956eb42ced93ccd4ee5f1d95bd01f (diff) |
Better hal_core_alloc() semantics, assert() and printf() cleanup.
Various fixes extracted from the abandoned(-for-now?) reuse-cores
branch, principally:
* Change hal_core_alloc*() to support core reuse and to pick the
least-recently-used core of a particular type otherwise;
* Replace assert() and printf() calls with hal_assert() and hal_log(),
respectively. assert() is particularly useless on the HSM, since it
sends its error message into hyperspace then hangs the HSM.
Diffstat (limited to 'hal.h')
-rw-r--r-- | hal.h | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -161,6 +161,8 @@ DEFINE_HAL_ERROR(HAL_ERROR_KEYSTORE_WRONG_BLOCK_TYPE, "Wrong block type in keystore") \ DEFINE_HAL_ERROR(HAL_ERROR_RPC_PROTOCOL_ERROR, "RPC protocol error") \ DEFINE_HAL_ERROR(HAL_ERROR_NOT_IMPLEMENTED, "Not implemented") \ + DEFINE_HAL_ERROR(HAL_ERROR_CORE_REASSIGNED, "Core has been reassigned since last use") \ + DEFINE_HAL_ERROR(HAL_ERROR_ASSERTION_FAILED, "Assertion failed") \ END_OF_HAL_ERROR_LIST /* Marker to forestall silly line continuation errors */ @@ -220,18 +222,17 @@ typedef struct { hal_addr_t base; } hal_core_info_t; +typedef uint32_t hal_core_lru_t; + extern hal_core_t *hal_core_find(const char *name, hal_core_t *core); extern const hal_core_info_t *hal_core_info(const hal_core_t *core); extern hal_addr_t hal_core_base(const hal_core_t *core); -extern hal_core_t * hal_core_iterate(hal_core_t *core); +extern hal_core_t *hal_core_iterate(hal_core_t *core); extern void hal_core_reset_table(void); -extern hal_error_t hal_core_alloc(const char *name, hal_core_t **core); -extern hal_error_t hal_core_alloc2(const char *name1, hal_core_t **pcore1, - const char *name2, hal_core_t **pcore2); +extern hal_error_t hal_core_alloc(const char *name, hal_core_t **core, hal_core_lru_t *pomace); +extern hal_error_t hal_core_alloc2(const char *name1, hal_core_t **core1, hal_core_lru_t *pomace1, + const char *name2, hal_core_t **core2, hal_core_lru_t *pomace2); extern void hal_core_free(hal_core_t *core); -extern void hal_critical_section_start(void); -extern void hal_critical_section_end(void); -extern int hal_core_busy(const hal_core_t *core); /* * Slightly higher level public API, still working directly with cores. |