Open rellermeyer opened 10 years ago
I'm willing to work on this.
Do you mean something like a command line prompt for the OS, or arguments given at "VersatilePB" prompt?
Sorry, I missed this one. The former would be a shell to me, I am thinking something else, the arguments passed to qemu and/or the bootloader. E.g., in Linux that would be the "root=..." etc.
I added basic argument parsing functionality (it will be later expanded) with commit d617f8f451593cac267115fb7206def47ef76849. I'm still trying to find a way to correctly pass arguments to the kernel via QEMU (perhaps -append ARGS is what I'm looking for). Do arguments from -append ARGS get passed to start()?
I don't think so. Maybe you find documentation where Linux gets them from. It should happen in Linux' init/main.c file.
I've looked through the Linux source code and I've been trying to understand how kernel parameters are read. This is my understanding:
From main.c, start_kernel() calls setup_arch() in arch/arm/kernel/setup.c, which calls which calls setup_machine_tags() in arch/arm/kernel/atags_parse.c. setup_machine_tags() copies a variable called "from" to boot_command_line. I think "from" is set by a function that mdesc has a function pointer to.
Here's where I'm stumped: setup_machine_tags() has struct machine desc called "mdesc" that is set to a variable named "p". Unfortunately, I can't find a struct machine desc called "p".
Here's the part in question:
http://lxr.free-electrons.com/source/arch/arm/kernel/atags_parse.c#L196
Am I going in the right direction, or is there a better way?
I seemed to be blocked by this. Now that the test is over, am I moving in the right direction? I still can't figure out how to obtain the kernel arguments.
The bootloader should pass you a parameter list in R2: https://www.kernel.org/doc/Documentation/arm/Booting
I pushed some minor changes so that you now get the start address of the parameter list as the first argument in start.c
The current implementation simply prints them to the screen. I guess that should give you what you need.
Here is some more information about the tagged list format. I guess all we need at the moment is the content of the ATAG_CMDLINE tag, all others can be skipped over.
http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html#ATAG_CORE
I added a function to read ATAG_CMDLINE in b6ab304f4a0e47d228248f9696b787eb7bba2b18. However, I tried adding -append "option=value" to the qemu command, but "option=value" doesn't appear in ATAG_CMDLINE. Is this the right way to pass arguments through qemu?
Once we have more of the kernel up and running we might want to pass arguments to it, e.g., to selectively load user processes. Therefore, we need an argument parser.