aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Merwick <liam.merwick@oracle.com>2018-12-06 21:09:26 +0000
committerPaolo Bonzini <bonzini@gnu.org>2018-12-28 14:31:29 +0100
commitad800ebf93a8edf25194f17c9bb75cbccd68ee6e (patch)
treea27cfb7d68659b71568db885a467cc67f91d9fed
parent29f013f76ea25f0384fb9602e508e09b3e445375 (diff)
downloadqboot-ad800ebf93a8edf25194f17c9bb75cbccd68ee6e.zip
qboot-ad800ebf93a8edf25194f17c9bb75cbccd68ee6e.tar.gz
qboot-ad800ebf93a8edf25194f17c9bb75cbccd68ee6e.tar.bz2
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 <liam.merwick@oracle.com>
-rw-r--r--include/memaccess.h30
-rw-r--r--linuxboot.c25
2 files changed, 31 insertions, 24 deletions
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_ */
diff --git a/linuxboot.c b/linuxboot.c
index a5f1c4f..d7eac74 100644
--- a/linuxboot.c
+++ b/linuxboot.c
@@ -1,34 +1,11 @@
#include "bios.h"
#include "linuxboot.h"
+#include "memaccess.h"
#include "ioport.h"
#include "string.h"
#include "stdio.h"
#include "benchmark.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);
-}
-
bool parse_bzimage(struct linuxboot_args *args)
{
uint8_t *header = args->header;