Initial RISC-V support implemented #365
Replies: 3 comments 2 replies
-
This is really cool. Thank you for sharing early! @cbiffle and @bcantrill will need to comment on Hubris kernel and Humility respectively but this looks fantastic so far. As far as how to integrate, I'd like to see a PR for the kernel changes only. |
Beta Was this translation helpful? Give feedback.
-
This looks great! I really want to get away from ITM entirely; have you been able to get Humility to work? (I ask because I would like to retool the test suite to not use ITM.) |
Beta Was this translation helpful? Give feedback.
-
This is pretty slick, @jperkin. I need to pick up one of those E310 boards -- I have older SiFive hardware that lacks the memory protection unit, as we discovered during early Hubris development. (If anyone at SiFive is excited about Hubris, I accept samples. :-) ) Others may differ, of course, but here are my responses to your bullet points.
Yeah, that's how I'd port it. M/U cores are probably going to be quite common in the microcontroller space, the M/S/U distinction is less important.
I'll take a look at your specific ABI choices when I get some spare time, but, this sounds reasonable. The trick for avoiding a full context switch is pretty ARMv7-M specific; most processors don't have an equivalent to the PendSV hack. However, perhaps there are things we can optimize. In general, Hubris was originally designed with the intent of moving to RISC-V eventually, which is part of why we're so register-focused in the calling convention.
Yeah, that seems like the right place to start, and you have correctly guessed my intent. :-) The reason why task pointer tracking is left to the
It looks like the spec permits WFI to be exposed to U-mode, but that also smells like the parts of the spec that tend not to get implemented (like U-mode interrupt handling), so I could believe that it's not possible on the E310. Support for interrupts should be straightforward assuming the E310 has a PLIC or something similar. The interrupt model was intended to cover the common RISC-V interrupt controller designs. If it doesn't, I'd sure like to know about it! Because Hubris winds up sending all application interrupts through a single handler, if you're able to disable vectoring and route all interrupts to a single location, you could save quite a bit of Flash compared to the ARM-M ports where the vector table is mandatory. I seem to recall this capability being included in the privileged spec at one point, but again, I have a hard time predicting which parts of the spec actually get implemented. :-\ |
Beta Was this translation helpful? Give feedback.
-
Hi!
I've ported Hubris to RISC-V, specifically the Freedom E310 core on a Sparkfun RED-V board that I have. The repository is available at https://github.com/jperkin/hubris/tree/riscv.
While I've yet to implement interrupts and peripherals, the rest of the kernel is done, and a demo application successfully runs
jefe
,ping
,pong
(without LEDs), andidle
:I've also implemented enough that the test suite runs with only 1 expected failure, due to differences between ARM and RISC-V fault handling:
I figured that now I have a working implementation it'd be a good time to verify that you're happy with the general direction. Some general notes:
mscratch
register instead to keep track.wfi
call from User mode, so instead theidle
task spins on asys_get_timer()
call. It might be worth adding a specific system call that implementswfi
instead.This is my first exposure to RISC-V so it's highly likely I've misunderstood things or missed optimisations, but hopefully this will at least provide a starting point for the conversation.
If you'd like me to submit a PR with this work then just let me know, otherwise I'll continue adding support for interrupts, GPIO, etc, as well as looking at RISC-V support in Humility which I've sorely missed during bring-up!
Beta Was this translation helpful? Give feedback.
All reactions