aboutsummaryrefslogtreecommitdiff
path: root/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* Ensure the right optimitzation level on DEBUGMiquel Sabaté Solà2024-12-021-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Simplify the qemu target by removing QEMU_BIOSMiquel Sabaté Solà2024-11-301-5/+0
| | | | | | | | | | | | | | The QEMU_BIOS parameter was meant to help on old QEMU installations which did not support the proper fw_dynamic workflow. That being said, old QEMU versions might also not implement the proper SBI specification, or it may have other unexpected issues. Hence, just remove the option and force people to have a sufficiently recent QEMU version. Finally, I have updated the SVG showing off a QEMU run. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Fix gdb target by not removing ELF executableMiquel Sabaté Solà2024-11-291-1/+0
| | | | | | | | GDB actually needs the ELF executable to run a session with symbols loaded in. Hence, do not remove the `fbos.elf` file after calling `objcopy`. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Allow the kernel to run as a Linux imageMiquel Sabaté Solà2024-11-291-8/+16
| | | | | | | | | | | | | | | | | | 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>
* Use mktemp when generating the archiveMiquel Sabaté Solà2024-11-271-7/+5
| | | | | | | | | | | Instead of manually making a temporary directory, do it through 'mktemp', which feels cleaner. Moreover, the base directory will now by named 'fbos' instead of the cryptic 'tmp' one. This is quite relevant when you uncompress the archive into another machine. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Move initrd.c into libMiquel Sabaté Solà2024-11-261-1/+1
| | | | | | | | Even if it's tightly coupled with the kernel (e.g. identifying specific tasks from the kernel), in the end it's a library and so it should be placed accordingly. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Move string.S to the lib directoryMiquel Sabaté Solà2024-11-261-1/+1
| | | | | | | It was weird enough to have it in the 'kernel' directory, as it's way more fitting to have it on 'lib'. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add a make target for producing a release archiveMiquel Sabaté Solà2024-11-251-8/+22
| | | | Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* tests: Only test initrd addresses on debugMiquel Sabaté Solà2024-11-251-1/+1
| | | | | | | | | | | | | | | | In initrd tests, and in general, we only need to check that the function did something. As in, that it set the entry addresses somewhere and did not leave them NULL. This is going to be performed from now on on CI and regular tests. And, just if you want to go the extra mile, we will run specific tests that check on memory addresses but that are not guaranteed to work. This is to be replaced in the future by having some proper debugging output. As in, having a message at kernel boot time specifying the addresses being used among other info. This needs a more complex printk utility, of course. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Simplify scheduling by introducing an init processMiquel Sabaté Solà2024-11-241-1/+1
| | | | | | | | | | | | | | | | 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>
* usr: Rename foo/bar to fizz/buzzMiquel Sabaté Solà2024-11-221-1/+1
| | | | | | | | | | | | When creating the user space binaries I forgot about their proper names, which is funny on its own. Anyways, let's get them the name they were intended. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com> alksjdlkajd Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Initial parsing of the provided initrd fileMiquel Sabaté Solà2024-11-211-8/+10
| | | | | | | | | | | | We expect a CPIO archive with the 'newc' format for the initrd. Parse this archive from the given initrd address and fetch the address for each ELF executable while also pairing which task correspond to which ELF. This commit leaves to do the actual parsing of the ELF file for each task, while also leaving some string utilities to be refined. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* ci: Make the build work for Ubuntu 24.04Miquel Sabaté Solà2024-11-201-2/+2
| | | | | | | | | The binutils used in Ubuntu 24.04 has a crash when trying to link the end binary, which is avoided when passing `-fno-PIE`. Since this is a good idea anyways for the kernel in general, let's pass this flag always and kill two birds with one stone. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Ensure the environment is clean on QEMU launchMiquel Sabaté Solà2024-11-201-4/+4
| | | | | | | | | Since the library code can now be exchanged between tests and the actual kernel, there might be a missmatch when launching QEMU after calling `make all`. Ensure that this cannot happen by calling `clean` on the `qemu` target. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Fetch the initrd address from the DTB blobMiquel Sabaté Solà2024-11-201-19/+39
| | | | | | | | | | The kernel entry has a pointer to the DTB blob as a parameter. From this pointer we can parse the the DTB blob to find the properties "chosen->linux,initrd-start" and "chosen->linux,initrd-start". These properties are guaranteed to have 64-bit addresses which point where the initrd is in memory, which we need to fetch the binaries to be loaded. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Setup the stack for an init taskMiquel Sabaté Solà2024-11-191-7/+7
| | | | | | | | | | | | | | | | | 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>
* usr: Make sure usr/bin/ existsRicardo B. Marliere2024-11-191-0/+1
| | | | | | | | | Fix the following build error on a clean repository: riscv64-suse-linux-ld: cannot open output file usr/bin/foo: No such file or directory Fixes: d79436a1170e ("usr: Bootstrap the initramfs for the kernel") Signed-off-by: Ricardo B. Marliere <rbm@suse.com>
* usr: Bootstrap the initramfs for the kernelMiquel Sabaté Solà2024-11-181-10/+39
| | | | | | | | | Introduce a sample `foo` program which already calls the `write_and_block` system call which is yet to be implemented by this kernel. Moreover, the same CPIO format is used for the initramfs as with Linux, so we can pass it with QEMU without worries. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Load debug symbols on the gdb targetMiquel Sabaté Solà2024-09-241-11/+16
| | | | | | | | | | | Load the debug symbols into the gdb session by simply passing the executable file into gdb directly. Moreover, allow users of the gdb target to provide an extra variable so to pass extra flags to gdb. Moreover, this commit comes with other small cleanups on the Makefile, like a proper ABI specifier, Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add CI jobMiquel Sabaté Solà2024-09-241-2/+6
| | | | | | | This will ensure that the code style is preserved and that commits being pushed at least build successfully. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Bootstrap the projectMiquel Sabaté Solà2024-08-241-0/+90
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>