-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move cpu reboot addr register to separate platform independent object #7
base: master
Are you sure you want to change the base?
Conversation
Remove unused addr register
The "addr" register is used to allow you to change the reset address of the CPU. For example, when debugging an .ELF file using the VexRiscv debug channel, the first thing openocd does is reset the CPU. If we didn't adjust the reset address, it would jump back to address 0, and the user would start to debug the bootloader. By adjusting the CPU reset address prior to jumping to the user's code, this behavior works as expected. A comment to this effect might be helpful, since it's not the most obvious of reasons. But we definitely should leave it in. |
Thanks, how about this? I want to separate the chip specific stuff from the common stuff. |
That works, and is much nicer asthetically! The downside I see now is that with this patch, the addresses have suddenly changed and now new software is no longer compatible with the RISC-V CPUs that are in the wild. Maybe this is a good case for adding a jump table for drivers at a known-good offset that can give us platform independence. |
I think you're suggesting we designate a set of per platform software drivers to abstract the hardware and access them through a jump table or swi mechanism? Sounds do-able. I've realised I've missed the point a little, that fomu is presented to its customers as a update to tomu, as both a cpu platform and a fpga platform. So yes, it would seem like we need to better define the cpu platform if we want both platform independence and binary api backward compatibility. |
I was having a chat with @mithro, and the idea came up to use a thunked syscall interface. The idea being that you'd have a function at a well-known address, or an address defined in a LiteX CSR, or an address defined in a RISC-V MSR, that has a function signature such as: int syscall(uint32_t family, uint32_t syscall, uint32_t arg1, void *arg2); ...or similar. Maybe the params would be different. But we'd define syscall('syst', 'boot', 0x20040000, NULL); Because the boot ROM is currently always memory-mapped, we could fix it at address 0x100, so any machine-level program could cast that value to a function pointer and make syscalls. Then, as part of the BIOS for various platforms, you'd implement __attribute__((section(".text.syscall")))
int syscall(uint32_t family, uint32_t call, uint32_t arg1, void *arg2) {
switch (family) {
case 'syst':
return do_syst(call, arg1, arg2);
default:
return -EIMPL;
}
}
static int do_syst(uint32_t call, uint32_t arg1, void *arg2) {
switch (family) {
case 'boot':
return do_reboot(arg1);
default:
return -EIMPL;
}
} |
Moving the conversation to #9 perhaps this PR should move to a new |
I'm not sure this has any purpose so I'm suggesting we remove it.