aboutsummaryrefslogtreecommitdiff
path: root/kernel/head.S
Commit message (Collapse)AuthorAgeFilesLines
* Share the same stack everywhereMiquel Sabaté Solà2024-12-021-3/+5
| | | | | | | | | | As documented in the code, we are not implementing any kind of memory protection, so in theory any process (regardless if running in user or kernel space) would be able to tamper with other processes' stack. Hence, don't even pretend that we are separating stacks and share the same global stack everywhere. This simplifies things a bit. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Prepend the name of the task on debugMiquel Sabaté Solà2024-12-021-3/+3
| | | | | | | | | 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-1/+3
| | | | | | | | 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>
* Allow the kernel to run as a Linux imageMiquel Sabaté Solà2024-11-291-0/+52
| | | | | | | | | | | | | | | | | | In order to run on real hardware, it's actually easier to re-use workflows from existing bootloaders than loading things in memory manually. In order to achieve this two things had to be settled: 1. The image has to have a Linux header as defined in the RISC-V port. This header will be taken into consideration by bootloaders in order to know where to jump, the image offset, the endianness of the image, etc. 2. The image cannot just be an ELF executable. Rather, we must translate it into binary form via `objcopy`. With all of this at hand, I was able to make the kernel run on a Starfive VisionFive 2 board, and I have recorded an example so it's available as documentation. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Enable the timer from the SBI interfaceMiquel Sabaté Solà2024-11-221-0/+4
| | | | | | | | 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>
* Add basic parsing for underlying ELF executablesMiquel Sabaté Solà2024-11-221-2/+2
| | | | | | | | | | | | | The given initrd is a CPIO archive of multiple ELF executables. We are already able to parse the CPIO archive to detect where each file is located, this commit adds the mapping for each ELF executable to the corresponding task_struct. Note that this is still heavily under construction, since we cannot simply jump into the entry point of an executable as we have not yet setup the proper layout from performing context switches. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Setup the stack for an init taskMiquel Sabaté Solà2024-11-191-3/+52
| | | | | | | | | | | | | | | | | Bootstrap an init task which holds at least the initial stack that is to be used when setting up the registers (such as `sp` and `tp`). In order to guarantee that the stack and the rest of the registers are set up correctly, this commit also provides a raw implementation of a `printk` function. Moreover, this commit also adds an argument that must be passed to `start_kernel`, which is the pointer to the embedded `fdt` blob. This argument will be used by later work so to fetch, at least, the base address for the initial ram disk. This was also used to test that the stack was working as expected. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Bootstrap the projectMiquel Sabaté Solà2024-08-241-0/+6
For now the base layout has been defined and we have a binary that is properly reached through openSBI. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>