Hi Martin,
Preface: all of my knowledge is up to Priv 1.9, so I apologize if I'm wrong or out-of-date (or if I missed your question entirely).
So I think the challenge here is you are describing tethered executions of RISC-V systems (spike, Sodor, etc.). There needs to be some mechanism for executing things like "print this to screen" and "end test with exit code" between the RISC-V design-under-test (DUT) and the host machine (riscv-fesvr).
> * Assembler tests (old, from Sodor?) use x28 with
> 1 as a notion of pass and 2 as a notion to fail.
The pre-priv1.9 days had no External Debug spec, so the magic connection between the RISC-V DUT and the host machine was the host-target interface (HTIF). HTIF provided special CSRs -- tohost and fromhost -- to manage communications between the tethered DUT and the host (riscv-fesvr). Tests ended with the host received a 1 to signify a pass.
The assembler test use riscv-tests-envs (a repo on github/riscv) to provide macros to write abstracted tests. Priv v1.7 Rocket/Sodor tests ended with a write to the HTIF tohost CSR.
Now that we have an External Debug spec, the non-standard HTIF has been removed and the Debug spec is used in its place. The "end test" macros in riscv-tests-env now write "tohost" values to a cached memory location, and the Debug Transport Module (DTM) will periodically read the value at the tohost location looking for a non-zero value.
> * In a (newlib) compiled C program clib functions (such as file IO) call
> `__internal_syscall`, which itself (after rotation of registers `a0`-`a7`)
> executes `ecall`. Does this go to the proxy kernel (pk)?
IIRC, the syscalls will get handled by some kernel (including the proxy kernel); than that kernel may kick into proxied routines where it sends the syscall to the host machine (riscv-fesvr) to handle them (printfs for example). In the past (and maybe currently too) this was handled by the tohost register as well. Since proxied syscalls are handled by reading the arguments from an aligned memory address, the lower bit 0 is always 0. Thus, the value tohost[0]==0 means "proxied syscall" and tohost[0]==1 means "end the test" with tohost[N-1:1] holding the exit code.
> * What else in ecall is implemented in spike?
Spike is executed as a tethered DUT, with the riscv-fesvr compiled into it. The code, syscalls.c I think, would answer this question better than I could.
> * ISA test cases start at 0x80000000 with a `_start` symbol
> * An assembler program linked with `.start` at 0x8000000 is executed by spike.
> However, spike starts at 0x1000 and executes 5 boostrap instructions.
> Assume those are hardcoded into spike.
The memory map for spike/Rocket-chip has the high-order bit set to 1 to represent "physical memory". This does slightly confuse things like elf2hex that are expecting to to spit out contiguous memory starting at 0x0.
The memory map also puts 0x0 as debug memory and 0x1000 as bootrom memory (at least on my copy of BOOM on priv1.9):
debug {
addr 0x0;
size 0x1000;
}
bootrom {
addr 0x1000;
size 0x1000;
}
So you're assessment is correct on the bootstrapping. For Rocket running its riscv-tests in a tethered mode, the booting process will involve loading the test binary using the DTM before it can jump to _start.
> * Compiling a C program (with newlib) has a start address (`_start`) at 0x00010074.
> Assume that the proxy kernel is loaded at 0x8000000 and simply gets the start address from
> the .elf file.
Yup. The memory map spike/rocket uses is designed with processors with VM translation in mind, and you can change it for your bare-metal cores as you see fit. Relatedly, Sodor has recently been updated to the latest priv 1.10 spec and debug spec, and it uses the spike memory map.
-Chris
> --
> You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
sw-dev+un...@groups.riscv.org.
> To post to this group, send email to
sw-...@groups.riscv.org.
> Visit this group at
https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
> To view this discussion on the web visit
https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/0A399C69-5B0A-423D-8300-39D55B0F359C%40jopdesign.com.