From ad800ebf93a8edf25194f17c9bb75cbccd68ee6e Mon Sep 17 00:00:00 2001 From: Liam Merwick Date: Thu, 6 Dec 2018 21:09:26 +0000 Subject: qboot: Move inline load and store routines to memaccess.h Move lduw_p, ldl_p, stw_p, stl_p from linuxboot.c to include/memaccess.h so they can be reused more easily. Signed-off-by: Liam Merwick --- include/memaccess.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 include/memaccess.h (limited to 'include') diff --git a/include/memaccess.h b/include/memaccess.h new file mode 100644 index 0000000..900b47e --- /dev/null +++ b/include/memaccess.h @@ -0,0 +1,30 @@ +#ifndef MEMACCESS_H_ +#define MEMACCESS_H_ + +#include "string.h" + +static inline uint16_t lduw_p(void *p) +{ + uint16_t val; + memcpy(&val, p, 2); + return val; +} + +static inline uint32_t ldl_p(void *p) +{ + uint32_t val; + memcpy(&val, p, 4); + return val; +} + +static inline void stw_p(void *p, uint16_t val) +{ + memcpy(p, &val, 2); +} + +static inline void stl_p(void *p, uint32_t val) +{ + memcpy(p, &val, 4); +} + +#endif /* MEMACCESS_H_ */ -- cgit v1.1