diff options
Diffstat (limited to 'hal.h')
-rw-r--r-- | hal.h | 31 |
1 files changed, 24 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") \ DEFINE_HAL_ERROR(HAL_ERROR_HASHSIG_KEY_EXHAUSTED, "Key exhausted") \ DEFINE_HAL_ERROR(HAL_ERROR_NOT_READY, "Not ready for this operation") \ END_OF_HAL_ERROR_LIST @@ -214,6 +216,12 @@ extern hal_error_t hal_io_wait2(const hal_core_t *core1, const hal_core_t *core2 * insistence on discarding array bounds information makes * non-delimited character arrays problematic unless we wrap them in a * structure. + * + * For performance reasons, we promise that the hal_core_info_t will + * be the first element of hal_core_t, so that we can convert between + * them using inline functions without completely exposing hal_core_t. + * This is icky, but hal_core_base() gets called a lot during I/O, so + * it's worth a bit of ick to eliminate some function call overhead. */ typedef struct { @@ -222,16 +230,25 @@ typedef struct { hal_addr_t base; } hal_core_info_t; +typedef uint32_t hal_core_lru_t; + +static inline const hal_core_info_t *hal_core_info(const hal_core_t *core) +{ + return (const hal_core_info_t *) core; +} + +static inline hal_addr_t hal_core_base(const hal_core_t *core) +{ + return core == NULL ? 0 : hal_core_info(core)->base; +} + 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_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. |