向静态内核模块发送参数的方法

Ways of sending parameters to static kerenel module

我可以找到 module_param 来为内核模块(我猜是可加载模块)发送参数。 module_param 是否可以用于将参数发送到静态模块(用kerenel 编译)。

请告诉我静态模块定义发送参数的方法。 (如果可能,请提供更多详细信息) 非常感谢您的宝贵时间。

对于内核映像中内置的模块,将您的模块自定义参数添加到内核启动参数列表中。该列表将(取决于体系结构)由引导加载程序传递或内置到内核中。

它将看起来像这样:

mymod.fooparam=debug

有关参考,请参阅 kernel-params documentation

您在模块中定义参数的方式与动态加载模块的方式相同。

编辑:本文来自:arch/arm/Kconfig 您可以通过基于构建选项生成的 .config 文件来设置 cmdline。

config CMDLINE
        string "Default kernel command string"
        default ""
        help
          On some architectures (EBSA110 and CATS), there is currently no way
          for the boot loader to pass arguments to the kernel. For these
          architectures, you should supply some command-line options at build
          time by entering them here. As a minimum, you should specify the
          memory size and the root device (e.g., mem=64M root=/dev/nfs).

choice
        prompt "Kernel command line type" if CMDLINE != ""
        default CMDLINE_FROM_BOOTLOADER

config CMDLINE_FROM_BOOTLOADER
        bool "Use bootloader kernel arguments if available"
        help
          Uses the command-line options passed by the boot loader. If
          the boot loader doesn't provide any, the default kernel command
          string provided in CMDLINE will be used.

config CMDLINE_EXTEND
        bool "Extend bootloader kernel arguments"
        help
          The command-line arguments provided by the boot loader will be
          appended to the default kernel command string.

config CMDLINE_FORCE
        bool "Always use the default kernel command string"
        help
          Always use the default kernel command string, even if the boot
          loader passes other arguments to the kernel.
          This is useful if you cannot or don't want to change the
          command-line options your boot loader passes to the kernel.
endchoice