aboutsummaryrefslogtreecommitdiff
path: root/kernel/trap.c
Commit message (Collapse)AuthorAgeFilesLines
* Move documentation to the proper placesMiquel Sabaté Solà2024-12-041-0/+5
| | | | | | | | | Code documentation was scattered between header and source files. Since the norm was already to have this documentation into header files, move some comments from source files to their header counterparts. This hopefully makes things more consistent. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Prepend the name of the task on debugMiquel Sabaté Solà2024-12-021-5/+5
| | | | | | | | | On 'printk' and 'sys_write' calls, prepend the name of the task that is being executed for each message. This is an easy way to show off that we are doing the right thing with the 'tp' register, even if we don't do much with it. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Document what we mean by scheduling on this kernelMiquel Sabaté Solà2024-11-301-4/+17
| | | | | | | | The notion of 'scheduling' a process on this kernel is effectively the same as starting the process anew. This is pretty bananas for any general purpose kernel, but this is not our case. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Rename 'switch_to' to 'set_return_address_to'Miquel Sabaté Solà2024-11-301-5/+4
| | | | | | | | The original name came from a previous hack the did not work but somehow the old name remained. Now it was more misleading than anything else, so let's rename it to something that is closer to what it actually does. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* dt: Fetch the CPU frequency as wellMiquel Sabaté Solà2024-11-261-9/+2
| | | | | | | | | | | If the 'timebase-frequency' property is available under the 'cpus' node from the DTB blob, it makes sense to try to fetch this value from there instead of hardcoding it. For other use-cases, where this information is not available through DT (e.g. ACPI on the VisionFive2 board), we will have to hardcode it with a default value even if it's not the proper one. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Simplify scheduling by introducing an init processMiquel Sabaté Solà2024-11-241-9/+10
| | | | | | | | | | | | | | | | Scheduling is easier if there is an init process which does nothing. This way we don't have to perform hacks in order to idle in S privilege mode while touching special registers in weird ways. For now this process is kind of costly since 'wfi' is not accepted in this context, but this can be further tuned down in the future by setting TW=1 on 'mstatus', or by handling the exception and allowing it if it comes from the proper process. All of that being said, there is still work to be done as things fail when optimitzations are on. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Enable exception handling from user modeMiquel Sabaté Solà2024-11-221-7/+36
| | | | | | | | This allows us to actually catch system calls and start to run user space programs. That being said, the whole thing is still pretty brittle, and the scheduler is not quite there yet. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Enable the timer from the SBI interfaceMiquel Sabaté Solà2024-11-221-0/+125
A basic interrupt handler has been implemented which tracks the seconds that have been elapsing along the way. Depending on the value of these seconds, then a task has to be called. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>