t-crest / patmos

Patmos is a time-predictable VLIW processor, and the processor for the T-CREST project
http://patmos.compute.dtu.dk
BSD 2-Clause "Simplified" License
134 stars 72 forks source link

Making the ISPM work on all cores using the bootloader #154

Open Emoun opened 4 weeks ago

Emoun commented 4 weeks ago

We currently have the issue of the instruction scratchpad (ISPM) not working on non-main cores.

It works on the main core by the bootloader reading the downloaded ELF and putting anything that is in the .text.spm section in the ISPM. However, this does not work for other cores since there is no way for the main core to load stuff into other cores' ISPMs, and there is no way for the cores themselves to do it, since they are called using pthreads or coresthread_create.

My idea is to update corethread/pthreads such that they call the bootloader on the other cores instead of the given function. The bootloader will be updated such that if it is not called from the main core, it loads the ISPM then runs the required function. This of course requires an update to the bootloader.

This is not totally fleshed out, but I think it would be a good way to use existing functionality in the bootloader to give us access to the ISPMs on non-main cores.

Emoun commented 4 weeks ago

An alternative is to add functionality to the bootloader that calls a bootloader-function on eacher non-main core, whose only job is to load the ISPM. The core then goes back to sleep. This would mean all cores' ISPM are loaded from the beginning and corethread/pthreads does not need to know about the bootloader.

schoeberl commented 4 weeks ago

Thanks for looking into this. Let us think about it when there is a need. This is very brittle anyway, as one needs to decide which functions shall be on which core. I do not think we want to have the very same function in all core's ISPMs.

Emoun commented 4 weeks ago

I've just opened this issue to write down my ideas. No plan to actually do any of this yet.

I've also thought about what goes in each core's ISPM. We could also allow additional core-specific section, like .text.spm.0, .text.spm.1. This would give us a section for all cores (.text.spm) and individual sections, though how exactly to map this in memory is an open question.

schoeberl commented 4 weeks ago

A maybe not so trivial issue is that all ISPMs are mapped to the same address. Can we have several functions in the .elf file that are mapper to the same address?

Emoun commented 4 weeks ago

I think it is possible in ELF to have sections referencing the same addresses. Though I have no experience with this, so maybe this is a misunderstanding of mine. We'll need to explore and test more.