From 1cf5458247da9cff686eaa49e3a52c04cc07d038 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Fri, 16 Jul 2021 22:27:32 +0200 Subject: [PATCH] added memset for non-rv32m environments --- kinclude/boot.S | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kinclude/boot.S b/kinclude/boot.S index cc7cf76..68fda22 100644 --- a/kinclude/boot.S +++ b/kinclude/boot.S @@ -113,6 +113,25 @@ trap_vector: .option pop jal trap_handle + +#ifdef __risc_no_ext +// "dumb" memset, if RV32M is not present on the target +// since memset is currently only used at startup, the performance implications +// should be minimal. +memset: + bge a1, a2, 2f +1: + sw a0, 0(a1) + addi a1, a1, 4 + blt a1, a2, 1b +2: + ret + +#else + +// "smart" memset, writing 32 bytes at a time. uses RV32M. If not present, +// the "dumb" fallback above is used. + // write a0 to memory starting at a1, until a2 (both must be four byte aligned) // this uses a loop which writes 32 (numbytes) bytes at a time // to prevent overshooting the end, we first calulate how many instructions to