discord: tref#6771 |
matrix: @tref:amber.tel


froggie
@froggie

I got Linux running INSIDE Team Fortress 2 VScript by writing a RISC-V implementation in Squirrel.

Thanks to cnlohr for the original mini-rv32ima project!

This is basically just a raw port of mini-rv32ima to Squirrel3. Rather annoying as Squirrel has no fixed/small size or unsigned types. So we have to emulate all of that and all the logic for it is 'fun'. We map the player_say game event to map player text to the UART interface.

It supports basically everything you could ever want, but do not consider it in any way conformant. It can boot the Linux kernel, run coremark, run sha256sum and get a correct results, etc. It can even shutdown with halt -f and it actually shuts down the risc-v computer and cleans up the entity responsible for the Think function.

I was very close to giving up many times writing this code. Luckily mini-rv32ima has a single-step register dump mode. All of the debugging was done via enabling single-step, and a fixed elapsed_us and diff-ing the single-step outputs to see where we diverge.

Special thanks to cnlohr for nerdsniping me with this tiny rv32 implementation I was very surprised how understandable it was, and how little it takes to have a rv32 implementation capable of actually being usable!

This code was all made in a tea-infused 6 hour coding session.


You must log in to comment.

in reply to @froggie's post: