9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 7f7d18298f84d24018b8d0c8f61849a8efdf8272
parent 068a0abdb27168e9a046b3ed588a5e363f36db78
Author: Dimitris Papastamos <dimitris.papastamos@arm.com>
Date:   Tue, 11 Dec 2018 16:29:12 +0000

Merge "Implement reloc() as part of the environment (rom/ram firmware)"
Diffstat:
Minclude/rcode.h | 1+
Minclude/romfw.h | 15---------------
Msrc/ramfw/rt.c | 16++++++++++++++++
Msrc/romfw/rmc.c | 15+++++++++++++++
4 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/include/rcode.h b/include/rcode.h @@ -71,6 +71,7 @@ extern noreturn void badcmd(int error); extern void rmc(Rmucmd *cmd); extern int debug(void); extern void idev(void); +extern void *reloc(const void *); /* driver functions */ extern int create(const char *name, int flags); diff --git a/include/romfw.h b/include/romfw.h @@ -1,5 +1,4 @@ #include <stddef.h> -#include <stdint.h> #include <setjmp.h> struct rmctab; @@ -34,18 +33,4 @@ struct bssmap { extern struct bssmap *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 struct rmctab romtab; diff --git a/src/ramfw/rt.c b/src/ramfw/rt.c @@ -1,5 +1,7 @@ #include <setjmp.h> +#include <stdint.h> +#include <ramfw.h> #include <rcode.h> void @@ -26,3 +28,17 @@ trap(struct trapframe *fp) { panic("trap"); } + +/* + * Reloc() is used to relocate address + * because we are linked at address 0 but we can be + * loaded at any address + */ +void * +reloc(const void *addr) +{ + uintptr_t a = (uintptr_t) addr; + uintptr_t off = (uintptr_t) bss->text; + + return (void *) (a + off); +} diff --git a/src/romfw/rmc.c b/src/romfw/rmc.c @@ -1,4 +1,5 @@ #include <setjmp.h> +#include <stdint.h> #include <libk.h> #include <rmu.h> @@ -188,3 +189,17 @@ rmc(Rmucmd *cmd) cmd->fp->x0 = SUCCESS; } + +/* + * Reloc() is used to relocate address + * because we are linked at address 0 but we can be + * loaded at any address + */ +void * +reloc(const void *addr) +{ + uintptr_t a = (uintptr_t) addr; + uintptr_t off = (uintptr_t) bss->text; + + return (void *) (a + off); +}