diff options
-rw-r--r-- | base/include/host/mars/base.h | 20 | ||||
-rw-r--r-- | base/src/host/lib/ea_cell.c | 12 |
2 files changed, 32 insertions, 0 deletions
diff --git a/base/include/host/mars/base.h b/base/include/host/mars/base.h index d0b1f87..648b985 100644 --- a/base/include/host/mars/base.h +++ b/base/include/host/mars/base.h @@ -133,6 +133,17 @@ void mars_ea_get(uint64_t ea, void *ptr, size_t size); /** * \ingroup group_mars_base + * \brief <b>[host]</b> Get 8-bit integer value from shared memory + * + * \param[in] ea - 64-bit address of source + * + * \return + * uint8_t - 8-bit result, no guarantee that it is loaded atomically + */ +uint8_t mars_ea_get_uint8(uint64_t ea); + +/** + * \ingroup group_mars_base * \brief <b>[host]</b> Get 16-bit integer value from shared memory * * \param[in] ea - 64-bit address of source @@ -177,6 +188,15 @@ void mars_ea_put(uint64_t ea, const void *ptr, size_t size); /** * \ingroup group_mars_base + * \brief <b>[host]</b> Put 8-bit integer value to shared memory atomically + * + * \param[in] ea - 64-bit address of destination + * \param[in] value - 8-bit value to be stored in shared memory, no guarantee that it is stored atomically + */ +void mars_ea_put_uint8(uint64_t ea, uint8_t value); + +/** + * \ingroup group_mars_base * \brief <b>[host]</b> Put 16-bit integer value to shared memory atomically * * \param[in] ea - 64-bit address of destination diff --git a/base/src/host/lib/ea_cell.c b/base/src/host/lib/ea_cell.c index 11c8c6f..e61aca2 100644 --- a/base/src/host/lib/ea_cell.c +++ b/base/src/host/lib/ea_cell.c @@ -131,6 +131,12 @@ void mars_ea_get(uint64_t ea, void *mem, size_t size) memcpy(mem, src, size); } +/* get uint8 value from EA */ +uint8_t mars_ea_get_uint8(uint64_t ea) +{ + return *(uint8_t *)mars_ea_to_ptr(ea); +} + /* get uint16 value from EA */ uint16_t mars_ea_get_uint16(uint64_t ea) { @@ -157,6 +163,12 @@ void mars_ea_put(uint64_t ea, const void *mem, size_t size) memcpy(dst, mem, size); } +/* put uint8 value to EA */ +void mars_ea_put_uint8(uint64_t ea, uint8_t value) +{ + *(uint8_t *)mars_ea_to_ptr(ea) = value; +} + /* put uint16 value to EA */ void mars_ea_put_uint16(uint64_t ea, uint16_t value) { |