9os

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

commit ab6318eaa3c4be6440b9df264aa5a194d2ca9e48
parent 3151d6e6198552f618be05e388c3fd330e437eea
Author: Dimitris Papastamos <dimitris.papastamos@arm.com>
Date:   Mon, 15 Oct 2018 11:55:03 +0100

Re-organize the arch directory

- Move badrmc/synchdl to rmc.c
- Introduce ram-{none,linux}.c and rom-{none,linux}.c
- Fix tests

Change-Id: I9fcd1363a352c1fac700ed05c9df801721329a5d
Signed-off-by: Dimitris Papastamos <dimitris.papastamos@arm.com>

Diffstat:
March/amd64/arch.s | 14++++++++++++++
March/amd64/panic.c | 4++--
March/amd64/ram.c | 3+--
March/amd64/rom.c | 11+----------
March/arm64/Makefile | 4++--
Aarch/arm64/ram-linux.c | 7+++++++
Aarch/arm64/ram-none.c | 6++++++
Aarch/arm64/rom-linux.c | 7+++++++
Aarch/arm64/rom-none.c | 42++++++++++++++++++++++++++++++++++++++++++
Darch/arm64/rom.c | 71-----------------------------------------------------------------------
Msrc/rmc.c | 29+++++++++++++++++++++++++++++
Mtest/test1/Makefile | 6+++++-
Mtest/test1/genrmu.sh | 2++
Mtest/test1/test.c | 14--------------
14 files changed, 118 insertions(+), 102 deletions(-)

diff --git a/arch/amd64/arch.s b/arch/amd64/arch.s @@ -1 +1,15 @@ .file "arch.s" + + .text + .globl swtch,panic + +panic: + jmp cpanic + +swtch: + mov $msg,%rdi + call panic + + .section .rodata +msg: + .asciz "swtch not implemented for amd64" diff --git a/arch/amd64/panic.c b/arch/amd64/panic.c @@ -1,9 +1,9 @@ #include <rcode.h> void -panic(const char *msg) +cpanic(const char *msg) { - dbg(msg); + printk("panic: %s\n", msg); for (;;) ; } diff --git a/arch/amd64/ram.c b/arch/amd64/ram.c @@ -1,8 +1,7 @@ -#include <stdint.h> - #include <rcode.h> int main(int argc, char *argv[]) { + return 0; } diff --git a/arch/amd64/rom.c b/arch/amd64/rom.c @@ -1,16 +1,7 @@ -#include <stdint.h> - #include <rcode.h> -void -badrmc(Rmucmd *cmd, int error) -{ - dbg("bad RMC: %d, %d = %d\n", cmd->imm1, cmd->imm2, error); - cmd->fp->x0 = error; - longjmp(cmd->recover, 1); -} - int main(int argc, char *argv[]) { + return 0; } diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile @@ -1,8 +1,8 @@ PROJECTDIR = ../.. include $(PROJECTDIR)/scripts/rules.mk -ROMOBJS = rom-crt-$(SYS).o panic.o arch.o rom.o $(SRCDIR)/romfw/builtin.o -RAMOBJS = ram-crt-$(SYS).o panic.o arch.o ram.o $(SRCDIR)/ramfw/builtin.o +ROMOBJS = rom-crt-$(SYS).o rom-$(SYS).o panic.o arch.o $(SRCDIR)/romfw/builtin.o +RAMOBJS = ram-crt-$(SYS).o ram-$(SYS).o panic.o arch.o $(SRCDIR)/ramfw/builtin.o TARGET = $(BINDIR)/romfw.bin $(BINDIR)/ramfw.bin LIBS = -lhdl -lrmu -lc diff --git a/arch/arm64/ram-linux.c b/arch/arm64/ram-linux.c @@ -0,0 +1,7 @@ +#include <rcode.h> + +int +main(int argc, char *argv[]) +{ + return 0; +} diff --git a/arch/arm64/ram-none.c b/arch/arm64/ram-none.c @@ -0,0 +1,6 @@ +#include <rcode.h> + +void +main(void) +{ +} diff --git a/arch/arm64/rom-linux.c b/arch/arm64/rom-linux.c @@ -0,0 +1,7 @@ +#include <rcode.h> + +int +main(int argc, char *argv[]) +{ + return 0; +} diff --git a/arch/arm64/rom-none.c b/arch/arm64/rom-none.c @@ -0,0 +1,42 @@ +#include <string.h> + +#include <rcode.h> + +/* + * We allocate space for 3 nested exceptions, covering + * the case of having an abort while dealing a panic + * from an abort generated by the rmc. You are not + * expected to understand this. + */ +#define NR_NESTED 3 + +void +main(void *text, void *ram, size_t ramsiz) +{ + struct trapframe *fp; + char *bp = ram; + size_t bsssiz; + + bsssiz = (sizeof(struct bssmap) + 15) & ~15; + fp = (struct trapframe *) (bp + bsssiz); + fp += NR_NESTED - 1; + wr_sp_r(fp); + _uart_init(); + enaabt(); + isb(); + + memset(ram, 0, bsssiz); + memset(fp, 0, sizeof(*fp)); + + bss->text = text; + + fp->sp = bp + (ramsiz - 16); + fp->elr = rd_rvbar_el3(); + fp->spsr = 0xf << 6 | 0xd; + + swtch(fp); + /* + * main is not expected to return. If it happens we will + * be out of sync and we will panic + */ +} diff --git a/arch/arm64/rom.c b/arch/arm64/rom.c @@ -1,71 +0,0 @@ -#include <string.h> - -#include <rcode.h> - -/* - * We allocate space for 3 nested exceptions, covering - * the case of having an abort while dealing a panic - * from an abort generated by the rmc. You are not - * expected to understand this. - */ -#define NR_NESTED 3 - -void -synchdl(struct trapframe *fp) -{ - Rmucmd cmd; - unsigned why; - - dbg("sync handler\n"); - - why = fp->esr >> 26; - cmd.imm1 = fp->esr & 0xff; - cmd.imm2 = (fp->esr >> 8) & 0xff; - - if (why != 0x2e) - panic("wrong exception"); - - if (!setjmp(cmd.recover)) - rmc(&cmd); - - swtch(fp); -} - -void -badrmc(Rmucmd *cmd, int error) -{ - dbg("bad RMC: %d, %d = %d\n", cmd->imm1, cmd->imm2, error); - cmd->fp->x0 = error; - longjmp(cmd->recover, 1); -} - -void -main(void *text, void *ram, size_t ramsiz) -{ - struct trapframe *fp; - char *bp = ram; - size_t bsssiz; - - bsssiz = (sizeof(struct bssmap) + 15) & ~15; - fp = (struct trapframe *) (bp + bsssiz); - fp += NR_NESTED - 1; - wr_sp_r(fp); - _uart_init(); - enaabt(); - isb(); - - memset(ram, 0, bsssiz); - memset(fp, 0, sizeof(*fp)); - - bss->text = text; - - fp->sp = bp + (ramsiz - 16); - fp->elr = rd_rvbar_el3(); - fp->spsr = 0xf << 6 | 0xd; - - swtch(fp); - /* - * main is not expected to return. If it happens we will - * be out of sync and we will panic - */ -} diff --git a/src/rmc.c b/src/rmc.c @@ -1,5 +1,34 @@ #include <rcode.h> +void +synchdl(struct trapframe *fp) +{ + Rmucmd cmd; + unsigned why; + + dbg("sync handler\n"); + + why = fp->esr >> 26; + cmd.imm1 = fp->esr & 0xff; + cmd.imm2 = (fp->esr >> 8) & 0xff; + + if (why != 0x2e) + panic("wrong exception"); + + if (!setjmp(cmd.recover)) + rmc(&cmd); + + swtch(fp); +} + +void +badrmc(Rmucmd *cmd, int error) +{ + dbg("bad RMC: %d, %d = %d\n", cmd->imm1, cmd->imm2, error); + cmd->fp->x0 = error; + longjmp(cmd->recover, 1); +} + /* * The dispatcher cannot be implemented using a table * because the rmu command number is composed by two diff --git a/test/test1/Makefile b/test/test1/Makefile @@ -45,7 +45,11 @@ LIBOBJ = hdl_RMU_Crypto_Random.o \ hdl_RMU_System_InterfaceVersion.o \ hdl_RMU_System_Status.o \ -OBJS = $(ARCHDIR)/crt-$(SYS).o $(SRCDIR)/romfw/builtin.o test.o +OBJS = $(ARCHDIR)/crt-$(SYS).o \ + $(ARCHDIR)/arch.o \ + $(ARCHDIR)/panic.o \ + $(SRCDIR)/romfw/builtin.o \ + test.o LIBS = -lhdl -lc LIBDEP = libhdl.a $(LIBDIR)/libc.a diff --git a/test/test1/genrmu.sh b/test/test1/genrmu.sh @@ -3,6 +3,8 @@ genfile() { cat <<FILE >$i.c +#include <stdio.h> + #include <rcode.h> void diff --git a/test/test1/test.c b/test/test1/test.c @@ -22,17 +22,3 @@ main(int argc, char *argv[]) } return 0; } - -void -panic(const char *msg) -{ - printk("panic: %s\n", msg); - abort(); -} - -void -badrmc(Rmucmd *cmd, int error) -{ - dbg("bad RMC: %d, %d = %d\n", cmd->imm1, cmd->imm2, error); - longjmp(cmd->recover, 1); -}