Reputation: 1721
I'm new at kernel programming and trying to do a "Hello World" example. I added the following code to init/main.c in start_kernel()
#ifdef HELLO
printk("Hello World");
#endif
Now to my question. How do i define HELLO in the boot parameters using qemu?
Upvotes: 0
Views: 1410
Reputation: 88801
You need to define HELLO
at compile time, (either with -DHELLO
as a compiler flag or #define HELLO
somewhere), otherwise the compiler never even sees the printk
call and no code for it gets emitted.
You can't make the C compiler get re-run at early stage boot time based on the boot parameters, which is what you'd need to do to change HELLO
there.
The kernel is no different than any other C program in this respect - preprocessor directives are handled really early on in compilation.
You can setup parameters with this helper macro that are a regular variable that can be set a boot and tested at runtime (not compile time) with a plain old if
statement.
Upvotes: 1