cirosantilli / linux-kernel-module-cheat

The perfect emulation setup to study and develop the Linux kernel v5.4.3, kernel modules, QEMU, gem5 and x86_64, ARMv7 and ARMv8 userland and baremetal assembly, ANSI C, C++ and POSIX. GDB step debug and KGDB just work. Powered by Buildroot and crosstool-NG. Highly automated. Thoroughly documented. Automated tests. "Tested" in an Ubuntu 24.04 host.
https://cirosantilli.com/linux-kernel-module-cheat
GNU General Public License v3.0
4.21k stars 605 forks source link

Baremetal command line arguments #67

Closed cirosantilli closed 4 years ago

cirosantilli commented 5 years ago

We currently just set argc to 0 on the bootloaders before calling main. This is particularly interesting because we can run several userland examples on baremetal.

Maybe this will be easy on QEMU with -device loader which according to docs supports direct data memory mapping: https://github.com/qemu/qemu/blob/60905286cb5150de854e08279bca7dfc4b549e91/docs/generic-loader.txt

This mechanism would be analogous to kernel CLI parameters and DTB, and would therefore allow us to have a single binary that works on either QEMU or gem5, just like the Linux kernel does! We just have to pass CLI arguments that describe the hardware!