Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Can I pass arguments to my new kernel via the UART chainloader #130

Discussion options

Hi All,

I would like to be able to pass the pointer to the DTB that the RPI4 bootloader passes to the kernel through the UART chainloader.

I.E. I would like to be able to do this inside of the chainloader after we've copied the new kernel into memory:

let kernel: extern "C" fn(pointer: u64) -> ! = unsafe { core::mem::transmute(kernel_addr) };
kernel(dtb_pointer)

I'm fairly sure I know how to get the pointer into Rust as it is passed to the kernel via the x0 register by the bootloader - however I'm not certain if I can generate an extern "C" function on the RPI4 and what registers the arguments I pass to it will end up in.

Does anyone have any knowledge on the calling conventions on the RPI and if I'm making this more complicated than it needs to be?

You must be logged in to vote

Your approach should work, extern C will follow the AArch64 calling convention, which means the chainloaded kernel will find dtb_pointer in x0 when it starts to run in its own _start in boot.s.

Replies: 2 comments

Comment options

Your approach should work, extern C will follow the AArch64 calling convention, which means the chainloaded kernel will find dtb_pointer in x0 when it starts to run in its own _start in boot.s.

You must be logged in to vote
0 replies
Answer selected by andre-richter
Comment options

Great thank you for the quick feedback, always good to know my intuition serves me well - appreciate all the hard work you've put into these tutorials, they have been very useful!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /