commit 2c19b32e891a768aabdd75a48add114c93777afb
parent f10c64b2c0179267cfdefedc6b0cd4e15739a4c1
Author: Roberto Vargas <roberto.vargas@arm.com>
Date: Fri, 26 Oct 2018 14:19:05 +0100
Move reloc() to rcode.h
This function can be used from different places, not only from rmc.c
Diffstat:
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/include/rcode.h b/include/rcode.h
@@ -130,6 +130,20 @@ bss(void)
}
#define bss bss()
+/*
+ * Reloc() is used to relocate address
+ * because we are linked at address 0 but we can be
+ * loaded at any address
+ */
+static inline void *
+reloc(const void *addr)
+{
+ uintptr_t a = (uintptr_t) addr;
+ uintptr_t off = (uintptr_t) bss->text;
+
+ return (void *) (a + off);
+}
+
extern void trap(struct trapframe *fp);
extern void badcmd(int error);
extern void dopanic(void);
diff --git a/src/rmc.c b/src/rmc.c
@@ -74,15 +74,6 @@ panic(const char *msg)
dopanic();
}
-static inline void *
-reloc(const void *addr)
-{
- uintptr_t a = (uintptr_t) addr;
- uintptr_t off = (uintptr_t) bss->text;
-
- return (void *) (a + off);
-}
-
void
trap(struct trapframe *fp)
{
@@ -163,11 +154,6 @@ rmc(Rmucmd *cmd)
if (cmd->func >= idx->cnt)
badcmd(-1); /* TODO: put the correct code */
- /*
- * and now we have to reallocate the function pointer,
- * because we are linked at address 0 but we can be
- * loaded at any address
- */
bp = reloc(handler[idx->off + cmd->func]);
fp = (void (*) (Rmucmd *)) bp;
(*fp)(cmd);