Skip to content
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

Turn the standalone kernel into a library #697

Merged
merged 5 commits into from
Jan 1, 2021
Merged

Conversation

tomaka
Copy link
Owner

@tomaka tomaka commented Jan 1, 2021

Close #689

Before this PR, the standalone kernel is cross-platform. It uses only the build target (e.g. x86_64-unknown-multiboot2) to determine which environment to expect, and documents it.
The kernel also assumes that the linker will provide the __bss_start and __bss_end symbols. Again, this is documented.

After this PR, the standalone kernel is no longer a binary but a library. It provides a macro called __gen_boot! that generates the code necessary to boot the kernel. The difference compared to now is that this macro can be passed more parameters than just the target, which will result in less guessing.
For example, the __bss_start and __bss_end symbols are now explicitly provided as parameters to the macro.
The user, here the standalone kernel builder, at the same time passes these symbols and ensures that they indeed exist, therefore resulting in less magic.

The intention behind this PR to later make it possible for the standalone kernel builder to parse a DeviceTree file, pass the appropriate memory ranges and CPUs count to the macro, and make sure that the appropriate drivers are included in the kernel. cc #283

The other intention is to make it possible for the standalone kernel builder to generate test kernels that just boot, test something, and shut down. Again, this is possible thanks to the fact that the kernel is passed everything instead of guessing what its environment is.

Another side effect is that in the future the standalone kernel builder can be truly standalone and fetch the kernel from crates.io. It would simply be a CLI program, which you can cargo install. You pass some parameters, and boom you get a kernel. No need to actually clone the source code.

@tomaka
Copy link
Owner Author

tomaka commented Jan 1, 2021

Just like #692, this broke the x86_64 kernel. Still investigating.

@tomaka tomaka added the automerge PRs with this label automatically get merged once they pass CI label Jan 1, 2021
@mergify mergify bot merged commit 489f892 into develop Jan 1, 2021
@mergify mergify bot deleted the library-standalone branch January 1, 2021 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge PRs with this label automatically get merged once they pass CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Turn standalone kernel into a library
1 participant