#ifndef _DARRA_MBX_CACHE_H_
#define _DARRA_MBX_CACHE_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#define MBX_CACHE_MAX_MASTER 8
#define MBX_CACHE_MAX_SLAVE  256

#define MBX_CACHE_UNCACHED 0xFFFF

uint16_t mbx_cache_get(uint16_t master_idx, uint16_t slave_idx);

void mbx_cache_put(uint16_t master_idx, uint16_t slave_idx, uint16_t mbx_proto);

void mbx_cache_invalidate_slave(uint16_t master_idx, uint16_t slave_idx);

void mbx_cache_invalidate_master(uint16_t master_idx);

void mbx_cache_clear_all(void);

typedef uint16_t (*mbx_cache_fetch_fn)(uint16_t master, uint16_t slave);
uint16_t mbx_cache_get_or_fetch(uint16_t master_idx, uint16_t slave_idx,
                                       mbx_cache_fetch_fn fetch_fn);

#ifdef __cplusplus
}
#endif

#endif
